@dxos/echo-pipeline 0.1.53-main.d2dd40b → 0.1.53-main.d824199

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 (42) hide show
  1. package/dist/lib/browser/{chunk-ZYDZBSIT.mjs → chunk-OJGL5427.mjs} +395 -350
  2. package/dist/lib/browser/chunk-OJGL5427.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +1 -1
  4. package/dist/lib/browser/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 +396 -351
  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 +402 -357
  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/dbhost/snapshot-manager.d.ts +2 -0
  18. package/dist/types/src/dbhost/snapshot-manager.d.ts.map +1 -1
  19. package/dist/types/src/dbhost/snapshot-store.d.ts +2 -0
  20. package/dist/types/src/dbhost/snapshot-store.d.ts.map +1 -1
  21. package/dist/types/src/metadata/metadata-store.d.ts +4 -0
  22. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  23. package/dist/types/src/pipeline/pipeline.d.ts +0 -1
  24. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  25. package/dist/types/src/space/data-pipeline.d.ts +3 -3
  26. package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
  27. package/dist/types/src/space/space.d.ts +0 -1
  28. package/dist/types/src/space/space.d.ts.map +1 -1
  29. package/package.json +30 -30
  30. package/src/dbhost/data-service-host.ts +14 -1
  31. package/src/dbhost/data-service.ts +6 -2
  32. package/src/dbhost/snapshot-manager.ts +4 -4
  33. package/src/dbhost/snapshot-store.ts +3 -2
  34. package/src/metadata/metadata-store.ts +15 -2
  35. package/src/pipeline/pipeline.ts +13 -1
  36. package/src/space/data-pipeline.ts +25 -19
  37. package/src/space/replication.browser.test.ts +2 -2
  38. package/src/space/space.test.ts +46 -5
  39. package/src/space/space.ts +3 -12
  40. package/src/testing/util.ts +1 -1
  41. package/src/tests/database.test.ts +1 -1
  42. 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,8 @@ 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
