@dxos/echo-pipeline 0.1.53-next.63b0547 → 0.1.53-next.e9dc2bc

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 (41) hide show
  1. package/dist/lib/browser/{chunk-SCMKAWNW.mjs → chunk-OJGL5427.mjs} +101 -67
  2. package/dist/lib/browser/chunk-OJGL5427.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 +2 -2
  6. package/dist/lib/browser/testing/index.mjs.map +2 -2
  7. package/dist/lib/node/index.cjs +102 -68
  8. package/dist/lib/node/index.cjs.map +3 -3
  9. package/dist/lib/node/meta.json +1 -1
  10. package/dist/lib/node/testing/index.cjs +108 -74
  11. package/dist/lib/node/testing/index.cjs.map +3 -3
  12. package/dist/types/src/dbhost/data-service-host.d.ts +3 -0
  13. package/dist/types/src/dbhost/data-service-host.d.ts.map +1 -1
  14. package/dist/types/src/dbhost/data-service.d.ts +2 -2
  15. package/dist/types/src/dbhost/data-service.d.ts.map +1 -1
  16. package/dist/types/src/dbhost/snapshot-manager.d.ts +2 -0
  17. package/dist/types/src/dbhost/snapshot-manager.d.ts.map +1 -1
  18. package/dist/types/src/dbhost/snapshot-store.d.ts +2 -0
  19. package/dist/types/src/dbhost/snapshot-store.d.ts.map +1 -1
  20. package/dist/types/src/metadata/metadata-store.d.ts +4 -0
  21. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  22. package/dist/types/src/pipeline/pipeline.d.ts +0 -1
  23. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  24. package/dist/types/src/space/data-pipeline.d.ts +3 -3
  25. package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
  26. package/dist/types/src/space/space.d.ts +0 -1
  27. package/dist/types/src/space/space.d.ts.map +1 -1
  28. package/package.json +30 -30
  29. package/src/dbhost/data-service-host.ts +14 -1
  30. package/src/dbhost/data-service.ts +6 -2
  31. package/src/dbhost/snapshot-manager.ts +4 -4
  32. package/src/dbhost/snapshot-store.ts +3 -2
  33. package/src/metadata/metadata-store.ts +15 -2
  34. package/src/pipeline/pipeline.ts +13 -1
  35. package/src/space/data-pipeline.ts +25 -19
  36. package/src/space/replication.browser.test.ts +2 -2
  37. package/src/space/space.test.ts +46 -5
  38. package/src/space/space.ts +3 -12
  39. package/src/testing/util.ts +1 -1
  40. package/src/tests/database.test.ts +1 -1
  41. package/dist/lib/browser/chunk-SCMKAWNW.mjs.map +0 -7
@@ -7,6 +7,7 @@ import { synchronized, Event } from "@dxos/async";
7
7
  import { DataCorruptionError } from "@dxos/errors";
8
8
  import { log } from "@dxos/log";
9
9
  import { STORAGE_VERSION, schema } from "@dxos/protocols";
10
+ import { SpaceState } from "@dxos/protocols/proto/dxos/client/services";
10
11
  import { arrayToBuffer } from "@dxos/util";
