@dxos/client-services 0.8.1 → 0.8.2-main.12df754

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 (36) hide show
  1. package/dist/lib/browser/{chunk-MHDASPY5.mjs → chunk-GCPSASQQ.mjs} +59 -69
  2. package/dist/lib/browser/chunk-GCPSASQQ.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/meta.json +1 -1
  5. package/dist/lib/browser/testing/index.mjs +1 -1
  6. package/dist/lib/node/{chunk-A2WCOW6P.cjs → chunk-BAW7EMSB.cjs} +231 -241
  7. package/dist/lib/node/chunk-BAW7EMSB.cjs.map +7 -0
  8. package/dist/lib/node/index.cjs +47 -47
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +8 -8
  11. package/dist/lib/node-esm/{chunk-SK52YZK7.mjs → chunk-NDJKR4OF.mjs} +59 -69
  12. package/dist/lib/node-esm/chunk-NDJKR4OF.mjs.map +7 -0
  13. package/dist/lib/node-esm/index.mjs +1 -1
  14. package/dist/lib/node-esm/meta.json +1 -1
  15. package/dist/lib/node-esm/testing/index.mjs +1 -1
  16. package/dist/types/src/packlets/agents/edge-agent-service.d.ts +1 -1
  17. package/dist/types/src/packlets/agents/edge-agent-service.d.ts.map +1 -1
  18. package/dist/types/src/packlets/devices/devices-service.d.ts.map +1 -1
  19. package/dist/types/src/packlets/network/network-service.d.ts +3 -1
  20. package/dist/types/src/packlets/network/network-service.d.ts.map +1 -1
  21. package/dist/types/src/packlets/services/service-host.d.ts.map +1 -1
  22. package/dist/types/src/packlets/spaces/edge-feed-replicator.d.ts.map +1 -1
  23. package/dist/types/src/version.d.ts +1 -1
  24. package/dist/types/src/version.d.ts.map +1 -1
  25. package/package.json +38 -38
  26. package/src/packlets/agents/edge-agent-service.ts +8 -11
  27. package/src/packlets/devices/devices-service.ts +5 -3
  28. package/src/packlets/identity/identity.test.ts +9 -6
  29. package/src/packlets/network/network-service.ts +9 -15
  30. package/src/packlets/services/service-host.ts +5 -1
  31. package/src/packlets/spaces/edge-feed-replicator.test.ts +2 -1
  32. package/src/packlets/spaces/edge-feed-replicator.ts +2 -1
  33. package/src/version.ts +1 -5
  34. package/dist/lib/browser/chunk-MHDASPY5.mjs.map +0 -7
  35. package/dist/lib/node/chunk-A2WCOW6P.cjs.map +0 -7
  36. package/dist/lib/node-esm/chunk-SK52YZK7.mjs.map +0 -7
@@ -397,7 +397,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
397
397
  import { TRACE_PROCESSOR } from "@dxos/tracing";
398
398
 
399
399
  // packages/sdk/client-services/src/version.ts
400
- var DXOS_VERSION = "0.8.1";
400
+ var DXOS_VERSION = "0.8.2-main.12df754";
401
401
 
402
402
  // packages/sdk/client-services/src/packlets/services/platform.ts
403
403
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -817,6 +817,7 @@ import { log as log4, logInfo } from "@dxos/log";
817
817
  import { EdgeService } from "@dxos/protocols";
818
818
  import { buf } from "@dxos/protocols/buf";
819
819
  import { MessageSchema as RouterMessageSchema } from "@dxos/protocols/buf/dxos/edge/messenger_pb";
820
+ import { EdgeStatus } from "@dxos/protocols/proto/dxos/client/services";
820
821
  import { ComplexMap as ComplexMap2, arrayToBuffer, bufferToArray, defaultMap, rangeFromTo } from "@dxos/util";
