## 0.24.27

### Improved

- We can use prefix for path for the Bucket synchronisation.
- The "Use Request API to avoid `inevitable` CORS problem" option is now promoted to the normal setting, not a niche patch.

### Fixed

- Now switching replicators applied immediately, without the need to restart Obsidian.

### Tidied up

- Some dependencies have been updated to the latest version.
This commit is contained in:
vorotamoroz
2025-06-10 02:51:47 +01:00
parent d61d6fec37
commit 5f76b9809b
7 changed files with 1652 additions and 2445 deletions

4052
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -81,10 +81,10 @@
"fflate": "^0.8.2", "fflate": "^0.8.2",
"idb": "^8.0.3", "idb": "^8.0.3",
"minimatch": "^10.0.1", "minimatch": "^10.0.1",
"octagonal-wheels": "^0.1.25", "octagonal-wheels": "^0.1.30",
"qrcode-generator": "^1.4.4", "qrcode-generator": "^1.4.4",
"svelte-check": "^4.1.7", "svelte-check": "^4.1.7",
"trystero": "^0.21.3", "trystero": "^0.21.5",
"xxhash-wasm-102": "npm:xxhash-wasm@^1.0.2" "xxhash-wasm-102": "npm:xxhash-wasm@^1.0.2"
} }
} }

Submodule src/lib updated: d53cad1c68...68434acfdd

View File

@@ -27,20 +27,28 @@ import {
updatePreviousExecutionTime, updatePreviousExecutionTime,
} from "../../common/utils"; } from "../../common/utils";
import { isAnyNote } from "../../lib/src/common/utils"; import { isAnyNote } from "../../lib/src/common/utils";
import { EVENT_FILE_SAVED, eventHub } from "../../common/events"; import { EVENT_FILE_SAVED, EVENT_SETTING_SAVED, eventHub } from "../../common/events";
import type { LiveSyncAbstractReplicator } from "../../lib/src/replication/LiveSyncAbstractReplicator"; import type { LiveSyncAbstractReplicator } from "../../lib/src/replication/LiveSyncAbstractReplicator";
import { globalSlipBoard } from "../../lib/src/bureau/bureau"; import { globalSlipBoard } from "../../lib/src/bureau/bureau";
import { $msg } from "../../lib/src/common/i18n"; import { $msg } from "../../lib/src/common/i18n";
const KEY_REPLICATION_ON_EVENT = "replicationOnEvent"; const KEY_REPLICATION_ON_EVENT = "replicationOnEvent";
const REPLICATION_ON_EVENT_FORECASTED_TIME = 5000; const REPLICATION_ON_EVENT_FORECASTED_TIME = 5000;
export class ModuleReplicator extends AbstractModule implements ICoreModule { export class ModuleReplicator extends AbstractModule implements ICoreModule {
_replicatorType?: string;
$everyOnloadAfterLoadSettings(): Promise<boolean> { $everyOnloadAfterLoadSettings(): Promise<boolean> {
eventHub.onEvent(EVENT_FILE_SAVED, () => { eventHub.onEvent(EVENT_FILE_SAVED, () => {
if (this.settings.syncOnSave && !this.core.$$isSuspended()) { if (this.settings.syncOnSave && !this.core.$$isSuspended()) {
scheduleTask("perform-replicate-after-save", 250, () => this.core.$$replicateByEvent()); scheduleTask("perform-replicate-after-save", 250, () => this.core.$$replicateByEvent());
} }
}); });
eventHub.onEvent(EVENT_SETTING_SAVED, (setting) => {
if (this._replicatorType !== setting.remoteType) {
void this.setReplicator();
}
});
return Promise.resolve(true); return Promise.resolve(true);
} }
@@ -50,7 +58,12 @@ export class ModuleReplicator extends AbstractModule implements ICoreModule {
this._log($msg("Replicator.Message.InitialiseFatalError"), LOG_LEVEL_NOTICE); this._log($msg("Replicator.Message.InitialiseFatalError"), LOG_LEVEL_NOTICE);
return false; return false;
} }
if (this.core.replicator) {
await this.core.replicator.closeReplication();
this._log("Replicator closed for changing", LOG_LEVEL_VERBOSE);
}
this.core.replicator = replicator; this.core.replicator = replicator;
this._replicatorType = this.settings.remoteType;
await yieldMicrotask(); await yieldMicrotask();
return true; return true;
} }

View File

