@dxos/echo-pipeline 0.3.11-main.346d280 → 0.3.11-main.3a8a0ef

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.
@@ -26,8 +26,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
26
  mod
27
27
  ));
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var chunk_V27KLI77_exports = {};
30
- __export(chunk_V27KLI77_exports, {
29
+ var chunk_PZONK23P_exports = {};
30
+ __export(chunk_PZONK23P_exports, {
31
31
  AuthExtension: () => AuthExtension,
32
32
  AuthStatus: () => AuthStatus,
33
33
  AutomergeHost: () => AutomergeHost,
@@ -55,7 +55,7 @@ __export(chunk_V27KLI77_exports, {
55
55
  startAfter: () => startAfter,
56
56
  valueEncoding: () => valueEncoding
57
57
  });
58
- module.exports = __toCommonJS(chunk_V27KLI77_exports);
58
+ module.exports = __toCommonJS(chunk_PZONK23P_exports);
59
59
  var import_hypercore = require("@dxos/hypercore");
60
60
  var import_protocols = require("@dxos/protocols");
61
61
  var import_invariant = require("@dxos/invariant");
@@ -149,9 +149,11 @@ var import_log12 = require("@dxos/log");
149
149
  var import_protocols7 = require("@dxos/protocols");
150
150
  var import_util9 = require("@dxos/util");
151
151
  var import_automerge_repo = require("@dxos/automerge/automerge-repo");
152
+ var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
152
153
  var import_codec_protobuf2 = require("@dxos/codec-protobuf");
153
154
  var import_invariant10 = require("@dxos/invariant");
154
155
  var import_log13 = require("@dxos/log");
156
+ var import_random_access_storage = require("@dxos/random-access-storage");
155
157
  var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
156
158
  var import_util10 = require("@dxos/util");
157
159
  var codec = import_protocols.schema.getCodecForType("dxos.echo.feed.FeedMessage");
@@ -620,12 +622,12 @@ var emptyLargeSpaceMetadata = () => ({});
620
622
  var EchoMetadata = import_protocols4.schema.getCodecForType("dxos.echo.metadata.EchoMetadata");
621
623
  var LargeSpaceMetadata = import_protocols4.schema.getCodecForType("dxos.echo.metadata.LargeSpaceMetadata");
622
624
  var MetadataStore = class {
623
- constructor(_directory) {
624
- this._directory = _directory;
625
+ constructor(directory) {
625
626
  this._metadata = emptyEchoMetadata();
626
627
  this._spaceLargeMetadata = new import_util3.ComplexMap(import_keys3.PublicKey.hash);
627
628
  this._metadataFile = void 0;
628
629
  this.update = new import_async2.Event();
630
+ this._directory = directory;
629
631
  }
630
632
  get metadata() {
631
633
  return this._metadata;
@@ -654,7 +656,7 @@ var MetadataStore = class {
654
656
  name: file.filename
655
657
  }, {
656
658
  F: __dxlog_file4,
657
- L: 78,
659
+ L: 85,
658
660
  S: this,
659
661
  C: (f, a) => f(...a)
660
662
  });
@@ -674,6 +676,9 @@ var MetadataStore = class {
674
676
  await file.close();
675
677
  }
676
678
  }
679
+ /**
680
+ * @internal
681
+ */
677
682
  async _writeFile(file, codec2, data) {
678
683
  const encoded = (0, import_util3.arrayToBuffer)(codec2.encode(data));
679
684
  const checksum = import_crc_32.default.buf(encoded);
@@ -687,7 +692,7 @@ var MetadataStore = class {
687
692
  checksum
688
693
  }, {
689
694
  F: __dxlog_file4,
690
- L: 110,
695
+ L: 120,
691
696
  S: this,
692
697
  C: (f, a) => f(...a)
693
698
  });
@@ -719,7 +724,7 @@ var MetadataStore = class {
719
724
  err
720
725
  }, {
721
726
  F: __dxlog_file4,
722
- L: 141,
727
+ L: 151,
723
728
  S: this,
724
729
  C: (f, a) => f(...a)
725
730
  });
@@ -736,7 +741,7 @@ var MetadataStore = class {
736
741
  err
737
742
  }, {
738
743
  F: __dxlog_file4,
739
- L: 153,
744
+ L: 163,
740
745
  S: this,
741
746
  C: (f, a) => f(...a)
742
747
  });
@@ -766,7 +771,7 @@ var MetadataStore = class {
766
771
  err
767
772
  }, {
768
773
  F: __dxlog_file4,
769
- L: 182,
774
+ L: 192,
770
775
  S: this,
771
776
  C: (f, a) => f(...a)
772
777
  });
@@ -787,7 +792,7 @@ var MetadataStore = class {
787
792
  const space = this.spaces.find((space2) => space2.key === spaceKey);
788
793
  (0, import_invariant4.invariant)(space, "Space not found", {
789
794
  F: __dxlog_file4,
790
- L: 204,
795
+ L: 214,
791
796
  S: this,
792
797
  A: [
793
798
  "space",
@@ -811,7 +816,7 @@ var MetadataStore = class {
811
816
  async clear() {
812
817
  (0, import_log3.log)("clearing all metadata", void 0, {
813
818
  F: __dxlog_file4,
814
- L: 223,
819
+ L: 233,
815
820
  S: this,
816
821
  C: (f, a) => f(...a)
817
822
  });
@@ -824,7 +829,7 @@ var MetadataStore = class {
824
829
  async setIdentityRecord(record) {
825
830
  (0, import_invariant4.invariant)(!this._metadata.identity, "Cannot overwrite existing identity in metadata", {
826
831
  F: __dxlog_file4,
827
- L: 233,
832
+ L: 243,
828
833
  S: this,
829
834
  A: [
830
835
  "!this._metadata.identity",
@@ -838,7 +843,7 @@ var MetadataStore = class {
838
843
  async addSpace(record) {
839
844
  (0, import_invariant4.invariant)(!(this._metadata.spaces ?? []).find((space) => space.key === record.key), "Cannot overwrite existing space in metadata", {
840
845
  F: __dxlog_file4,
841
- L: 241,
846
+ L: 251,
842
847
  S: this,
843
848
  A: [
844
849
  "!(this._metadata.spaces ?? []).find((space) => space.key === record.key)",
@@ -1532,7 +1537,7 @@ var __dxlog_file9 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipelin
1532
1537
  var MESSAGES_PER_SNAPSHOT = 10;
1533
1538
  var AUTOMATIC_SNAPSHOT_DEBOUNCE_INTERVAL = 5e3;
1534
1539
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL = 5e3;
1535
- var DataPipeline = class DataPipeline2 {
1540
+ var DataPipeline = class {
1536
1541
  constructor(_params) {
1537
1542
  this._params = _params;
1538
1543
  this._ctx = new import_context5.Context();
@@ -1987,7 +1992,7 @@ var __dxlog_file10 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeli
1987
1992
  var TIMEFRAME_SAVE_DEBOUNCE_INTERVAL2 = 500;
1988
1993
  var CONTROL_PIPELINE_SNAPSHOT_DELAY = 1e4;
1989
1994
  var USE_SNAPSHOTS = true;
1990
- var ControlPipeline = class ControlPipeline2 {
1995
+ var ControlPipeline = class {
1991
1996
  constructor({ spaceKey, genesisFeed, feedProvider, metadataStore }) {
1992
1997
  this._ctx = new import_context6.Context();
1993
1998
  this._lastTimeframeSaveTime = Date.now();
@@ -2231,7 +2236,7 @@ function _ts_decorate6(decorators, target, key, desc) {
2231
2236
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2232
2237
  }
2233
2238
  var __dxlog_file11 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space.ts";
2234
- var Space = class Space2 {
2239
+ var Space = class {
2235
2240
  constructor(params) {
2236
2241
  this._addFeedLock = new import_async7.Lock();
2237
2242
  this.onCredentialProcessed = new import_util6.Callback();
@@ -2604,7 +2609,7 @@ var SpaceProtocolSession = class {
2604
2609
  this.replicator = new import_teleport_extension_replicator.ReplicatorExtension().setOptions({
2605
2610
  upload: true
2606
2611
  });
2607
- this._authStatus = AuthStatus.INITIAL;
2612
+ this._authStatus = "INITIAL";
2608
2613
  this._wireParams = wireParams;
2609
2614
  this._swarmIdentity = swarmIdentity;
2610
2615
  this._onSessionAuth = onSessionAuth;
@@ -2633,11 +2638,11 @@ var SpaceProtocolSession = class {
2633
2638
  S: this,
2634
2639
  C: (f, a) => f(...a)
2635
2640
  });
2636
- this._authStatus = AuthStatus.SUCCESS;
2641
+ this._authStatus = "SUCCESS";
2637
2642
  this._onSessionAuth?.(this._teleport);
2638
2643
  },
2639
2644
  onAuthFailure: () => {
2640
- this._authStatus = AuthStatus.FAILURE;
2645
+ this._authStatus = "FAILURE";
2641
2646
  this._onAuthFailure?.(this._teleport);
2642
2647
  }
2643
2648
  }));
@@ -2674,7 +2679,7 @@ function _ts_decorate8(decorators, target, key, desc) {
2674
2679
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2675
2680
  }
2676
2681
  var __dxlog_file13 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/space/space-manager.ts";
2677
- var SpaceManager = class SpaceManager2 {
2682
+ var SpaceManager = class {
2678
2683
  constructor({ feedStore, networkManager, modelFactory, metadataStore, snapshotStore, blobStore }) {
2679
2684
  this._spaces = new import_util9.ComplexMap(import_keys7.PublicKey.hash);
2680
2685
  this._instanceId = import_keys7.PublicKey.random().toHex();
@@ -2760,7 +2765,7 @@ var AutomergeHost = class {
2760
2765
  constructor(storageDirectory) {
2761
2766
  this._meshNetwork = new MeshNetworkAdapter();
2762
2767
  this._clientNetwork = new LocalHostNetworkAdapter();
2763
- this._storage = new AutomergeStorageAdapter(storageDirectory);
2768
+ this._storage = storageDirectory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(storageDirectory.path, "data") : new AutomergeStorageAdapter(storageDirectory);
2764
2769
  this._repo = new import_automerge_repo.Repo({
2765
2770
  network: [
2766
2771
  this._clientNetwork,
@@ -2818,7 +2823,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter
2818
2823
  const peer = this._peers.get(message.targetId);
2819
2824
  (0, import_invariant10.invariant)(peer, "Peer not found.", {
2820
2825
  F: __dxlog_file14,
2821
- L: 108,
2826
+ L: 114,
2822
2827
  S: this,
2823
2828
  A: [
2824
2829
  "peer",
@@ -2838,7 +2843,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter
2838
2843
  return new import_codec_protobuf2.Stream(({ next, close }) => {
2839
2844
  (0, import_invariant10.invariant)(!this._peers.has(peerId), "Peer already connected.", {
2840
2845
  F: __dxlog_file14,
2841
- L: 126,
2846
+ L: 132,
2842
2847
  S: this,
2843
2848
  A: [
2844
2849
  "!this._peers.has(peerId)",
@@ -2872,7 +2877,7 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo.NetworkAdapter
2872
2877
  getHostInfo() {
2873
2878
  (0, import_invariant10.invariant)(this.peerId, "Peer id not set.", {
2874
2879
  F: __dxlog_file14,
2875
- L: 155,
2880
+ L: 161,
2876
2881
  S: this,
2877
2882
  A: [
2878
2883
  "this.peerId",
@@ -2908,7 +2913,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
2908
2913
  const extension = this._extensions.get(receiverId);
2909
2914
  (0, import_invariant10.invariant)(extension, "Extension not found.", {
2910
2915
  F: __dxlog_file14,
2911
- L: 190,
2916
+ L: 196,
2912
2917
  S: this,
2913
2918
  A: [
2914
2919
  "extension",
@@ -2919,7 +2924,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
2919
2924
  payload: import_automerge_repo.cbor.encode(message)
2920
2925
  }).catch((err) => import_log13.log.catch(err, void 0, {
2921
2926
  F: __dxlog_file14,
2922
- L: 191,
2927
+ L: 197,
2923
2928
  S: this,
2924
2929
  C: (f, a) => f(...a)
2925
2930
  }));
@@ -2929,7 +2934,7 @@ var MeshNetworkAdapter = class extends import_automerge_repo.NetworkAdapter {
2929
2934
  createExtension() {
2930
2935
  (0, import_invariant10.invariant)(this.peerId, "Peer id not set.", {
2931
2936
  F: __dxlog_file14,
2932
- L: 199,
2937
+ L: 205,
2933
2938
  S: this,
2934
2939
  A: [
2935
2940
  "this.peerId",
@@ -3047,4 +3052,4 @@ var AutomergeStorageAdapter = class extends import_automerge_repo.StorageAdapter
3047
3052
  startAfter,
3048
3053
  valueEncoding
3049
3054
  });
3050
- //# sourceMappingURL=chunk-V27KLI77.cjs.map
3055
+ //# sourceMappingURL=chunk-PZONK23P.cjs.map