@dxos/echo-pipeline 0.1.53-main.55faa2f → 0.1.53-main.5bcfb84

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 (35) hide show
  1. package/dist/lib/browser/{chunk-ZYDZBSIT.mjs → chunk-RFRZMQ5T.mjs} +389 -346
  2. package/dist/lib/browser/chunk-RFRZMQ5T.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/index.mjs.map +1 -1
  5. package/dist/lib/browser/meta.json +1 -1
  6. package/dist/lib/browser/testing/index.mjs +2 -2
  7. package/dist/lib/browser/testing/index.mjs.map +2 -2
  8. package/dist/lib/node/index.cjs +390 -347
  9. package/dist/lib/node/index.cjs.map +3 -3
  10. package/dist/lib/node/meta.json +1 -1
  11. package/dist/lib/node/testing/index.cjs +396 -353
  12. package/dist/lib/node/testing/index.cjs.map +3 -3
  13. package/dist/types/src/dbhost/data-service-host.d.ts +3 -0
  14. package/dist/types/src/dbhost/data-service-host.d.ts.map +1 -1
  15. package/dist/types/src/dbhost/data-service.d.ts +2 -2
  16. package/dist/types/src/dbhost/data-service.d.ts.map +1 -1
  17. package/dist/types/src/metadata/metadata-store.d.ts +4 -0
  18. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  19. package/dist/types/src/pipeline/pipeline.d.ts +0 -1
  20. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  21. package/dist/types/src/space/data-pipeline.d.ts +3 -3
  22. package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
  23. package/dist/types/src/space/space.d.ts +0 -1
  24. package/dist/types/src/space/space.d.ts.map +1 -1
  25. package/package.json +30 -30
  26. package/src/dbhost/data-service-host.ts +14 -1
  27. package/src/dbhost/data-service.ts +6 -2
  28. package/src/metadata/metadata-store.ts +15 -2
  29. package/src/pipeline/pipeline.ts +13 -1
  30. package/src/space/data-pipeline.ts +25 -19
  31. package/src/space/space.test.ts +46 -5
  32. package/src/space/space.ts +3 -12
  33. package/src/testing/util.ts +1 -1
  34. package/src/tests/database.test.ts +1 -1
  35. package/dist/lib/browser/chunk-ZYDZBSIT.mjs.map +0 -7
@@ -7,8 +7,9 @@ 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
- var __decorate = function(decorators, target, key, desc) {
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;
13
14
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
14
15
  r = Reflect.decorate(decorators, target, key, desc);
@@ -17,13 +18,15 @@ var __decorate = function(decorators, target, key, desc) {
17
18
  if (d = decorators[i])
18
19
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
19
20
  return c > 3 && r && Object.defineProperty(target, key, r), r;
20
- };
21
+ }
22
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
21
23
  var emptyEchoMetadata = () => ({
22
24
  version: STORAGE_VERSION,
23
25
  spaces: [],
24
26
  created: new Date(),
25
27
  updated: new Date()
26
28
  });
