@dxos/client-services 0.5.9-main.9587514 → 0.5.9-main.9a55396

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.
@@ -359,7 +359,7 @@ import { SpaceMember } from "@dxos/protocols/proto/dxos/client/services";
359
359
  import { TRACE_PROCESSOR } from "@dxos/tracing";
360
360
 
361
361
  // packages/sdk/client-services/src/version.ts
362
- var DXOS_VERSION = "0.5.9-main.9587514";
362
+ var DXOS_VERSION = "0.5.9-main.9a55396";
363
363
 
364
364
  // packages/sdk/client-services/src/packlets/services/platform.ts
365
365
  import { Platform } from "@dxos/protocols/proto/dxos/client/services";
@@ -6267,13 +6267,151 @@ var createLevel = async (config) => {
6267
6267
  return level;
6268
6268
  };
6269
6269
 
6270
+ // packages/sdk/client-services/src/packlets/storage/profile-archive.ts
6271
+ import { cbor } from "@dxos/automerge/automerge-repo";
6272
+ import { invariant as invariant17 } from "@dxos/invariant";
6273
+ import { log as log20 } from "@dxos/log";
6274
+ import { ProfileArchiveEntryType } from "@dxos/protocols";
6275
+ import { arrayToBuffer } from "@dxos/util";
6276
+ var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/storage/profile-archive.ts";
6277
+ var encodeProfileArchive = (profile) => cbor.encode(profile);
6278
+ var decodeProfileArchive = (data) => cbor.decode(data);
6279
+ var exportProfileData = async ({ storage, level }) => {
6280
+ const archive = {
6281
+ storage: [],
6282
+ meta: {
6283
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
6284
+ }
6285
+ };
6286
+ {
6287
+ const directory = await storage.createDirectory();
6288
+ const files = await directory.list();
6289
+ log20.info("begin exporting files", {
6290
+ count: files.length
6291
+ }, {
6292
+ F: __dxlog_file23,
6293
+ L: 30,
6294
+ S: void 0,
6295
+ C: (f, a) => f(...a)
6296
+ });
6297
+ for (const filename of files) {
6298
+ const file = await directory.getOrCreateFile(filename);
6299
+ const { size } = await file.stat();
6300
+ const data = await file.read(0, size);
6301
+ archive.storage.push({
6302
+ type: ProfileArchiveEntryType.FILE,
6303
+ key: filename,
6304
+ value: data
6305
+ });
6306
+ }
6307
+ log20.info("done exporting files", {
6308
+ count: files.length
6309
+ }, {
6310
+ F: __dxlog_file23,
6311
+ L: 41,
6312
+ S: void 0,
6313
+ C: (f, a) => f(...a)
6314
+ });
6315
+ }
6316
+ {
6317
+ log20.info("begin exporting kv pairs", void 0, {
6318
+ F: __dxlog_file23,
6319
+ L: 45,
6320
+ S: void 0,
6321
+ C: (f, a) => f(...a)
6322
+ });
6323
+ const iter = await level.iterator({
6324
+ keyEncoding: "binary",
6325
+ valueEncoding: "binary"
6326
+ });
6327
+ let count = 0;
6328
+ for await (const [key, value] of iter) {
6329
+ archive.storage.push({
6330
+ type: ProfileArchiveEntryType.KEY_VALUE,
6331
+ key,
6332
+ value
6333
+ });
6334
+ count++;
6335
+ }
6336
+ log20.info("done exporting kv pairs", {
6337
+ count
6338
+ }, {
6339
+ F: __dxlog_file23,
6340
+ L: 56,
6341
+ S: void 0,
6342
+ C: (f, a) => f(...a)
6343
+ });
6344
+ }
6345
+ return archive;
6346
+ };
6347
+ var importProfileData = async ({ storage, level }, archive) => {
6348
+ const batch = level.batch();
6349
+ for (const entry2 of archive.storage) {
6350
+ switch (entry2.type) {
6351
+ case ProfileArchiveEntryType.FILE: {
6352
+ const directory = await storage.createDirectory();
6353
+ invariant17(typeof entry2.key === "string", "Invalid key type", {
6354
+ F: __dxlog_file23,
6355
+ L: 78,
6356
+ S: void 0,
6357
+ A: [
6358
+ "typeof entry.key === 'string'",
6359
+ "'Invalid key type'"
6360
+ ]
6361
+ });
6362
+ const file = await directory.getOrCreateFile(entry2.key);
6363
+ invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
6364
+ F: __dxlog_file23,
6365
+ L: 80,
6366
+ S: void 0,
6367
+ A: [
6368
+ "entry.value instanceof Uint8Array",
6369
+ "'Invalid value type'"
6370
+ ]
6371
+ });
6372
+ await file.write(0, arrayToBuffer(entry2.value));
6373
+ await file.close();
6374
+ break;
6375
+ }
6376
+ case ProfileArchiveEntryType.KEY_VALUE: {
6377
+ invariant17(entry2.key instanceof Uint8Array, "Invalid key type", {
6378
+ F: __dxlog_file23,
6379
+ L: 86,
6380
+ S: void 0,
6381
+ A: [
6382
+ "entry.key instanceof Uint8Array",
6383
+ "'Invalid key type'"
6384
+ ]
6385
+ });
6386
+ invariant17(entry2.value instanceof Uint8Array, "Invalid value type", {
6387
+ F: __dxlog_file23,
6388
+ L: 87,
6389
+ S: void 0,
6390
+ A: [
6391
+ "entry.value instanceof Uint8Array",
6392
+ "'Invalid value type'"
6393
+ ]
6394
+ });
6395
+ batch.put(entry2.key, entry2.value, {
6396
+ keyEncoding: "binary",
6397
+ valueEncoding: "binary"
6398
+ });
6399
+ break;
6400
+ }
6401
+ default:
6402
+ throw new Error(`Invalid entry type: ${entry2.type}`);
6403
+ }
6404
+ }
6405
+ await batch.write();
6406
+ };
6407
+
6270
6408
  // packages/sdk/client-services/src/packlets/services/service-host.ts
