@dxos/client-services 0.3.3-main.e0ded2e → 0.3.3-main.e5ff429

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.
@@ -69,6 +69,82 @@ var import_services15 = require("@dxos/protocols/proto/dxos/client/services");
69
69
  var import_codec_protobuf = require("@dxos/codec-protobuf");
70
70
  var import_debug = require("@dxos/debug");
71
71
  var import_rpc = require("@dxos/rpc");
72
+ var import_tracing = require("@dxos/tracing");
73
+ function _ts_decorate(decorators, target, key, desc) {
74
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
75
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
76
+ r = Reflect.decorate(decorators, target, key, desc);
77
+ else
78
+ for (var i = decorators.length - 1; i >= 0; i--)
79
+ if (d = decorators[i])
80
+ r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
81
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
82
+ }
83
+ var ClientRpcServer = class ClientRpcServer2 {
84
+ constructor(params) {
85
+ this._handlerCache = /* @__PURE__ */ new Map();
86
+ this._callMetrics = new import_tracing.MapCounter();
87
+ const { serviceRegistry, handleCall, handleStream, ...rpcOptions } = params;
88
+ this._handleCall = handleCall;
89
+ this._handleStream = handleStream;
90
+ this._serviceRegistry = serviceRegistry;
91
+ this._rpcPeer = new import_rpc.RpcPeer({
92
+ ...rpcOptions,
93
+ callHandler: (method, params2) => {
94
+ const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
95
+ const handler = (method2, params3) => this._getServiceHandler(serviceName).call(method2, params3);
96
+ this._callMetrics.inc(`${serviceName}.${methodName} request`);
97
+ if (this._handleCall) {
98
+ return this._handleCall(methodName, params2, handler);
99
+ } else {
100
+ return handler(methodName, params2);
101
+ }
102
+ },
103
+ streamHandler: (method, params2) => {
104
+ const [serviceName, methodName] = (0, import_rpc.parseMethodName)(method);
105
+ const handler = (method2, params3) => this._getServiceHandler(serviceName).callStream(method2, params3);
106
+ this._callMetrics.inc(`${serviceName}.${methodName} request stream`);
107
+ if (this._handleStream) {
108
+ return import_codec_protobuf.Stream.map(import_codec_protobuf.Stream.unwrapPromise(this._handleStream(methodName, params2, handler)), (data) => {
109
+ this._callMetrics.inc(`${serviceName}.${methodName} response stream`);
110
+ return data;
111
+ });
112
+ } else {
113
+ return handler(methodName, params2);
114
+ }
115
+ }
116
+ });
117
+ }
118
+ get _services() {
119
+ return Object.keys(this._serviceRegistry.services);
120
+ }
121
+ async open() {
122
+ await this._rpcPeer.open();
123
+ }
124
+ async close() {
125
+ await this._rpcPeer.close();
126
+ }
127
+ _getServiceHandler(serviceName) {
128
+ if (!this._handlerCache.has(serviceName)) {
129
+ const [key, descriptor] = Object.entries(this._serviceRegistry.descriptors).find(([key2, descriptor2]) => descriptor2.name === serviceName) ?? (0, import_debug.raise)(new Error(`Service not available: ${serviceName}`));
130
+ const service = this._serviceRegistry.services[key];
131
+ if (!service) {
132
+ throw new Error(`Service not available: ${serviceName}`);
133
+ }
134
+ this._handlerCache.set(serviceName, descriptor.createServer(service));
135
+ }
136
+ return this._handlerCache.get(serviceName);
137
+ }
138
+ };
139
+ _ts_decorate([
140
+ import_tracing.trace.metricsCounter()
141
+ ], ClientRpcServer.prototype, "_callMetrics", void 0);
142
+ _ts_decorate([
143
+ import_tracing.trace.info()
144
+ ], ClientRpcServer.prototype, "_services", null);
145
+ ClientRpcServer = _ts_decorate([
146
+ import_tracing.trace.resource()
147
+ ], ClientRpcServer);
72
148
 