+ }
924
+ var SpaceSnapshot = schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
893
925
  var SnapshotManager = class SnapshotManager2 {
894
926
  // prettier-ignore
895
927
  constructor(_snapshotStore, _blobStore, _blobSync) {
@@ -899,7 +931,7 @@ var SnapshotManager = class SnapshotManager2 {
899
931
  }
900
932
  async _getBlob(blobId) {
901
933
  const blob = await this._blobStore.get(blobId);
902
- return schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(blob);
934
+ return SpaceSnapshot.decode(blob);
903
935
  }
904
936
  async load(ctx, id) {
905
937
  const blobId = PublicKey2.fromHex(id).asUint8Array();
@@ -915,28 +947,29 @@ var SnapshotManager = class SnapshotManager2 {
915
947
  return this._getBlob(blobId);
916
948
  }
917
949
  async store(snapshot) {
918
- const { id } = await this._blobStore.set(schema4.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot));
950
+ const { id } = await this._blobStore.set(SpaceSnapshot.encode(snapshot));
919
951
  await this._blobSync.notifyBlobAdded(id);
920
952
  return PublicKey2.from(id).toHex();
921
953
  }
922
954
  };
923
- __decorate4([
955
+ _ts_decorate4([
924
956
  timed2(1e4)
925
957
  ], SnapshotManager.prototype, "load", null);
926
- SnapshotManager = __decorate4([
958
+ SnapshotManager = _ts_decorate4([
927
959
  trackLeaks("open", "close")
928
960
  ], SnapshotManager);
929
961
 
930
962
  // packages/core/echo/echo-pipeline/src/dbhost/snapshot-store.ts
931
963
  import { subtleCrypto } from "@dxos/crypto";
932
964
  import { schema as schema5 } from "@dxos/protocols";
965
+ var SpaceSnapshot2 = schema5.getCodecForType("dxos.echo.snapshot.SpaceSnapshot");
933
966
  var SnapshotStore = class {
934
967
  // prettier-ignore
935
968
  constructor(_directory) {
936
969
  this._directory = _directory;
937
970
  }
938
971
  async saveSnapshot(snapshot) {
939
- const encoded = schema5.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").encode(snapshot);
972
+ const encoded = SpaceSnapshot2.encode(snapshot);
940
973
  const key = await subtleCrypto.digest("SHA-256", encoded);
941
974
  const keyString = Buffer.from(key).toString("hex");
942
975
  const file = await this._directory.getOrCreateFile(keyString);
@@ -955,7 +988,7 @@ var SnapshotStore = class {
955
988
  return void 0;
956
989
  }
957
990
  const buffer = await file.read(0, size);
958
- return schema5.getCodecForType("dxos.echo.snapshot.SpaceSnapshot").decode(buffer);
991
+ return SpaceSnapshot2.decode(buffer);
959
992
  } finally {
960
993
  await file.close();
961
994
  }
@@ -978,6 +1011,7 @@ import { raise } from "@dxos/debug";
978
1011
  import { PublicKey as PublicKey3 } from "@dxos/keys";
979
1012
  import { log as log7 } from "@dxos/log";
980
1013
  import { ComplexMap as ComplexMap3 } from "@dxos/util";
1014
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
981
1015
  var DataServiceSubscriptions = class {
982
1016
  constructor() {
983
1017
  this._spaces = new ComplexMap3(PublicKey3.hash);
@@ -985,26 +1019,30 @@ var DataServiceSubscriptions = class {
985
1019
  clear() {
986
1020
  this._spaces.clear();
987
1021
  }
988
- registerSpace(spaceKey, host) {
1022
+ async registerSpace(spaceKey, host) {
989
1023
  log7("Registering space", {
990
1024
  spaceKey
991
1025
  }, {
992
- file: "data-service.ts",
993
- line: 31,
994
- scope: this,
995
- callSite: (f, a) => f(...a)
1026
+ F: __dxlog_file7,
1027
+ L: 31,
1028
+ S: this,
1029
+ C: (f, a) => f(...a)
996
1030
  });
1031
+ invariant7(!this._spaces.has(spaceKey));
1032
+ await host.open();
997
1033
  this._spaces.set(spaceKey, host);
998
1034
  }
999
- unregisterSpace(spaceKey) {
1035
+ async unregisterSpace(spaceKey) {
1000
1036
  log7("Unregistering space", {
1001
1037
  spaceKey
1002
1038
  }, {
1003
- file: "data-service.ts",
1004
- line: 36,
1005
- scope: this,
1006
- callSite: (f, a) => f(...a)
1039
+ F: __dxlog_file7,
1040
+ L: 38,
1041
+ S: this,
1042
+ C: (f, a) => f(...a)
1007
1043
  });
1044
+ const host = this._spaces.get(spaceKey);
1045
+ await (host == null ? void 0 : host.close());
1008
1046
  this._spaces.delete(spaceKey);
1009
1047
  }
1010
1048
  getDataService(spaceKey) {
@@ -1033,13 +1071,13 @@ var DataServiceImpl = class {
1033
1071
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1034
1072
  import invariant8 from "tiny-invariant";
1035
1073
  import { Event as Event4, scheduleTask as scheduleTask2, synchronized as synchronized3, trackLeaks as trackLeaks2 } from "@dxos/async";
1036
- import { Context as Context3 } from "@dxos/context";
1074
+ import { Context as Context4 } from "@dxos/context";
1037
1075
  import { checkCredentialType } from "@dxos/credentials";
1038
1076
  import { getStateMachineFromItem, ItemManager } from "@dxos/echo-db";
1039
1077
  import { CancelledError } from "@dxos/errors";
1040
1078
  import { log as log8 } from "@dxos/log";
1041
1079
  import { Timeframe as Timeframe3 } from "@dxos/timeframe";
1042
- var __decorate5 = function(decorators, target, key, desc) {
1080
+ function _ts_decorate5(decorators, target, key, desc) {
1043
1081
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1044
1082
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1045
1083
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1048,18 +1086,23 @@ var __decorate5 = function(decorators, target, key, desc) {
1048
1086
  if (d = decorators[i])
1049
1087
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1050
1088
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1051
- };
1089
+ }
1090
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1052
1091
  var MESSAGES_PER_SNAPSHOT = 10;
1053
1092
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1054
1093
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1055
1094
  var DataPipeline = class DataPipeline2 {
1056
1095
  constructor(_params) {
1057
1096
  this._params = _params;
1058
- this._ctx = new Context3();
1097
+ this._ctx = new Context4();
1098
+ this._pipeline = void 0;
1099
+ this._targetTimeframe = void 0;
1059
1100
  this._lastAutomaticSnapshotTimeframe = new Timeframe3();
1060
1101
  this._isOpen = false;
1061
1102
  this._lastTimeframeSaveTime = 0;
1062
1103
  this._lastSnapshotSaveTime = 0;
1104
+ this.currentEpoch = void 0;
1105
+ this.appliedEpoch = void 0;
1063
1106
  this._lastProcessedEpoch = -1;
1064
1107
  this.onNewEpoch = new Event4();
1065
1108
  }
@@ -1078,18 +1121,14 @@ var DataPipeline = class DataPipeline2 {
1078
1121
  this._targetTimeframe = timeframe;
1079
1122
  (_a = this._pipeline) == null ? void 0 : _a.state.setTargetTimeframe(timeframe);
1080
1123
  }
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
- };
1124
+ async processCredential(credential) {
1125
+ if (!checkCredentialType(credential, "dxos.halo.credentials.Epoch")) {
1126
+ return;
1127
+ }
1128
+ this.currentEpoch = credential;
1129
+ if (this._isOpen) {
1130
+ await this._processEpochInSeparateTask(credential);
1131
+ }
1093
1132
  }
1094
1133
  async open() {
1095
1134
  if (this._isOpen) {
@@ -1124,11 +1163,11 @@ var DataPipeline = class DataPipeline2 {
1124
1163
  if (!this._isOpen) {
1125
1164
  return;
1126
1165
  }
1127
- log8("close", {}, {
1128
- file: "data-pipeline.ts",
1129
- line: 174,
1130
- scope: this,
1131
- callSite: (f, a) => f(...a)
1166
+ log8("close", void 0, {
1167
+ F: __dxlog_file8,
1168
+ L: 171,
1169
+ S: this,
1170
+ C: (f, a) => f(...a)
1132
1171
  });
1133
1172
  this._isOpen = false;
1134
1173
  await this._ctx.dispose();
@@ -1139,15 +1178,23 @@ var DataPipeline = class DataPipeline2 {
1139
1178
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1140
1179
  }
1141
1180
  } catch (err) {
1142
- log8.catch(err, {}, {
1143
- file: "data-pipeline.ts",
1144
- line: 187,
1145
- scope: this,
1146
- callSite: (f, a) => f(...a)
1181
+ log8.catch(err, void 0, {
1182
+ F: __dxlog_file8,
1183
+ L: 184,
1184
+ S: this,
1185
+ C: (f, a) => f(...a)
1147
1186
  });
1148
1187
  }
1149
1188
  await ((_b = this.databaseHost) == null ? void 0 : _b.close());
1150
1189
  await ((_c = this.itemManager) == null ? void 0 : _c.destroy());
1190
+ this._ctx = new Context4();
1191
+ this._pipeline = void 0;
1192
+ this._targetTimeframe = void 0;
1193
+ this._lastAutomaticSnapshotTimeframe = new Timeframe3();
1194
+ this.currentEpoch = void 0;
1195
+ this.appliedEpoch = void 0;
1196
+ this._lastProcessedEpoch = -1;
1197
+ this._epochCtx = void 0;
1151
1198
  }
1152
1199
  async _consumePipeline() {
1153
1200
  if (this.currentEpoch) {
@@ -1162,10 +1209,10 @@ var DataPipeline = class DataPipeline2 {
1162
1209
  feedKey,
1163
1210
  seq
1164
1211
  }, {
1165
- file: "data-pipeline.ts",
1166
- line: 204,
1167
- scope: this,
1168
- callSite: (f, a) => f(...a)
1212
+ F: __dxlog_file8,
1213
+ L: 210,
1214
+ S: this,
1215
+ C: (f, a) => f(...a)
1169
1216
  });
1170
1217
  try {
1171
1218
  if (data.payload.data) {
@@ -1174,10 +1221,10 @@ var DataPipeline = class DataPipeline2 {
1174
1221
  log8.error("Could not find feed.", {
1175
1222
  feedKey
1176
1223
  }, {
1177
- file: "data-pipeline.ts",
1178
- line: 210,
1179
- scope: this,
1180
- callSite: (f, a) => f(...a)
1224
+ F: __dxlog_file8,
1225
+ L: 216,
1226
+ S: this,
1227
+ C: (f, a) => f(...a)
1181
1228
  });
1182
1229
  continue;
1183
1230
  }
@@ -1195,19 +1242,19 @@ var DataPipeline = class DataPipeline2 {
1195
1242
  seq,
1196
1243
  spaceKey: this._params.spaceKey.toHex()
1197
1244
  }, {
1198
- file: "data-pipeline.ts",
1199
- line: 224,
1200
- scope: this,
1201
- callSite: (f, a) => f(...a)
1245
+ F: __dxlog_file8,
1246
+ L: 230,
1247
+ S: this,
1248
+ C: (f, a) => f(...a)
1202
1249
  });
1203
1250
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1204
1251
  }
1205
1252
  } catch (err) {
1206
- log8.catch(err, {}, {
1207
- file: "data-pipeline.ts",
1208
- line: 234,
1209
- scope: this,
1210
- callSite: (f, a) => f(...a)
1253
+ log8.catch(err, void 0, {
1254
+ F: __dxlog_file8,
1255
+ L: 240,
1256
+ S: this,
1257
+ C: (f, a) => f(...a)
1211
1258
  });
1212
1259
  }
1213
1260
  }
@@ -1232,18 +1279,17 @@ var DataPipeline = class DataPipeline2 {
1232
1279
  try {
1233
1280
  const propertiesItem = this.itemManager.items.find((item) => {
1234
1281
  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";
1282
+ 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
1283
  });
1238
1284
  if (propertiesItem) {
1239
1285
  cache.properties = (_a = getStateMachineFromItem(propertiesItem)) == null ? void 0 : _a.snapshot();
1240
1286
  }
1241
1287
  } catch (err) {
1242
1288
  log8.warn("Failed to cache properties", err, {
1243
- file: "data-pipeline.ts",
1244
- line: 269,
1245
- scope: this,
1246
- callSite: (f, a) => f(...a)
1289
+ F: __dxlog_file8,
1290
+ L: 275,
1291
+ S: this,
1292
+ C: (f, a) => f(...a)
1247
1293
  });
1248
1294
  }
1249
1295
  await this._params.metadataStore.setCache(this._params.spaceKey, cache);
@@ -1263,21 +1309,21 @@ var DataPipeline = class DataPipeline2 {
1263
1309
  return;
1264
1310
  }
1265
1311
  await ((_a = this._epochCtx) == null ? void 0 : _a.dispose());
1266
- const ctx = new Context3({
1312
+ const ctx = new Context4({
1267
1313
  onError: (err) => {
1268
1314
  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)
1315
+ log8("Epoch processing cancelled.", void 0, {
1316
+ F: __dxlog_file8,
1317
+ L: 307,
1318
+ S: this,
1319
+ C: (f, a) => f(...a)
1274
1320
  });
1275
1321
  } else {
1276
- log8.catch(err, {}, {
1277
- file: "data-pipeline.ts",
1278
- line: 303,
1279
- scope: this,
1280
- callSite: (f, a) => f(...a)
1322
+ log8.catch(err, void 0, {
1323
+ F: __dxlog_file8,
1324
+ L: 309,
1325
+ S: this,
1326
+ C: (f, a) => f(...a)
1281
1327
  });
1282
1328
  }
1283
1329
  }
@@ -1290,10 +1336,10 @@ var DataPipeline = class DataPipeline2 {
1290
1336
  log8("process epoch", {
1291
1337
  epoch
1292
1338
  }, {
1293
- file: "data-pipeline.ts",
1294
- line: 313,
1295
- scope: this,
1296
- callSite: (f, a) => f(...a)
1339
+ F: __dxlog_file8,
1340
+ L: 319,
1341
+ S: this,
1342
+ C: (f, a) => f(...a)
1297
1343
  });
1298
1344
  await this._processEpoch(ctx, epoch.subject.assertion);
1299
1345
  this.appliedEpoch = epoch;
@@ -1307,20 +1353,20 @@ var DataPipeline = class DataPipeline2 {
1307
1353
  log8("Processing epoch", {
1308
1354
  epoch
1309
1355
  }, {
1310
- file: "data-pipeline.ts",
1311
- line: 327,
1312
- scope: this,
1313
- callSite: (f, a) => f(...a)
1356
+ F: __dxlog_file8,
1357
+ L: 333,
1358
+ S: this,
1359
+ C: (f, a) => f(...a)
1314
1360
  });
1315
1361
  if (epoch.snapshotCid) {
1316
1362
  const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1317
1363
  this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1318
1364
  }
1319
- log8("restarting pipeline for epoch", {}, {
1320
- file: "data-pipeline.ts",
1321
- line: 335,
1322
- scope: this,
1323
- callSite: (f, a) => f(...a)
1365
+ log8("restarting pipeline for epoch", void 0, {
1366
+ F: __dxlog_file8,
1367
+ L: 341,
1368
+ S: this,
1369
+ C: (f, a) => f(...a)
1324
1370
  });
1325
1371
  await this._pipeline.pause();
1326
1372
  await this._pipeline.setCursor(epoch.timeframe);
@@ -1349,19 +1395,19 @@ var DataPipeline = class DataPipeline2 {
1349
1395
  await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
1350
1396
  }
1351
1397
  };
1352
- __decorate5([
1398
+ _ts_decorate5([
1353
1399
  synchronized3
1354
1400
  ], DataPipeline.prototype, "open", null);
1355
- __decorate5([
1401
+ _ts_decorate5([
1356
1402
  synchronized3
1357
1403
  ], DataPipeline.prototype, "close", null);
1358
- __decorate5([
1404
+ _ts_decorate5([
1359
1405
  synchronized3
1360
1406
  ], DataPipeline.prototype, "_processEpoch", null);
1361
- __decorate5([
1407
+ _ts_decorate5([
1362
1408
  synchronized3
1363
1409
  ], DataPipeline.prototype, "createEpoch", null);
1364
- DataPipeline = __decorate5([
1410
+ DataPipeline = _ts_decorate5([
1365
1411
  trackLeaks2("open", "close")
1366
1412
  ], DataPipeline);
1367
1413
 
@@ -1379,6 +1425,7 @@ import { log as log9 } from "@dxos/log";
1379
1425
  import { AdmittedFeed } from "@dxos/protocols/proto/dxos/halo/credentials";
1380
1426
  import { Timeframe as Timeframe4 } from "@dxos/timeframe";
1381
1427
  import { Callback } from "@dxos/util";
1428
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1382
1429
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1383
1430
  var ControlPipeline = class {
1384
1431
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
@@ -1393,21 +1440,21 @@ var ControlPipeline = class {
1393
1440
  log9("feed admitted", {
1394
1441
  key: info.key
1395
1442
  }, {
1396
- file: "control-pipeline.ts",
1397
- line: 51,
1398
- scope: this,
1399
- callSite: (f, a) => f(...a)
1443
+ F: __dxlog_file9,
1444
+ L: 51,
1445
+ S: this,
1446
+ C: (f, a) => f(...a)
1400
1447
  });
1401
1448
  if (info.assertion.designation === AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
1402
1449
  try {
1403
1450
  const feed = await feedProvider(info.key);
1404
1451
  await this._pipeline.addFeed(feed);
1405
1452
  } catch (err) {
1406
- log9.catch(err, {}, {
1407
- file: "control-pipeline.ts",
1408
- line: 59,
1409
- scope: this,
1410
- callSite: (f, a) => f(...a)
1453
+ log9.catch(err, void 0, {
1454
+ F: __dxlog_file9,
1455
+ L: 59,
1456
+ S: this,
1457
+ C: (f, a) => f(...a)
1411
1458
  });
1412
1459
  }
1413
1460
  }
@@ -1426,11 +1473,11 @@ var ControlPipeline = class {
1426
1473
  this._pipeline.setWriteFeed(feed);
1427
1474
  }
1428
1475
  async start() {
1429
- log9("starting...", {}, {
1430
- file: "control-pipeline.ts",
1431
- line: 83,
1432
- scope: this,
1433
- callSite: (f, a) => f(...a)
1476
+ log9("starting...", void 0, {
1477
+ F: __dxlog_file9,
1478
+ L: 83,
1479
+ S: this,
1480
+ C: (f, a) => f(...a)
1434
1481
  });
1435
1482
  setTimeout(async () => {
1436
1483
  for await (const msg of this._pipeline.consume()) {
@@ -1439,10 +1486,10 @@ var ControlPipeline = class {
1439
1486
  key: msg.feedKey,
1440
1487
  seq: msg.seq
1441
1488
  }, {
1442
- file: "control-pipeline.ts",
1443
- line: 88,
1444
- scope: this,
1445
- callSite: (f, a) => f(...a)
1489
+ F: __dxlog_file9,
1490
+ L: 88,
1491
+ S: this,
1492
+ C: (f, a) => f(...a)
1446
1493
  });
1447
1494
  if (msg.data.payload.credential) {
1448
1495
  const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, PublicKey4.from(msg.feedKey));
@@ -1450,31 +1497,31 @@ var ControlPipeline = class {
1450
1497
  log9.warn("processing failed", {
1451
1498
  msg
1452
1499
  }, {
1453
- file: "control-pipeline.ts",
1454
- line: 95,
1455
- scope: this,
1456
- callSite: (f, a) => f(...a)
1500
+ F: __dxlog_file9,
1501
+ L: 95,
1502
+ S: this,
1503
+ C: (f, a) => f(...a)
1457
1504
  });
1458
1505
  } else {
1459
1506
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1460
1507
  }
1461
1508
  }
1462
1509
  } catch (err) {
1463
- log9.catch(err, {}, {
1464
- file: "control-pipeline.ts",
1465
- line: 101,
1466
- scope: this,
1467
- callSite: (f, a) => f(...a)
1510
+ log9.catch(err, void 0, {
1511
+ F: __dxlog_file9,
1512
+ L: 101,
1513
+ S: this,
1514
+ C: (f, a) => f(...a)
1468
1515
  });
1469
1516
  }
1470
1517
  }
1471
1518
  });
1472
1519
  await this._pipeline.start();
1473
- log9("started", {}, {
1474
- file: "control-pipeline.ts",
1475
- line: 107,
1476
- scope: this,
1477
- callSite: (f, a) => f(...a)
1520
+ log9("started", void 0, {
1521
+ F: __dxlog_file9,
1522
+ L: 107,
1523
+ S: this,
1524
+ C: (f, a) => f(...a)
1478
1525
  });
1479
1526
  }
1480
1527
  async _noteTargetStateIfNeeded(timeframe) {
@@ -1484,19 +1531,19 @@ var ControlPipeline = class {
1484
1531
  }
1485
1532
  }
1486
1533
  async stop() {
1487
- log9("stopping...", {}, {
1488
- file: "control-pipeline.ts",
1489
- line: 121,
1490
- scope: this,
1491
- callSite: (f, a) => f(...a)
1534
+ log9("stopping...", void 0, {
1535
+ F: __dxlog_file9,
1536
+ L: 121,
1537
+ S: this,
1538
+ C: (f, a) => f(...a)
1492
1539
  });
1493
1540
  await this._pipeline.stop();
1494
1541
  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)
1542
+ log9("stopped", void 0, {
1543
+ F: __dxlog_file9,
1544
+ L: 124,
1545
+ S: this,
1546
+ C: (f, a) => f(...a)
1500
1547
  });
1501
1548
  }
1502
1549
  async _saveTargetTimeframe(timeframe) {
@@ -1506,18 +1553,18 @@ var ControlPipeline = class {
1506
1553
  await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1507
1554
  this._targetTimeframe = newTimeframe;
1508
1555
  } catch (err) {
1509
- log9(err, {}, {
1510
- file: "control-pipeline.ts",
1511
- line: 133,
1512
- scope: this,
1513
- callSite: (f, a) => f(...a)
1556
+ log9(err, void 0, {
1557
+ F: __dxlog_file9,
1558
+ L: 133,
1559
+ S: this,
1560
+ C: (f, a) => f(...a)
1514
1561
  });
1515
1562
  }
1516
1563
  }
1517
1564
  };
1518
1565
 
1519
1566
  // packages/core/echo/echo-pipeline/src/space/space.ts
1520
- var __decorate6 = function(decorators, target, key, desc) {
1567
+ function _ts_decorate6(decorators, target, key, desc) {
1521
1568
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1522
1569
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1523
1570
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1526,14 +1573,13 @@ var __decorate6 = function(decorators, target, key, desc) {
1526
1573
  if (d = decorators[i])
1527
1574
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1528
1575
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1529
- };
1576
+ }
1577
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1530
1578
  var Space = class Space2 {
1531
1579
  constructor(params) {
1532
1580
  this._addFeedLock = new Lock();
1533
1581
  this.onCredentialProcessed = new Callback2();
1534
1582
  this.stateUpdate = new Event5();
1535
- // Processes epoch credentials.
1536
- this._dataPipelineCredentialConsumer = void 0;
1537
1583
  this._isOpen = false;
1538
1584
  invariant9(params.spaceKey && params.feedProvider);
1539
1585
  this._key = params.spaceKey;
@@ -1570,10 +1616,10 @@ var Space = class Space2 {
1570
1616
  log10("onCredentialProcessed", {
1571
1617
  credential
1572
1618
  }, {
1573
- file: "space.ts",
1574
- line: 110,
1575
- scope: this,
1576
- callSite: (f, a) => f(...a)
1619
+ F: __dxlog_file10,
1620
+ L: 107,
1621
+ S: this,
1622
+ C: (f, a) => f(...a)
1577
1623
  });
1578
1624
  this.stateUpdate.emit();
1579
1625
  });
@@ -1661,77 +1707,74 @@ var Space = class Space2 {
1661
1707
  // return this._dataPipeline?.getFeeds();
1662
1708
  // }
1663
1709
  async open() {
1664
- log10("opening...", {}, {
1665
- file: "space.ts",
1666
- line: 212,
1667
- scope: this,
1668
- callSite: (f, a) => f(...a)
1710
+ log10("opening...", void 0, {
1711
+ F: __dxlog_file10,
1712
+ L: 209,
1713
+ S: this,
1714
+ C: (f, a) => f(...a)
1669
1715
  });
1670
1716
  if (this._isOpen) {
1671
1717
  return;
1672
1718
  }
1673
1719
  await this._controlPipeline.start();
1674
1720
  await this.protocol.start();
1675
- this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1676
- await this._dataPipelineCredentialConsumer.open();
1721
+ await this._controlPipeline.spaceState.addCredentialProcessor(this._dataPipeline);
1677
1722
  this._isOpen = true;
1678
- log10("opened", {}, {
1679
- file: "space.ts",
1680
- line: 228,
1681
- scope: this,
1682
- callSite: (f, a) => f(...a)
1723
+ log10("opened", void 0, {
1724
+ F: __dxlog_file10,
1725
+ L: 220,
1726
+ S: this,
1727
+ C: (f, a) => f(...a)
1683
1728
  });
1684
1729
  }
1685
1730
  async close() {
1686
- var _a;
1687
1731
  log10("closing...", {
1688
1732
  key: this._key
1689
1733
  }, {
1690
- file: "space.ts",
1691
- line: 233,
1692
- scope: this,
1693
- callSite: (f, a) => f(...a)
1734
+ F: __dxlog_file10,
1735
+ L: 225,
1736
+ S: this,
1737
+ C: (f, a) => f(...a)
1694
1738
  });
1695
1739
  if (!this._isOpen) {
1696
1740
  return;
1697
1741
  }
1698
- await ((_a = this._dataPipelineCredentialConsumer) == null ? void 0 : _a.close());
1699
- this._dataPipelineCredentialConsumer = void 0;
1742
+ await this._controlPipeline.spaceState.removeCredentialProcessor(this._dataPipeline);
1700
1743
  await this._dataPipeline.close();
1701
1744
  await this.protocol.stop();
1702
1745
  await this._controlPipeline.stop();
1703
1746
  this._isOpen = false;
1704
- log10("closed", {}, {
1705
- file: "space.ts",
1706
- line: 247,
1707
- scope: this,
1708
- callSite: (f, a) => f(...a)
1747
+ log10("closed", void 0, {
1748
+ F: __dxlog_file10,
1749
+ L: 238,
1750
+ S: this,
1751
+ C: (f, a) => f(...a)
1709
1752
  });
1710
1753
  }
1711
1754
  async initializeDataPipeline() {
1712
- log10("initializeDataPipeline", {}, {
1713
- file: "space.ts",
1714
- line: 252,
1715
- scope: this,
1716
- callSite: (f, a) => f(...a)
1755
+ log10("initializeDataPipeline", void 0, {
1756
+ F: __dxlog_file10,
1757
+ L: 243,
1758
+ S: this,
1759
+ C: (f, a) => f(...a)
1717
1760
  });
1718
1761
  invariant9(this._isOpen, "Space must be open to initialize data pipeline.");
1719
1762
  await this._dataPipeline.open();
1720
1763
  }
1721
1764
  };
1722
- __decorate6([
1765
+ _ts_decorate6([
1723
1766
  logInfo
1724
1767
  ], Space.prototype, "key", null);
1725
- __decorate6([
1768
+ _ts_decorate6([
1726
1769
  synchronized4
1727
1770
  ], Space.prototype, "open", null);
1728
- __decorate6([
1771
+ _ts_decorate6([
1729
1772
  synchronized4
1730
1773
  ], Space.prototype, "close", null);
1731
- __decorate6([
1774
+ _ts_decorate6([
1732
1775
  synchronized4
1733
1776
  ], Space.prototype, "initializeDataPipeline", null);
1734
- Space = __decorate6([
1777
+ Space = _ts_decorate6([
1735
1778
  trackLeaks3("open", "close")
1736
1779
  ], Space);
1737
1780
 
@@ -1744,7 +1787,7 @@ import { Teleport } from "@dxos/teleport";
1744
1787
  import { BlobSync } from "@dxos/teleport-extension-object-sync";
1745
1788
  import { ReplicatorExtension } from "@dxos/teleport-extension-replicator";
1746
1789
  import { ComplexMap as ComplexMap4 } from "@dxos/util";
1747
- var __decorate7 = function(decorators, target, key, desc) {
1790
+ function _ts_decorate7(decorators, target, key, desc) {
1748
1791
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1749
1792
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1750
1793
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1753,7 +1796,8 @@ var __decorate7 = function(decorators, target, key, desc) {
1753
1796
  if (d = decorators[i])
1754
1797
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1755
1798
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1756
- };
1799
+ }
1800
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1757
1801
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1758
1802
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1759
1803
  var SpaceProtocol = class {
@@ -1783,10 +1827,10 @@ var SpaceProtocol = class {
1783
1827
  log11("addFeed", {
1784
1828
  key: feed.key
1785
1829
  }, {
1786
- file: "space-protocol.ts",
1787
- line: 96,
1788
- scope: this,
1789
- callSite: (f, a) => f(...a)
1830
+ F: __dxlog_file11,
1831
+ L: 96,
1832
+ S: this,
1833
+ C: (f, a) => f(...a)
1790
1834
  });
1791
1835
  this._feeds.add(feed);
1792
1836
  for (const session of this._sessions.values()) {
@@ -1804,11 +1848,11 @@ var SpaceProtocol = class {
1804
1848
  sampleSize: 20
1805
1849
  };
1806
1850
  await this.blobSync.open();
1807
- log11("starting...", {}, {
1808
- file: "space-protocol.ts",
1809
- line: 121,
1810
- scope: this,
1811
- callSite: (f, a) => f(...a)
1851
+ log11("starting...", void 0, {
1852
+ F: __dxlog_file11,
1853
+ L: 121,
1854
+ S: this,
1855
+ C: (f, a) => f(...a)
1812
1856
  });
1813
1857
  this._connection = await this._networkManager.joinSwarm({
1814
1858
  protocolProvider: this._createProtocolProvider(credentials),
@@ -1817,28 +1861,28 @@ var SpaceProtocol = class {
1817
1861
  topology: new MMSTTopology(topologyConfig),
1818
1862
  label: `Protocol swarm: ${this._topic}`
1819
1863
  });
1820
- log11("started", {}, {
1821
- file: "space-protocol.ts",
1822
- line: 130,
1823
- scope: this,
1824
- callSite: (f, a) => f(...a)
1864
+ log11("started", void 0, {
1865
+ F: __dxlog_file11,
1866
+ L: 130,
1867
+ S: this,
1868
+ C: (f, a) => f(...a)
1825
1869
  });
1826
1870
  }
1827
1871
  async stop() {
1828
1872
  await this.blobSync.close();
1829
1873
  if (this._connection) {
1830
- log11("stopping...", {}, {
1831
- file: "space-protocol.ts",
1832
- line: 137,
1833
- scope: this,
1834
- callSite: (f, a) => f(...a)
1874
+ log11("stopping...", void 0, {
1875
+ F: __dxlog_file11,
1876
+ L: 137,
1877
+ S: this,
1878
+ C: (f, a) => f(...a)
1835
1879
  });
1836
1880
  await this._connection.close();
1837
- log11("stopped", {}, {
1838
- file: "space-protocol.ts",
1839
- line: 139,
1840
- scope: this,
1841
- callSite: (f, a) => f(...a)
1881
+ log11("stopped", void 0, {
1882
+ F: __dxlog_file11,
1883
+ L: 139,
1884
+ S: this,
1885
+ C: (f, a) => f(...a)
1842
1886
  });
1843
1887
  }
1844
1888
  }
@@ -1859,10 +1903,10 @@ var SpaceProtocol = class {
1859
1903
  };
1860
1904
  }
1861
1905
  };
1862
- __decorate7([
1906
+ _ts_decorate7([
1863
1907
  logInfo2
1864
1908
  ], SpaceProtocol.prototype, "_topic", void 0);
1865
- __decorate7([
1909
+ _ts_decorate7([
1866
1910
  logInfo2
1867
1911
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
1868
1912
  var AuthStatus;
@@ -1902,11 +1946,11 @@ var SpaceProtocolSession = class {
1902
1946
  verifier: this._swarmIdentity.credentialAuthenticator,
1903
1947
  onAuthSuccess: () => {
1904
1948
  var _a;
1905
- log11("Peer authenticated", {}, {
1906
- file: "space-protocol.ts",
1907
- line: 236,
1908
- scope: this,
1909
- callSite: (f, a) => f(...a)
1949
+ log11("Peer authenticated", void 0, {
1950
+ F: __dxlog_file11,
1951
+ L: 236,
1952
+ S: this,
1953
+ C: (f, a) => f(...a)
1910
1954
  });
1911
1955
  this._authStatus = AuthStatus.SUCCESS;
1912
1956
  (_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
@@ -1924,10 +1968,10 @@ var SpaceProtocolSession = class {
1924
1968
  await this._teleport.close();
1925
1969
  }
1926
1970
  };
1927
- __decorate7([
1971
+ _ts_decorate7([
1928
1972
  logInfo2
1929
1973
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
1930
- __decorate7([
1974
+ _ts_decorate7([
1931
1975
  logInfo2
1932
1976
  ], SpaceProtocolSession.prototype, "authStatus", null);
1933
1977
 
@@ -1938,7 +1982,7 @@ import { PublicKey as PublicKey6 } from "@dxos/keys";
1938
1982
  import { log as log12 } from "@dxos/log";
1939
1983
  import { trace } from "@dxos/protocols";
1940
1984
  import { ComplexMap as ComplexMap5 } from "@dxos/util";
1941
- var __decorate8 = function(decorators, target, key, desc) {
1985
+ function _ts_decorate8(decorators, target, key, desc) {
1942
1986
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1943
1987
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1944
1988
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1947,7 +1991,8 @@ var __decorate8 = function(decorators, target, key, desc) {
1947
1991
  if (d = decorators[i])
1948
1992
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1949
1993
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1950
- };
1994
+ }
1995
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1951
1996
  var SpaceManager = class SpaceManager2 {
1952
1997
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
1953
1998
  this._spaces = new ComplexMap5(PublicKey6.hash);
@@ -1975,18 +2020,18 @@ var SpaceManager = class SpaceManager2 {
1975
2020
  log12.trace("dxos.echo.space-manager.construct-space", trace.begin({
1976
2021
  id: this._instanceId
1977
2022
  }), {
1978
- file: "space-manager.ts",
1979
- line: 97,
1980
- scope: this,
1981
- callSite: (f, a) => f(...a)
2023
+ F: __dxlog_file12,
2024
+ L: 97,
2025
+ S: this,
2026
+ C: (f, a) => f(...a)
1982
2027
  });
1983
2028
  log12("constructing space...", {
1984
2029
  spaceKey: metadata.genesisFeedKey
1985
2030
  }, {
1986
- file: "space-manager.ts",
1987
- line: 98,
1988
- scope: this,
1989
- callSite: (f, a) => f(...a)
2031
+ F: __dxlog_file12,
2032
+ L: 98,
2033
+ S: this,
2034
+ C: (f, a) => f(...a)
1990
2035
  });
1991
2036
  const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : failUndefined2());
1992
2037
  const spaceKey = metadata.key;
@@ -2013,21 +2058,21 @@ var SpaceManager = class SpaceManager2 {
2013
2058
  log12.trace("dxos.echo.space-manager.construct-space", trace.end({
2014
2059
  id: this._instanceId
2015
2060
  }), {
2016
- file: "space-manager.ts",
2017
- line: 125,
2018
- scope: this,
2019
- callSite: (f, a) => f(...a)
2061
+ F: __dxlog_file12,
2062
+ L: 125,
2063
+ S: this,
2064
+ C: (f, a) => f(...a)
2020
2065
  });
2021
2066
  return space;
2022
2067
  }
2023
2068
  };
2024
- __decorate8([
2069
+ _ts_decorate8([
2025
2070
  synchronized5
2026
2071
  ], SpaceManager.prototype, "open", null);
2027
- __decorate8([
2072
+ _ts_decorate8([
2028
2073
  synchronized5
2029
2074
  ], SpaceManager.prototype, "close", null);
2030
- SpaceManager = __decorate8([
2075
+ SpaceManager = _ts_decorate8([
2031
2076
  trackLeaks4("open", "close")
2032
2077
  ], SpaceManager);
2033
2078
 
@@ -2057,4 +2102,4 @@ export {
2057
2102
  SpaceProtocolSession,
2058
2103
  SpaceManager
2059
2104
  };
2060
- //# sourceMappingURL=chunk-ZYDZBSIT.mjs.map
2105
+ //# sourceMappingURL=chunk-OJGL5427.mjs.map