mirror of
https://github.com/vrtmrz/obsidian-livesync.git
synced 2025-12-23 22:51:30 +00:00
Improved:
- Performance improved Prebuilt PouchDB is no longer used. Fixed: - Merging hidden files is also fixed. New Feature: - Now we can synchronise automatically after merging conflicts.
This commit is contained in:
@@ -25,14 +25,16 @@ esbuild
|
|||||||
"MANIFEST_VERSION": `"${manifestJson.version}"`,
|
"MANIFEST_VERSION": `"${manifestJson.version}"`,
|
||||||
"PACKAGE_VERSION": `"${packageJson.version}"`,
|
"PACKAGE_VERSION": `"${packageJson.version}"`,
|
||||||
"UPDATE_INFO": `${updateInfo}`,
|
"UPDATE_INFO": `${updateInfo}`,
|
||||||
|
"global":"window",
|
||||||
},
|
},
|
||||||
external: ["obsidian", "electron", ...builtins],
|
external: ["obsidian", "electron", "crypto"],
|
||||||
format: "cjs",
|
format: "cjs",
|
||||||
watch: !prod,
|
watch: !prod,
|
||||||
target: "es2018",
|
target: "es2018",
|
||||||
logLevel: "info",
|
logLevel: "info",
|
||||||
sourcemap: prod ? false : "inline",
|
sourcemap: prod ? false : "inline",
|
||||||
treeShaking: true,
|
treeShaking: true,
|
||||||
|
platform: "browser",
|
||||||
plugins: [
|
plugins: [
|
||||||
sveltePlugin({
|
sveltePlugin({
|
||||||
preprocess: sveltePreprocess(),
|
preprocess: sveltePreprocess(),
|
||||||
|
|||||||
842
package-lock.json
generated
842
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -24,11 +24,20 @@
|
|||||||
"eslint": "^8.28.0",
|
"eslint": "^8.28.0",
|
||||||
"eslint-config-airbnb-base": "^15.0.0",
|
"eslint-config-airbnb-base": "^15.0.0",
|
||||||
"eslint-plugin-import": "^2.26.0",
|
"eslint-plugin-import": "^2.26.0",
|
||||||
|
"events": "^3.3.0",
|
||||||
"obsidian": "^0.16.3",
|
"obsidian": "^0.16.3",
|
||||||
"postcss": "^8.4.19",
|
"postcss": "^8.4.19",
|
||||||
"postcss-load-config": "^4.0.1",
|
"postcss-load-config": "^4.0.1",
|
||||||
|
"pouchdb-adapter-http": "^8.0.0",
|
||||||
|
"pouchdb-adapter-idb": "^8.0.0",
|
||||||
|
"pouchdb-core": "^8.0.0",
|
||||||
|
"pouchdb-find": "^8.0.0",
|
||||||
|
"pouchdb-mapreduce": "^8.0.0",
|
||||||
|
"pouchdb-replication": "^8.0.0",
|
||||||
|
"pouchdb-utils": "file:src/lib/src/patches/pouchdb-utils",
|
||||||
"svelte": "^3.53.1",
|
"svelte": "^3.53.1",
|
||||||
"svelte-preprocess": "^4.10.7",
|
"svelte-preprocess": "^4.10.7",
|
||||||
|
"transform-pouch": "^2.0.0",
|
||||||
"tslib": "^2.4.1",
|
"tslib": "^2.4.1",
|
||||||
"typescript": "^4.9.3"
|
"typescript": "^4.9.3"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -133,6 +133,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
if (this.plugin.settings.syncOnFileOpen) return true;
|
if (this.plugin.settings.syncOnFileOpen) return true;
|
||||||
if (this.plugin.settings.syncOnSave) return true;
|
if (this.plugin.settings.syncOnSave) return true;
|
||||||
if (this.plugin.settings.syncOnStart) return true;
|
if (this.plugin.settings.syncOnStart) return true;
|
||||||
|
if (this.plugin.settings.syncAfterMerge) return true;
|
||||||
if (this.plugin.localDatabase.syncStatus == "CONNECTED") return true;
|
if (this.plugin.localDatabase.syncStatus == "CONNECTED") return true;
|
||||||
if (this.plugin.localDatabase.syncStatus == "PAUSED") return true;
|
if (this.plugin.localDatabase.syncStatus == "PAUSED") return true;
|
||||||
return false;
|
return false;
|
||||||
@@ -144,7 +145,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
new Setting(setupWizardEl)
|
new Setting(setupWizardEl)
|
||||||
.setName("Discard the existing configuration and set up")
|
.setName("Discard the existing configuration and set up")
|
||||||
.addButton((text) => {
|
.addButton((text) => {
|
||||||
text.setButtonText("Next").onClick(async () => {
|
text.setButtonText("Next").onClick(() => {
|
||||||
if (JSON.stringify(this.plugin.settings) != JSON.stringify(DEFAULT_SETTINGS)) {
|
if (JSON.stringify(this.plugin.settings) != JSON.stringify(DEFAULT_SETTINGS)) {
|
||||||
this.plugin.localDatabase.closeReplication();
|
this.plugin.localDatabase.closeReplication();
|
||||||
this.plugin.settings = { ...DEFAULT_SETTINGS };
|
this.plugin.settings = { ...DEFAULT_SETTINGS };
|
||||||
@@ -170,6 +171,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.syncOnSave = false;
|
this.plugin.settings.syncOnSave = false;
|
||||||
this.plugin.settings.syncOnStart = false;
|
this.plugin.settings.syncOnStart = false;
|
||||||
this.plugin.settings.syncOnFileOpen = false;
|
this.plugin.settings.syncOnFileOpen = false;
|
||||||
|
this.plugin.settings.syncAfterMerge = false;
|
||||||
this.plugin.localDatabase.closeReplication();
|
this.plugin.localDatabase.closeReplication();
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
containerEl.addClass("isWizard");
|
containerEl.addClass("isWizard");
|
||||||
@@ -226,7 +228,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
syncLive.forEach((e) => {
|
syncLive.forEach((e) => {
|
||||||
e.setDisabled(false).setTooltip("");
|
e.setDisabled(false).setTooltip("");
|
||||||
});
|
});
|
||||||
} else if (this.plugin.settings.syncOnFileOpen || this.plugin.settings.syncOnSave || this.plugin.settings.syncOnStart || this.plugin.settings.periodicReplication) {
|
} else if (this.plugin.settings.syncOnFileOpen || this.plugin.settings.syncOnSave || this.plugin.settings.syncOnStart || this.plugin.settings.periodicReplication || this.plugin.settings.syncAfterMerge) {
|
||||||
syncNonLive.forEach((e) => {
|
syncNonLive.forEach((e) => {
|
||||||
e.setDisabled(false).setTooltip("");
|
e.setDisabled(false).setTooltip("");
|
||||||
});
|
});
|
||||||
@@ -387,6 +389,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.syncOnSave = false;
|
this.plugin.settings.syncOnSave = false;
|
||||||
this.plugin.settings.syncOnStart = false;
|
this.plugin.settings.syncOnStart = false;
|
||||||
this.plugin.settings.syncOnFileOpen = false;
|
this.plugin.settings.syncOnFileOpen = false;
|
||||||
|
this.plugin.settings.syncAfterMerge = false;
|
||||||
this.plugin.settings.encrypt = this.plugin.settings.workingEncrypt;
|
this.plugin.settings.encrypt = this.plugin.settings.workingEncrypt;
|
||||||
this.plugin.settings.passphrase = this.plugin.settings.workingPassphrase;
|
this.plugin.settings.passphrase = this.plugin.settings.workingPassphrase;
|
||||||
this.plugin.settings.useDynamicIterationCount = this.plugin.settings.workingUseDynamicIterationCount;
|
this.plugin.settings.useDynamicIterationCount = this.plugin.settings.workingUseDynamicIterationCount;
|
||||||
@@ -433,7 +436,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.syncOnSave = false;
|
this.plugin.settings.syncOnSave = false;
|
||||||
this.plugin.settings.syncOnStart = false;
|
this.plugin.settings.syncOnStart = false;
|
||||||
this.plugin.settings.syncOnFileOpen = false;
|
this.plugin.settings.syncOnFileOpen = false;
|
||||||
|
this.plugin.settings.syncAfterMerge = false;
|
||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
|
|
||||||
applyDisplayEnabled();
|
applyDisplayEnabled();
|
||||||
@@ -693,7 +696,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
.setButtonText("Next")
|
.setButtonText("Next")
|
||||||
.setClass("mod-cta")
|
.setClass("mod-cta")
|
||||||
.setDisabled(false)
|
.setDisabled(false)
|
||||||
.onClick(async () => {
|
.onClick(() => {
|
||||||
if (!this.plugin.settings.encrypt) {
|
if (!this.plugin.settings.encrypt) {
|
||||||
this.plugin.settings.passphrase = "";
|
this.plugin.settings.passphrase = "";
|
||||||
}
|
}
|
||||||
@@ -714,7 +717,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
.setButtonText("Discard exist database and proceed")
|
.setButtonText("Discard exist database and proceed")
|
||||||
.setDisabled(false)
|
.setDisabled(false)
|
||||||
.setWarning()
|
.setWarning()
|
||||||
.onClick(async () => {
|
.onClick(() => {
|
||||||
if (!this.plugin.settings.encrypt) {
|
if (!this.plugin.settings.encrypt) {
|
||||||
this.plugin.settings.passphrase = "";
|
this.plugin.settings.passphrase = "";
|
||||||
}
|
}
|
||||||
@@ -793,7 +796,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
button
|
button
|
||||||
.setButtonText("Next")
|
.setButtonText("Next")
|
||||||
.setDisabled(false)
|
.setDisabled(false)
|
||||||
.onClick(async () => {
|
.onClick(() => {
|
||||||
changeDisplay("40");
|
changeDisplay("40");
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
@@ -949,7 +952,17 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
await this.plugin.saveSettings();
|
await this.plugin.saveSettings();
|
||||||
applyDisplayEnabled();
|
applyDisplayEnabled();
|
||||||
})
|
})
|
||||||
)
|
),
|
||||||
|
new Setting(containerSyncSettingEl)
|
||||||
|
.setName("Sync after merging file")
|
||||||
|
.setDesc("Sync automatically after merging files")
|
||||||
|
.addToggle((toggle) =>
|
||||||
|
toggle.setValue(this.plugin.settings.syncAfterMerge).onChange(async (value) => {
|
||||||
|
this.plugin.settings.syncAfterMerge = value;
|
||||||
|
await this.plugin.saveSettings();
|
||||||
|
applyDisplayEnabled();
|
||||||
|
})
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
new Setting(containerSyncSettingEl)
|
new Setting(containerSyncSettingEl)
|
||||||
@@ -1272,6 +1285,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.syncOnSave = false;
|
this.plugin.settings.syncOnSave = false;
|
||||||
this.plugin.settings.syncOnStart = false;
|
this.plugin.settings.syncOnStart = false;
|
||||||
this.plugin.settings.syncOnFileOpen = false;
|
this.plugin.settings.syncOnFileOpen = false;
|
||||||
|
this.plugin.settings.syncAfterMerge = false;
|
||||||
if (currentPreset == "LIVESYNC") {
|
if (currentPreset == "LIVESYNC") {
|
||||||
this.plugin.settings.liveSync = true;
|
this.plugin.settings.liveSync = true;
|
||||||
Logger("Synchronization setting configured as LiveSync.", LOG_LEVEL.NOTICE);
|
Logger("Synchronization setting configured as LiveSync.", LOG_LEVEL.NOTICE);
|
||||||
@@ -1281,6 +1295,7 @@ export class ObsidianLiveSyncSettingTab extends PluginSettingTab {
|
|||||||
this.plugin.settings.syncOnSave = false;
|
this.plugin.settings.syncOnSave = false;
|
||||||
this.plugin.settings.syncOnStart = true;
|
this.plugin.settings.syncOnStart = true;
|
||||||
this.plugin.settings.syncOnFileOpen = true;
|
this.plugin.settings.syncOnFileOpen = true;
|
||||||
|
this.plugin.settings.syncAfterMerge = true;
|
||||||
Logger("Synchronization setting configured as Periodic sync with batch database update.", LOG_LEVEL.NOTICE);
|
Logger("Synchronization setting configured as Periodic sync with batch database update.", LOG_LEVEL.NOTICE);
|
||||||
} else {
|
} else {
|
||||||
Logger("All synchronization disabled.", LOG_LEVEL.NOTICE);
|
Logger("All synchronization disabled.", LOG_LEVEL.NOTICE);
|
||||||
|
|||||||
2
src/lib
2
src/lib
Submodule src/lib updated: bfad1f86d3...4ef5986b4d
15
src/main.ts
15
src/main.ts
@@ -309,6 +309,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
this.settings.syncOnSave = false;
|
this.settings.syncOnSave = false;
|
||||||
this.settings.syncOnStart = false;
|
this.settings.syncOnStart = false;
|
||||||
this.settings.syncOnFileOpen = false;
|
this.settings.syncOnFileOpen = false;
|
||||||
|
this.settings.syncAfterMerge = false;
|
||||||
this.settings.periodicReplication = false;
|
this.settings.periodicReplication = false;
|
||||||
this.settings.versionUpFlash = "Self-hosted LiveSync has been upgraded and some behaviors have changed incompatibly. All automatic synchronization is now disabled temporary. Ensure that other devices are also upgraded, and enable synchronization again.";
|
this.settings.versionUpFlash = "Self-hosted LiveSync has been upgraded and some behaviors have changed incompatibly. All automatic synchronization is now disabled temporary. Ensure that other devices are also upgraded, and enable synchronization again.";
|
||||||
this.saveSettings();
|
this.saveSettings();
|
||||||
@@ -375,6 +376,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
this.settings.syncOnSave = false;
|
this.settings.syncOnSave = false;
|
||||||
this.settings.syncOnStart = false;
|
this.settings.syncOnStart = false;
|
||||||
this.settings.syncOnFileOpen = false;
|
this.settings.syncOnFileOpen = false;
|
||||||
|
this.settings.syncAfterMerge = false;
|
||||||
this.settings.autoSweepPlugins = false;
|
this.settings.autoSweepPlugins = false;
|
||||||
this.settings.usePluginSync = false;
|
this.settings.usePluginSync = false;
|
||||||
this.settings.suspendFileWatching = true;
|
this.settings.suspendFileWatching = true;
|
||||||
@@ -2297,6 +2299,9 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
await this.pullFile(filename);
|
await this.pullFile(filename);
|
||||||
Logger("concat both file");
|
Logger("concat both file");
|
||||||
|
if (this.settings.syncAfterMerge && !this.suspended) {
|
||||||
|
await this.replicate();
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
//resolved, check again.
|
//resolved, check again.
|
||||||
this.showIfConflicted(filename);
|
this.showIfConflicted(filename);
|
||||||
@@ -2304,9 +2309,12 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
} else if (toDelete == null) {
|
} else if (toDelete == null) {
|
||||||
Logger("Leave it still conflicted");
|
Logger("Leave it still conflicted");
|
||||||
} else {
|
} else {
|
||||||
Logger(`Conflict resolved:${filename}`);
|
|
||||||
await this.localDatabase.deleteDBEntry(filename, { rev: toDelete });
|
await this.localDatabase.deleteDBEntry(filename, { rev: toDelete });
|
||||||
await this.pullFile(filename, null, true, toKeep);
|
await this.pullFile(filename, null, true, toKeep);
|
||||||
|
Logger(`Conflict resolved:${filename}`);
|
||||||
|
if (this.settings.syncAfterMerge && !this.suspended) {
|
||||||
|
await this.replicate();
|
||||||
|
}
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
//resolved, check again.
|
//resolved, check again.
|
||||||
this.showIfConflicted(filename);
|
this.showIfConflicted(filename);
|
||||||
@@ -2354,6 +2362,9 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
if (conflictCheckResult === true) {
|
if (conflictCheckResult === true) {
|
||||||
//auto resolved, but need check again;
|
//auto resolved, but need check again;
|
||||||
|
if (this.settings.syncAfterMerge && !this.suspended) {
|
||||||
|
await this.replicate();
|
||||||
|
}
|
||||||
Logger("conflict:Automatically merged, but we have to check it again");
|
Logger("conflict:Automatically merged, but we have to check it again");
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
this.showIfConflicted(filename);
|
this.showIfConflicted(filename);
|
||||||
@@ -2970,7 +2981,7 @@ export default class ObsidianLiveSyncPlugin extends Plugin {
|
|||||||
const conflictedRevNo = Number(conflictedRev.split("-")[0]);
|
const conflictedRevNo = Number(conflictedRev.split("-")[0]);
|
||||||
//Search
|
//Search
|
||||||
const revFrom = (await this.localDatabase.localDatabase.get(id, { revs_info: true })) as unknown as LoadedEntry & PouchDB.Core.GetMeta;
|
const revFrom = (await this.localDatabase.localDatabase.get(id, { revs_info: true })) as unknown as LoadedEntry & PouchDB.Core.GetMeta;
|
||||||
const commonBase = revFrom._revs_info.filter(e => e.status == "available" && Number(e.rev.split("-")[0]) < conflictedRevNo).first().rev ?? "";
|
const commonBase = revFrom._revs_info.filter(e => e.status == "available" && Number(e.rev.split("-")[0]) < conflictedRevNo).first()?.rev ?? "";
|
||||||
const result = await this.mergeObject(id, commonBase, doc._rev, conflictedRev);
|
const result = await this.mergeObject(id, commonBase, doc._rev, conflictedRev);
|
||||||
if (result) {
|
if (result) {
|
||||||
Logger(`Object merge:${id}`, LOG_LEVEL.INFO);
|
Logger(`Object merge:${id}`, LOG_LEVEL.INFO);
|
||||||
|
|||||||
Reference in New Issue
Block a user