@@ -138,6 +138,8 @@ export class ModuleObsidianSettings extends AbstractObsidianModule implements IO
jwtKid: settings.jwtKid, jwtKid: settings.jwtKid,
jwtExpDuration: settings.jwtExpDuration, jwtExpDuration: settings.jwtExpDuration,
jwtSub: settings.jwtSub, jwtSub: settings.jwtSub,
useRequestAPI: settings.useRequestAPI,
bucketPrefix: settings.bucketPrefix,
}; };
settings.encryptedCouchDBConnection = await this.encryptConfigurationItem( settings.encryptedCouchDBConnection = await this.encryptConfigurationItem(
JSON.stringify(connectionSetting), JSON.stringify(connectionSetting),

View File

@@ -1475,6 +1475,10 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
new Setting(paneEl).autoWireText("region", { holdValue: true }); new Setting(paneEl).autoWireText("region", { holdValue: true });
new Setting(paneEl).autoWireText("bucket", { holdValue: true }); new Setting(paneEl).autoWireText("bucket", { holdValue: true });
new Setting(paneEl).autoWireText("bucketPrefix", {
holdValue: true,
placeHolder: "vaultname/",
});
new Setting(paneEl).autoWireToggle("useCustomRequestHandler", { holdValue: true }); new Setting(paneEl).autoWireToggle("useCustomRequestHandler", { holdValue: true });
new Setting(paneEl).autoWireTextArea("bucketCustomHeaders", { new Setting(paneEl).autoWireTextArea("bucketCustomHeaders", {
@@ -1503,6 +1507,7 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
"bucket", "bucket",
"useCustomRequestHandler", "useCustomRequestHandler",
"bucketCustomHeaders", "bucketCustomHeaders",
"bucketPrefix",
]) ])
.addOnUpdate(onlyOnMinIO); .addOnUpdate(onlyOnMinIO);
}); });
@@ -1662,6 +1667,10 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
onUpdate: enableOnlySyncDisabled, onUpdate: enableOnlySyncDisabled,
}); });
new Setting(paneEl).autoWireTextArea("couchDB_CustomHeaders", { holdValue: true }); new Setting(paneEl).autoWireTextArea("couchDB_CustomHeaders", { holdValue: true });
new Setting(paneEl).autoWireToggle("useRequestAPI", {
holdValue: true,
onUpdate: enableOnlySyncDisabled,
});
new Setting(paneEl) new Setting(paneEl)
.setName($msg("obsidianLiveSyncSettingTab.nameTestDatabaseConnection")) .setName($msg("obsidianLiveSyncSettingTab.nameTestDatabaseConnection"))
.setClass("wizardHidden") .setClass("wizardHidden")
@@ -1706,6 +1715,7 @@ The pane also can be launched by \`P2P Replicator\` command from the Command Pal
"jwtKid", "jwtKid",
"useJWT", "useJWT",
"couchDB_CustomHeaders", "couchDB_CustomHeaders",
"useRequestAPI",
]) ])
.addOnUpdate(onlyOnCouchDB); .addOnUpdate(onlyOnCouchDB);
}); });
@@ -3104,9 +3114,9 @@ ${stringifyYaml(pluginConfig)}`;
onUpdate: visibleOnly(() => this.isConfiguredAs("disableWorkerForGeneratingChunks", false)), onUpdate: visibleOnly(() => this.isConfiguredAs("disableWorkerForGeneratingChunks", false)),
}); });
}); });
void addPanel(paneEl, "Edge case addressing (Networking)").then((paneEl) => { // void addPanel(paneEl, "Edge case addressing (Networking)").then((paneEl) => {
new Setting(paneEl).autoWireToggle("useRequestAPI"); // new Setting(paneEl).autoWireToggle("useRequestAPI");
}); // });
void addPanel(paneEl, "Compatibility (Trouble addressed)").then((paneEl) => { void addPanel(paneEl, "Compatibility (Trouble addressed)").then((paneEl) => {
new Setting(paneEl).autoWireToggle("disableCheckingConfigMismatch"); new Setting(paneEl).autoWireToggle("disableCheckingConfigMismatch");
}); });
@@ -3547,6 +3557,7 @@ ${stringifyYaml(pluginConfig)}`;
const id = this.plugin.settings.accessKey; const id = this.plugin.settings.accessKey;
const key = this.plugin.settings.secretKey; const key = this.plugin.settings.secretKey;
const bucket = this.plugin.settings.bucket; const bucket = this.plugin.settings.bucket;
const prefix = this.plugin.settings.bucketPrefix;
const region = this.plugin.settings.region; const region = this.plugin.settings.region;
const endpoint = this.plugin.settings.endpoint; const endpoint = this.plugin.settings.endpoint;
const useCustomRequestHandler = this.plugin.settings.useCustomRequestHandler; const useCustomRequestHandler = this.plugin.settings.useCustomRequestHandler;
@@ -3556,6 +3567,7 @@ ${stringifyYaml(pluginConfig)}`;
key, key,
endpoint, endpoint,
bucket, bucket,
prefix,
this.plugin.simpleStore, this.plugin.simpleStore,
this.plugin, this.plugin,
useCustomRequestHandler, useCustomRequestHandler,

View File

@@ -385,6 +385,10 @@ export const SettingInformation: Partial<Record<keyof AllSettings, Configuration
name: "Show status icon instead of file warnings banner", name: "Show status icon instead of file warnings banner",
desc: "If enabled, the ⛔ icon will be shown inside the status instead of the file warnings banner. No details will be shown.", desc: "If enabled, the ⛔ icon will be shown inside the status instead of the file warnings banner. No details will be shown.",
}, },
bucketPrefix: {
name: "File prefix on the bucket",
desc: "Effectively a directory. Should end with `/`. e.g., `vault-name/`.",
},
}; };
function translateInfo(infoSrc: ConfigurationItem | undefined | false) { function translateInfo(infoSrc: ConfigurationItem | undefined | false) {
if (!infoSrc) return false; if (!infoSrc) return false;