73
149
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
74
150
  var import_codec_protobuf2 = require("@dxos/codec-protobuf");
@@ -109,7 +185,7 @@ var getPlatform = () => {
109
185
  };
110
186
 
111
187
  // packages/sdk/client-services/src/version.ts
112
- var DXOS_VERSION = "0.3.3-main.e0ded2e";
188
+ var DXOS_VERSION = "0.3.3-main.e5ff429";
113
189
 
114
190
  // packages/sdk/client-services/src/packlets/services/diagnostics.ts
115
191
  var __dxlog_file = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/diagnostics.ts";
@@ -128,7 +204,7 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
128
204
  {
129
205
  (0, import_invariant.invariant)(clientServices.LoggingService, "SystemService is not available.", {
130
206
  F: __dxlog_file,
131
- L: 88,
207
+ L: 92,
132
208
  S: void 0,
133
209
  A: [
134
210
  "clientServices.LoggingService",
@@ -161,6 +237,11 @@ var createDiagnostics = async (clientServices, serviceContext, config) => {
161
237
  bytes,
162
238
  length
163
239
  }));
240
+ const status = await (0, import_codec_protobuf2.getFirstStreamValue)(clientServices.NetworkService.queryStatus(), {
241
+ timeout: DEFAULT_TIMEOUT
242
+ }).catch(() => void 0);
243
+ diagnostics.networkStatus = status;
244
+ diagnostics.swarms = serviceContext.networkManager.connectionLog?.swarms;
164
245
  }
165
246
  diagnostics.config = config.values;
166
247
  return diagnostics;
@@ -174,7 +255,7 @@ var getProperties = (space) => {
174
255
  } catch (err) {
175
256
  import_log.log.warn(err.message, void 0, {
176
257
  F: __dxlog_file,
177
- L: 145,
258
+ L: 160,
178
259
  S: void 0,
179
260
  C: (f, a) => f(...a)
180
261
  });
@@ -243,7 +324,7 @@ var import_log13 = require("@dxos/log");
243
324
  var import_protocols10 = require("@dxos/protocols");
244
325
  var import_services10 = require("@dxos/protocols/proto/dxos/client/services");
245
326
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
246
- var import_tracing4 = require("@dxos/tracing");
327
+ var import_tracing5 = require("@dxos/tracing");
247
328
  var import_util6 = require("@dxos/util");
248
329
 
249
330
  // packages/sdk/client-services/src/packlets/identity/authenticator.ts
@@ -371,9 +452,9 @@ var import_invariant2 = require("@dxos/invariant");
371
452
  var import_keys2 = require("@dxos/keys");
372
453
  var import_log3 = require("@dxos/log");
373
454
  var import_credentials5 = require("@dxos/protocols/proto/dxos/halo/credentials");
374
- var import_tracing = require("@dxos/tracing");
455
+ var import_tracing2 = require("@dxos/tracing");
375
456
  var import_util = require("@dxos/util");
376
- function _ts_decorate(decorators, target, key, desc) {
457
+ function _ts_decorate2(decorators, target, key, desc) {
377
458
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
378
459
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
379
460
  r = Reflect.decorate(decorators, target, key, desc);
@@ -532,14 +613,14 @@ var Identity = class Identity2 {
532
613
  })));
533
614
  }
534
615
  };
