From 7ca5ac5ac747a85b1b3ad0247a3b8b02306e4583 Mon Sep 17 00:00:00 2001 From: vorotamoroz Date: Thu, 17 Oct 2024 10:19:08 +0100 Subject: [PATCH] 0.24.0.dev-rc3 --- manifest-beta.json | 2 +- package-lock.json | 4 +-- package.json | 2 +- src/features/ConfigSync/CmdConfigSync.ts | 32 +++++++++---------- .../HiddenFileSync/CmdHiddenFileSync.ts | 22 ++++++------- src/features/LiveSyncCommands.ts | 12 +++---- src/main.ts | 8 ++--- src/modules/AbstractObsidianModule.ts | 14 ++++---- src/modules/extras/ModuleDev.ts | 5 ++- updates.md | 7 ++++ 10 files changed, 59 insertions(+), 49 deletions(-) diff --git a/manifest-beta.json b/manifest-beta.json index 8c4cc40..fee0d43 100644 --- a/manifest-beta.json +++ b/manifest-beta.json @@ -1,7 +1,7 @@ { "id": "obsidian-livesync", "name": "Self-hosted LiveSync", - "version": "0.24.0.dev-rc2", + "version": "0.24.0.dev-rc3", "minAppVersion": "0.9.12", "description": "Community implementation of self-hosted livesync. Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.", "author": "vorotamoroz", diff --git a/package-lock.json b/package-lock.json index 6369a8d..f218c14 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "obsidian-livesync", - "version": "0.24.0.dev-rc2", + "version": "0.24.0.dev-rc3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "obsidian-livesync", - "version": "0.24.0.dev-rc2", + "version": "0.24.0.dev-rc3", "license": "MIT", "dependencies": { "@aws-sdk/client-s3": "^3.645.0", diff --git a/package.json b/package.json index 9c8ef46..8db3c5b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-livesync", - "version": "0.24.0.dev-rc2", + "version": "0.24.0.dev-rc3", "description": "Reflect your vault changes to some other devices immediately. Please make sure to disable other synchronize solutions to avoid content corruption or duplication.", "main": "main.js", "type": "module", diff --git a/src/features/ConfigSync/CmdConfigSync.ts b/src/features/ConfigSync/CmdConfigSync.ts index 2c94712..2ea6ea7 100644 --- a/src/features/ConfigSync/CmdConfigSync.ts +++ b/src/features/ConfigSync/CmdConfigSync.ts @@ -343,7 +343,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { get useSyncPluginEtc() { return this.plugin.settings.usePluginEtc; } - $isThisModuleEnabled() { + _isThisModuleEnabled() { return this.plugin.settings.usePluginSync; } @@ -352,7 +352,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { pluginList: IPluginDataExDisplay[] = []; showPluginSyncModal() { - if (!this.$isThisModuleEnabled()) { + if (!this._isThisModuleEnabled()) { return; } if (this.pluginDialog) { @@ -417,7 +417,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { return this.getFileCategory(filePath) != ""; } async $everyOnDatabaseInitialized(showNotice: boolean) { - if (!this.$isThisModuleEnabled()) return true; + if (!this._isThisModuleEnabled()) return true; try { Logger("Scanning customizations..."); await this.scanAllConfigFiles(showNotice); @@ -429,7 +429,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { return true; } async $everyBeforeReplicate(showNotice: boolean) { - if (!this.$isThisModuleEnabled()) return true; + if (!this._isThisModuleEnabled()) return true; if (this.settings.autoSweepPlugins) { await this.scanAllConfigFiles(showNotice); return true; @@ -437,8 +437,8 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { return true; } async $everyOnResumeProcess(): Promise { - if (!this.$isThisModuleEnabled()) return true; - if (this.$isMainSuspended()) { + if (!this._isThisModuleEnabled()) return true; + if (this._isMainSuspended()) { return true; } if (this.settings.autoSweepPlugins) { @@ -449,7 +449,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { } $everyAfterResumeProcess(): Promise { const q = activeDocument.querySelector(`.livesync-ribbon-showcustom`); - q?.toggleClass("sls-hidden", !this.$isThisModuleEnabled()); + q?.toggleClass("sls-hidden", !this._isThisModuleEnabled()); return Promise.resolve(true); } async reloadPluginList(showMessage: boolean) { @@ -754,7 +754,7 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { } async updatePluginList(showMessage: boolean, updatedDocumentPath?: FilePathWithPrefix): Promise { - if (!this.$isThisModuleEnabled()) { + if (!this._isThisModuleEnabled()) { this.pluginScanProcessor.clearQueue(); this.pluginList = []; pluginList.set(this.pluginList) @@ -1019,10 +1019,10 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { } async $anyModuleParsedReplicationResultItem(docs: PouchDB.Core.ExistingDocument) { if (!docs._id.startsWith(ICXHeader)) return undefined; - if (this.$isThisModuleEnabled()) { + if (this._isThisModuleEnabled()) { await this.updatePluginList(false, (docs as AnyEntry).path ? (docs as AnyEntry).path : this.getPath((docs as AnyEntry))); } - if (this.$isThisModuleEnabled() && this.plugin.settings.notifyPluginOrSettingUpdated) { + if (this._isThisModuleEnabled() && this.plugin.settings.notifyPluginOrSettingUpdated) { if (!this.pluginDialog || (this.pluginDialog && !this.pluginDialog.isOpened())) { const fragment = createFragment((doc) => { doc.createEl("span", undefined, (a) => { @@ -1063,9 +1063,9 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { } async $everyRealizeSettingSyncMode(): Promise { this.periodicPluginSweepProcessor?.disable(); - if (!this.$isMainReady) return true; - if (!this.$isMainSuspended()) return true; - if (!this.$isThisModuleEnabled()) return true; + if (!this._isMainReady) return true; + if (!this._isMainSuspended()) return true; + if (!this._isThisModuleEnabled()) return true; if (this.settings.autoSweepPlugins) { await this.scanAllConfigFiles(false); } @@ -1323,9 +1323,9 @@ export class ConfigSync extends LiveSyncCommands implements IObsidianModule { } async watchVaultRawEventsAsync(path: FilePath) { - // if (!this.$isMainReady) return true; - // if (!this.$isMainSuspended()) return true; - if (!this.$isThisModuleEnabled()) return true; + if (!this._isMainReady) return true; + if (!this._isMainSuspended()) return true; + if (!this._isThisModuleEnabled()) return true; if (!this.isTargetPath(path)) return false; const stat = await this.plugin.storageAccess.statHidden(path); // Make sure that target is a file. diff --git a/src/features/HiddenFileSync/CmdHiddenFileSync.ts b/src/features/HiddenFileSync/CmdHiddenFileSync.ts index b86a088..5446036 100644 --- a/src/features/HiddenFileSync/CmdHiddenFileSync.ts +++ b/src/features/HiddenFileSync/CmdHiddenFileSync.ts @@ -14,11 +14,11 @@ import type { IObsidianModule } from "../../modules/AbstractObsidianModule.ts"; export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule { - $isThisModuleEnabled() { + _isThisModuleEnabled() { return this.plugin.settings.syncInternalFiles; } - periodicInternalFileScanProcessor: PeriodicProcessor = new PeriodicProcessor(this.plugin, async () => this.$isThisModuleEnabled() && this.$isDatabaseReady() && await this.syncInternalFilesAndDatabase("push", false)); + periodicInternalFileScanProcessor: PeriodicProcessor = new PeriodicProcessor(this.plugin, async () => this._isThisModuleEnabled() && this._isDatabaseReady() && await this.syncInternalFilesAndDatabase("push", false)); get kvDB() { return this.plugin.kvDB; @@ -39,7 +39,7 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule }); } async $everyOnDatabaseInitialized(showNotice: boolean) { - if (this.$isThisModuleEnabled()) { + if (this._isThisModuleEnabled()) { try { Logger("Synchronizing hidden files..."); await this.syncInternalFilesAndDatabase("push", showNotice); @@ -52,7 +52,7 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule return true; } async $everyBeforeReplicate(showNotice: boolean) { - if (this.$isThisModuleEnabled() && this.$isDatabaseReady() && this.settings.syncInternalFilesBeforeReplication && !this.settings.watchInternalFileChanges) { + if (this._isThisModuleEnabled() && this._isDatabaseReady() && this.settings.syncInternalFilesBeforeReplication && !this.settings.watchInternalFileChanges) { await this.syncInternalFilesAndDatabase("push", showNotice); } return true; @@ -61,22 +61,22 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule async $everyOnResumeProcess(): Promise { this.periodicInternalFileScanProcessor?.disable(); - if (this.$isMainSuspended()) + if (this._isMainSuspended()) return true; - if (this.$isThisModuleEnabled()) { + if (this._isThisModuleEnabled()) { await this.syncInternalFilesAndDatabase("safe", false); } - this.periodicInternalFileScanProcessor.enable(this.$isThisModuleEnabled() && this.settings.syncInternalFilesInterval ? (this.settings.syncInternalFilesInterval * 1000) : 0); + this.periodicInternalFileScanProcessor.enable(this._isThisModuleEnabled() && this.settings.syncInternalFilesInterval ? (this.settings.syncInternalFilesInterval * 1000) : 0); return true } $everyRealizeSettingSyncMode(): Promise { this.periodicInternalFileScanProcessor?.disable(); - if (this.$isMainSuspended()) + if (this._isMainSuspended()) return Promise.resolve(true); if (!this.plugin.isReady) return Promise.resolve(true); - this.periodicInternalFileScanProcessor.enable(this.$isThisModuleEnabled() && this.settings.syncInternalFilesInterval ? (this.settings.syncInternalFilesInterval * 1000) : 0); + this.periodicInternalFileScanProcessor.enable(this._isThisModuleEnabled() && this.settings.syncInternalFilesInterval ? (this.settings.syncInternalFilesInterval * 1000) : 0); return Promise.resolve(true); } @@ -98,7 +98,7 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule return await this.watchVaultRawEventsAsync(path); } async watchVaultRawEventsAsync(path: FilePath): Promise { - if (!this.$isThisModuleEnabled()) return false; + if (!this._isThisModuleEnabled()) return false; if (!isInternalMetadata(path)) return false; // Exclude files handled by customization sync @@ -274,7 +274,7 @@ export class HiddenFileSync extends LiveSyncCommands implements IObsidianModule } async $anyProcessOptionalSyncFiles(doc: LoadedEntry): Promise { - if (isInternalMetadata(doc._id) && this.$isThisModuleEnabled()) { + if (isInternalMetadata(doc._id) && this._isThisModuleEnabled()) { //system file const filename = getPath(doc); if (await this.plugin.$$isTargetFile(filename)) { diff --git a/src/features/LiveSyncCommands.ts b/src/features/LiveSyncCommands.ts index 8ea24c4..d0e3fa3 100644 --- a/src/features/LiveSyncCommands.ts +++ b/src/features/LiveSyncCommands.ts @@ -31,13 +31,13 @@ export abstract class LiveSyncCommands { abstract onunload(): void; abstract onload(): void | Promise; - $isMainReady() { - return this.plugin.$isMainReady(); + _isMainReady() { + return this.plugin._isMainReady(); } - $isMainSuspended() { - return this.plugin.$isMainSuspended(); + _isMainSuspended() { + return this.plugin._isMainSuspended(); } - $isDatabaseReady() { - return this.plugin.$isDatabaseReady(); + _isDatabaseReady() { + return this.plugin._isDatabaseReady(); } } diff --git a/src/main.ts b/src/main.ts index 7f8e63e..b9366cb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -618,10 +618,10 @@ export default class ObsidianLiveSyncPlugin extends Plugin implements LiveSyncLo $everyModuleTestMultiDevice(): Promise { return InterceptiveEvery; } $$addTestResult(name: string, key: string, result: boolean, summary?: string, message?: string): void { throwShouldBeOverridden(); } - $isMainReady(): boolean { return this.isReady; } - $isMainSuspended(): boolean { return this.suspended; } - $isThisModuleEnabled(): boolean { return true; } - $isDatabaseReady(): boolean { return this.localDatabase.isReady; } + _isMainReady(): boolean { return this.isReady; } + _isMainSuspended(): boolean { return this.suspended; } + _isThisModuleEnabled(): boolean { return true; } + _isDatabaseReady(): boolean { return this.localDatabase.isReady; } $anyGetAppId(): Promise { return InterceptiveAny; } } diff --git a/src/modules/AbstractObsidianModule.ts b/src/modules/AbstractObsidianModule.ts index 6bef67d..60e9b3b 100644 --- a/src/modules/AbstractObsidianModule.ts +++ b/src/modules/AbstractObsidianModule.ts @@ -38,18 +38,18 @@ export abstract class AbstractObsidianModule extends AbstractModule { saveSettings = this.plugin.saveSettings.bind(this.plugin); - $isMainReady() { - return this.core.$isMainReady(); + _isMainReady() { + return this.core._isMainReady(); } - $isMainSuspended() { - return this.core.$isMainSuspended(); + _isMainSuspended() { + return this.core._isMainSuspended(); } - $isDatabaseReady() { - return this.core.$isDatabaseReady(); + _isDatabaseReady() { + return this.core._isDatabaseReady(); } //should be overridden - $isThisModuleEnabled() { + _isThisModuleEnabled() { return true } } \ No newline at end of file diff --git a/src/modules/extras/ModuleDev.ts b/src/modules/extras/ModuleDev.ts index bd7ed9b..42cb034 100644 --- a/src/modules/extras/ModuleDev.ts +++ b/src/modules/extras/ModuleDev.ts @@ -9,9 +9,12 @@ import { writable } from "svelte/store"; export class ModuleDev extends AbstractObsidianModule implements IObsidianModule { + $everyOnloadStart(): Promise { + __onMissingTranslation(() => { }); + return Promise.resolve(true); + } $everyOnloadAfterLoadSettings(): Promise { if (!this.settings.enableDebugTools) return Promise.resolve(true); - __onMissingTranslation(() => { }); // eslint-disable-next-line no-unused-labels __onMissingTranslation((key) => { const now = new Date(); diff --git a/updates.md b/updates.md index 9323acb..a286c07 100644 --- a/updates.md +++ b/updates.md @@ -23,6 +23,13 @@ Thank you, and I hope your troubles will be resolved! --- +## 0.24.0.dev-rc3 + +### Fixed + +- No longer Missing Translation Warning is shown in the console. +- Fixed the issue where some functions were not working properly (`_` started functions). + ## 0.24.0.dev-rc2 ### Fixed