@dxos/echo-pipeline 0.8.4-main.f9ba587 → 0.8.4-main.fd6878d

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 (115) hide show
  1. package/dist/lib/browser/{chunk-GBFX5J5B.mjs → chunk-2543T5DX.mjs} +198 -119
  2. package/dist/lib/browser/chunk-2543T5DX.mjs.map +7 -0
  3. package/dist/lib/browser/{chunk-ANZAS5CC.mjs → chunk-VUXUDIPM.mjs} +1 -1
  4. package/dist/lib/{node-esm/chunk-2SAZ7CCF.mjs.map → browser/chunk-VUXUDIPM.mjs.map} +2 -2
  5. package/dist/lib/browser/filter/index.mjs +1 -1
  6. package/dist/lib/browser/index.mjs +363 -186
  7. package/dist/lib/browser/index.mjs.map +4 -4
  8. package/dist/lib/browser/meta.json +1 -1
  9. package/dist/lib/browser/testing/index.mjs +30 -5
  10. package/dist/lib/browser/testing/index.mjs.map +3 -3
  11. package/dist/lib/node-esm/{chunk-2SAZ7CCF.mjs → chunk-PGZYXNYE.mjs} +1 -1
  12. package/dist/lib/{browser/chunk-ANZAS5CC.mjs.map → node-esm/chunk-PGZYXNYE.mjs.map} +2 -2
  13. package/dist/lib/node-esm/{chunk-FQFKWA3X.mjs → chunk-UQI6R3TD.mjs} +198 -119
  14. package/dist/lib/node-esm/chunk-UQI6R3TD.mjs.map +7 -0
  15. package/dist/lib/node-esm/filter/index.mjs +1 -1
  16. package/dist/lib/node-esm/index.mjs +363 -186
  17. package/dist/lib/node-esm/index.mjs.map +4 -4
  18. package/dist/lib/node-esm/meta.json +1 -1
  19. package/dist/lib/node-esm/testing/index.mjs +30 -5
  20. package/dist/lib/node-esm/testing/index.mjs.map +3 -3
  21. package/dist/types/src/automerge/automerge-host.d.ts +1 -1
  22. package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
  23. package/dist/types/src/automerge/collection-synchronizer.d.ts +1 -1
  24. package/dist/types/src/automerge/collection-synchronizer.d.ts.map +1 -1
  25. package/dist/types/src/automerge/echo-network-adapter.d.ts +1 -1
  26. package/dist/types/src/automerge/echo-network-adapter.d.ts.map +1 -1
  27. package/dist/types/src/automerge/echo-replicator.d.ts +1 -1
  28. package/dist/types/src/automerge/echo-replicator.d.ts.map +1 -1
  29. package/dist/types/src/automerge/index.d.ts +1 -1
  30. package/dist/types/src/automerge/index.d.ts.map +1 -1
  31. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts +1 -1
  32. package/dist/types/src/automerge/leveldb-storage-adapter.d.ts.map +1 -1
  33. package/dist/types/src/automerge/mesh-echo-replicator.d.ts.map +1 -1
  34. package/dist/types/src/db-host/data-service.d.ts +2 -2
  35. package/dist/types/src/db-host/data-service.d.ts.map +1 -1
  36. package/dist/types/src/db-host/database-root.d.ts.map +1 -1
  37. package/dist/types/src/db-host/documents-synchronizer.d.ts +2 -2
  38. package/dist/types/src/db-host/documents-synchronizer.d.ts.map +1 -1
  39. package/dist/types/src/db-host/echo-host.d.ts +2 -2
  40. package/dist/types/src/db-host/echo-host.d.ts.map +1 -1
  41. package/dist/types/src/db-host/query-service.d.ts +1 -1
  42. package/dist/types/src/db-host/query-service.d.ts.map +1 -1
  43. package/dist/types/src/db-host/space-state-manager.d.ts +1 -1
  44. package/dist/types/src/db-host/space-state-manager.d.ts.map +1 -1
  45. package/dist/types/src/edge/echo-edge-replicator.d.ts.map +1 -1
  46. package/dist/types/src/filter/filter-match.d.ts +1 -1
  47. package/dist/types/src/filter/filter-match.d.ts.map +1 -1
  48. package/dist/types/src/metadata/metadata-store.d.ts +1 -1
  49. package/dist/types/src/metadata/metadata-store.d.ts.map +1 -1
  50. package/dist/types/src/pipeline/pipeline.d.ts +1 -1
  51. package/dist/types/src/pipeline/pipeline.d.ts.map +1 -1
  52. package/dist/types/src/query/errors.d.ts +19 -6
  53. package/dist/types/src/query/errors.d.ts.map +1 -1
  54. package/dist/types/src/query/query-executor.d.ts +1 -1
  55. package/dist/types/src/query/query-executor.d.ts.map +1 -1
  56. package/dist/types/src/space/admission-discovery-extension.d.ts.map +1 -1
  57. package/dist/types/src/space/control-pipeline.d.ts +1 -1
  58. package/dist/types/src/space/control-pipeline.d.ts.map +1 -1
  59. package/dist/types/src/space/space-manager.d.ts +1 -1
  60. package/dist/types/src/space/space-manager.d.ts.map +1 -1
  61. package/dist/types/src/space/space-protocol.d.ts +1 -1
  62. package/dist/types/src/space/space-protocol.d.ts.map +1 -1
  63. package/dist/types/src/space/space.d.ts +1 -1
  64. package/dist/types/src/space/space.d.ts.map +1 -1
  65. package/dist/types/src/testing/test-agent-builder.d.ts +2 -2
  66. package/dist/types/src/testing/test-agent-builder.d.ts.map +1 -1
  67. package/dist/types/src/util.d.ts +1 -1
  68. package/dist/types/src/util.d.ts.map +1 -1
  69. package/dist/types/tsconfig.tsbuildinfo +1 -1
  70. package/package.json +41 -38
  71. package/src/automerge/automerge-host.test.ts +3 -2
  72. package/src/automerge/automerge-host.ts +20 -10
  73. package/src/automerge/automerge-repo.test.ts +10 -16
  74. package/src/automerge/collection-synchronizer.test.ts +2 -2
  75. package/src/automerge/collection-synchronizer.ts +2 -2
  76. package/src/automerge/echo-data-monitor.ts +1 -1
  77. package/src/automerge/echo-network-adapter.test.ts +3 -3
  78. package/src/automerge/echo-network-adapter.ts +6 -5
  79. package/src/automerge/echo-replicator.ts +2 -1
  80. package/src/automerge/index.ts +1 -1
  81. package/src/automerge/leveldb-storage-adapter.ts +1 -1
  82. package/src/automerge/mesh-echo-replicator.ts +2 -1
  83. package/src/automerge/storage-adapter.test.ts +1 -1
  84. package/src/common/space-id.ts +1 -1
  85. package/src/db-host/data-service.ts +8 -7
  86. package/src/db-host/database-root.ts +2 -2
  87. package/src/db-host/documents-synchronizer.test.ts +1 -1
  88. package/src/db-host/documents-synchronizer.ts +39 -26
  89. package/src/db-host/echo-host.ts +13 -12
  90. package/src/db-host/query-service.ts +8 -1
  91. package/src/db-host/space-state-manager.ts +2 -2
  92. package/src/edge/echo-edge-replicator.test.ts +3 -2
  93. package/src/edge/echo-edge-replicator.ts +36 -15
  94. package/src/filter/filter-match.test.ts +2 -2
  95. package/src/filter/filter-match.ts +1 -1
  96. package/src/metadata/metadata-store.ts +3 -3
  97. package/src/pipeline/pipeline-stress.test.ts +4 -2
  98. package/src/pipeline/pipeline.test.ts +3 -2
  99. package/src/pipeline/pipeline.ts +8 -5
  100. package/src/query/query-executor.ts +7 -7
  101. package/src/query/query-planner.test.ts +2 -1
  102. package/src/space/admission-discovery-extension.ts +2 -2
  103. package/src/space/control-pipeline.test.ts +4 -3
  104. package/src/space/control-pipeline.ts +4 -4
  105. package/src/space/space-manager.browser.test.ts +1 -1
  106. package/src/space/space-manager.ts +5 -4
  107. package/src/space/space-protocol.browser.test.ts +2 -2
  108. package/src/space/space-protocol.test.ts +3 -2
  109. package/src/space/space-protocol.ts +6 -3
  110. package/src/space/space.test.ts +1 -1
  111. package/src/space/space.ts +3 -2
  112. package/src/testing/test-agent-builder.ts +4 -3
  113. package/src/util.ts +1 -1
  114. package/dist/lib/browser/chunk-GBFX5J5B.mjs.map +0 -7
  115. package/dist/lib/node-esm/chunk-FQFKWA3X.mjs.map +0 -7