535
- _ts_decorate([
536
- import_tracing.trace.span()
616
+ _ts_decorate2([
617
+ import_tracing2.trace.span()
537
618
  ], Identity.prototype, "open", null);
538
- _ts_decorate([
539
- import_tracing.trace.span()
619
+ _ts_decorate2([
620
+ import_tracing2.trace.span()
540
621
  ], Identity.prototype, "close", null);
541
- Identity = _ts_decorate([
542
- import_tracing.trace.resource()
622
+ Identity = _ts_decorate2([
623
+ import_tracing2.trace.resource()
543
624
  ], Identity);
544
625
 
545
626
  // packages/sdk/client-services/src/packlets/identity/identity-manager.ts
@@ -553,9 +634,9 @@ var import_log4 = require("@dxos/log");
553
634
  var import_protocols3 = require("@dxos/protocols");
554
635
  var import_credentials7 = require("@dxos/protocols/proto/dxos/halo/credentials");
555
636
  var import_timeframe = require("@dxos/timeframe");
556
- var import_tracing2 = require("@dxos/tracing");
637
+ var import_tracing3 = require("@dxos/tracing");
557
638
  var import_util2 = require("@dxos/util");
558
- function _ts_decorate2(decorators, target, key, desc) {
639
+ function _ts_decorate3(decorators, target, key, desc) {
559
640
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
560
641
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
561
642
  r = Reflect.decorate(decorators, target, key, desc);
@@ -911,13 +992,13 @@ var IdentityManager = class IdentityManager2 {
911
992
  });
912
993
  }
913
994
  };
914
- _ts_decorate2([
915
- import_tracing2.trace.span({
995
+ _ts_decorate3([
996
+ import_tracing3.trace.span({
916
997
  showInBrowserTimeline: true
917
998
  })
918
999
  ], IdentityManager.prototype, "open", null);
919
- IdentityManager = _ts_decorate2([
920
- import_tracing2.trace.resource()
1000
+ IdentityManager = _ts_decorate3([
1001
+ import_tracing3.trace.resource()
921
1002
  ], IdentityManager);
922
1003
 
923
1004
  // packages/sdk/client-services/src/packlets/identity/identity-service.ts
@@ -2348,7 +2429,7 @@ var import_protocols7 = require("@dxos/protocols");
2348
2429
  var import_services7 = require("@dxos/protocols/proto/dxos/client/services");
2349
2430
  var import_credentials11 = require("@dxos/protocols/proto/dxos/halo/credentials");
2350
2431
  var import_timeframe2 = require("@dxos/timeframe");
2351
- var import_tracing3 = require("@dxos/tracing");
2432
+ var import_tracing4 = require("@dxos/tracing");
2352
2433
  var import_util4 = require("@dxos/util");
2353
2434
 
2354
2435
  // packages/sdk/client-services/src/packlets/spaces/notarization-plugin.ts
@@ -2620,7 +2701,7 @@ var NotarizationTeleportExtension = class extends import_teleport2.RpcExtension
2620
2701
  };
2621
2702
 
2622
2703
  // packages/sdk/client-services/src/packlets/spaces/data-space.ts
2623
- function _ts_decorate3(decorators, target, key, desc) {
2704
+ function _ts_decorate4(decorators, target, key, desc) {
2624
2705
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
2625
2706
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
2626
2707
  r = Reflect.decorate(decorators, target, key, desc);
@@ -2952,32 +3033,32 @@ var DataSpace = class DataSpace2 {
2952
3033
  this.stateUpdate.emit();
2953
3034
  }
2954
3035
  };
2955
- _ts_decorate3([
3036
+ _ts_decorate4([
2956
3037
  import_async8.synchronized
2957
3038
  ], DataSpace.prototype, "open", null);
2958
- _ts_decorate3([
3039
+ _ts_decorate4([
2959
3040
  import_async8.synchronized
2960
3041
  ], DataSpace.prototype, "close", null);
2961
- _ts_decorate3([
2962
- import_tracing3.trace.span({
3042
+ _ts_decorate4([
3043
+ import_tracing4.trace.span({
2963
3044
  showInBrowserTimeline: true
2964
3045
  })
2965
3046
  ], DataSpace.prototype, "initializeDataPipeline", null);
2966
- _ts_decorate3([
2967
- import_tracing3.trace.span({
3047
+ _ts_decorate4([
3048
+ import_tracing4.trace.span({
2968
3049
  showInBrowserTimeline: true
2969
3050
  })
2970
3051
  ], DataSpace.prototype, "_initializeAndReadControlPipeline", null);
2971
- _ts_decorate3([
3052
+ _ts_decorate4([
2972
3053
  (0, import_debug4.timed)(1e4)
2973
3054
  ], DataSpace.prototype, "_createWritableFeeds", null);
2974
- _ts_decorate3([
3055
+ _ts_decorate4([
2975
3056
  import_async8.synchronized
2976
3057
  ], DataSpace.prototype, "activate", null);
2977
- _ts_decorate3([
3058
+ _ts_decorate4([
2978
3059
  import_async8.synchronized
2979
3060
  ], DataSpace.prototype, "deactivate", null);
2980
- DataSpace = _ts_decorate3([
3061
+ DataSpace = _ts_decorate4([
2981
3062
  (0, import_async8.trackLeaks)("open", "close")
2982
3063
  ], DataSpace);
2983
3064
 
@@ -3051,7 +3132,7 @@ var spaceGenesis = async (keyring, signingContext, space) => {
3051
3132
  };
3052
3133
 
3053
3134
  // packages/sdk/client-services/src/packlets/spaces/data-space-manager.ts
3054
- function _ts_decorate4(decorators, target, key, desc) {
3135
+ function _ts_decorate5(decorators, target, key, desc) {
3055
3136
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3056
3137
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3057
3138
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3367,19 +3448,19 @@ var DataSpaceManager = class DataSpaceManager2 {
3367
3448
  return dataSpace;
3368
3449
  }
3369
3450
  };
3370
- _ts_decorate4([
3451
+ _ts_decorate5([
3371
3452
  import_async9.synchronized
3372
3453
  ], DataSpaceManager.prototype, "open", null);
3373
- _ts_decorate4([
3454
+ _ts_decorate5([
3374
3455
  import_async9.synchronized
3375
3456
  ], DataSpaceManager.prototype, "close", null);
3376
- _ts_decorate4([
3457
+ _ts_decorate5([
3377
3458
  import_async9.synchronized
3378
3459
  ], DataSpaceManager.prototype, "createSpace", null);
3379
- _ts_decorate4([
3460
+ _ts_decorate5([
3380
3461
  import_async9.synchronized
3381
3462
  ], DataSpaceManager.prototype, "acceptSpace", null);
3382
- DataSpaceManager = _ts_decorate4([
3463
+ DataSpaceManager = _ts_decorate5([
3383
3464
  (0, import_async9.trackLeaks)("open", "close")
3384
3465
  ], DataSpaceManager);
3385
3466
 
@@ -3605,7 +3686,7 @@ var SpacesServiceImpl = class {
3605
3686
  var getChannelId = (channel) => `user-channel/${channel}`;
3606
3687
 
3607
3688
  // packages/sdk/client-services/src/packlets/services/service-context.ts
3608
- function _ts_decorate5(decorators, target, key, desc) {
3689
+ function _ts_decorate6(decorators, target, key, desc) {
3609
3690
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3610
3691
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
3611
3692
  r = Reflect.decorate(decorators, target, key, desc);
@@ -3839,15 +3920,15 @@ var ServiceContext = class ServiceContext2 {
3839
3920
  await identity.space.spaceState.addCredentialProcessor(this._deviceSpaceSync);
3840
3921
  }
3841
3922
  };
3842
- _ts_decorate5([
3843
- import_tracing4.trace.span()
3923
+ _ts_decorate6([
3924
+ import_tracing5.trace.span()
3844
3925
  ], ServiceContext.prototype, "open", null);
3845
- _ts_decorate5([
3846
- import_tracing4.trace.span()
3926
+ _ts_decorate6([
3927
+ import_tracing5.trace.span()
3847
3928
  ], ServiceContext.prototype, "_initialize", null);
3848
- ServiceContext = _ts_decorate5([
3929
+ ServiceContext = _ts_decorate6([
3849
3930
  (0, import_util6.safeInstanceof)("dxos.client-services.ServiceContext"),
3850
- import_tracing4.trace.resource()
3931
+ import_tracing5.trace.resource()
3851
3932
  ], ServiceContext);
3852
3933
 
3853
3934
  // packages/sdk/client-services/src/packlets/services/service-host.ts
@@ -3866,7 +3947,7 @@ var import_network_manager2 = require("@dxos/network-manager");
3866
3947
  var import_protocols12 = require("@dxos/protocols");
3867
3948
  var import_services14 = require("@dxos/protocols/proto/dxos/client/services");
3868
3949
  var import_text_model = require("@dxos/text-model");
3869
- var import_tracing5 = require("@dxos/tracing");
3950
+ var import_tracing6 = require("@dxos/tracing");
3870
3951
  var import_websocket_rpc = require("@dxos/websocket-rpc");
3871
3952
 
3872
3953
  // packages/sdk/client-services/src/packlets/services/service-registry.ts
@@ -4249,7 +4330,7 @@ var DevtoolsServiceImpl = class {
4249
4330
  var import_invariant14 = require("@dxos/invariant");
4250
4331
  var import_lock_file = require("@dxos/lock-file");
4251
4332
  var import_log14 = require("@dxos/log");
4252
- function _ts_decorate6(decorators, target, key, desc) {
4333
+ function _ts_decorate7(decorators, target, key, desc) {
4253
4334
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4254
4335
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4255
4336
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4299,7 +4380,7 @@ var Lock = class {
4299
4380
  await import_lock_file.LockFile.release(this._fileHandle);
4300
4381
  }
4301
4382
  };
4302
- _ts_decorate6([
4383
+ _ts_decorate7([
4303
4384
  import_log14.logInfo
4304
4385
  ], Lock.prototype, "lockKey", null);
4305
4386
 
@@ -4556,7 +4637,7 @@ var SystemServiceImpl = class {
4556
4637
  };
4557
4638
 
4558
4639
  // packages/sdk/client-services/src/packlets/services/service-host.ts
4559
- function _ts_decorate7(decorators, target, key, desc) {
4640
+ function _ts_decorate8(decorators, target, key, desc) {
4560
4641
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4561
4642
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
4562
4643
  r = Reflect.decorate(decorators, target, key, desc);
@@ -4593,7 +4674,7 @@ var ClientServicesHost = class ClientServicesHost2 {
4593
4674
  lockKey,
4594
4675
  callbacks
4595
4676
  } = {}) {
4596
- this._tracingService = import_tracing5.TRACE_PROCESSOR.createTraceSender();
4677
+ this._tracingService = import_tracing6.TRACE_PROCESSOR.createTraceSender();
4597
4678
  this._statusUpdate = new import_async17.Event();
4598
4679
  this._opening = false;
4599
4680
  this._open = false;
@@ -4918,22 +4999,22 @@ var ClientServicesHost = class ClientServicesHost2 {
4918
4999
  return identity;
4919
5000
  }
4920
5001
  };
4921
- _ts_decorate7([
4922
- import_tracing5.trace.info()
5002
+ _ts_decorate8([
5003
+ import_tracing6.trace.info()
4923
5004
  ], ClientServicesHost.prototype, "_opening", void 0);
4924
- _ts_decorate7([
4925
- import_tracing5.trace.info()
5005
+ _ts_decorate8([
5006
+ import_tracing6.trace.info()
4926
5007
  ], ClientServicesHost.prototype, "_open", void 0);
4927
- _ts_decorate7([
5008
+ _ts_decorate8([
4928
5009
  import_async17.synchronized,
4929
- import_tracing5.trace.span()
5010
+ import_tracing6.trace.span()
4930
5011
  ], ClientServicesHost.prototype, "open", null);
4931
- _ts_decorate7([
5012
+ _ts_decorate8([
4932
5013
  import_async17.synchronized,
4933
- import_tracing5.trace.span()
5014
+ import_tracing6.trace.span()
4934
5015
  ], ClientServicesHost.prototype, "close", null);
4935
- ClientServicesHost = _ts_decorate7([
4936
- import_tracing5.trace.resource()
5016
+ ClientServicesHost = _ts_decorate8([
5017
+ import_tracing6.trace.resource()
4937
5018
  ], ClientServicesHost);
4938
5019
 
4939
5020
  // packages/sdk/client-services/src/packlets/testing/invitation-utils.ts