6271
6409
  import { Event as Event9, synchronized as synchronized3 } from "@dxos/async";
6272
6410
  import { clientServiceBundle } from "@dxos/client-protocol";
6273
6411
  import { Context as Context11 } from "@dxos/context";
6274
- import { invariant as invariant18 } from "@dxos/invariant";
6412
+ import { invariant as invariant19 } from "@dxos/invariant";
6275
6413
  import { PublicKey as PublicKey17 } from "@dxos/keys";
6276
- import { log as log21 } from "@dxos/log";
6414
+ import { log as log22 } from "@dxos/log";
6277
6415
  import { WebsocketSignalManager } from "@dxos/messaging";
6278
6416
  import { SwarmNetworkManager, createSimplePeerTransportFactory } from "@dxos/network-manager";
6279
6417
  import { trace as trace10 } from "@dxos/protocols";
@@ -6284,9 +6422,9 @@ import { WebsocketRpcClient } from "@dxos/websocket-rpc";
6284
6422
  // packages/sdk/client-services/src/packlets/devices/devices-service.ts
6285
6423
  import { EventSubscriptions as EventSubscriptions3 } from "@dxos/async";
6286
6424
  import { Stream as Stream11 } from "@dxos/codec-protobuf";
6287
- import { invariant as invariant17 } from "@dxos/invariant";
6425
+ import { invariant as invariant18 } from "@dxos/invariant";
6288
6426
  import { Device as Device2, DeviceKind as DeviceKind2 } from "@dxos/protocols/proto/dxos/client/services";
