@dxos/echo-pipeline 0.1.56-main.ad054df → 0.1.56-main.adb2b88

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.
@@ -67,7 +67,6 @@ var DataServiceHost = class {
67
67
  }
68
68
  });
69
69
  this._itemDemuxer.mutation.on(ctx, (message) => {
70
- var _a;
71
70
  const { batch, meta } = message;
72
71
  invariant2(!meta.clientTag, "Unexpected client tag in mutation message", {
73
72
  F: __dxlog_file2,
@@ -91,7 +90,7 @@ var DataServiceHost = class {
91
90
  message.meta.feedKey,
92
91
  message.meta.seq
93
92
  ]);
94
- (_a = batch.objects) == null ? void 0 : _a.forEach((object) => {
93
+ batch.objects?.forEach((object) => {
95
94
  setMetadataOnObject(object, {
96
95
  ...meta
97
96
  });
@@ -109,7 +108,6 @@ var DataServiceHost = class {
109
108
  });
110
109
  }
111
110
  async write(request) {
112
- var _a, _b;
113
111
  invariant2(!this._ctx.disposed, "Cannot write to closed DataServiceHost", {
114
112
  F: __dxlog_file2,
115
113
  L: 88,
@@ -130,7 +128,7 @@ var DataServiceHost = class {
130
128
  });
131
129
  log("write", {
132
130
  clientTag: request.clientTag,
133
- objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
131
+ objectCount: request.batch.objects?.length ?? 0
134
132
  }, {
135
133
  F: __dxlog_file2,
136
134
  L: 91,
@@ -161,24 +159,18 @@ var DataServiceHost = class {
161
159
  return receipt;
162
160
  }
163
161
  };
164
- var createDataMessage = (batch) => {
165
- var _a;
166
- return {
167
- batch: {
168
- objects: (_a = batch.objects) == null ? void 0 : _a.map((object) => {
169
- var _a2;
170
- return {
171
- ...object,
172
- mutations: (_a2 = object.mutations) == null ? void 0 : _a2.map((mutation) => ({
173
- ...mutation,
174
- meta: void 0
175
- })),
176
- meta: void 0
177
- };
178
- })
179
- }
180
- };
181
- };
162
+ var createDataMessage = (batch) => ({
163
+ batch: {
164
+ objects: batch.objects?.map((object) => ({
165
+ ...object,
166
+ mutations: object.mutations?.map((mutation) => ({
167
+ ...mutation,
168
+ meta: void 0
169
+ })),
170
+ meta: void 0
171
+ }))
172
+ }
173
+ });
182
174
 
183
175
  // packages/core/echo/echo-pipeline/src/db-host/database-host.ts
184
176
  import { ItemDemuxer } from "@dxos/echo-db";
@@ -207,15 +199,13 @@ var DatabaseHost = class {
207
199
  return this._itemDemuxer.createSnapshot();
208
200
  }
209
201
  createDataServiceHost() {
210
- var _a;
211
- return new DataServiceHost(this._itemManager, this._itemDemuxer, (_a = this._outboundStream) != null ? _a : void 0);
202
+ return new DataServiceHost(this._itemManager, this._itemDemuxer, this._outboundStream ?? void 0);
212
203
  }
213
204
  };
214
205
 
215
206
  // packages/core/echo/echo-pipeline/src/db-host/snapshot-manager.ts
216
207
  import { trackLeaks } from "@dxos/async";
217
208
  import { cancelWithContext } from "@dxos/context";
218
- import { timed } from "@dxos/debug";
219
209
  import { PublicKey } from "@dxos/keys";
220
210
  import { schema as schema2 } from "@dxos/protocols";
221
211
  import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
@@ -260,9 +250,6 @@ var SnapshotManager = class SnapshotManager2 {
260
250
  return PublicKey.from(id).toHex();
261
251
  }
262
252
  };
263
- _ts_decorate([
264
- timed(1e4)
265
- ], SnapshotManager.prototype, "load", null);
266
253
  SnapshotManager = _ts_decorate([
267
254
  trackLeaks("open", "close")
268
255
  ], SnapshotManager);
@@ -358,7 +345,7 @@ var DataServiceSubscriptions = class {
358
345
  C: (f, a) => f(...a)
359
346
  });
360
347
  const host = this._spaces.get(spaceKey);
361
- await (host == null ? void 0 : host.close());
348
+ await host?.close();
362
349
  this._spaces.delete(spaceKey);
363
350
  }
364
351
  getDataService(spaceKey) {
@@ -370,7 +357,6 @@ var DataServiceImpl = class {
370
357
  this._subscriptions = _subscriptions;
371
358
  }
372
359
  subscribe(request) {
373
- var _a;
374
360
  invariant3(request.spaceKey, void 0, {
375
361
  F: __dxlog_file3,
376
362
  L: 56,
@@ -380,11 +366,10 @@ var DataServiceImpl = class {
380
366
  ""
381
367
  ]
382
368
  });
383
- const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
369
+ const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
384
370
  return host.subscribe();
385
371
  }
386
372
  write(request) {
387
- var _a;
388
373
  invariant3(request.spaceKey, void 0, {
389
374
  F: __dxlog_file3,
390
375
  L: 63,
@@ -403,7 +388,7 @@ var DataServiceImpl = class {
403
388
  ""
404
389
  ]
405
390
  });
406
- const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : raise(new Error(`space not found: ${request.spaceKey}`));
391
+ const host = this._subscriptions.getDataService(request.spaceKey) ?? raise(new Error(`space not found: ${request.spaceKey}`));
407
392
  return host.write(request);
408
393
  }
409
394
  };
@@ -431,8 +416,8 @@ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipelin
431
416
  var emptyEchoMetadata = () => ({
432
417
  version: STORAGE_VERSION,
433
418
  spaces: [],
434
- created: new Date(),
435
- updated: new Date()
419
+ created: /* @__PURE__ */ new Date(),
420
+ updated: /* @__PURE__ */ new Date()
436
421
  });
437
422
  var EchoMetadata = schema4.getCodecForType("dxos.echo.metadata.EchoMetadata");
438
423
  var MetadataStore = class {
@@ -446,22 +431,19 @@ var MetadataStore = class {
446
431
  return this._metadata;
447
432
  }
448
433
  get version() {
449
- var _a;
450
- return (_a = this._metadata.version) != null ? _a : 0;
434
+ return this._metadata.version ?? 0;
451
435
  }
452
436
  /**
453
437
  * Returns a list of currently saved spaces. The list and objects in it can be modified addSpace and
454
438
  * addSpaceFeed functions.
455
439
  */
456
440
  get spaces() {
457
- var _a;
458
- return (_a = this._metadata.spaces) != null ? _a : [];
441
+ return this._metadata.spaces ?? [];
459
442
  }
460
443
  /**
461
444
  * Loads metadata from persistent storage.
462
445
  */
463
446
  async load() {
464
- var _a;
465
447
  const file = this._directory.getOrCreateFile("EchoMetadata");
466
448
  try {
467
449
  const { size: fileLength } = await file.stat();
@@ -480,7 +462,10 @@ var MetadataStore = class {
480
462
  C: (f, a) => f(...a)
481
463
  });
482
464
  if (fileLength < dataSize + 8) {
483
- throw new DataCorruptionError("Metadata size is smaller than expected.");
465
+ throw new DataCorruptionError("Metadata size is smaller than expected.", {
466
+ fileLength,
467
+ dataSize
468
+ });
484
469
  }
485
470
  const data = await file.read(8, dataSize);
486
471
  const calculatedChecksum = CRC32.buf(data);
@@ -488,9 +473,8 @@ var MetadataStore = class {
488
473
  throw new DataCorruptionError("Metadata checksum is invalid.");
489
474
  }
490
475
  this._metadata = EchoMetadata.decode(data);
491
- (_a = this._metadata.spaces) == null ? void 0 : _a.forEach((space) => {
492
- var _a2;
493
- (_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
476
+ this._metadata.spaces?.forEach((space) => {
477
+ space.state ??= SpaceState.ACTIVE;
494
478
  });
495
479
  } catch (err) {
496
480
  log3.error("failed to load metadata", {
@@ -507,12 +491,11 @@ var MetadataStore = class {
507
491
  }
508
492
  }
509
493
  async _save() {
510
- var _a;
511
494
  const data = {
512
495
  ...this._metadata,
513
496
  version: STORAGE_VERSION,
514
- created: (_a = this._metadata.created) != null ? _a : new Date(),
515
- updated: new Date()
497
+ created: this._metadata.created ?? /* @__PURE__ */ new Date(),
498
+ updated: /* @__PURE__ */ new Date()
516
499
  };
517
500
  this.update.emit(data);
518
501
  const file = this._directory.getOrCreateFile("EchoMetadata");
@@ -538,8 +521,7 @@ var MetadataStore = class {
538
521
  }
539
522
  }
540
523
  _getSpace(spaceKey) {
541
- var _a;
542
- if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
524
+ if (this._metadata.identity?.haloSpace.key.equals(spaceKey)) {
543
525
  return this._metadata.identity.haloSpace;
544
526
  }
545
527
  const space = this.spaces.find((space2) => space2.key === spaceKey);
@@ -584,8 +566,7 @@ var MetadataStore = class {
584
566
  await this._save();
585
567
  }
586
568
  async addSpace(record) {
587
- var _a, _b, _c;
588
- invariant4(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
569
+ invariant4(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
589
570
  F: __dxlog_file4,
590
571
  L: 162,
591
572
  S: this,
@@ -594,7 +575,7 @@ var MetadataStore = class {
594
575
  "'Cannot overwrite existing space in metadata'"
595
576
  ]
596
577
  });
597
- ((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
578
+ (this._metadata.spaces ??= []).push(record);
598
579
  await this._save();
599
580
  }
600
581
  async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
@@ -630,7 +611,7 @@ var fromBytesInt32 = (buf) => buf.readInt32LE(0);
630
611
 
631
612
  // packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
632
613
  import { Event as Event2 } from "@dxos/async";
633
- import { timed as timed2 } from "@dxos/debug";
614
+ import { timed } from "@dxos/debug";
634
615
  import { log as log4 } from "@dxos/log";
635
616
  import { Timeframe } from "@dxos/timeframe";
636
617
  function _ts_decorate3(decorators, target, key, desc) {
@@ -723,7 +704,7 @@ var TimeframeClock = class {
723
704
  }
724
705
  };
725
706
  _ts_decorate3([
726
- timed2(5e3)
707
+ timed(5e3)
727
708
  ], TimeframeClock.prototype, "waitUntilReached", null);
728
709
 
729
710
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
@@ -829,7 +810,6 @@ var PipelineState = class {
829
810
  * @param timeout Timeout in milliseconds to specify the maximum wait time.
830
811
  */
831
812
  async waitUntilReachedTargetTimeframe({ ctx = new Context2(), timeout, breakOnStall = true } = {}) {
832
- var _a;
833
813
  log6("waitUntilReachedTargetTimeframe", {
834
814
  timeout,
835
815
  current: this.timeframe,
@@ -840,7 +820,7 @@ var PipelineState = class {
840
820
  S: this,
841
821
  C: (f, a) => f(...a)
842
822
  });
843
- (_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
823
+ this._reachedTargetPromise ??= Promise.race([
844
824
  this._timeframeClock.update.waitForCondition(() => {
845
825
  return Timeframe2.dependencies(this.targetTimeframe, this.timeframe).isEmpty();
846
826
  }),
@@ -947,10 +927,19 @@ var Pipeline = class {
947
927
  }), feed.createFeedWriter());
948
928
  }
949
929
  async start() {
950
- log6("starting...", void 0, {
930
+ invariant6(!this._isStarted, "Pipeline is already started.", {
951
931
  F: __dxlog_file7,
952
932
  L: 267,
953
933
  S: this,
934
+ A: [
935
+ "!this._isStarted",
936
+ "'Pipeline is already started.'"
937
+ ]
938
+ });
939
+ log6("starting...", void 0, {
940
+ F: __dxlog_file7,
941
+ L: 268,
942
+ S: this,
954
943
  C: (f, a) => f(...a)
955
944
  });
956
945
  await this._initIterator();
@@ -958,21 +947,20 @@ var Pipeline = class {
958
947
  this._isStarted = true;
959
948
  log6("started", void 0, {
960
949
  F: __dxlog_file7,
961
- L: 271,
950
+ L: 272,
962
951
  S: this,
963
952
  C: (f, a) => f(...a)
964
953
  });
965
954
  }
966
955
  async stop() {
967
- var _a;
968
956
  log6("stopping...", void 0, {
969
957
  F: __dxlog_file7,
970
- L: 276,
958
+ L: 277,
971
959
  S: this,
972
960
  C: (f, a) => f(...a)
973
961
  });
974
962
  this._isStopping = true;
975
- await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
963
+ await this._feedSetIterator?.close();
976
964
  await this._processingTrigger.wait();
977
965
  await this._state._ctx.dispose();
978
966
  this._state._ctx = new Context2();
@@ -980,7 +968,7 @@ var Pipeline = class {
980
968
  this._isStarted = false;
981
969
  log6("stopped", void 0, {
982
970
  F: __dxlog_file7,
983
- L: 284,
971
+ L: 285,
984
972
  S: this,
985
973
  C: (f, a) => f(...a)
986
974
  });
@@ -992,7 +980,7 @@ var Pipeline = class {
992
980
  async setCursor(timeframe) {
993
981
  invariant6(!this._isStarted || this._isPaused, "Invalid state.", {
994
982
  F: __dxlog_file7,
995
- L: 293,
983
+ L: 294,
996
984
  S: this,
997
985
  A: [
998
986
  "!this._isStarted || this._isPaused",
@@ -1016,7 +1004,7 @@ var Pipeline = class {
1016
1004
  async pause() {
1017
1005
  invariant6(this._isStarted, "Pipeline is not open.", {
1018
1006
  F: __dxlog_file7,
1019
- L: 315,
1007
+ L: 316,
1020
1008
  S: this,
1021
1009
  A: [
1022
1010
  "this._isStarted",
@@ -1033,7 +1021,7 @@ var Pipeline = class {
1033
1021
  async unpause() {
1034
1022
  invariant6(this._isStarted, "Pipeline is not open.", {
1035
1023
  F: __dxlog_file7,
1036
- L: 327,
1024
+ L: 328,
1037
1025
  S: this,
1038
1026
  A: [
1039
1027
  "this._isStarted",
@@ -1042,7 +1030,7 @@ var Pipeline = class {
1042
1030
  });
1043
1031
  invariant6(this._isPaused, "Pipeline is not paused.", {
1044
1032
  F: __dxlog_file7,
1045
- L: 328,
1033
+ L: 329,
1046
1034
  S: this,
1047
1035
  A: [
1048
1036
  "this._isPaused",
@@ -1059,7 +1047,7 @@ var Pipeline = class {
1059
1047
  async *consume() {
1060
1048
  invariant6(!this._isOpen, "Pipeline is already being consumed.", {
1061
1049
  F: __dxlog_file7,
1062
- L: 339,
1050
+ L: 340,
1063
1051
  S: this,
1064
1052
  A: [
1065
1053
  "!this._isOpen",
@@ -1069,7 +1057,7 @@ var Pipeline = class {
1069
1057
  this._isOpen = true;
1070
1058
  invariant6(this._feedSetIterator, "Iterator not initialized.", {
1071
1059
  F: __dxlog_file7,
1072
- L: 342,
1060
+ L: 343,
1073
1061
  S: this,
1074
1062
  A: [
1075
1063
  "this._feedSetIterator",
@@ -1083,7 +1071,7 @@ var Pipeline = class {
1083
1071
  if (lastFeedSetIterator !== this._feedSetIterator) {
1084
1072
  invariant6(this._feedSetIterator, "Iterator not initialized.", {
1085
1073
  F: __dxlog_file7,
1086
- L: 351,
1074
+ L: 352,
1087
1075
  S: this,
1088
1076
  A: [
1089
1077
  "this._feedSetIterator",
@@ -1095,7 +1083,7 @@ var Pipeline = class {
1095
1083
  }
1096
1084
  const { done, value } = await iterable.next();
1097
1085
  if (!done) {
1098
- const block = value != null ? value : failUndefined();
1086
+ const block = value ?? failUndefined();
1099
1087
  this._processingTrigger.reset();
1100
1088
  this._timeframeClock.updatePendingTimeframe(PublicKey3.from(block.feedKey), block.seq);
1101
1089
  yield block;
@@ -1106,13 +1094,12 @@ var Pipeline = class {
1106
1094
  this._isOpen = false;
1107
1095
  }
1108
1096
  _setFeedDownloadState(feed) {
1109
- var _a;
1110
1097
  const timeframe = this._state._startTimeframe;
1111
- const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
1098
+ const seq = timeframe.get(feed.key) ?? 0;
1112
1099
  feed.undownload({
1113
1100
  callback: () => log6("undownload", void 0, {
1114
1101
  F: __dxlog_file7,
1115
- L: 375,
1102
+ L: 377,
1116
1103
  S: this,
1117
1104
  C: (f, a) => f(...a)
1118
1105
  })
@@ -1125,7 +1112,7 @@ var Pipeline = class {
1125
1112
  err
1126
1113
  }, {
1127
1114
  F: __dxlog_file7,
1128
- L: 377,
1115
+ L: 379,
1129
1116
  S: this,
1130
1117
  C: (f, a) => f(...a)
1131
1118
  });
@@ -1139,7 +1126,7 @@ var Pipeline = class {
1139
1126
  this._feedSetIterator.stalled.on((iterator) => {
1140
1127
  log6.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
1141
1128
  F: __dxlog_file7,
1142
- L: 388,
1129
+ L: 390,
1143
1130
  S: this,
1144
1131
  C: (f, a) => f(...a)
1145
1132
  });
@@ -1231,7 +1218,7 @@ var AuthExtension = class extends RpcExtension {
1231
1218
  const { credential } = await this.rpc.AuthService.authenticate({
1232
1219
  challenge
1233
1220
  });
1234
- invariant7((credential == null ? void 0 : credential.length) > 0, "invalid credential", {
1221
+ invariant7(credential?.length > 0, "invalid credential", {
1235
1222
  F: __dxlog_file8,
1236
1223
  L: 69,
1237
1224
  S: this,
@@ -1315,13 +1302,11 @@ var DataPipeline = class DataPipeline2 {
1315
1302
  return this._pipeline;
1316
1303
  }
1317
1304
  get pipelineState() {
1318
- var _a;
1319
- return (_a = this._pipeline) == null ? void 0 : _a.state;
1305
+ return this._pipeline?.state;
1320
1306
  }
1321
1307
  setTargetTimeframe(timeframe) {
1322
- var _a;
1323
1308
  this._targetTimeframe = timeframe;
1324
- (_a = this._pipeline) == null ? void 0 : _a.state.setTargetTimeframe(timeframe);
1309
+ this._pipeline?.state.setTargetTimeframe(timeframe);
1325
1310
  }
1326
1311
  async processCredential(credential) {
1327
1312
  if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
@@ -1377,7 +1362,6 @@ var DataPipeline = class DataPipeline2 {
1377
1362
  this._isOpen = true;
1378
1363
  }
1379
1364
  async close() {
1380
- var _a, _b, _c;
1381
1365
  if (!this._isOpen) {
1382
1366
  return;
1383
1367
  }
@@ -1389,7 +1373,7 @@ var DataPipeline = class DataPipeline2 {
1389
1373
  });
1390
1374
  this._isOpen = false;
1391
1375
  await this._ctx.dispose();
1392
- await ((_a = this._pipeline) == null ? void 0 : _a.stop());
1376
+ await this._pipeline?.stop();
1393
1377
  try {
1394
1378
  await this._saveCache();
1395
1379
  if (this._pipeline) {
@@ -1403,8 +1387,8 @@ var DataPipeline = class DataPipeline2 {
1403
1387
  C: (f, a) => f(...a)
1404
1388
  });
1405
1389
  }
1406
- await ((_b = this.databaseHost) == null ? void 0 : _b.close());
1407
- await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
1390
+ await this.databaseHost?.close();
1391
+ await this.itemManager?.destroy();
1408
1392
  this._ctx = new Context4();
1409
1393
  this._pipeline = void 0;
1410
1394
  this._targetTimeframe = void 0;
@@ -1504,21 +1488,17 @@ var DataPipeline = class DataPipeline2 {
1504
1488
  };
1505
1489
  }
1506
1490
  async _saveTargetTimeframe(timeframe) {
1507
- var _a;
1508
- const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
1491
+ const newTimeframe = Timeframe3.merge(this._targetTimeframe ?? new Timeframe3(), timeframe);
1509
1492
  await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
1510
1493
  this._targetTimeframe = newTimeframe;
1511
1494
  }
1512
1495
  async _saveCache() {
1513
- var _a;
1514
1496
  const cache = {};
1515
1497
  try {
1516
- const propertiesItem = this.itemManager.items.find((item) => {
1517
- var _a2, _b;
1518
- return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
1519
- });
1498
+ const propertiesItem = this.itemManager.items.find((item) => item.modelMeta?.type === "dxos:model/document" && // TODO(burdon): Document?
1499
+ (getStateMachineFromItem(item)?.snapshot()).type === "dxos.sdk.client.Properties");
1520
1500
  if (propertiesItem) {
1521
- cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
1501
+ cache.properties = getStateMachineFromItem(propertiesItem)?.snapshot();
1522
1502
  }
1523
1503
  } catch (err) {
1524
1504
  log8.warn("Failed to cache properties", err, {
@@ -1540,11 +1520,10 @@ var DataPipeline = class DataPipeline2 {
1540
1520
  }
1541
1521
  }
1542
1522
  async _processEpochInSeparateTask(epoch) {
1543
- var _a;
1544
1523
  if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
1545
1524
  return;
1546
1525
  }
1547
- await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
1526
+ await this._epochCtx?.dispose();
1548
1527
  const ctx = new Context4({
1549
1528
  onError: (err) => {
1550
1529
  if (err instanceof CancelledError) {
@@ -1826,9 +1805,8 @@ var ControlPipeline = class {
1826
1805
  });
1827
1806
  }
1828
1807
  async _saveTargetTimeframe(timeframe) {
1829
- var _a;
1830
1808
  try {
1831
- const newTimeframe = Timeframe4.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe4(), timeframe);
1809
+ const newTimeframe = Timeframe4.merge(this._targetTimeframe ?? new Timeframe4(), timeframe);
1832
1810
  await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1833
1811
  this._targetTimeframe = newTimeframe;
1834
1812
  } catch (err) {
@@ -1946,12 +1924,10 @@ var Space = class Space2 {
1946
1924
  return this._genesisFeedKey;
1947
1925
  }
1948
1926
  get controlFeedKey() {
1949
- var _a;
1950
- return (_a = this._controlFeed) == null ? void 0 : _a.key;
1927
+ return this._controlFeed?.key;
1951
1928
  }
1952
1929
  get dataFeedKey() {
1953
- var _a;
1954
- return (_a = this._dataFeed) == null ? void 0 : _a.key;
1930
+ return this._dataFeed?.key;
1955
1931
  }
1956
1932
  get spaceState() {
1957
1933
  return this._controlPipeline.spaceState;
@@ -1983,7 +1959,6 @@ var Space = class Space2 {
1983
1959
  return this;
1984
1960
  }
1985
1961
  setDataFeed(feed) {
1986
- var _a;
1987
1962
  invariant9(!this._dataFeed, "Data feed already set.", {
1988
1963
  F: __dxlog_file11,
1989
1964
  L: 190,
@@ -1994,7 +1969,7 @@ var Space = class Space2 {
1994
1969
  ]
1995
1970
  });
1996
1971
  this._dataFeed = feed;
1997
- (_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
1972
+ this._dataPipeline.pipeline?.setWriteFeed(feed);
1998
1973
  return this;
1999
1974
  }
2000
1975
  /**
@@ -2259,7 +2234,6 @@ var SpaceProtocolSession = class {
2259
2234
  provider: this._swarmIdentity.credentialProvider,
2260
2235
  verifier: this._swarmIdentity.credentialAuthenticator,
2261
2236
  onAuthSuccess: () => {
2262
- var _a;
2263
2237
  log11("Peer authenticated", void 0, {
2264
2238
  F: __dxlog_file12,
2265
2239
  L: 236,
@@ -2267,12 +2241,11 @@ var SpaceProtocolSession = class {
2267
2241
  C: (f, a) => f(...a)
2268
2242
  });
2269
2243
  this._authStatus = AuthStatus.SUCCESS;
2270
- (_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
2244
+ this._onSessionAuth?.(this._teleport);
2271
2245
  },
2272
2246
  onAuthFailure: () => {
2273
- var _a;
2274
2247
  this._authStatus = AuthStatus.FAILURE;
2275
- (_a = this._onAuthFailure) == null ? void 0 : _a.call(this, this._teleport);
2248
+ this._onAuthFailure?.(this._teleport);
2276
2249
  }
2277
2250
  }));
2278
2251
  this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
@@ -2330,7 +2303,6 @@ var SpaceManager = class SpaceManager2 {
2330
2303
  ].map((space) => space.close()));
2331
2304
  }
2332
2305
  async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
2333
- var _a;
2334
2306
  log12.trace("dxos.echo.space-manager.construct-space", trace2.begin({
2335
2307
  id: this._instanceId
2336
2308
  }), {
@@ -2347,7 +2319,7 @@ var SpaceManager = class SpaceManager2 {
2347
2319
  S: this,
2348
2320
  C: (f, a) => f(...a)
2349
2321
  });
2350
- const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : failUndefined2());
2322
+ const genesisFeed = await this._feedStore.openFeed(metadata.genesisFeedKey ?? failUndefined2());
2351
2323
  const spaceKey = metadata.key;
2352
2324
  const protocol = new SpaceProtocol({
2353
2325
  topic: spaceKey,
@@ -2416,4 +2388,4 @@ export {
2416
2388
  SpaceProtocolSession,
2417
2389
  SpaceManager
2418
2390
  };
2419
- //# sourceMappingURL=chunk-7S5RJM3K.mjs.map
2391
+ //# sourceMappingURL=chunk-3OTHGQEY.mjs.map