@jr2804/livesync-cli 0.25.80-cli.2 → 0.25.82-cli
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/LICENSE +21 -0
- package/README.md +56 -0
- package/bin/livesync-cli.js +6 -0
- package/dist/index.cjs +186 -87
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jan Reimes
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
# @jr2804/livesync-cli
|
|
2
|
+
|
|
3
|
+
**npm-published wrapper** for the [Self-hosted LiveSync CLI](https://github.com/vrtmrz/obsidian-livesync/tree/main/src/apps/cli).
|
|
4
|
+
|
|
5
|
+
No build steps, no Docker — just `npx` or `npm install -g`.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
# Run directly
|
|
11
|
+
npx @jr2804/livesync-cli <database-path> [options] <command>
|
|
12
|
+
|
|
13
|
+
# Install globally
|
|
14
|
+
npm install -g @jr2804/livesync-cli
|
|
15
|
+
livesync-cli <database-path> daemon --vault /path/to/vault
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Commands
|
|
19
|
+
|
|
20
|
+
| Command | Description |
|
|
21
|
+
|---------|-------------|
|
|
22
|
+
| `daemon` | (default) Run mirror scan then continuously sync CouchDB ↔ local filesystem |
|
|
23
|
+
| `sync` | Run one replication cycle and exit |
|
|
24
|
+
| `ls [prefix]` | List DB files |
|
|
25
|
+
| `cat <src>` | Read file from local database to stdout |
|
|
26
|
+
| `put <dst>` | Write stdin to local database path |
|
|
27
|
+
| `push <src> <dst>` | Push local file into local database |
|
|
28
|
+
| `pull <src> <dst>` | Pull file from local database to local file |
|
|
29
|
+
| `rm <path>` | Mark file as deleted in local database |
|
|
30
|
+
| `init-settings [file]` | Create settings JSON from defaults |
|
|
31
|
+
| `setup <setupURI>` | Apply setup URI to settings file |
|
|
32
|
+
| `remote-add <name> <connstr>` | Add a remote CouchDB |
|
|
33
|
+
| `remote-ls` | List configured remotes |
|
|
34
|
+
| `p2p-peers <timeout>` | Discover P2P peers |
|
|
35
|
+
| `p2p-sync <peer> <timeout>` | Sync with a P2P peer |
|
|
36
|
+
|
|
37
|
+
See the [upstream README](https://github.com/vrtmrz/obsidian-livesync/blob/main/src/apps/cli/README.md) for full documentation.
|
|
38
|
+
|
|
39
|
+
## How it works
|
|
40
|
+
|
|
41
|
+
This package wraps the upstream CLI from [vrtmrz/obsidian-livesync](https://github.com/vrtmrz/obsidian-livesync) at the `*-cli` release tag. The build process:
|
|
42
|
+
|
|
43
|
+
1. Checks out the upstream repo at the matching `*-cli` tag
|
|
44
|
+
2. Runs `npm install` and `npm run build` inside `src/apps/cli/`
|
|
45
|
+
3. Packages the built `dist/` files into an npm package
|
|
46
|
+
|
|
47
|
+
No modifications are made to the upstream code — this is purely a packaging layer.
|
|
48
|
+
|
|
49
|
+
## Versioning
|
|
50
|
+
|
|
51
|
+
Versions match upstream `*-cli` tags (e.g. `0.25.80-cli`). When a new upstream CLI release is published, this package is updated to match.
|
|
52
|
+
|
|
53
|
+
## License
|
|
54
|
+
|
|
55
|
+
MIT — this wrapper project.
|
|
56
|
+
The upstream CLI is licensed under MIT by [vorotamoroz](https://github.com/vrtmrz).
|
package/dist/index.cjs
CHANGED
|
@@ -9896,7 +9896,6 @@ var RESULT_TIMED_OUT = Symbol("timed out");
|
|
|
9896
9896
|
//#endregion
|
|
9897
9897
|
//#region ../../../node_modules/octagonal-wheels/dist/bureau/SlipBoard.js
|
|
9898
9898
|
var GENERIC_COMPATIBILITY_VALUE = "x-compatibility-value";
|
|
9899
|
-
var GENERIC_COMPATIBILITY_SIGNAL = "x-compatibility-signal";
|
|
9900
9899
|
var SlipBoard = class {
|
|
9901
9900
|
constructor() {
|
|
9902
9901
|
Object.defineProperty(this, "_clip", {
|
|
@@ -9906,9 +9905,6 @@ var SlipBoard = class {
|
|
|
9906
9905
|
value: /* @__PURE__ */ new Map()
|
|
9907
9906
|
});
|
|
9908
9907
|
}
|
|
9909
|
-
_makeKey(type, key) {
|
|
9910
|
-
return `${String(type)}:${key}`;
|
|
9911
|
-
}
|
|
9912
9908
|
/**
|
|
9913
9909
|
* Checks if a specific key is awaiting.
|
|
9914
9910
|
*
|
|
@@ -9919,7 +9915,7 @@ var SlipBoard = class {
|
|
|
9919
9915
|
* @returns {boolean} - Returns `true` if the event and sub-event combination is awaiting, otherwise `false`.
|
|
9920
9916
|
*/
|
|
9921
9917
|
isAwaiting(type, key) {
|
|
9922
|
-
return this._clip.has(
|
|
9918
|
+
return this._clip.has(`${String(type)}:${key}`);
|
|
9923
9919
|
}
|
|
9924
9920
|
/**
|
|
9925
9921
|
* Issues a slip of process and proceeds with the provided options.
|
|
@@ -9946,7 +9942,7 @@ var SlipBoard = class {
|
|
|
9946
9942
|
this.submit(type, key, ret);
|
|
9947
9943
|
} catch (ex) {
|
|
9948
9944
|
if (opt.submitAsSuccess) this.submit(type, key, opt.transformError ? opt.transformError(ex) : ex);
|
|
9949
|
-
else if (opt.dropSlipWithRisks) this._clip.delete(
|
|
9945
|
+
else if (opt.dropSlipWithRisks) this._clip.delete(type);
|
|
9950
9946
|
else this.reject(type, key, ex);
|
|
9951
9947
|
}
|
|
9952
9948
|
});
|
|
@@ -9967,16 +9963,15 @@ var SlipBoard = class {
|
|
|
9967
9963
|
timeout: void 0,
|
|
9968
9964
|
onNotAwaited: void 0
|
|
9969
9965
|
}) {
|
|
9970
|
-
|
|
9971
|
-
let taskPromise = this._clip.get(slipKey);
|
|
9966
|
+
let taskPromise = this._clip.get(`${String(type)}:${key}`);
|
|
9972
9967
|
if (!taskPromise) {
|
|
9973
9968
|
taskPromise = promiseWithResolvers();
|
|
9974
9969
|
taskPromise.promise = taskPromise.promise.then((ret) => {
|
|
9975
9970
|
return ret;
|
|
9976
9971
|
}).finally(() => {
|
|
9977
|
-
this._clip.delete(
|
|
9972
|
+
this._clip.delete(`${String(type)}:${key}`);
|
|
9978
9973
|
});
|
|
9979
|
-
this._clip.set(
|
|
9974
|
+
this._clip.set(`${String(type)}:${key}`, taskPromise);
|
|
9980
9975
|
if (onNotAwaited) fireAndForget(async () => (await yieldMicrotask(), onNotAwaited()));
|
|
9981
9976
|
}
|
|
9982
9977
|
if (timeout) {
|
|
@@ -9996,7 +9991,7 @@ var SlipBoard = class {
|
|
|
9996
9991
|
* @returns {void}
|
|
9997
9992
|
*/
|
|
9998
9993
|
submit(type, key, data) {
|
|
9999
|
-
const taskPromise = this._clip.get(
|
|
9994
|
+
const taskPromise = this._clip.get(`${String(type)}:${key}`);
|
|
10000
9995
|
if (taskPromise) taskPromise.resolve(data);
|
|
10001
9996
|
}
|
|
10002
9997
|
/**
|
|
@@ -10010,7 +10005,7 @@ var SlipBoard = class {
|
|
|
10010
10005
|
* @returns {void}
|
|
10011
10006
|
*/
|
|
10012
10007
|
submitToAll(type, prefix, data) {
|
|
10013
|
-
for (const [key, taskPromise] of this._clip.entries()) if (`${String(key)}`.startsWith(
|
|
10008
|
+
for (const [key, taskPromise] of this._clip.entries()) if (`${String(key)}`.startsWith(`${String(type)}:${prefix}`)) taskPromise.resolve(data);
|
|
10014
10009
|
}
|
|
10015
10010
|
/**
|
|
10016
10011
|
* Rejects a task promise associated with a specific event type and key.
|
|
@@ -10022,40 +10017,18 @@ var SlipBoard = class {
|
|
|
10022
10017
|
* @param {any} reason - The reason for rejecting the promise.
|
|
10023
10018
|
*/
|
|
10024
10019
|
reject(type, key = "", reason) {
|
|
10025
|
-
const taskPromise = this._clip.get(
|
|
10020
|
+
const taskPromise = this._clip.get(`${String(type)}:${key}`);
|
|
10026
10021
|
if (taskPromise) taskPromise.reject(reason);
|
|
10027
10022
|
}
|
|
10028
10023
|
};
|
|
10029
|
-
|
|
10030
|
-
return new SlipBoard();
|
|
10031
|
-
}
|
|
10032
|
-
function createSignalHub(board = createSlipBoard()) {
|
|
10033
|
-
return {
|
|
10034
|
-
board,
|
|
10035
|
-
async waitForSignal(id, timeout) {
|
|
10036
|
-
return await board.awaitNext(GENERIC_COMPATIBILITY_SIGNAL, id, { timeout }) !== TIMED_OUT_SIGNAL;
|
|
10037
|
-
},
|
|
10038
|
-
async waitForValue(id, timeout) {
|
|
10039
|
-
const ret = await board.awaitNext(GENERIC_COMPATIBILITY_VALUE, id, { timeout });
|
|
10040
|
-
if (ret === TIMED_OUT_SIGNAL) return RESULT_TIMED_OUT;
|
|
10041
|
-
return ret;
|
|
10042
|
-
},
|
|
10043
|
-
sendSignal(id) {
|
|
10044
|
-
board.submit(GENERIC_COMPATIBILITY_SIGNAL, id);
|
|
10045
|
-
},
|
|
10046
|
-
sendValue(id, result) {
|
|
10047
|
-
board.submit(GENERIC_COMPATIBILITY_VALUE, id, result);
|
|
10048
|
-
}
|
|
10049
|
-
};
|
|
10050
|
-
}
|
|
10051
|
-
var globalSignalHub = createSignalHub(createSlipBoard());
|
|
10024
|
+
var globalSlipBoard = new SlipBoard();
|
|
10052
10025
|
/**
|
|
10053
10026
|
* Sends a value to the specified ID.
|
|
10054
10027
|
* @param id - The ID to send the value to.
|
|
10055
10028
|
* @param result - The value to send.
|
|
10056
10029
|
*/
|
|
10057
10030
|
function sendValue(id, result) {
|
|
10058
|
-
|
|
10031
|
+
globalSlipBoard.submit(GENERIC_COMPATIBILITY_VALUE, id, result);
|
|
10059
10032
|
}
|
|
10060
10033
|
//#endregion
|
|
10061
10034
|
//#region ../../../node_modules/octagonal-wheels/dist/concurrency/task.js
|
|
@@ -10765,9 +10738,6 @@ var ClerkGroup = class {
|
|
|
10765
10738
|
//#endregion
|
|
10766
10739
|
//#region ../../../node_modules/octagonal-wheels/dist/concurrency/processor_v2.js
|
|
10767
10740
|
var allRunningProcessors = /* @__PURE__ */ new Set([]);
|
|
10768
|
-
/**
|
|
10769
|
-
* @deprecated Use QueueProcessorShim for low-friction migration, or PipelineSource and ProcessorStage for new code.
|
|
10770
|
-
*/
|
|
10771
10741
|
var QueueProcessor = class {
|
|
10772
10742
|
get nowProcessing() {
|
|
10773
10743
|
return this.processingEntities;
|
|
@@ -11339,7 +11309,6 @@ function stopAllRunningProcessors() {
|
|
|
11339
11309
|
const processors = [...allRunningProcessors];
|
|
11340
11310
|
for (const processor of processors) processor.terminate();
|
|
11341
11311
|
}
|
|
11342
|
-
TransformStream;
|
|
11343
11312
|
//#endregion
|
|
11344
11313
|
//#region ../../lib/src/services/base/ControlService.ts
|
|
11345
11314
|
/**
|
|
@@ -13840,7 +13809,7 @@ var QUANTUM = 32768;
|
|
|
13840
13809
|
* todo: When Capacitor or Electron is upgraded, check and reappraise this.
|
|
13841
13810
|
*/
|
|
13842
13811
|
var te$2 = new TextEncoder();
|
|
13843
|
-
var td = new TextDecoder();
|
|
13812
|
+
var td = new TextDecoder("utf-8", { ignoreBOM: true });
|
|
13844
13813
|
function writeString(string) {
|
|
13845
13814
|
if (string.length > 128) return te$2.encode(string);
|
|
13846
13815
|
const buffer = new Uint8Array(string.length * 4);
|
|
@@ -13873,6 +13842,7 @@ function writeString(string) {
|
|
|
13873
13842
|
*
|
|
13874
13843
|
* @param buffer - The Uint8Array buffer to convert.
|
|
13875
13844
|
* @returns The converted string.
|
|
13845
|
+
* @remarks Preserves a leading UTF-8 BOM as U+FEFF so that valid UTF-8 round-trips without dropping its first code point. Callers that treat a BOM as a document signature should remove it explicitly after decoding.
|
|
13876
13846
|
*/
|
|
13877
13847
|
function readString(buffer) {
|
|
13878
13848
|
const length = buffer.length;
|
|
@@ -14845,6 +14815,20 @@ var matchOpts = {
|
|
|
14845
14815
|
flipNegate: true,
|
|
14846
14816
|
nocase: true
|
|
14847
14817
|
};
|
|
14818
|
+
var matcherCache = /* @__PURE__ */ new WeakMap();
|
|
14819
|
+
function matchIgnoredPath(path, pattern, ignore) {
|
|
14820
|
+
let matchers = matcherCache.get(ignore);
|
|
14821
|
+
if (matchers === void 0) {
|
|
14822
|
+
matchers = /* @__PURE__ */ new Map();
|
|
14823
|
+
matcherCache.set(ignore, matchers);
|
|
14824
|
+
}
|
|
14825
|
+
let matcher = matchers.get(pattern);
|
|
14826
|
+
if (matcher === void 0) {
|
|
14827
|
+
matcher = new Minimatch(pattern, matchOpts);
|
|
14828
|
+
matchers.set(pattern, matcher);
|
|
14829
|
+
}
|
|
14830
|
+
return matcher.match(path);
|
|
14831
|
+
}
|
|
14848
14832
|
/**
|
|
14849
14833
|
* returns whether the given path is accepted (not ignored) by the `.gitignore`.
|
|
14850
14834
|
* @param path path of the file which is relative from `.gitignore` file
|
|
@@ -14859,10 +14843,10 @@ function isAccepted(path, ignore) {
|
|
|
14859
14843
|
let result = void 0;
|
|
14860
14844
|
for (const pattern of patterns) {
|
|
14861
14845
|
if (pattern.endsWith("/")) {
|
|
14862
|
-
if (
|
|
14846
|
+
if (matchIgnoredPath(path, `${pattern}**`, ignore)) return false;
|
|
14863
14847
|
}
|
|
14864
14848
|
const newResult = pattern.startsWith("!");
|
|
14865
|
-
if (
|
|
14849
|
+
if (matchIgnoredPath(path, pattern, ignore) || !pattern.endsWith("/") && matchIgnoredPath(path, pattern + "/**", ignore)) result = newResult;
|
|
14866
14850
|
}
|
|
14867
14851
|
return result;
|
|
14868
14852
|
}
|
|
@@ -16255,8 +16239,8 @@ function memoWithMap(bufferLength, fn, keyFunction) {
|
|
|
16255
16239
|
if (cache.get(key) === newPromise) cache.delete(key);
|
|
16256
16240
|
});
|
|
16257
16241
|
if (cache.size > bufferLength) {
|
|
16258
|
-
const
|
|
16259
|
-
if (
|
|
16242
|
+
const oldest = cache.keys().next();
|
|
16243
|
+
if (!oldest.done) cache.delete(oldest.value);
|
|
16260
16244
|
}
|
|
16261
16245
|
return newPromise;
|
|
16262
16246
|
};
|
|
@@ -18333,20 +18317,23 @@ var ReplicationService = class extends ServiceBase {
|
|
|
18333
18317
|
this.clearErrors();
|
|
18334
18318
|
return true;
|
|
18335
18319
|
}
|
|
18336
|
-
|
|
18337
|
-
* perform replication. The actual replication logic should be implemented in the handler of this event.
|
|
18338
|
-
* @param showMessage
|
|
18339
|
-
*/
|
|
18340
|
-
async performReplication(showMessage) {
|
|
18320
|
+
async performReplicationRequest(showMessage) {
|
|
18341
18321
|
const activeReplicator = this.replicatorService.getActiveReplicator();
|
|
18342
18322
|
if (!activeReplicator) {
|
|
18343
18323
|
this._log(`No active replicator found`, showMessage ? 64 : 32);
|
|
18344
18324
|
return false;
|
|
18345
18325
|
}
|
|
18346
18326
|
const settings = this.settingService.currentSettings();
|
|
18347
|
-
|
|
18348
|
-
|
|
18349
|
-
|
|
18327
|
+
return await activeReplicator.openReplication(settings, false, !!showMessage, false);
|
|
18328
|
+
}
|
|
18329
|
+
/**
|
|
18330
|
+
* Perform replication and handle a failed result.
|
|
18331
|
+
* @param showMessage Whether to show replication progress messages.
|
|
18332
|
+
*/
|
|
18333
|
+
async performReplication(showMessage) {
|
|
18334
|
+
const result = await this.performReplicationRequest(showMessage);
|
|
18335
|
+
if (!result) return await this.onReplicationFailed(showMessage);
|
|
18336
|
+
return result;
|
|
18350
18337
|
}
|
|
18351
18338
|
/**
|
|
18352
18339
|
* Start the replication process.
|
|
@@ -18355,7 +18342,9 @@ var ReplicationService = class extends ServiceBase {
|
|
|
18355
18342
|
async replicate(showMessage) {
|
|
18356
18343
|
try {
|
|
18357
18344
|
if (!await this.isReplicationReady(showMessage)) return false;
|
|
18358
|
-
|
|
18345
|
+
const result = await this.replicatorService.runBoundedRemoteActivity(() => this.performReplicationRequest(showMessage), { label: "replication" });
|
|
18346
|
+
if (!result) return await this.onReplicationFailed(showMessage);
|
|
18347
|
+
return result;
|
|
18359
18348
|
} finally {
|
|
18360
18349
|
this.previousReplicated = Date.now();
|
|
18361
18350
|
}
|
|
@@ -18445,6 +18434,13 @@ var ReplicationService = class extends ServiceBase {
|
|
|
18445
18434
|
//#region ../../lib/src/services/implements/injectable/InjectableReplicationService.ts
|
|
18446
18435
|
var InjectableReplicationService = class extends ReplicationService {};
|
|
18447
18436
|
//#endregion
|
|
18437
|
+
//#region ../../lib/src/interfaces/AsyncActivityRunner.ts
|
|
18438
|
+
/** Runs a task through the injected activity owner, or directly when none is supplied. */
|
|
18439
|
+
async function runWithOptionalActivity(runner, task, options) {
|
|
18440
|
+
if (runner) return await runner.run(task, options);
|
|
18441
|
+
return await task();
|
|
18442
|
+
}
|
|
18443
|
+
//#endregion
|
|
18448
18444
|
//#region ../../lib/src/services/base/ReplicatorService.ts
|
|
18449
18445
|
/**
|
|
18450
18446
|
* The ReplicatorService provides methods for managing replication.
|
|
@@ -18453,6 +18449,7 @@ var ReplicatorService = class extends ServiceBase {
|
|
|
18453
18449
|
constructor(context, dependencies) {
|
|
18454
18450
|
super(context);
|
|
18455
18451
|
this.dependencies = dependencies;
|
|
18452
|
+
this.boundedRemoteActivityCount = reactiveSource(0);
|
|
18456
18453
|
this._log = createInstanceLogFunction("ReplicatorService");
|
|
18457
18454
|
this.onCloseActiveReplication = handlers().anySuccess("onCloseActiveReplication");
|
|
18458
18455
|
this.getNewReplicator = handlers().firstResult("getNewReplicator");
|
|
@@ -18469,6 +18466,18 @@ var ReplicatorService = class extends ServiceBase {
|
|
|
18469
18466
|
this.databaseEventService.onDatabaseHasReady.addHandler(this.reinitialiseReplicator.bind(this));
|
|
18470
18467
|
this.appLifecycleService.onSuspending.addHandler(this.suspendReplication.bind(this));
|
|
18471
18468
|
}
|
|
18469
|
+
/**
|
|
18470
|
+
* Runs one finite remote operation while exposing its lifetime to host policy and status UI.
|
|
18471
|
+
* Continuous replication must not use this boundary.
|
|
18472
|
+
*/
|
|
18473
|
+
async runBoundedRemoteActivity(task, options) {
|
|
18474
|
+
this.boundedRemoteActivityCount.value++;
|
|
18475
|
+
try {
|
|
18476
|
+
return await runWithOptionalActivity(this.dependencies.activityRunner, task, options);
|
|
18477
|
+
} finally {
|
|
18478
|
+
this.boundedRemoteActivityCount.value--;
|
|
18479
|
+
}
|
|
18480
|
+
}
|
|
18472
18481
|
suspendReplication() {
|
|
18473
18482
|
const activeReplicator = this._activeReplicator;
|
|
18474
18483
|
if (activeReplicator) activeReplicator.closeReplication();
|
|
@@ -18830,10 +18839,10 @@ var HeadlessAPIService = class extends InjectableAPIService {
|
|
|
18830
18839
|
return "headless-app";
|
|
18831
18840
|
}
|
|
18832
18841
|
getAppVersion() {
|
|
18833
|
-
return `0.25.
|
|
18842
|
+
return `0.25.82`;
|
|
18834
18843
|
}
|
|
18835
18844
|
getPluginVersion() {
|
|
18836
|
-
return `0.25.
|
|
18845
|
+
return `0.25.82`;
|
|
18837
18846
|
}
|
|
18838
18847
|
getPlatform() {
|
|
18839
18848
|
return "server";
|
|
@@ -20448,7 +20457,7 @@ var ChunkFetcher = class {
|
|
|
20448
20457
|
Logger("No active replicator was found to request missing chunks.");
|
|
20449
20458
|
return;
|
|
20450
20459
|
}
|
|
20451
|
-
const fetched = await replicator.fetchRemoteChunks(requestIDs, false);
|
|
20460
|
+
const fetched = await this.options.replicatorService.runBoundedRemoteActivity(() => replicator.fetchRemoteChunks(requestIDs, false), { label: "chunk-fetch" });
|
|
20452
20461
|
if (!fetched) {
|
|
20453
20462
|
Logger(`No chunks were found for the following IDs: ${requestIDs.join(", ")}`);
|
|
20454
20463
|
for (const chunkID of requestIDs) this.chunkManager.emitEvent(EVENT_MISSING_CHUNK_REMOTE, chunkID);
|
|
@@ -29778,7 +29787,7 @@ async function canReplicateWithPBKDF2(errorManager, host, showMessage) {
|
|
|
29778
29787
|
}
|
|
29779
29788
|
errorManager.clearError(errorMessage);
|
|
29780
29789
|
const ensureMessage = `Failed to initialise the encryption key, preventing replication.`;
|
|
29781
|
-
const ensureResult = await replicator.ensurePBKDF2Salt(currentSettings, showMessage,
|
|
29790
|
+
const ensureResult = await replicator.ensurePBKDF2Salt(currentSettings, showMessage, false);
|
|
29782
29791
|
if (!ensureResult) {
|
|
29783
29792
|
errorManager.showError(ensureMessage, showMessage ? 64 : 32);
|
|
29784
29793
|
return false;
|
|
@@ -29840,7 +29849,7 @@ Even if you choose to clean up, you will see this option again if you exit Obsid
|
|
|
29840
29849
|
CHOICE_DISMISS
|
|
29841
29850
|
], CHOICE_DISMISS, 30);
|
|
29842
29851
|
if (ret == CHOICE_FETCH) await this.core.rebuilder.$performRebuildDB("localOnly");
|
|
29843
|
-
if (ret == CHOICE_CLEAN) {
|
|
29852
|
+
if (ret == CHOICE_CLEAN) await this.services.replicator.runBoundedRemoteActivity(async () => {
|
|
29844
29853
|
const replicator = this.services.replicator.getActiveReplicator();
|
|
29845
29854
|
if (!(replicator instanceof LiveSyncCouchDBReplicator)) return;
|
|
29846
29855
|
const remoteDB = await replicator.connectRemoteCouchDBWithSetting(this.settings, this.services.API.isMobile(), true);
|
|
@@ -29857,7 +29866,7 @@ Even if you choose to clean up, you will see this option again if you exit Obsid
|
|
|
29857
29866
|
await this.services.replicator.getActiveReplicator()?.markRemoteResolved(this.settings);
|
|
29858
29867
|
Logger("The local database has been cleaned up.", showMessage ? 64 : 32);
|
|
29859
29868
|
} else Logger("Replication has been cancelled. Please try it again.", showMessage ? 64 : 32);
|
|
29860
|
-
}
|
|
29869
|
+
}, { label: "database-cleanup" });
|
|
29861
29870
|
});
|
|
29862
29871
|
}
|
|
29863
29872
|
async onReplicationFailed(showMessage = false) {
|
|
@@ -29941,7 +29950,9 @@ var ModuleReplicatorCouchDB = class extends AbstractModule {
|
|
|
29941
29950
|
const eventualOnStart = !LiveSyncEnabled && this.settings.syncOnStart;
|
|
29942
29951
|
if (LiveSyncEnabled || eventualOnStart) fireAndForget(async () => {
|
|
29943
29952
|
if (!await this.services.replication.isReplicationReady(false)) return;
|
|
29944
|
-
this.core.replicator.openReplication(this.settings, continuous, false, false);
|
|
29953
|
+
const openReplication = () => this.core.replicator.openReplication(this.settings, continuous, false, false);
|
|
29954
|
+
if (continuous) openReplication();
|
|
29955
|
+
else await this.services.replicator.runBoundedRemoteActivity(openReplication, { label: "replication" });
|
|
29945
29956
|
});
|
|
29946
29957
|
}
|
|
29947
29958
|
return Promise.resolve(true);
|
|
@@ -56304,8 +56315,8 @@ var ModuleResolvingMismatchedTweaks = class extends AbstractModule {
|
|
|
56304
56315
|
};
|
|
56305
56316
|
//#endregion
|
|
56306
56317
|
//#region ../../lib/src/common/coreEnvVars.ts
|
|
56307
|
-
var manifestVersion = "0.25.
|
|
56308
|
-
var packageVersion = "0.25.
|
|
56318
|
+
var manifestVersion = "0.25.82";
|
|
56319
|
+
var packageVersion = "0.25.82";
|
|
56309
56320
|
//#endregion
|
|
56310
56321
|
//#region ../../modules/main/ModuleLiveSyncMain.ts
|
|
56311
56322
|
var ModuleLiveSyncMain = class extends AbstractModule {
|
|
@@ -56375,7 +56386,7 @@ var ModuleLiveSyncMain = class extends AbstractModule {
|
|
|
56375
56386
|
}
|
|
56376
56387
|
const lsKey = "obsidian-live-sync-ver" + this.services.vault.getVaultName();
|
|
56377
56388
|
const last_version = compatGlobal.localStorage.getItem(lsKey);
|
|
56378
|
-
if (~~(versionNumberString2Number("0.25.
|
|
56389
|
+
if (~~(versionNumberString2Number("0.25.82") / 1e3) > this.settings.lastReadUpdates && this.settings.isConfigured) this._log($msg("moduleLiveSyncMain.logReadChangelog"), 64);
|
|
56379
56390
|
if (last_version && Number(last_version) < 12) {
|
|
56380
56391
|
this.settings.liveSync = false;
|
|
56381
56392
|
this.settings.syncOnSave = false;
|
|
@@ -56982,6 +56993,10 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
|
|
|
56982
56993
|
}) == "yes") await this.setting.suggestOptionalFeatures(opt);
|
|
56983
56994
|
}
|
|
56984
56995
|
async rebuildRemote() {
|
|
56996
|
+
await this.replicator.runBoundedRemoteActivity(() => this.performRemoteRebuild(), { label: "rebuild-remote" });
|
|
56997
|
+
await this.informOptionalFeatures();
|
|
56998
|
+
}
|
|
56999
|
+
async performRemoteRebuild() {
|
|
56985
57000
|
await this.setting.suspendExtraSync();
|
|
56986
57001
|
await this.setting.applyPartial({
|
|
56987
57002
|
isConfigured: true,
|
|
@@ -56996,12 +57011,15 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
|
|
|
56996
57011
|
await this.replication.replicateAllToRemote(true);
|
|
56997
57012
|
await delay$1(1e3);
|
|
56998
57013
|
await this.replication.replicateAllToRemote(true, true);
|
|
56999
|
-
await this.informOptionalFeatures();
|
|
57000
57014
|
}
|
|
57001
57015
|
$rebuildRemote() {
|
|
57002
57016
|
return this.rebuildRemote();
|
|
57003
57017
|
}
|
|
57004
57018
|
async rebuildEverything() {
|
|
57019
|
+
await this.replicator.runBoundedRemoteActivity(() => this.performRebuildEverything(), { label: "rebuild-everything" });
|
|
57020
|
+
await this.informOptionalFeatures();
|
|
57021
|
+
}
|
|
57022
|
+
async performRebuildEverything() {
|
|
57005
57023
|
await this.setting.suspendExtraSync();
|
|
57006
57024
|
await this.setting.applyPartial({
|
|
57007
57025
|
isConfigured: true,
|
|
@@ -57019,7 +57037,6 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
|
|
|
57019
57037
|
await this.replication.replicateAllToRemote(true);
|
|
57020
57038
|
await delay$1(1e3);
|
|
57021
57039
|
await this.replication.replicateAllToRemote(true, true);
|
|
57022
|
-
await this.informOptionalFeatures();
|
|
57023
57040
|
}
|
|
57024
57041
|
$rebuildEverything() {
|
|
57025
57042
|
return this.rebuildEverything();
|
|
@@ -57130,6 +57147,9 @@ Are you sure you wish to proceed?`;
|
|
|
57130
57147
|
}
|
|
57131
57148
|
if (ret == CANCEL) return;
|
|
57132
57149
|
}
|
|
57150
|
+
await this.replicator.runBoundedRemoteActivity(() => this.performFetchLocal(makeLocalChunkBeforeSync, preventMakeLocalFilesBeforeSync, autoResume), { label: "rebuild-fetch" });
|
|
57151
|
+
}
|
|
57152
|
+
async performFetchLocal(makeLocalChunkBeforeSync, preventMakeLocalFilesBeforeSync, autoResume = true) {
|
|
57133
57153
|
await this.suspendReflectingDatabase(!autoResume);
|
|
57134
57154
|
await this.control.applySettings();
|
|
57135
57155
|
await this.resetLocalDatabase();
|
|
@@ -57160,6 +57180,9 @@ Are you sure you wish to proceed?`;
|
|
|
57160
57180
|
await this.fetchLocal(false, true, autoResume);
|
|
57161
57181
|
return;
|
|
57162
57182
|
}
|
|
57183
|
+
await this.replicator.runBoundedRemoteActivity(() => this.performFetchLocalDBFast(settings, autoResume), { label: "fast-fetch" });
|
|
57184
|
+
}
|
|
57185
|
+
async performFetchLocalDBFast(settings, autoResume) {
|
|
57163
57186
|
const remote = settings.couchDB_URI.replace(/\/+$/, "") + (settings.couchDB_DBNAME == "" ? "" : "/" + settings.couchDB_DBNAME);
|
|
57164
57187
|
let checkpoint = this.getFastFetchCheckpoint(remote);
|
|
57165
57188
|
await this.suspendReflectingDatabase();
|
|
@@ -57865,6 +57888,24 @@ var NodeConversionAdapter = class {
|
|
|
57865
57888
|
}
|
|
57866
57889
|
};
|
|
57867
57890
|
//#endregion
|
|
57891
|
+
//#region ../storagePath.ts
|
|
57892
|
+
/**
|
|
57893
|
+
* Validate the platform-neutral path vocabulary used by rooted storage adapters.
|
|
57894
|
+
*
|
|
57895
|
+
* Paths are slash-separated and relative to the root bound to the adapter. Root
|
|
57896
|
+
* selection and authorisation happen before the adapter is constructed.
|
|
57897
|
+
*/
|
|
57898
|
+
function validateStoragePath(storagePath, allowRoot = true) {
|
|
57899
|
+
if (storagePath === "") {
|
|
57900
|
+
if (allowRoot) return storagePath;
|
|
57901
|
+
throw new Error("The storage root is not a valid entry path");
|
|
57902
|
+
}
|
|
57903
|
+
if (storagePath.startsWith("/") || storagePath.startsWith("\\") || /^[A-Za-z]:/.test(storagePath)) throw new Error(`Storage paths must be relative to the configured root: ${storagePath}`);
|
|
57904
|
+
if (storagePath.includes("\\")) throw new Error(`Storage paths must use forward slashes: ${storagePath}`);
|
|
57905
|
+
if (storagePath.split("/").some((segment) => segment === "." || segment === "..")) throw new Error(`Storage paths must not contain traversal segments: ${storagePath}`);
|
|
57906
|
+
return storagePath;
|
|
57907
|
+
}
|
|
57908
|
+
//#endregion
|
|
57868
57909
|
//#region adapters/NodeStorageAdapter.ts
|
|
57869
57910
|
/**
|
|
57870
57911
|
* Storage adapter implementation for Node.js
|
|
@@ -57874,20 +57915,22 @@ var NodeStorageAdapter = class {
|
|
|
57874
57915
|
constructor(basePath) {
|
|
57875
57916
|
this.basePath = basePath;
|
|
57876
57917
|
}
|
|
57877
|
-
resolvePath(p) {
|
|
57878
|
-
return node_path.join(this.basePath, p);
|
|
57918
|
+
resolvePath(p, allowRoot = true) {
|
|
57919
|
+
return node_path.join(this.basePath, validateStoragePath(p, allowRoot));
|
|
57879
57920
|
}
|
|
57880
57921
|
async exists(p) {
|
|
57922
|
+
const fullPath = this.resolvePath(p);
|
|
57881
57923
|
try {
|
|
57882
|
-
await node_fs_promises.access(
|
|
57924
|
+
await node_fs_promises.access(fullPath);
|
|
57883
57925
|
return true;
|
|
57884
57926
|
} catch {
|
|
57885
57927
|
return false;
|
|
57886
57928
|
}
|
|
57887
57929
|
}
|
|
57888
57930
|
async trystat(p) {
|
|
57931
|
+
const fullPath = this.resolvePath(p);
|
|
57889
57932
|
try {
|
|
57890
|
-
const stat = await node_fs_promises.stat(
|
|
57933
|
+
const stat = await node_fs_promises.stat(fullPath);
|
|
57891
57934
|
return {
|
|
57892
57935
|
size: stat.size,
|
|
57893
57936
|
mtime: Math.floor(stat.mtimeMs),
|
|
@@ -57905,7 +57948,7 @@ var NodeStorageAdapter = class {
|
|
|
57905
57948
|
await node_fs_promises.mkdir(this.resolvePath(p), { recursive: true });
|
|
57906
57949
|
}
|
|
57907
57950
|
async remove(p) {
|
|
57908
|
-
const fullPath = this.resolvePath(p);
|
|
57951
|
+
const fullPath = this.resolvePath(p, false);
|
|
57909
57952
|
if ((await node_fs_promises.stat(fullPath)).isDirectory()) await node_fs_promises.rm(fullPath, {
|
|
57910
57953
|
recursive: true,
|
|
57911
57954
|
force: true
|
|
@@ -57913,14 +57956,14 @@ var NodeStorageAdapter = class {
|
|
|
57913
57956
|
else await node_fs_promises.unlink(fullPath);
|
|
57914
57957
|
}
|
|
57915
57958
|
async read(p) {
|
|
57916
|
-
return await node_fs_promises.readFile(this.resolvePath(p), "utf-8");
|
|
57959
|
+
return await node_fs_promises.readFile(this.resolvePath(p, false), "utf-8");
|
|
57917
57960
|
}
|
|
57918
57961
|
async readBinary(p) {
|
|
57919
|
-
const buffer = await node_fs_promises.readFile(this.resolvePath(p));
|
|
57962
|
+
const buffer = await node_fs_promises.readFile(this.resolvePath(p, false));
|
|
57920
57963
|
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
57921
57964
|
}
|
|
57922
57965
|
async write(p, data, options) {
|
|
57923
|
-
const fullPath = this.resolvePath(p);
|
|
57966
|
+
const fullPath = this.resolvePath(p, false);
|
|
57924
57967
|
await node_fs_promises.mkdir(node_path.dirname(fullPath), { recursive: true });
|
|
57925
57968
|
await node_fs_promises.writeFile(fullPath, data, "utf-8");
|
|
57926
57969
|
if (options?.mtime || options?.ctime) {
|
|
@@ -57930,7 +57973,7 @@ var NodeStorageAdapter = class {
|
|
|
57930
57973
|
}
|
|
57931
57974
|
}
|
|
57932
57975
|
async writeBinary(p, data, options) {
|
|
57933
|
-
const fullPath = this.resolvePath(p);
|
|
57976
|
+
const fullPath = this.resolvePath(p, false);
|
|
57934
57977
|
await node_fs_promises.mkdir(node_path.dirname(fullPath), { recursive: true });
|
|
57935
57978
|
await node_fs_promises.writeFile(fullPath, new Uint8Array(data));
|
|
57936
57979
|
if (options?.mtime || options?.ctime) {
|
|
@@ -57940,7 +57983,7 @@ var NodeStorageAdapter = class {
|
|
|
57940
57983
|
}
|
|
57941
57984
|
}
|
|
57942
57985
|
async append(p, data, options) {
|
|
57943
|
-
const fullPath = this.resolvePath(p);
|
|
57986
|
+
const fullPath = this.resolvePath(p, false);
|
|
57944
57987
|
await node_fs_promises.mkdir(node_path.dirname(fullPath), { recursive: true });
|
|
57945
57988
|
await node_fs_promises.appendFile(fullPath, data, "utf-8");
|
|
57946
57989
|
if (options?.mtime || options?.ctime) {
|
|
@@ -66741,6 +66784,10 @@ var TrysteroReplicator = class {
|
|
|
66741
66784
|
get confirm() {
|
|
66742
66785
|
return this._env.confirm;
|
|
66743
66786
|
}
|
|
66787
|
+
async runBoundedRemoteActivity(task) {
|
|
66788
|
+
if (this._env.runBoundedRemoteActivity) return await this._env.runBoundedRemoteActivity(task, { label: "replication" });
|
|
66789
|
+
return await task();
|
|
66790
|
+
}
|
|
66744
66791
|
constructor(env, server) {
|
|
66745
66792
|
this._onSetup = false;
|
|
66746
66793
|
this.lastSeq = "";
|
|
@@ -66795,7 +66842,7 @@ var TrysteroReplicator = class {
|
|
|
66795
66842
|
}
|
|
66796
66843
|
async onNewPeer(peer) {
|
|
66797
66844
|
const peerName = peer.name;
|
|
66798
|
-
if (this.autoSyncPeers.some((e) => e.test(peerName))) await this.sync(peer.peerId);
|
|
66845
|
+
if (this.autoSyncPeers.some((e) => e.test(peerName))) await this.runBoundedRemoteActivity(() => this.sync(peer.peerId));
|
|
66799
66846
|
if (this.autoWatchPeers.some((e) => e.test(peerName))) this.watchPeer(peer.peerId);
|
|
66800
66847
|
}
|
|
66801
66848
|
onPeerLeaved(peerId) {
|
|
@@ -66823,7 +66870,7 @@ var TrysteroReplicator = class {
|
|
|
66823
66870
|
return {
|
|
66824
66871
|
reqSync: async (fromPeerId) => {
|
|
66825
66872
|
if (this._onSetup) return { error: /* @__PURE__ */ new Error("The setup is in progress") };
|
|
66826
|
-
return await this.replicateFrom(fromPeerId);
|
|
66873
|
+
return await this.runBoundedRemoteActivity(() => this.replicateFrom(fromPeerId));
|
|
66827
66874
|
},
|
|
66828
66875
|
"!reqAuth": async (fromPeerId) => {
|
|
66829
66876
|
return await this.server?.isAcceptablePeer(fromPeerId);
|
|
@@ -67108,7 +67155,7 @@ var TrysteroReplicator = class {
|
|
|
67108
67155
|
if (this._watchingPeers.has(fromPeerId)) {
|
|
67109
67156
|
Logger(`Progress notification from ${fromPeerId}`, 16);
|
|
67110
67157
|
return await serialized(`onProgress-${fromPeerId}`, async () => {
|
|
67111
|
-
return await this.replicateFrom(fromPeerId);
|
|
67158
|
+
return await this.runBoundedRemoteActivity(() => this.replicateFrom(fromPeerId));
|
|
67112
67159
|
});
|
|
67113
67160
|
}
|
|
67114
67161
|
return false;
|
|
@@ -67238,6 +67285,7 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
|
|
|
67238
67285
|
get confirm() {
|
|
67239
67286
|
return services.API.confirm;
|
|
67240
67287
|
},
|
|
67288
|
+
runBoundedRemoteActivity: (task, options) => services.replicator.runBoundedRemoteActivity(task, options),
|
|
67241
67289
|
processReplicatedDocs: async (docs) => {
|
|
67242
67290
|
if (services.setting.currentSettings().suspendParseReplicationResult) {
|
|
67243
67291
|
const docLength = docs.length;
|
|
@@ -67304,15 +67352,19 @@ var LiveSyncTrysteroReplicator = class extends LiveSyncAbstractReplicator {
|
|
|
67304
67352
|
this._replicator?.onPeerLeaved(peerId);
|
|
67305
67353
|
}
|
|
67306
67354
|
async replicateFromCommand(showResult = false) {
|
|
67307
|
-
|
|
67355
|
+
const replicator = this._replicator;
|
|
67356
|
+
if (!replicator) return;
|
|
67357
|
+
await this.env.services.replicator.runBoundedRemoteActivity(() => replicator.replicateFromCommand(showResult), { label: "replication" });
|
|
67308
67358
|
}
|
|
67309
67359
|
async replicateFrom(peerId, showNotice = false) {
|
|
67310
|
-
|
|
67311
|
-
|
|
67360
|
+
const replicator = this._replicator;
|
|
67361
|
+
if (!replicator) throw new Error("P2P replicator is not open");
|
|
67362
|
+
return await this.env.services.replicator.runBoundedRemoteActivity(() => replicator.replicateFrom(peerId, showNotice), { label: "replication" });
|
|
67312
67363
|
}
|
|
67313
67364
|
async requestSynchroniseToPeer(peerId) {
|
|
67314
|
-
|
|
67315
|
-
|
|
67365
|
+
const replicator = this._replicator;
|
|
67366
|
+
if (!replicator) throw new Error("P2P replicator is not open");
|
|
67367
|
+
return await this.env.services.replicator.runBoundedRemoteActivity(() => replicator.requestSynchroniseToPeer(peerId), { label: "replication" });
|
|
67316
67368
|
}
|
|
67317
67369
|
async getRemoteConfig(peerId) {
|
|
67318
67370
|
if (!this._replicator) throw new Error("P2P replicator is not open");
|
|
@@ -67548,6 +67600,52 @@ function resolvePeer(peers, peerToken) {
|
|
|
67548
67600
|
if (byName.length > 1) throw new Error(`Multiple peers matched by name '${peerToken}'. Use peer-id instead.`);
|
|
67549
67601
|
if (byName.length === 1) return byName[0];
|
|
67550
67602
|
}
|
|
67603
|
+
function getReportValue(report, key) {
|
|
67604
|
+
const value = report?.[key];
|
|
67605
|
+
return typeof value === "string" || typeof value === "number" ? value : "unknown";
|
|
67606
|
+
}
|
|
67607
|
+
function summariseCandidate(reports, candidateId) {
|
|
67608
|
+
if (candidateId === "unknown") return;
|
|
67609
|
+
const report = reports.map((r) => r).find((r) => r.id === candidateId);
|
|
67610
|
+
if (!report) return;
|
|
67611
|
+
return {
|
|
67612
|
+
id: candidateId,
|
|
67613
|
+
candidateType: getReportValue(report, "candidateType"),
|
|
67614
|
+
protocol: getReportValue(report, "protocol"),
|
|
67615
|
+
relayProtocol: getReportValue(report, "relayProtocol")
|
|
67616
|
+
};
|
|
67617
|
+
}
|
|
67618
|
+
async function writePeerConnectionStatsIfRequested(replicator, peer) {
|
|
67619
|
+
const outputPath = process.env.LIVESYNC_P2P_STATS_JSONL?.trim();
|
|
67620
|
+
if (!outputPath) return;
|
|
67621
|
+
const peerConnection = replicator.rawHost?.room?.getPeers()[peer.peerId];
|
|
67622
|
+
const stats = peerConnection ? await getPeerConnectionStats(`cli-p2p-${peer.peerId}`, peerConnection) : void 0;
|
|
67623
|
+
const localCandidate = summariseCandidate(stats?.reports ?? [], stats?.localCandidateId ?? "unknown");
|
|
67624
|
+
const remoteCandidate = summariseCandidate(stats?.reports ?? [], stats?.remoteCandidateId ?? "unknown");
|
|
67625
|
+
const selectedPath = localCandidate && remoteCandidate ? `${localCandidate.candidateType}<->${remoteCandidate.candidateType}` : "unknown";
|
|
67626
|
+
const payload = {
|
|
67627
|
+
generatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
67628
|
+
command: "p2p-sync",
|
|
67629
|
+
peerId: peer.peerId,
|
|
67630
|
+
peerName: peer.name,
|
|
67631
|
+
candidatePathCollected: !!stats?.selectedPair,
|
|
67632
|
+
selectedPath,
|
|
67633
|
+
selectedPair: stats ? {
|
|
67634
|
+
id: stats.selectedPairId,
|
|
67635
|
+
state: stats.state,
|
|
67636
|
+
currentRoundTripTime: stats.currentRoundTripTime,
|
|
67637
|
+
totalRoundTripTime: stats.totalRoundTripTime,
|
|
67638
|
+
requestsSent: stats.requestsSent,
|
|
67639
|
+
responsesReceived: stats.responsesReceived,
|
|
67640
|
+
packetsDiscardedOnSend: stats.packetsDiscardedOnSend,
|
|
67641
|
+
bytesSent: stats.bytesSent,
|
|
67642
|
+
bytesReceived: stats.bytesReceived
|
|
67643
|
+
} : void 0,
|
|
67644
|
+
localCandidate,
|
|
67645
|
+
remoteCandidate
|
|
67646
|
+
};
|
|
67647
|
+
await (0, node_fs_promises.appendFile)(outputPath, `${JSON.stringify(payload)}\n`, "utf8");
|
|
67648
|
+
}
|
|
67551
67649
|
async function syncWithPeer(core, peerToken, timeoutSec) {
|
|
67552
67650
|
const replicator = await createReplicator(core);
|
|
67553
67651
|
await replicator.open();
|
|
@@ -67568,6 +67666,7 @@ async function syncWithPeer(core, peerToken, timeoutSec) {
|
|
|
67568
67666
|
const err = pushResult?.error;
|
|
67569
67667
|
throw err instanceof Error ? err : LiveSyncError.fromError(err ?? "P2P sync failed while requesting remote sync");
|
|
67570
67668
|
}
|
|
67669
|
+
await writePeerConnectionStatsIfRequested(replicator, targetPeer);
|
|
67571
67670
|
return targetPeer;
|
|
67572
67671
|
} finally {
|
|
67573
67672
|
await replicator.close();
|
|
@@ -68717,7 +68816,7 @@ var IgnoreRules = class {
|
|
|
68717
68816
|
}
|
|
68718
68817
|
_addPattern(raw) {
|
|
68719
68818
|
if (raw.startsWith("!")) throw new Error(`[IgnoreRules] Negation pattern '${raw}' is not supported. Remove it from .livesync/ignore or use a separate include/exclude file.`);
|
|
68720
|
-
this.patterns.push(this._normalisePattern(raw));
|
|
68819
|
+
this.patterns.push(new Minimatch(this._normalisePattern(raw), { dot: true }));
|
|
68721
68820
|
}
|
|
68722
68821
|
/**
|
|
68723
68822
|
* Returns `true` if the given vault-relative path matches any loaded
|
|
@@ -68729,7 +68828,7 @@ var IgnoreRules = class {
|
|
|
68729
68828
|
shouldIgnore(relativePath) {
|
|
68730
68829
|
if (this.patterns.length === 0) return false;
|
|
68731
68830
|
const normalised = relativePath.replace(/\\/g, "/");
|
|
68732
|
-
return this.patterns.some((
|
|
68831
|
+
return this.patterns.some((pattern) => pattern.match(normalised));
|
|
68733
68832
|
}
|
|
68734
68833
|
};
|
|
68735
68834
|
//#endregion
|