@dxos/echo-pipeline 0.3.9-main.ec541d7 → 0.3.9-main.ee839a8
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.
- package/dist/lib/browser/{chunk-RV3JOJQ4.mjs → chunk-6XOL2DVG.mjs} +83 -12
- package/dist/lib/browser/{chunk-RV3JOJQ4.mjs.map → chunk-6XOL2DVG.mjs.map} +3 -3
- package/dist/lib/browser/index.mjs +1 -1
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/browser/testing/index.mjs +1 -1
- package/dist/lib/node/{chunk-QIIIHTAB.cjs → chunk-2RIO52RK.cjs} +86 -15
- package/dist/lib/node/{chunk-QIIIHTAB.cjs.map → chunk-2RIO52RK.cjs.map} +3 -3
- package/dist/lib/node/index.cjs +26 -26
- package/dist/lib/node/index.cjs.map +1 -1
- package/dist/lib/node/meta.json +1 -1
- package/dist/lib/node/testing/index.cjs +15 -15
- package/dist/types/src/automerge/automerge-host.d.ts +2 -0
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/space/space-manager.d.ts +3 -0
- package/dist/types/src/space/space-manager.d.ts.map +1 -1
- package/package.json +33 -32
- package/src/automerge/automerge-host.ts +64 -8
- package/src/space/space-manager.ts +3 -0
|
@@ -2687,7 +2687,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2687
2687
|
id: this._instanceId
|
|
2688
2688
|
}), {
|
|
2689
2689
|
F: __dxlog_file13,
|
|
2690
|
-
L:
|
|
2690
|
+
L: 100,
|
|
2691
2691
|
S: this,
|
|
2692
2692
|
C: (f, a) => f(...a)
|
|
2693
2693
|
});
|
|
@@ -2695,7 +2695,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2695
2695
|
spaceKey: metadata.genesisFeedKey
|
|
2696
2696
|
}, {
|
|
2697
2697
|
F: __dxlog_file13,
|
|
2698
|
-
L:
|
|
2698
|
+
L: 101,
|
|
2699
2699
|
S: this,
|
|
2700
2700
|
C: (f, a) => f(...a)
|
|
2701
2701
|
});
|
|
@@ -2725,7 +2725,7 @@ var SpaceManager = class SpaceManager2 {
|
|
|
2725
2725
|
id: this._instanceId
|
|
2726
2726
|
}), {
|
|
2727
2727
|
F: __dxlog_file13,
|
|
2728
|
-
L:
|
|
2728
|
+
L: 129,
|
|
2729
2729
|
S: this,
|
|
2730
2730
|
C: (f, a) => f(...a)
|
|
2731
2731
|
});
|
|
@@ -2746,6 +2746,8 @@ SpaceManager = _ts_decorate8([
|
|
|
2746
2746
|
import { Repo, NetworkAdapter, StorageAdapter, cbor } from "@dxos/automerge/automerge-repo";
|
|
2747
2747
|
import { Stream as Stream2 } from "@dxos/codec-protobuf";
|
|
2748
2748
|
import { invariant as invariant10 } from "@dxos/invariant";
|
|
2749
|
+
import { log as log13 } from "@dxos/log";
|
|
2750
|
+
import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
|
|
2749
2751
|
import { arrayToBuffer as arrayToBuffer2, bufferToArray } from "@dxos/util";
|
|
2750
2752
|
var __dxlog_file14 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
2751
2753
|
var AutomergeHost = class {
|
|
@@ -2755,14 +2757,15 @@ var AutomergeHost = class {
|
|
|
2755
2757
|
this._storage = new AutomergeStorageAdapter(storageDirectory);
|
|
2756
2758
|
this._repo = new Repo({
|
|
2757
2759
|
network: [
|
|
2758
|
-
|
|
2759
|
-
this.
|
|
2760
|
+
this._clientNetwork,
|
|
2761
|
+
this._meshNetwork
|
|
2760
2762
|
],
|
|
2761
2763
|
storage: this._storage,
|
|
2762
2764
|
// TODO(dmaretskyi): Share based on HALO permissions and space affinity.
|
|
2763
2765
|
sharePolicy: async (peerId, documentId) => true
|
|
2764
2766
|
});
|
|
2765
2767
|
this._clientNetwork.ready();
|
|
2768
|
+
this._meshNetwork.ready();
|
|
2766
2769
|
}
|
|
2767
2770
|
get repo() {
|
|
2768
2771
|
return this._repo;
|
|
@@ -2782,6 +2785,12 @@ var AutomergeHost = class {
|
|
|
2782
2785
|
getHostInfo() {
|
|
2783
2786
|
return this._clientNetwork.getHostInfo();
|
|
2784
2787
|
}
|
|
2788
|
+
//
|
|
2789
|
+
// Mesh replication.
|
|
2790
|
+
//
|
|
2791
|
+
createExtension() {
|
|
2792
|
+
return this._meshNetwork.createExtension();
|
|
2793
|
+
}
|
|
2785
2794
|
};
|
|
2786
2795
|
var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
2787
2796
|
constructor() {
|
|
@@ -2803,7 +2812,7 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
|
2803
2812
|
const peer = this._peers.get(message.targetId);
|
|
2804
2813
|
invariant10(peer, "Peer not found.", {
|
|
2805
2814
|
F: __dxlog_file14,
|
|
2806
|
-
L:
|
|
2815
|
+
L: 108,
|
|
2807
2816
|
S: this,
|
|
2808
2817
|
A: [
|
|
2809
2818
|
"peer",
|
|
@@ -2823,7 +2832,7 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
|
2823
2832
|
return new Stream2(({ next, close }) => {
|
|
2824
2833
|
invariant10(!this._peers.has(peerId), "Peer already connected.", {
|
|
2825
2834
|
F: __dxlog_file14,
|
|
2826
|
-
L:
|
|
2835
|
+
L: 126,
|
|
2827
2836
|
S: this,
|
|
2828
2837
|
A: [
|
|
2829
2838
|
"!this._peers.has(peerId)",
|
|
@@ -2857,7 +2866,7 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
|
2857
2866
|
getHostInfo() {
|
|
2858
2867
|
invariant10(this.peerId, "Peer id not set.", {
|
|
2859
2868
|
F: __dxlog_file14,
|
|
2860
|
-
L:
|
|
2869
|
+
L: 155,
|
|
2861
2870
|
S: this,
|
|
2862
2871
|
A: [
|
|
2863
2872
|
"this.peerId",
|
|
@@ -2873,14 +2882,76 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter {
|
|
|
2873
2882
|
}
|
|
2874
2883
|
};
|
|
2875
2884
|
var MeshNetworkAdapter = class extends NetworkAdapter {
|
|
2885
|
+
constructor() {
|
|
2886
|
+
super(...arguments);
|
|
2887
|
+
this._extensions = /* @__PURE__ */ new Map();
|
|
2888
|
+
}
|
|
2889
|
+
/**
|
|
2890
|
+
* Emits `ready` event. That signals to `Repo` that it can start using the adapter.
|
|
2891
|
+
*/
|
|
2892
|
+
ready() {
|
|
2893
|
+
this.emit("ready", {
|
|
2894
|
+
network: this
|
|
2895
|
+
});
|
|
2896
|
+
}
|
|
2876
2897
|
connect(peerId) {
|
|
2877
|
-
|
|
2898
|
+
this.peerId = peerId;
|
|
2878
2899
|
}
|
|
2879
2900
|
send(message) {
|
|
2880
|
-
|
|
2901
|
+
const receiverId = message.targetId;
|
|
2902
|
+
const extension = this._extensions.get(receiverId);
|
|
2903
|
+
invariant10(extension, "Extension not found.", {
|
|
2904
|
+
F: __dxlog_file14,
|
|
2905
|
+
L: 190,
|
|
2906
|
+
S: this,
|
|
2907
|
+
A: [
|
|
2908
|
+
"extension",
|
|
2909
|
+
"'Extension not found.'"
|
|
2910
|
+
]
|
|
2911
|
+
});
|
|
2912
|
+
extension.sendSyncMessage({
|
|
2913
|
+
payload: cbor.encode(message)
|
|
2914
|
+
}).catch((err) => log13.catch(err, void 0, {
|
|
2915
|
+
F: __dxlog_file14,
|
|
2916
|
+
L: 191,
|
|
2917
|
+
S: this,
|
|
2918
|
+
C: (f, a) => f(...a)
|
|
2919
|
+
}));
|
|
2881
2920
|
}
|
|
2882
2921
|
disconnect() {
|
|
2883
|
-
|
|
2922
|
+
}
|
|
2923
|
+
createExtension() {
|
|
2924
|
+
invariant10(this.peerId, "Peer id not set.", {
|
|
2925
|
+
F: __dxlog_file14,
|
|
2926
|
+
L: 199,
|
|
2927
|
+
S: this,
|
|
2928
|
+
A: [
|
|
2929
|
+
"this.peerId",
|
|
2930
|
+
"'Peer id not set.'"
|
|
2931
|
+
]
|
|
2932
|
+
});
|
|
2933
|
+
let peerInfo;
|
|
2934
|
+
const extension = new AutomergeReplicator({
|
|
2935
|
+
peerId: this.peerId
|
|
2936
|
+
}, {
|
|
2937
|
+
onStartReplication: async (info) => {
|
|
2938
|
+
peerInfo = info;
|
|
2939
|
+
this._extensions.set(info.id, extension);
|
|
2940
|
+
this.emit("peer-candidate", {
|
|
2941
|
+
peerId: info.id
|
|
2942
|
+
});
|
|
2943
|
+
},
|
|
2944
|
+
onSyncMessage: async ({ payload }) => {
|
|
2945
|
+
const message = cbor.decode(payload);
|
|
2946
|
+
this.emit("message", message);
|
|
2947
|
+
},
|
|
2948
|
+
onClose: async () => {
|
|
2949
|
+
peerInfo && this.emit("peer-disconnected", {
|
|
2950
|
+
peerId: peerInfo.id
|
|
2951
|
+
});
|
|
2952
|
+
}
|
|
2953
|
+
});
|
|
2954
|
+
return extension;
|
|
2884
2955
|
}
|
|
2885
2956
|
};
|
|
2886
2957
|
var AutomergeStorageAdapter = class extends StorageAdapter {
|
|
@@ -2966,4 +3037,4 @@ export {
|
|
|
2966
3037
|
SpaceManager,
|
|
2967
3038
|
AutomergeHost
|
|
2968
3039
|
};
|
|
2969
|
-
//# sourceMappingURL=chunk-
|
|
3040
|
+
//# sourceMappingURL=chunk-6XOL2DVG.mjs.map
|