6289
- var __dxlog_file23 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6427
+ var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/devices/devices-service.ts";
6290
6428
  var DevicesServiceImpl = class {
6291
6429
  constructor(_identityManager) {
6292
6430
  this._identityManager = _identityManager;
@@ -6303,8 +6441,8 @@ var DevicesServiceImpl = class {
6303
6441
  devices: []
6304
6442
  });
6305
6443
  } else {
6306
- invariant17(this._identityManager.identity?.presence, "presence not present", {
6307
- F: __dxlog_file23,
6444
+ invariant18(this._identityManager.identity?.presence, "presence not present", {
6445
+ F: __dxlog_file24,
6308
6446
  L: 32,
6309
6447
  S: this,
6310
6448
  A: [
@@ -6497,7 +6635,7 @@ var ContactsServiceImpl = class {
6497
6635
  import { Event as Event8 } from "@dxos/async";
6498
6636
  import { Stream as Stream13 } from "@dxos/codec-protobuf";
6499
6637
  import { PublicKey as PublicKey16 } from "@dxos/keys";
6500
- import { getContextFromEntry, log as log20 } from "@dxos/log";
6638
+ import { getContextFromEntry, log as log21 } from "@dxos/log";
6501
6639
  import { QueryLogsRequest } from "@dxos/protocols/proto/dxos/client/services";
6502
6640
  import { getDebugName, jsonify, numericalValues, tracer } from "@dxos/util";
6503
6641
  var LoggingServiceImpl = class {
@@ -6510,11 +6648,11 @@ var LoggingServiceImpl = class {
6510
6648
  };
6511
6649
  }
6512
6650
  async open() {
6513
- log20.runtimeConfig.processors.push(this._logProcessor);
6651
+ log21.runtimeConfig.processors.push(this._logProcessor);
6514
6652
  }
6515
6653
  async close() {
6516
- const index = log20.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6517
- log20.runtimeConfig.processors.splice(index, 1);
6654
+ const index = log21.runtimeConfig.processors.findIndex((processor) => processor === this._logProcessor);
6655
+ log21.runtimeConfig.processors.splice(index, 1);
6518
6656
  }
6519
6657
  async controlMetrics({ reset, record }) {
6520
6658
  if (reset) {
@@ -6718,7 +6856,7 @@ function _ts_decorate8(decorators, target, key, desc) {
6718
6856
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6719
6857
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6720
6858
  }
6721
- var __dxlog_file24 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6859
+ var __dxlog_file25 = "/home/runner/work/dxos/dxos/packages/sdk/client-services/src/packlets/services/service-host.ts";
6722
6860
  var ClientServicesHost = class {
6723
6861
  constructor({
6724
6862
  config,
@@ -6752,7 +6890,7 @@ var ClientServicesHost = class {
6752
6890
  onAcquire: () => {
6753
6891
  if (!this._opening) {
6754
6892
  void this.open(new Context11(void 0, {
6755
- F: __dxlog_file24,
6893
+ F: __dxlog_file25,
6756
6894
  L: 121
6757
6895
  }));
6758
6896
  }
@@ -6809,8 +6947,8 @@ var ClientServicesHost = class {
6809
6947
  * Can only be called once.
6810
6948
  */
6811
6949
  initialize({ config, ...options }) {
6812
- invariant18(!this._open, "service host is open", {
6813
- F: __dxlog_file24,
6950
+ invariant19(!this._open, "service host is open", {
6951
+ F: __dxlog_file25,
6814
6952
  L: 187,
6815
6953
  S: this,
6816
6954
  A: [
@@ -6818,15 +6956,15 @@ var ClientServicesHost = class {
6818
6956
  "'service host is open'"
6819
6957
  ]
6820
6958
  });
6821
- log21("initializing...", void 0, {
6822
- F: __dxlog_file24,
6959
+ log22("initializing...", void 0, {
6960
+ F: __dxlog_file25,
6823
6961
  L: 188,
6824
6962
  S: this,
6825
6963
  C: (f, a) => f(...a)
6826
6964
  });
6827
6965
  if (config) {
6828
- invariant18(!this._config, "config already set", {
6829
- F: __dxlog_file24,
6966
+ invariant19(!this._config, "config already set", {
6967
+ F: __dxlog_file25,
6830
6968
  L: 191,
6831
6969
  S: this,
6832
6970
  A: [
@@ -6840,8 +6978,8 @@ var ClientServicesHost = class {
6840
6978
  }
6841
6979
  }
6842
6980
  if (!options.signalManager) {
6843
- log21.warn("running signaling without telemetry metadata.", void 0, {
6844
- F: __dxlog_file24,
6981
+ log22.warn("running signaling without telemetry metadata.", void 0, {
6982
+ F: __dxlog_file25,
6845
6983
  L: 199,
6846
6984
  S: this,
6847
6985
  C: (f, a) => f(...a)
@@ -6851,8 +6989,8 @@ var ClientServicesHost = class {
6851
6989
  iceServers: this._config?.get("runtime.services.ice")
6852
6990
  }), signalManager = new WebsocketSignalManager(this._config?.get("runtime.services.signaling") ?? []) } = options;
6853
6991
  this._signalManager = signalManager;
6854
- invariant18(!this._networkManager, "network manager already set", {
6855
- F: __dxlog_file24,
6992
+ invariant19(!this._networkManager, "network manager already set", {
6993
+ F: __dxlog_file25,
6856
6994
  L: 210,
6857
6995
  S: this,
6858
6996
  A: [
@@ -6865,8 +7003,8 @@ var ClientServicesHost = class {
6865
7003
  transportFactory,
6866
7004
  signalManager
6867
7005
  });
6868
- log21("initialized", void 0, {
6869
- F: __dxlog_file24,
7006
+ log22("initialized", void 0, {
7007
+ F: __dxlog_file25,
6870
7008
  L: 217,
6871
7009
  S: this,
6872
7010
  C: (f, a) => f(...a)
@@ -6877,16 +7015,16 @@ var ClientServicesHost = class {
6877
7015
  return;
6878
7016
  }
6879
7017
  const traceId = PublicKey17.random().toHex();
6880
- log21.trace("dxos.client-services.host.open", trace10.begin({
7018
+ log22.trace("dxos.client-services.host.open", trace10.begin({
6881
7019
  id: traceId
6882
7020
  }), {
6883
- F: __dxlog_file24,
7021
+ F: __dxlog_file25,
6884
7022
  L: 228,
6885
7023
  S: this,
6886
7024
  C: (f, a) => f(...a)
6887
7025
  });
6888
- invariant18(this._config, "config not set", {
6889
- F: __dxlog_file24,
7026
+ invariant19(this._config, "config not set", {
7027
+ F: __dxlog_file25,
6890
7028
  L: 230,
6891
7029
  S: this,
6892
7030
  A: [
@@ -6894,8 +7032,8 @@ var ClientServicesHost = class {
6894
7032
  "'config not set'"
6895
7033
  ]
6896
7034
  });
6897
- invariant18(this._storage, "storage not set", {
6898
- F: __dxlog_file24,
7035
+ invariant19(this._storage, "storage not set", {
7036
+ F: __dxlog_file25,
6899
7037
  L: 231,
6900
7038
  S: this,
6901
7039
  A: [
@@ -6903,8 +7041,8 @@ var ClientServicesHost = class {
6903
7041
  "'storage not set'"
6904
7042
  ]
6905
7043
  });
6906
- invariant18(this._signalManager, "signal manager not set", {
6907
- F: __dxlog_file24,
7044
+ invariant19(this._signalManager, "signal manager not set", {
7045
+ F: __dxlog_file25,
6908
7046
  L: 232,
6909
7047
  S: this,
6910
7048
  A: [
@@ -6912,8 +7050,8 @@ var ClientServicesHost = class {
6912
7050
  "'signal manager not set'"
6913
7051
  ]
6914
7052
  });
6915
- invariant18(this._networkManager, "network manager not set", {
6916
- F: __dxlog_file24,
7053
+ invariant19(this._networkManager, "network manager not set", {
7054
+ F: __dxlog_file25,
6917
7055
  L: 233,
6918
7056
  S: this,
6919
7057
  A: [
@@ -6922,10 +7060,10 @@ var ClientServicesHost = class {
6922
7060
  ]
6923
7061
  });
6924
7062
  this._opening = true;
6925
- log21("opening...", {
7063
+ log22("opening...", {
6926
7064
  lockKey: this._resourceLock?.lockKey
6927
7065
  }, {
6928
- F: __dxlog_file24,
7066
+ F: __dxlog_file25,
6929
7067
  L: 236,
6930
7068
  S: this,
6931
7069
  C: (f, a) => f(...a)
@@ -6978,18 +7116,18 @@ var ClientServicesHost = class {
6978
7116
  this._open = true;
6979
7117
  this._statusUpdate.emit();
6980
7118
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
6981
- log21("opened", {
7119
+ log22("opened", {
6982
7120
  deviceKey
6983
7121
  }, {
6984
- F: __dxlog_file24,
7122
+ F: __dxlog_file25,
6985
7123
  L: 322,
6986
7124
  S: this,
6987
7125
  C: (f, a) => f(...a)
6988
7126
  });
6989
- log21.trace("dxos.client-services.host.open", trace10.end({
7127
+ log22.trace("dxos.client-services.host.open", trace10.end({
6990
7128
  id: traceId
6991
7129
  }), {
6992
- F: __dxlog_file24,
7130
+ F: __dxlog_file25,
6993
7131
  L: 323,
6994
7132
  S: this,
6995
7133
  C: (f, a) => f(...a)
@@ -7000,10 +7138,10 @@ var ClientServicesHost = class {
7000
7138
  return;
7001
7139
  }
7002
7140
  const deviceKey = this._serviceContext.identityManager.identity?.deviceKey;
7003
- log21("closing...", {
7141
+ log22("closing...", {
7004
7142
  deviceKey
7005
7143
  }, {
7006
- F: __dxlog_file24,
7144
+ F: __dxlog_file25,
7007
7145
  L: 334,
7008
7146
  S: this,
7009
7147
  C: (f, a) => f(...a)
@@ -7018,10 +7156,10 @@ var ClientServicesHost = class {
7018
7156
  await this._level?.close();
7019
7157
  this._open = false;
7020
7158
  this._statusUpdate.emit();
7021
- log21("closed", {
7159
+ log22("closed", {
7022
7160
  deviceKey
7023
7161
  }, {
7024
- F: __dxlog_file24,
7162
+ F: __dxlog_file25,
7025
7163
  L: 343,
7026
7164
  S: this,
7027
7165
  C: (f, a) => f(...a)
@@ -7029,32 +7167,32 @@ var ClientServicesHost = class {
7029
7167
  }
7030
7168
  async reset() {
7031
7169
  const traceId = PublicKey17.random().toHex();
7032
- log21.trace("dxos.sdk.client-services-host.reset", trace10.begin({
7170
+ log22.trace("dxos.sdk.client-services-host.reset", trace10.begin({
7033
7171
  id: traceId
7034
7172
  }), {
7035
- F: __dxlog_file24,
7173
+ F: __dxlog_file25,
7036
7174
  L: 348,
7037
7175
  S: this,
7038
7176
  C: (f, a) => f(...a)
7039
7177
  });
7040
- log21.info("resetting...", void 0, {
7041
- F: __dxlog_file24,
7178
+ log22.info("resetting...", void 0, {
7179
+ F: __dxlog_file25,
7042
7180
  L: 350,
7043
7181
  S: this,
7044
7182
  C: (f, a) => f(...a)
7045
7183
  });
7046
7184
  await this._serviceContext?.close();
7047
7185
  await this._storage.reset();
7048
- log21.info("reset", void 0, {
7049
- F: __dxlog_file24,
7186
+ log22.info("reset", void 0, {
7187
+ F: __dxlog_file25,
7050
7188
  L: 353,
7051
7189
  S: this,
7052
7190
  C: (f, a) => f(...a)
7053
7191
  });
7054
- log21.trace("dxos.sdk.client-services-host.reset", trace10.end({
7192
+ log22.trace("dxos.sdk.client-services-host.reset", trace10.end({
7055
7193
  id: traceId
7056
7194
  }), {
7057
- F: __dxlog_file24,
7195
+ F: __dxlog_file25,
7058
7196
  L: 354,
7059
7197
  S: this,
7060
7198
  C: (f, a) => f(...a)
@@ -7121,8 +7259,12 @@ export {
7121
7259
  isLocked,
7122
7260
  createStorageObjects,
7123
7261
  createLevel,
7262
+ encodeProfileArchive,
7263
+ decodeProfileArchive,
7264
+ exportProfileData,
7265
+ importProfileData,
7124
7266
  ClientServicesHost,
7125
7267
  ClientServicesProviderResource,
7126
7268
  DiagnosticsCollector
7127
7269
  };
7128
- //# sourceMappingURL=chunk-Y4NGEDFZ.mjs.map
7270
+ //# sourceMappingURL=chunk-KK6LG6CO.mjs.map