@dxos/echo-pipeline 0.1.51-main.e7215ae → 0.1.51-next.5787f10

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 (44) hide show
  1. package/dist/lib/browser/{chunk-CSFWTLPD.mjs → chunk-AXGWKSM3.mjs} +289 -175
  2. package/dist/lib/browser/chunk-AXGWKSM3.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 +12 -4
  6. package/dist/lib/browser/testing/index.mjs.map +3 -3
  7. package/dist/lib/node/index.cjs +288 -174
  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 +350 -228
  11. package/dist/lib/node/testing/index.cjs.map +3 -3
  12. package/dist/types/src/dbhost/snapshot-manager.d.ts +7 -7
  13. package/dist/types/src/dbhost/snapshot-manager.d.ts.map +1 -1
  14. package/dist/types/src/metadata/metadata-store.d.ts +2 -1
  15. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  16. package/dist/types/src/pipeline/pipeline.d.ts +2 -0
  17. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  18. package/dist/types/src/space/control-pipeline.d.ts +9 -1
  19. package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
  20. package/dist/types/src/space/data-pipeline.d.ts +10 -0
  21. package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
  22. package/dist/types/src/space/space-manager.d.ts +7 -1
  23. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  24. package/dist/types/src/space/space-protocol.d.ts +7 -2
  25. package/dist/types/src/space/space-protocol.d.ts.map +1 -1
  26. package/dist/types/src/space/space.d.ts +2 -2
  27. package/dist/types/src/space/space.d.ts.map +1 -1
  28. package/dist/types/src/testing/test-agent-builder.d.ts +3 -0
  29. package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
  30. package/package.json +30 -30
  31. package/src/dbhost/snapshot-manager.ts +29 -43
  32. package/src/metadata/metadata-store.ts +12 -1
  33. package/src/pipeline/pipeline.ts +27 -0
  34. package/src/space/control-pipeline.test.ts +4 -0
  35. package/src/space/control-pipeline.ts +36 -1
  36. package/src/space/data-pipeline.ts +62 -9
  37. package/src/space/space-manager.ts +20 -3
  38. package/src/space/space-protocol.test.ts +4 -0
  39. package/src/space/space-protocol.ts +20 -2
  40. package/src/space/space.test.ts +2 -5
  41. package/src/space/space.ts +11 -7
  42. package/src/testing/test-agent-builder.ts +12 -1
  43. package/src/testing/util.ts +1 -1
  44. package/dist/lib/browser/chunk-CSFWTLPD.mjs.map +0 -7
@@ -121,6 +121,10 @@ var MetadataStore = class {
121
121
  }
122
122
  }