@@ -79,15 +79,19 @@ var emptyLargeSpaceMetadata = () => ({});
79
79
  var EchoMetadata = schema2.getCodecForType("dxos.echo.metadata.EchoMetadata");
80
80
  var LargeSpaceMetadata = schema2.getCodecForType("dxos.echo.metadata.LargeSpaceMetadata");
81
81
  var MetadataStore = class {
82
+ _metadata = emptyEchoMetadata();
83
+ _spaceLargeMetadata = new ComplexMap2(PublicKey2.hash);
84
+ _metadataFile = void 0;
85
+ update = new Event();
86
+ _invitationCleanupCtx = new Context(void 0, {
87
+ F: __dxlog_file2,
88
+ L: 55
89
+ });
90
+ /**
91
+ * @internal
92
+ */
93
+ _directory;
82
94
  constructor(directory) {
83
- this._metadata = emptyEchoMetadata();
84
- this._spaceLargeMetadata = new ComplexMap2(PublicKey2.hash);
85
- this._metadataFile = void 0;
86
- this.update = new Event();
87
- this._invitationCleanupCtx = new Context(void 0, {
88
- F: __dxlog_file2,
89
- L: 55
90
- });
91
95
  this._directory = directory;
92
96
  }
93
97
  get metadata() {
@@ -429,6 +433,9 @@ var startAfter = (timeframe) => timeframe.frames().map(([feedKey, index]) => ({
429
433
  index: index + 1
430
434
  }));
431
435
  var TimeframeClock = class {
436
+ _timeframe;
437
+ update;
438
+ _pendingTimeframe;
432
439
  constructor(_timeframe = new Timeframe()) {
433
440
  this._timeframe = _timeframe;
434
441
  this.update = new Event2();
@@ -498,7 +505,7 @@ _ts_decorate2([
498
505
  ], TimeframeClock.prototype, "waitUntilReached", null);
499
506
 
500
507
  // src/pipeline/pipeline.ts
501
- import { Event as Event3, sleepWithContext, synchronized as synchronized2, Trigger } from "@dxos/async";
508
+ import { Event as Event3, Trigger, sleepWithContext, synchronized as synchronized2 } from "@dxos/async";
502
509
  import { Context as Context2, rejectOnDispose } from "@dxos/context";
503
510
  import { failUndefined } from "@dxos/debug";
504
511
  import { FeedSetIterator } from "@dxos/feed-store";
@@ -547,14 +554,40 @@ function _ts_decorate3(decorators, target, key, desc) {
547
554
  }
548
555
  var __dxlog_file5 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/pipeline/pipeline.ts";
549
556
  var PipelineState = class {
557
+ _feeds;
558
+ _timeframeClock;
559
+ /**
560
+ * @internal
561
+ */
562
+ _ctx;
563
+ // TODO(dmaretskyi): Remove?. Avoid accessing `_timeframeClock` before constructor initialization.
564
+ get timeframeUpdate() {
565
+ return this._timeframeClock.update;
566
+ }
567
+ stalled;
568
+ /**
569
+ * @internal
570
+ */
571
+ _startTimeframe;
572
+ /**
573
+ * Target timeframe we are waiting to reach.
574
+ */
575
+ _targetTimeframe;
576
+ /**
577
+ * @internal
578
+ */
579
+ _reachedTargetPromise;
580
+ /**
581
+ * @internal
582
+ */
583
+ _reachedTarget;
550
584
  constructor(_feeds, _timeframeClock) {
551
585
  this._feeds = _feeds;
552
586
  this._timeframeClock = _timeframeClock;
553
587
  this._ctx = new Context2(void 0, {
554
588
  F: __dxlog_file5,
555
- L: 41
589
+ L: 42
556
590
  });
557
- this.timeframeUpdate = this._timeframeClock.update;
558
591
  this.stalled = new Event3();
559
592
  this._startTimeframe = new Timeframe2();
560
593
  this._reachedTarget = false;
@@ -603,7 +636,7 @@ var PipelineState = class {
603
636
  */
604
637
  async waitUntilReachedTargetTimeframe({ ctx = new Context2(void 0, {
605
638
  F: __dxlog_file5,
606
- L: 129
639
+ L: 132
607
640
  }), timeout, breakOnStall = true } = {}) {
608
641
  log4("waitUntilReachedTargetTimeframe", {
609
642
  timeout,
@@ -611,7 +644,7 @@ var PipelineState = class {
611
644
  target: this.targetTimeframe
612
645
  }, {
613
646
  F: __dxlog_file5,
614
- L: 133,
647
+ L: 136,
615
648
  S: this,
616
649
  C: (f, a) => f(...a)
617
650
  });
@@ -643,7 +676,7 @@ var PipelineState = class {
643
676
  dependencies: Timeframe2.dependencies(this.targetTimeframe, this.timeframe)
644
677
  }, {
645
678
  F: __dxlog_file5,
646
- L: 161,
679
+ L: 164,
647
680
  S: this,
648
681
  C: (f, a) => f(...a)
649
682
  });
@@ -655,28 +688,30 @@ var PipelineState = class {
655
688
  }
656
689
  };
657
690
  var Pipeline = class {
658
- constructor() {
659
- this._timeframeClock = new TimeframeClock(new Timeframe2());
660
- this._feeds = new ComplexMap3(PublicKey3.hash);
661
- // External state accessor.
662
- this._state = new PipelineState(this._feeds, this._timeframeClock);
663
- // Waits for the message consumer to process the message and yield control back to the pipeline.
664
- this._processingTrigger = new Trigger().wake();
665
- this._pauseTrigger = new Trigger().wake();
666
- // Pending downloads.
667
- this._downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
668
- this._isStopping = false;
669
- this._isStarted = false;
670
- this._isBeingConsumed = false;
671
- this._isPaused = false;
672
- }
691
+ _timeframeClock = new TimeframeClock(new Timeframe2());
692
+ _feeds = new ComplexMap3(PublicKey3.hash);
693
+ // External state accessor.
694
+ _state = new PipelineState(this._feeds, this._timeframeClock);
695
+ // Waits for the message consumer to process the message and yield control back to the pipeline.
696
+ _processingTrigger = new Trigger().wake();
697
+ _pauseTrigger = new Trigger().wake();
698
+ // Pending downloads.
699
+ _downloads = new ComplexMap3((value) => PublicKey3.hash(value.key));
700
+ // Inbound feed stream.
701
+ _feedSetIterator;
702
+ // Outbound feed writer.
703
+ _writer;
704
+ _isStopping = false;
705
+ _isStarted = false;
706
+ _isBeingConsumed = false;
707
+ _isPaused = false;
673
708
  get state() {
674
709
  return this._state;
675
710
  }
676
711
  get writer() {
677
712
  invariant4(this._writer, "Writer not set.", {
678
713
  F: __dxlog_file5,
679
- L: 243,
714
+ L: 246,
680
715
  S: this,
681
716
  A: [
682
717
  "this._writer",
@@ -705,7 +740,7 @@ var Pipeline = class {
705
740
  setWriteFeed(feed) {
706
741
  invariant4(!this._writer, "Writer already set.", {
707
742
  F: __dxlog_file5,
708
- L: 270,
743
+ L: 273,
709
744
  S: this,
710
745
  A: [
711
746
  "!this._writer",
@@ -714,7 +749,7 @@ var Pipeline = class {
714
749
  });
715
750
  invariant4(feed.properties.writable, "Feed must be writable.", {
716
751
  F: __dxlog_file5,
717
- L: 271,
752
+ L: 274,
718
753
  S: this,
719
754
  A: [
720
755
  "feed.properties.writable",
@@ -729,7 +764,7 @@ var Pipeline = class {
729
764
  async start() {
730
765
  invariant4(!this._isStarted, "Pipeline is already started.", {
731
766
  F: __dxlog_file5,
732
- L: 284,
767
+ L: 287,
733
768
  S: this,
734
769
  A: [
735
770
  "!this._isStarted",
@@ -738,7 +773,7 @@ var Pipeline = class {
738
773
  });
739
774
  log4("starting...", void 0, {
740
775
  F: __dxlog_file5,
741
- L: 285,
776
+ L: 288,
742
777
  S: this,
743
778
  C: (f, a) => f(...a)
744
779
  });
@@ -747,7 +782,7 @@ var Pipeline = class {
747
782
  this._isStarted = true;
748
783
  log4("started", void 0, {
749
784
  F: __dxlog_file5,
750
- L: 289,
785
+ L: 292,
751
786
  S: this,
752
787
  C: (f, a) => f(...a)
753
788
  });
@@ -760,7 +795,7 @@ var Pipeline = class {
760
795
  async stop() {
761
796
  log4("stopping...", void 0, {
762
797
  F: __dxlog_file5,
763
- L: 300,
798
+ L: 303,
764
799
  S: this,
765
800
  C: (f, a) => f(...a)
766
801
  });
@@ -774,14 +809,14 @@ var Pipeline = class {
774
809
  await this._state._ctx.dispose();
775
810
  this._state._ctx = new Context2(void 0, {
776
811
  F: __dxlog_file5,
777
- L: 309
812
+ L: 312
778
813
  });
779
814
  this._state._reachedTargetPromise = void 0;
780
815
  this._state._reachedTarget = false;
781
816
  this._isStarted = false;
782
817
  log4("stopped", void 0, {
783
818
  F: __dxlog_file5,
784
- L: 313,
819
+ L: 316,
785
820
  S: this,
786
821
  C: (f, a) => f(...a)
787
822
  });
@@ -793,7 +828,7 @@ var Pipeline = class {
793
828
  async setCursor(timeframe) {
794
829
  invariant4(!this._isStarted || this._isPaused, "Invalid state.", {
795
830
  F: __dxlog_file5,
796
- L: 322,
831
+ L: 325,
797
832
  S: this,
798
833
  A: [
799
834
  "!this._isStarted || this._isPaused",
@@ -822,7 +857,7 @@ var Pipeline = class {
822
857
  async unpause() {
823
858
  invariant4(this._isPaused, "Pipeline is not paused.", {
824
859
  F: __dxlog_file5,
825
- L: 351,
860
+ L: 354,
826
861
  S: this,
827
862
  A: [
828
863
  "this._isPaused",
@@ -842,7 +877,7 @@ var Pipeline = class {
842
877
  async *consume() {
843
878
  invariant4(!this._isBeingConsumed, "Pipeline is already being consumed.", {
844
879
  F: __dxlog_file5,
845
- L: 366,
880
+ L: 369,
846
881
  S: this,
847
882
  A: [
848
883
  "!this._isBeingConsumed",
@@ -852,7 +887,7 @@ var Pipeline = class {
852
887
  this._isBeingConsumed = true;
853
888
  invariant4(this._feedSetIterator, "Iterator not initialized.", {
854
889
  F: __dxlog_file5,
855
- L: 369,
890
+ L: 372,
856
891
  S: this,
857
892
  A: [
858
893
  "this._feedSetIterator",
@@ -866,7 +901,7 @@ var Pipeline = class {
866
901
  if (lastFeedSetIterator !== this._feedSetIterator) {
867
902
  invariant4(this._feedSetIterator, "Iterator not initialized.", {
868
903
  F: __dxlog_file5,
869
- L: 378,
904
+ L: 381,
870
905
  S: this,
871
906
  A: [
872
907
  "this._feedSetIterator",
@@ -901,7 +936,7 @@ var Pipeline = class {
901
936
  length: feed.length
902
937
  }, {
903
938
  F: __dxlog_file5,
904
- L: 407,
939
+ L: 410,
905
940
  S: this,
906
941
  C: (f, a) => f(...a)
907
942
  });
@@ -915,7 +950,7 @@ var Pipeline = class {
915
950
  data
916
951
  }, {
917
952
  F: __dxlog_file5,
918
- L: 412,
953
+ L: 415,
919
954
  S: this,
920
955
  C: (f, a) => f(...a)
921
956
  });
@@ -934,7 +969,7 @@ var Pipeline = class {
934
969
  targetTimeframe: this._state.targetTimeframe
935
970
  }, {
936
971
  F: __dxlog_file5,
937
- L: 426,
972
+ L: 429,
938
973
  S: this,
939
974
  C: (f, a) => f(...a)
940
975
  });
@@ -971,6 +1006,8 @@ import { schema as schema3 } from "@dxos/protocols/proto";
971
1006
  import { RpcExtension } from "@dxos/teleport";
972
1007
  var __dxlog_file6 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/auth.ts";
973
1008
  var AuthExtension = class extends RpcExtension {
1009
+ _authParams;
1010
+ _ctx;
974
1011
  constructor(_authParams) {
975
1012
  super({
976
1013
  requested: {
@@ -1099,19 +1136,28 @@ var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 500;
1099
1136
  var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
1100
1137
  var USE_SNAPSHOTS = true;
1101
1138
  var ControlPipeline = class {
1139
+ _ctx = new Context4(void 0, {
1140
+ F: __dxlog_file7,
1141
+ L: 47
1142
+ });
1143
+ _pipeline;
1144
+ _spaceStateMachine;
1145
+ _spaceKey;
1146
+ _metadata;
1147
+ _targetTimeframe;
1148
+ _lastTimeframeSaveTime = Date.now();
1149
+ onFeedAdmitted = new Callback();
1150
+ onMemberRoleChanged;
1151
+ onCredentialProcessed;
1152
+ onDelegatedInvitation;
1153
+ onDelegatedInvitationRemoved;
1154
+ _usage = new TimeUsageCounter();
1155
+ _mutations = new TimeSeriesCounter();
1156
+ _snapshotTask = new DeferredTask(this._ctx, async () => {
1157
+ await sleepWithContext2(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
1158
+ await this._saveSnapshot();
1159
+ });
1102
1160
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
1103
- this._ctx = new Context4(void 0, {
1104
- F: __dxlog_file7,
1105
- L: 47
1106
- });
1107
- this._lastTimeframeSaveTime = Date.now();
1108
- this.onFeedAdmitted = new Callback();
1109
- this._usage = new TimeUsageCounter();
1110
- this._mutations = new TimeSeriesCounter();
1111
- this._snapshotTask = new DeferredTask(this._ctx, async () => {
1112
- await sleepWithContext2(this._ctx, CONTROL_PIPELINE_SNAPSHOT_DELAY);
1113
- await this._saveSnapshot();
1114
- });
1115
1161
  this._spaceKey = spaceKey;
1116
1162
  this._metadata = metadataStore;
1117
1163
  this._pipeline = new Pipeline();
@@ -1364,13 +1410,21 @@ function _ts_decorate5(decorators, target, key, desc) {
1364
1410
  }
1365
1411
  var __dxlog_file8 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
1366
1412
  var Space = class extends Resource {
1413
+ onCredentialProcessed = new Callback2();
1414
+ stateUpdate = new Event4();
1415
+ protocol;
1416
+ _id;
1417
+ _key;
1418
+ _genesisFeedKey;
1419
+ _feedProvider;
1420
+ _controlPipeline;
1421
+ _controlFeed;
1422
+ _dataFeed;
1367
1423
  constructor(params) {
1368
1424
  super();
1369
- this.onCredentialProcessed = new Callback2();
1370
- this.stateUpdate = new Event4();
1371
1425
  invariant6(params.spaceKey && params.feedProvider, void 0, {
1372
1426
  F: __dxlog_file8,
1373
- L: 72,
1427
+ L: 73,
1374
1428
  S: this,
1375
1429
  A: [
1376
1430
  "params.spaceKey && params.feedProvider",
@@ -1403,7 +1457,7 @@ var Space = class extends Resource {
1403
1457
  credential
1404
1458
  }, {
1405
1459
  F: __dxlog_file8,
1406
- L: 99,
1460
+ L: 100,
1407
1461
  S: this,
1408
1462
  C: (f, a) => f(...a)
1409
1463
  });
@@ -1414,7 +1468,7 @@ var Space = class extends Resource {
1414
1468
  invitation
1415
1469
  }, {
1416
1470
  F: __dxlog_file8,
1417
- L: 103,
1471
+ L: 104,
1418
1472
  S: this,
1419
1473
  C: (f, a) => f(...a)
1420
1474
  });
@@ -1425,7 +1479,7 @@ var Space = class extends Resource {
1425
1479
  invitation
1426
1480
  }, {
1427
1481
  F: __dxlog_file8,
1428
- L: 107,
1482
+ L: 108,
1429
1483
  S: this,
1430
1484
  C: (f, a) => f(...a)
1431
1485
  });
@@ -1439,7 +1493,7 @@ var Space = class extends Resource {
1439
1493
  ])
1440
1494
  }), {
1441
1495
  F: __dxlog_file8,
1442
- L: 111,
1496
+ L: 112,
1443
1497
  S: this,
1444
1498
  C: (f, a) => f(...a)
1445
1499
  });
@@ -1474,7 +1528,7 @@ var Space = class extends Resource {
1474
1528
  async setControlFeed(feed) {
1475
1529
  invariant6(!this._controlFeed, "Control feed already set.", {
1476
1530
  F: __dxlog_file8,
1477
- L: 155,
1531
+ L: 156,
1478
1532
  S: this,
1479
1533
  A: [
1480
1534
  "!this._controlFeed",
@@ -1488,7 +1542,7 @@ var Space = class extends Resource {
1488
1542
  async setDataFeed(feed) {
1489
1543
  invariant6(!this._dataFeed, "Data feed already set.", {
1490
1544
  F: __dxlog_file8,
1491
- L: 162,
1545
+ L: 163,
1492
1546
  S: this,
1493
1547
  A: [
1494
1548
  "!this._dataFeed",
@@ -1507,14 +1561,14 @@ var Space = class extends Resource {
1507
1561
  async _open(ctx) {
1508
1562
  log7("opening...", void 0, {
1509
1563
  F: __dxlog_file8,
1510
- L: 176,
1564
+ L: 177,
1511
1565
  S: this,
1512
1566
  C: (f, a) => f(...a)
1513
1567
  });
1514
1568
  await this._controlPipeline.start();
1515
1569
  log7("opened", void 0, {
1516
1570
  F: __dxlog_file8,
1517
- L: 181,
1571
+ L: 182,
1518
1572
  S: this,
1519
1573
  C: (f, a) => f(...a)
1520
1574
  });
@@ -1522,7 +1576,7 @@ var Space = class extends Resource {
1522
1576
  async startProtocol() {
1523
1577
  invariant6(this.isOpen, void 0, {
1524
1578
  F: __dxlog_file8,
1525
- L: 186,
1579
+ L: 187,
1526
1580
  S: this,
1527
1581
  A: [
1528
1582
  "this.isOpen",
@@ -1537,7 +1591,7 @@ var Space = class extends Resource {
1537
1591
  key: this._key
1538
1592
  }, {
1539
1593
  F: __dxlog_file8,
1540
- L: 193,
1594
+ L: 194,
1541
1595
  S: this,
1542
1596
  C: (f, a) => f(...a)
1543
1597
  });
@@ -1545,7 +1599,7 @@ var Space = class extends Resource {
1545
1599
  await this._controlPipeline.stop();
1546
1600
  log7("closed", void 0, {
1547
1601
  F: __dxlog_file8,
1548
- L: 199,
1602
+ L: 200,
1549
1603
  S: this,
1550
1604
  C: (f, a) => f(...a)
1551
1605
  });
@@ -1587,6 +1641,9 @@ import { schema as schema4 } from "@dxos/protocols/proto";
1587
1641
  import { RpcExtension as RpcExtension2 } from "@dxos/teleport";
1588
1642
  var __dxlog_file9 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/admission-discovery-extension.ts";
1589
1643
  var CredentialRetrieverExtension = class extends RpcExtension2 {
1644
+ _request;
1645
+ _onResult;
1646
+ _ctx;
1590
1647
  constructor(_request, _onResult) {
1591
1648
  super({
1592
1649
  requested: {
@@ -1619,6 +1676,7 @@ var CredentialRetrieverExtension = class extends RpcExtension2 {
1619
1676
  }
1620
1677
  };
1621
1678
  var CredentialServerExtension = class extends RpcExtension2 {
1679
+ _space;
1622
1680
  constructor(_space) {
1623
1681
  super({
1624
1682
  exposed: {
@@ -1663,16 +1721,34 @@ var __dxlog_file10 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/
1663
1721
  var MOCK_AUTH_PROVIDER = async (nonce) => Buffer.from("mock");
1664
1722
  var MOCK_AUTH_VERIFIER = async (nonce, credential) => true;
1665
1723
  var SpaceProtocol = class {
1724
+ _networkManager;
1725
+ _swarmIdentity;
1726
+ _onSessionAuth;
1727
+ _onAuthFailure;
1728
+ blobSync;
1729
+ _disableP2pReplication;
1730
+ _topic;
1731
+ _spaceKey;
1732
+ _feeds = /* @__PURE__ */ new Set();
1733
+ _sessions = new ComplexMap4(PublicKey5.hash);
1734
+ // TODO(burdon): Move to config (with sensible defaults).
1735
+ _topology = new MMSTTopology({
1736
+ originateConnections: 4,
1737
+ maxPeers: 10,
1738
+ sampleSize: 20
1739
+ });
1740
+ _connection;
1741
+ feedAdded = new CallbackCollection();
1742
+ get sessions() {
1743
+ return this._sessions;
1744
+ }
1745
+ get feeds() {
1746
+ return this._feeds;
1747
+ }
1748
+ get _ownPeerKey() {
1749
+ return this._swarmIdentity.peerKey;
1750
+ }
1666
1751
  constructor({ topic, swarmIdentity, networkManager, onSessionAuth, onAuthFailure, blobStore, disableP2pReplication }) {
1667
- this._feeds = /* @__PURE__ */ new Set();
1668
- this._sessions = new ComplexMap4(PublicKey5.hash);
1669
- // TODO(burdon): Move to config (with sensible defaults).
1670
- this._topology = new MMSTTopology({
1671
- originateConnections: 4,
1672
- maxPeers: 10,
1673
- sampleSize: 20
1674
- });
1675
- this.feedAdded = new CallbackCollection();
1676
1752
  this._spaceKey = topic;
1677
1753
  this._networkManager = networkManager;
1678
1754
  this._swarmIdentity = swarmIdentity;
@@ -1684,22 +1760,13 @@ var SpaceProtocol = class {
1684
1760
  this._topic = subtleCrypto2.digest("SHA-256", topic.asBuffer()).then(discoveryKey).then(PublicKey5.from);
1685
1761
  this._disableP2pReplication = disableP2pReplication ?? false;
1686
1762
  }
1687
- get sessions() {
1688
- return this._sessions;
1689
- }
1690
- get feeds() {
1691
- return this._feeds;
1692
- }
1693
- get _ownPeerKey() {
1694
- return this._swarmIdentity.peerKey;
1695
- }
1696
1763
  // TODO(burdon): Create abstraction for Space (e.g., add keys and have provider).
1697
1764
  async addFeed(feed) {
1698
1765
  log8("addFeed", {
1699
1766
  key: feed.key
1700
1767
  }, {
1701
1768
  F: __dxlog_file10,
1702
- L: 128,
1769
+ L: 131,
1703
1770
  S: this,
1704
1771
  C: (f, a) => f(...a)
1705
1772
  });
@@ -1718,7 +1785,7 @@ var SpaceProtocol = class {
1718
1785
  await this.blobSync.open();
1719
1786
  log8("starting...", void 0, {
1720
1787
  F: __dxlog_file10,
1721
- L: 149,
1788
+ L: 152,
1722
1789
  S: this,
1723
1790
  C: (f, a) => f(...a)
1724
1791
  });
@@ -1731,7 +1798,7 @@ var SpaceProtocol = class {
1731
1798
  });
1732
1799
  log8("started", void 0, {
1733
1800
  F: __dxlog_file10,
1734
- L: 158,
1801
+ L: 161,
1735
1802
  S: this,
1736
1803
  C: (f, a) => f(...a)
1737
1804
  });
@@ -1744,14 +1811,14 @@ var SpaceProtocol = class {
1744
1811
  if (this._connection) {
1745
1812
  log8("stopping...", void 0, {
1746
1813
  F: __dxlog_file10,
1747
- L: 169,
1814
+ L: 172,
1748
1815
  S: this,
1749
1816
  C: (f, a) => f(...a)
1750
1817
  });
1751
1818
  await this._connection.close();
1752
1819
  log8("stopped", void 0, {
1753
1820
  F: __dxlog_file10,
1754
- L: 171,
1821
+ L: 174,
1755
1822
  S: this,
1756
1823
  C: (f, a) => f(...a)
1757
1824
  });
@@ -1795,13 +1862,26 @@ var AuthStatus = /* @__PURE__ */ function(AuthStatus2) {
1795
1862
  return AuthStatus2;
1796
1863
  }({});
1797
1864
  var SpaceProtocolSession = class {
1865
+ _wireParams;
1866
+ _disableP2pReplication;
1867
+ _onSessionAuth;
1868
+ _onAuthFailure;
1869
+ _swarmIdentity;
1870
+ _blobSync;
1871
+ _teleport;
1872
+ // TODO(dmaretskyi): Start with upload=false when switching it on the fly works.
1873
+ replicator = new ReplicatorExtension().setOptions({
1874
+ upload: true
1875
+ });
1876
+ _authStatus = "INITIAL";
1877
+ get authStatus() {
1878
+ return this._authStatus;
1879
+ }
1880
+ get stats() {
1881
+ return this._teleport.stats;
1882
+ }
1798
1883
  // TODO(dmaretskyi): Allow to pass in extra extensions.
1799
1884
  constructor({ wireParams, swarmIdentity, onSessionAuth, onAuthFailure, blobSync, disableP2pReplication }) {
1800
- // TODO(dmaretskyi): Start with upload=false when switching it on the fly works.
1801
- this.replicator = new ReplicatorExtension().setOptions({
1802
- upload: true
1803
- });
1804
- this._authStatus = "INITIAL";
1805
1885
  this._wireParams = wireParams;
1806
1886
  this._swarmIdentity = swarmIdentity;
1807
1887
  this._onSessionAuth = onSessionAuth;
@@ -1810,12 +1890,6 @@ var SpaceProtocolSession = class {
1810
1890
  this._teleport = new Teleport(wireParams);
1811
1891
  this._disableP2pReplication = disableP2pReplication ?? false;
1812
1892
  }
1813
- get authStatus() {
1814
- return this._authStatus;
1815
- }
1816
- get stats() {
1817
- return this._teleport.stats;
1818
- }
1819
1893
  get stream() {
1820
1894
  return this._teleport.stream;
1821
1895
  }
@@ -1827,7 +1901,7 @@ var SpaceProtocolSession = class {
1827
1901
  onAuthSuccess: () => {
1828
1902
  log8("Peer authenticated", void 0, {
1829
1903
  F: __dxlog_file10,
1830
- L: 282,
1904
+ L: 285,
1831
1905
  S: this,
1832
1906
  C: (f, a) => f(...a)
1833
1907
  });
@@ -1847,7 +1921,7 @@ var SpaceProtocolSession = class {
1847
1921
  async close() {
1848
1922
  log8("close", void 0, {
1849
1923
  F: __dxlog_file10,
1850
- L: 301,
1924
+ L: 304,
1851
1925
  S: this,
1852
1926
  C: (f, a) => f(...a)
1853
1927
  });
@@ -1866,7 +1940,7 @@ _ts_decorate6([
1866
1940
 
1867
1941
  // src/space/space-manager.ts
1868
1942
  import { parseAutomergeUrl } from "@automerge/automerge-repo";
1869
- import { synchronized as synchronized4, trackLeaks as trackLeaks3, Trigger as Trigger2 } from "@dxos/async";
1943
+ import { Trigger as Trigger2, synchronized as synchronized4, trackLeaks as trackLeaks3 } from "@dxos/async";
1870
1944
  import { getCredentialAssertion } from "@dxos/credentials";
1871
1945
  import { failUndefined as failUndefined2 } from "@dxos/debug";
1872
1946
  import { PublicKey as PublicKey6 } from "@dxos/keys";
@@ -1881,9 +1955,14 @@ function _ts_decorate7(decorators, target, key, desc) {
1881
1955
  }
1882
1956
  var __dxlog_file11 = "/__w/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
1883
1957
  var SpaceManager = class {
1958
+ _spaces = new ComplexMap5(PublicKey6.hash);
1959
+ _feedStore;
1960
+ _networkManager;
1961
+ _metadataStore;
1962
+ _blobStore;
1963
+ _instanceId = PublicKey6.random().toHex();
1964
+ _disableP2pReplication;
1884
1965
  constructor({ feedStore, networkManager, metadataStore, blobStore, disableP2pReplication }) {
1885
- this._spaces = new ComplexMap5(PublicKey6.hash);
1886
- this._instanceId = PublicKey6.random().toHex();
1887
1966
  this._feedStore = feedStore;
1888
1967
  this._networkManager = networkManager;
1889
1968
  this._metadataStore = metadataStore;
@@ -1906,7 +1985,7 @@ var SpaceManager = class {
1906
1985
  id: this._instanceId
1907
1986
  }), {
1908
1987
  F: __dxlog_file11,
1909
- L: 102,
1988
+ L: 103,
1910
1989
  S: this,
1911
1990
  C: (f, a) => f(...a)
1912
1991
  });
@@ -1914,7 +1993,7 @@ var SpaceManager = class {
1914
1993
  spaceKey: metadata.genesisFeedKey
1915
1994
  }, {
1916
1995
  F: __dxlog_file11,
1917
- L: 103,
1996
+ L: 104,
1918
1997
  S: this,
1919
1998
  C: (f, a) => f(...a)
1920
1999
  });
@@ -1946,7 +2025,7 @@ var SpaceManager = class {
1946
2025
  id: this._instanceId
1947
2026
  }), {
1948
2027
  F: __dxlog_file11,
1949
- L: 133,
2028
+ L: 134,
1950
2029
  S: this,
1951
2030
  C: (f, a) => f(...a)
1952
2031
  });
@@ -1958,7 +2037,7 @@ var SpaceManager = class {
1958
2037
  id: this._instanceId
1959
2038
  }), {
1960
2039
  F: __dxlog_file11,
1961
- L: 139,
2040
+ L: 140,
1962
2041
  S: this,
1963
2042
  C: (f, a) => f(...a)
1964
2043
  });
@@ -1966,7 +2045,7 @@ var SpaceManager = class {
1966
2045
  spaceKey: params.spaceKey
1967
2046
  }, {
1968
2047
  F: __dxlog_file11,
1969
- L: 140,
2048
+ L: 141,
1970
2049
  S: this,
1971
2050
  C: (f, a) => f(...a)
1972
2051
  });
@@ -1994,7 +2073,7 @@ var SpaceManager = class {
1994
2073
  id: this._instanceId
1995
2074
  }), {
1996
2075
  F: __dxlog_file11,
1997
- L: 164,
2076
+ L: 165,
1998
2077
  S: this,
1999
2078
  C: (f, a) => f(...a)
2000
2079
  });
@@ -2005,7 +2084,7 @@ var SpaceManager = class {
2005
2084
  error: err
2006
2085
  }), {
2007
2086
  F: __dxlog_file11,
2008
- L: 167,
2087
+ L: 168,
2009
2088
  S: this,
2010
2089
  C: (f, a) => f(...a)
2011
2090
  });
@@ -2064,4 +2143,4 @@ export {
2064
2143
  SpaceProtocolSession,
2065
2144
  SpaceManager
2066
2145
  };
2067
- //# sourceMappingURL=chunk-GBFX5J5B.mjs.map
2146
+ //# sourceMappingURL=chunk-2543T5DX.mjs.map