@dxos/echo-pipeline 0.5.9-main.0a0e87d → 0.5.9-main.1c1903d
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/index.mjs +63 -182
- package/dist/lib/browser/index.mjs.map +4 -4
- package/dist/lib/browser/meta.json +1 -1
- package/dist/lib/node/index.cjs +64 -178
- package/dist/lib/node/index.cjs.map +4 -4
- package/dist/lib/node/meta.json +1 -1
- package/dist/types/src/automerge/automerge-host.d.ts +1 -8
- package/dist/types/src/automerge/automerge-host.d.ts.map +1 -1
- package/dist/types/src/automerge/index.d.ts +0 -1
- package/dist/types/src/automerge/index.d.ts.map +1 -1
- package/package.json +33 -33
- package/src/automerge/automerge-host.ts +8 -21
- package/src/automerge/index.ts +0 -1
- package/src/automerge/storage-adapter.test.ts +103 -139
- package/dist/types/src/automerge/automerge-storage-adapter.d.ts +0 -16
- package/dist/types/src/automerge/automerge-storage-adapter.d.ts.map +0 -1
- package/dist/types/src/automerge/automerge-storage/342/200/223wrapper.d.ts +0 -25
- package/dist/types/src/automerge/automerge-storage/342/200/223wrapper.d.ts.map +0 -1
- package/dist/types/src/automerge/migrations.d.ts +0 -7
- package/dist/types/src/automerge/migrations.d.ts.map +0 -1
- package/src/automerge/automerge-storage-adapter.ts +0 -103
- package/src/automerge/automerge-storage/342/200/223wrapper.ts +0 -59
- package/src/automerge/migrations.ts +0 -42
package/dist/lib/node/index.cjs
CHANGED
|
@@ -22,7 +22,6 @@ __export(node_exports, {
|
|
|
22
22
|
AuthStatus: () => import_chunk_QPCNQ4ZK.AuthStatus,
|
|
23
23
|
AutomergeDocumentLoaderImpl: () => AutomergeDocumentLoaderImpl,
|
|
24
24
|
AutomergeHost: () => AutomergeHost,
|
|
25
|
-
AutomergeStorageAdapter: () => AutomergeStorageAdapter,
|
|
26
25
|
DataServiceImpl: () => import_chunk_QPCNQ4ZK.DataServiceImpl,
|
|
27
26
|
LevelDBStorageAdapter: () => LevelDBStorageAdapter,
|
|
28
27
|
LocalHostNetworkAdapter: () => LocalHostNetworkAdapter,
|
|
@@ -71,23 +70,19 @@ var import_async3 = require("@dxos/async");
|
|
|
71
70
|
var import_automerge_repo3 = require("@dxos/automerge/automerge-repo");
|
|
72
71
|
var import_codec_protobuf = require("@dxos/codec-protobuf");
|
|
73
72
|
var import_invariant3 = require("@dxos/invariant");
|
|
74
|
-
var import_automerge_repo_storage_indexeddb = require("@dxos/automerge/automerge-repo-storage-indexeddb");
|
|
75
|
-
var import_log3 = require("@dxos/log");
|
|
76
|
-
var import_random_access_storage = require("@dxos/random-access-storage");
|
|
77
|
-
var import_util2 = require("@dxos/util");
|
|
78
73
|
var import_async4 = require("@dxos/async");
|
|
79
74
|
var import_context4 = require("@dxos/context");
|
|
80
75
|
var import_debug = require("@dxos/debug");
|
|
81
76
|
var import_invariant4 = require("@dxos/invariant");
|
|
82
|
-
var
|
|
77
|
+
var import_log3 = require("@dxos/log");
|
|
83
78
|
var import_tracing2 = require("@dxos/tracing");
|
|
84
79
|
var import_automerge_repo4 = require("@dxos/automerge/automerge-repo");
|
|
85
80
|
var import_context5 = require("@dxos/context");
|
|
86
81
|
var import_invariant5 = require("@dxos/invariant");
|
|
87
82
|
var import_keys2 = require("@dxos/keys");
|
|
88
|
-
var
|
|
83
|
+
var import_log4 = require("@dxos/log");
|
|
89
84
|
var import_teleport_extension_automerge_replicator = require("@dxos/teleport-extension-automerge-replicator");
|
|
90
|
-
var
|
|
85
|
+
var import_util2 = require("@dxos/util");
|
|
91
86
|
function _ts_decorate(decorators, target, key, desc) {
|
|
92
87
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
93
88
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -608,108 +603,6 @@ var LocalHostNetworkAdapter = class extends import_automerge_repo3.NetworkAdapte
|
|
|
608
603
|
return id;
|
|
609
604
|
}
|
|
610
605
|
};
|
|
611
|
-
var AutomergeStorageAdapter = class {
|
|
612
|
-
constructor(_directory) {
|
|
613
|
-
this._directory = _directory;
|
|
614
|
-
this._state = "opened";
|
|
615
|
-
}
|
|
616
|
-
async load(key) {
|
|
617
|
-
if (this._state !== "opened") {
|
|
618
|
-
return void 0;
|
|
619
|
-
}
|
|
620
|
-
const filename = this._getFilename(key);
|
|
621
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
622
|
-
const { size } = await file.stat();
|
|
623
|
-
if (!size || size === 0) {
|
|
624
|
-
return void 0;
|
|
625
|
-
}
|
|
626
|
-
const buffer = await file.read(0, size);
|
|
627
|
-
return (0, import_util2.bufferToArray)(buffer);
|
|
628
|
-
}
|
|
629
|
-
async save(key, data) {
|
|
630
|
-
if (this._state !== "opened") {
|
|
631
|
-
return void 0;
|
|
632
|
-
}
|
|
633
|
-
const filename = this._getFilename(key);
|
|
634
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
635
|
-
await file.write(0, (0, import_util2.arrayToBuffer)(data));
|
|
636
|
-
await file.truncate?.(data.length);
|
|
637
|
-
await file.flush?.();
|
|
638
|
-
}
|
|
639
|
-
async remove(key) {
|
|
640
|
-
if (this._state !== "opened") {
|
|
641
|
-
return void 0;
|
|
642
|
-
}
|
|
643
|
-
const filename = this._getFilename(key);
|
|
644
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
645
|
-
await file.destroy();
|
|
646
|
-
}
|
|
647
|
-
async loadRange(keyPrefix) {
|
|
648
|
-
if (this._state !== "opened") {
|
|
649
|
-
return [];
|
|
650
|
-
}
|
|
651
|
-
const filename = this._getFilename(keyPrefix);
|
|
652
|
-
const entries = await this._directory.list();
|
|
653
|
-
return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
654
|
-
const file = this._directory.getOrCreateFile(entry);
|
|
655
|
-
const { size } = await file.stat();
|
|
656
|
-
const buffer = await file.read(0, size);
|
|
657
|
-
return {
|
|
658
|
-
key: this._getKeyFromFilename(entry),
|
|
659
|
-
data: (0, import_util2.bufferToArray)(buffer)
|
|
660
|
-
};
|
|
661
|
-
}));
|
|
662
|
-
}
|
|
663
|
-
async removeRange(keyPrefix) {
|
|
664
|
-
if (this._state !== "opened") {
|
|
665
|
-
return void 0;
|
|
666
|
-
}
|
|
667
|
-
const filename = this._getFilename(keyPrefix);
|
|
668
|
-
const entries = await this._directory.list();
|
|
669
|
-
await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
670
|
-
const file = this._directory.getOrCreateFile(entry);
|
|
671
|
-
await file.destroy();
|
|
672
|
-
}));
|
|
673
|
-
}
|
|
674
|
-
async close() {
|
|
675
|
-
this._state = "closed";
|
|
676
|
-
}
|
|
677
|
-
_getFilename(key) {
|
|
678
|
-
return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
|
|
679
|
-
}
|
|
680
|
-
_getKeyFromFilename(filename) {
|
|
681
|
-
return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
|
|
682
|
-
}
|
|
683
|
-
};
|
|
684
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/migrations.ts";
|
|
685
|
-
var levelMigration = async ({ db, directory }) => {
|
|
686
|
-
const isNewLevel = !await db.iterator({
|
|
687
|
-
...encodingOptions
|
|
688
|
-
}).next();
|
|
689
|
-
if (!isNewLevel) {
|
|
690
|
-
return;
|
|
691
|
-
}
|
|
692
|
-
const oldStorageAdapter = directory.type === import_random_access_storage.StorageType.IDB ? new import_automerge_repo_storage_indexeddb.IndexedDBStorageAdapter(directory.path, "data") : new AutomergeStorageAdapter(directory);
|
|
693
|
-
const chunks = await oldStorageAdapter.loadRange([]);
|
|
694
|
-
if (chunks.length === 0) {
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
const batch = db.batch();
|
|
698
|
-
import_log3.log.info("found chunks on old storage adapter", {
|
|
699
|
-
chunks: chunks.length
|
|
700
|
-
}, {
|
|
701
|
-
F: __dxlog_file3,
|
|
702
|
-
L: 37,
|
|
703
|
-
S: void 0,
|
|
704
|
-
C: (f, a) => f(...a)
|
|
705
|
-
});
|
|
706
|
-
for (const { key, data } of await oldStorageAdapter.loadRange([])) {
|
|
707
|
-
data && batch.put(key, data, {
|
|
708
|
-
...encodingOptions
|
|
709
|
-
});
|
|
710
|
-
}
|
|
711
|
-
await batch.write();
|
|
712
|
-
};
|
|
713
606
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
714
607
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
715
608
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
@@ -720,31 +613,25 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
720
613
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
721
614
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
722
615
|
}
|
|
723
|
-
var
|
|
616
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
724
617
|
var AutomergeHost = class {
|
|
725
|
-
constructor({
|
|
618
|
+
constructor({ db, indexMetadataStore }) {
|
|
726
619
|
this._ctx = new import_context.Context();
|
|
727
620
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
728
621
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
729
622
|
});
|
|
730
623
|
this._requestedDocs = /* @__PURE__ */ new Set();
|
|
731
|
-
this._directory = directory;
|
|
732
|
-
this._db = db;
|
|
733
|
-
this._indexMetadataStore = indexMetadataStore;
|
|
734
|
-
}
|
|
735
|
-
async open() {
|
|
736
|
-
this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
|
|
737
|
-
this._directory && await levelMigration({
|
|
738
|
-
db: this._db,
|
|
739
|
-
directory: this._directory
|
|
740
|
-
});
|
|
741
624
|
this._storage = new LevelDBStorageAdapter({
|
|
742
|
-
db
|
|
625
|
+
db,
|
|
743
626
|
callbacks: {
|
|
744
627
|
beforeSave: async (params) => this._beforeSave(params),
|
|
745
628
|
afterSave: async () => this._afterSave()
|
|
746
629
|
}
|
|
747
630
|
});
|
|
631
|
+
this._indexMetadataStore = indexMetadataStore;
|
|
632
|
+
}
|
|
633
|
+
async open() {
|
|
634
|
+
this._peerId = `host-${import_keys.PublicKey.random().toHex()}`;
|
|
748
635
|
await this._storage.open?.();
|
|
749
636
|
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
750
637
|
this._repo = new import_automerge_repo.Repo({
|
|
@@ -797,8 +684,8 @@ var AutomergeHost = class {
|
|
|
797
684
|
documentId,
|
|
798
685
|
isRequested
|
|
799
686
|
}, {
|
|
800
|
-
F:
|
|
801
|
-
L:
|
|
687
|
+
F: __dxlog_file3,
|
|
688
|
+
L: 143,
|
|
802
689
|
S: this,
|
|
803
690
|
C: (f, a) => f(...a)
|
|
804
691
|
});
|
|
@@ -883,8 +770,8 @@ var AutomergeHost = class {
|
|
|
883
770
|
async flush({ states }) {
|
|
884
771
|
await Promise.all(states?.map(async ({ heads, documentId }) => {
|
|
885
772
|
(0, import_invariant.invariant)(heads, "heads are required for flush", {
|
|
886
|
-
F:
|
|
887
|
-
L:
|
|
773
|
+
F: __dxlog_file3,
|
|
774
|
+
L: 237,
|
|
888
775
|
S: this,
|
|
889
776
|
A: [
|
|
890
777
|
"heads",
|
|
@@ -962,7 +849,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
962
849
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
963
850
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
964
851
|
}
|
|
965
|
-
var
|
|
852
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
|
|
966
853
|
var AutomergeDocumentLoaderImpl = class {
|
|
967
854
|
constructor(_spaceId, _repo, _spaceKey) {
|
|
968
855
|
this._spaceId = _spaceId;
|
|
@@ -984,10 +871,10 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
984
871
|
return;
|
|
985
872
|
}
|
|
986
873
|
if (!spaceState.rootUrl) {
|
|
987
|
-
|
|
874
|
+
import_log3.log.error("Database opened with no rootUrl", {
|
|
988
875
|
spaceId: this._spaceId
|
|
989
876
|
}, {
|
|
990
|
-
F:
|
|
877
|
+
F: __dxlog_file4,
|
|
991
878
|
L: 72,
|
|
992
879
|
S: this,
|
|
993
880
|
C: (f, a) => f(...a)
|
|
@@ -997,7 +884,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
997
884
|
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
998
885
|
const doc = existingDocHandle.docSync();
|
|
999
886
|
(0, import_invariant4.invariant)(doc, void 0, {
|
|
1000
|
-
F:
|
|
887
|
+
F: __dxlog_file4,
|
|
1001
888
|
L: 77,
|
|
1002
889
|
S: this,
|
|
1003
890
|
A: [
|
|
@@ -1019,7 +906,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1019
906
|
const urlsToLoad = {};
|
|
1020
907
|
for (const objectId of objectIds) {
|
|
1021
908
|
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1022
|
-
F:
|
|
909
|
+
F: __dxlog_file4,
|
|
1023
910
|
L: 90,
|
|
1024
911
|
S: this,
|
|
1025
912
|
A: [
|
|
@@ -1032,7 +919,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1032
919
|
}
|
|
1033
920
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
1034
921
|
(0, import_invariant4.invariant)(spaceRootDoc, void 0, {
|
|
1035
|
-
F:
|
|
922
|
+
F: __dxlog_file4,
|
|
1036
923
|
L: 95,
|
|
1037
924
|
S: this,
|
|
1038
925
|
A: [
|
|
@@ -1043,10 +930,10 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1043
930
|
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
1044
931
|
if (documentUrl == null) {
|
|
1045
932
|
this._objectsPendingDocumentLoad.add(objectId);
|
|
1046
|
-
|
|
933
|
+
import_log3.log.info("loading delayed until object links are initialized", {
|
|
1047
934
|
objectId
|
|
1048
935
|
}, {
|
|
1049
|
-
F:
|
|
936
|
+
F: __dxlog_file4,
|
|
1050
937
|
L: 99,
|
|
1051
938
|
S: this,
|
|
1052
939
|
C: (f, a) => f(...a)
|
|
@@ -1070,7 +957,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1070
957
|
}
|
|
1071
958
|
getSpaceRootDocHandle() {
|
|
1072
959
|
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1073
|
-
F:
|
|
960
|
+
F: __dxlog_file4,
|
|
1074
961
|
L: 122,
|
|
1075
962
|
S: this,
|
|
1076
963
|
A: [
|
|
@@ -1082,7 +969,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1082
969
|
}
|
|
1083
970
|
createDocumentForObject(objectId) {
|
|
1084
971
|
(0, import_invariant4.invariant)(this._spaceRootDocHandle, void 0, {
|
|
1085
|
-
F:
|
|
972
|
+
F: __dxlog_file4,
|
|
1086
973
|
L: 127,
|
|
1087
974
|
S: this,
|
|
1088
975
|
A: [
|
|
@@ -1121,11 +1008,11 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1121
1008
|
};
|
|
1122
1009
|
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
1123
1010
|
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
1124
|
-
|
|
1011
|
+
import_log3.log.warn("object already inlined in a different document, ignoring the link", {
|
|
1125
1012
|
...logMeta,
|
|
1126
1013
|
actualDocumentUrl: objectDocumentHandle.url
|
|
1127
1014
|
}, {
|
|
1128
|
-
F:
|
|
1015
|
+
F: __dxlog_file4,
|
|
1129
1016
|
L: 157,
|
|
1130
1017
|
S: this,
|
|
1131
1018
|
C: (f, a) => f(...a)
|
|
@@ -1133,8 +1020,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1133
1020
|
continue;
|
|
1134
1021
|
}
|
|
1135
1022
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1136
|
-
|
|
1137
|
-
F:
|
|
1023
|
+
import_log3.log.warn("object document was already loaded", logMeta, {
|
|
1024
|
+
F: __dxlog_file4,
|
|
1138
1025
|
L: 164,
|
|
1139
1026
|
S: this,
|
|
1140
1027
|
C: (f, a) => f(...a)
|
|
@@ -1142,8 +1029,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1142
1029
|
continue;
|
|
1143
1030
|
}
|
|
1144
1031
|
const handle = this._repo.find(automergeUrl);
|
|
1145
|
-
|
|
1146
|
-
F:
|
|
1032
|
+
import_log3.log.debug("document loading triggered", logMeta, {
|
|
1033
|
+
F: __dxlog_file4,
|
|
1147
1034
|
L: 168,
|
|
1148
1035
|
S: this,
|
|
1149
1036
|
C: (f, a) => f(...a)
|
|
@@ -1162,11 +1049,11 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1162
1049
|
break;
|
|
1163
1050
|
} catch (err) {
|
|
1164
1051
|
if (`${err}`.includes("Timeout")) {
|
|
1165
|
-
|
|
1052
|
+
import_log3.log.info("wraparound", {
|
|
1166
1053
|
id: docHandle.documentId,
|
|
1167
1054
|
state: docHandle.state
|
|
1168
1055
|
}, {
|
|
1169
|
-
F:
|
|
1056
|
+
F: __dxlog_file4,
|
|
1170
1057
|
L: 184,
|
|
1171
1058
|
S: this,
|
|
1172
1059
|
C: (f, a) => f(...a)
|
|
@@ -1207,8 +1094,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1207
1094
|
docUrl: handle.url
|
|
1208
1095
|
};
|
|
1209
1096
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1210
|
-
|
|
1211
|
-
F:
|
|
1097
|
+
import_log3.log.info("document loaded after all listeners were removed", logMeta, {
|
|
1098
|
+
F: __dxlog_file4,
|
|
1212
1099
|
L: 220,
|
|
1213
1100
|
S: this,
|
|
1214
1101
|
C: (f, a) => f(...a)
|
|
@@ -1217,8 +1104,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1217
1104
|
}
|
|
1218
1105
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1219
1106
|
if (objectDocHandle?.url !== handle.url) {
|
|
1220
|
-
|
|
1221
|
-
F:
|
|
1107
|
+
import_log3.log.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1108
|
+
F: __dxlog_file4,
|
|
1222
1109
|
L: 225,
|
|
1223
1110
|
S: this,
|
|
1224
1111
|
C: (f, a) => f(...a)
|
|
@@ -1231,13 +1118,13 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1231
1118
|
});
|
|
1232
1119
|
} catch (err) {
|
|
1233
1120
|
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1234
|
-
|
|
1121
|
+
import_log3.log.warn("failed to load a document", {
|
|
1235
1122
|
objectId,
|
|
1236
1123
|
automergeUrl: handle.url,
|
|
1237
1124
|
retryLoading: shouldRetryLoading,
|
|
1238
1125
|
err
|
|
1239
1126
|
}, {
|
|
1240
|
-
F:
|
|
1127
|
+
F: __dxlog_file4,
|
|
1241
1128
|
L: 231,
|
|
1242
1129
|
S: this,
|
|
1243
1130
|
C: (f, a) => f(...a)
|
|
@@ -1256,12 +1143,12 @@ _ts_decorate3([
|
|
|
1256
1143
|
AutomergeDocumentLoaderImpl = _ts_decorate3([
|
|
1257
1144
|
import_tracing2.trace.resource()
|
|
1258
1145
|
], AutomergeDocumentLoaderImpl);
|
|
1259
|
-
var
|
|
1146
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
1260
1147
|
var MeshEchoReplicator = class {
|
|
1261
1148
|
constructor() {
|
|
1262
1149
|
this._connections = /* @__PURE__ */ new Set();
|
|
1263
1150
|
this._connectionsPerPeer = /* @__PURE__ */ new Map();
|
|
1264
|
-
this._authorizedDevices = new
|
|
1151
|
+
this._authorizedDevices = new import_util2.ComplexMap(import_keys2.PublicKey.hash);
|
|
1265
1152
|
this._context = null;
|
|
1266
1153
|
}
|
|
1267
1154
|
async connect(context) {
|
|
@@ -1277,7 +1164,7 @@ var MeshEchoReplicator = class {
|
|
|
1277
1164
|
}
|
|
1278
1165
|
createExtension() {
|
|
1279
1166
|
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1280
|
-
F:
|
|
1167
|
+
F: __dxlog_file5,
|
|
1281
1168
|
L: 54,
|
|
1282
1169
|
S: this,
|
|
1283
1170
|
A: [
|
|
@@ -1288,16 +1175,16 @@ var MeshEchoReplicator = class {
|
|
|
1288
1175
|
const connection = new MeshReplicatorConnection({
|
|
1289
1176
|
ownPeerId: this._context.peerId,
|
|
1290
1177
|
onRemoteConnected: async () => {
|
|
1291
|
-
(0,
|
|
1178
|
+
(0, import_log4.log)("onRemoteConnected", {
|
|
1292
1179
|
peerId: connection.peerId
|
|
1293
1180
|
}, {
|
|
1294
|
-
F:
|
|
1181
|
+
F: __dxlog_file5,
|
|
1295
1182
|
L: 59,
|
|
1296
1183
|
S: this,
|
|
1297
1184
|
C: (f, a) => f(...a)
|
|
1298
1185
|
});
|
|
1299
1186
|
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1300
|
-
F:
|
|
1187
|
+
F: __dxlog_file5,
|
|
1301
1188
|
L: 60,
|
|
1302
1189
|
S: this,
|
|
1303
1190
|
A: [
|
|
@@ -1314,10 +1201,10 @@ var MeshEchoReplicator = class {
|
|
|
1314
1201
|
}
|
|
1315
1202
|
},
|
|
1316
1203
|
onRemoteDisconnected: async () => {
|
|
1317
|
-
(0,
|
|
1204
|
+
(0, import_log4.log)("onRemoteDisconnected", {
|
|
1318
1205
|
peerId: connection.peerId
|
|
1319
1206
|
}, {
|
|
1320
|
-
F:
|
|
1207
|
+
F: __dxlog_file5,
|
|
1321
1208
|
L: 71,
|
|
1322
1209
|
S: this,
|
|
1323
1210
|
C: (f, a) => f(...a)
|
|
@@ -1328,17 +1215,17 @@ var MeshEchoReplicator = class {
|
|
|
1328
1215
|
this._connections.delete(connection);
|
|
1329
1216
|
},
|
|
1330
1217
|
shouldAdvertize: async (params) => {
|
|
1331
|
-
(0,
|
|
1218
|
+
(0, import_log4.log)("shouldAdvertize", {
|
|
1332
1219
|
peerId: connection.peerId,
|
|
1333
1220
|
documentId: params.documentId
|
|
1334
1221
|
}, {
|
|
1335
|
-
F:
|
|
1222
|
+
F: __dxlog_file5,
|
|
1336
1223
|
L: 78,
|
|
1337
1224
|
S: this,
|
|
1338
1225
|
C: (f, a) => f(...a)
|
|
1339
1226
|
});
|
|
1340
1227
|
(0, import_invariant5.invariant)(this._context, void 0, {
|
|
1341
|
-
F:
|
|
1228
|
+
F: __dxlog_file5,
|
|
1342
1229
|
L: 79,
|
|
1343
1230
|
S: this,
|
|
1344
1231
|
A: [
|
|
@@ -1349,11 +1236,11 @@ var MeshEchoReplicator = class {
|
|
|
1349
1236
|
try {
|
|
1350
1237
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1351
1238
|
if (!spaceKey) {
|
|
1352
|
-
(0,
|
|
1239
|
+
(0, import_log4.log)("space key not found for share policy check", {
|
|
1353
1240
|
peerId: connection.peerId,
|
|
1354
1241
|
documentId: params.documentId
|
|
1355
1242
|
}, {
|
|
1356
|
-
F:
|
|
1243
|
+
F: __dxlog_file5,
|
|
1357
1244
|
L: 83,
|
|
1358
1245
|
S: this,
|
|
1359
1246
|
C: (f, a) => f(...a)
|
|
@@ -1362,11 +1249,11 @@ var MeshEchoReplicator = class {
|
|
|
1362
1249
|
}
|
|
1363
1250
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1364
1251
|
if (!connection.remoteDeviceKey) {
|
|
1365
|
-
(0,
|
|
1252
|
+
(0, import_log4.log)("device key not found for share policy check", {
|
|
1366
1253
|
peerId: connection.peerId,
|
|
1367
1254
|
documentId: params.documentId
|
|
1368
1255
|
}, {
|
|
1369
|
-
F:
|
|
1256
|
+
F: __dxlog_file5,
|
|
1370
1257
|
L: 93,
|
|
1371
1258
|
S: this,
|
|
1372
1259
|
C: (f, a) => f(...a)
|
|
@@ -1374,7 +1261,7 @@ var MeshEchoReplicator = class {
|
|
|
1374
1261
|
return false;
|
|
1375
1262
|
}
|
|
1376
1263
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1377
|
-
(0,
|
|
1264
|
+
(0, import_log4.log)("share policy check", {
|
|
1378
1265
|
localPeer: this._context.peerId,
|
|
1379
1266
|
remotePeer: connection.peerId,
|
|
1380
1267
|
documentId: params.documentId,
|
|
@@ -1382,15 +1269,15 @@ var MeshEchoReplicator = class {
|
|
|
1382
1269
|
spaceKey,
|
|
1383
1270
|
isAuthorized
|
|
1384
1271
|
}, {
|
|
1385
|
-
F:
|
|
1272
|
+
F: __dxlog_file5,
|
|
1386
1273
|
L: 101,
|
|
1387
1274
|
S: this,
|
|
1388
1275
|
C: (f, a) => f(...a)
|
|
1389
1276
|
});
|
|
1390
1277
|
return isAuthorized;
|
|
1391
1278
|
} catch (err) {
|
|
1392
|
-
|
|
1393
|
-
F:
|
|
1279
|
+
import_log4.log.catch(err, void 0, {
|
|
1280
|
+
F: __dxlog_file5,
|
|
1394
1281
|
L: 111,
|
|
1395
1282
|
S: this,
|
|
1396
1283
|
C: (f, a) => f(...a)
|
|
@@ -1403,16 +1290,16 @@ var MeshEchoReplicator = class {
|
|
|
1403
1290
|
return connection.replicatorExtension;
|
|
1404
1291
|
}
|
|
1405
1292
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1406
|
-
(0,
|
|
1293
|
+
(0, import_log4.log)("authorizeDevice", {
|
|
1407
1294
|
spaceKey,
|
|
1408
1295
|
deviceKey
|
|
1409
1296
|
}, {
|
|
1410
|
-
F:
|
|
1297
|
+
F: __dxlog_file5,
|
|
1411
1298
|
L: 122,
|
|
1412
1299
|
S: this,
|
|
1413
1300
|
C: (f, a) => f(...a)
|
|
1414
1301
|
});
|
|
1415
|
-
(0,
|
|
1302
|
+
(0, import_util2.defaultMap)(this._authorizedDevices, spaceKey, () => new import_util2.ComplexSet(import_keys2.PublicKey.hash)).add(deviceKey);
|
|
1416
1303
|
}
|
|
1417
1304
|
};
|
|
1418
1305
|
var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
@@ -1444,12 +1331,12 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1444
1331
|
onStartReplication: async (info, remotePeerId) => {
|
|
1445
1332
|
this.remoteDeviceKey = remotePeerId;
|
|
1446
1333
|
this._remotePeerId = info.id;
|
|
1447
|
-
(0,
|
|
1334
|
+
(0, import_log4.log)("onStartReplication", {
|
|
1448
1335
|
id: info.id,
|
|
1449
1336
|
thisPeerId: this.peerId,
|
|
1450
1337
|
remotePeerId: remotePeerId.toHex()
|
|
1451
1338
|
}, {
|
|
1452
|
-
F:
|
|
1339
|
+
F: __dxlog_file5,
|
|
1453
1340
|
L: 187,
|
|
1454
1341
|
S: this,
|
|
1455
1342
|
C: (f, a) => f(...a)
|
|
@@ -1473,7 +1360,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1473
1360
|
}
|
|
1474
1361
|
get peerId() {
|
|
1475
1362
|
(0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1476
|
-
F:
|
|
1363
|
+
F: __dxlog_file5,
|
|
1477
1364
|
L: 210,
|
|
1478
1365
|
S: this,
|
|
1479
1366
|
A: [
|
|
@@ -1492,7 +1379,7 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1492
1379
|
*/
|
|
1493
1380
|
async enable() {
|
|
1494
1381
|
(0, import_invariant5.invariant)(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1495
|
-
F:
|
|
1382
|
+
F: __dxlog_file5,
|
|
1496
1383
|
L: 223,
|
|
1497
1384
|
S: this,
|
|
1498
1385
|
A: [
|
|
@@ -1515,7 +1402,6 @@ var MeshReplicatorConnection = class extends import_context5.Resource {
|
|
|
1515
1402
|
AuthStatus,
|
|
1516
1403
|
AutomergeDocumentLoaderImpl,
|
|
1517
1404
|
AutomergeHost,
|
|
1518
|
-
AutomergeStorageAdapter,
|
|
1519
1405
|
DataServiceImpl,
|
|
1520
1406
|
LevelDBStorageAdapter,
|
|
1521
1407
|
LocalHostNetworkAdapter,
|