@dxos/echo-pipeline 0.1.52 → 0.1.53-main.00be1a9

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 (34) hide show
  1. package/dist/lib/browser/{chunk-AXGWKSM3.mjs → chunk-SCMKAWNW.mjs} +386 -366
  2. package/dist/lib/browser/chunk-SCMKAWNW.mjs.map +7 -0
  3. package/dist/lib/browser/index.mjs +2 -2
  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 +1 -1
  8. package/dist/lib/node/index.cjs +452 -432
  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 +436 -416
  12. package/dist/lib/node/testing/index.cjs.map +3 -3
  13. package/dist/types/src/dbhost/snapshot-store.d.ts +3 -0
  14. package/dist/types/src/dbhost/snapshot-store.d.ts.map +1 -1
  15. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  16. package/dist/types/src/pipeline/message-selector.d.ts.map +1 -1
  17. package/dist/types/src/space/data-pipeline.d.ts.map +1 -1
  18. package/dist/types/src/space/space-protocol.d.ts +3 -0
  19. package/dist/types/src/space/space-protocol.d.ts.map +1 -1
  20. package/package.json +31 -32
  21. package/src/common/feeds.ts +3 -3
  22. package/src/dbhost/data-service-host.ts +3 -3
  23. package/src/dbhost/data-service.ts +4 -4
  24. package/src/dbhost/snapshot-store.ts +3 -0
  25. package/src/metadata/metadata-store.ts +6 -5
  26. package/src/pipeline/message-selector.ts +3 -5
  27. package/src/pipeline/pipeline.ts +11 -11
  28. package/src/space/auth.ts +3 -3
  29. package/src/space/data-pipeline.ts +11 -10
  30. package/src/space/space-protocol.browser.test.ts +2 -2
  31. package/src/space/space-protocol.test.ts +2 -2
  32. package/src/space/space-protocol.ts +10 -4
  33. package/src/space/space.ts +5 -5
  34. package/dist/lib/browser/chunk-AXGWKSM3.mjs.map +0 -7
@@ -52,14 +52,15 @@ var import_credentials6 = require("@dxos/protocols/proto/dxos/halo/credentials")
52
52
  var import_random_access_storage = require("@dxos/random-access-storage");
53
53
  var import_teleport_extension_gossip = require("@dxos/teleport-extension-gossip");
54
54
  var import_teleport_extension_object_sync2 = require("@dxos/teleport-extension-object-sync");
55
- var import_util8 = require("@dxos/util");
55
+ var import_util9 = require("@dxos/util");
56
56
 
57
57
  // packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts
58
- var import_node_assert = __toESM(require("node:assert"));
58
+ var import_tiny_invariant = __toESM(require("tiny-invariant"));
59
59
  var import_codec_protobuf = require("@dxos/codec-protobuf");
60
60
  var import_echo_db = require("@dxos/echo-db");
61
61
  var import_log = require("@dxos/log");
62
62
  var import_util = require("@dxos/util");