123
123
  _getSpace(spaceKey) {
124
+ var _a;
125
+ if ((_a = this._metadata.identity) == null ? void 0 : _a.haloSpace.key.equals(spaceKey)) {
126
+ return this._metadata.identity.haloSpace;
127
+ }
124
128
  const space = this.spaces.find((space2) => space2.key === spaceKey);
125
129
  assert(space, "Space not found");
126
130
  return space;
@@ -131,7 +135,7 @@ var MetadataStore = class {
131
135
  async clear() {
132
136
  log("clearing all metadata", {}, {
133
137
  file: "metadata-store.ts",
134
- line: 131,
138
+ line: 136,
135
139
  scope: this,
136
140
  callSite: (f, a) => f(...a)
137
141
  });
@@ -152,10 +156,14 @@ var MetadataStore = class {
152
156
  ((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
153
157
  await this._save();
154
158
  }
155
- async setSpaceLatestTimeframe(spaceKey, timeframe) {
159
+ async setSpaceDataLatestTimeframe(spaceKey, timeframe) {
156
160
  this._getSpace(spaceKey).dataTimeframe = timeframe;
157
161
  await this._save();
158
162
  }
163
+ async setSpaceControlLatestTimeframe(spaceKey, timeframe) {
164
+ this._getSpace(spaceKey).controlTimeframe = timeframe;
165
+ await this._save();
166
+ }
159
167
  async setCache(spaceKey, cache) {
160
168
  this._getSpace(spaceKey).cache = cache;
161
169
  await this._save();
@@ -334,6 +342,7 @@ var PipelineState = class {
334
342
  this._timeframeClock = _timeframeClock;
335
343
  this.timeframeUpdate = this._timeframeClock.update;
336
344
  this.stalled = new Event3();
345
+ this._startTimeframe = new Timeframe2();
337
346
  }
338
347
  /**
339
348
  * Latest theoretical timeframe based on the last mutation in each feed.
@@ -346,6 +355,9 @@ var PipelineState = class {
346
355
  index: feed.length - 1
347
356
  })));
348
357
  }
358
+ get startTimeframe() {
359
+ return this._startTimeframe;
360
+ }
349
361
  get timeframe() {
350
362
  return this._timeframeClock.timeframe;
351
363
  }
@@ -379,7 +391,7 @@ var PipelineState = class {
379
391
  target: this.targetTimeframe
380
392
  }, {
381
393
  file: "pipeline.ts",
382
- line: 109,
394
+ line: 118,
383
395
  scope: this,
384
396
  callSite: (f, a) => f(...a)
385
397
  });
@@ -409,7 +421,7 @@ var PipelineState = class {
409
421
  dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
410
422
  }, {
411
423
  file: "pipeline.ts",
412
- line: 135,
424
+ line: 144,
413
425
  scope: this,
414
426
  callSite: (f, a) => f(...a)
415
427
  });
@@ -451,6 +463,7 @@ var Pipeline = class {
451
463
  if (this._feedSetIterator) {
452
464
  await this._feedSetIterator.addFeed(feed);
453
465
  }
466
+ this._setFeedDownloadState(feed);
454
467
  }
455
468
  hasFeed(feedKey) {
456
469
  return this._feeds.has(feedKey);
@@ -466,7 +479,7 @@ var Pipeline = class {
466
479
  async start() {
467
480
  log4("starting...", {}, {
468
481
  file: "pipeline.ts",
469
- line: 254,
482
+ line: 264,
470
483
  scope: this,
471
484
  callSite: (f, a) => f(...a)
472
485
  });
@@ -474,7 +487,7 @@ var Pipeline = class {
474
487
  await this._feedSetIterator.open();
475
488
  log4("started", {}, {
476
489
  file: "pipeline.ts",
477
- line: 257,
490
+ line: 267,
478
491
  scope: this,
479
492
  callSite: (f, a) => f(...a)
480
493
  });
@@ -484,7 +497,7 @@ var Pipeline = class {
484
497
  var _a;
485
498
  log4("stopping...", {}, {
486
499
  file: "pipeline.ts",
487
- line: 263,
500
+ line: 273,
488
501
  scope: this,
489
502
  callSite: (f, a) => f(...a)
490
503
  });
@@ -493,7 +506,7 @@ var Pipeline = class {
493
506
  await this._processingTrigger.wait();
494
507
  log4("stopped", {}, {
495
508
  file: "pipeline.ts",
496
- line: 267,
509
+ line: 277,
497
510
  scope: this,
498
511
  callSite: (f, a) => f(...a)
499
512
  });
@@ -504,7 +517,11 @@ var Pipeline = class {
504
517
  */
505
518
  async setCursor(timeframe) {
506
519
  assert4(!this._isStarted || this._isPaused, "Invalid state.");
520
+ this._state._startTimeframe = timeframe;
507
521
  this._timeframeClock.setTimeframe(timeframe);
522
+ for (const feed of this._feeds.values()) {
523
+ this._setFeedDownloadState(feed);
524
+ }
508
525
  if (this._feedSetIterator) {
509
526
  await this._feedSetIterator.close();
510
527
  await this._initIterator();
@@ -559,6 +576,32 @@ var Pipeline = class {
559
576
  }
560
577
  this._isOpen = false;
561
578
  }
579
+ _setFeedDownloadState(feed) {
580
+ var _a;
581
+ const timeframe = this._state._startTimeframe;
582
+ const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
583
+ feed.undownload({
584
+ callback: () => log4("Undownloaded", {}, {
585
+ file: "pipeline.ts",
586
+ line: 371,
587
+ scope: this,
588
+ callSite: (f, a) => f(...a)
589
+ })
590
+ });
591
+ feed.download({
592
+ start: seq + 1,
593
+ linear: true
594
+ }).catch((err) => {
595
+ log4("failed to download feed", {
596
+ err
597
+ }, {
598
+ file: "pipeline.ts",
599
+ line: 374,
600
+ scope: this,
601
+ callSite: (f, a) => f(...a)
602
+ });
603
+ });
604
+ }
562
605
  async _initIterator() {
563
606
  this._feedSetIterator = new FeedSetIterator(createMessageSelector(this._timeframeClock), {
564
607
  start: startAfter(this._timeframeClock.timeframe),
@@ -567,7 +610,7 @@ var Pipeline = class {
567
610
  this._feedSetIterator.stalled.on((iterator) => {
568
611
  log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, {}, {
569
612
  file: "pipeline.ts",
570
- line: 357,
613
+ line: 384,
571
614
  scope: this,
572
615
  callSite: (f, a) => f(...a)
573
616
  });
@@ -827,10 +870,11 @@ var DatabaseHost = class {
827
870
 
828
871
  // packages/core/echo/echo-pipeline/src/dbhost/snapshot-manager.ts
829
872
  import { trackLeaks } from "@dxos/async";
873
+ import { cancelWithContext } from "@dxos/context";
830
874
  import { timed as timed2 } from "@dxos/debug";
831
- import { log as log7 } from "@dxos/log";
875
+ import { PublicKey as PublicKey2 } from "@dxos/keys";
832
876
  import { schema as schema4 } from "@dxos/protocols";
833
- import { ObjectSync } from "@dxos/teleport-extension-object-sync";
877
+ import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
834
878
  var __decorate4 = function(decorators, target, key, desc) {
835
879
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
836
880
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
@@ -843,62 +887,32 @@ var __decorate4 = function(decorators, target, key, desc) {
843
887
  };
844
888
  var SnapshotManager = class SnapshotManager2 {
845
889
  // prettier-ignore
846
- constructor(_snapshotStore) {
890
+ constructor(_snapshotStore, _blobStore, _blobSync) {
847
891
  this._snapshotStore = _snapshotStore;
848
- this._objectSync = new ObjectSync({
849
- getObject: async (id) => {
850
- const snapshot = await this._snapshotStore.loadSnapshot(id);
851
- log7("getObject", {
852
- id,
853
- snapshot
854
- }, {
855
- file: "snapshot-manager.ts",
856
- line: 30,
857
- scope: this,
858
- callSite: (f, a) => f(...a)
859
- });
860
- if (!snapshot) {
861
- return void 0;
862
- }
863
- return {
864
- id,
865
- payload: schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encodeAsAny(snapshot)
866
- };
867
- },
868
- setObject: async (data) => {
869
- log7("setObject", {
870
- data
871
- }, {
872
- file: "snapshot-manager.ts",
873
- line: 40,
874
- scope: this,
875
- callSite: (f, a) => f(...a)
876
- });
877
- const snapshot = schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(data.payload.value);
878
- await this._snapshotStore.saveSnapshot(snapshot);
879
- }
880
- });
881
- }
882
- get objectSync() {
883
- return this._objectSync;
884
- }
885
- async open() {
886
- await this._objectSync.open();
887
- }
888
- async close() {
889
- await this._objectSync.close();
890
- }
891
- async load(id) {
892
- const local = await this._snapshotStore.loadSnapshot(id);
893
- if (local) {
894
- return local;
892
+ this._blobStore = _blobStore;
893
+ this._blobSync = _blobSync;
894
+ }
895
+ async _getBlob(blobId) {
896
+ const blob = await this._blobStore.get(blobId);
897
+ return schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(blob);
898
+ }
899
+ async load(ctx, id) {
900
+ const blobId = PublicKey2.fromHex(id).asUint8Array();
901
+ const blobMeta = await this._blobStore.getMeta(blobId);
902
+ if (blobMeta && blobMeta.state === BlobMeta.State.FULLY_PRESENT) {
903
+ return this._getBlob(blobId);
895
904
  }
896
- const remote = await this._objectSync.download(id);
897
- return schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(remote.payload.value);
905
+ const fallbackStore = await cancelWithContext(ctx, this._snapshotStore.loadSnapshot(id));
906
+ if (fallbackStore) {
907
+ return fallbackStore;
908
+ }
909
+ await this._blobSync.download(ctx, blobId);
910
+ return this._getBlob(blobId);
898
911
  }
899
912
  async store(snapshot) {
900
- const id = await this._snapshotStore.saveSnapshot(snapshot);
901
- return id;
913
+ const { id } = await this._blobStore.set(schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot));
914
+ await this._blobSync.notifyBlobAdded(id);
915
+ return PublicKey2.from(id).toHex();
902
916
  }
903
917
  };
904
918
  __decorate4([
@@ -956,18 +970,18 @@ var SnapshotStore = class {
956
970
  // packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
957
971
  import assert7 from "@dxos/node-std/assert";
958
972
  import { raise } from "@dxos/debug";
959
- import { PublicKey as PublicKey2 } from "@dxos/keys";
960
- import { log as log8 } from "@dxos/log";
973
+ import { PublicKey as PublicKey3 } from "@dxos/keys";
974
+ import { log as log7 } from "@dxos/log";
961
975
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
962
976
  var DataServiceSubscriptions = class {
963
977
  constructor() {
964
- this._spaces = new ComplexMap3(PublicKey2.hash);
978
+ this._spaces = new ComplexMap3(PublicKey3.hash);
965
979
  }
966
980
  clear() {
967
981
  this._spaces.clear();
968
982
  }
969
983
  registerSpace(spaceKey, host) {
970
- log8("Registering space", {
984
+ log7("Registering space", {
971
985
  spaceKey
972
986
  }, {
973
987
  file: "data-service.ts",
@@ -978,7 +992,7 @@ var DataServiceSubscriptions = class {
978
992
  this._spaces.set(spaceKey, host);
979
993
  }
980
994
  unregisterSpace(spaceKey) {
981
- log8("Unregistering space", {
995
+ log7("Unregistering space", {
982
996
  spaceKey
983
997
  }, {
984
998
  file: "data-service.ts",
@@ -1017,7 +1031,8 @@ import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchro
1017
1031
  import { Context as Context3 } from "@dxos/context";
1018
1032
  import { checkCredentialType } from "@dxos/credentials";
1019
1033
  import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
1020
- import { log as log9 } from "@dxos/log";
1034
+ import { CancelledError } from "@dxos/errors";
1035
+ import { log as log8 } from "@dxos/log";
1021
1036
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
1022
1037
  var __decorate5 = function(decorators, target, key, desc) {
1023
1038
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -1040,6 +1055,7 @@ var DataPipeline = class DataPipeline2 {
1040
1055
  this._isOpen = false;
1041
1056
  this._lastTimeframeSaveTime = 0;
1042
1057
  this._lastSnapshotSaveTime = 0;
1058
+ this._lastProcessedEpoch = -1;
1043
1059
  this.onNewEpoch = new Event4();
1044
1060
  }
1045
1061
  get isOpen() {
@@ -1063,17 +1079,10 @@ var DataPipeline = class DataPipeline2 {
1063
1079
  if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1064
1080
  return;
1065
1081
  }
1066
- log9("new epoch", {
1067
- credential
1068
- }, {
1069
- file: "data-pipeline.ts",
1070
- line: 109,
1071
- scope: this,
1072
- callSite: (f, a) => f(...a)
1073
- });
1074
- await this._processEpoch(credential.subject.assertion);
1075
1082
  this.currentEpoch = credential;
1076
- this.onNewEpoch.emit(credential);
1083
+ if (this._isOpen) {
1084
+ await this._processEpochInSeparateTask(credential);
1085
+ }
1077
1086
  }
1078
1087
  };
1079
1088
  }
@@ -1110,9 +1119,9 @@ var DataPipeline = class DataPipeline2 {
1110
1119
  if (!this._isOpen) {
1111
1120
  return;
1112
1121
  }
1113
- log9("close", {}, {
1122
+ log8("close", {}, {
1114
1123
  file: "data-pipeline.ts",
1115
- line: 161,
1124
+ line: 174,
1116
1125
  scope: this,
1117
1126
  callSite: (f, a) => f(...a)
1118
1127
  });
@@ -1125,27 +1134,31 @@ var DataPipeline = class DataPipeline2 {
1125
1134
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1126
1135
  }
1127
1136
  } catch (err) {
1128
- log9.catch(err, {}, {
1137
+ log8.catch(err, {}, {
1129
1138
  file: "data-pipeline.ts",
1130
- line: 174,
1139
+ line: 187,
1131
1140
  scope: this,
1132
1141
  callSite: (f, a) => f(...a)
1133
1142
  });
1134
1143
  }
1135
1144
  await ((_b = this.databaseHost) == null ? void 0 : _b.close());
1136
1145
  await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
1137
- await this._params.snapshotManager.close();
1138
1146
  }
1139
1147
  async _consumePipeline() {
1148
+ if (this.currentEpoch) {
1149
+ const waitForOneEpoch = this.onNewEpoch.waitForCount(1);
1150
+ await this._processEpochInSeparateTask(this.currentEpoch);
1151
+ await waitForOneEpoch;
1152
+ }
1140
1153
  assert8(this._pipeline, "Pipeline is not initialized.");
1141
1154
  for await (const msg of this._pipeline.consume()) {
1142
1155
  const { feedKey, seq, data } = msg;
1143
- log9("processing message", {
1156
+ log8("processing message", {
1144
1157
  feedKey,
1145
1158
  seq
1146
1159
  }, {
1147
1160
  file: "data-pipeline.ts",
1148
- line: 186,
1161
+ line: 204,
1149
1162
  scope: this,
1150
1163
  callSite: (f, a) => f(...a)
1151
1164
  });
@@ -1153,11 +1166,11 @@ var DataPipeline = class DataPipeline2 {
1153
1166
  if (data.payload.data) {
1154
1167
  const feedInfo = this._params.feedInfoProvider(feedKey);
1155
1168
  if (!feedInfo) {
1156
- log9.error("Could not find feed.", {
1169
+ log8.error("Could not find feed.", {
1157
1170
  feedKey
1158
1171
  }, {
1159
1172
  file: "data-pipeline.ts",
1160
- line: 192,
1173
+ line: 210,
1161
1174
  scope: this,
1162
1175
  callSite: (f, a) => f(...a)
1163
1176
  });
@@ -1172,12 +1185,22 @@ var DataPipeline = class DataPipeline2 {
1172
1185
  memberKey: feedInfo.assertion.identityKey
1173
1186
  }
1174
1187
  });
1188
+ log8.trace("dxos.echo.data-pipeline.processed", {
1189
+ feedKey: feedKey.toHex(),
1190
+ seq,
1191
+ spaceKey: this._params.spaceKey.toHex()
1192
+ }, {
1193
+ file: "data-pipeline.ts",
1194
+ line: 224,
1195
+ scope: this,
1196
+ callSite: (f, a) => f(...a)
1197
+ });
1175
1198
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1176
1199
  }
1177
1200
  } catch (err) {
1178
- log9.catch(err, {}, {
1201
+ log8.catch(err, {}, {
1179
1202
  file: "data-pipeline.ts",
1180
- line: 210,
1203
+ line: 234,
1181
1204
  scope: this,
1182
1205
  callSite: (f, a) => f(...a)
1183
1206
  });
@@ -1195,7 +1218,7 @@ var DataPipeline = class DataPipeline2 {
1195
1218
  async _saveTargetTimeframe(timeframe) {
1196
1219
  var _a;
1197
1220
  const newTimeframe = Timeframe3.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe3(), timeframe);
1198
- await this._params.metadataStore.setSpaceLatestTimeframe(this._params.spaceKey, newTimeframe);
1221
+ await this._params.metadataStore.setSpaceDataLatestTimeframe(this._params.spaceKey, newTimeframe);
1199
1222
  this._targetTimeframe = newTimeframe;
1200
1223
  }
1201
1224
  async _saveCache() {
@@ -1210,9 +1233,9 @@ var DataPipeline = class DataPipeline2 {
1210
1233
  cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
1211
1234
  }
1212
1235
  } catch (err) {
1213
- log9.warn("Failed to cache properties", err, {
1236
+ log8.warn("Failed to cache properties", err, {
1214
1237
  file: "data-pipeline.ts",
1215
- line: 244,
1238
+ line: 268,
1216
1239
  scope: this,
1217
1240
  callSite: (f, a) => f(...a)
1218
1241
  });
@@ -1228,24 +1251,68 @@ var DataPipeline = class DataPipeline2 {
1228
1251
  await this._saveCache();
1229
1252
  }
1230
1253
  }
1231
- async _processEpoch(epoch) {
1232
- assert8(this._isOpen);
1254
+ async _processEpochInSeparateTask(epoch) {
1255
+ var _a;
1256
+ if (epoch.subject.assertion.number <= this._lastProcessedEpoch) {
1257
+ return;
1258
+ }
1259
+ await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
1260
+ const ctx = new Context3({
1261
+ onError: (err) => {
1262
+ if (err instanceof CancelledError) {
1263
+ log8("Epoch processing cancelled.", {}, {
1264
+ file: "data-pipeline.ts",
1265
+ line: 300,
1266
+ scope: this,
1267
+ callSite: (f, a) => f(...a)
1268
+ });
1269
+ } else {
1270
+ log8.catch(err, {}, {
1271
+ file: "data-pipeline.ts",
1272
+ line: 302,
1273
+ scope: this,
1274
+ callSite: (f, a) => f(...a)
1275
+ });
1276
+ }
1277
+ }
1278
+ });
1279
+ this._epochCtx = ctx;
1280
+ scheduleTask2(ctx, async () => {
1281
+ if (!this._isOpen) {
1282
+ return;
1283
+ }
1284
+ log8("process epoch", {
1285
+ epoch
1286
+ }, {
1287
+ file: "data-pipeline.ts",
1288
+ line: 312,
1289
+ scope: this,
1290
+ callSite: (f, a) => f(...a)
1291
+ });
1292
+ await this._processEpoch(ctx, epoch.subject.assertion);
1293
+ this.appliedEpoch = epoch;
1294
+ this.onNewEpoch.emit(epoch);
1295
+ });
1296
+ }
1297
+ async _processEpoch(ctx, epoch) {
1298
+ assert8(this._isOpen, "Space is closed.");
1233
1299
  assert8(this._pipeline);
1234
- log9("Processing epoch", {
1300
+ this._lastProcessedEpoch = epoch.number;
1301
+ log8("Processing epoch", {
1235
1302
  epoch
1236
1303
  }, {
1237
1304
  file: "data-pipeline.ts",
1238
- line: 273,
1305
+ line: 326,
1239
1306
  scope: this,
1240
1307
  callSite: (f, a) => f(...a)
1241
1308
  });
1242
1309
  if (epoch.snapshotCid) {
1243
- const snapshot = await this._params.snapshotManager.load(epoch.snapshotCid);
1310
+ const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1244
1311
  this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1245
1312
  }
1246
- log9("restarting pipeline for epoch", {}, {
1313
+ log8("restarting pipeline for epoch", {}, {
1247
1314
  file: "data-pipeline.ts",
1248
- line: 281,
1315
+ line: 334,
1249
1316
  scope: this,
1250
1317
  callSite: (f, a) => f(...a)
1251
1318
  });
@@ -1295,28 +1362,33 @@ DataPipeline = __decorate5([
1295
1362
  // packages/core/echo/echo-pipeline/src/space/space.ts
1296
1363
  import assert9 from "@dxos/node-std/assert";
1297
1364
  import { Event as Event5, synchronized as synchronized4, trackLeaks as trackLeaks3, Lock } from "@dxos/async";
1298
- import { log as log11, logInfo } from "@dxos/log";
1365
+ import { log as log10, logInfo } from "@dxos/log";
1299
1366
  import { AdmittedFeed as AdmittedFeed2 } from "@dxos/protocols/proto/dxos/halo/credentials";
1300
1367
  import { Callback as Callback2 } from "@dxos/util";
1301
1368
 
1302
1369
  // packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
1303
1370
  import { SpaceStateMachine } from "@dxos/credentials";
1304
- import { PublicKey as PublicKey3 } from "@dxos/keys";
1305
- import { log as log10 } from "@dxos/log";
1371
+ import { PublicKey as PublicKey4 } from "@dxos/keys";
1372
+ import { log as log9 } from "@dxos/log";
1306
1373
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
1374
+ import { Timeframe as Timeframe4 } from "@dxos/timeframe";
1307
1375
  import { Callback } from "@dxos/util";
1376
+ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1308
1377
  var ControlPipeline = class {
1309
- constructor({ spaceKey, genesisFeed, feedProvider }) {
1378
+ constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
1379
+ this._lastTimeframeSaveTime = Date.now();
1310
1380
  this.onFeedAdmitted = new Callback();
1381
+ this._spaceKey = spaceKey;
1382
+ this._metadata = metadataStore;
1311
1383
  this._pipeline = new Pipeline();
1312
1384
  void this._pipeline.addFeed(genesisFeed);
1313
1385
  this._spaceStateMachine = new SpaceStateMachine(spaceKey);
1314
1386
  this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
1315
- log10("feed admitted", {
1387
+ log9("feed admitted", {
1316
1388
  key: info.key
1317
1389
  }, {
1318
1390
  file: "control-pipeline.ts",
1319
- line: 39,
1391
+ line: 51,
1320
1392
  scope: this,
1321
1393
  callSite: (f, a) => f(...a)
1322
1394
  });
@@ -1325,9 +1397,9 @@ var ControlPipeline = class {
1325
1397
  const feed = await feedProvider(info.key);
1326
1398
  await this._pipeline.addFeed(feed);
1327
1399
  } catch (err) {
1328
- log10.catch(err, {}, {
1400
+ log9.catch(err, {}, {
1329
1401
  file: "control-pipeline.ts",
1330
- line: 47,
1402
+ line: 59,
1331
1403
  scope: this,
1332
1404
  callSite: (f, a) => f(...a)
1333
1405
  });
@@ -1348,41 +1420,43 @@ var ControlPipeline = class {
1348
1420
  this._pipeline.setWriteFeed(feed);
1349
1421
  }
1350
1422
  async start() {
1351
- log10("starting...", {}, {
1423
+ log9("starting...", {}, {
1352
1424
  file: "control-pipeline.ts",
1353
- line: 71,
1425
+ line: 83,
1354
1426
  scope: this,
1355
1427
  callSite: (f, a) => f(...a)
1356
1428
  });
1357
1429
  setTimeout(async () => {
1358
1430
  for await (const msg of this._pipeline.consume()) {
1359
1431
  try {
1360
- log10("processing", {
1432
+ log9("processing", {
1361
1433
  key: msg.feedKey,
1362
1434
  seq: msg.seq
1363
1435
  }, {
1364
1436
  file: "control-pipeline.ts",
1365
- line: 76,
1437
+ line: 88,
1366
1438
  scope: this,
1367
1439
  callSite: (f, a) => f(...a)
1368
1440
  });
1369
1441
  if (msg.data.payload.credential) {
1370
- const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey3.from(msg.feedKey));
1442
+ const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
1371
1443
  if (!result) {
1372
- log10.warn("processing failed", {
1444
+ log9.warn("processing failed", {
1373
1445
  msg
1374
1446
  }, {
1375
1447
  file: "control-pipeline.ts",
1376
- line: 83,
1448
+ line: 95,
1377
1449
  scope: this,
1378
1450
  callSite: (f, a) => f(...a)
1379
1451
  });
1452
+ } else {
1453
+ await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1380
1454
  }
1381
1455
  }
1382
1456
  } catch (err) {
1383
- log10.catch(err, {}, {
1457
+ log9.catch(err, {}, {
1384
1458
  file: "control-pipeline.ts",
1385
- line: 87,
1459
+ line: 101,
1386
1460
  scope: this,
1387
1461
  callSite: (f, a) => f(...a)
1388
1462
  });
@@ -1390,28 +1464,50 @@ var ControlPipeline = class {
1390
1464
  }
1391
1465
  });
1392
1466
  await this._pipeline.start();
1393
- log10("started", {}, {
1467
+ log9("started", {}, {
1394
1468
  file: "control-pipeline.ts",
1395
- line: 93,
1469
+ line: 107,
1396
1470
  scope: this,
1397
1471
  callSite: (f, a) => f(...a)
1398
1472
  });
1399
1473
  }
1474
+ async _noteTargetStateIfNeeded(timeframe) {
1475
+ if (Date.now() - this._lastTimeframeSaveTime > TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2) {
1476
+ this._lastTimeframeSaveTime = Date.now();
1477
+ await this._saveTargetTimeframe(timeframe);
1478
+ }
1479
+ }
1400
1480
  async stop() {
1401
- log10("stopping...", {}, {
1481
+ log9("stopping...", {}, {
1402
1482
  file: "control-pipeline.ts",
1403
- line: 97,
1483
+ line: 121,
1404
1484
  scope: this,
1405
1485
  callSite: (f, a) => f(...a)
1406
1486
  });
1407
1487
  await this._pipeline.stop();
1408
- log10("stopped", {}, {
1488
+ await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1489
+ log9("stopped", {}, {
1409
1490
  file: "control-pipeline.ts",
1410
- line: 99,
1491
+ line: 124,
1411
1492
  scope: this,
1412
1493
  callSite: (f, a) => f(...a)
1413
1494
  });
1414
1495
  }
1496
+ async _saveTargetTimeframe(timeframe) {
1497
+ var _a;
1498
+ try {
1499
+ const newTimeframe = Timeframe4.merge((_a = this._targetTimeframe) != null ? _a : new Timeframe4(), timeframe);
1500
+ await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1501
+ this._targetTimeframe = newTimeframe;
1502
+ } catch (err) {
1503
+ log9(err, {}, {
1504
+ file: "control-pipeline.ts",
1505
+ line: 133,
1506
+ scope: this,
1507
+ callSite: (f, a) => f(...a)
1508
+ });
1509
+ }
1510
+ }
1415
1511
  };
1416
1512
 
1417
1513
  // packages/core/echo/echo-pipeline/src/space/space.ts
@@ -1441,29 +1537,35 @@ var Space = class Space2 {
1441
1537
  this._controlPipeline = new ControlPipeline({
1442
1538
  spaceKey: params.spaceKey,
1443
1539
  genesisFeed: params.genesisFeed,
1444
- feedProvider: params.feedProvider
1540
+ feedProvider: params.feedProvider,
1541
+ metadataStore: params.metadataStore
1445
1542
  });
1446
1543
  this._controlPipeline.onFeedAdmitted.set(async (info) => {
1544
+ const sparse = info.assertion.designation === AdmittedFeed2.Designation.DATA;
1447
1545
  if (info.assertion.designation === AdmittedFeed2.Designation.DATA) {
1448
1546
  await this._addFeedLock.executeSynchronized(async () => {
1449
1547
  if (this._dataPipeline.pipeline) {
1450
1548
  if (!this._dataPipeline.pipeline.hasFeed(info.key)) {
1451
- return this._dataPipeline.pipeline.addFeed(await this._feedProvider(info.key));
1549
+ return this._dataPipeline.pipeline.addFeed(await this._feedProvider(info.key, {
1550
+ sparse
1551
+ }));
1452
1552
  }
1453
1553
  }
1454
1554
  });
1455
1555
  }
1456
1556
  if (!info.key.equals(params.genesisFeed.key)) {
1457
- this.protocol.addFeed(await params.feedProvider(info.key));
1557
+ this.protocol.addFeed(await params.feedProvider(info.key, {
1558
+ sparse
1559
+ }));
1458
1560
  }
1459
1561
  });
1460
1562
  this._controlPipeline.onCredentialProcessed.set(async (credential) => {
1461
1563
  await this.onCredentialProcessed.callIfSet(credential);
1462
- log11("onCredentialProcessed", {
1564
+ log10("onCredentialProcessed", {
1463
1565
  credential
1464
1566
  }, {
1465
1567
  file: "space.ts",
1466
- line: 106,
1568
+ line: 110,
1467
1569
  scope: this,
1468
1570
  callSite: (f, a) => f(...a)
1469
1571
  });
@@ -1486,7 +1588,9 @@ var Space = class Space2 {
1486
1588
  await this._addFeedLock.executeSynchronized(async () => {
1487
1589
  for (const feed of this._controlPipeline.spaceState.feeds.values()) {
1488
1590
  if (feed.assertion.designation === AdmittedFeed2.Designation.DATA && !pipeline.hasFeed(feed.key)) {
1489
- await pipeline.addFeed(await this._feedProvider(feed.key));
1591
+ await pipeline.addFeed(await this._feedProvider(feed.key, {
1592
+ sparse: true
1593
+ }));
1490
1594
  }
1491
1595
  }
1492
1596
  });
@@ -1551,9 +1655,9 @@ var Space = class Space2 {
1551
1655
  // return this._dataPipeline?.getFeeds();
1552
1656
  // }
1553
1657
  async open() {
1554
- log11("opening...", {}, {
1658
+ log10("opening...", {}, {
1555
1659
  file: "space.ts",
1556
- line: 208,
1660
+ line: 212,
1557
1661
  scope: this,
1558
1662
  callSite: (f, a) => f(...a)
1559
1663
  });
@@ -1563,21 +1667,22 @@ var Space = class Space2 {
1563
1667
  await this._controlPipeline.start();
1564
1668
  await this.protocol.start();
1565
1669
  this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1670
+ await this._dataPipelineCredentialConsumer.open();
1566
1671
  this._isOpen = true;
1567
- log11("opened", {}, {
1672
+ log10("opened", {}, {
1568
1673
  file: "space.ts",
1569
- line: 222,
1674
+ line: 228,
1570
1675
  scope: this,
1571
1676
  callSite: (f, a) => f(...a)
1572
1677
  });
1573
1678
  }
1574
1679
  async close() {
1575
1680
  var _a;
1576
- log11("closing...", {
1681
+ log10("closing...", {
1577
1682
  key: this._key
1578
1683
  }, {
1579
1684
  file: "space.ts",
1580
- line: 227,
1685
+ line: 233,
1581
1686
  scope: this,
1582
1687
  callSite: (f, a) => f(...a)
1583
1688
  });
@@ -1590,24 +1695,22 @@ var Space = class Space2 {
1590
1695
  await this.protocol.stop();
1591
1696
  await this._controlPipeline.stop();
1592
1697
  this._isOpen = false;
1593
- log11("closed", {}, {
1698
+ log10("closed", {}, {
1594
1699
  file: "space.ts",
1595
- line: 241,
1700
+ line: 247,
1596
1701
  scope: this,
1597
1702
  callSite: (f, a) => f(...a)
1598
1703
  });
1599
1704
  }
1600
1705
  async initializeDataPipeline() {
1601
- log11("initializeDataPipeline", {}, {
1706
+ log10("initializeDataPipeline", {}, {
1602
1707
  file: "space.ts",
1603
- line: 246,
1708
+ line: 252,
1604
1709
  scope: this,
1605
1710
  callSite: (f, a) => f(...a)
1606
1711
  });
1607
1712
  assert9(this._isOpen, "Space must be open to initialize data pipeline.");
1608
1713
  await this._dataPipeline.open();
1609
- assert9(this._dataPipelineCredentialConsumer);
1610
- await this._dataPipelineCredentialConsumer.open();
1611
1714
  }
1612
1715
  };
1613
1716
  __decorate6([
@@ -1628,10 +1731,11 @@ Space = __decorate6([
1628
1731
 
1629
1732
  // packages/core/echo/echo-pipeline/src/space/space-protocol.ts
1630
1733
  import { discoveryKey, sha256 } from "@dxos/crypto";
1631
- import { PublicKey as PublicKey4 } from "@dxos/keys";
1632
- import { log as log12, logInfo as logInfo2 } from "@dxos/log";
1734
+ import { PublicKey as PublicKey5 } from "@dxos/keys";
1735
+ import { log as log11, logInfo as logInfo2 } from "@dxos/log";
1633
1736
  import { MMSTTopology } from "@dxos/network-manager";
1634
1737
  import { Teleport } from "@dxos/teleport";
1738
+ import { BlobSync } from "@dxos/teleport-extension-object-sync";
1635
1739
  import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
1636
1740
  import { ComplexMap as ComplexMap4 } from "@dxos/util";
1637
1741
  var __decorate7 = function(decorators, target, key, desc) {
@@ -1647,14 +1751,17 @@ var __decorate7 = function(decorators, target, key, desc) {
1647
1751
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1648
1752
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1649
1753
  var SpaceProtocol = class {
1650
- constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure }) {
1754
+ constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }) {
1651
1755
  this._feeds = /* @__PURE__ */ new Set();
1652
- this._sessions = new ComplexMap4(PublicKey4.hash);
1756
+ this._sessions = new ComplexMap4(PublicKey5.hash);
1653
1757
  this._networkManager = networkManager;
1654
1758
  this._swarmIdentity = swarmIdentity;
1655
1759
  this._onSessionAuth = onSessionAuth;
1656
1760
  this._onAuthFailure = onAuthFailure;
1657
- this._topic = PublicKey4.from(discoveryKey(sha256(topic.toHex())));
1761
+ this.blobSync = new BlobSync({
1762
+ blobStore
1763
+ });
1764
+ this._topic = PublicKey5.from(discoveryKey(sha256(topic.toHex())));
1658
1765
  }
1659
1766
  get sessions() {
1660
1767
  return this._sessions;
@@ -1667,11 +1774,11 @@ var SpaceProtocol = class {
1667
1774
  }
1668
1775
  // TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
1669
1776
  addFeed(feed) {
1670
- log12("addFeed", {
1777
+ log11("addFeed", {
1671
1778
  key: feed.key
1672
1779
  }, {
1673
1780
  file: "space-protocol.ts",
1674
- line: 87,
1781
+ line: 94,
1675
1782
  scope: this,
1676
1783
  callSite: (f, a) => f(...a)
1677
1784
  });
@@ -1690,9 +1797,10 @@ var SpaceProtocol = class {
1690
1797
  maxPeers: 10,
1691
1798
  sampleSize: 20
1692
1799
  };
1693
- log12("starting...", {}, {
1800
+ await this.blobSync.open();
1801
+ log11("starting...", {}, {
1694
1802
  file: "space-protocol.ts",
1695
- line: 110,
1803
+ line: 119,
1696
1804
  scope: this,
1697
1805
  callSite: (f, a) => f(...a)
1698
1806
  });
@@ -1703,25 +1811,26 @@ var SpaceProtocol = class {
1703
1811
  topology: new MMSTTopology(topologyConfig),
1704
1812
  label: `Protocol swarm: ${this._topic}`
1705
1813
  });
1706
- log12("started", {}, {
1814
+ log11("started", {}, {
1707
1815
  file: "space-protocol.ts",
1708
- line: 119,
1816
+ line: 128,
1709
1817
  scope: this,
1710
1818
  callSite: (f, a) => f(...a)
1711
1819
  });
1712
1820
  }
1713
1821
  async stop() {
1822
+ await this.blobSync.close();
1714
1823
  if (this._connection) {
1715
- log12("stopping...", {}, {
1824
+ log11("stopping...", {}, {
1716
1825
  file: "space-protocol.ts",
1717
- line: 124,
1826
+ line: 135,
1718
1827
  scope: this,
1719
1828
  callSite: (f, a) => f(...a)
1720
1829
  });
1721
1830
  await this._connection.close();
1722
- log12("stopped", {}, {
1831
+ log11("stopped", {}, {
1723
1832
  file: "space-protocol.ts",
1724
- line: 126,
1833
+ line: 137,
1725
1834
  scope: this,
1726
1835
  callSite: (f, a) => f(...a)
1727
1836
  });
@@ -1733,7 +1842,8 @@ var SpaceProtocol = class {
1733
1842
  wireParams,
1734
1843
  swarmIdentity: this._swarmIdentity,
1735
1844
  onSessionAuth: this._onSessionAuth,
1736
- onAuthFailure: this._onAuthFailure
1845
+ onAuthFailure: this._onAuthFailure,
1846
+ blobSync: this.blobSync
1737
1847
  });
1738
1848
  this._sessions.set(wireParams.remotePeerId, session);
1739
1849
  for (const feed of this._feeds) {
@@ -1757,7 +1867,7 @@ var AuthStatus;
1757
1867
  })(AuthStatus || (AuthStatus = {}));
1758
1868
  var SpaceProtocolSession = class {
1759
1869
  // TODO(dmaretskyi): Allow to pass in extra extensions.
1760
- constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure }) {
1870
+ constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync }) {
1761
1871
  // TODO(dmaretskyi): Start with upload=false when switching it on the fly works.
1762
1872
  this.replicator = new ReplicatorExtension().setOptions({
1763
1873
  upload: true
@@ -1767,6 +1877,7 @@ var SpaceProtocolSession = class {
1767
1877
  this._swarmIdentity = swarmIdentity;
1768
1878
  this._onSessionAuth = onSessionAuth;
1769
1879
  this._onAuthFailure = onAuthFailure;
1880
+ this._blobSync = blobSync;
1770
1881
  this._teleport = new Teleport(wireParams);
1771
1882
  }
1772
1883
  get authStatus() {
@@ -1782,9 +1893,9 @@ var SpaceProtocolSession = class {
1782
1893
  verifier: this._swarmIdentity.credentialAuthenticator,
1783
1894
  onAuthSuccess: () => {
1784
1895
  var _a;
1785
- log12("Peer authenticated", {}, {
1896
+ log11("Peer authenticated", {}, {
1786
1897
  file: "space-protocol.ts",
1787
- line: 213,
1898
+ line: 230,
1788
1899
  scope: this,
1789
1900
  callSite: (f, a) => f(...a)
1790
1901
  });
@@ -1798,6 +1909,7 @@ var SpaceProtocolSession = class {
1798
1909
  }
1799
1910
  }));
1800
1911
  this._teleport.addExtension("dxos.mesh.teleport.replicator", this.replicator);
1912
+ this._teleport.addExtension("dxos.mesh.teleport.blobsync", this._blobSync.createExtension());
1801
1913
  }
1802
1914
  async destroy() {
1803
1915
  await this._teleport.close();
@@ -1813,8 +1925,8 @@ __decorate7([
1813
1925
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
1814
1926
  import { synchronized as synchronized5, trackLeaks as trackLeaks4 } from "@dxos/async";
1815
1927
  import { failUndefined as failUndefined2 } from "@dxos/debug";
1816
- import { PublicKey as PublicKey5 } from "@dxos/keys";
1817
- import { log as log13 } from "@dxos/log";
1928
+ import { PublicKey as PublicKey6 } from "@dxos/keys";
1929
+ import { log as log12 } from "@dxos/log";
1818
1930
  import { trace } from "@dxos/protocols";
1819
1931
  import { ComplexMap as ComplexMap5 } from "@dxos/util";
1820
1932
  var __decorate8 = function(decorators, target, key, desc) {
@@ -1828,14 +1940,15 @@ var __decorate8 = function(decorators, target, key, desc) {
1828
1940
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1829
1941
  };
1830
1942
  var SpaceManager = class SpaceManager2 {
1831
- constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore }) {
1832
- this._spaces = new ComplexMap5(PublicKey5.hash);
1833
- this._instanceId = PublicKey5.random().toHex();
1943
+ constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
1944
+ this._spaces = new ComplexMap5(PublicKey6.hash);
1945
+ this._instanceId = PublicKey6.random().toHex();
1834
1946
  this._feedStore = feedStore;
1835
1947
  this._networkManager = networkManager;
1836
1948
  this._modelFactory = modelFactory;
1837
1949
  this._metadataStore = metadataStore;
1838
1950
  this._snapshotStore = snapshotStore;
1951
+ this._blobStore = blobStore;
1839
1952
  }
1840
1953
  // TODO(burdon): Remove.
1841
1954
  get spaces() {
@@ -1850,19 +1963,19 @@ var SpaceManager = class SpaceManager2 {
1850
1963
  }
1851
1964
  async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
1852
1965
  var _a;
1853
- log13.trace("dxos.echo.space-manager.construct-space", trace.begin({
1966
+ log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
1854
1967
  id: this._instanceId
1855
1968
  }), {
1856
1969
  file: "space-manager.ts",
1857
- line: 81,
1970
+ line: 97,
1858
1971
  scope: this,
1859
1972
  callSite: (f, a) => f(...a)
1860
1973
  });
1861
- log13("constructing space...", {
1974
+ log12("constructing space...", {
1862
1975
  spaceKey: metadata.genesisFeedKey
1863
1976
  }, {
1864
1977
  file: "space-manager.ts",
1865
- line: 82,
1978
+ line: 98,
1866
1979
  scope: this,
1867
1980
  callSite: (f, a) => f(...a)
1868
1981
  });
@@ -1873,25 +1986,26 @@ var SpaceManager = class SpaceManager2 {
1873
1986
  swarmIdentity,
1874
1987
  networkManager: this._networkManager,
1875
1988
  onSessionAuth: onNetworkConnection,
1876
- onAuthFailure
1989
+ onAuthFailure,
1990
+ blobStore: this._blobStore
1877
1991
  });
1878
- const snapshotManager = new SnapshotManager(this._snapshotStore);
1992
+ const snapshotManager = new SnapshotManager(this._snapshotStore, this._blobStore, protocol.blobSync);
1879
1993
  const space = new Space({
1880
1994
  spaceKey,
1881
1995
  protocol,
1882
1996
  genesisFeed,
1883
- feedProvider: (feedKey) => this._feedStore.openFeed(feedKey),
1997
+ feedProvider: (feedKey, opts) => this._feedStore.openFeed(feedKey, opts),
1884
1998
  modelFactory: this._modelFactory,
1885
1999
  metadataStore: this._metadataStore,
1886
2000
  snapshotManager,
1887
2001
  memberKey
1888
2002
  });
1889
2003
  this._spaces.set(space.key, space);
1890
- log13.trace("dxos.echo.space-manager.construct-space", trace.end({
2004
+ log12.trace("dxos.echo.space-manager.construct-space", trace.end({
1891
2005
  id: this._instanceId
1892
2006
  }), {
1893
2007
  file: "space-manager.ts",
1894
- line: 108,
2008
+ line: 125,
1895
2009
  scope: this,
1896
2010
  callSite: (f, a) => f(...a)
1897
2011
  });
@@ -1934,4 +2048,4 @@ export {
1934
2048
  SpaceProtocolSession,
1935
2049
  SpaceManager
1936
2050
  };
1937
- //# sourceMappingURL=chunk-CSFWTLPD.mjs.map
2051
+ //# sourceMappingURL=chunk-AXGWKSM3.mjs.map