11
12
  function _ts_decorate(decorators, target, key, desc) {
12
13
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -25,6 +26,7 @@ var emptyEchoMetadata = () => ({
25
26
  created: new Date(),
26
27
  updated: new Date()
27
28
  });
29
+ var EchoMetadata = schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
28
30
  var MetadataStore = class {
29
31
  // prettier-ignore
30
32
  constructor(_directory) {
@@ -51,6 +53,7 @@ var MetadataStore = class {
51
53
  * Loads metadata from persistent storage.
52
54
  */
53
55
  async load() {
56
+ var _a;
54
57
  const file = this._directory.getOrCreateFile("EchoMetadata");
55
58
  try {
56
59
  const { size: fileLength } = await file.stat();
@@ -64,7 +67,7 @@ var MetadataStore = class {
64
67
  checksum
65
68
  }, {
66
69
  F: __dxlog_file,
67
- L: 69,
70
+ L: 72,
68
71
  S: this,
69
72
  C: (f, a) => f(...a)
70
73
  });
@@ -76,13 +79,17 @@ var MetadataStore = class {
76
79
  if (calculatedChecksum !== checksum) {
77
80
  throw new DataCorruptionError("Metadata checksum is invalid.");
78
81
  }
79
- this._metadata = schema.getCodecForType("dxos.echo.metadata.EchoMetadata").decode(data);
82
+ this._metadata = EchoMetadata.decode(data);
83
+ (_a = this._metadata.spaces) == null ? void 0 : _a.forEach((space) => {
84
+ var _a2;
85
+ (_a2 = space.state) != null ? _a2 : space.state = SpaceState.ACTIVE;
86
+ });
80
87
  } catch (err) {
81
88
  log.error("failed to load metadata", {
82
89
  err
83
90
  }, {
84
91
  F: __dxlog_file,
85
- L: 84,
92
+ L: 92,
86
93
  S: this,
87
94
  C: (f, a) => f(...a)
88
95
  });
@@ -102,7 +109,7 @@ var MetadataStore = class {
102
109
  this.update.emit(data);
103
110
  const file = this._directory.getOrCreateFile("EchoMetadata");
104
111
  try {
105
- const encoded = arrayToBuffer(schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
112
+ const encoded = arrayToBuffer(EchoMetadata.encode(data));
106
113
  const checksum = CRC32.buf(encoded);
107
114
  const result = Buffer.alloc(8 + encoded.length);
108
115
  result.writeInt32LE(encoded.length, 0);
@@ -114,7 +121,7 @@ var MetadataStore = class {
114
121
  checksum
115
122
  }, {
116
123
  F: __dxlog_file,
117
- L: 116,
124
+ L: 124,
118
125
  S: this,
119
126
  C: (f, a) => f(...a)
120
127
  });
@@ -137,7 +144,7 @@ var MetadataStore = class {
137
144
  async clear() {
138
145
  log("clearing all metadata", void 0, {
139
146
  F: __dxlog_file,
140
- L: 137,
147
+ L: 145,
141
148
  S: this,
142
149
  C: (f, a) => f(...a)
143
150
  });
@@ -176,6 +183,10 @@ var MetadataStore = class {
176
183
  space.dataFeedKey = dataFeedKey;
177
184
  await this._save();
178
185
  }
186
+ async setSpaceState(spaceKey, state) {
187
+ this._getSpace(spaceKey).state = state;
188
+ await this._save();
189
+ }
179
190
  };
180
191
  _ts_decorate([
181
192
  synchronized
@@ -349,6 +360,7 @@ var PipelineState = class {
349
360
  constructor(_feeds, _timeframeClock) {
350
361
  this._feeds = _feeds;
351
362
  this._timeframeClock = _timeframeClock;
363
+ this._ctx = new Context();
352
364
  this.timeframeUpdate = this._timeframeClock.update;
353
365
  this.stalled = new Event3();
354
366
  this._startTimeframe = new Timeframe2();
@@ -400,7 +412,7 @@ var PipelineState = class {
400
412
  target: this.targetTimeframe
401
413
  }, {
402
414
  F: __dxlog_file4,
403
- L: 118,
415
+ L: 126,
404
416
  S: this,
405
417
  C: (f, a) => f(...a)
406
418
  });
@@ -416,6 +428,7 @@ var PipelineState = class {
416
428
  if (timeout) {
417
429
  return Promise.race([
418
430
  rejectOnDispose(ctx),
431
+ rejectOnDispose(this._ctx),
419
432
  this._reachedTargetPromise.then(() => {
420
433
  done = true;
421
434
  }),
@@ -430,7 +443,7 @@ var PipelineState = class {
430
443
  dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
431
444
  }, {
432
445
  F: __dxlog_file4,
433
- L: 144,
446
+ L: 153,
434
447
  S: this,
435
448
  C: (f, a) => f(...a)
436
449
  });
@@ -488,7 +501,7 @@ var Pipeline = class {
488
501
  async start() {
489
502
  log4("starting...", {}, {
490
503
  F: __dxlog_file4,
491
- L: 264,
504
+ L: 273,
492
505
  S: this,
493
506
  C: (f, a) => f(...a)
494
507
  });
@@ -496,7 +509,7 @@ var Pipeline = class {
496
509
  await this._feedSetIterator.open();
497
510
  log4("started", void 0, {
498
511
  F: __dxlog_file4,
499
- L: 267,
512
+ L: 276,
500
513
  S: this,
501
514
  C: (f, a) => f(...a)
502
515
  });
@@ -506,16 +519,19 @@ var Pipeline = class {
506
519
  var _a;
507
520
  log4("stopping...", {}, {
508
521
  F: __dxlog_file4,
509
- L: 273,
522
+ L: 282,
510
523
  S: this,
511
524
  C: (f, a) => f(...a)
512
525
  });
513
526
  this._isStopping = true;
514
527
  await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
515
528
  await this._processingTrigger.wait();
529
+ await this._state._ctx.dispose();
530
+ this._state._ctx = new Context();
531
+ this._state._reachedTargetPromise = void 0;
516
532
  log4("stopped", void 0, {
517
533
  F: __dxlog_file4,
518
- L: 277,
534
+ L: 289,
519
535
  S: this,
520
536
  C: (f, a) => f(...a)
521
537
  });
@@ -592,7 +608,7 @@ var Pipeline = class {
592
608
  feed.undownload({
593
609
  callback: () => log4("Undownloaded", void 0, {
594
610
  F: __dxlog_file4,
595
- L: 371,
611
+ L: 383,
596
612
  S: this,
597
613
  C: (f, a) => f(...a)
598
614
  })
@@ -605,7 +621,7 @@ var Pipeline = class {
605
621
  err
606
622
  }, {
607
623
  F: __dxlog_file4,
608
- L: 374,
624
+ L: 386,
609
625
  S: this,
610
626
  C: (f, a) => f(...a)
611
627
  });
@@ -619,7 +635,7 @@ var Pipeline = class {
619
635
  this._feedSetIterator.stalled.on((iterator) => {
620
636
  log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
621
637
  F: __dxlog_file4,
622
- L: 384,
638
+ L: 396,
623
639
  S: this,
624
640
  C: (f, a) => f(...a)
625
641
  });
@@ -736,6 +752,7 @@ var AuthExtension = class extends RpcExtension {
736
752
  // packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
737
753
  import invariant6 from "tiny-invariant";
738
754
  import { Stream } from "@dxos/codec-protobuf";
755
+ import { Context as Context3 } from "@dxos/context";
739
756
  import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
740
757
  import { log as log6 } from "@dxos/log";
741
758
  import { ComplexMap as ComplexMap2 } from "@dxos/util";
@@ -745,13 +762,20 @@ var DataServiceHost = class {
745
762
  this._itemManager = _itemManager;
746
763
  this._itemDemuxer = _itemDemuxer;
747
764
  this._writeStream = _writeStream;
765
+ this._ctx = new Context3();
748
766
  this._clientTagMap = new ComplexMap2(([feedKey, seq]) => `${feedKey.toHex()}:${seq}`);
749
767
  }
768
+ async open() {
769
+ }
770
+ async close() {
771
+ await this._ctx.dispose();
772
+ }
750
773
  /**
751
774
  * Real-time subscription to data objects in a space.
752
775
  */
753
776
  subscribe() {
754
- return new Stream(({ next, ctx }) => {
777
+ return new Stream(({ next, close, ctx }) => {
778
+ ctx.onDispose(this._ctx.onDispose(close));
755
779
  const objects = Array.from(this._itemManager.entities.values()).map((entity) => entity.createSnapshot());
756
780
  next({
757
781
  batch: {
@@ -767,7 +791,7 @@ var DataServiceHost = class {
767
791
  meta
768
792
  }, {
769
793
  F: __dxlog_file6,
770
- L: 51,
794
+ L: 63,
771
795
  S: this,
772
796
  C: (f, a) => f(...a)
773
797
  });
@@ -794,13 +818,14 @@ var DataServiceHost = class {
794
818
  }
795
819
  async write(request) {
796
820
  var _a, _b;
821
+ invariant6(!this._ctx.disposed, "Cannot write to closed DataServiceHost");
797
822
  invariant6(this._writeStream, "Cannot write mutations in readonly mode");
798
823
  log6("write", {
799
824
  clientTag: request.clientTag,
800
825
  objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
801
826
  }, {
802
827
  F: __dxlog_file6,
803
- L: 79,
828
+ L: 92,
804
829
  S: this,
805
830
  C: (f, a) => f(...a)
806
831
  });
@@ -814,7 +839,7 @@ var DataServiceHost = class {
814
839
  seq: receipt2.seq
815
840
  }, {
816
841
  F: __dxlog_file6,
817
- L: 88,
842
+ L: 101,
818
843
  S: this,
819
844
  C: (f, a) => f(...a)
820
845
  });
@@ -896,6 +921,7 @@ function _ts_decorate4(decorators, target, key, desc) {
896
921
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
897
922
  return c > 3 && r && Object.defineProperty(target, key, r), r;
898
923
  }
924
+ var SpaceSnapshot = schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
899
925
  var SnapshotManager = class SnapshotManager2 {
900
926
  // prettier-ignore
901
927
  constructor(_snapshotStore, _blobStore, _blobSync) {
@@ -905,7 +931,7 @@ var SnapshotManager = class SnapshotManager2 {
905
931
  }
906
932
  async _getBlob(blobId) {
907
933
  const blob = await this._blobStore.get(blobId);
908
- return schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(blob);
934
+ return SpaceSnapshot.decode(blob);
909
935
  }
910
936
  async load(ctx, id) {
911
937
  const blobId = PublicKey2.fromHex(id).asUint8Array();
@@ -921,7 +947,7 @@ var SnapshotManager = class SnapshotManager2 {
921
947
  return this._getBlob(blobId);
922
948
  }
923
949
  async store(snapshot) {
924
- const { id } = await this._blobStore.set(schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot));
950
+ const { id } = await this._blobStore.set(SpaceSnapshot.encode(snapshot));
925
951
  await this._blobSync.notifyBlobAdded(id);
926
952
  return PublicKey2.from(id).toHex();
927
953
  }
@@ -936,13 +962,14 @@ SnapshotManager = _ts_decorate4([
936
962
  // packages/core/echo/echo-pipeline/src/dbhost/snapshot-store.ts
937
963
  import { subtleCrypto } from "@dxos/crypto";
938
964
  import { schema as schema5 } from "@dxos/protocols";
965
+ var SpaceSnapshot2 = schema5.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
939
966
  var SnapshotStore = class {
940
967
  // prettier-ignore
941
968
  constructor(_directory) {
942
969
  this._directory = _directory;
943
970
  }
944
971
  async saveSnapshot(snapshot) {
945
- const encoded = schema5.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot);
972
+ const encoded = SpaceSnapshot2.encode(snapshot);
946
973
  const key = await subtleCrypto.digest("SHA-256", encoded);
947
974
  const keyString = Buffer.from(key).toString("hex");
948
975
  const file = await this._directory.getOrCreateFile(keyString);
@@ -961,7 +988,7 @@ var SnapshotStore = class {
961
988
  return void 0;
962
989
  }
963
990
  const buffer = await file.read(0, size);
964
- return schema5.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(buffer);
991
+ return SpaceSnapshot2.decode(buffer);
965
992
  } finally {
966
993
  await file.close();
967
994
  }
@@ -992,7 +1019,7 @@ var DataServiceSubscriptions = class {
992
1019
  clear() {
993
1020
  this._spaces.clear();
994
1021
  }
995
- registerSpace(spaceKey, host) {
1022
+ async registerSpace(spaceKey, host) {
996
1023
  log7("Registering space", {
997
1024
  spaceKey
998
1025
  }, {
@@ -1001,17 +1028,21 @@ var DataServiceSubscriptions = class {
1001
1028
  S: this,
1002
1029
  C: (f, a) => f(...a)
1003
1030
  });
1031
+ invariant7(!this._spaces.has(spaceKey));
1032
+ await host.open();
1004
1033
  this._spaces.set(spaceKey, host);
1005
1034
  }
1006
- unregisterSpace(spaceKey) {
1035
+ async unregisterSpace(spaceKey) {
1007
1036
  log7("Unregistering space", {
1008
1037
  spaceKey
1009
1038
  }, {
1010
1039
  F: __dxlog_file7,
1011
- L: 36,
1040
+ L: 38,
1012
1041
  S: this,
1013
1042
  C: (f, a) => f(...a)
1014
1043
  });
1044
+ const host = this._spaces.get(spaceKey);
1045
+ await (host == null ? void 0 : host.close());
1015
1046
  this._spaces.delete(spaceKey);
1016
1047
  }
1017
1048
  getDataService(spaceKey) {
@@ -1040,7 +1071,7 @@ var DataServiceImpl = class {
1040
1071
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1041
1072
  import invariant8 from "tiny-invariant";
1042
1073
  import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
1043
- import { Context as Context3 } from "@dxos/context";
1074
+ import { Context as Context4 } from "@dxos/context";
1044
1075
  import { checkCredentialType } from "@dxos/credentials";
1045
1076
  import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
1046
1077
  import { CancelledError } from "@dxos/errors";
@@ -1063,11 +1094,15 @@ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1063
1094
  var DataPipeline = class DataPipeline2 {
1064
1095
  constructor(_params) {
1065
1096
  this._params = _params;
1066
- this._ctx = new Context3();
1097
+ this._ctx = new Context4();
1098
+ this._pipeline = void 0;
1099
+ this._targetTimeframe = void 0;
1067
1100
  this._lastAutomaticSnapshotTimeframe = new Timeframe3();
1068
1101
  this._isOpen = false;
1069
1102
  this._lastTimeframeSaveTime = 0;
1070
1103
  this._lastSnapshotSaveTime = 0;
1104
+ this.currentEpoch = void 0;
1105
+ this.appliedEpoch = void 0;
1071
1106
  this._lastProcessedEpoch = -1;
1072
1107
  this.onNewEpoch = new Event4();
1073
1108
  }
@@ -1086,18 +1121,14 @@ var DataPipeline = class DataPipeline2 {
1086
1121
  this._targetTimeframe = timeframe;
1087
1122
  (_a = this._pipeline) == null ? void 0 : _a.state.setTargetTimeframe(timeframe);
1088
1123
  }
1089
- createCredentialProcessor() {
1090
- return {
1091
- process: async (credential) => {
1092
- if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1093
- return;
1094
- }
1095
- this.currentEpoch = credential;
1096
- if (this._isOpen) {
1097
- await this._processEpochInSeparateTask(credential);
1098
- }
1099
- }
1100
- };
1124
+ async processCredential(credential) {
1125
+ if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1126
+ return;
1127
+ }
1128
+ this.currentEpoch = credential;
1129
+ if (this._isOpen) {
1130
+ await this._processEpochInSeparateTask(credential);
1131
+ }
1101
1132
  }
1102
1133
  async open() {
1103
1134
  if (this._isOpen) {
@@ -1134,7 +1165,7 @@ var DataPipeline = class DataPipeline2 {
1134
1165
  }
1135
1166
  log8("close", void 0, {
1136
1167
  F: __dxlog_file8,
1137
- L: 174,
1168
+ L: 171,
1138
1169
  S: this,
1139
1170
  C: (f, a) => f(...a)
1140
1171
  });
@@ -1149,13 +1180,21 @@ var DataPipeline = class DataPipeline2 {
1149
1180
  } catch (err) {
1150
1181
  log8.catch(err, void 0, {
1151
1182
  F: __dxlog_file8,
1152
- L: 187,
1183
+ L: 184,
1153
1184
  S: this,
1154
1185
  C: (f, a) => f(...a)
1155
1186
  });
1156
1187
  }
1157
1188
  await ((_b = this.databaseHost) == null ? void 0 : _b.close());
1158
1189
  await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
1190
+ this._ctx = new Context4();
1191
+ this._pipeline = void 0;
1192
+ this._targetTimeframe = void 0;
1193
+ this._lastAutomaticSnapshotTimeframe = new Timeframe3();
1194
+ this.currentEpoch = void 0;
1195
+ this.appliedEpoch = void 0;
1196
+ this._lastProcessedEpoch = -1;
1197
+ this._epochCtx = void 0;
1159
1198
  }
1160
1199
  async _consumePipeline() {
1161
1200
  if (this.currentEpoch) {
@@ -1171,7 +1210,7 @@ var DataPipeline = class DataPipeline2 {
1171
1210
  seq
1172
1211
  }, {
1173
1212
  F: __dxlog_file8,
1174
- L: 204,
1213
+ L: 210,
1175
1214
  S: this,
1176
1215
  C: (f, a) => f(...a)
1177
1216
  });
@@ -1183,7 +1222,7 @@ var DataPipeline = class DataPipeline2 {
1183
1222
  feedKey
1184
1223
  }, {
1185
1224
  F: __dxlog_file8,
1186
- L: 210,
1225
+ L: 216,
1187
1226
  S: this,
1188
1227
  C: (f, a) => f(...a)
1189
1228
  });
@@ -1204,7 +1243,7 @@ var DataPipeline = class DataPipeline2 {
1204
1243
  spaceKey: this._params.spaceKey.toHex()
1205
1244
  }, {
1206
1245
  F: __dxlog_file8,
1207
- L: 224,
1246
+ L: 230,
1208
1247
  S: this,
1209
1248
  C: (f, a) => f(...a)
1210
1249
  });
@@ -1213,7 +1252,7 @@ var DataPipeline = class DataPipeline2 {
1213
1252
  } catch (err) {
1214
1253
  log8.catch(err, void 0, {
1215
1254
  F: __dxlog_file8,
1216
- L: 234,
1255
+ L: 240,
1217
1256
  S: this,
1218
1257
  C: (f, a) => f(...a)
1219
1258
  });
@@ -1248,7 +1287,7 @@ var DataPipeline = class DataPipeline2 {
1248
1287
  } catch (err) {
1249
1288
  log8.warn("Failed to cache properties", err, {
1250
1289
  F: __dxlog_file8,
1251
- L: 269,
1290
+ L: 275,
1252
1291
  S: this,
1253
1292
  C: (f, a) => f(...a)
1254
1293
  });
@@ -1270,19 +1309,19 @@ var DataPipeline = class DataPipeline2 {
1270
1309
  return;
1271
1310
  }
1272
1311
  await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
1273
- const ctx = new Context3({
1312
+ const ctx = new Context4({
1274
1313
  onError: (err) => {
1275
1314
  if (err instanceof CancelledError) {
1276
1315
  log8("Epoch processing cancelled.", void 0, {
1277
1316
  F: __dxlog_file8,
1278
- L: 301,
1317
+ L: 307,
1279
1318
  S: this,
1280
1319
  C: (f, a) => f(...a)
1281
1320
  });
1282
1321
  } else {
1283
1322
  log8.catch(err, void 0, {
1284
1323
  F: __dxlog_file8,
1285
- L: 303,
1324
+ L: 309,
1286
1325
  S: this,
1287
1326
  C: (f, a) => f(...a)
1288
1327
  });
@@ -1298,7 +1337,7 @@ var DataPipeline = class DataPipeline2 {
1298
1337
  epoch
1299
1338
  }, {
1300
1339
  F: __dxlog_file8,
1301
- L: 313,
1340
+ L: 319,
1302
1341
  S: this,
1303
1342
  C: (f, a) => f(...a)
1304
1343
  });
@@ -1315,7 +1354,7 @@ var DataPipeline = class DataPipeline2 {
1315
1354
  epoch
1316
1355
  }, {
1317
1356
  F: __dxlog_file8,
1318
- L: 327,
1357
+ L: 333,
1319
1358
  S: this,
1320
1359
  C: (f, a) => f(...a)
1321
1360
  });
@@ -1325,7 +1364,7 @@ var DataPipeline = class DataPipeline2 {
1325
1364
  }
1326
1365
  log8("restarting pipeline for epoch", void 0, {
1327
1366
  F: __dxlog_file8,
1328
- L: 335,
1367
+ L: 341,
1329
1368
  S: this,
1330
1369
  C: (f, a) => f(...a)
1331
1370
  });
@@ -1541,8 +1580,6 @@ var Space = class Space2 {
1541
1580
  this._addFeedLock = new Lock();
1542
1581
  this.onCredentialProcessed = new Callback2();
1543
1582
  this.stateUpdate = new Event5();
1544
- // Processes epoch credentials.
1545
- this._dataPipelineCredentialConsumer = void 0;
1546
1583
  this._isOpen = false;
1547
1584
  invariant9(params.spaceKey && params.feedProvider);
1548
1585
  this._key = params.spaceKey;
@@ -1580,7 +1617,7 @@ var Space = class Space2 {
1580
1617
  credential
1581
1618
  }, {
1582
1619
  F: __dxlog_file10,
1583
- L: 110,
1620
+ L: 107,
1584
1621
  S: this,
1585
1622
  C: (f, a) => f(...a)
1586
1623
  });
@@ -1672,7 +1709,7 @@ var Space = class Space2 {
1672
1709
  async open() {
1673
1710
  log10("opening...", void 0, {
1674
1711
  F: __dxlog_file10,
1675
- L: 212,
1712
+ L: 209,
1676
1713
  S: this,
1677
1714
  C: (f, a) => f(...a)
1678
1715
  });
@@ -1681,38 +1718,35 @@ var Space = class Space2 {
1681
1718
  }
1682
1719
  await this._controlPipeline.start();
1683
1720
  await this.protocol.start();
1684
- this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1685
- await this._dataPipelineCredentialConsumer.open();
1721
+ await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
1686
1722
  this._isOpen = true;
1687
1723
  log10("opened", void 0, {
1688
1724
  F: __dxlog_file10,
1689
- L: 228,
1725
+ L: 220,
1690
1726
  S: this,
1691
1727
  C: (f, a) => f(...a)
1692
1728
  });
1693
1729
  }
1694
1730
  async close() {
1695
- var _a;
1696
1731
  log10("closing...", {
1697
1732
  key: this._key
1698
1733
  }, {
1699
1734
  F: __dxlog_file10,
1700
- L: 233,
1735
+ L: 225,
1701
1736
  S: this,
1702
1737
  C: (f, a) => f(...a)
1703
1738
  });
1704
1739
  if (!this._isOpen) {
1705
1740
  return;
1706
1741
  }
1707
- await ((_a = this._dataPipelineCredentialConsumer) == null ? void 0 : _a.close());
1708
- this._dataPipelineCredentialConsumer = void 0;
1742
+ await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
1709
1743
  await this._dataPipeline.close();
1710
1744
  await this.protocol.stop();
1711
1745
  await this._controlPipeline.stop();
1712
1746
  this._isOpen = false;
1713
1747
  log10("closed", void 0, {
1714
1748
  F: __dxlog_file10,
1715
- L: 247,
1749
+ L: 238,
1716
1750
  S: this,
1717
1751
  C: (f, a) => f(...a)
1718
1752
  });
@@ -1720,7 +1754,7 @@ var Space = class Space2 {
1720
1754
  async initializeDataPipeline() {
1721
1755
  log10("initializeDataPipeline", void 0, {
1722
1756
  F: __dxlog_file10,
1723
- L: 252,
1757
+ L: 243,
1724
1758
  S: this,
1725
1759
  C: (f, a) => f(...a)
1726
1760
  });
@@ -2068,4 +2102,4 @@ export {
2068
2102
  SpaceProtocolSession,
2069
2103
  SpaceManager
2070
2104
  };
2071
- //# sourceMappingURL=chunk-SCMKAWNW.mjs.map
2105
+ //# sourceMappingURL=chunk-OJGL5427.mjs.map