29
+ var EchoMetadata = schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
27
30
  var MetadataStore = class {
28
31
  // prettier-ignore
29
32
  constructor(_directory) {
@@ -50,6 +53,7 @@ var MetadataStore = class {
50
53
  * Loads metadata from persistent storage.
51
54
  */
52
55
  async load() {
56
+ var _a;
53
57
  const file = this._directory.getOrCreateFile("EchoMetadata");
54
58
  try {
55
59
  const { size: fileLength } = await file.stat();
@@ -62,10 +66,10 @@ var MetadataStore = class {
62
66
  size: dataSize,
63
67
  checksum
64
68
  }, {
65
- file: "metadata-store.ts",
66
- line: 69,
67
- scope: this,
68
- callSite: (f, a) => f(...a)
69
+ F: __dxlog_file,
70
+ L: 72,
71
+ S: this,
72
+ C: (f, a) => f(...a)
69
73
  });
70
74
  if (fileLength < dataSize + 8) {
71
75
  throw new DataCorruptionError("Metadata size is smaller than expected.");
@@ -75,15 +79,19 @@ var MetadataStore = class {
75
79
  if (calculatedChecksum !== checksum) {
76
80
  throw new DataCorruptionError("Metadata checksum is invalid.");
77
81
  }
78
- 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
+ });
79
87
  } catch (err) {
80
88
  log.error("failed to load metadata", {
81
89
  err
82
90
  }, {
83
- file: "metadata-store.ts",
84
- line: 84,
85
- scope: this,
86
- callSite: (f, a) => f(...a)
91
+ F: __dxlog_file,
92
+ L: 92,
93
+ S: this,
94
+ C: (f, a) => f(...a)
87
95
  });
88
96
  this._metadata = emptyEchoMetadata();
89
97
  } finally {
@@ -101,7 +109,7 @@ var MetadataStore = class {
101
109
  this.update.emit(data);
102
110
  const file = this._directory.getOrCreateFile("EchoMetadata");
103
111
  try {
104
- const encoded = arrayToBuffer(schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
112
+ const encoded = arrayToBuffer(EchoMetadata.encode(data));
105
113
  const checksum = CRC32.buf(encoded);
106
114
  const result = Buffer.alloc(8 + encoded.length);
107
115
  result.writeInt32LE(encoded.length, 0);
@@ -112,10 +120,10 @@ var MetadataStore = class {
112
120
  size: encoded.length,
113
121
  checksum
114
122
  }, {
115
- file: "metadata-store.ts",
116
- line: 116,
117
- scope: this,
118
- callSite: (f, a) => f(...a)
123
+ F: __dxlog_file,
124
+ L: 124,
125
+ S: this,
126
+ C: (f, a) => f(...a)
119
127
  });
120
128
  } finally {
121
129
  await file.close();
@@ -134,11 +142,11 @@ var MetadataStore = class {
134
142
  * Clears storage - doesn't work for now.
135
143
  */
136
144
  async clear() {
137
- log("clearing all metadata", {}, {
138
- file: "metadata-store.ts",
139
- line: 137,
140
- scope: this,
141
- callSite: (f, a) => f(...a)
145
+ log("clearing all metadata", void 0, {
146
+ F: __dxlog_file,
147
+ L: 145,
148
+ S: this,
149
+ C: (f, a) => f(...a)
142
150
  });
143
151
  await this._directory.delete();
144
152
  this._metadata = emptyEchoMetadata();
@@ -175,11 +183,15 @@ var MetadataStore = class {
175
183
  space.dataFeedKey = dataFeedKey;
176
184
  await this._save();
177
185
  }
186
+ async setSpaceState(spaceKey, state) {
187
+ this._getSpace(spaceKey).state = state;
188
+ await this._save();
189
+ }
178
190
  };
179
- __decorate([
191
+ _ts_decorate([
180
192
  synchronized
181
193
  ], MetadataStore.prototype, "load", null);
182
- __decorate([
194
+ _ts_decorate([
183
195
  synchronized
184
196
  ], MetadataStore.prototype, "_save", null);
185
197
  var fromBytesInt32 = (buf) => buf.readInt32LE(0);
@@ -205,7 +217,7 @@ import { Event as Event2 } from "@dxos/async";
205
217
  import { timed } from "@dxos/debug";
206
218
  import { log as log2 } from "@dxos/log";
207
219
  import { Timeframe } from "@dxos/timeframe";
208
- var __decorate2 = function(decorators, target, key, desc) {
220
+ function _ts_decorate2(decorators, target, key, desc) {
209
221
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
210
222
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
211
223
  r = Reflect.decorate(decorators, target, key, desc);
@@ -214,7 +226,8 @@ var __decorate2 = function(decorators, target, key, desc) {
214
226
  if (d = decorators[i])
215
227
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
216
228
  return c > 3 && r && Object.defineProperty(target, key, r), r;
217
- };
229
+ }
230
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
218
231
  var mapTimeframeToFeedIndexes = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
219
232
  feedKey,
220
233
  index
@@ -273,10 +286,10 @@ var TimeframeClock = class {
273
286
  target,
274
287
  current: this._timeframe
275
288
  }, {
276
- file: "timeframe-clock.ts",
277
- line: 73,
278
- scope: this,
279
- callSite: (f, a) => f(...a)
289
+ F: __dxlog_file2,
290
+ L: 73,
291
+ S: this,
292
+ C: (f, a) => f(...a)
280
293
  });
281
294
  await this.update.waitForCondition(() => {
282
295
  log2("check if reached", {
@@ -284,16 +297,16 @@ var TimeframeClock = class {
284
297
  current: this._timeframe,
285
298
  deps: Timeframe.dependencies(target, this._timeframe)
286
299
  }, {
287
- file: "timeframe-clock.ts",
288
- line: 75,
289
- scope: this,
290
- callSite: (f, a) => f(...a)
300
+ F: __dxlog_file2,
301
+ L: 75,
302
+ S: this,
303
+ C: (f, a) => f(...a)
291
304
  });
292
305
  return Timeframe.dependencies(target, this._timeframe).isEmpty();
293
306
  });
294
307
  }
295
308
  };
296
- __decorate2([
309
+ _ts_decorate2([
297
310
  timed(5e3)
298
311
  ], TimeframeClock.prototype, "waitUntilReached", null);
299
312
 
@@ -311,6 +324,7 @@ import { ComplexMap } from "@dxos/util";
311
324
  // packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
312
325
  import invariant3 from "tiny-invariant";
313
326
  import { log as log3 } from "@dxos/log";
327
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
314
328
  var createMessageSelector = (timeframeClock) => {
315
329
  return (messages) => {
316
330
  for (let i = 0; i < messages.length; i++) {
@@ -320,17 +334,17 @@ var createMessageSelector = (timeframeClock) => {
320
334
  return i;
321
335
  }
322
336
  }
323
- log3("Skipping...", {}, {
324
- file: "message-selector.ts",
325
- line: 34,
326
- scope: void 0,
327
- callSite: (f, a) => f(...a)
337
+ log3("Skipping...", void 0, {
338
+ F: __dxlog_file3,
339
+ L: 34,
340
+ S: void 0,
341
+ C: (f, a) => f(...a)
328
342
  });
329
343
  };
330
344
  };
331
345
 
332
346
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
333
- var __decorate3 = function(decorators, target, key, desc) {
347
+ function _ts_decorate3(decorators, target, key, desc) {
334
348
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
335
349
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
336
350
  r = Reflect.decorate(decorators, target, key, desc);
@@ -339,12 +353,14 @@ var __decorate3 = function(decorators, target, key, desc) {
339
353
  if (d = decorators[i])
340
354
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
341
355
  return c > 3 && r && Object.defineProperty(target, key, r), r;
342
- };
356
+ }
357
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
343
358
  var PipelineState = class {
344
359
  // prettier-ignore
345
360
  constructor(_feeds, _timeframeClock) {
346
361
  this._feeds = _feeds;
347
362
  this._timeframeClock = _timeframeClock;
363
+ this._ctx = new Context();
348
364
  this.timeframeUpdate = this._timeframeClock.update;
349
365
  this.stalled = new Event3();
350
366
  this._startTimeframe = new Timeframe2();
@@ -395,10 +411,10 @@ var PipelineState = class {
395
411
  current: this.timeframe,
396
412
  target: this.targetTimeframe
397
413
  }, {
398
- file: "pipeline.ts",
399
- line: 118,
400
- scope: this,
401
- callSite: (f, a) => f(...a)
414
+ F: __dxlog_file4,
415
+ L: 126,
416
+ S: this,
417
+ C: (f, a) => f(...a)
402
418
  });
403
419
  (_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
404
420
  this._timeframeClock.update.waitForCondition(() => {
@@ -412,6 +428,7 @@ var PipelineState = class {
412
428
  if (timeout) {
413
429
  return Promise.race([
414
430
  rejectOnDispose(ctx),
431
+ rejectOnDispose(this._ctx),
415
432
  this._reachedTargetPromise.then(() => {
416
433
  done = true;
417
434
  }),
@@ -425,10 +442,10 @@ var PipelineState = class {
425
442
  target: this.targetTimeframe,
426
443
  dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
427
444
  }, {
428
- file: "pipeline.ts",
429
- line: 144,
430
- scope: this,
431
- callSite: (f, a) => f(...a)
445
+ F: __dxlog_file4,
446
+ L: 153,
447
+ S: this,
448
+ C: (f, a) => f(...a)
432
449
  });
433
450
  })
434
451
  ]);
@@ -483,37 +500,40 @@ var Pipeline = class {
483
500
  }
484
501
  async start() {
485
502
  log4("starting...", {}, {
486
- file: "pipeline.ts",
487
- line: 264,
488
- scope: this,
489
- callSite: (f, a) => f(...a)
503
+ F: __dxlog_file4,
504
+ L: 273,
505
+ S: this,
506
+ C: (f, a) => f(...a)
490
507
  });
491
508
  await this._initIterator();
492
509
  await this._feedSetIterator.open();
493
- log4("started", {}, {
494
- file: "pipeline.ts",
495
- line: 267,
496
- scope: this,
497
- callSite: (f, a) => f(...a)
510
+ log4("started", void 0, {
511
+ F: __dxlog_file4,
512
+ L: 276,
513
+ S: this,
514
+ C: (f, a) => f(...a)
498
515
  });
499
516
  this._isStarted = true;
500
517
  }
501
518
  async stop() {
502
519
  var _a;
503
520
  log4("stopping...", {}, {
504
- file: "pipeline.ts",
505
- line: 273,
506
- scope: this,
507
- callSite: (f, a) => f(...a)
521
+ F: __dxlog_file4,
522
+ L: 282,
523
+ S: this,
524
+ C: (f, a) => f(...a)
508
525
  });
509
526
  this._isStopping = true;
510
527
  await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
511
528
  await this._processingTrigger.wait();
512
- log4("stopped", {}, {
513
- file: "pipeline.ts",
514
- line: 277,
515
- scope: this,
516
- callSite: (f, a) => f(...a)
529
+ await this._state._ctx.dispose();
530
+ this._state._ctx = new Context();
531
+ this._state._reachedTargetPromise = void 0;
532
+ log4("stopped", void 0, {
533
+ F: __dxlog_file4,
534
+ L: 289,
535
+ S: this,
536
+ C: (f, a) => f(...a)
517
537
  });
518
538
  this._isStarted = false;
519
539
  }
@@ -586,11 +606,11 @@ var Pipeline = class {
586
606
  const timeframe = this._state._startTimeframe;
587
607
  const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
588
608
  feed.undownload({
589
- callback: () => log4("Undownloaded", {}, {
590
- file: "pipeline.ts",
591
- line: 371,
592
- scope: this,
593
- callSite: (f, a) => f(...a)
609
+ callback: () => log4("Undownloaded", void 0, {
610
+ F: __dxlog_file4,
611
+ L: 383,
612
+ S: this,
613
+ C: (f, a) => f(...a)
594
614
  })
595
615
  });
596
616
  feed.download({
@@ -600,10 +620,10 @@ var Pipeline = class {
600
620
  log4("failed to download feed", {
601
621
  err
602
622
  }, {
603
- file: "pipeline.ts",
604
- line: 374,
605
- scope: this,
606
- callSite: (f, a) => f(...a)
623
+ F: __dxlog_file4,
624
+ L: 386,
625
+ S: this,
626
+ C: (f, a) => f(...a)
607
627
  });
608
628
  });
609
629
  }
@@ -613,11 +633,11 @@ var Pipeline = class {
613
633
  stallTimeout: 1e3
614
634
  });
615
635
  this._feedSetIterator.stalled.on((iterator) => {
616
- log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, {}, {
617
- file: "pipeline.ts",
618
- line: 384,
619
- scope: this,
620
- callSite: (f, a) => f(...a)
636
+ log4.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
637
+ F: __dxlog_file4,
638
+ L: 396,
639
+ S: this,
640
+ C: (f, a) => f(...a)
621
641
  });
622
642
  this._state.stalled.emit();
623
643
  });
@@ -626,19 +646,19 @@ var Pipeline = class {
626
646
  }
627
647
  }
628
648
  };
629
- __decorate3([
649
+ _ts_decorate3([
630
650
  synchronized2
631
651
  ], Pipeline.prototype, "start", null);
632
- __decorate3([
652
+ _ts_decorate3([
633
653
  synchronized2
634
654
  ], Pipeline.prototype, "stop", null);
635
- __decorate3([
655
+ _ts_decorate3([
636
656
  synchronized2
637
657
  ], Pipeline.prototype, "setCursor", null);
638
- __decorate3([
658
+ _ts_decorate3([
639
659
  synchronized2
640
660
  ], Pipeline.prototype, "pause", null);
641
- __decorate3([
661
+ _ts_decorate3([
642
662
  synchronized2
643
663
  ], Pipeline.prototype, "unpause", null);
644
664
 
@@ -650,6 +670,7 @@ import { randomBytes } from "@dxos/crypto";
650
670
  import { log as log5 } from "@dxos/log";
651
671
  import { schema as schema3 } from "@dxos/protocols";
652
672
  import { RpcExtension } from "@dxos/teleport";
673
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
653
674
  var AuthExtension = class extends RpcExtension {
654
675
  constructor(_authParams) {
655
676
  super({
@@ -664,11 +685,11 @@ var AuthExtension = class extends RpcExtension {
664
685
  this._authParams = _authParams;
665
686
  this._ctx = new Context2({
666
687
  onError: (err) => {
667
- log5.catch(err, {}, {
668
- file: "auth.ts",
669
- line: 29,
670
- scope: this,
671
- callSite: (f, a) => f(...a)
688
+ log5.catch(err, void 0, {
689
+ F: __dxlog_file5,
690
+ L: 29,
691
+ S: this,
692
+ C: (f, a) => f(...a)
672
693
  });
673
694
  }
674
695
  });
@@ -687,10 +708,10 @@ var AuthExtension = class extends RpcExtension {
687
708
  };
688
709
  } catch (err) {
689
710
  log5.error("failed to generate auth credentials", err, {
690
- file: "auth.ts",
691
- line: 56,
692
- scope: this,
693
- callSite: (f, a) => f(...a)
711
+ F: __dxlog_file5,
712
+ L: 56,
713
+ S: this,
714
+ C: (f, a) => f(...a)
694
715
  });
695
716
  throw new Error("auth rejected");
696
717
  }
@@ -712,10 +733,10 @@ var AuthExtension = class extends RpcExtension {
712
733
  runInContext(this._ctx, () => this._authParams.onAuthSuccess());
713
734
  } catch (err) {
714
735
  log5("auth failed", err, {
715
- file: "auth.ts",
716
- line: 75,
717
- scope: this,
718
- callSite: (f, a) => f(...a)
736
+ F: __dxlog_file5,
737
+ L: 75,
738
+ S: this,
739
+ C: (f, a) => f(...a)
719
740
  });
720
741
  this.close();
721
742
  this._authParams.onAuthFailure();
@@ -731,21 +752,30 @@ var AuthExtension = class extends RpcExtension {
731
752
  // packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
732
753
  import invariant6 from "tiny-invariant";
733
754
  import { Stream } from "@dxos/codec-protobuf";
755
+ import { Context as Context3 } from "@dxos/context";
734
756
  import { tagMutationsInBatch, setMetadataOnObject } from "@dxos/echo-db";
735
757
  import { log as log6 } from "@dxos/log";
736
758
  import { ComplexMap as ComplexMap2 } from "@dxos/util";
759
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts";
737
760
  var DataServiceHost = class {
738
761
  constructor(_itemManager, _itemDemuxer, _writeStream) {
739
762
  this._itemManager = _itemManager;
740
763
  this._itemDemuxer = _itemDemuxer;
741
764
  this._writeStream = _writeStream;
765
+ this._ctx = new Context3();
742
766
  this._clientTagMap = new ComplexMap2(([feedKey, seq]) => `${feedKey.toHex()}:${seq}`);
743
767
  }
768
+ async open() {
769
+ }
770
+ async close() {
771
+ await this._ctx.dispose();
772
+ }
744
773
  /**
745
774
  * Real-time subscription to data objects in a space.
746
775
  */
747
776
  subscribe() {
748
- return new Stream(({ next, ctx }) => {
777
+ return new Stream(({ next, close, ctx }) => {
778
+ ctx.onDispose(this._ctx.onDispose(close));
749
779
  const objects = Array.from(this._itemManager.entities.values()).map((entity) => entity.createSnapshot());
750
780
  next({
751
781
  batch: {
@@ -760,10 +790,10 @@ var DataServiceHost = class {
760
790
  batch,
761
791
  meta
762
792
  }, {
763
- file: "data-service-host.ts",
764
- line: 51,
765
- scope: this,
766
- callSite: (f, a) => f(...a)
793
+ F: __dxlog_file6,
794
+ L: 63,
795
+ S: this,
796
+ C: (f, a) => f(...a)
767
797
  });
768
798
  const clientTag = this._clientTagMap.get([
769
799
  message.meta.feedKey,
@@ -788,15 +818,16 @@ var DataServiceHost = class {
788
818
  }
789
819
  async write(request) {
790
820
  var _a, _b;
821
+ invariant6(!this._ctx.disposed, "Cannot write to closed DataServiceHost");
791
822
  invariant6(this._writeStream, "Cannot write mutations in readonly mode");
792
823
  log6("write", {
793
824
  clientTag: request.clientTag,
794
825
  objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
795
826
  }, {
796
- file: "data-service-host.ts",
797
- line: 79,
798
- scope: this,
799
- callSite: (f, a) => f(...a)
827
+ F: __dxlog_file6,
828
+ L: 92,
829
+ S: this,
830
+ C: (f, a) => f(...a)
800
831
  });
801
832
  const message = createDataMessage(request.batch);
802
833
  const receipt = await this._writeStream.write(message, {
@@ -807,10 +838,10 @@ var DataServiceHost = class {
807
838
  feedKey: receipt2.feedKey,
808
839
  seq: receipt2.seq
809
840
  }, {
810
- file: "data-service-host.ts",
811
- line: 88,
812
- scope: this,
813
- callSite: (f, a) => f(...a)
841
+ F: __dxlog_file6,
842
+ L: 101,
843
+ S: this,
844
+ C: (f, a) => f(...a)
814
845
  });
815
846
  this._clientTagMap.set([
816
847
  receipt2.feedKey,
@@ -880,7 +911,7 @@ import { timed as timed2 } from "@dxos/debug";
880
911
  import { PublicKey as PublicKey2 } from "@dxos/keys";
881
912
  import { schema as schema4 } from "@dxos/protocols";
882
913
  import { BlobMeta } from "@dxos/protocols/proto/dxos/echo/blob";
883
- var __decorate4 = function(decorators, target, key, desc) {
914
+ function _ts_decorate4(decorators, target, key, desc) {
884
915
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
885
916
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
886
917
  r = Reflect.decorate(decorators, target, key, desc);
@@ -889,7 +920,7 @@ var __decorate4 = function(decorators, target, key, desc) {
889
920
  if (d = decorators[i])
890
921
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
891
922
  return c > 3 && r && Object.defineProperty(target, key, r), r;
892
- };
923
+ }
893
924
  var SnapshotManager = class SnapshotManager2 {
894
925
  // prettier-ignore
895
926
  constructor(_snapshotStore, _blobStore, _blobSync) {
@@ -920,10 +951,10 @@ var SnapshotManager = class SnapshotManager2 {
920
951
  return PublicKey2.from(id).toHex();
921
952
  }
922
953
  };
923
- __decorate4([
954
+ _ts_decorate4([
924
955
  timed2(1e4)
925
956
  ], SnapshotManager.prototype, "load", null);
926
- SnapshotManager = __decorate4([
957
+ SnapshotManager = _ts_decorate4([
927
958
  trackLeaks("open", "close")
928
959
  ], SnapshotManager);
929
960
 
@@ -978,6 +1009,7 @@ import { raise } from "@dxos/debug";
978
1009
  import { PublicKey as PublicKey3 } from "@dxos/keys";
979
1010
  import { log as log7 } from "@dxos/log";
980
1011
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
1012
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
981
1013
  var DataServiceSubscriptions = class {
982
1014
  constructor() {
983
1015
  this._spaces = new ComplexMap3(PublicKey3.hash);
@@ -985,26 +1017,30 @@ var DataServiceSubscriptions = class {
985
1017
  clear() {
986
1018
  this._spaces.clear();
987
1019
  }
988
- registerSpace(spaceKey, host) {
1020
+ async registerSpace(spaceKey, host) {
989
1021
  log7("Registering space", {
990
1022
  spaceKey
991
1023
  }, {
992
- file: "data-service.ts",
993
- line: 31,
994
- scope: this,
995
- callSite: (f, a) => f(...a)
1024
+ F: __dxlog_file7,
1025
+ L: 31,
1026
+ S: this,
1027
+ C: (f, a) => f(...a)
996
1028
  });
1029
+ invariant7(!this._spaces.has(spaceKey));
1030
+ await host.open();
997
1031
  this._spaces.set(spaceKey, host);
998
1032
  }
999
- unregisterSpace(spaceKey) {
1033
+ async unregisterSpace(spaceKey) {
1000
1034
  log7("Unregistering space", {
1001
1035
  spaceKey
1002
1036
  }, {
1003
- file: "data-service.ts",
1004
- line: 36,
1005
- scope: this,
1006
- callSite: (f, a) => f(...a)
1037
+ F: __dxlog_file7,
1038
+ L: 38,
1039
+ S: this,
1040
+ C: (f, a) => f(...a)
1007
1041
  });
1042
+ const host = this._spaces.get(spaceKey);
1043
+ await (host == null ? void 0 : host.close());
1008
1044
  this._spaces.delete(spaceKey);
1009
1045
  }
1010
1046
  getDataService(spaceKey) {
@@ -1033,13 +1069,13 @@ var DataServiceImpl = class {
1033
1069
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1034
1070
  import invariant8 from "tiny-invariant";
1035
1071
  import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
1036
- import { Context as Context3 } from "@dxos/context";
1072
+ import { Context as Context4 } from "@dxos/context";
1037
1073
  import { checkCredentialType } from "@dxos/credentials";
1038
1074
  import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
1039
1075
  import { CancelledError } from "@dxos/errors";
1040
1076
  import { log as log8 } from "@dxos/log";
1041
1077
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
1042
- var __decorate5 = function(decorators, target, key, desc) {
1078
+ function _ts_decorate5(decorators, target, key, desc) {
1043
1079
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1044
1080
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1045
1081
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1048,18 +1084,23 @@ var __decorate5 = function(decorators, target, key, desc) {
1048
1084
  if (d = decorators[i])
1049
1085
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1050
1086
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1051
- };
1087
+ }
1088
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1052
1089
  var MESSAGES_PER_SNAPSHOT = 10;
1053
1090
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1054
1091
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1055
1092
  var DataPipeline = class DataPipeline2 {
1056
1093
  constructor(_params) {
1057
1094
  this._params = _params;
1058
- this._ctx = new Context3();
1095
+ this._ctx = new Context4();
1096
+ this._pipeline = void 0;
1097
+ this._targetTimeframe = void 0;
1059
1098
  this._lastAutomaticSnapshotTimeframe = new Timeframe3();
1060
1099
  this._isOpen = false;
1061
1100
  this._lastTimeframeSaveTime = 0;
1062
1101
  this._lastSnapshotSaveTime = 0;
1102
+ this.currentEpoch = void 0;
1103
+ this.appliedEpoch = void 0;
1063
1104
  this._lastProcessedEpoch = -1;
1064
1105
  this.onNewEpoch = new Event4();
1065
1106
  }
@@ -1078,18 +1119,14 @@ var DataPipeline = class DataPipeline2 {
1078
1119
  this._targetTimeframe = timeframe;
1079
1120
  (_a = this._pipeline) == null ? void 0 : _a.state.setTargetTimeframe(timeframe);
1080
1121
  }
1081
- createCredentialProcessor() {
1082
- return {
1083
- process: async (credential) => {
1084
- if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1085
- return;
1086
- }
1087
- this.currentEpoch = credential;
1088
- if (this._isOpen) {
1089
- await this._processEpochInSeparateTask(credential);
1090
- }
1091
- }
1092
- };
1122
+ async processCredential(credential) {
1123
+ if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1124
+ return;
1125
+ }
1126
+ this.currentEpoch = credential;
1127
+ if (this._isOpen) {
1128
+ await this._processEpochInSeparateTask(credential);
1129
+ }
1093
1130
  }
1094
1131
  async open() {
1095
1132
  if (this._isOpen) {
@@ -1124,11 +1161,11 @@ var DataPipeline = class DataPipeline2 {
1124
1161
  if (!this._isOpen) {
1125
1162
  return;
1126
1163
  }
1127
- log8("close", {}, {
1128
- file: "data-pipeline.ts",
1129
- line: 174,
1130
- scope: this,
1131
- callSite: (f, a) => f(...a)
1164
+ log8("close", void 0, {
1165
+ F: __dxlog_file8,
1166
+ L: 171,
1167
+ S: this,
1168
+ C: (f, a) => f(...a)
1132
1169
  });
1133
1170
  this._isOpen = false;
1134
1171
  await this._ctx.dispose();
@@ -1139,15 +1176,23 @@ var DataPipeline = class DataPipeline2 {
1139
1176
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1140
1177
  }
1141
1178
  } catch (err) {
1142
- log8.catch(err, {}, {
1143
- file: "data-pipeline.ts",
1144
- line: 187,
1145
- scope: this,
1146
- callSite: (f, a) => f(...a)
1179
+ log8.catch(err, void 0, {
1180
+ F: __dxlog_file8,
1181
+ L: 184,
1182
+ S: this,
1183
+ C: (f, a) => f(...a)
1147
1184
  });
1148
1185
  }
1149
1186
  await ((_b = this.databaseHost) == null ? void 0 : _b.close());
1150
1187
  await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
1188
+ this._ctx = new Context4();
1189
+ this._pipeline = void 0;
1190
+ this._targetTimeframe = void 0;
1191
+ this._lastAutomaticSnapshotTimeframe = new Timeframe3();
1192
+ this.currentEpoch = void 0;
1193
+ this.appliedEpoch = void 0;
1194
+ this._lastProcessedEpoch = -1;
1195
+ this._epochCtx = void 0;
1151
1196
  }
1152
1197
  async _consumePipeline() {
1153
1198
  if (this.currentEpoch) {
@@ -1162,10 +1207,10 @@ var DataPipeline = class DataPipeline2 {
1162
1207
  feedKey,
1163
1208
  seq
1164
1209
  }, {
1165
- file: "data-pipeline.ts",
1166
- line: 204,
1167
- scope: this,
1168
- callSite: (f, a) => f(...a)
1210
+ F: __dxlog_file8,
1211
+ L: 210,
1212
+ S: this,
1213
+ C: (f, a) => f(...a)
1169
1214
  });
1170
1215
  try {
1171
1216
  if (data.payload.data) {
@@ -1174,10 +1219,10 @@ var DataPipeline = class DataPipeline2 {
1174
1219
  log8.error("Could not find feed.", {
1175
1220
  feedKey
1176
1221
  }, {
1177
- file: "data-pipeline.ts",
1178
- line: 210,
1179
- scope: this,
1180
- callSite: (f, a) => f(...a)
1222
+ F: __dxlog_file8,
1223
+ L: 216,
1224
+ S: this,
1225
+ C: (f, a) => f(...a)
1181
1226
  });
1182
1227
  continue;
1183
1228
  }
@@ -1195,19 +1240,19 @@ var DataPipeline = class DataPipeline2 {
1195
1240
  seq,
1196
1241
  spaceKey: this._params.spaceKey.toHex()
1197
1242
  }, {
1198
- file: "data-pipeline.ts",
1199
- line: 224,
1200
- scope: this,
1201
- callSite: (f, a) => f(...a)
1243
+ F: __dxlog_file8,
1244
+ L: 230,
1245
+ S: this,
1246
+ C: (f, a) => f(...a)
1202
1247
  });
1203
1248
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1204
1249
  }
1205
1250
  } catch (err) {
1206
- log8.catch(err, {}, {
1207
- file: "data-pipeline.ts",
1208
- line: 234,
1209
- scope: this,
1210
- callSite: (f, a) => f(...a)
1251
+ log8.catch(err, void 0, {
1252
+ F: __dxlog_file8,
1253
+ L: 240,
1254
+ S: this,
1255
+ C: (f, a) => f(...a)
1211
1256
  });
1212
1257
  }
1213
1258
  }
@@ -1232,18 +1277,17 @@ var DataPipeline = class DataPipeline2 {
1232
1277
  try {
1233
1278
  const propertiesItem = this.itemManager.items.find((item) => {
1234
1279
  var _a2, _b;
1235
- return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && // TODO(burdon): Document?
1236
- ((_b = getStateMachineFromItem(item)) == null ? void 0 : _b.snapshot().type) === "dxos.sdk.client.Properties";
1280
+ 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";
1237
1281
  });
1238
1282
  if (propertiesItem) {
1239
1283
  cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
1240
1284
  }
1241
1285
  } catch (err) {
1242
1286
  log8.warn("Failed to cache properties", err, {
1243
- file: "data-pipeline.ts",
1244
- line: 269,
1245
- scope: this,
1246
- callSite: (f, a) => f(...a)
1287
+ F: __dxlog_file8,
1288
+ L: 275,
1289
+ S: this,
1290
+ C: (f, a) => f(...a)
1247
1291
  });
1248
1292
  }
1249
1293
  await this._params.metadataStore.setCache(this._params.spaceKey, cache);
@@ -1263,21 +1307,21 @@ var DataPipeline = class DataPipeline2 {
1263
1307
  return;
1264
1308
  }
1265
1309
  await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
1266
- const ctx = new Context3({
1310
+ const ctx = new Context4({
1267
1311
  onError: (err) => {
1268
1312
  if (err instanceof CancelledError) {
1269
- log8("Epoch processing cancelled.", {}, {
1270
- file: "data-pipeline.ts",
1271
- line: 301,
1272
- scope: this,
1273
- callSite: (f, a) => f(...a)
1313
+ log8("Epoch processing cancelled.", void 0, {
1314
+ F: __dxlog_file8,
1315
+ L: 307,
1316
+ S: this,
1317
+ C: (f, a) => f(...a)
1274
1318
  });
1275
1319
  } else {
1276
- log8.catch(err, {}, {
1277
- file: "data-pipeline.ts",
1278
- line: 303,
1279
- scope: this,
1280
- callSite: (f, a) => f(...a)
1320
+ log8.catch(err, void 0, {
1321
+ F: __dxlog_file8,
1322
+ L: 309,
1323
+ S: this,
1324
+ C: (f, a) => f(...a)
1281
1325
  });
1282
1326
  }
1283
1327
  }
@@ -1290,10 +1334,10 @@ var DataPipeline = class DataPipeline2 {
1290
1334
  log8("process epoch", {
1291
1335
  epoch
1292
1336
  }, {
1293
- file: "data-pipeline.ts",
1294
- line: 313,
1295
- scope: this,
1296
- callSite: (f, a) => f(...a)
1337
+ F: __dxlog_file8,
1338
+ L: 319,
1339
+ S: this,
1340
+ C: (f, a) => f(...a)
1297
1341
  });
1298
1342
  await this._processEpoch(ctx, epoch.subject.assertion);
1299
1343
  this.appliedEpoch = epoch;
@@ -1307,20 +1351,20 @@ var DataPipeline = class DataPipeline2 {
1307
1351
  log8("Processing epoch", {
1308
1352
  epoch
1309
1353
  }, {
1310
- file: "data-pipeline.ts",
1311
- line: 327,
1312
- scope: this,
1313
- callSite: (f, a) => f(...a)
1354
+ F: __dxlog_file8,
1355
+ L: 333,
1356
+ S: this,
1357
+ C: (f, a) => f(...a)
1314
1358
  });
1315
1359
  if (epoch.snapshotCid) {
1316
1360
  const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1317
1361
  this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1318
1362
  }
1319
- log8("restarting pipeline for epoch", {}, {
1320
- file: "data-pipeline.ts",
1321
- line: 335,
1322
- scope: this,
1323
- callSite: (f, a) => f(...a)
1363
+ log8("restarting pipeline for epoch", void 0, {
1364
+ F: __dxlog_file8,
1365
+ L: 341,
1366
+ S: this,
1367
+ C: (f, a) => f(...a)
1324
1368
  });
1325
1369
  await this._pipeline.pause();
1326
1370
  await this._pipeline.setCursor(epoch.timeframe);
@@ -1349,19 +1393,19 @@ var DataPipeline = class DataPipeline2 {
1349
1393
  await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
1350
1394
  }
1351
1395
  };
1352
- __decorate5([
1396
+ _ts_decorate5([
1353
1397
  synchronized3
1354
1398
  ], DataPipeline.prototype, "open", null);
1355
- __decorate5([
1399
+ _ts_decorate5([
1356
1400
  synchronized3
1357
1401
  ], DataPipeline.prototype, "close", null);
1358
- __decorate5([
1402
+ _ts_decorate5([
1359
1403
  synchronized3
1360
1404
  ], DataPipeline.prototype, "_processEpoch", null);
1361
- __decorate5([
1405
+ _ts_decorate5([
1362
1406
  synchronized3
1363
1407
  ], DataPipeline.prototype, "createEpoch", null);
1364
- DataPipeline = __decorate5([
1408
+ DataPipeline = _ts_decorate5([
1365
1409
  trackLeaks2("open", "close")
1366
1410
  ], DataPipeline);
1367
1411
 
@@ -1379,6 +1423,7 @@ import { log as log9 } from "@dxos/log";
1379
1423
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
1380
1424
  import { Timeframe as Timeframe4 } from "@dxos/timeframe";
1381
1425
  import { Callback } from "@dxos/util";
1426
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1382
1427
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1383
1428
  var ControlPipeline = class {
1384
1429
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
@@ -1393,21 +1438,21 @@ var ControlPipeline = class {
1393
1438
  log9("feed admitted", {
1394
1439
  key: info.key
1395
1440
  }, {
1396
- file: "control-pipeline.ts",
1397
- line: 51,
1398
- scope: this,
1399
- callSite: (f, a) => f(...a)
1441
+ F: __dxlog_file9,
1442
+ L: 51,
1443
+ S: this,
1444
+ C: (f, a) => f(...a)
1400
1445
  });
1401
1446
  if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
1402
1447
  try {
1403
1448
  const feed = await feedProvider(info.key);
1404
1449
  await this._pipeline.addFeed(feed);
1405
1450
  } catch (err) {
1406
- log9.catch(err, {}, {
1407
- file: "control-pipeline.ts",
1408
- line: 59,
1409
- scope: this,
1410
- callSite: (f, a) => f(...a)
1451
+ log9.catch(err, void 0, {
1452
+ F: __dxlog_file9,
1453
+ L: 59,
1454
+ S: this,
1455
+ C: (f, a) => f(...a)
1411
1456
  });
1412
1457
  }
1413
1458
  }
@@ -1426,11 +1471,11 @@ var ControlPipeline = class {
1426
1471
  this._pipeline.setWriteFeed(feed);
1427
1472
  }
1428
1473
  async start() {
1429
- log9("starting...", {}, {
1430
- file: "control-pipeline.ts",
1431
- line: 83,
1432
- scope: this,
1433
- callSite: (f, a) => f(...a)
1474
+ log9("starting...", void 0, {
1475
+ F: __dxlog_file9,
1476
+ L: 83,
1477
+ S: this,
1478
+ C: (f, a) => f(...a)
1434
1479
  });
1435
1480
  setTimeout(async () => {
1436
1481
  for await (const msg of this._pipeline.consume()) {
@@ -1439,10 +1484,10 @@ var ControlPipeline = class {
1439
1484
  key: msg.feedKey,
1440
1485
  seq: msg.seq
1441
1486
  }, {
1442
- file: "control-pipeline.ts",
1443
- line: 88,
1444
- scope: this,
1445
- callSite: (f, a) => f(...a)
1487
+ F: __dxlog_file9,
1488
+ L: 88,
1489
+ S: this,
1490
+ C: (f, a) => f(...a)
1446
1491
  });
1447
1492
  if (msg.data.payload.credential) {
1448
1493
  const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
@@ -1450,31 +1495,31 @@ var ControlPipeline = class {
1450
1495
  log9.warn("processing failed", {
1451
1496
  msg
1452
1497
  }, {
1453
- file: "control-pipeline.ts",
1454
- line: 95,
1455
- scope: this,
1456
- callSite: (f, a) => f(...a)
1498
+ F: __dxlog_file9,
1499
+ L: 95,
1500
+ S: this,
1501
+ C: (f, a) => f(...a)
1457
1502
  });
1458
1503
  } else {
1459
1504
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1460
1505
  }
1461
1506
  }
1462
1507
  } catch (err) {
1463
- log9.catch(err, {}, {
1464
- file: "control-pipeline.ts",
1465
- line: 101,
1466
- scope: this,
1467
- callSite: (f, a) => f(...a)
1508
+ log9.catch(err, void 0, {
1509
+ F: __dxlog_file9,
1510
+ L: 101,
1511
+ S: this,
1512
+ C: (f, a) => f(...a)
1468
1513
  });
1469
1514
  }
1470
1515
  }
1471
1516
  });
1472
1517
  await this._pipeline.start();
1473
- log9("started", {}, {
1474
- file: "control-pipeline.ts",
1475
- line: 107,
1476
- scope: this,
1477
- callSite: (f, a) => f(...a)
1518
+ log9("started", void 0, {
1519
+ F: __dxlog_file9,
1520
+ L: 107,
1521
+ S: this,
1522
+ C: (f, a) => f(...a)
1478
1523
  });
1479
1524
  }
1480
1525
  async _noteTargetStateIfNeeded(timeframe) {
@@ -1484,19 +1529,19 @@ var ControlPipeline = class {
1484
1529
  }
1485
1530
  }
1486
1531
  async stop() {
1487
- log9("stopping...", {}, {
1488
- file: "control-pipeline.ts",
1489
- line: 121,
1490
- scope: this,
1491
- callSite: (f, a) => f(...a)
1532
+ log9("stopping...", void 0, {
1533
+ F: __dxlog_file9,
1534
+ L: 121,
1535
+ S: this,
1536
+ C: (f, a) => f(...a)
1492
1537
  });
1493
1538
  await this._pipeline.stop();
1494
1539
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1495
- log9("stopped", {}, {
1496
- file: "control-pipeline.ts",
1497
- line: 124,
1498
- scope: this,
1499
- callSite: (f, a) => f(...a)
1540
+ log9("stopped", void 0, {
1541
+ F: __dxlog_file9,
1542
+ L: 124,
1543
+ S: this,
1544
+ C: (f, a) => f(...a)
1500
1545
  });
1501
1546
  }
1502
1547
  async _saveTargetTimeframe(timeframe) {
@@ -1506,18 +1551,18 @@ var ControlPipeline = class {
1506
1551
  await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1507
1552
  this._targetTimeframe = newTimeframe;
1508
1553
  } catch (err) {
1509
- log9(err, {}, {
1510
- file: "control-pipeline.ts",
1511
- line: 133,
1512
- scope: this,
1513
- callSite: (f, a) => f(...a)
1554
+ log9(err, void 0, {
1555
+ F: __dxlog_file9,
1556
+ L: 133,
1557
+ S: this,
1558
+ C: (f, a) => f(...a)
1514
1559
  });
1515
1560
  }
1516
1561
  }
1517
1562
  };
1518
1563
 
1519
1564
  // packages/core/echo/echo-pipeline/src/space/space.ts
1520
- var __decorate6 = function(decorators, target, key, desc) {
1565
+ function _ts_decorate6(decorators, target, key, desc) {
1521
1566
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1522
1567
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1523
1568
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1526,14 +1571,13 @@ var __decorate6 = function(decorators, target, key, desc) {
1526
1571
  if (d = decorators[i])
1527
1572
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1528
1573
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1529
- };
1574
+ }
1575
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1530
1576
  var Space = class Space2 {
1531
1577
  constructor(params) {
1532
1578
  this._addFeedLock = new Lock();
1533
1579
  this.onCredentialProcessed = new Callback2();
1534
1580
  this.stateUpdate = new Event5();
1535
- // Processes epoch credentials.
1536
- this._dataPipelineCredentialConsumer = void 0;
1537
1581
  this._isOpen = false;
1538
1582
  invariant9(params.spaceKey && params.feedProvider);
1539
1583
  this._key = params.spaceKey;
@@ -1570,10 +1614,10 @@ var Space = class Space2 {
1570
1614
  log10("onCredentialProcessed", {
1571
1615
  credential
1572
1616
  }, {
1573
- file: "space.ts",
1574
- line: 110,
1575
- scope: this,
1576
- callSite: (f, a) => f(...a)
1617
+ F: __dxlog_file10,
1618
+ L: 107,
1619
+ S: this,
1620
+ C: (f, a) => f(...a)
1577
1621
  });
1578
1622
  this.stateUpdate.emit();
1579
1623
  });
@@ -1661,77 +1705,74 @@ var Space = class Space2 {
1661
1705
  // return this._dataPipeline?.getFeeds();
1662
1706
  // }
1663
1707
  async open() {
1664
- log10("opening...", {}, {
1665
- file: "space.ts",
1666
- line: 212,
1667
- scope: this,
1668
- callSite: (f, a) => f(...a)
1708
+ log10("opening...", void 0, {
1709
+ F: __dxlog_file10,
1710
+ L: 209,
1711
+ S: this,
1712
+ C: (f, a) => f(...a)
1669
1713
  });
1670
1714
  if (this._isOpen) {
1671
1715
  return;
1672
1716
  }
1673
1717
  await this._controlPipeline.start();
1674
1718
  await this.protocol.start();
1675
- this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1676
- await this._dataPipelineCredentialConsumer.open();
1719
+ await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
1677
1720
  this._isOpen = true;
1678
- log10("opened", {}, {
1679
- file: "space.ts",
1680
- line: 228,
1681
- scope: this,
1682
- callSite: (f, a) => f(...a)
1721
+ log10("opened", void 0, {
1722
+ F: __dxlog_file10,
1723
+ L: 220,
1724
+ S: this,
1725
+ C: (f, a) => f(...a)
1683
1726
  });
1684
1727
  }
1685
1728
  async close() {
1686
- var _a;
1687
1729
  log10("closing...", {
1688
1730
  key: this._key
1689
1731
  }, {
1690
- file: "space.ts",
1691
- line: 233,
1692
- scope: this,
1693
- callSite: (f, a) => f(...a)
1732
+ F: __dxlog_file10,
1733
+ L: 225,
1734
+ S: this,
1735
+ C: (f, a) => f(...a)
1694
1736
  });
1695
1737
  if (!this._isOpen) {
1696
1738
  return;
1697
1739
  }
1698
- await ((_a = this._dataPipelineCredentialConsumer) == null ? void 0 : _a.close());
1699
- this._dataPipelineCredentialConsumer = void 0;
1740
+ await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
1700
1741
  await this._dataPipeline.close();
1701
1742
  await this.protocol.stop();
1702
1743
  await this._controlPipeline.stop();
1703
1744
  this._isOpen = false;
1704
- log10("closed", {}, {
1705
- file: "space.ts",
1706
- line: 247,
1707
- scope: this,
1708
- callSite: (f, a) => f(...a)
1745
+ log10("closed", void 0, {
1746
+ F: __dxlog_file10,
1747
+ L: 238,
1748
+ S: this,
1749
+ C: (f, a) => f(...a)
1709
1750
  });
1710
1751
  }
1711
1752
  async initializeDataPipeline() {
1712
- log10("initializeDataPipeline", {}, {
1713
- file: "space.ts",
1714
- line: 252,
1715
- scope: this,
1716
- callSite: (f, a) => f(...a)
1753
+ log10("initializeDataPipeline", void 0, {
1754
+ F: __dxlog_file10,
1755
+ L: 243,
1756
+ S: this,
1757
+ C: (f, a) => f(...a)
1717
1758
  });
1718
1759
  invariant9(this._isOpen, "Space must be open to initialize data pipeline.");
1719
1760
  await this._dataPipeline.open();
1720
1761
  }
1721
1762
  };
1722
- __decorate6([
1763
+ _ts_decorate6([
1723
1764
  logInfo
1724
1765
  ], Space.prototype, "key", null);
1725
- __decorate6([
1766
+ _ts_decorate6([
1726
1767
  synchronized4
1727
1768
  ], Space.prototype, "open", null);
1728
- __decorate6([
1769
+ _ts_decorate6([
1729
1770
  synchronized4
1730
1771
  ], Space.prototype, "close", null);
1731
- __decorate6([
1772
+ _ts_decorate6([
1732
1773
  synchronized4
1733
1774
  ], Space.prototype, "initializeDataPipeline", null);
1734
- Space = __decorate6([
1775
+ Space = _ts_decorate6([
1735
1776
  trackLeaks3("open", "close")
1736
1777
  ], Space);
1737
1778
 
@@ -1744,7 +1785,7 @@ import { Teleport } from "@dxos/teleport";
1744
1785
  import { BlobSync } from "@dxos/teleport-extension-object-sync";
1745
1786
  import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
1746
1787
  import { ComplexMap as ComplexMap4 } from "@dxos/util";
1747
- var __decorate7 = function(decorators, target, key, desc) {
1788
+ function _ts_decorate7(decorators, target, key, desc) {
1748
1789
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1749
1790
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1750
1791
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1753,7 +1794,8 @@ var __decorate7 = function(decorators, target, key, desc) {
1753
1794
  if (d = decorators[i])
1754
1795
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1755
1796
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1756
- };
1797
+ }
1798
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1757
1799
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1758
1800
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1759
1801
  var SpaceProtocol = class {
@@ -1783,10 +1825,10 @@ var SpaceProtocol = class {
1783
1825
  log11("addFeed", {
1784
1826
  key: feed.key
1785
1827
  }, {
1786
- file: "space-protocol.ts",
1787
- line: 96,
1788
- scope: this,
1789
- callSite: (f, a) => f(...a)
1828
+ F: __dxlog_file11,
1829
+ L: 96,
1830
+ S: this,
1831
+ C: (f, a) => f(...a)
1790
1832
  });
1791
1833
  this._feeds.add(feed);
1792
1834
  for (const session of this._sessions.values()) {
@@ -1804,11 +1846,11 @@ var SpaceProtocol = class {
1804
1846
  sampleSize: 20
1805
1847
  };
1806
1848
  await this.blobSync.open();
1807
- log11("starting...", {}, {
1808
- file: "space-protocol.ts",
1809
- line: 121,
1810
- scope: this,
1811
- callSite: (f, a) => f(...a)
1849
+ log11("starting...", void 0, {
1850
+ F: __dxlog_file11,
1851
+ L: 121,
1852
+ S: this,
1853
+ C: (f, a) => f(...a)
1812
1854
  });
1813
1855
  this._connection = await this._networkManager.joinSwarm({
1814
1856
  protocolProvider: this._createProtocolProvider(credentials),
@@ -1817,28 +1859,28 @@ var SpaceProtocol = class {
1817
1859
  topology: new MMSTTopology(topologyConfig),
1818
1860
  label: `Protocol swarm: ${this._topic}`
1819
1861
  });
1820
- log11("started", {}, {
1821
- file: "space-protocol.ts",
1822
- line: 130,
1823
- scope: this,
1824
- callSite: (f, a) => f(...a)
1862
+ log11("started", void 0, {
1863
+ F: __dxlog_file11,
1864
+ L: 130,
1865
+ S: this,
1866
+ C: (f, a) => f(...a)
1825
1867
  });
1826
1868
  }
1827
1869
  async stop() {
1828
1870
  await this.blobSync.close();
1829
1871
  if (this._connection) {
1830
- log11("stopping...", {}, {
1831
- file: "space-protocol.ts",
1832
- line: 137,
1833
- scope: this,
1834
- callSite: (f, a) => f(...a)
1872
+ log11("stopping...", void 0, {
1873
+ F: __dxlog_file11,
1874
+ L: 137,
1875
+ S: this,
1876
+ C: (f, a) => f(...a)
1835
1877
  });
1836
1878
  await this._connection.close();
1837
- log11("stopped", {}, {
1838
- file: "space-protocol.ts",
1839
- line: 139,
1840
- scope: this,
1841
- callSite: (f, a) => f(...a)
1879
+ log11("stopped", void 0, {
1880
+ F: __dxlog_file11,
1881
+ L: 139,
1882
+ S: this,
1883
+ C: (f, a) => f(...a)
1842
1884
  });
1843
1885
  }
1844
1886
  }
@@ -1859,10 +1901,10 @@ var SpaceProtocol = class {
1859
1901
  };
1860
1902
  }
1861
1903
  };
1862
- __decorate7([
1904
+ _ts_decorate7([
1863
1905
  logInfo2
1864
1906
  ], SpaceProtocol.prototype, "_topic", void 0);
1865
- __decorate7([
1907
+ _ts_decorate7([
1866
1908
  logInfo2
1867
1909
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
1868
1910
  var AuthStatus;
@@ -1902,11 +1944,11 @@ var SpaceProtocolSession = class {
1902
1944
  verifier: this._swarmIdentity.credentialAuthenticator,
1903
1945
  onAuthSuccess: () => {
1904
1946
  var _a;
1905
- log11("Peer authenticated", {}, {
1906
- file: "space-protocol.ts",
1907
- line: 236,
1908
- scope: this,
1909
- callSite: (f, a) => f(...a)
1947
+ log11("Peer authenticated", void 0, {
1948
+ F: __dxlog_file11,
1949
+ L: 236,
1950
+ S: this,
1951
+ C: (f, a) => f(...a)
1910
1952
  });
1911
1953
  this._authStatus = AuthStatus.SUCCESS;
1912
1954
  (_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
@@ -1924,10 +1966,10 @@ var SpaceProtocolSession = class {
1924
1966
  await this._teleport.close();
1925
1967
  }
1926
1968
  };
1927
- __decorate7([
1969
+ _ts_decorate7([
1928
1970
  logInfo2
1929
1971
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
1930
- __decorate7([
1972
+ _ts_decorate7([
1931
1973
  logInfo2
1932
1974
  ], SpaceProtocolSession.prototype, "authStatus", null);
1933
1975
 
@@ -1938,7 +1980,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
1938
1980
  import { log as log12 } from "@dxos/log";
1939
1981
  import { trace } from "@dxos/protocols";
1940
1982
  import { ComplexMap as ComplexMap5 } from "@dxos/util";
1941
- var __decorate8 = function(decorators, target, key, desc) {
1983
+ function _ts_decorate8(decorators, target, key, desc) {
1942
1984
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1943
1985
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1944
1986
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1947,7 +1989,8 @@ var __decorate8 = function(decorators, target, key, desc) {
1947
1989
  if (d = decorators[i])
1948
1990
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1949
1991
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1950
- };
1992
+ }
1993
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1951
1994
  var SpaceManager = class SpaceManager2 {
1952
1995
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
1953
1996
  this._spaces = new ComplexMap5(PublicKey6.hash);
@@ -1975,18 +2018,18 @@ var SpaceManager = class SpaceManager2 {
1975
2018
  log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
1976
2019
  id: this._instanceId
1977
2020
  }), {
1978
- file: "space-manager.ts",
1979
- line: 97,
1980
- scope: this,
1981
- callSite: (f, a) => f(...a)
2021
+ F: __dxlog_file12,
2022
+ L: 97,
2023
+ S: this,
2024
+ C: (f, a) => f(...a)
1982
2025
  });
1983
2026
  log12("constructing space...", {
1984
2027
  spaceKey: metadata.genesisFeedKey
1985
2028
  }, {
1986
- file: "space-manager.ts",
1987
- line: 98,
1988
- scope: this,
1989
- callSite: (f, a) => f(...a)
2029
+ F: __dxlog_file12,
2030
+ L: 98,
2031
+ S: this,
2032
+ C: (f, a) => f(...a)
1990
2033
  });
1991
2034
  const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : failUndefined2());
1992
2035
  const spaceKey = metadata.key;
@@ -2013,21 +2056,21 @@ var SpaceManager = class SpaceManager2 {
2013
2056
  log12.trace("dxos.echo.space-manager.construct-space", trace.end({
2014
2057
  id: this._instanceId
2015
2058
  }), {
2016
- file: "space-manager.ts",
2017
- line: 125,
2018
- scope: this,
2019
- callSite: (f, a) => f(...a)
2059
+ F: __dxlog_file12,
2060
+ L: 125,
2061
+ S: this,
2062
+ C: (f, a) => f(...a)
2020
2063
  });
2021
2064
  return space;
2022
2065
  }
2023
2066
  };
2024
- __decorate8([
2067
+ _ts_decorate8([
2025
2068
  synchronized5
2026
2069
  ], SpaceManager.prototype, "open", null);
2027
- __decorate8([
2070
+ _ts_decorate8([
2028
2071
  synchronized5
2029
2072
  ], SpaceManager.prototype, "close", null);
2030
- SpaceManager = __decorate8([
2073
+ SpaceManager = _ts_decorate8([
2031
2074
  trackLeaks4("open", "close")
2032
2075
  ], SpaceManager);
2033
2076
 
@@ -2057,4 +2100,4 @@ export {
2057
2100
  SpaceProtocolSession,
2058
2101
  SpaceManager
2059
2102
  };
2060
- //# sourceMappingURL=chunk-ZYDZBSIT.mjs.map
2103
+ //# sourceMappingURL=chunk-RFRZMQ5T.mjs.map