63
+ var __dxlog_file = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service-host.ts";
63
64
  var DataServiceHost = class {
64
65
  constructor(_itemManager, _itemDemuxer, _writeStream) {
65
66
  this._itemManager = _itemManager;
@@ -81,15 +82,15 @@ var DataServiceHost = class {
81
82
  this._itemDemuxer.mutation.on(ctx, (message) => {
82
83
  var _a;
83
84
  const { batch, meta } = message;
84
- (0, import_node_assert.default)(!meta.clientTag, "Unexpected client tag in mutation message");
85
+ (0, import_tiny_invariant.default)(!meta.clientTag, "Unexpected client tag in mutation message");
85
86
  (0, import_log.log)("message", {
86
87
  batch,
87
88
  meta
88
89
  }, {
89
- file: "data-service-host.ts",
90
- line: 51,
91
- scope: this,
92
- callSite: (f, a) => f(...a)
90
+ F: __dxlog_file,
91
+ L: 51,
92
+ S: this,
93
+ C: (f, a) => f(...a)
93
94
  });
94
95
  const clientTag = this._clientTagMap.get([
95
96
  message.meta.feedKey,
@@ -114,15 +115,15 @@ var DataServiceHost = class {
114
115
  }
115
116
  async write(request) {
116
117
  var _a, _b;
117
- (0, import_node_assert.default)(this._writeStream, "Cannot write mutations in readonly mode");
118
+ (0, import_tiny_invariant.default)(this._writeStream, "Cannot write mutations in readonly mode");
118
119
  (0, import_log.log)("write", {
119
120
  clientTag: request.clientTag,
120
121
  objectCount: (_b = (_a = request.batch.objects) == null ? void 0 : _a.length) != null ? _b : 0
121
122
  }, {
122
- file: "data-service-host.ts",
123
- line: 79,
124
- scope: this,
125
- callSite: (f, a) => f(...a)
123
+ F: __dxlog_file,
124
+ L: 79,
125
+ S: this,
126
+ C: (f, a) => f(...a)
126
127
  });
127
128
  const message = createDataMessage(request.batch);
128
129
  const receipt = await this._writeStream.write(message, {
@@ -133,10 +134,10 @@ var DataServiceHost = class {
133
134
  feedKey: receipt2.feedKey,
134
135
  seq: receipt2.seq
135
136
  }, {
136
- file: "data-service-host.ts",
137
- line: 88,
138
- scope: this,
139
- callSite: (f, a) => f(...a)
137
+ F: __dxlog_file,
138
+ L: 88,
139
+ S: this,
140
+ C: (f, a) => f(...a)
140
141
  });
141
142
  this._clientTagMap.set([
142
143
  receipt2.feedKey,
@@ -206,7 +207,7 @@ var import_debug = require("@dxos/debug");
206
207
  var import_keys = require("@dxos/keys");
207
208
  var import_protocols = require("@dxos/protocols");
208
209
  var import_blob = require("@dxos/protocols/proto/dxos/echo/blob");
209
- var __decorate = function(decorators, target, key, desc) {
210
+ function _ts_decorate(decorators, target, key, desc) {
210
211
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
211
212
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
212
213
  r = Reflect.decorate(decorators, target, key, desc);
@@ -215,7 +216,7 @@ var __decorate = function(decorators, target, key, desc) {
215
216
  if (d = decorators[i])
216
217
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
217
218
  return c > 3 && r && Object.defineProperty(target, key, r), r;
218
- };
219
+ }
219
220
  var SnapshotManager = class SnapshotManager2 {
220
221
  // prettier-ignore
221
222
  constructor(_snapshotStore, _blobStore, _blobSync) {
@@ -246,10 +247,10 @@ var SnapshotManager = class SnapshotManager2 {
246
247
  return import_keys.PublicKey.from(id).toHex();
247
248
  }
248
249
  };
249
- __decorate([
250
+ _ts_decorate([
250
251
  (0, import_debug.timed)(1e4)
251
252
  ], SnapshotManager.prototype, "load", null);
252
- SnapshotManager = __decorate([
253
+ SnapshotManager = _ts_decorate([
253
254
  (0, import_async.trackLeaks)("open", "close")
254
255
  ], SnapshotManager);
255
256
 
@@ -299,11 +300,12 @@ var SnapshotStore = class {
299
300
  };
300
301
 
301
302
  // packages/core/echo/echo-pipeline/src/dbhost/data-service.ts
302
- var import_node_assert2 = __toESM(require("node:assert"));
303
+ var import_tiny_invariant2 = __toESM(require("tiny-invariant"));
303
304
  var import_debug2 = require("@dxos/debug");
304
305
  var import_keys2 = require("@dxos/keys");
305
306
  var import_log2 = require("@dxos/log");
306
307
  var import_util2 = require("@dxos/util");
308
+ var __dxlog_file2 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/dbhost/data-service.ts";
307
309
  var DataServiceSubscriptions = class {
308
310
  constructor() {
309
311
  this._spaces = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
@@ -315,10 +317,10 @@ var DataServiceSubscriptions = class {
315
317
  (0, import_log2.log)("Registering space", {
316
318
  spaceKey
317
319
  }, {
318
- file: "data-service.ts",
319
- line: 31,
320
- scope: this,
321
- callSite: (f, a) => f(...a)
320
+ F: __dxlog_file2,
321
+ L: 31,
322
+ S: this,
323
+ C: (f, a) => f(...a)
322
324
  });
323
325
  this._spaces.set(spaceKey, host);
324
326
  }
@@ -326,10 +328,10 @@ var DataServiceSubscriptions = class {
326
328
  (0, import_log2.log)("Unregistering space", {
327
329
  spaceKey
328
330
  }, {
329
- file: "data-service.ts",
330
- line: 36,
331
- scope: this,
332
- callSite: (f, a) => f(...a)
331
+ F: __dxlog_file2,
332
+ L: 36,
333
+ S: this,
334
+ C: (f, a) => f(...a)
333
335
  });
334
336
  this._spaces.delete(spaceKey);
335
337
  }
@@ -343,14 +345,14 @@ var DataServiceImpl = class {
343
345
  }
344
346
  subscribe(request) {
345
347
  var _a;
346
- (0, import_node_assert2.default)(request.spaceKey);
348
+ (0, import_tiny_invariant2.default)(request.spaceKey);
347
349
  const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : (0, import_debug2.raise)(new Error(`space not found: ${request.spaceKey}`));
348
350
  return host.subscribe();
349
351
  }
350
352
  write(request) {
351
353
  var _a;
352
- (0, import_node_assert2.default)(request.spaceKey);
353
- (0, import_node_assert2.default)(request.batch);
354
+ (0, import_tiny_invariant2.default)(request.spaceKey);
355
+ (0, import_tiny_invariant2.default)(request.batch);
354
356
  const host = (_a = this._subscriptions.getDataService(request.spaceKey)) != null ? _a : (0, import_debug2.raise)(new Error(`space not found: ${request.spaceKey}`));
355
357
  return host.write(request);
356
358
  }
@@ -358,12 +360,13 @@ var DataServiceImpl = class {
358
360
 
359
361
  // packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts
360
362
  var import_crc_32 = __toESM(require("crc-32"));
361
- var import_node_assert3 = __toESM(require("node:assert"));
363
+ var import_tiny_invariant3 = __toESM(require("tiny-invariant"));
362
364
  var import_async2 = require("@dxos/async");
363
365
  var import_errors = require("@dxos/errors");
364
366
  var import_log3 = require("@dxos/log");
365
367
  var import_protocols3 = require("@dxos/protocols");
366
- var __decorate2 = function(decorators, target, key, desc) {
368
+ var import_util3 = require("@dxos/util");
369
+ function _ts_decorate2(decorators, target, key, desc) {
367
370
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
368
371
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
369
372
  r = Reflect.decorate(decorators, target, key, desc);
@@ -372,7 +375,8 @@ var __decorate2 = function(decorators, target, key, desc) {
372
375
  if (d = decorators[i])
373
376
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
374
377
  return c > 3 && r && Object.defineProperty(target, key, r), r;
375
- };
378
+ }
379
+ var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/metadata/metadata-store.ts";
376
380
  var emptyEchoMetadata = () => ({
377
381
  version: import_protocols3.STORAGE_VERSION,
378
382
  spaces: [],
@@ -417,10 +421,10 @@ var MetadataStore = class {
417
421
  size: dataSize,
418
422
  checksum
419
423
  }, {
420
- file: "metadata-store.ts",
421
- line: 68,
422
- scope: this,
423
- callSite: (f, a) => f(...a)
424
+ F: __dxlog_file3,
425
+ L: 69,
426
+ S: this,
427
+ C: (f, a) => f(...a)
424
428
  });
425
429
  if (fileLength < dataSize + 8) {
426
430
  throw new import_errors.DataCorruptionError("Metadata size is smaller than expected.");
@@ -435,10 +439,10 @@ var MetadataStore = class {
435
439
  import_log3.log.error("failed to load metadata", {
436
440
  err
437
441
  }, {
438
- file: "metadata-store.ts",
439
- line: 83,
440
- scope: this,
441
- callSite: (f, a) => f(...a)
442
+ F: __dxlog_file3,
443
+ L: 84,
444
+ S: this,
445
+ C: (f, a) => f(...a)
442
446
  });
443
447
  this._metadata = emptyEchoMetadata();
444
448
  } finally {
@@ -456,7 +460,7 @@ var MetadataStore = class {
456
460
  this.update.emit(data);
457
461
  const file = this._directory.getOrCreateFile("EchoMetadata");
458
462
  try {
459
- const encoded = Buffer.from(import_protocols3.schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
463
+ const encoded = (0, import_util3.arrayToBuffer)(import_protocols3.schema.getCodecForType("dxos.echo.metadata.EchoMetadata").encode(data));
460
464
  const checksum = import_crc_32.default.buf(encoded);
461
465
  const result = Buffer.alloc(8 + encoded.length);
462
466
  result.writeInt32LE(encoded.length, 0);
@@ -467,10 +471,10 @@ var MetadataStore = class {
467
471
  size: encoded.length,
468
472
  checksum
469
473
  }, {
470
- file: "metadata-store.ts",
471
- line: 115,
472
- scope: this,
473
- callSite: (f, a) => f(...a)
474
+ F: __dxlog_file3,
475
+ L: 116,
476
+ S: this,
477
+ C: (f, a) => f(...a)
474
478
  });
475
479
  } finally {
476
480
  await file.close();
@@ -482,18 +486,18 @@ var MetadataStore = class {
482
486
  return this._metadata.identity.haloSpace;
483
487
  }
484
488
  const space = this.spaces.find((space2) => space2.key === spaceKey);
485
- (0, import_node_assert3.default)(space, "Space not found");
489
+ (0, import_tiny_invariant3.default)(space, "Space not found");
486
490
  return space;
487
491
  }
488
492
  /**
489
493
  * Clears storage - doesn't work for now.
490
494
  */
491
495
  async clear() {
492
- (0, import_log3.log)("clearing all metadata", {}, {
493
- file: "metadata-store.ts",
494
- line: 136,
495
- scope: this,
496
- callSite: (f, a) => f(...a)
496
+ (0, import_log3.log)("clearing all metadata", void 0, {
497
+ F: __dxlog_file3,
498
+ L: 137,
499
+ S: this,
500
+ C: (f, a) => f(...a)
497
501
  });
498
502
  await this._directory.delete();
499
503
  this._metadata = emptyEchoMetadata();
@@ -502,13 +506,13 @@ var MetadataStore = class {
502
506
  return this._metadata.identity;
503
507
  }
504
508
  async setIdentityRecord(record) {
505
- (0, import_node_assert3.default)(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
509
+ (0, import_tiny_invariant3.default)(!this._metadata.identity, "Cannot overwrite existing identity in metadata");
506
510
  this._metadata.identity = record;
507
511
  await this._save();
508
512
  }
509
513
  async addSpace(record) {
510
514
  var _a, _b, _c;
511
- (0, import_node_assert3.default)(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
515
+ (0, import_tiny_invariant3.default)(!((_a = this._metadata.spaces) != null ? _a : []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata");
512
516
  ((_c = (_b = this._metadata).spaces) != null ? _c : _b.spaces = []).push(record);
513
517
  await this._save();
514
518
  }
@@ -531,22 +535,23 @@ var MetadataStore = class {
531
535
  await this._save();
532
536
  }
533
537
  };
534
- __decorate2([
538
+ _ts_decorate2([
535
539
  import_async2.synchronized
536
540
  ], MetadataStore.prototype, "load", null);
537
- __decorate2([
541
+ _ts_decorate2([
538
542
  import_async2.synchronized
539
543
  ], MetadataStore.prototype, "_save", null);
540
544
  var fromBytesInt32 = (buf) => buf.readInt32LE(0);
541
545
 
542
546
  // packages/core/echo/echo-pipeline/src/space/auth.ts
543
- var import_node_assert4 = __toESM(require("node:assert"));
547
+ var import_tiny_invariant4 = __toESM(require("tiny-invariant"));
544
548
  var import_async3 = require("@dxos/async");
545
549
  var import_context2 = require("@dxos/context");
546
550
  var import_crypto2 = require("@dxos/crypto");
547
551
  var import_log4 = require("@dxos/log");
548
552
  var import_protocols4 = require("@dxos/protocols");
549
553
  var import_teleport = require("@dxos/teleport");
554
+ var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
550
555
  var AuthExtension = class extends import_teleport.RpcExtension {
551
556
  constructor(_authParams) {
552
557
  super({
@@ -561,11 +566,11 @@ var AuthExtension = class extends import_teleport.RpcExtension {
561
566
  this._authParams = _authParams;
562
567
  this._ctx = new import_context2.Context({
563
568
  onError: (err) => {
564
- import_log4.log.catch(err, {}, {
565
- file: "auth.ts",
566
- line: 29,
567
- scope: this,
568
- callSite: (f, a) => f(...a)
569
+ import_log4.log.catch(err, void 0, {
570
+ F: __dxlog_file4,
571
+ L: 29,
572
+ S: this,
573
+ C: (f, a) => f(...a)
569
574
  });
570
575
  }
571
576
  });
@@ -584,10 +589,10 @@ var AuthExtension = class extends import_teleport.RpcExtension {
584
589
  };
585
590
  } catch (err) {
586
591
  import_log4.log.error("failed to generate auth credentials", err, {
587
- file: "auth.ts",
588
- line: 56,
589
- scope: this,
590
- callSite: (f, a) => f(...a)
592
+ F: __dxlog_file4,
593
+ L: 56,
594
+ S: this,
595
+ C: (f, a) => f(...a)
591
596
  });
592
597
  throw new Error("auth rejected");
593
598
  }
@@ -603,16 +608,16 @@ var AuthExtension = class extends import_teleport.RpcExtension {
603
608
  const { credential } = await this.rpc.AuthService.authenticate({
604
609
  challenge
605
610
  });
606
- (0, import_node_assert4.default)((credential == null ? void 0 : credential.length) > 0, "invalid credential");
611
+ (0, import_tiny_invariant4.default)((credential == null ? void 0 : credential.length) > 0, "invalid credential");
607
612
  const success = await this._authParams.verifier(challenge, credential);
608
- (0, import_node_assert4.default)(success, "credential not verified");
613
+ (0, import_tiny_invariant4.default)(success, "credential not verified");
609
614
  (0, import_async3.runInContext)(this._ctx, () => this._authParams.onAuthSuccess());
610
615
  } catch (err) {
611
616
  (0, import_log4.log)("auth failed", err, {
612
- file: "auth.ts",
613
- line: 75,
614
- scope: this,
615
- callSite: (f, a) => f(...a)
617
+ F: __dxlog_file4,
618
+ L: 75,
619
+ S: this,
620
+ C: (f, a) => f(...a)
616
621
  });
617
622
  this.close();
618
623
  this._authParams.onAuthFailure();
@@ -626,30 +631,30 @@ var AuthExtension = class extends import_teleport.RpcExtension {
626
631
  };
627
632
 
628
633
  // packages/core/echo/echo-pipeline/src/space/space.ts
629
- var import_node_assert9 = __toESM(require("node:assert"));
634
+ var import_tiny_invariant9 = __toESM(require("tiny-invariant"));
630
635
  var import_async7 = require("@dxos/async");
631
- var import_log9 = require("@dxos/log");
636
+ var import_log10 = require("@dxos/log");
632
637
  var import_credentials4 = require("@dxos/protocols/proto/dxos/halo/credentials");
633
- var import_util5 = require("@dxos/util");
638
+ var import_util6 = require("@dxos/util");
634
639
 
635
640
  // packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
636
641
  var import_credentials = require("@dxos/credentials");
637
642
  var import_keys4 = require("@dxos/keys");
638
- var import_log7 = require("@dxos/log");
643
+ var import_log8 = require("@dxos/log");
639
644
  var import_credentials2 = require("@dxos/protocols/proto/dxos/halo/credentials");
640
645
  var import_timeframe3 = require("@dxos/timeframe");
641
- var import_util4 = require("@dxos/util");
646
+ var import_util5 = require("@dxos/util");
642
647
 
643
648
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
644
- var import_node_assert7 = __toESM(require("node:assert"));
649
+ var import_tiny_invariant7 = __toESM(require("tiny-invariant"));
645
650
  var import_async5 = require("@dxos/async");
646
651
  var import_context3 = require("@dxos/context");
647
- var import_debug5 = require("@dxos/debug");
652
+ var import_debug4 = require("@dxos/debug");
648
653
  var import_feed_store = require("@dxos/feed-store");
649
654
  var import_keys3 = require("@dxos/keys");
650
- var import_log6 = require("@dxos/log");
655
+ var import_log7 = require("@dxos/log");
651
656
  var import_timeframe2 = require("@dxos/timeframe");
652
- var import_util3 = require("@dxos/util");
657
+ var import_util4 = require("@dxos/util");
653
658
 
654
659
  // packages/core/echo/echo-pipeline/src/common/codec.ts
655
660
  var import_hypercore = require("@dxos/hypercore");
@@ -658,38 +663,43 @@ var codec = import_protocols5.schema.getCodecForType("dxos.echo.feed.FeedMessage
658
663
  var valueEncoding = (0, import_hypercore.createCodecEncoding)(codec);
659
664
 
660
665
  // packages/core/echo/echo-pipeline/src/common/feeds.ts
661
- var import_node_assert5 = __toESM(require("node:assert"));
666
+ var import_tiny_invariant5 = __toESM(require("tiny-invariant"));
662
667
  var createMappedFeedWriter = (mapper, writer) => {
663
- (0, import_node_assert5.default)(mapper);
664
- (0, import_node_assert5.default)(writer);
668
+ (0, import_tiny_invariant5.default)(mapper);
669
+ (0, import_tiny_invariant5.default)(writer);
665
670
  return {
666
671
  write: async (data, options) => await writer.write(await mapper(data), options)
667
672
  };
668
673
  };
669
674
 
670
675
  // packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts
671
- var import_debug3 = __toESM(require("debug"));
672
- var import_node_assert6 = __toESM(require("node:assert"));
673
- var log5 = (0, import_debug3.default)("dxos:echo-db:message-selector");
676
+ var import_tiny_invariant6 = __toESM(require("tiny-invariant"));
677
+ var import_log5 = require("@dxos/log");
678
+ var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/message-selector.ts";
674
679
  var createMessageSelector = (timeframeClock) => {
675
680
  return (messages) => {
676
681
  for (let i = 0; i < messages.length; i++) {
677
682
  const { data: { timeframe } } = messages[i];
678
- (0, import_node_assert6.default)(timeframe);
683
+ (0, import_tiny_invariant6.default)(timeframe);
679
684
  if (!timeframeClock.hasGaps(timeframe)) {
680
685
  return i;
681
686
  }
682
687
  }
683
- log5("Skipping...");
688
+ (0, import_log5.log)("Skipping...", void 0, {
689
+ F: __dxlog_file5,
690
+ L: 34,
691
+ S: void 0,
692
+ C: (f, a) => f(...a)
693
+ });
684
694
  };
685
695
  };
686
696
 
687
697
  // packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts
688
698
  var import_async4 = require("@dxos/async");
689
- var import_debug4 = require("@dxos/debug");
690
- var import_log5 = require("@dxos/log");
699
+ var import_debug3 = require("@dxos/debug");
700
+ var import_log6 = require("@dxos/log");
691
701
  var import_timeframe = require("@dxos/timeframe");
692
- var __decorate3 = function(decorators, target, key, desc) {
702
+ function _ts_decorate3(decorators, target, key, desc) {
693
703
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
694
704
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
695
705
  r = Reflect.decorate(decorators, target, key, desc);
@@ -698,7 +708,8 @@ var __decorate3 = function(decorators, target, key, desc) {
698
708
  if (d = decorators[i])
699
709
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
700
710
  return c > 3 && r && Object.defineProperty(target, key, r), r;
701
- };
711
+ }
712
+ var __dxlog_file6 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/timeframe-clock.ts";
702
713
  var mapFeedIndexesToTimeframe = (indexes) => new import_timeframe.Timeframe(indexes.map(({ feedKey, index }) => [
703
714
  feedKey,
704
715
  index
@@ -749,36 +760,36 @@ var TimeframeClock = class {
749
760
  return !gaps.isEmpty();
750
761
  }
751
762
  async waitUntilReached(target) {
752
- (0, import_log5.log)("waitUntilReached", {
763
+ (0, import_log6.log)("waitUntilReached", {
753
764
  target,
754
765
  current: this._timeframe
755
766
  }, {
756
- file: "timeframe-clock.ts",
757
- line: 73,
758
- scope: this,
759
- callSite: (f, a) => f(...a)
767
+ F: __dxlog_file6,
768
+ L: 73,
769
+ S: this,
770
+ C: (f, a) => f(...a)
760
771
  });
761
772
  await this.update.waitForCondition(() => {
762
- (0, import_log5.log)("check if reached", {
773
+ (0, import_log6.log)("check if reached", {
763
774
  target,
764
775
  current: this._timeframe,
765
776
  deps: import_timeframe.Timeframe.dependencies(target, this._timeframe)
766
777
  }, {
767
- file: "timeframe-clock.ts",
768
- line: 75,
769
- scope: this,
770
- callSite: (f, a) => f(...a)
778
+ F: __dxlog_file6,
779
+ L: 75,
780
+ S: this,
781
+ C: (f, a) => f(...a)
771
782
  });
772
783
  return import_timeframe.Timeframe.dependencies(target, this._timeframe).isEmpty();
773
784
  });
774
785
  }
775
786
  };
776
- __decorate3([
777
- (0, import_debug4.timed)(5e3)
787
+ _ts_decorate3([
788
+ (0, import_debug3.timed)(5e3)
778
789
  ], TimeframeClock.prototype, "waitUntilReached", null);
779
790
 
780
791
  // packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts
781
- var __decorate4 = function(decorators, target, key, desc) {
792
+ function _ts_decorate4(decorators, target, key, desc) {
782
793
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
783
794
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
784
795
  r = Reflect.decorate(decorators, target, key, desc);
@@ -787,7 +798,8 @@ var __decorate4 = function(decorators, target, key, desc) {
787
798
  if (d = decorators[i])
788
799
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
789
800
  return c > 3 && r && Object.defineProperty(target, key, r), r;
790
- };
801
+ }
802
+ var __dxlog_file7 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
791
803
  var PipelineState = class {
792
804
  // prettier-ignore
793
805
  constructor(_feeds, _timeframeClock) {
@@ -838,15 +850,15 @@ var PipelineState = class {
838
850
  */
839
851
  async waitUntilReachedTargetTimeframe({ ctx = new import_context3.Context(), timeout, breakOnStall = true } = {}) {
840
852
  var _a;
841
- (0, import_log6.log)("waitUntilReachedTargetTimeframe", {
853
+ (0, import_log7.log)("waitUntilReachedTargetTimeframe", {
842
854
  timeout,
843
855
  current: this.timeframe,
844
856
  target: this.targetTimeframe
845
857
  }, {
846
- file: "pipeline.ts",
847
- line: 118,
848
- scope: this,
849
- callSite: (f, a) => f(...a)
858
+ F: __dxlog_file7,
859
+ L: 118,
860
+ S: this,
861
+ C: (f, a) => f(...a)
850
862
  });
851
863
  (_a = this._reachedTargetPromise) != null ? _a : this._reachedTargetPromise = Promise.race([
852
864
  this._timeframeClock.update.waitForCondition(() => {
@@ -867,16 +879,16 @@ var PipelineState = class {
867
879
  if (done) {
868
880
  return;
869
881
  }
870
- import_log6.log.warn("waitUntilReachedTargetTimeframe timed out", {
882
+ import_log7.log.warn("waitUntilReachedTargetTimeframe timed out", {
871
883
  timeout,
872
884
  current: this.timeframe,
873
885
  target: this.targetTimeframe,
874
886
  dependencies: import_timeframe2.Timeframe.dependencies(this.targetTimeframe, this.timeframe)
875
887
  }, {
876
- file: "pipeline.ts",
877
- line: 144,
878
- scope: this,
879
- callSite: (f, a) => f(...a)
888
+ F: __dxlog_file7,
889
+ L: 144,
890
+ S: this,
891
+ C: (f, a) => f(...a)
880
892
  });
881
893
  })
882
894
  ]);
@@ -888,7 +900,7 @@ var PipelineState = class {
888
900
  var Pipeline = class {
889
901
  constructor() {
890
902
  this._timeframeClock = new TimeframeClock(new import_timeframe2.Timeframe());
891
- this._feeds = new import_util3.ComplexMap(import_keys3.PublicKey.hash);
903
+ this._feeds = new import_util4.ComplexMap(import_keys3.PublicKey.hash);
892
904
  // External state accessor.
893
905
  this._state = new PipelineState(this._feeds, this._timeframeClock);
894
906
  // Waits for the message consumer to process the message and yield control back to the pipeline.
@@ -903,7 +915,7 @@ var Pipeline = class {
903
915
  return this._state;
904
916
  }
905
917
  get writer() {
906
- (0, import_node_assert7.default)(this._writer, "Writer not set.");
918
+ (0, import_tiny_invariant7.default)(this._writer, "Writer not set.");
907
919
  return this._writer;
908
920
  }
909
921
  getFeeds() {
@@ -922,46 +934,46 @@ var Pipeline = class {
922
934
  return this._feeds.has(feedKey);
923
935
  }
924
936
  setWriteFeed(feed) {
925
- (0, import_node_assert7.default)(!this._writer, "Writer already set.");
926
- (0, import_node_assert7.default)(feed.properties.writable, "Feed must be writable.");
937
+ (0, import_tiny_invariant7.default)(!this._writer, "Writer already set.");
938
+ (0, import_tiny_invariant7.default)(feed.properties.writable, "Feed must be writable.");
927
939
  this._writer = createMappedFeedWriter((payload) => ({
928
940
  timeframe: this._timeframeClock.timeframe,
929
941
  payload
930
942
  }), feed.createFeedWriter());
931
943
  }
932
944
  async start() {
933
- (0, import_log6.log)("starting...", {}, {
934
- file: "pipeline.ts",
935
- line: 264,
936
- scope: this,
937
- callSite: (f, a) => f(...a)
945
+ (0, import_log7.log)("starting...", {}, {
946
+ F: __dxlog_file7,
947
+ L: 264,
948
+ S: this,
949
+ C: (f, a) => f(...a)
938
950
  });
939
951
  await this._initIterator();
940
952
  await this._feedSetIterator.open();
941
- (0, import_log6.log)("started", {}, {
942
- file: "pipeline.ts",
943
- line: 267,
944
- scope: this,
945
- callSite: (f, a) => f(...a)
953
+ (0, import_log7.log)("started", void 0, {
954
+ F: __dxlog_file7,
955
+ L: 267,
956
+ S: this,
957
+ C: (f, a) => f(...a)
946
958
  });
947
959
  this._isStarted = true;
948
960
  }
949
961
  async stop() {
950
962
  var _a;
951
- (0, import_log6.log)("stopping...", {}, {
952
- file: "pipeline.ts",
953
- line: 273,
954
- scope: this,
955
- callSite: (f, a) => f(...a)
963
+ (0, import_log7.log)("stopping...", {}, {
964
+ F: __dxlog_file7,
965
+ L: 273,
966
+ S: this,
967
+ C: (f, a) => f(...a)
956
968
  });
957
969
  this._isStopping = true;
958
970
  await ((_a = this._feedSetIterator) == null ? void 0 : _a.close());
959
971
  await this._processingTrigger.wait();
960
- (0, import_log6.log)("stopped", {}, {
961
- file: "pipeline.ts",
962
- line: 277,
963
- scope: this,
964
- callSite: (f, a) => f(...a)
972
+ (0, import_log7.log)("stopped", void 0, {
973
+ F: __dxlog_file7,
974
+ L: 277,
975
+ S: this,
976
+ C: (f, a) => f(...a)
965
977
  });
966
978
  this._isStarted = false;
967
979
  }
@@ -969,7 +981,7 @@ var Pipeline = class {
969
981
  * @param timeframe Timeframe of already processed messages. The pipeline will start processing messages AFTER this timeframe.
970
982
  */
971
983
  async setCursor(timeframe) {
972
- (0, import_node_assert7.default)(!this._isStarted || this._isPaused, "Invalid state.");
984
+ (0, import_tiny_invariant7.default)(!this._isStarted || this._isPaused, "Invalid state.");
973
985
  this._state._startTimeframe = timeframe;
974
986
  this._timeframeClock.setTimeframe(timeframe);
975
987
  for (const feed of this._feeds.values()) {
@@ -985,7 +997,7 @@ var Pipeline = class {
985
997
  * Calling pause while processing will cause a deadlock.
986
998
  */
987
999
  async pause() {
988
- (0, import_node_assert7.default)(this._isStarted, "Pipeline is not open.");
1000
+ (0, import_tiny_invariant7.default)(this._isStarted, "Pipeline is not open.");
989
1001
  if (this._isPaused) {
990
1002
  return;
991
1003
  }
@@ -994,8 +1006,8 @@ var Pipeline = class {
994
1006
  this._isPaused = true;
995
1007
  }
996
1008
  async unpause() {
997
- (0, import_node_assert7.default)(this._isStarted, "Pipeline is not open.");
998
- (0, import_node_assert7.default)(this._isPaused, "Pipeline is not paused.");
1009
+ (0, import_tiny_invariant7.default)(this._isStarted, "Pipeline is not open.");
1010
+ (0, import_tiny_invariant7.default)(this._isPaused, "Pipeline is not paused.");
999
1011
  this._pauseTrigger.wake();
1000
1012
  this._isPaused = false;
1001
1013
  }
@@ -1004,15 +1016,15 @@ var Pipeline = class {
1004
1016
  * Updates the timeframe clock after the message has bee processed.
1005
1017
  */
1006
1018
  async *consume() {
1007
- (0, import_node_assert7.default)(!this._isOpen, "Pipeline is already being consumed.");
1019
+ (0, import_tiny_invariant7.default)(!this._isOpen, "Pipeline is already being consumed.");
1008
1020
  this._isOpen = true;
1009
- (0, import_node_assert7.default)(this._feedSetIterator, "Iterator not initialized.");
1021
+ (0, import_tiny_invariant7.default)(this._feedSetIterator, "Iterator not initialized.");
1010
1022
  let lastFeedSetIterator = this._feedSetIterator;
1011
1023
  let iterable = lastFeedSetIterator[Symbol.asyncIterator]();
1012
1024
  while (!this._isStopping) {
1013
1025
  await this._pauseTrigger.wait();
1014
1026
  if (lastFeedSetIterator !== this._feedSetIterator) {
1015
- (0, import_node_assert7.default)(this._feedSetIterator, "Iterator not initialized.");
1027
+ (0, import_tiny_invariant7.default)(this._feedSetIterator, "Iterator not initialized.");
1016
1028
  lastFeedSetIterator = this._feedSetIterator;
1017
1029
  iterable = lastFeedSetIterator[Symbol.asyncIterator]();
1018
1030
  }
@@ -1020,7 +1032,7 @@ var Pipeline = class {
1020
1032
  if (done) {
1021
1033
  continue;
1022
1034
  }
1023
- const block = value != null ? value : (0, import_debug5.failUndefined)();
1035
+ const block = value != null ? value : (0, import_debug4.failUndefined)();
1024
1036
  this._processingTrigger.reset();
1025
1037
  this._timeframeClock.updatePendingTimeframe(import_keys3.PublicKey.from(block.feedKey), block.seq);
1026
1038
  yield block;
@@ -1034,24 +1046,24 @@ var Pipeline = class {
1034
1046
  const timeframe = this._state._startTimeframe;
1035
1047
  const seq = (_a = timeframe.get(feed.key)) != null ? _a : 0;
1036
1048
  feed.undownload({
1037
- callback: () => (0, import_log6.log)("Undownloaded", {}, {
1038
- file: "pipeline.ts",
1039
- line: 371,
1040
- scope: this,
1041
- callSite: (f, a) => f(...a)
1049
+ callback: () => (0, import_log7.log)("Undownloaded", void 0, {
1050
+ F: __dxlog_file7,
1051
+ L: 371,
1052
+ S: this,
1053
+ C: (f, a) => f(...a)
1042
1054
  })
1043
1055
  });
1044
1056
  feed.download({
1045
1057
  start: seq + 1,
1046
1058
  linear: true
1047
1059
  }).catch((err) => {
1048
- (0, import_log6.log)("failed to download feed", {
1060
+ (0, import_log7.log)("failed to download feed", {
1049
1061
  err
1050
1062
  }, {
1051
- file: "pipeline.ts",
1052
- line: 374,
1053
- scope: this,
1054
- callSite: (f, a) => f(...a)
1063
+ F: __dxlog_file7,
1064
+ L: 374,
1065
+ S: this,
1066
+ C: (f, a) => f(...a)
1055
1067
  });
1056
1068
  });
1057
1069
  }
@@ -1061,11 +1073,11 @@ var Pipeline = class {
1061
1073
  stallTimeout: 1e3
1062
1074
  });
1063
1075
  this._feedSetIterator.stalled.on((iterator) => {
1064
- import_log6.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, {}, {
1065
- file: "pipeline.ts",
1066
- line: 384,
1067
- scope: this,
1068
- callSite: (f, a) => f(...a)
1076
+ import_log7.log.warn(`Stalled after ${iterator.options.stallTimeout}ms with ${iterator.size} feeds.`, void 0, {
1077
+ F: __dxlog_file7,
1078
+ L: 384,
1079
+ S: this,
1080
+ C: (f, a) => f(...a)
1069
1081
  });
1070
1082
  this._state.stalled.emit();
1071
1083
  });
@@ -1074,52 +1086,53 @@ var Pipeline = class {
1074
1086
  }
1075
1087
  }
1076
1088
  };
1077
- __decorate4([
1089
+ _ts_decorate4([
1078
1090
  import_async5.synchronized
1079
1091
  ], Pipeline.prototype, "start", null);
1080
- __decorate4([
1092
+ _ts_decorate4([
1081
1093
  import_async5.synchronized
1082
1094
  ], Pipeline.prototype, "stop", null);
1083
- __decorate4([
1095
+ _ts_decorate4([
1084
1096
  import_async5.synchronized
1085
1097
  ], Pipeline.prototype, "setCursor", null);
1086
- __decorate4([
1098
+ _ts_decorate4([
1087
1099
  import_async5.synchronized
1088
1100
  ], Pipeline.prototype, "pause", null);
1089
- __decorate4([
1101
+ _ts_decorate4([
1090
1102
  import_async5.synchronized
1091
1103
  ], Pipeline.prototype, "unpause", null);
1092
1104
 
1093
1105
  // packages/core/echo/echo-pipeline/src/space/control-pipeline.ts
1106
+ var __dxlog_file8 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/control-pipeline.ts";
1094
1107
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1095
1108
  var ControlPipeline = class {
1096
1109
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
1097
1110
  this._lastTimeframeSaveTime = Date.now();
1098
- this.onFeedAdmitted = new import_util4.Callback();
1111
+ this.onFeedAdmitted = new import_util5.Callback();
1099
1112
  this._spaceKey = spaceKey;
1100
1113
  this._metadata = metadataStore;
1101
1114
  this._pipeline = new Pipeline();
1102
1115
  void this._pipeline.addFeed(genesisFeed);
1103
1116
  this._spaceStateMachine = new import_credentials.SpaceStateMachine(spaceKey);
1104
1117
  this._spaceStateMachine.onFeedAdmitted.set(async (info) => {
1105
- (0, import_log7.log)("feed admitted", {
1118
+ (0, import_log8.log)("feed admitted", {
1106
1119
  key: info.key
1107
1120
  }, {
1108
- file: "control-pipeline.ts",
1109
- line: 51,
1110
- scope: this,
1111
- callSite: (f, a) => f(...a)
1121
+ F: __dxlog_file8,
1122
+ L: 51,
1123
+ S: this,
1124
+ C: (f, a) => f(...a)
1112
1125
  });
1113
1126
  if (info.assertion.designation === import_credentials2.AdmittedFeed.Designation.CONTROL && !info.key.equals(genesisFeed.key)) {
1114
1127
  try {
1115
1128
  const feed = await feedProvider(info.key);
1116
1129
  await this._pipeline.addFeed(feed);
1117
1130
  } catch (err) {
1118
- import_log7.log.catch(err, {}, {
1119
- file: "control-pipeline.ts",
1120
- line: 59,
1121
- scope: this,
1122
- callSite: (f, a) => f(...a)
1131
+ import_log8.log.catch(err, void 0, {
1132
+ F: __dxlog_file8,
1133
+ L: 59,
1134
+ S: this,
1135
+ C: (f, a) => f(...a)
1123
1136
  });
1124
1137
  }
1125
1138
  }
@@ -1138,55 +1151,55 @@ var ControlPipeline = class {
1138
1151
  this._pipeline.setWriteFeed(feed);
1139
1152
  }
1140
1153
  async start() {
1141
- (0, import_log7.log)("starting...", {}, {
1142
- file: "control-pipeline.ts",
1143
- line: 83,
1144
- scope: this,
1145
- callSite: (f, a) => f(...a)
1154
+ (0, import_log8.log)("starting...", void 0, {
1155
+ F: __dxlog_file8,
1156
+ L: 83,
1157
+ S: this,
1158
+ C: (f, a) => f(...a)
1146
1159
  });
1147
1160
  setTimeout(async () => {
1148
1161
  for await (const msg of this._pipeline.consume()) {
1149
1162
  try {
1150
- (0, import_log7.log)("processing", {
1163
+ (0, import_log8.log)("processing", {
1151
1164
  key: msg.feedKey,
1152
1165
  seq: msg.seq
1153
1166
  }, {
1154
- file: "control-pipeline.ts",
1155
- line: 88,
1156
- scope: this,
1157
- callSite: (f, a) => f(...a)
1167
+ F: __dxlog_file8,
1168
+ L: 88,
1169
+ S: this,
1170
+ C: (f, a) => f(...a)
1158
1171
  });
1159
1172
  if (msg.data.payload.credential) {
1160
1173
  const result = await this._spaceStateMachine.process(msg.data.payload.credential.credential, import_keys4.PublicKey.from(msg.feedKey));
1161
1174
  if (!result) {
1162
- import_log7.log.warn("processing failed", {
1175
+ import_log8.log.warn("processing failed", {
1163
1176
  msg
1164
1177
  }, {
1165
- file: "control-pipeline.ts",
1166
- line: 95,
1167
- scope: this,
1168
- callSite: (f, a) => f(...a)
1178
+ F: __dxlog_file8,
1179
+ L: 95,
1180
+ S: this,
1181
+ C: (f, a) => f(...a)
1169
1182
  });
1170
1183
  } else {
1171
1184
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1172
1185
  }
1173
1186
  }
1174
1187
  } catch (err) {
1175
- import_log7.log.catch(err, {}, {
1176
- file: "control-pipeline.ts",
1177
- line: 101,
1178
- scope: this,
1179
- callSite: (f, a) => f(...a)
1188
+ import_log8.log.catch(err, void 0, {
1189
+ F: __dxlog_file8,
1190
+ L: 101,
1191
+ S: this,
1192
+ C: (f, a) => f(...a)
1180
1193
  });
1181
1194
  }
1182
1195
  }
1183
1196
  });
1184
1197
  await this._pipeline.start();
1185
- (0, import_log7.log)("started", {}, {
1186
- file: "control-pipeline.ts",
1187
- line: 107,
1188
- scope: this,
1189
- callSite: (f, a) => f(...a)
1198
+ (0, import_log8.log)("started", void 0, {
1199
+ F: __dxlog_file8,
1200
+ L: 107,
1201
+ S: this,
1202
+ C: (f, a) => f(...a)
1190
1203
  });
1191
1204
  }
1192
1205
  async _noteTargetStateIfNeeded(timeframe) {
@@ -1196,19 +1209,19 @@ var ControlPipeline = class {
1196
1209
  }
1197
1210
  }
1198
1211
  async stop() {
1199
- (0, import_log7.log)("stopping...", {}, {
1200
- file: "control-pipeline.ts",
1201
- line: 121,
1202
- scope: this,
1203
- callSite: (f, a) => f(...a)
1212
+ (0, import_log8.log)("stopping...", void 0, {
1213
+ F: __dxlog_file8,
1214
+ L: 121,
1215
+ S: this,
1216
+ C: (f, a) => f(...a)
1204
1217
  });
1205
1218
  await this._pipeline.stop();
1206
1219
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1207
- (0, import_log7.log)("stopped", {}, {
1208
- file: "control-pipeline.ts",
1209
- line: 124,
1210
- scope: this,
1211
- callSite: (f, a) => f(...a)
1220
+ (0, import_log8.log)("stopped", void 0, {
1221
+ F: __dxlog_file8,
1222
+ L: 124,
1223
+ S: this,
1224
+ C: (f, a) => f(...a)
1212
1225
  });
1213
1226
  }
1214
1227
  async _saveTargetTimeframe(timeframe) {
@@ -1218,26 +1231,26 @@ var ControlPipeline = class {
1218
1231
  await this._metadata.setSpaceControlLatestTimeframe(this._spaceKey, newTimeframe);
1219
1232
  this._targetTimeframe = newTimeframe;
1220
1233
  } catch (err) {
1221
- (0, import_log7.log)(err, {}, {
1222
- file: "control-pipeline.ts",
1223
- line: 133,
1224
- scope: this,
1225
- callSite: (f, a) => f(...a)
1234
+ (0, import_log8.log)(err, void 0, {
1235
+ F: __dxlog_file8,
1236
+ L: 133,
1237
+ S: this,
1238
+ C: (f, a) => f(...a)
1226
1239
  });
1227
1240
  }
1228
1241
  }
1229
1242
  };
1230
1243
 
1231
1244
  // packages/core/echo/echo-pipeline/src/space/data-pipeline.ts
1232
- var import_node_assert8 = __toESM(require("node:assert"));
1245
+ var import_tiny_invariant8 = __toESM(require("tiny-invariant"));
1233
1246
  var import_async6 = require("@dxos/async");
1234
1247
  var import_context4 = require("@dxos/context");
1235
1248
  var import_credentials3 = require("@dxos/credentials");
1236
1249
  var import_echo_db3 = require("@dxos/echo-db");
1237
1250
  var import_errors2 = require("@dxos/errors");
1238
- var import_log8 = require("@dxos/log");
1251
+ var import_log9 = require("@dxos/log");
1239
1252
  var import_timeframe4 = require("@dxos/timeframe");
1240
- var __decorate5 = function(decorators, target, key, desc) {
1253
+ function _ts_decorate5(decorators, target, key, desc) {
1241
1254
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1242
1255
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1243
1256
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1246,7 +1259,8 @@ var __decorate5 = function(decorators, target, key, desc) {
1246
1259
  if (d = decorators[i])
1247
1260
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1248
1261
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1249
- };
1262
+ }
1263
+ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/data-pipeline.ts";
1250
1264
  var MESSAGES_PER_SNAPSHOT = 10;
1251
1265
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1252
1266
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
@@ -1302,8 +1316,8 @@ var DataPipeline = class DataPipeline2 {
1302
1316
  }
1303
1317
  const feedWriter = {
1304
1318
  write: (data, options) => {
1305
- (0, import_node_assert8.default)(this._pipeline, "Pipeline is not initialized.");
1306
- (0, import_node_assert8.default)(this.currentEpoch, "Epoch is not initialized.");
1319
+ (0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
1320
+ (0, import_tiny_invariant8.default)(this.currentEpoch, "Epoch is not initialized.");
1307
1321
  return this._pipeline.writer.write({
1308
1322
  data
1309
1323
  }, options);
@@ -1322,11 +1336,11 @@ var DataPipeline = class DataPipeline2 {
1322
1336
  if (!this._isOpen) {
1323
1337
  return;
1324
1338
  }
1325
- (0, import_log8.log)("close", {}, {
1326
- file: "data-pipeline.ts",
1327
- line: 174,
1328
- scope: this,
1329
- callSite: (f, a) => f(...a)
1339
+ (0, import_log9.log)("close", void 0, {
1340
+ F: __dxlog_file9,
1341
+ L: 174,
1342
+ S: this,
1343
+ C: (f, a) => f(...a)
1330
1344
  });
1331
1345
  this._isOpen = false;
1332
1346
  await this._ctx.dispose();
@@ -1337,11 +1351,11 @@ var DataPipeline = class DataPipeline2 {
1337
1351
  await this._saveTargetTimeframe(this._pipeline.state.timeframe);
1338
1352
  }
1339
1353
  } catch (err) {
1340
- import_log8.log.catch(err, {}, {
1341
- file: "data-pipeline.ts",
1342
- line: 187,
1343
- scope: this,
1344
- callSite: (f, a) => f(...a)
1354
+ import_log9.log.catch(err, void 0, {
1355
+ F: __dxlog_file9,
1356
+ L: 187,
1357
+ S: this,
1358
+ C: (f, a) => f(...a)
1345
1359
  });
1346
1360
  }
1347
1361
  await ((_b = this.databaseHost) == null ? void 0 : _b.close());
@@ -1353,29 +1367,29 @@ var DataPipeline = class DataPipeline2 {
1353
1367
  await this._processEpochInSeparateTask(this.currentEpoch);
1354
1368
  await waitForOneEpoch;
1355
1369
  }
1356
- (0, import_node_assert8.default)(this._pipeline, "Pipeline is not initialized.");
1370
+ (0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
1357
1371
  for await (const msg of this._pipeline.consume()) {
1358
1372
  const { feedKey, seq, data } = msg;
1359
- (0, import_log8.log)("processing message", {
1373
+ (0, import_log9.log)("processing message", {
1360
1374
  feedKey,
1361
1375
  seq
1362
1376
  }, {
1363
- file: "data-pipeline.ts",
1364
- line: 204,
1365
- scope: this,
1366
- callSite: (f, a) => f(...a)
1377
+ F: __dxlog_file9,
1378
+ L: 204,
1379
+ S: this,
1380
+ C: (f, a) => f(...a)
1367
1381
  });
1368
1382
  try {
1369
1383
  if (data.payload.data) {
1370
1384
  const feedInfo = this._params.feedInfoProvider(feedKey);
1371
1385
  if (!feedInfo) {
1372
- import_log8.log.error("Could not find feed.", {
1386
+ import_log9.log.error("Could not find feed.", {
1373
1387
  feedKey
1374
1388
  }, {
1375
- file: "data-pipeline.ts",
1376
- line: 210,
1377
- scope: this,
1378
- callSite: (f, a) => f(...a)
1389
+ F: __dxlog_file9,
1390
+ L: 210,
1391
+ S: this,
1392
+ C: (f, a) => f(...a)
1379
1393
  });
1380
1394
  continue;
1381
1395
  }
@@ -1388,30 +1402,30 @@ var DataPipeline = class DataPipeline2 {
1388
1402
  memberKey: feedInfo.assertion.identityKey
1389
1403
  }
1390
1404
  });
1391
- import_log8.log.trace("dxos.echo.data-pipeline.processed", {
1405
+ import_log9.log.trace("dxos.echo.data-pipeline.processed", {
1392
1406
  feedKey: feedKey.toHex(),
1393
1407
  seq,
1394
1408
  spaceKey: this._params.spaceKey.toHex()
1395
1409
  }, {
1396
- file: "data-pipeline.ts",
1397
- line: 224,
1398
- scope: this,
1399
- callSite: (f, a) => f(...a)
1410
+ F: __dxlog_file9,
1411
+ L: 224,
1412
+ S: this,
1413
+ C: (f, a) => f(...a)
1400
1414
  });
1401
1415
  await this._noteTargetStateIfNeeded(this._pipeline.state.pendingTimeframe);
1402
1416
  }
1403
1417
  } catch (err) {
1404
- import_log8.log.catch(err, {}, {
1405
- file: "data-pipeline.ts",
1406
- line: 234,
1407
- scope: this,
1408
- callSite: (f, a) => f(...a)
1418
+ import_log9.log.catch(err, void 0, {
1419
+ F: __dxlog_file9,
1420
+ L: 234,
1421
+ S: this,
1422
+ C: (f, a) => f(...a)
1409
1423
  });
1410
1424
  }
1411
1425
  }
1412
1426
  }
1413
1427
  _createSnapshot() {
1414
- (0, import_node_assert8.default)(this.databaseHost, "Database backend is not initialized.");
1428
+ (0, import_tiny_invariant8.default)(this.databaseHost, "Database backend is not initialized.");
1415
1429
  return {
1416
1430
  spaceKey: this._params.spaceKey.asUint8Array(),
1417
1431
  timeframe: this._pipeline.state.timeframe,
@@ -1430,17 +1444,17 @@ var DataPipeline = class DataPipeline2 {
1430
1444
  try {
1431
1445
  const propertiesItem = this.itemManager.items.find((item) => {
1432
1446
  var _a2, _b;
1433
- return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = (0, import_echo_db3.getStateMachineFromItem)(item)) == null ? void 0 : _b.snapshot().type) === "dxos.sdk.client.Properties";
1447
+ return ((_a2 = item.modelMeta) == null ? void 0 : _a2.type) === "dxos:model/document" && ((_b = (0, import_echo_db3.getStateMachineFromItem)(item)) == null ? void 0 : _b.snapshot()).type === "dxos.sdk.client.Properties";
1434
1448
  });
1435
1449
  if (propertiesItem) {
1436
1450
  cache.properties = (_a = (0, import_echo_db3.getStateMachineFromItem)(propertiesItem)) == null ? void 0 : _a.snapshot();
1437
1451
  }
1438
1452
  } catch (err) {
1439
- import_log8.log.warn("Failed to cache properties", err, {
1440
- file: "data-pipeline.ts",
1441
- line: 268,
1442
- scope: this,
1443
- callSite: (f, a) => f(...a)
1453
+ import_log9.log.warn("Failed to cache properties", err, {
1454
+ F: __dxlog_file9,
1455
+ L: 269,
1456
+ S: this,
1457
+ C: (f, a) => f(...a)
1444
1458
  });
1445
1459
  }
1446
1460
  await this._params.metadataStore.setCache(this._params.spaceKey, cache);
@@ -1463,18 +1477,18 @@ var DataPipeline = class DataPipeline2 {
1463
1477
  const ctx = new import_context4.Context({
1464
1478
  onError: (err) => {
1465
1479
  if (err instanceof import_errors2.CancelledError) {
1466
- (0, import_log8.log)("Epoch processing cancelled.", {}, {
1467
- file: "data-pipeline.ts",
1468
- line: 300,
1469
- scope: this,
1470
- callSite: (f, a) => f(...a)
1480
+ (0, import_log9.log)("Epoch processing cancelled.", void 0, {
1481
+ F: __dxlog_file9,
1482
+ L: 301,
1483
+ S: this,
1484
+ C: (f, a) => f(...a)
1471
1485
  });
1472
1486
  } else {
1473
- import_log8.log.catch(err, {}, {
1474
- file: "data-pipeline.ts",
1475
- line: 302,
1476
- scope: this,
1477
- callSite: (f, a) => f(...a)
1487
+ import_log9.log.catch(err, void 0, {
1488
+ F: __dxlog_file9,
1489
+ L: 303,
1490
+ S: this,
1491
+ C: (f, a) => f(...a)
1478
1492
  });
1479
1493
  }
1480
1494
  }
@@ -1484,13 +1498,13 @@ var DataPipeline = class DataPipeline2 {
1484
1498
  if (!this._isOpen) {
1485
1499
  return;
1486
1500
  }
1487
- (0, import_log8.log)("process epoch", {
1501
+ (0, import_log9.log)("process epoch", {
1488
1502
  epoch
1489
1503
  }, {
1490
- file: "data-pipeline.ts",
1491
- line: 312,
1492
- scope: this,
1493
- callSite: (f, a) => f(...a)
1504
+ F: __dxlog_file9,
1505
+ L: 313,
1506
+ S: this,
1507
+ C: (f, a) => f(...a)
1494
1508
  });
1495
1509
  await this._processEpoch(ctx, epoch.subject.assertion);
1496
1510
  this.appliedEpoch = epoch;
@@ -1498,38 +1512,38 @@ var DataPipeline = class DataPipeline2 {
1498
1512
  });
1499
1513
  }
1500
1514
  async _processEpoch(ctx, epoch) {
1501
- (0, import_node_assert8.default)(this._isOpen, "Space is closed.");
1502
- (0, import_node_assert8.default)(this._pipeline);
1515
+ (0, import_tiny_invariant8.default)(this._isOpen, "Space is closed.");
1516
+ (0, import_tiny_invariant8.default)(this._pipeline);
1503
1517
  this._lastProcessedEpoch = epoch.number;
1504
- (0, import_log8.log)("Processing epoch", {
1518
+ (0, import_log9.log)("Processing epoch", {
1505
1519
  epoch
1506
1520
  }, {
1507
- file: "data-pipeline.ts",
1508
- line: 326,
1509
- scope: this,
1510
- callSite: (f, a) => f(...a)
1521
+ F: __dxlog_file9,
1522
+ L: 327,
1523
+ S: this,
1524
+ C: (f, a) => f(...a)
1511
1525
  });
1512
1526
  if (epoch.snapshotCid) {
1513
1527
  const snapshot = await this._params.snapshotManager.load(ctx, epoch.snapshotCid);
1514
1528
  this.databaseHost._itemDemuxer.restoreFromSnapshot(snapshot.database);
1515
1529
  }
1516
- (0, import_log8.log)("restarting pipeline for epoch", {}, {
1517
- file: "data-pipeline.ts",
1518
- line: 334,
1519
- scope: this,
1520
- callSite: (f, a) => f(...a)
1530
+ (0, import_log9.log)("restarting pipeline for epoch", void 0, {
1531
+ F: __dxlog_file9,
1532
+ L: 335,
1533
+ S: this,
1534
+ C: (f, a) => f(...a)
1521
1535
  });
1522
1536
  await this._pipeline.pause();
1523
1537
  await this._pipeline.setCursor(epoch.timeframe);
1524
1538
  await this._pipeline.unpause();
1525
1539
  }
1526
1540
  async waitUntilTimeframe(timeframe) {
1527
- (0, import_node_assert8.default)(this._pipeline, "Pipeline is not initialized.");
1541
+ (0, import_tiny_invariant8.default)(this._pipeline, "Pipeline is not initialized.");
1528
1542
  await this._pipeline.state.waitUntilTimeframe(timeframe);
1529
1543
  }
1530
1544
  async createEpoch() {
1531
- (0, import_node_assert8.default)(this._pipeline);
1532
- (0, import_node_assert8.default)(this.currentEpoch);
1545
+ (0, import_tiny_invariant8.default)(this._pipeline);
1546
+ (0, import_tiny_invariant8.default)(this.currentEpoch);
1533
1547
  await this._pipeline.pause();
1534
1548
  const snapshot = await this._createSnapshot();
1535
1549
  const snapshotCid = await this._params.snapshotManager.store(snapshot);
@@ -1546,24 +1560,24 @@ var DataPipeline = class DataPipeline2 {
1546
1560
  await this.onNewEpoch.waitForCondition(() => !!this.currentEpoch);
1547
1561
  }
1548
1562
  };
1549
- __decorate5([
1563
+ _ts_decorate5([
1550
1564
  import_async6.synchronized
1551
1565
  ], DataPipeline.prototype, "open", null);
1552
- __decorate5([
1566
+ _ts_decorate5([
1553
1567
  import_async6.synchronized
1554
1568
  ], DataPipeline.prototype, "close", null);
1555
- __decorate5([
1569
+ _ts_decorate5([
1556
1570
  import_async6.synchronized
1557
1571
  ], DataPipeline.prototype, "_processEpoch", null);
1558
- __decorate5([
1572
+ _ts_decorate5([
1559
1573
  import_async6.synchronized
1560
1574
  ], DataPipeline.prototype, "createEpoch", null);
1561
- DataPipeline = __decorate5([
1575
+ DataPipeline = _ts_decorate5([
1562
1576
  (0, import_async6.trackLeaks)("open", "close")
1563
1577
  ], DataPipeline);
1564
1578
 
1565
1579
  // packages/core/echo/echo-pipeline/src/space/space.ts
1566
- var __decorate6 = function(decorators, target, key, desc) {
1580
+ function _ts_decorate6(decorators, target, key, desc) {
1567
1581
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1568
1582
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1569
1583
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1572,16 +1586,17 @@ var __decorate6 = function(decorators, target, key, desc) {
1572
1586
  if (d = decorators[i])
1573
1587
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1574
1588
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1575
- };
1589
+ }
1590
+ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1576
1591
  var Space = class Space2 {
1577
1592
  constructor(params) {
1578
1593
  this._addFeedLock = new import_async7.Lock();
1579
- this.onCredentialProcessed = new import_util5.Callback();
1594
+ this.onCredentialProcessed = new import_util6.Callback();
1580
1595
  this.stateUpdate = new import_async7.Event();
1581
1596
  // Processes epoch credentials.
1582
1597
  this._dataPipelineCredentialConsumer = void 0;
1583
1598
  this._isOpen = false;
1584
- (0, import_node_assert9.default)(params.spaceKey && params.feedProvider);
1599
+ (0, import_tiny_invariant9.default)(params.spaceKey && params.feedProvider);
1585
1600
  this._key = params.spaceKey;
1586
1601
  this._genesisFeedKey = params.genesisFeed.key;
1587
1602
  this._feedProvider = params.feedProvider;
@@ -1613,13 +1628,13 @@ var Space = class Space2 {
1613
1628
  });
1614
1629
  this._controlPipeline.onCredentialProcessed.set(async (credential) => {
1615
1630
  await this.onCredentialProcessed.callIfSet(credential);
1616
- (0, import_log9.log)("onCredentialProcessed", {
1631
+ (0, import_log10.log)("onCredentialProcessed", {
1617
1632
  credential
1618
1633
  }, {
1619
- file: "space.ts",
1620
- line: 110,
1621
- scope: this,
1622
- callSite: (f, a) => f(...a)
1634
+ F: __dxlog_file10,
1635
+ L: 110,
1636
+ S: this,
1637
+ C: (f, a) => f(...a)
1623
1638
  });
1624
1639
  this.stateUpdate.emit();
1625
1640
  });
@@ -1682,14 +1697,14 @@ var Space = class Space2 {
1682
1697
  return this._snapshotManager;
1683
1698
  }
1684
1699
  setControlFeed(feed) {
1685
- (0, import_node_assert9.default)(!this._controlFeed, "Control feed already set.");
1700
+ (0, import_tiny_invariant9.default)(!this._controlFeed, "Control feed already set.");
1686
1701
  this._controlFeed = feed;
1687
1702
  this._controlPipeline.setWriteFeed(feed);
1688
1703
  return this;
1689
1704
  }
1690
1705
  setDataFeed(feed) {
1691
1706
  var _a;
1692
- (0, import_node_assert9.default)(!this._dataFeed, "Data feed already set.");
1707
+ (0, import_tiny_invariant9.default)(!this._dataFeed, "Data feed already set.");
1693
1708
  this._dataFeed = feed;
1694
1709
  (_a = this._dataPipeline.pipeline) == null ? void 0 : _a.setWriteFeed(feed);
1695
1710
  return this;
@@ -1707,11 +1722,11 @@ var Space = class Space2 {
1707
1722
  // return this._dataPipeline?.getFeeds();
1708
1723
  // }
1709
1724
  async open() {
1710
- (0, import_log9.log)("opening...", {}, {
1711
- file: "space.ts",
1712
- line: 212,
1713
- scope: this,
1714
- callSite: (f, a) => f(...a)
1725
+ (0, import_log10.log)("opening...", void 0, {
1726
+ F: __dxlog_file10,
1727
+ L: 212,
1728
+ S: this,
1729
+ C: (f, a) => f(...a)
1715
1730
  });
1716
1731
  if (this._isOpen) {
1717
1732
  return;
@@ -1721,22 +1736,22 @@ var Space = class Space2 {
1721
1736
  this._dataPipelineCredentialConsumer = this._controlPipeline.spaceState.registerProcessor(this._dataPipeline.createCredentialProcessor());
1722
1737
  await this._dataPipelineCredentialConsumer.open();
1723
1738
  this._isOpen = true;
1724
- (0, import_log9.log)("opened", {}, {
1725
- file: "space.ts",
1726
- line: 228,
1727
- scope: this,
1728
- callSite: (f, a) => f(...a)
1739
+ (0, import_log10.log)("opened", void 0, {
1740
+ F: __dxlog_file10,
1741
+ L: 228,
1742
+ S: this,
1743
+ C: (f, a) => f(...a)
1729
1744
  });
1730
1745
  }
1731
1746
  async close() {
1732
1747
  var _a;
1733
- (0, import_log9.log)("closing...", {
1748
+ (0, import_log10.log)("closing...", {
1734
1749
  key: this._key
1735
1750
  }, {
1736
- file: "space.ts",
1737
- line: 233,
1738
- scope: this,
1739
- callSite: (f, a) => f(...a)
1751
+ F: __dxlog_file10,
1752
+ L: 233,
1753
+ S: this,
1754
+ C: (f, a) => f(...a)
1740
1755
  });
1741
1756
  if (!this._isOpen) {
1742
1757
  return;
@@ -1747,58 +1762,58 @@ var Space = class Space2 {
1747
1762
  await this.protocol.stop();
1748
1763
  await this._controlPipeline.stop();
1749
1764
  this._isOpen = false;
1750
- (0, import_log9.log)("closed", {}, {
1751
- file: "space.ts",
1752
- line: 247,
1753
- scope: this,
1754
- callSite: (f, a) => f(...a)
1765
+ (0, import_log10.log)("closed", void 0, {
1766
+ F: __dxlog_file10,
1767
+ L: 247,
1768
+ S: this,
1769
+ C: (f, a) => f(...a)
1755
1770
  });
1756
1771
  }
1757
1772
  async initializeDataPipeline() {
1758
- (0, import_log9.log)("initializeDataPipeline", {}, {
1759
- file: "space.ts",
1760
- line: 252,
1761
- scope: this,
1762
- callSite: (f, a) => f(...a)
1773
+ (0, import_log10.log)("initializeDataPipeline", void 0, {
1774
+ F: __dxlog_file10,
1775
+ L: 252,
1776
+ S: this,
1777
+ C: (f, a) => f(...a)
1763
1778
  });
1764
- (0, import_node_assert9.default)(this._isOpen, "Space must be open to initialize data pipeline.");
1779
+ (0, import_tiny_invariant9.default)(this._isOpen, "Space must be open to initialize data pipeline.");
1765
1780
  await this._dataPipeline.open();
1766
1781
  }
1767
1782
  };
1768
- __decorate6([
1769
- import_log9.logInfo
1783
+ _ts_decorate6([
1784
+ import_log10.logInfo
1770
1785
  ], Space.prototype, "key", null);
1771
- __decorate6([
1786
+ _ts_decorate6([
1772
1787
  import_async7.synchronized
1773
1788
  ], Space.prototype, "open", null);
1774
- __decorate6([
1789
+ _ts_decorate6([
1775
1790
  import_async7.synchronized
1776
1791
  ], Space.prototype, "close", null);
1777
- __decorate6([
1792
+ _ts_decorate6([
1778
1793
  import_async7.synchronized
1779
1794
  ], Space.prototype, "initializeDataPipeline", null);
1780
- Space = __decorate6([
1795
+ Space = _ts_decorate6([
1781
1796
  (0, import_async7.trackLeaks)("open", "close")
1782
1797
  ], Space);
1783
1798
 
1784
1799
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
1785
1800
  var import_async8 = require("@dxos/async");
1786
- var import_debug6 = require("@dxos/debug");
1801
+ var import_debug5 = require("@dxos/debug");
1787
1802
  var import_keys6 = require("@dxos/keys");
1788
- var import_log11 = require("@dxos/log");
1803
+ var import_log12 = require("@dxos/log");
1789
1804
  var import_protocols6 = require("@dxos/protocols");
1790
- var import_util7 = require("@dxos/util");
1805
+ var import_util8 = require("@dxos/util");
1791
1806
 
1792
1807
  // packages/core/echo/echo-pipeline/src/space/space-protocol.ts
1793
1808
  var import_crypto3 = require("@dxos/crypto");
1794
1809
  var import_keys5 = require("@dxos/keys");
1795
- var import_log10 = require("@dxos/log");
1810
+ var import_log11 = require("@dxos/log");
1796
1811
  var import_network_manager = require("@dxos/network-manager");
1797
1812
  var import_teleport2 = require("@dxos/teleport");
1798
1813
  var import_teleport_extension_object_sync = require("@dxos/teleport-extension-object-sync");
1799
1814
  var import_teleport_extension_replicator = require("@dxos/teleport-extension-replicator");
1800
- var import_util6 = require("@dxos/util");
1801
- var __decorate7 = function(decorators, target, key, desc) {
1815
+ var import_util7 = require("@dxos/util");
1816
+ function _ts_decorate7(decorators, target, key, desc) {
1802
1817
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1803
1818
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1804
1819
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1807,13 +1822,14 @@ var __decorate7 = function(decorators, target, key, desc) {
1807
1822
  if (d = decorators[i])
1808
1823
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1809
1824
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1810
- };
1825
+ }
1826
+ var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-protocol.ts";
1811
1827
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1812
1828
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1813
1829
  var SpaceProtocol = class {
1814
1830
  constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore }) {
1815
1831
  this._feeds = /* @__PURE__ */ new Set();
1816
- this._sessions = new import_util6.ComplexMap(import_keys5.PublicKey.hash);
1832
+ this._sessions = new import_util7.ComplexMap(import_keys5.PublicKey.hash);
1817
1833
  this._networkManager = networkManager;
1818
1834
  this._swarmIdentity = swarmIdentity;
1819
1835
  this._onSessionAuth = onSessionAuth;
@@ -1821,7 +1837,7 @@ var SpaceProtocol = class {
1821
1837
  this.blobSync = new import_teleport_extension_object_sync.BlobSync({
1822
1838
  blobStore
1823
1839
  });
1824
- this._topic = import_keys5.PublicKey.from((0, import_crypto3.discoveryKey)((0, import_crypto3.sha256)(topic.toHex())));
1840
+ this._topic = import_crypto3.subtleCrypto.digest("SHA-256", topic.asBuffer()).then(import_crypto3.discoveryKey).then(import_keys5.PublicKey.from);
1825
1841
  }
1826
1842
  get sessions() {
1827
1843
  return this._sessions;
@@ -1834,13 +1850,13 @@ var SpaceProtocol = class {
1834
1850
  }
1835
1851
  // TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
1836
1852
  addFeed(feed) {
1837
- (0, import_log10.log)("addFeed", {
1853
+ (0, import_log11.log)("addFeed", {
1838
1854
  key: feed.key
1839
1855
  }, {
1840
- file: "space-protocol.ts",
1841
- line: 94,
1842
- scope: this,
1843
- callSite: (f, a) => f(...a)
1856
+ F: __dxlog_file11,
1857
+ L: 96,
1858
+ S: this,
1859
+ C: (f, a) => f(...a)
1844
1860
  });
1845
1861
  this._feeds.add(feed);
1846
1862
  for (const session of this._sessions.values()) {
@@ -1858,41 +1874,41 @@ var SpaceProtocol = class {
1858
1874
  sampleSize: 20
1859
1875
  };
1860
1876
  await this.blobSync.open();
1861
- (0, import_log10.log)("starting...", {}, {
1862
- file: "space-protocol.ts",
1863
- line: 119,
1864
- scope: this,
1865
- callSite: (f, a) => f(...a)
1877
+ (0, import_log11.log)("starting...", void 0, {
1878
+ F: __dxlog_file11,
1879
+ L: 121,
1880
+ S: this,
1881
+ C: (f, a) => f(...a)
1866
1882
  });
1867
1883
  this._connection = await this._networkManager.joinSwarm({
1868
1884
  protocolProvider: this._createProtocolProvider(credentials),
1869
1885
  peerId: this._swarmIdentity.peerKey,
1870
- topic: this._topic,
1886
+ topic: await this._topic,
1871
1887
  topology: new import_network_manager.MMSTTopology(topologyConfig),
1872
1888
  label: `Protocol swarm: ${this._topic}`
1873
1889
  });
1874
- (0, import_log10.log)("started", {}, {
1875
- file: "space-protocol.ts",
1876
- line: 128,
1877
- scope: this,
1878
- callSite: (f, a) => f(...a)
1890
+ (0, import_log11.log)("started", void 0, {
1891
+ F: __dxlog_file11,
1892
+ L: 130,
1893
+ S: this,
1894
+ C: (f, a) => f(...a)
1879
1895
  });
1880
1896
  }
1881
1897
  async stop() {
1882
1898
  await this.blobSync.close();
1883
1899
  if (this._connection) {
1884
- (0, import_log10.log)("stopping...", {}, {
1885
- file: "space-protocol.ts",
1886
- line: 135,
1887
- scope: this,
1888
- callSite: (f, a) => f(...a)
1900
+ (0, import_log11.log)("stopping...", void 0, {
1901
+ F: __dxlog_file11,
1902
+ L: 137,
1903
+ S: this,
1904
+ C: (f, a) => f(...a)
1889
1905
  });
1890
1906
  await this._connection.close();
1891
- (0, import_log10.log)("stopped", {}, {
1892
- file: "space-protocol.ts",
1893
- line: 137,
1894
- scope: this,
1895
- callSite: (f, a) => f(...a)
1907
+ (0, import_log11.log)("stopped", void 0, {
1908
+ F: __dxlog_file11,
1909
+ L: 139,
1910
+ S: this,
1911
+ C: (f, a) => f(...a)
1896
1912
  });
1897
1913
  }
1898
1914
  }
@@ -1913,11 +1929,11 @@ var SpaceProtocol = class {
1913
1929
  };
1914
1930
  }
1915
1931
  };
1916
- __decorate7([
1917
- import_log10.logInfo
1932
+ _ts_decorate7([
1933
+ import_log11.logInfo
1918
1934
  ], SpaceProtocol.prototype, "_topic", void 0);
1919
- __decorate7([
1920
- import_log10.logInfo
1935
+ _ts_decorate7([
1936
+ import_log11.logInfo
1921
1937
  ], SpaceProtocol.prototype, "_ownPeerKey", null);
1922
1938
  var AuthStatus;
1923
1939
  (function(AuthStatus2) {
@@ -1943,6 +1959,9 @@ var SpaceProtocolSession = class {
1943
1959
  get authStatus() {
1944
1960
  return this._authStatus;
1945
1961
  }
1962
+ get stats() {
1963
+ return this._teleport.stats;
1964
+ }
1946
1965
  get stream() {
1947
1966
  return this._teleport.stream;
1948
1967
  }
@@ -1953,11 +1972,11 @@ var SpaceProtocolSession = class {
1953
1972
  verifier: this._swarmIdentity.credentialAuthenticator,
1954
1973
  onAuthSuccess: () => {
1955
1974
  var _a;
1956
- (0, import_log10.log)("Peer authenticated", {}, {
1957
- file: "space-protocol.ts",
1958
- line: 230,
1959
- scope: this,
1960
- callSite: (f, a) => f(...a)
1975
+ (0, import_log11.log)("Peer authenticated", void 0, {
1976
+ F: __dxlog_file11,
1977
+ L: 236,
1978
+ S: this,
1979
+ C: (f, a) => f(...a)
1961
1980
  });
1962
1981
  this._authStatus = AuthStatus.SUCCESS;
1963
1982
  (_a = this._onSessionAuth) == null ? void 0 : _a.call(this, this._teleport);
@@ -1975,15 +1994,15 @@ var SpaceProtocolSession = class {
1975
1994
  await this._teleport.close();
1976
1995
  }
1977
1996
  };
1978
- __decorate7([
1979
- import_log10.logInfo
1997
+ _ts_decorate7([
1998
+ import_log11.logInfo
1980
1999
  ], SpaceProtocolSession.prototype, "_wireParams", void 0);
1981
- __decorate7([
1982
- import_log10.logInfo
2000
+ _ts_decorate7([
2001
+ import_log11.logInfo
1983
2002
  ], SpaceProtocolSession.prototype, "authStatus", null);
1984
2003
 
1985
2004
  // packages/core/echo/echo-pipeline/src/space/space-manager.ts
1986
- var __decorate8 = function(decorators, target, key, desc) {
2005
+ function _ts_decorate8(decorators, target, key, desc) {
1987
2006
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
1988
2007
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
1989
2008
  r = Reflect.decorate(decorators, target, key, desc);
@@ -1992,10 +2011,11 @@ var __decorate8 = function(decorators, target, key, desc) {
1992
2011
  if (d = decorators[i])
1993
2012
  r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
1994
2013
  return c > 3 && r && Object.defineProperty(target, key, r), r;
1995
- };
2014
+ }
2015
+ var __dxlog_file12 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1996
2016
  var SpaceManager = class SpaceManager2 {
1997
2017
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
1998
- this._spaces = new import_util7.ComplexMap(import_keys6.PublicKey.hash);
2018
+ this._spaces = new import_util8.ComplexMap(import_keys6.PublicKey.hash);
1999
2019
  this._instanceId = import_keys6.PublicKey.random().toHex();
2000
2020
  this._feedStore = feedStore;
2001
2021
  this._networkManager = networkManager;
@@ -2017,23 +2037,23 @@ var SpaceManager = class SpaceManager2 {
2017
2037
  }
2018
2038
  async constructSpace({ metadata, swarmIdentity, onNetworkConnection, onAuthFailure, memberKey }) {
2019
2039
  var _a;
2020
- import_log11.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
2040
+ import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.begin({
2021
2041
  id: this._instanceId
2022
2042
  }), {
2023
- file: "space-manager.ts",
2024
- line: 97,
2025
- scope: this,
2026
- callSite: (f, a) => f(...a)
2043
+ F: __dxlog_file12,
2044
+ L: 97,
2045
+ S: this,
2046
+ C: (f, a) => f(...a)
2027
2047
  });
2028
- (0, import_log11.log)("constructing space...", {
2048
+ (0, import_log12.log)("constructing space...", {
2029
2049
  spaceKey: metadata.genesisFeedKey
2030
2050
  }, {
2031
- file: "space-manager.ts",
2032
- line: 98,
2033
- scope: this,
2034
- callSite: (f, a) => f(...a)
2051
+ F: __dxlog_file12,
2052
+ L: 98,
2053
+ S: this,
2054
+ C: (f, a) => f(...a)
2035
2055
  });
2036
- const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : (0, import_debug6.failUndefined)());
2056
+ const genesisFeed = await this._feedStore.openFeed((_a = metadata.genesisFeedKey) != null ? _a : (0, import_debug5.failUndefined)());
2037
2057
  const spaceKey = metadata.key;
2038
2058
  const protocol = new SpaceProtocol({
2039
2059
  topic: spaceKey,
@@ -2055,24 +2075,24 @@ var SpaceManager = class SpaceManager2 {
2055
2075
  memberKey
2056
2076
  });
2057
2077
  this._spaces.set(space.key, space);
2058
- import_log11.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
2078
+ import_log12.log.trace("dxos.echo.space-manager.construct-space", import_protocols6.trace.end({
2059
2079
  id: this._instanceId
2060
2080
  }), {
2061
- file: "space-manager.ts",
2062
- line: 125,
2063
- scope: this,
2064
- callSite: (f, a) => f(...a)
2081
+ F: __dxlog_file12,
2082
+ L: 125,
2083
+ S: this,
2084
+ C: (f, a) => f(...a)
2065
2085
  });
2066
2086
  return space;
2067
2087
  }
2068
2088
  };
2069
- __decorate8([
2089
+ _ts_decorate8([
2070
2090
  import_async8.synchronized
2071
2091
  ], SpaceManager.prototype, "open", null);
2072
- __decorate8([
2092
+ _ts_decorate8([
2073
2093
  import_async8.synchronized
2074
2094
  ], SpaceManager.prototype, "close", null);
2075
- SpaceManager = __decorate8([
2095
+ SpaceManager = _ts_decorate8([
2076
2096
  (0, import_async8.trackLeaks)("open", "close")
2077
2097
  ], SpaceManager);
2078
2098
 
@@ -2101,7 +2121,7 @@ var WebsocketNetworkManagerProvider = (signalUrl) => () => new import_network_ma
2101
2121
  });
2102
2122
  var TestAgentBuilder = class {
2103
2123
  constructor({ storage, networkManagerProvider } = {}) {
2104
- this._agents = new import_util8.ComplexMap(import_keys7.PublicKey.hash);
2124
+ this._agents = new import_util9.ComplexMap(import_keys7.PublicKey.hash);
2105
2125
  this._storage = storage != null ? storage : (0, import_random_access_storage.createStorage)({
2106
2126
  type: import_random_access_storage.StorageType.RAM
2107
2127
  });
@@ -2143,7 +2163,7 @@ var TestAgent = class {
2143
2163
  this._feedBuilder = _feedBuilder;
2144
2164
  this.identityKey = identityKey;
2145
2165
  this.deviceKey = deviceKey;
2146
- this._spaces = new import_util8.ComplexMap(import_keys7.PublicKey.hash);
2166
+ this._spaces = new import_util9.ComplexMap(import_keys7.PublicKey.hash);
2147
2167
  this.modelFactory = new import_model_factory.ModelFactory().registerModel(import_document_model.DocumentModel);
2148
2168
  this.storage = this._feedBuilder.storage;
2149
2169
  this.keyring = this._feedBuilder.keyring;