821
822
  function _ts_decorate(decorators, target, key, desc) {
822
823
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -907,7 +908,7 @@ var EdgeFeedReplicator = class extends Resource {
907
908
  async _open() {
908
909
  log4("open", void 0, {
909
910
  F: __dxlog_file6,
910
- L: 56,
911
+ L: 57,
911
912
  S: this,
912
913
  C: (f, a) => f(...a)
913
914
  });
@@ -926,7 +927,7 @@ var EdgeFeedReplicator = class extends Resource {
926
927
  _spaceId: this._spaceId
927
928
  }, {
928
929
  F: __dxlog_file6,
929
- L: 70,
930
+ L: 71,
930
931
  S: this,
931
932
  C: (f, a) => f(...a)
932
933
  });
@@ -939,7 +940,7 @@ var EdgeFeedReplicator = class extends Resource {
939
940
  type: payload.type
940
941
  }, {
941
942
  F: __dxlog_file6,
942
- L: 75,
943
+ L: 76,
943
944
  S: this,
944
945
  C: (f, a) => f(...a)
945
946
  });
@@ -951,14 +952,14 @@ var EdgeFeedReplicator = class extends Resource {
951
952
  }
952
953
  async _handleReconnect() {
953
954
  await this._resetConnection();
954
- if (this._messenger.isConnected) {
955
+ if (this._messenger.status === EdgeStatus.CONNECTED) {
955
956
  this._startReplication();
956
957
  }
957
958
  }
958
959
  async _close() {
959
960
  log4("close", void 0, {
960
961
  F: __dxlog_file6,
961
- L: 95,
962
+ L: 96,
962
963
  S: this,
963
964
  C: (f, a) => f(...a)
964
965
  });
@@ -970,7 +971,7 @@ var EdgeFeedReplicator = class extends Resource {
970
971
  this._connectionCtx = connectionCtx;
971
972
  log4("connection context created", void 0, {
972
973
  F: __dxlog_file6,
973
- L: 103,
974
+ L: 104,
974
975
  S: this,
975
976
  C: (f, a) => f(...a)
976
977
  });
@@ -983,7 +984,7 @@ var EdgeFeedReplicator = class extends Resource {
983
984
  async _resetConnection() {
984
985
  log4("resetConnection", void 0, {
985
986
  F: __dxlog_file6,
986
- L: 112,
987
+ L: 113,
987
988
  S: this,
988
989
  C: (f, a) => f(...a)
989
990
  });
@@ -999,7 +1000,7 @@ var EdgeFeedReplicator = class extends Resource {
999
1000
  hasConnectionCtx: !!this._connectionCtx
1000
1001
  }, {
1001
1002
  F: __dxlog_file6,
1002
- L: 120,
1003
+ L: 121,
1003
1004
  S: this,
1004
1005
  C: (f, a) => f(...a)
1005
1006
  });
@@ -1016,7 +1017,7 @@ var EdgeFeedReplicator = class extends Resource {
1016
1017
  key: feed.key
1017
1018
  }, {
1018
1019
  F: __dxlog_file6,
1019
- L: 133,
1020
+ L: 134,
1020
1021
  S: this,
1021
1022
  C: (f, a) => f(...a)
1022
1023
  });
@@ -1032,7 +1033,7 @@ var EdgeFeedReplicator = class extends Resource {
1032
1033
  if (!this._connectionCtx) {
1033
1034
  log4("message dropped because connection was disposed", void 0, {
1034
1035
  F: __dxlog_file6,
1035
- L: 146,
1036
+ L: 147,
1036
1037
  S: this,
1037
1038
  C: (f, a) => f(...a)
1038
1039
  });
@@ -1044,14 +1045,14 @@ var EdgeFeedReplicator = class extends Resource {
1044
1045
  blocks: message.blocks.map((b) => b.index)
1045
1046
  }, {
1046
1047
  F: __dxlog_file6,
1047
- L: 151,
1048
+ L: 152,
1048
1049
  S: this,
1049
1050
  C: (f, a) => f(...a)
1050
1051
  });
1051
1052
  }
1052
1053
  invariant2(message.feedKey, void 0, {
1053
1054
  F: __dxlog_file6,
1054
- L: 157,
1055
+ L: 158,
1055
1056
  S: this,
1056
1057
  A: [
1057
1058
  "message.feedKey",
@@ -1063,7 +1064,7 @@ var EdgeFeedReplicator = class extends Resource {
1063
1064
  type: message.type
1064
1065
  }, {
1065
1066
  F: __dxlog_file6,
1066
- L: 160,
1067
+ L: 161,
1067
1068
  S: this,
1068
1069
  C: (f, a) => f(...a)
1069
1070
  });
@@ -1082,7 +1083,7 @@ var EdgeFeedReplicator = class extends Resource {
1082
1083
  if (!this._connectionCtx) {
1083
1084
  log4.warn("received message after connection context was disposed", void 0, {
1084
1085
  F: __dxlog_file6,
1085
- L: 175,
1086
+ L: 176,
1086
1087
  S: this,
1087
1088
  C: (f, a) => f(...a)
1088
1089
  });
@@ -1100,7 +1101,7 @@ var EdgeFeedReplicator = class extends Resource {
1100
1101
  feedKey
1101
1102
  }, {
1102
1103
  F: __dxlog_file6,
1103
- L: 184,
1104
+ L: 185,
1104
1105
  S: this,
1105
1106
  C: (f, a) => f(...a)
1106
1107
  });
@@ -1116,7 +1117,7 @@ var EdgeFeedReplicator = class extends Resource {
1116
1117
  if (message.length > feed.length) {
1117
1118
  log4("requesting missing blocks", logMeta, {
1118
1119
  F: __dxlog_file6,
1119
- L: 194,
1120
+ L: 195,
1120
1121
  S: this,
1121
1122
  C: (f, a) => f(...a)
1122
1123
  });
@@ -1131,7 +1132,7 @@ var EdgeFeedReplicator = class extends Resource {
1131
1132
  } else if (message.length < feed.length) {
1132
1133
  log4("pushing blocks to remote", logMeta, {
1133
1134
  F: __dxlog_file6,
1134
- L: 202,
1135
+ L: 203,
1135
1136
  S: this,
1136
1137
  C: (f, a) => f(...a)
1137
1138
  });
@@ -1150,7 +1151,7 @@ var EdgeFeedReplicator = class extends Resource {
1150
1151
  blocks: message.blocks.map((b) => b.index)
1151
1152
  }, {
1152
1153
  F: __dxlog_file6,
1153
- L: 211,
1154
+ L: 212,
1154
1155
  S: this,
1155
1156
  C: (f, a) => f(...a)
1156
1157
  });
@@ -1161,7 +1162,7 @@ var EdgeFeedReplicator = class extends Resource {
1161
1162
  feedKey
1162
1163
  }, {
1163
1164
  F: __dxlog_file6,
1164
- L: 216,
1165
+ L: 217,
1165
1166
  S: this,
1166
1167
  C: (f, a) => f(...a)
1167
1168
  });
@@ -1175,7 +1176,7 @@ var EdgeFeedReplicator = class extends Resource {
1175
1176
  ...message
1176
1177
  }, {
1177
1178
  F: __dxlog_file6,
1178
- L: 225,
1179
+ L: 226,
1179
1180
  S: this,
1180
1181
  C: (f, a) => f(...a)
1181
1182
  });
@@ -1190,7 +1191,7 @@ var EdgeFeedReplicator = class extends Resource {
1190
1191
  to
1191
1192
  }, {
1192
1193
  F: __dxlog_file6,
1193
- L: 232,
1194
+ L: 233,
1194
1195
  S: this,
1195
1196
  C: (f, a) => f(...a)
1196
1197
  });
@@ -1200,7 +1201,7 @@ var EdgeFeedReplicator = class extends Resource {
1200
1201
  });
1201
1202
  invariant2(data instanceof Uint8Array, void 0, {
1202
1203
  F: __dxlog_file6,
1203
- L: 237,
1204
+ L: 238,
1204
1205
  S: this,
1205
1206
  A: [
1206
1207
  "data instanceof Uint8Array",
@@ -1228,7 +1229,7 @@ var EdgeFeedReplicator = class extends Resource {
1228
1229
  blocks: blocks.length
1229
1230
  }, {
1230
1231
  F: __dxlog_file6,
1231
- L: 258,
1232
+ L: 259,
1232
1233
  S: this,
1233
1234
  C: (f, a) => f(...a)
1234
1235
  });
@@ -1250,7 +1251,7 @@ var EdgeFeedReplicator = class extends Resource {
1250
1251
  if (!this._remoteLength.has(feed.key)) {
1251
1252
  log4("blocks not pushed because remote length is unknown", void 0, {
1252
1253
  F: __dxlog_file6,
1253
- L: 279,
1254
+ L: 280,
1254
1255
  S: this,
1255
1256
  C: (f, a) => f(...a)
1256
1257
  });
@@ -1275,7 +1276,7 @@ var EdgeFeedReplicator = class extends Resource {
1275
1276
  if (err instanceof EdgeIdentityChangedError || err instanceof EdgeConnectionClosedError) {
1276
1277
  log4("resetting on reconnect", void 0, {
1277
1278
  F: __dxlog_file6,
1278
- L: 296,
1279
+ L: 297,
1279
1280
  S: this,
1280
1281
  C: (f, a) => f(...a)
1281
1282
  });
@@ -1286,7 +1287,7 @@ var EdgeFeedReplicator = class extends Resource {
1286
1287
  }
1287
1288
  }, {
1288
1289
  F: __dxlog_file6,
1289
- L: 290
1290
+ L: 291
1290
1291
  });
1291
1292
  return connectionCtx;
1292
1293
  }
@@ -7646,28 +7647,22 @@ _ts_decorate9([
7646
7647
  // packages/sdk/client-services/src/packlets/agents/edge-agent-service.ts
7647
7648
  import { Stream as Stream11 } from "@dxos/codec-protobuf/stream";
7648
7649
  import { EdgeAgentStatus as EdgeAgentStatus2 } from "@dxos/protocols";
7649
- import { QueryAgentStatusResponse, QueryEdgeStatusResponse } from "@dxos/protocols/proto/dxos/client/services";
7650
+ import { QueryAgentStatusResponse, EdgeStatus as EdgeStatus2 } from "@dxos/protocols/proto/dxos/client/services";
7650
7651
  var EdgeAgentServiceImpl = class {
7651
7652
  constructor(_agentManagerProvider, _edgeConnection) {
7652
7653
  this._agentManagerProvider = _agentManagerProvider;
7653
7654
  this._edgeConnection = _edgeConnection;
7654
7655
  }
7656
+ // TODO(mykola): Reconcile with NetworkService.queryStatus.
7655
7657
  queryEdgeStatus() {
7656
7658
  return new Stream11(({ ctx, next }) => {
7657
- next({
7658
- status: QueryEdgeStatusResponse.EdgeStatus.NOT_CONNECTED
7659
- });
7660
- if (!this._edgeConnection) {
7661
- return;
7662
- }
7663
- ctx.onDispose(
7664
- // TODO(wittjosiah): EdgeConnection should include a disconnected event as well.
7665
- this._edgeConnection.onReconnected(() => {
7666
- next({
7667
- status: QueryEdgeStatusResponse.EdgeStatus.CONNECTED
7668
- });
7669
- })
7670
- );
7659
+ const update = () => {
7660
+ next({
7661
+ status: this._edgeConnection?.status ?? EdgeStatus2.NOT_CONNECTED
7662
+ });
7663
+ };
7664
+ this._edgeConnection?.statusChanged.on(ctx, update);
7665
+ update();
7671
7666
  });
7672
7667
  }
7673
7668
  async createAgent() {
@@ -8659,7 +8654,7 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
8659
8654
  import { SubscriptionList as SubscriptionList3 } from "@dxos/async";
8660
8655
  import { Stream as Stream12 } from "@dxos/codec-protobuf/stream";
8661
8656
  import { invariant as invariant24 } from "@dxos/invariant";
8662
- import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
8657
+ import { Device as Device2, DeviceKind as DeviceKind2, EdgeStatus as EdgeStatus3 } from "@dxos/protocols/proto/dxos/client/services";
8663
8658
  var __dxlog_file31 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
8664
8659
  var DevicesServiceImpl = class {
8665
8660
  constructor(_identityManager, _edgeConnection) {
@@ -8680,7 +8675,7 @@ var DevicesServiceImpl = class {
8680
8675
  } else {
8681
8676
  invariant24(this._identityManager.identity?.presence, "presence not present", {
8682
8677
  F: __dxlog_file31,
8683
- L: 36,
8678
+ L: 37,
8684
8679
  S: this,
8685
8680
  A: [
8686
8681
  "this._identityManager.identity?.presence",
@@ -8695,7 +8690,7 @@ var DevicesServiceImpl = class {
8695
8690
  if (isMe) {
8696
8691
  presence = Device2.PresenceState.ONLINE;
8697
8692
  } else if (profile.os?.toUpperCase() === "EDGE") {
8698
- presence = this._edgeConnection?.isConnected ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8693
+ presence = this._edgeConnection?.status === EdgeStatus3.CONNECTED ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8699
8694
  } else {
8700
8695
  presence = peers.some((peer) => peer.identityKey.equals(key)) ? Device2.PresenceState.ONLINE : Device2.PresenceState.OFFLINE;
8701
8696
  }
@@ -8955,12 +8950,13 @@ var LOG_PROCESSING = 0;
8955
8950
  // packages/sdk/client-services/src/packlets/network/network-service.ts
8956
8951
  import { Stream as Stream15 } from "@dxos/codec-protobuf/stream";
8957
8952
  var NetworkServiceImpl = class {
8958
- constructor(networkManager, signalManager) {
8953
+ constructor(networkManager, signalManager, edgeConnection) {
8959
8954
  this.networkManager = networkManager;
8960
8955
  this.signalManager = signalManager;
8956
+ this.edgeConnection = edgeConnection;
8961
8957
  }
8962
8958
  queryStatus() {
8963
- return new Stream15(({ next }) => {
8959
+ return new Stream15(({ ctx, next }) => {
8964
8960
  const update = () => {
8965
8961
  next({
8966
8962
  swarm: this.networkManager.connectionState,
@@ -8971,13 +8967,9 @@ var NetworkServiceImpl = class {
8971
8967
  }))
8972
8968
  });
8973
8969
  };
8974
- const unsubscribeSwarm = this.networkManager.connectionStateChanged.on(() => update());
8975
- const unsubscribeSignal = this.signalManager.statusChanged?.on(() => update());
8970
+ this.networkManager.connectionStateChanged.on(ctx, () => update());
8971
+ this.signalManager.statusChanged?.on(ctx, () => update());
8976
8972
  update();
8977
- return () => {
8978
- unsubscribeSwarm();
8979
- unsubscribeSignal?.();
8980
- };
8981
8973
  });
8982
8974
  }
8983
8975
  async updateConfig(request) {
@@ -8993,26 +8985,24 @@ var NetworkServiceImpl = class {
8993
8985
  return this.signalManager.query(request);
8994
8986
  }
8995
8987
  subscribeSwarmState(request) {
8996
- return new Stream15(({ next }) => {
8997
- const unsubscribe = this.signalManager.swarmState?.on((state) => {
8988
+ return new Stream15(({ ctx, next }) => {
8989
+ this.signalManager.swarmState?.on(ctx, (state) => {
8998
8990
  if (request.topic.equals(state.swarmKey)) {
8999
8991
  next(state);
9000
8992
  }
9001
8993
  });
9002
- return unsubscribe;
9003
8994
  });
9004
8995
  }
9005
8996
  async sendMessage(message) {
9006
8997
  return this.signalManager.sendMessage(message);
9007
8998
  }
9008
8999
  subscribeMessages(peer) {
9009
- return new Stream15(({ next }) => {
9010
- const unsubscribe = this.signalManager.onMessage.on((message) => {
9000
+ return new Stream15(({ ctx, next }) => {
9001
+ this.signalManager.onMessage.on(ctx, (message) => {
9011
9002
  if (message.recipient.peerKey === peer.peerKey) {
9012
9003
  next(message);
9013
9004
  }
9014
9005
  });
9015
- return unsubscribe;
9016
9006
  });
9017
9007
  }
9018
9008
  };
@@ -9337,7 +9327,7 @@ var ClientServicesHost = class {
9337
9327
  SpacesService: new SpacesServiceImpl(this._serviceContext.identityManager, this._serviceContext.spaceManager, dataSpaceManagerProvider),
9338
9328
  DataService: this._serviceContext.echoHost.dataService,
9339
9329
  QueryService: this._serviceContext.echoHost.queryService,
9340
- NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager),
9330
+ NetworkService: new NetworkServiceImpl(this._serviceContext.networkManager, this._serviceContext.signalManager, this._edgeConnection),
9341
9331
  LoggingService: this._loggingService,
9342
9332
  TracingService: this._tracingService,
9343
9333
  // TODO(burdon): Move to new protobuf definitions.
@@ -9369,7 +9359,7 @@ var ClientServicesHost = class {
9369
9359
  deviceKey
9370
9360
  }, {
9371
9361
  F: __dxlog_file32,
9372
- L: 366,
9362
+ L: 370,
9373
9363
  S: this,
9374
9364
  C: (f, a) => f(...a)
9375
9365
  });
@@ -9377,7 +9367,7 @@ var ClientServicesHost = class {
9377
9367
  id: traceId
9378
9368
  }), {
9379
9369
  F: __dxlog_file32,
9380
- L: 367,
9370
+ L: 371,
9381
9371
  S: this,
9382
9372
  C: (f, a) => f(...a)
9383
9373
  });
@@ -9391,7 +9381,7 @@ var ClientServicesHost = class {
9391
9381
  deviceKey
9392
9382
  }, {
9393
9383
  F: __dxlog_file32,
9394
- L: 378,
9384
+ L: 382,
9395
9385
  S: this,
9396
9386
  C: (f, a) => f(...a)
9397
9387
  });
@@ -9409,7 +9399,7 @@ var ClientServicesHost = class {
9409
9399
  deviceKey
9410
9400
  }, {
9411
9401
  F: __dxlog_file32,
9412
- L: 387,
9402
+ L: 391,
9413
9403
  S: this,
9414
9404
  C: (f, a) => f(...a)
9415
9405
  });
@@ -9420,13 +9410,13 @@ var ClientServicesHost = class {
9420
9410
  id: traceId
9421
9411
  }), {
9422
9412
  F: __dxlog_file32,
9423
- L: 392,
9413
+ L: 396,
9424
9414
  S: this,
9425
9415
  C: (f, a) => f(...a)
9426
9416
  });
9427
9417
  log28.info("resetting...", void 0, {
9428
9418
  F: __dxlog_file32,
9429
- L: 394,
9419
+ L: 398,
9430
9420
  S: this,
9431
9421
  C: (f, a) => f(...a)
9432
9422
  });
@@ -9436,7 +9426,7 @@ var ClientServicesHost = class {
9436
9426
  await this._storage.reset();
9437
9427
  log28.info("reset", void 0, {
9438
9428
  F: __dxlog_file32,
9439
- L: 401,
9429
+ L: 405,
9440
9430
  S: this,
9441
9431
  C: (f, a) => f(...a)
9442
9432
  });
@@ -9444,7 +9434,7 @@ var ClientServicesHost = class {
9444
9434
  id: traceId
9445
9435
  }), {
9446
9436
  F: __dxlog_file32,
9447
- L: 402,
9437
+ L: 406,
9448
9438
  S: this,
9449
9439
  C: (f, a) => f(...a)
9450
9440
  });
@@ -9522,4 +9512,4 @@ export {
9522
9512
  importProfileData,
9523
9513
  ClientServicesHost
9524
9514
  };
9525
- //# sourceMappingURL=chunk-MHDASPY5.mjs.map
9515
+ //# sourceMappingURL=chunk-GCPSASQQ.mjs.map