@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
|
@@ -32,7 +32,7 @@ import { Repo } from "@dxos/automerge/automerge-repo";
|
|
|
32
32
|
import { Context } from "@dxos/context";
|
|
33
33
|
import { invariant as invariant3 } from "@dxos/invariant";
|
|
34
34
|
import { PublicKey } from "@dxos/keys";
|
|
35
|
-
import { log as
|
|
35
|
+
import { log as log2 } from "@dxos/log";
|
|
36
36
|
import { objectPointerCodec } from "@dxos/protocols";
|
|
37
37
|
import { trace } from "@dxos/tracing";
|
|
38
38
|
import { mapValues } from "@dxos/util";
|
|
@@ -573,118 +573,6 @@ var LocalHostNetworkAdapter = class extends NetworkAdapter2 {
|
|
|
573
573
|
}
|
|
574
574
|
};
|
|
575
575
|
|
|
576
|
-
// packages/core/echo/echo-pipeline/src/automerge/migrations.ts
|
|
577
|
-
import { IndexedDBStorageAdapter } from "@dxos/automerge/automerge-repo-storage-indexeddb";
|
|
578
|
-
import { log as log2 } from "@dxos/log";
|
|
579
|
-
import { StorageType } from "@dxos/random-access-storage";
|
|
580
|
-
|
|
581
|
-
// packages/core/echo/echo-pipeline/src/automerge/automerge-storage-adapter.ts
|
|
582
|
-
import { arrayToBuffer, bufferToArray } from "@dxos/util";
|
|
583
|
-
var AutomergeStorageAdapter = class {
|
|
584
|
-
constructor(_directory) {
|
|
585
|
-
this._directory = _directory;
|
|
586
|
-
this._state = "opened";
|
|
587
|
-
}
|
|
588
|
-
async load(key) {
|
|
589
|
-
if (this._state !== "opened") {
|
|
590
|
-
return void 0;
|
|
591
|
-
}
|
|
592
|
-
const filename = this._getFilename(key);
|
|
593
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
594
|
-
const { size } = await file.stat();
|
|
595
|
-
if (!size || size === 0) {
|
|
596
|
-
return void 0;
|
|
597
|
-
}
|
|
598
|
-
const buffer = await file.read(0, size);
|
|
599
|
-
return bufferToArray(buffer);
|
|
600
|
-
}
|
|
601
|
-
async save(key, data) {
|
|
602
|
-
if (this._state !== "opened") {
|
|
603
|
-
return void 0;
|
|
604
|
-
}
|
|
605
|
-
const filename = this._getFilename(key);
|
|
606
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
607
|
-
await file.write(0, arrayToBuffer(data));
|
|
608
|
-
await file.truncate?.(data.length);
|
|
609
|
-
await file.flush?.();
|
|
610
|
-
}
|
|
611
|
-
async remove(key) {
|
|
612
|
-
if (this._state !== "opened") {
|
|
613
|
-
return void 0;
|
|
614
|
-
}
|
|
615
|
-
const filename = this._getFilename(key);
|
|
616
|
-
const file = this._directory.getOrCreateFile(filename);
|
|
617
|
-
await file.destroy();
|
|
618
|
-
}
|
|
619
|
-
async loadRange(keyPrefix) {
|
|
620
|
-
if (this._state !== "opened") {
|
|
621
|
-
return [];
|
|
622
|
-
}
|
|
623
|
-
const filename = this._getFilename(keyPrefix);
|
|
624
|
-
const entries = await this._directory.list();
|
|
625
|
-
return Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
626
|
-
const file = this._directory.getOrCreateFile(entry);
|
|
627
|
-
const { size } = await file.stat();
|
|
628
|
-
const buffer = await file.read(0, size);
|
|
629
|
-
return {
|
|
630
|
-
key: this._getKeyFromFilename(entry),
|
|
631
|
-
data: bufferToArray(buffer)
|
|
632
|
-
};
|
|
633
|
-
}));
|
|
634
|
-
}
|
|
635
|
-
async removeRange(keyPrefix) {
|
|
636
|
-
if (this._state !== "opened") {
|
|
637
|
-
return void 0;
|
|
638
|
-
}
|
|
639
|
-
const filename = this._getFilename(keyPrefix);
|
|
640
|
-
const entries = await this._directory.list();
|
|
641
|
-
await Promise.all(entries.filter((entry) => entry.startsWith(filename)).map(async (entry) => {
|
|
642
|
-
const file = this._directory.getOrCreateFile(entry);
|
|
643
|
-
await file.destroy();
|
|
644
|
-
}));
|
|
645
|
-
}
|
|
646
|
-
async close() {
|
|
647
|
-
this._state = "closed";
|
|
648
|
-
}
|
|
649
|
-
_getFilename(key) {
|
|
650
|
-
return key.map((k) => k.replaceAll("%", "%25").replaceAll("-", "%2D")).join("-");
|
|
651
|
-
}
|
|
652
|
-
_getKeyFromFilename(filename) {
|
|
653
|
-
return filename.split("-").map((k) => k.replaceAll("%2D", "-").replaceAll("%25", "%"));
|
|
654
|
-
}
|
|
655
|
-
};
|
|
656
|
-
|
|
657
|
-
// packages/core/echo/echo-pipeline/src/automerge/migrations.ts
|
|
658
|
-
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/migrations.ts";
|
|
659
|
-
var levelMigration = async ({ db, directory }) => {
|
|
660
|
-
const isNewLevel = !await db.iterator({
|
|
661
|
-
...encodingOptions
|
|
662
|
-
}).next();
|
|
663
|
-
if (!isNewLevel) {
|
|
664
|
-
return;
|
|
665
|
-
}
|
|
666
|
-
const oldStorageAdapter = directory.type === StorageType.IDB ? new IndexedDBStorageAdapter(directory.path, "data") : new AutomergeStorageAdapter(directory);
|
|
667
|
-
const chunks = await oldStorageAdapter.loadRange([]);
|
|
668
|
-
if (chunks.length === 0) {
|
|
669
|
-
return;
|
|
670
|
-
}
|
|
671
|
-
const batch = db.batch();
|
|
672
|
-
log2.info("found chunks on old storage adapter", {
|
|
673
|
-
chunks: chunks.length
|
|
674
|
-
}, {
|
|
675
|
-
F: __dxlog_file3,
|
|
676
|
-
L: 37,
|
|
677
|
-
S: void 0,
|
|
678
|
-
C: (f, a) => f(...a)
|
|
679
|
-
});
|
|
680
|
-
for (const { key, data } of await oldStorageAdapter.loadRange([])) {
|
|
681
|
-
data && batch.put(key, data, {
|
|
682
|
-
...encodingOptions
|
|
683
|
-
});
|
|
684
|
-
}
|
|
685
|
-
await batch.write();
|
|
686
|
-
};
|
|
687
|
-
|
|
688
576
|
// packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts
|
|
689
577
|
function _ts_decorate2(decorators, target, key, desc) {
|
|
690
578
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -696,31 +584,25 @@ function _ts_decorate2(decorators, target, key, desc) {
|
|
|
696
584
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
697
585
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
698
586
|
}
|
|
699
|
-
var
|
|
587
|
+
var __dxlog_file3 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-host.ts";
|
|
700
588
|
var AutomergeHost = class {
|
|
701
|
-
constructor({
|
|
589
|
+
constructor({ db, indexMetadataStore }) {
|
|
702
590
|
this._ctx = new Context();
|
|
703
591
|
this._echoNetworkAdapter = new EchoNetworkAdapter({
|
|
704
592
|
getContainingSpaceForDocument: this._getContainingSpaceForDocument.bind(this)
|
|
705
593
|
});
|
|
706
594
|
this._requestedDocs = /* @__PURE__ */ new Set();
|
|
707
|
-
this._directory = directory;
|
|
708
|
-
this._db = db;
|
|
709
|
-
this._indexMetadataStore = indexMetadataStore;
|
|
710
|
-
}
|
|
711
|
-
async open() {
|
|
712
|
-
this._peerId = `host-${PublicKey.random().toHex()}`;
|
|
713
|
-
this._directory && await levelMigration({
|
|
714
|
-
db: this._db,
|
|
715
|
-
directory: this._directory
|
|
716
|
-
});
|
|
717
595
|
this._storage = new LevelDBStorageAdapter({
|
|
718
|
-
db
|
|
596
|
+
db,
|
|
719
597
|
callbacks: {
|
|
720
598
|
beforeSave: async (params) => this._beforeSave(params),
|
|
721
599
|
afterSave: async () => this._afterSave()
|
|
722
600
|
}
|
|
723
601
|
});
|
|
602
|
+
this._indexMetadataStore = indexMetadataStore;
|
|
603
|
+
}
|
|
604
|
+
async open() {
|
|
605
|
+
this._peerId = `host-${PublicKey.random().toHex()}`;
|
|
724
606
|
await this._storage.open?.();
|
|
725
607
|
this._clientNetwork = new LocalHostNetworkAdapter();
|
|
726
608
|
this._repo = new Repo({
|
|
@@ -768,13 +650,13 @@ var AutomergeHost = class {
|
|
|
768
650
|
const doc = this._repo.handles[documentId]?.docSync();
|
|
769
651
|
if (!doc) {
|
|
770
652
|
const isRequested = this._requestedDocs.has(`automerge:${documentId}`);
|
|
771
|
-
|
|
653
|
+
log2("doc share policy check", {
|
|
772
654
|
peerId,
|
|
773
655
|
documentId,
|
|
774
656
|
isRequested
|
|
775
657
|
}, {
|
|
776
|
-
F:
|
|
777
|
-
L:
|
|
658
|
+
F: __dxlog_file3,
|
|
659
|
+
L: 143,
|
|
778
660
|
S: this,
|
|
779
661
|
C: (f, a) => f(...a)
|
|
780
662
|
});
|
|
@@ -859,8 +741,8 @@ var AutomergeHost = class {
|
|
|
859
741
|
async flush({ states }) {
|
|
860
742
|
await Promise.all(states?.map(async ({ heads, documentId }) => {
|
|
861
743
|
invariant3(heads, "heads are required for flush", {
|
|
862
|
-
F:
|
|
863
|
-
L:
|
|
744
|
+
F: __dxlog_file3,
|
|
745
|
+
L: 237,
|
|
864
746
|
S: this,
|
|
865
747
|
A: [
|
|
866
748
|
"heads",
|
|
@@ -934,7 +816,7 @@ import { Event as Event2 } from "@dxos/async";
|
|
|
934
816
|
import { cancelWithContext } from "@dxos/context";
|
|
935
817
|
import { warnAfterTimeout } from "@dxos/debug";
|
|
936
818
|
import { invariant as invariant4 } from "@dxos/invariant";
|
|
937
|
-
import { log as
|
|
819
|
+
import { log as log3 } from "@dxos/log";
|
|
938
820
|
import { trace as trace2 } from "@dxos/tracing";
|
|
939
821
|
function _ts_decorate3(decorators, target, key, desc) {
|
|
940
822
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
@@ -946,7 +828,7 @@ function _ts_decorate3(decorators, target, key, desc) {
|
|
|
946
828
|
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
947
829
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
948
830
|
}
|
|
949
|
-
var
|
|
831
|
+
var __dxlog_file4 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/automerge-doc-loader.ts";
|
|
950
832
|
var AutomergeDocumentLoaderImpl = class {
|
|
951
833
|
constructor(_spaceId, _repo, _spaceKey) {
|
|
952
834
|
this._spaceId = _spaceId;
|
|
@@ -968,10 +850,10 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
968
850
|
return;
|
|
969
851
|
}
|
|
970
852
|
if (!spaceState.rootUrl) {
|
|
971
|
-
|
|
853
|
+
log3.error("Database opened with no rootUrl", {
|
|
972
854
|
spaceId: this._spaceId
|
|
973
855
|
}, {
|
|
974
|
-
F:
|
|
856
|
+
F: __dxlog_file4,
|
|
975
857
|
L: 72,
|
|
976
858
|
S: this,
|
|
977
859
|
C: (f, a) => f(...a)
|
|
@@ -981,7 +863,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
981
863
|
const existingDocHandle = await this._initDocHandle(ctx, spaceState.rootUrl);
|
|
982
864
|
const doc = existingDocHandle.docSync();
|
|
983
865
|
invariant4(doc, void 0, {
|
|
984
|
-
F:
|
|
866
|
+
F: __dxlog_file4,
|
|
985
867
|
L: 77,
|
|
986
868
|
S: this,
|
|
987
869
|
A: [
|
|
@@ -1003,7 +885,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1003
885
|
const urlsToLoad = {};
|
|
1004
886
|
for (const objectId of objectIds) {
|
|
1005
887
|
invariant4(this._spaceRootDocHandle, void 0, {
|
|
1006
|
-
F:
|
|
888
|
+
F: __dxlog_file4,
|
|
1007
889
|
L: 90,
|
|
1008
890
|
S: this,
|
|
1009
891
|
A: [
|
|
@@ -1016,7 +898,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1016
898
|
}
|
|
1017
899
|
const spaceRootDoc = this._spaceRootDocHandle.docSync();
|
|
1018
900
|
invariant4(spaceRootDoc, void 0, {
|
|
1019
|
-
F:
|
|
901
|
+
F: __dxlog_file4,
|
|
1020
902
|
L: 95,
|
|
1021
903
|
S: this,
|
|
1022
904
|
A: [
|
|
@@ -1027,10 +909,10 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1027
909
|
const documentUrl = (spaceRootDoc.links ?? {})[objectId];
|
|
1028
910
|
if (documentUrl == null) {
|
|
1029
911
|
this._objectsPendingDocumentLoad.add(objectId);
|
|
1030
|
-
|
|
912
|
+
log3.info("loading delayed until object links are initialized", {
|
|
1031
913
|
objectId
|
|
1032
914
|
}, {
|
|
1033
|
-
F:
|
|
915
|
+
F: __dxlog_file4,
|
|
1034
916
|
L: 99,
|
|
1035
917
|
S: this,
|
|
1036
918
|
C: (f, a) => f(...a)
|
|
@@ -1054,7 +936,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1054
936
|
}
|
|
1055
937
|
getSpaceRootDocHandle() {
|
|
1056
938
|
invariant4(this._spaceRootDocHandle, void 0, {
|
|
1057
|
-
F:
|
|
939
|
+
F: __dxlog_file4,
|
|
1058
940
|
L: 122,
|
|
1059
941
|
S: this,
|
|
1060
942
|
A: [
|
|
@@ -1066,7 +948,7 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1066
948
|
}
|
|
1067
949
|
createDocumentForObject(objectId) {
|
|
1068
950
|
invariant4(this._spaceRootDocHandle, void 0, {
|
|
1069
|
-
F:
|
|
951
|
+
F: __dxlog_file4,
|
|
1070
952
|
L: 127,
|
|
1071
953
|
S: this,
|
|
1072
954
|
A: [
|
|
@@ -1105,11 +987,11 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1105
987
|
};
|
|
1106
988
|
const objectDocumentHandle = this._objectDocumentHandles.get(objectId);
|
|
1107
989
|
if (objectDocumentHandle != null && objectDocumentHandle.url !== automergeUrl) {
|
|
1108
|
-
|
|
990
|
+
log3.warn("object already inlined in a different document, ignoring the link", {
|
|
1109
991
|
...logMeta,
|
|
1110
992
|
actualDocumentUrl: objectDocumentHandle.url
|
|
1111
993
|
}, {
|
|
1112
|
-
F:
|
|
994
|
+
F: __dxlog_file4,
|
|
1113
995
|
L: 157,
|
|
1114
996
|
S: this,
|
|
1115
997
|
C: (f, a) => f(...a)
|
|
@@ -1117,8 +999,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1117
999
|
continue;
|
|
1118
1000
|
}
|
|
1119
1001
|
if (objectDocumentHandle?.url === automergeUrl) {
|
|
1120
|
-
|
|
1121
|
-
F:
|
|
1002
|
+
log3.warn("object document was already loaded", logMeta, {
|
|
1003
|
+
F: __dxlog_file4,
|
|
1122
1004
|
L: 164,
|
|
1123
1005
|
S: this,
|
|
1124
1006
|
C: (f, a) => f(...a)
|
|
@@ -1126,8 +1008,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1126
1008
|
continue;
|
|
1127
1009
|
}
|
|
1128
1010
|
const handle = this._repo.find(automergeUrl);
|
|
1129
|
-
|
|
1130
|
-
F:
|
|
1011
|
+
log3.debug("document loading triggered", logMeta, {
|
|
1012
|
+
F: __dxlog_file4,
|
|
1131
1013
|
L: 168,
|
|
1132
1014
|
S: this,
|
|
1133
1015
|
C: (f, a) => f(...a)
|
|
@@ -1146,11 +1028,11 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1146
1028
|
break;
|
|
1147
1029
|
} catch (err) {
|
|
1148
1030
|
if (`${err}`.includes("Timeout")) {
|
|
1149
|
-
|
|
1031
|
+
log3.info("wraparound", {
|
|
1150
1032
|
id: docHandle.documentId,
|
|
1151
1033
|
state: docHandle.state
|
|
1152
1034
|
}, {
|
|
1153
|
-
F:
|
|
1035
|
+
F: __dxlog_file4,
|
|
1154
1036
|
L: 184,
|
|
1155
1037
|
S: this,
|
|
1156
1038
|
C: (f, a) => f(...a)
|
|
@@ -1191,8 +1073,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1191
1073
|
docUrl: handle.url
|
|
1192
1074
|
};
|
|
1193
1075
|
if (this.onObjectDocumentLoaded.listenerCount() === 0) {
|
|
1194
|
-
|
|
1195
|
-
F:
|
|
1076
|
+
log3.info("document loaded after all listeners were removed", logMeta, {
|
|
1077
|
+
F: __dxlog_file4,
|
|
1196
1078
|
L: 220,
|
|
1197
1079
|
S: this,
|
|
1198
1080
|
C: (f, a) => f(...a)
|
|
@@ -1201,8 +1083,8 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1201
1083
|
}
|
|
1202
1084
|
const objectDocHandle = this._objectDocumentHandles.get(objectId);
|
|
1203
1085
|
if (objectDocHandle?.url !== handle.url) {
|
|
1204
|
-
|
|
1205
|
-
F:
|
|
1086
|
+
log3.warn("object was rebound while a document was loading, discarding handle", logMeta, {
|
|
1087
|
+
F: __dxlog_file4,
|
|
1206
1088
|
L: 225,
|
|
1207
1089
|
S: this,
|
|
1208
1090
|
C: (f, a) => f(...a)
|
|
@@ -1215,13 +1097,13 @@ var AutomergeDocumentLoaderImpl = class {
|
|
|
1215
1097
|
});
|
|
1216
1098
|
} catch (err) {
|
|
1217
1099
|
const shouldRetryLoading = this.onObjectDocumentLoaded.listenerCount() > 0;
|
|
1218
|
-
|
|
1100
|
+
log3.warn("failed to load a document", {
|
|
1219
1101
|
objectId,
|
|
1220
1102
|
automergeUrl: handle.url,
|
|
1221
1103
|
retryLoading: shouldRetryLoading,
|
|
1222
1104
|
err
|
|
1223
1105
|
}, {
|
|
1224
|
-
F:
|
|
1106
|
+
F: __dxlog_file4,
|
|
1225
1107
|
L: 231,
|
|
1226
1108
|
S: this,
|
|
1227
1109
|
C: (f, a) => f(...a)
|
|
@@ -1246,10 +1128,10 @@ import { cbor as cbor2 } from "@dxos/automerge/automerge-repo";
|
|
|
1246
1128
|
import { Resource as Resource2 } from "@dxos/context";
|
|
1247
1129
|
import { invariant as invariant5 } from "@dxos/invariant";
|
|
1248
1130
|
import { PublicKey as PublicKey2 } from "@dxos/keys";
|
|
1249
|
-
import { log as
|
|
1131
|
+
import { log as log4 } from "@dxos/log";
|
|
1250
1132
|
import { AutomergeReplicator } from "@dxos/teleport-extension-automerge-replicator";
|
|
1251
1133
|
import { ComplexMap, ComplexSet, defaultMap } from "@dxos/util";
|
|
1252
|
-
var
|
|
1134
|
+
var __dxlog_file5 = "/home/runner/work/dxos/dxos/packages/core/echo/echo-pipeline/src/automerge/mesh-echo-replicator.ts";
|
|
1253
1135
|
var MeshEchoReplicator = class {
|
|
1254
1136
|
constructor() {
|
|
1255
1137
|
this._connections = /* @__PURE__ */ new Set();
|
|
@@ -1276,7 +1158,7 @@ var MeshEchoReplicator = class {
|
|
|
1276
1158
|
}
|
|
1277
1159
|
createExtension() {
|
|
1278
1160
|
invariant5(this._context, void 0, {
|
|
1279
|
-
F:
|
|
1161
|
+
F: __dxlog_file5,
|
|
1280
1162
|
L: 54,
|
|
1281
1163
|
S: this,
|
|
1282
1164
|
A: [
|
|
@@ -1287,16 +1169,16 @@ var MeshEchoReplicator = class {
|
|
|
1287
1169
|
const connection = new MeshReplicatorConnection({
|
|
1288
1170
|
ownPeerId: this._context.peerId,
|
|
1289
1171
|
onRemoteConnected: async () => {
|
|
1290
|
-
|
|
1172
|
+
log4("onRemoteConnected", {
|
|
1291
1173
|
peerId: connection.peerId
|
|
1292
1174
|
}, {
|
|
1293
|
-
F:
|
|
1175
|
+
F: __dxlog_file5,
|
|
1294
1176
|
L: 59,
|
|
1295
1177
|
S: this,
|
|
1296
1178
|
C: (f, a) => f(...a)
|
|
1297
1179
|
});
|
|
1298
1180
|
invariant5(this._context, void 0, {
|
|
1299
|
-
F:
|
|
1181
|
+
F: __dxlog_file5,
|
|
1300
1182
|
L: 60,
|
|
1301
1183
|
S: this,
|
|
1302
1184
|
A: [
|
|
@@ -1313,10 +1195,10 @@ var MeshEchoReplicator = class {
|
|
|
1313
1195
|
}
|
|
1314
1196
|
},
|
|
1315
1197
|
onRemoteDisconnected: async () => {
|
|
1316
|
-
|
|
1198
|
+
log4("onRemoteDisconnected", {
|
|
1317
1199
|
peerId: connection.peerId
|
|
1318
1200
|
}, {
|
|
1319
|
-
F:
|
|
1201
|
+
F: __dxlog_file5,
|
|
1320
1202
|
L: 71,
|
|
1321
1203
|
S: this,
|
|
1322
1204
|
C: (f, a) => f(...a)
|
|
@@ -1327,17 +1209,17 @@ var MeshEchoReplicator = class {
|
|
|
1327
1209
|
this._connections.delete(connection);
|
|
1328
1210
|
},
|
|
1329
1211
|
shouldAdvertize: async (params) => {
|
|
1330
|
-
|
|
1212
|
+
log4("shouldAdvertize", {
|
|
1331
1213
|
peerId: connection.peerId,
|
|
1332
1214
|
documentId: params.documentId
|
|
1333
1215
|
}, {
|
|
1334
|
-
F:
|
|
1216
|
+
F: __dxlog_file5,
|
|
1335
1217
|
L: 78,
|
|
1336
1218
|
S: this,
|
|
1337
1219
|
C: (f, a) => f(...a)
|
|
1338
1220
|
});
|
|
1339
1221
|
invariant5(this._context, void 0, {
|
|
1340
|
-
F:
|
|
1222
|
+
F: __dxlog_file5,
|
|
1341
1223
|
L: 79,
|
|
1342
1224
|
S: this,
|
|
1343
1225
|
A: [
|
|
@@ -1348,11 +1230,11 @@ var MeshEchoReplicator = class {
|
|
|
1348
1230
|
try {
|
|
1349
1231
|
const spaceKey = await this._context.getContainingSpaceForDocument(params.documentId);
|
|
1350
1232
|
if (!spaceKey) {
|
|
1351
|
-
|
|
1233
|
+
log4("space key not found for share policy check", {
|
|
1352
1234
|
peerId: connection.peerId,
|
|
1353
1235
|
documentId: params.documentId
|
|
1354
1236
|
}, {
|
|
1355
|
-
F:
|
|
1237
|
+
F: __dxlog_file5,
|
|
1356
1238
|
L: 83,
|
|
1357
1239
|
S: this,
|
|
1358
1240
|
C: (f, a) => f(...a)
|
|
@@ -1361,11 +1243,11 @@ var MeshEchoReplicator = class {
|
|
|
1361
1243
|
}
|
|
1362
1244
|
const authorizedDevices = this._authorizedDevices.get(spaceKey);
|
|
1363
1245
|
if (!connection.remoteDeviceKey) {
|
|
1364
|
-
|
|
1246
|
+
log4("device key not found for share policy check", {
|
|
1365
1247
|
peerId: connection.peerId,
|
|
1366
1248
|
documentId: params.documentId
|
|
1367
1249
|
}, {
|
|
1368
|
-
F:
|
|
1250
|
+
F: __dxlog_file5,
|
|
1369
1251
|
L: 93,
|
|
1370
1252
|
S: this,
|
|
1371
1253
|
C: (f, a) => f(...a)
|
|
@@ -1373,7 +1255,7 @@ var MeshEchoReplicator = class {
|
|
|
1373
1255
|
return false;
|
|
1374
1256
|
}
|
|
1375
1257
|
const isAuthorized = authorizedDevices?.has(connection.remoteDeviceKey) ?? false;
|
|
1376
|
-
|
|
1258
|
+
log4("share policy check", {
|
|
1377
1259
|
localPeer: this._context.peerId,
|
|
1378
1260
|
remotePeer: connection.peerId,
|
|
1379
1261
|
documentId: params.documentId,
|
|
@@ -1381,15 +1263,15 @@ var MeshEchoReplicator = class {
|
|
|
1381
1263
|
spaceKey,
|
|
1382
1264
|
isAuthorized
|
|
1383
1265
|
}, {
|
|
1384
|
-
F:
|
|
1266
|
+
F: __dxlog_file5,
|
|
1385
1267
|
L: 101,
|
|
1386
1268
|
S: this,
|
|
1387
1269
|
C: (f, a) => f(...a)
|
|
1388
1270
|
});
|
|
1389
1271
|
return isAuthorized;
|
|
1390
1272
|
} catch (err) {
|
|
1391
|
-
|
|
1392
|
-
F:
|
|
1273
|
+
log4.catch(err, void 0, {
|
|
1274
|
+
F: __dxlog_file5,
|
|
1393
1275
|
L: 111,
|
|
1394
1276
|
S: this,
|
|
1395
1277
|
C: (f, a) => f(...a)
|
|
@@ -1402,11 +1284,11 @@ var MeshEchoReplicator = class {
|
|
|
1402
1284
|
return connection.replicatorExtension;
|
|
1403
1285
|
}
|
|
1404
1286
|
authorizeDevice(spaceKey, deviceKey) {
|
|
1405
|
-
|
|
1287
|
+
log4("authorizeDevice", {
|
|
1406
1288
|
spaceKey,
|
|
1407
1289
|
deviceKey
|
|
1408
1290
|
}, {
|
|
1409
|
-
F:
|
|
1291
|
+
F: __dxlog_file5,
|
|
1410
1292
|
L: 122,
|
|
1411
1293
|
S: this,
|
|
1412
1294
|
C: (f, a) => f(...a)
|
|
@@ -1443,12 +1325,12 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1443
1325
|
onStartReplication: async (info, remotePeerId) => {
|
|
1444
1326
|
this.remoteDeviceKey = remotePeerId;
|
|
1445
1327
|
this._remotePeerId = info.id;
|
|
1446
|
-
|
|
1328
|
+
log4("onStartReplication", {
|
|
1447
1329
|
id: info.id,
|
|
1448
1330
|
thisPeerId: this.peerId,
|
|
1449
1331
|
remotePeerId: remotePeerId.toHex()
|
|
1450
1332
|
}, {
|
|
1451
|
-
F:
|
|
1333
|
+
F: __dxlog_file5,
|
|
1452
1334
|
L: 187,
|
|
1453
1335
|
S: this,
|
|
1454
1336
|
C: (f, a) => f(...a)
|
|
@@ -1472,7 +1354,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1472
1354
|
}
|
|
1473
1355
|
get peerId() {
|
|
1474
1356
|
invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1475
|
-
F:
|
|
1357
|
+
F: __dxlog_file5,
|
|
1476
1358
|
L: 210,
|
|
1477
1359
|
S: this,
|
|
1478
1360
|
A: [
|
|
@@ -1491,7 +1373,7 @@ var MeshReplicatorConnection = class extends Resource2 {
|
|
|
1491
1373
|
*/
|
|
1492
1374
|
async enable() {
|
|
1493
1375
|
invariant5(this._remotePeerId != null, "Remote peer has not connected yet.", {
|
|
1494
|
-
F:
|
|
1376
|
+
F: __dxlog_file5,
|
|
1495
1377
|
L: 223,
|
|
1496
1378
|
S: this,
|
|
1497
1379
|
A: [
|
|
@@ -1513,7 +1395,6 @@ export {
|
|
|
1513
1395
|
AuthStatus,
|
|
1514
1396
|
AutomergeDocumentLoaderImpl,
|
|
1515
1397
|
AutomergeHost,
|
|
1516
|
-
AutomergeStorageAdapter,
|
|
1517
1398
|
DataServiceImpl,
|
|
1518
1399
|
LevelDBStorageAdapter,
|
|
1519
1400
|
LocalHostNetworkAdapter,
|