@vrtmrz/livesync-commonlib 0.1.16 → 0.1.18
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/common/ConnectionString.js +9 -1
- package/dist/common/models/setting.const.d.ts +18 -0
- package/dist/common/models/setting.const.defaults.js +10 -1
- package/dist/common/models/setting.const.js +12 -0
- package/dist/common/models/setting.const.qr.js +3 -1
- package/dist/common/models/setting.p2p.d.ts +21 -0
- package/dist/common/models/setting.p2p.js +35 -0
- package/dist/common/models/setting.type.d.ts +11 -1
- package/dist/common/models/shared.definition.configNames.js +8 -0
- package/dist/common/models/tweak.definition.d.ts +2 -0
- package/dist/common/settingConstants.d.ts +2 -0
- package/dist/common/types.d.ts +5 -3
- package/dist/common/types.js +17 -1
- package/dist/common/utils.js +4 -1
- package/dist/interfaces/DatabaseFileAccess.d.ts +10 -0
- package/dist/managers/EntryManager/EntryManager.d.ts +1 -0
- package/dist/managers/EntryManager/EntryManager.js +4 -0
- package/dist/managers/EntryManager/EntryManagerImpls.d.ts +7 -0
- package/dist/managers/EntryManager/EntryManagerImpls.js +21 -3
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +1 -0
- package/dist/pouchdb/LiveSyncLocalDB.js +3 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +8 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.js +36 -8
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +2 -2
- package/dist/rpc/transports/TrysteroTransport.d.ts +2 -0
- package/dist/rpc/transports/TrysteroTransport.js +18 -2
- package/dist/rpc/transports/trysteroUtils.js +12 -1
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.d.ts +1 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.js +22 -4
- package/dist/worker/bgWorker.js +1 -1
- package/docs/conflict-resolution.md +2 -0
- package/docs/development.md +1 -1
- package/docs/p2p-transport-lifecycle.md +4 -2
- package/docs/proven-in-use.md +3 -1
- package/docs/releasing.md +2 -0
- package/docs/remote-configurations.md +2 -0
- package/package.json +1 -1
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
import { P2PConnectionPaths } from "../../common/models/setting.const.js";
|
|
2
|
+
import {
|
|
3
|
+
hasValidP2PTurnServerUrl,
|
|
4
|
+
normaliseP2PConnectionPath,
|
|
5
|
+
splitP2PTurnServerUrls
|
|
6
|
+
} from "../../common/models/setting.p2p.js";
|
|
1
7
|
import { mixedHash } from "octagonal-wheels/hash/purejs";
|
|
2
8
|
import { compatGlobal } from "../../common/coreEnvFunctions.js";
|
|
3
9
|
import { createDiagRTCPeerConnectionConstructor } from "./DiagRTCPeerConnections.js";
|
|
@@ -5,7 +11,7 @@ function generateJoinRoomOptions(settings) {
|
|
|
5
11
|
const passphraseNumbers = mixedHash(settings.P2P_passphrase, 0);
|
|
6
12
|
const passphrase = passphraseNumbers[0].toString(36) + passphraseNumbers[1].toString(36);
|
|
7
13
|
const relays = settings.P2P_relays.split(",").map((e) => e.trim()).filter((e) => e.length > 0);
|
|
8
|
-
const turnServers = settings.P2P_turnServers
|
|
14
|
+
const turnServers = splitP2PTurnServerUrls(settings.P2P_turnServers);
|
|
9
15
|
const relayConfig = {
|
|
10
16
|
manualReconnection: true,
|
|
11
17
|
urls: relays
|
|
@@ -30,6 +36,11 @@ function generateJoinRoomOptions(settings) {
|
|
|
30
36
|
}
|
|
31
37
|
];
|
|
32
38
|
}
|
|
39
|
+
if (normaliseP2PConnectionPath(settings.P2P_connectionPath) === P2PConnectionPaths.Relay && hasValidP2PTurnServerUrl(settings.P2P_turnServers)) {
|
|
40
|
+
options.rtcConfig = {
|
|
41
|
+
iceTransportPolicy: "relay"
|
|
42
|
+
};
|
|
43
|
+
}
|
|
33
44
|
return options;
|
|
34
45
|
}
|
|
35
46
|
export {
|
|
@@ -27,6 +27,7 @@ export declare class ServiceDatabaseFileAccessBase extends ServiceModuleBase<Ser
|
|
|
27
27
|
createChunks(file: UXFileInfo, force?: boolean, skipCheck?: boolean): Promise<boolean>;
|
|
28
28
|
store(file: UXFileInfo, force?: boolean, skipCheck?: boolean): Promise<boolean>;
|
|
29
29
|
storeWithBaseRevision(file: UXFileInfo, baseRevision: string | undefined, skipCheck?: boolean): Promise<string | false>;
|
|
30
|
+
storeWithLiveBaseRevision(file: UXFileInfo, baseRevision: string, skipCheck?: boolean): Promise<string | false>;
|
|
30
31
|
storeAsConflictedRevision(file: UXFileInfo, currentRev: string, skipCheck?: boolean): Promise<boolean>;
|
|
31
32
|
storeAsConflictedRevisionWithResult(file: UXFileInfo, currentRev: string, skipCheck?: boolean): Promise<string | false>;
|
|
32
33
|
storeDeletionWithBaseRevision(file: UXFileInfoStub | FilePathWithPrefix, baseRevision: string): Promise<string | false>;
|
|
@@ -53,7 +53,17 @@ class ServiceDatabaseFileAccessBase extends ServiceModuleBase {
|
|
|
53
53
|
return await this.__store(file, force, skipCheck, false) !== false;
|
|
54
54
|
}
|
|
55
55
|
async storeWithBaseRevision(file, baseRevision, skipCheck) {
|
|
56
|
-
const result = await this.__store(file, true, skipCheck, false,
|
|
56
|
+
const result = await this.__store(file, true, skipCheck, false, {
|
|
57
|
+
mode: "force-base",
|
|
58
|
+
baseRevision
|
|
59
|
+
});
|
|
60
|
+
return result !== null && typeof result === "object" && "rev" in result ? result.rev : false;
|
|
61
|
+
}
|
|
62
|
+
async storeWithLiveBaseRevision(file, baseRevision, skipCheck) {
|
|
63
|
+
const result = await this.__store(file, true, skipCheck, false, {
|
|
64
|
+
mode: "live-base",
|
|
65
|
+
baseRevision
|
|
66
|
+
});
|
|
57
67
|
return result !== null && typeof result === "object" && "rev" in result ? result.rev : false;
|
|
58
68
|
}
|
|
59
69
|
async storeAsConflictedRevision(file, currentRev, skipCheck) {
|
|
@@ -97,7 +107,7 @@ class ServiceDatabaseFileAccessBase extends ServiceModuleBase {
|
|
|
97
107
|
};
|
|
98
108
|
return await this.__store(dummyUXFileInfo, true, false, false) !== false;
|
|
99
109
|
}
|
|
100
|
-
async __store(file, force = false, skipCheck, onlyChunks,
|
|
110
|
+
async __store(file, force = false, skipCheck, onlyChunks, revisionTarget = { mode: "default" }) {
|
|
101
111
|
if (!skipCheck) {
|
|
102
112
|
if (!await this.checkIsTargetFile(file)) {
|
|
103
113
|
return true;
|
|
@@ -148,7 +158,7 @@ class ServiceDatabaseFileAccessBase extends ServiceModuleBase {
|
|
|
148
158
|
};
|
|
149
159
|
const msg = `STORAGE -> DB (${datatype}) `;
|
|
150
160
|
const isNotChanged = await serialized("file-" + fullPath, async () => {
|
|
151
|
-
if (
|
|
161
|
+
if (revisionTarget.mode !== "default") {
|
|
152
162
|
return false;
|
|
153
163
|
}
|
|
154
164
|
if (force) {
|
|
@@ -183,7 +193,15 @@ class ServiceDatabaseFileAccessBase extends ServiceModuleBase {
|
|
|
183
193
|
this._log(msg + " Skip " + fullPath, LOG_LEVEL_VERBOSE);
|
|
184
194
|
return true;
|
|
185
195
|
}
|
|
186
|
-
const ret = await this.database.localDatabase.
|
|
196
|
+
const ret = revisionTarget.mode === "live-base" ? await this.database.localDatabase.putDBEntryWithLiveBaseRevision(
|
|
197
|
+
d,
|
|
198
|
+
revisionTarget.baseRevision,
|
|
199
|
+
onlyChunks
|
|
200
|
+
) : await this.database.localDatabase.putDBEntry(
|
|
201
|
+
d,
|
|
202
|
+
onlyChunks,
|
|
203
|
+
revisionTarget.mode === "force-base" ? revisionTarget.baseRevision : void 0
|
|
204
|
+
);
|
|
187
205
|
if (ret !== false) {
|
|
188
206
|
this._log(msg + fullPath);
|
|
189
207
|
this.events.emitEvent(EVENT_FILE_SAVED);
|