@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
@@ -120,6 +120,7 @@ var import_async = require("@dxos/async");
120
120
  var import_errors = require("@dxos/errors");
121
121
  var import_log = require("@dxos/log");
122
122
  var import_protocols = require("@dxos/protocols");
123
+ var import_services = require("@dxos/protocols/proto/dxos/client/services");
123
124
  var import_util = require("@dxos/util");
124
125
  function _ts_decorate(decorators, target, key, desc) {
125
126
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -138,6 +139,7 @@ var emptyEchoMetadata = () => ({
138
139
  created: new Date(),
139
140
  updated: new Date()
140
141
  });
142
+ var EchoMetadata = import_protocols.schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
141
143
  var MetadataStore = class {
142
144
  // prettier-ignore
143
145
  constructor(_directory) {
@@ -164,6 +166,7 @@ var MetadataStore = class {
164
166
  * Loads metadata from persistent storage.
165
167
  */
166
168
  async load() {
169
+ var _a;
167
170
  const file = this._directory.getOrCreateFile("EchoMetadata");
168
171
  try {
169
172
  const { size: fileLength } = await file.stat();
@@ -177,7 +180,7 @@ var MetadataStore = class {
177
180
  checksum
178
181
  }, {
179
182
  F: __dxlog_file,
180
- L: 69,
183
+ L: 72,
181
184
  S: this,
182
185
  C: (f, a) => f(...a)
183
186
  });
@@ -189,13 +192,17 @@ var MetadataStore = class {
189
192
  if (calculatedChecksum !== checksum) {
190
193
  throw new import_errors.DataCorruptionError("Metadata checksum is invalid.");
191
194
  }
192
- this._metadata = import_protocols.schema.getCodecForType("dxos.echo.metadata.EchoMetadata").decode(data);
195
+ this._metadata = EchoMetadata.decode(data);
196
+ (_a = this._metadata.spaces) == null ? void 0 : _a.forEach((space) => {
197
+ var _a2;
198
+ (_a2 = space.state) != null ? _a2 : space.state = import_services.SpaceState.ACTIVE;
199
+ });
193
200
  } catch (err) {
194
201
  import_log.log.error("failed to load metadata", {
195
202
  err
196
203
  }, {
197
204
  F: __dxlog_file,
198
- L: 84,
205
+ L: 92,
199
206
  S: this,
200
207
  C: (f, a) => f(...a)
201
208
  });
@@ -215,7 +222,7 @@ var MetadataStore = class {
215
222
  this.update.emit(data);
216
223
  const file = this._directory.getOrCreateFile("EchoMetadata");
217
224
  try {
218
- const encoded = (0, import_util.arrayToBuffer)(import_protocols.schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
225
+ const encoded = (0, import_util.arrayToBuffer)(EchoMetadata.encode(data));
219
226
  const checksum = import_crc_32.default.buf(encoded);
220
227
  const result = Buffer.alloc(8 + encoded.length);
221
228
  result.writeInt32LE(encoded.length, 0);
@@ -227,7 +234,7 @@ var MetadataStore = class {
227
234
  checksum
228
235
  }, {
229
236
  F: __dxlog_file,
230
- L: 116,
237
+ L: 124,
231
238
  S: this,
232
239
  C: (f, a) => f(...a)
233
240
  });
@@ -250,7 +257,7 @@ var MetadataStore = class {
250
257
  async clear() {
251
258
  (0, import_log.log)("clearing all metadata", void 0, {
252
259
  F: __dxlog_file,
253
- L: 137,
260
+ L: 145,
254
261
  S: this,
255
262
  C: (f, a) => f(...a)
256
263
  });
@@ -289,6 +296,10 @@ var MetadataStore = class {
289
296
  space.dataFeedKey = dataFeedKey;
290
297
  await this._save();
291
298
  }
299
+ async setSpaceState(spaceKey, state) {
300
+ this._getSpace(spaceKey).state = state;
301
+ await this._save();
302
+ }
292
303
  };
293
304
  _ts_decorate([
294
305
  import_async.synchronized
@@ -462,6 +473,7 @@ var PipelineState = class {
462
473
  constructor(_feeds, _timeframeClock) {
463
474
  this._feeds = _feeds;
464
475
  this._timeframeClock = _timeframeClock;
476
+ this._ctx = new import_context.Context();
465
477
  this.timeframeUpdate = this._timeframeClock.update;
466
478
  this.stalled = new import_async3.Event();
467
479
  this._startTimeframe = new import_timeframe2.Timeframe();
@@ -513,7 +525,7 @@ var PipelineState = class {
513
525
  target: this.targetTimeframe
514
526
  }, {
515
527
  F: __dxlog_file4,
516
- L: 118,
528
+ L: 126,
517
529
  S: this,
518
530
  C: (f, a) => f(...a)
519
531
  });
@@ -529,6 +541,7 @@ var PipelineState = class {
529
541
  if (timeout) {
530
542
  return Promise.race([
531
543
  (0, import_context.rejectOnDispose)(ctx),
544
+ (0, import_context.rejectOnDispose)(this._ctx),
532
545
  this._reachedTargetPromise.then(() => {
533
546
  done = true;
534
547
  }),
@@ -543,7 +556,7 @@ var PipelineState = class {
543
556
  dependencies: import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe)
544
557
  }, {
545
558
  F: __dxlog_file4,
546
- L: 144,
559
+ L: 153,
547
560
  S: this,
548
561
  C: (f, a) => f(...a)
549
562
  });
@@ -601,7 +614,7 @@ var Pipeline = class {
601
614
  async start() {
602
615
  (0, import_log4.log)("starting...", {}, {
603
616
  F: __dxlog_file4,
604
- L: 264,
617
+ L: 273,
605
618
  S: this,
606
619
  C: (f, a) => f(...a)
607
620
  });
@@ -609,7 +622,7 @@ var Pipeline = class {
609
622
  await this._feedSetIterator.open();
610
623
  (0, import_log4.log)("started", void 0, {
611
624
  F: __dxlog_file4,
612
- L: 267,
625
+ L: 276,
613
626
  S: this,
614
627
  C: (f, a) => f(...a)
615
628
  });
@@ -619,16 +632,19 @@ var Pipeline = class {
619
632
  var _a;
620
633
  (0, import_log4.log)("stopping...", {}, {
621
634
  F: __dxlog_file4,
622
- L: 273,
635
+ L: 282,
623
636
  S: this,
624
637
  C: (f, a) => f(...a)
625
638
  });
626
639
  this._isStopping = true;
627
640
  await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
628
641
  await this._processingTrigger.wait();
642
+ await this._state._ctx.dispose();
643
+ this._state._ctx = new import_context.Context();
644
+ this._state._reachedTargetPromise = void 0;
629
645
  (0, import_log4.log)("stopped", void 0, {
630
646
  F: __dxlog_file4,
631
- L: 277,
647
+ L: 289,
632
648
  S: this,
633
649
  C: (f, a) => f(...a)
634
650
  });
@@ -705,7 +721,7 @@ var Pipeline = class {
705
721
  feed.undownload({
706
722
  callback: () => (0, import_log4.log)("Undownloaded", void 0, {
707
723
  F: __dxlog_file4,
708
- L: 371,
724
+ L: 383,
709
725
  S: this,
710
726
  C: (f, a) => f(...a)
711
727
  })
@@ -718,7 +734,7 @@ var Pipeline = class {
718
734
  err
719
735
  }, {
720
736
  F: __dxlog_file4,
721
- L: 374,
737
+ L: 386,
722
738
  S: this,
723
739
  C: (f, a) => f(...a)
724
740
  });
@@ -732,7 +748,7 @@ var Pipeline = class {
732
748
  this._feedSetIterator.stalled.on((iterator) => {
733
749
  import_log4.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
734
750
  F: __dxlog_file4,
735
- L: 384,
751
+ L: 396,
736
752
  S: this,
737
753
  C: (f, a) => f(...a)
738
754
  });
@@ -1001,7 +1017,7 @@ var ControlPipeline = class {
1001
1017
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1002
1018
  var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
1003
1019
  var import_async6 = require("@dxos/async");
1004
- var import_context4 = require("@dxos/context");
1020
+ var import_context5 = require("@dxos/context");
1005
1021
  var import_credentials3 = require("@dxos/credentials");
1006
1022
  var import_echo_db3 = require("@dxos/echo-db");
1007
1023
  var import_errors2 = require("@dxos/errors");
@@ -1011,6 +1027,7 @@ var import_timeframe4 = require("@dxos/timeframe");
1011
1027
  // packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
1012
1028
  var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
1013
1029
  var import_codec_protobuf = require("@dxos/codec-protobuf");
1030
+ var import_context3 = require("@dxos/context");
1014
1031
  var import_echo_db = require("@dxos/echo-db");
1015
1032
  var import_log7 = require("@dxos/log");
1016
1033
  var import_util4 = require("@dxos/util");
@@ -1020,13 +1037,20 @@ var DataServiceHost = class {
1020
1037
  this._itemManager = _itemManager;
1021
1038
  this._itemDemuxer = _itemDemuxer;
1022
1039
  this._writeStream = _writeStream;
1040
+ this._ctx = new import_context3.Context();
1023
1041
  this._clientTagMap = new import_util4.ComplexMap(([feedKey, seq]) => `${feedKey.toHex()}:${seq}`);
1024
1042
  }
1043
+ async open() {
1044
+ }
1045
+ async close() {
1046
+ await this._ctx.dispose();
1047
+ }
1025
1048
  /**
1026
1049
  * Real-time subscription to data objects in a space.
1027
1050
  */
1028
1051
  subscribe() {
1029
- return new import_codec_protobuf.Stream(({ next, ctx }) => {
1052
+ return new import_codec_protobuf.Stream(({ next, close, ctx }) => {
1053
+ ctx.onDispose(this._ctx.onDispose(close));
1030
1054
  const objects = Array.from(this._itemManager.entities.values()).map((entity) => entity.createSnapshot());
1031
1055
  next({
1032
1056
  batch: {
@@ -1042,7 +1066,7 @@ var DataServiceHost = class {
1042
1066
  meta
1043
1067
  }, {
1044
1068
  F: __dxlog_file7,
1045
- L: 51,
1069
+ L: 63,
1046
1070
  S: this,
1047
1071
  C: (f, a) => f(...a)
1048
1072
  });
@@ -1069,13 +1093,14 @@ var DataServiceHost = class {
1069
1093
  }
1070
1094
  async write(request) {
1071
1095
  var _a, _b;
1096
+ (0, import_tiny_invariant6.default)(!this._ctx.disposed, "Cannot write to closed DataServiceHost");
1072
1097
  (0, import_tiny_invariant6.default)(this._writeStream, "Cannot write mutations in readonly mode");
1073
1098
  (0, import_log7.log)("write", {
1074
1099
  clientTag: request.clientTag,
1075
1100
  objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
1076
1101
  }, {
1077
1102
  F: __dxlog_file7,
1078
- L: 79,
1103
+ L: 92,
1079
1104
  S: this,
1080
1105
  C: (f, a) => f(...a)
1081
1106
  });
@@ -1089,7 +1114,7 @@ var DataServiceHost = class {
1089
1114
  seq: receipt2.seq
1090
1115
  }, {
1091
1116
  F: __dxlog_file7,
1092
- L: 88,
1117
+ L: 101,
1093
1118
  S: this,
1094
1119
  C: (f, a) => f(...a)
1095
1120
  });
@@ -1156,7 +1181,7 @@ var DatabaseHost = class {
1156
1181
 
1157
1182
  // packages/core/echo/echo-pipeline/src/dbhost/snapshot-manager.ts
1158
1183
  var import_async5 = require("@dxos/async");
1159
- var import_context3 = require("@dxos/context");
1184
+ var import_context4 = require("@dxos/context");
1160
1185
  var import_debug3 = require("@dxos/debug");
1161
1186
  var import_keys3 = require("@dxos/keys");
1162
1187
  var import_protocols4 = require("@dxos/protocols");
@@ -1171,6 +1196,7 @@ function _ts_decorate4(decorators, target, key, desc) {
1171
1196
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1172
1197
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1173
1198
  }
1199
+ var SpaceSnapshot = import_protocols4.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
1174
1200
  var SnapshotManager = class SnapshotManager2 {
1175
1201
  // prettier-ignore
1176
1202
  constructor(_snapshotStore, _blobStore, _blobSync) {
@@ -1180,7 +1206,7 @@ var SnapshotManager = class SnapshotManager2 {
1180
1206
  }
1181
1207
  async _getBlob(blobId) {
1182
1208
  const blob = await this._blobStore.get(blobId);
1183
- return import_protocols4.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(blob);
1209
+ return SpaceSnapshot.decode(blob);
1184
1210
  }
1185
1211
  async load(ctx, id) {
1186
1212
  const blobId = import_keys3.PublicKey.fromHex(id).asUint8Array();
@@ -1188,7 +1214,7 @@ var SnapshotManager = class SnapshotManager2 {
1188
1214
  if (blobMeta && blobMeta.state === import_blob.BlobMeta.State.FULLY_PRESENT) {
1189
1215
  return this._getBlob(blobId);
1190
1216
  }
1191
- const fallbackStore = await (0, import_context3.cancelWithContext)(ctx, this._snapshotStore.loadSnapshot(id));
1217
+ const fallbackStore = await (0, import_context4.cancelWithContext)(ctx, this._snapshotStore.loadSnapshot(id));
1192
1218
  if (fallbackStore) {
1193
1219
  return fallbackStore;
1194
1220
  }
@@ -1196,7 +1222,7 @@ var SnapshotManager = class SnapshotManager2 {
1196
1222
  return this._getBlob(blobId);
1197
1223
  }
1198
1224
  async store(snapshot) {
1199
- const { id } = await this._blobStore.set(import_protocols4.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot));
1225
+ const { id } = await this._blobStore.set(SpaceSnapshot.encode(snapshot));
1200
1226
  await this._blobSync.notifyBlobAdded(id);
1201
1227
  return import_keys3.PublicKey.from(id).toHex();
1202
1228
  }
@@ -1211,13 +1237,14 @@ SnapshotManager = _ts_decorate4([
1211
1237
  // packages/core/echo/echo-pipeline/src/dbhost/snapshot-store.ts
1212
1238
  var import_crypto2 = require("@dxos/crypto");
1213
1239
  var import_protocols5 = require("@dxos/protocols");
1240
+ var SpaceSnapshot2 = import_protocols5.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
1214
1241
  var SnapshotStore = class {
1215
1242
  // prettier-ignore
1216
1243
  constructor(_directory) {
1217
1244
  this._directory = _directory;
1218
1245
  }
1219
1246
  async saveSnapshot(snapshot) {
1220
- const encoded = import_protocols5.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot);
1247
+ const encoded = SpaceSnapshot2.encode(snapshot);
1221
1248
  const key = await import_crypto2.subtleCrypto.digest("SHA-256", encoded);
1222
1249
  const keyString = Buffer.from(key).toString("hex");
1223
1250
  const file = await this._directory.getOrCreateFile(keyString);
@@ -1236,7 +1263,7 @@ var SnapshotStore = class {
1236
1263
  return void 0;
1237
1264
  }
1238
1265
  const buffer = await file.read(0, size);
1239
- return import_protocols5.schema.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(buffer);
1266
+ return SpaceSnapshot2.decode(buffer);
1240
1267
  } finally {
1241
1268
  await file.close();
1242
1269
  }
@@ -1267,7 +1294,7 @@ var DataServiceSubscriptions = class {
1267
1294
  clear() {
1268
1295
  this._spaces.clear();
1269
1296
  }
1270
- registerSpace(spaceKey, host) {
1297
+ async registerSpace(spaceKey, host) {
1271
1298
  (0, import_log8.log)("Registering space", {
1272
1299
  spaceKey
1273
1300
  }, {
@@ -1276,17 +1303,21 @@ var DataServiceSubscriptions = class {
1276
1303
  S: this,
1277
1304
  C: (f, a) => f(...a)
1278
1305
  });
1306
+ (0, import_tiny_invariant7.default)(!this._spaces.has(spaceKey));
1307
+ await host.open();
1279
1308
  this._spaces.set(spaceKey, host);
1280
1309
  }
1281
- unregisterSpace(spaceKey) {
1310
+ async unregisterSpace(spaceKey) {
1282
1311
  (0, import_log8.log)("Unregistering space", {
1283
1312
  spaceKey
1284
1313
  }, {
1285
1314
  F: __dxlog_file8,
1286
- L: 36,
1315
+ L: 38,
1287
1316
  S: this,
1288
1317
  C: (f, a) => f(...a)
1289
1318
  });
1319
+ const host = this._spaces.get(spaceKey);
1320
+ await (host == null ? void 0 : host.close());
1290
1321
  this._spaces.delete(spaceKey);
1291
1322
  }
1292
1323
  getDataService(spaceKey) {
@@ -1330,11 +1361,15 @@ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1330
1361
  var DataPipeline = class DataPipeline2 {
1331
1362
  constructor(_params) {
1332
1363
  this._params = _params;
1333
- this._ctx = new import_context4.Context();
1364
+ this._ctx = new import_context5.Context();
1365
+ this._pipeline = void 0;
1366
+ this._targetTimeframe = void 0;
1334
1367
  this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
1335
1368
  this._isOpen = false;
1336
1369
  this._lastTimeframeSaveTime = 0;
1337
1370
  this._lastSnapshotSaveTime = 0;
1371
+ this.currentEpoch = void 0;
1372
+ this.appliedEpoch = void 0;
1338
1373
  this._lastProcessedEpoch = -1;
1339
1374
  this.onNewEpoch = new import_async6.Event();
1340
1375
  }
@@ -1353,18 +1388,14 @@ var DataPipeline = class DataPipeline2 {
1353
1388
  this._targetTimeframe = timeframe;
1354
1389
  (_a = this._pipeline) == null ? void 0 : _a.state.setTargetTimeframe(timeframe);
1355
1390
  }
1356
- createCredentialProcessor() {
1357
- return {
1358
- process: async (credential) => {
1359
- if (!(0, import_credentials3.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
1360
- return;
1361
- }
1362
- this.currentEpoch = credential;
1363
- if (this._isOpen) {
1364
- await this._processEpochInSeparateTask(credential);
1365
- }
1366
- }
1367
- };
1391
+ async processCredential(credential) {
1392
+ if (!(0, import_credentials3.checkCredentialType)(credential, "dxos.halo.credentials.Epoch")) {
1393
+ return;
1394
+ }
1395
+ this.currentEpoch = credential;
1396
+ if (this._isOpen) {
1397
+ await this._processEpochInSeparateTask(credential);
1398
+ }
1368
1399
  }
1369
1400
  async open() {
1370
1401
  if (this._isOpen) {
@@ -1401,7 +1432,7 @@ var DataPipeline = class DataPipeline2 {
1401
1432
  }
1402
1433
  (0, import_log9.log)("close", void 0, {
1403
1434
  F: __dxlog_file9,
1404
- L: 174,
1435
+ L: 171,
1405
1436
  S: this,
1406
1437
  C: (f, a) => f(...a)
1407
1438
  });
@@ -1416,13 +1447,21 @@ var DataPipeline = class DataPipeline2 {
1416
1447
  } catch (err) {
1417
1448
  import_log9.log.catch(err, void 0, {
1418
1449
  F: __dxlog_file9,
1419
- L: 187,
1450
+ L: 184,
1420
1451
  S: this,
1421
1452
  C: (f, a) => f(...a)
1422
1453
  });
1423
1454
  }
1424
1455
  await ((_b = this.databaseHost) == null ? void 0 : _b.close());
1425
1456
  await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
1457
+ this._ctx = new import_context5.Context();
1458
+ this._pipeline = void 0;
1459
+ this._targetTimeframe = void 0;
1460
+ this._lastAutomaticSnapshotTimeframe = new import_timeframe4.Timeframe();
1461
+ this.currentEpoch = void 0;
1462
+ this.appliedEpoch = void 0;
1463
+ this._lastProcessedEpoch = -1;
1464
+ this._epochCtx = void 0;
1426
1465
  }
1427
1466
  async _consumePipeline() {
1428
1467
  if (this.currentEpoch) {
@@ -1438,7 +1477,7 @@ var DataPipeline = class DataPipeline2 {
1438
1477
  seq
1439
1478
  }, {
1440
1479
  F: __dxlog_file9,
1441
- L: 204,
1480
+ L: 210,
1442
1481
  S: this,
1443
1482
  C: (f, a) => f(...a)
1444
1483
  });
@@ -1450,7 +1489,7 @@ var DataPipeline = class DataPipeline2 {
1450
1489
  feedKey
1451
1490
  }, {
1452
1491
  F: __dxlog_file9,
1453
- L: 210,
1492
+ L: 216,
1454
1493
  S: this,
1455
1494
  C: (f, a) => f(...a)
1456
1495
  });
@@ -1471,7 +1510,7 @@ var DataPipeline = class DataPipeline2 {
1471
1510
  spaceKey: this._params.spaceKey.toHex()
1472
1511
  }, {
1473
1512
  F: __dxlog_file9,
1474
- L: 224,
1513
+ L: 230,
1475
1514
  S: this,
1476
1515
  C: (f, a) => f(...a)
1477
1516
  });
@@ -1480,7 +1519,7 @@ var DataPipeline = class DataPipeline2 {
1480
1519
  } catch (err) {
1481
1520
  import_log9.log.catch(err, void 0, {
1482
1521
  F: __dxlog_file9,
1483
- L: 234,
1522
+ L: 240,
1484
1523
  S: this,
1485
1524
  C: (f, a) => f(...a)
1486
1525
  });
@@ -1515,7 +1554,7 @@ var DataPipeline = class DataPipeline2 {
1515
1554
  } catch (err) {
1516
1555
  import_log9.log.warn("Failed to cache properties", err, {
1517
1556
  F: __dxlog_file9,
1518
- L: 269,
1557
+ L: 275,
1519
1558
  S: this,
1520
1559
  C: (f, a) => f(...a)
1521
1560
  });
@@ -1537,19 +1576,19 @@ var DataPipeline = class DataPipeline2 {
1537
1576
  return;
1538
1577
  }
1539
1578
  await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
1540
- const ctx = new import_context4.Context({
1579
+ const ctx = new import_context5.Context({
1541
1580
  onError: (err) => {
1542
1581
  if (err instanceof import_errors2.CancelledError) {
1543
1582
  (0, import_log9.log)("Epoch processing cancelled.", void 0, {
1544
1583
  F: __dxlog_file9,
1545
- L: 301,
1584
+ L: 307,
1546
1585
  S: this,
1547
1586
  C: (f, a) => f(...a)
1548
1587
  });
1549
1588
  } else {
1550
1589
  import_log9.log.catch(err, void 0, {
1551
1590
  F: __dxlog_file9,
1552
- L: 303,
1591
+ L: 309,
1553
1592
  S: this,
1554
1593
  C: (f, a) => f(...a)
1555
1594
  });
@@ -1565,7 +1604,7 @@ var DataPipeline = class DataPipeline2 {
1565
1604
  epoch
1566
1605
  }, {
1567
1606
  F: __dxlog_file9,
1568
- L: 313,
1607
+ L: 319,
1569
1608
  S: this,
1570
1609
  C: (f, a) => f(...a)
1571
1610
  });
@@ -1582,7 +1621,7 @@ var DataPipeline = class DataPipeline2 {
1582
1621
  epoch
1583
1622
  }, {
1584
1623
  F: __dxlog_file9,
1585
- L: 327,
1624
+ L: 333,
1586
1625
  S: this,
1587
1626
  C: (f, a) => f(...a)
1588
1627
  });
@@ -1592,7 +1631,7 @@ var DataPipeline = class DataPipeline2 {
1592
1631
  }
1593
1632
  (0, import_log9.log)("restarting pipeline for epoch", void 0, {
1594
1633
  F: __dxlog_file9,
1595
- L: 335,
1634
+ L: 341,
1596
1635
  S: this,
1597
1636
  C: (f, a) => f(...a)
1598
1637
  });
@@ -1656,8 +1695,6 @@ var Space = class Space2 {
1656
1695
  this._addFeedLock = new import_async7.Lock();
1657
1696
  this.onCredentialProcessed = new import_util6.Callback();
1658
1697
  this.stateUpdate = new import_async7.Event();
1659
- // Processes epoch credentials.
1660
- this._dataPipelineCredentialConsumer = void 0;
1661
1698
  this._isOpen = false;
1662
1699
  (0, import_tiny_invariant9.default)(params.spaceKey && params.feedProvider);
1663
1700
  this._key = params.spaceKey;
@@ -1695,7 +1732,7 @@ var Space = class Space2 {
1695
1732
  credential
1696
1733
  }, {
1697
1734
  F: __dxlog_file10,
1698
- L: 110,
1735
+ L: 107,
1699
1736
  S: this,
1700
1737
  C: (f, a) => f(...a)
1701
1738
  });
@@ -1787,7 +1824,7 @@ var Space = class Space2 {
1787
1824
  async open() {
1788
1825
  (0, import_log10.log)("opening...", void 0, {
1789
1826
  F: __dxlog_file10,
1790
- L: 212,
1827
+ L: 209,
1791
1828
  S: this,
1792
1829
  C: (f, a) => f(...a)
1793
1830
  });
@@ -1796,38 +1833,35 @@ var Space = class Space2 {
1796
1833
  }
1797
1834
  await this._controlPipeline.start();
1798
1835
  await this.protocol.start();
1799
- this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1800
- await this._dataPipelineCredentialConsumer.open();
1836
+ await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
1801
1837
  this._isOpen = true;
1802
1838
  (0, import_log10.log)("opened", void 0, {
1803
1839
  F: __dxlog_file10,
1804
- L: 228,
1840
+ L: 220,
1805
1841
  S: this,
1806
1842
  C: (f, a) => f(...a)
1807
1843
  });
1808
1844
  }
1809
1845
  async close() {
1810
- var _a;
1811
1846
  (0, import_log10.log)("closing...", {
1812
1847
  key: this._key
1813
1848
  }, {
1814
1849
  F: __dxlog_file10,
1815
- L: 233,
1850
+ L: 225,
1816
1851
  S: this,
1817
1852
  C: (f, a) => f(...a)
1818
1853
  });
1819
1854
  if (!this._isOpen) {
1820
1855
  return;
1821
1856
  }
1822
- await ((_a = this._dataPipelineCredentialConsumer) == null ? void 0 : _a.close());
1823
- this._dataPipelineCredentialConsumer = void 0;
1857
+ await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
1824
1858
  await this._dataPipeline.close();
1825
1859
  await this.protocol.stop();
1826
1860
  await this._controlPipeline.stop();
1827
1861
  this._isOpen = false;
1828
1862
  (0, import_log10.log)("closed", void 0, {
1829
1863
  F: __dxlog_file10,
1830
- L: 247,
1864
+ L: 238,
1831
1865
  S: this,
1832
1866
  C: (f, a) => f(...a)
1833
1867
  });
@@ -1835,7 +1869,7 @@ var Space = class Space2 {
1835
1869
  async initializeDataPipeline() {
1836
1870
  (0, import_log10.log)("initializeDataPipeline", void 0, {
1837
1871
  F: __dxlog_file10,
1838
- L: 252,
1872
+ L: 243,
1839
1873
  S: this,
1840
1874
  C: (f, a) => f(...a)
1841
1875
  });