@jr2804/livesync-cli 1.0.17-cli.1 → 1.0.21-cli.1

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.
Files changed (2) hide show
  1. package/dist/index.cjs +549 -313
  2. package/package.json +1 -1
package/dist/index.cjs CHANGED
@@ -7111,8 +7111,7 @@ var ReplicationService = class extends ServiceBase {
7111
7111
  }
7112
7112
  return activeReplicator;
7113
7113
  }
7114
- async replicateAllToRemote(showingNotice = false) {
7115
- if (!this.appLifecycleService.isReady()) return false;
7114
+ async performReplicateAllToRemote(showingNotice) {
7116
7115
  if (!await this.onBeforeReplicate(showingNotice)) {
7117
7116
  this._log(this.context.translate("Replicator.Message.SomeModuleFailed"), 64);
7118
7117
  return false;
@@ -7125,8 +7124,7 @@ var ReplicationService = class extends ServiceBase {
7125
7124
  if (checkResult == "CHECKAGAIN") return await activeReplicator.replicateAllToServer(currentSettings, showingNotice);
7126
7125
  return !checkResult;
7127
7126
  }
7128
- async replicateAllFromRemote(showingNotice = false) {
7129
- if (!this.appLifecycleService.isReady()) return false;
7127
+ async performReplicateAllFromRemote(showingNotice) {
7130
7128
  const activeReplicator = this.getActiveReplicatorFor("fetching data from remote");
7131
7129
  if (!activeReplicator) return false;
7132
7130
  const currentSettings = this.settingService.currentSettings();
@@ -7135,6 +7133,40 @@ var ReplicationService = class extends ServiceBase {
7135
7133
  if (checkResult == "CHECKAGAIN") return await activeReplicator.replicateAllFromServer(currentSettings, showingNotice);
7136
7134
  return !checkResult;
7137
7135
  }
7136
+ async replicateAllToRemote(showingNotice = false) {
7137
+ if (!this.appLifecycleService.isReady()) return false;
7138
+ return await this.performReplicateAllToRemote(showingNotice);
7139
+ }
7140
+ async replicateAllFromRemote(showingNotice = false) {
7141
+ if (!this.appLifecycleService.isReady()) return false;
7142
+ return await this.performReplicateAllFromRemote(showingNotice);
7143
+ }
7144
+ /**
7145
+ * Perform a full upload owned by an active rebuild while the physical database is ready.
7146
+ *
7147
+ * This concrete maintenance entry point is intentionally absent from `IReplicationService`;
7148
+ * it is not a general application-readiness bypass.
7149
+ */
7150
+ async replicateAllToRemoteForRebuild(showingNotice = false) {
7151
+ if (!this.databaseService.isDatabaseReady()) {
7152
+ this._log("The selected local database is not ready for the rebuild upload.", 64);
7153
+ return false;
7154
+ }
7155
+ return await this.performReplicateAllToRemote(showingNotice);
7156
+ }
7157
+ /**
7158
+ * Perform a full download owned by an active rebuild while the physical database is ready.
7159
+ *
7160
+ * This concrete maintenance entry point is intentionally absent from `IReplicationService`;
7161
+ * it is not a general application-readiness bypass.
7162
+ */
7163
+ async replicateAllFromRemoteForRebuild(showingNotice = false) {
7164
+ if (!this.databaseService.isDatabaseReady()) {
7165
+ this._log("The selected local database is not ready for the rebuild download.", 64);
7166
+ return false;
7167
+ }
7168
+ return await this.performReplicateAllFromRemote(showingNotice);
7169
+ }
7138
7170
  _getReplicatorAndPerform(action, perform) {
7139
7171
  const activeReplicator = this.getActiveReplicatorFor(action);
7140
7172
  if (!activeReplicator) return Promise.resolve();
@@ -7232,6 +7264,18 @@ var ReplicatorService = class extends ServiceBase {
7232
7264
  this._replicatorType = void 0;
7233
7265
  return true;
7234
7266
  }
7267
+ async discardFailedReplicator(replicator) {
7268
+ if (this._activeReplicator === replicator) {
7269
+ this._activeReplicator = void 0;
7270
+ this._replicatorType = void 0;
7271
+ }
7272
+ try {
7273
+ await Promise.resolve(replicator.closeReplication());
7274
+ } catch (error) {
7275
+ this._log("Failed to close a replicator after its initialisation failed.", 16);
7276
+ this._log(error, 16);
7277
+ }
7278
+ }
7235
7279
  async _initialiseReplicator() {
7236
7280
  const message = this.context.translate("Replicator.Message.InitialiseFatalError");
7237
7281
  const setting = this.settingService.currentSettings();
@@ -7271,19 +7315,23 @@ var ReplicatorService = class extends ServiceBase {
7271
7315
  this._replicatorType = replicatorType;
7272
7316
  this.replicationStatics.value = { ...DEFAULT_REPLICATION_STATICS };
7273
7317
  await yieldMicrotask();
7274
- if (!await newReplicator.initializeDatabaseForReplication()) {
7275
- this._log("Failed to initialise the replicator's local node information.");
7276
- this._activeReplicator = void 0;
7277
- this._replicatorType = void 0;
7278
- this._unresolvedErrorManager.showError(message, 64);
7279
- return false;
7280
- }
7281
- if (!await this.onReplicatorInitialised()) {
7282
- this._log("Failed to initialise the replicator, onReplicatorInitialised reported some problems.");
7283
- this._activeReplicator = void 0;
7284
- this._replicatorType = void 0;
7318
+ try {
7319
+ if (!await newReplicator.initializeDatabaseForReplication()) {
7320
+ this._log("Failed to initialise the replicator's local node information.");
7321
+ await this.discardFailedReplicator(newReplicator);
7322
+ this._unresolvedErrorManager.showError(message, 64);
7323
+ return false;
7324
+ }
7325
+ if (!await this.onReplicatorInitialised()) {
7326
+ this._log("Failed to initialise the replicator, onReplicatorInitialised reported some problems.");
7327
+ await this.discardFailedReplicator(newReplicator);
7328
+ this._unresolvedErrorManager.showError(message, 64);
7329
+ return false;
7330
+ }
7331
+ } catch (error) {
7332
+ await this.discardFailedReplicator(newReplicator);
7285
7333
  this._unresolvedErrorManager.showError(message, 64);
7286
- return false;
7334
+ throw error;
7287
7335
  }
7288
7336
  const remoteTypeDisplay = replicatorType === RemoteTypes.REMOTE_COUCHDB ? "CouchDB" : replicatorType;
7289
7337
  this._log(`Replicator (${remoteTypeDisplay}) initialised and activated`, 16);
@@ -10457,10 +10505,10 @@ var HeadlessAPIService = class extends InjectableAPIService {
10457
10505
  return "headless-app";
10458
10506
  }
10459
10507
  getAppVersion() {
10460
- return `1.0.17`;
10508
+ return `1.0.21`;
10461
10509
  }
10462
10510
  getPluginVersion() {
10463
- return `1.0.17`;
10511
+ return `1.0.21`;
10464
10512
  }
10465
10513
  getPlatform() {
10466
10514
  return "server";
@@ -18891,16 +18939,14 @@ var LiveSyncLocalDB = class {
18891
18939
  async _prepareHashFunctions() {
18892
18940
  await this._managers?.prepareHashFunction();
18893
18941
  }
18894
- onunload() {
18895
- this.env.services.databaseEvents.onUnloadDatabase(this);
18896
- this.localDatabase.removeAllListeners();
18897
- }
18898
18942
  refreshSettings() {
18899
18943
  const settings = this.env.services.setting.currentSettings();
18900
18944
  this.settings = settings;
18901
18945
  this._prepareHashFunctions();
18902
18946
  }
18903
18947
  offRemoteChunkFetchedHandler;
18948
+ databaseCloseCleanup;
18949
+ databaseUnloadNotification;
18904
18950
  constructor(dbname, env) {
18905
18951
  this.auth = {
18906
18952
  username: "",
@@ -18911,12 +18957,68 @@ var LiveSyncLocalDB = class {
18911
18957
  this._log = createInstanceLogFunction("LiveSyncLocalDB", this.env.services.API);
18912
18958
  this.refreshSettings();
18913
18959
  }
18960
+ /** Notify dependent services at most once for each physical database lifecycle. */
18961
+ notifyDatabaseUnload() {
18962
+ if (!this.databaseUnloadNotification) this.databaseUnloadNotification = Promise.resolve().then(async () => {
18963
+ await this.env.services.databaseEvents.onUnloadDatabase(this);
18964
+ });
18965
+ return this.databaseUnloadNotification;
18966
+ }
18967
+ onunload() {
18968
+ this.notifyDatabaseUnload();
18969
+ }
18914
18970
  async close() {
18915
18971
  this._log("Database closed (by close)");
18916
18972
  this.isReady = false;
18917
18973
  this.offRemoteChunkFetchedHandler?.();
18918
- if (this.localDatabase != null) await this.localDatabase.close();
18919
- await this.env.services.databaseEvents.onUnloadDatabase(this);
18974
+ this.offRemoteChunkFetchedHandler = void 0;
18975
+ if (this.localDatabase != null) {
18976
+ const database = this.localDatabase;
18977
+ await database.close();
18978
+ if (this.databaseCloseCleanup?.database === database) await this.databaseCloseCleanup.promise;
18979
+ if (this.localDatabase === database) this.localDatabase = null;
18980
+ }
18981
+ this._managers = void 0;
18982
+ await this.notifyDatabaseUnload();
18983
+ }
18984
+ async teardownDatabaseDependencies(managers) {
18985
+ try {
18986
+ await Promise.resolve(this.env.services.replicator.getActiveReplicator()?.closeReplication());
18987
+ } catch (error) {
18988
+ this._log("Failed to close replication while tearing down the local database.", 16);
18989
+ this._log(error, 16);
18990
+ }
18991
+ try {
18992
+ await managers.teardownManagers();
18993
+ } catch (error) {
18994
+ this._log("Failed to tear down managers while closing the local database.", 16);
18995
+ this._log(error, 16);
18996
+ }
18997
+ }
18998
+ async rollbackFailedInitialisation(database, managers) {
18999
+ this.isReady = false;
19000
+ this.offRemoteChunkFetchedHandler?.();
19001
+ this.offRemoteChunkFetchedHandler = void 0;
19002
+ const closeCleanup = this.databaseCloseCleanup?.database === database ? this.databaseCloseCleanup : void 0;
19003
+ if (closeCleanup) await closeCleanup.promise;
19004
+ else {
19005
+ database.removeAllListeners();
19006
+ await this.teardownDatabaseDependencies(managers);
19007
+ try {
19008
+ await database.close();
19009
+ } catch (error) {
19010
+ this._log("Failed to close the database after its initialisation was rejected.", 16);
19011
+ this._log(error, 16);
19012
+ }
19013
+ }
19014
+ if (this.localDatabase === database) this.localDatabase = null;
19015
+ if (this._managers === managers) this._managers = void 0;
19016
+ try {
19017
+ await this.notifyDatabaseUnload();
19018
+ } catch (error) {
19019
+ this._log("A database unload handler failed after initialisation was rejected.", 16);
19020
+ this._log(error, 16);
19021
+ }
18920
19022
  }
18921
19023
  onNewLeaf(chunk) {
18922
19024
  this.managers.chunkManager?.emitEvent(EVENT_CHUNK_FETCHED, chunk);
@@ -18933,6 +19035,7 @@ var LiveSyncLocalDB = class {
18933
19035
  revs_limit: 100,
18934
19036
  deterministic_revs: true
18935
19037
  });
19038
+ this.databaseUnloadNotification = void 0;
18936
19039
  const manager = new LiveSyncManagers({
18937
19040
  database: this.localDatabase,
18938
19041
  APIService: this.env.services.API,
@@ -18942,31 +19045,45 @@ var LiveSyncLocalDB = class {
18942
19045
  databaseService: this.env.services.database
18943
19046
  });
18944
19047
  this._managers = manager;
18945
- if (!await this.env.services.databaseEvents.onDatabaseInitialisation(this)) this._log("Initializing Database has been failed on some module", 64);
18946
- this._log("Opening Database...");
18947
- this._log("Database info", 16);
18948
- this._log(JSON.stringify(await this.localDatabase.info(), null, 2), 16);
18949
- await this.managers.initialise();
18950
- this.localDatabase.on("close", () => {
18951
- this._log("Database closed.");
18952
- this.isReady = false;
18953
- this.localDatabase.removeAllListeners();
18954
- this.env.services.replicator.getActiveReplicator()?.closeReplication();
18955
- this.managers.teardownManagers();
18956
- });
18957
- const _instance = new FallbackWeakRef(this);
18958
- const unload = this.env.services.context.events.onEvent(REMOTE_CHUNK_FETCHED, (chunk) => {
18959
- if (_instance.deref() == null) unload();
18960
- _instance.deref()?.onNewLeaf(chunk);
18961
- });
18962
- this.offRemoteChunkFetchedHandler = unload;
18963
- this.isReady = true;
18964
- if (!await this.env.services.databaseEvents.onDatabaseHasReady()) {
18965
- this._log("Some module has prevented the database from being ready. The database is initialised but not ready for use.", 64);
18966
- return false;
19048
+ const openedDatabase = this.localDatabase;
19049
+ this.databaseCloseCleanup = void 0;
19050
+ try {
19051
+ if (!await this.env.services.databaseEvents.onDatabaseInitialisation(this)) {
19052
+ await this.rollbackFailedInitialisation(openedDatabase, manager);
19053
+ this._log("Database initialisation was rejected by a required module.", 64);
19054
+ return false;
19055
+ }
19056
+ this._log("Opening Database...");
19057
+ this._log("Database info", 16);
19058
+ this._log(JSON.stringify(await openedDatabase.info(), null, 2), 16);
19059
+ await manager.initialise();
19060
+ openedDatabase.on("close", () => {
19061
+ this._log("Database closed.");
19062
+ this.isReady = false;
19063
+ openedDatabase.removeAllListeners();
19064
+ if (this.databaseCloseCleanup?.database !== openedDatabase) this.databaseCloseCleanup = {
19065
+ database: openedDatabase,
19066
+ promise: this.teardownDatabaseDependencies(manager)
19067
+ };
19068
+ });
19069
+ const _instance = new FallbackWeakRef(this);
19070
+ const unload = this.env.services.context.events.onEvent(REMOTE_CHUNK_FETCHED, (chunk) => {
19071
+ if (_instance.deref() == null) unload();
19072
+ _instance.deref()?.onNewLeaf(chunk);
19073
+ });
19074
+ this.offRemoteChunkFetchedHandler = unload;
19075
+ this.isReady = true;
19076
+ if (!await this.env.services.databaseEvents.onDatabaseHasReady() || this.localDatabase !== openedDatabase || !this.isReady) {
19077
+ await this.rollbackFailedInitialisation(openedDatabase, manager);
19078
+ this._log("Some module has prevented the database from being ready. The database is initialised but not ready for use.", 64);
19079
+ return false;
19080
+ }
19081
+ this._log("Database is now ready.");
19082
+ return true;
19083
+ } catch (error) {
19084
+ await this.rollbackFailedInitialisation(openedDatabase, manager);
19085
+ throw error;
18967
19086
  }
18968
- this._log("Database is now ready.");
18969
- return true;
18970
19087
  }
18971
19088
  /**
18972
19089
  * Retrieve all used and existing chunks in the database.
@@ -19039,6 +19156,7 @@ var LiveSyncLocalDB = class {
19039
19156
  };
19040
19157
  }
19041
19158
  async resetDatabase() {
19159
+ this.isReady = false;
19042
19160
  await this.managers.teardownManagers();
19043
19161
  this.env.services.replicator.getActiveReplicator()?.closeReplication();
19044
19162
  if (!await this.env.services.databaseEvents.onResetDatabase(this)) {
@@ -19046,10 +19164,12 @@ var LiveSyncLocalDB = class {
19046
19164
  return false;
19047
19165
  }
19048
19166
  Logger("Database closed for reset Database.");
19049
- this.isReady = false;
19050
19167
  await this.localDatabase.destroy();
19051
19168
  this.localDatabase = null;
19052
- await this.initializeDatabase();
19169
+ if (!await this.initializeDatabase()) {
19170
+ this._log("Local Database could not be reinitialised after reset.", 64);
19171
+ return false;
19172
+ }
19053
19173
  this._log("Local Database Reset", 64);
19054
19174
  return true;
19055
19175
  }
@@ -19222,9 +19342,7 @@ var DatabaseService = class extends ServiceBase {
19222
19342
  _localDatabase = null;
19223
19343
  services;
19224
19344
  onOpenDatabase = handlers().bailFirstFailure("onOpenDatabase");
19225
- /**
19226
- * Called after the local database has been reset.
19227
- */
19345
+ /** Called after the active database has been reset and successfully reinitialised. */
19228
19346
  onDatabaseReset = handlers().bailFirstFailure("onDatabaseReset");
19229
19347
  get localDatabase() {
19230
19348
  if (!this._localDatabase) throw new Error("Local database is not ready yet.");
@@ -19257,22 +19375,68 @@ var DatabaseService = class extends ServiceBase {
19257
19375
  if (this._localDatabase != null) await this._localDatabase.close();
19258
19376
  const vaultName = this.services.vault.getVaultName();
19259
19377
  this._log(this.context.translate("moduleLocalDatabase.logWaitingForReady"));
19260
- const env = { services: {
19378
+ const selectedDatabase = new LiveSyncLocalDB(vaultName, { services: {
19261
19379
  context: this.context,
19262
19380
  ...this.services,
19263
19381
  ...params,
19264
19382
  database: this
19265
- } };
19266
- this._localDatabase = new LiveSyncLocalDB(vaultName, env);
19267
- await this.onOpenDatabase(vaultName);
19268
- return await this.localDatabase.initializeDatabase();
19383
+ } });
19384
+ this._localDatabase = selectedDatabase;
19385
+ try {
19386
+ await this.onOpenDatabase(vaultName);
19387
+ const initialised = await selectedDatabase.initializeDatabase();
19388
+ if (!initialised && this._localDatabase === selectedDatabase) this._localDatabase = null;
19389
+ return initialised;
19390
+ } catch (error) {
19391
+ if (this._localDatabase === selectedDatabase) this._localDatabase = null;
19392
+ throw error;
19393
+ }
19269
19394
  }
19270
19395
  isDatabaseReady() {
19271
19396
  return this._localDatabase != null && this._localDatabase.isReady;
19272
19397
  }
19398
+ async discardFailedActiveDatabase(database) {
19399
+ if (this._localDatabase === database) this._localDatabase = null;
19400
+ try {
19401
+ await database.close();
19402
+ } catch (error) {
19403
+ this._log("Failed to close the active database after a rejected lifecycle transition.", 16);
19404
+ this._log(error, 16);
19405
+ }
19406
+ }
19273
19407
  async resetDatabase() {
19274
19408
  if (!this._localDatabase) return Promise.resolve(true);
19275
- return await this._localDatabase.resetDatabase();
19409
+ const activeDatabase = this._localDatabase;
19410
+ try {
19411
+ if (!await activeDatabase.resetDatabase()) {
19412
+ await this.discardFailedActiveDatabase(activeDatabase);
19413
+ return false;
19414
+ }
19415
+ if (!await this.onDatabaseReset()) {
19416
+ await this.discardFailedActiveDatabase(activeDatabase);
19417
+ return false;
19418
+ }
19419
+ return true;
19420
+ } catch (error) {
19421
+ await this.discardFailedActiveDatabase(activeDatabase);
19422
+ throw error;
19423
+ }
19424
+ }
19425
+ /**
19426
+ * Reset the database selected by the current settings.
19427
+ *
19428
+ * A `LiveSyncLocalDB` captures its name when constructed, so changing a
19429
+ * suffix does not retarget the active instance. This operation selects and
19430
+ * opens the settings-derived database before resetting it when necessary.
19431
+ * The formerly active physical database is closed but not destroyed.
19432
+ */
19433
+ async resetDatabaseForCurrentSettings(params) {
19434
+ const selectedDatabaseName = this.services.vault.getVaultName();
19435
+ if (this._localDatabase?.dbname !== selectedDatabaseName) {
19436
+ if (!await this.openDatabase(params)) return false;
19437
+ if (this._localDatabase?.dbname !== selectedDatabaseName) return false;
19438
+ }
19439
+ return await this.resetDatabase();
19276
19440
  }
19277
19441
  };
19278
19442
  //#endregion
@@ -23619,16 +23783,6 @@ var allMessages = {
23619
23783
  zh: "显示日志",
23620
23784
  "zh-tw": "顯示日誌"
23621
23785
  },
23622
- "moduleMigration.docUri": {
23623
- def: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
23624
- es: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README_ES.md#how-to-use",
23625
- fr: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
23626
- he: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
23627
- ja: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
23628
- ko: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
23629
- ru: "https://github.com/vrtmrz/obsidian-livesync/blob/main/README.md#how-to-use",
23630
- zh: "https://github.com/vrtmrz/obsidian-livesync/blob/main/docs/zh/README_zh.md#%E5%A6%82%E4%BD%95%E4%BD%BF%E7%94%A8"
23631
- },
23632
23786
  "moduleMigration.fix0256.buttons.checkItLater": {
23633
23787
  def: "Check it later",
23634
23788
  es: "Comprobarlo más tarde",
@@ -23860,28 +24014,6 @@ var allMessages = {
23860
24014
  zh: "您可能已经知道,Self-hosted LiveSync 更改了其默认行为和数据库结构。\n\n值得庆幸的是,在您的时间和努力下,远程数据库似乎已经迁移完成。恭喜!\n\n但是,我们还需要一点点操作。此设备的配置与远程数据库不兼容。我们需要再次从远程数据库获取。我们现在应该再次从远程获取吗?\n\n___注意:在更改配置并再次获取数据库之前,我们无法进行同步。___\n___注意2:chunks 是完全不可变的,我们只能获取元数据和差异",
23861
24015
  "zh-tw": "你可能已經知道,Self-hosted LiveSync 變更了預設行為與資料庫結構。\n\n值得慶幸的是,在你的努力下,遠端資料庫似乎已經完成遷移。恭喜!\n\n不過,還需要再多做一點。此裝置的設定與遠端資料庫不相容,我們需要再次從遠端資料庫抓取。現在要再次從遠端抓取嗎?\n\n___注意:在變更設定並再次抓取資料庫之前,我們無法進行同步。___\n___注意 2:chunks 完全不可變,我們只需要抓取中繼資料與差異部分。___"
23862
24016
  },
23863
- "moduleMigration.msgInitialSetup": {
23864
- def: "Your device has **not been set up yet**. Let me guide you through the setup process.\n\nPlease keep in mind that every dialogue content can be copied to the clipboard. If you need to refer to it later, you can paste it into a note in Obsidian. You can also translate it into your language using a translation tool.\n\nFirst, do you have **Setup URI**?\n\nNote: If you do not know what it is, please refer to the [documentation](${URI_DOC}).",
23865
- es: "Tu dispositivo **aún no ha sido configurado**. Permíteme guiarte a través del proceso de configuración.\n\nTen en cuenta que todo el contenido del diálogo se puede copiar al portapapeles. Si necesitas consultarlo más tarde, puedes pegarlo en una nota en Obsidian. También puedes traducirlo a tu idioma utilizando una herramienta de traducción.\n\nPrimero, ¿tienes **URI de configuración**?\n\nNota: Si no sabes qué es, consulta la [documentación](${URI_DOC}).",
23866
- fr: "Votre appareil n'a **pas encore été configuré**. Laissez-moi vous guider dans le processus de configuration.\n\nVeuillez noter que chaque contenu de boîte de dialogue peut être copié dans le presse-papiers. Si vous souhaitez vous y référer plus tard, vous pouvez le coller dans une note d'Obsidian. Vous pouvez également le traduire dans votre langue via un outil de traduction.\n\nTout d'abord, disposez-vous d'une **URI de configuration** ?\n\nNote : Si vous ne savez pas ce que c'est, consultez la [documentation](${URI_DOC}).",
23867
- he: "המכשיר שלך **טרם הוגדר**. אנחנו כאן לעזור לך בתהליך ההגדרה.\n\nשים לב שניתן להעתיק את תוכן כל דיאלוג ללוח. אם צריך לחזור אליו מאוחר יותר, ניתן להדביק אותו כפתק ב-Obsidian. ניתן גם לתרגם לשפתך בעזרת כלי תרגום.\n\nראשית, האם יש לך **Setup URI**?\n\nהערה: אם אינך יודע מהו, אנא עיין ב[תיעוד](${URI_DOC}).",
23868
- ja: "このデバイスは**まだセットアップされていません**。セットアッププロセスをご案内します。\n\nすべてのダイアログの内容はクリップボードにコピーできます。後で参照する必要があれば、Obsidianのノートに貼り付けてください。翻訳ツールを使ってお使いの言語に翻訳することもできます。\n\nまず、**セットアップURI**をお持ちですか?\n\n注意: それが何か分からない場合は、[documentation](${URI_DOC})を参照してください。",
23869
- ko: "이 기기는 **아직 초기 설정이 완료되지 않았습니다**. 지금부터 설정 과정을 안내해 드리겠습니다.\n\n모든 대화 내용은 클립보드에 복사할 수 있습니다. 나중에 참고하려면 Obsidian 노트에 붙여넣거나 번역 도구를 활용해 번역하셔도 됩니다.\n\n먼저, **Setup URI**를 가지고 계신가요?\n\n참고: Setup URI가 무엇인지 잘 모르시겠다면 [문서](${URI_DOC})를 참고해 주세요.",
23870
- ru: "Ваше устройство ещё не настроено. У вас есть Setup URI?",
23871
- zh: "您的设备**尚未设置**。让我引导您完成设置过程。\n\n请记住,每个对话框内容都可以复制到剪贴板。如果以后需要参考,可以将其粘贴到 Obsidian 的笔记中。您也可以使用翻译工具将其翻译成您的语言。\n\n首先,您有**设置 URI** 吗?\n\n注意:如果您不知道这是什么,请参阅[文档](${URI_DOC})",
23872
- "zh-tw": "你的裝置**尚未完成設定**。讓我引導你完成設定流程。\n\n請記得,每個對話框的內容都可以複製到剪貼簿。如果日後需要參考,可以貼到 Obsidian 的筆記中,也可以用翻譯工具翻成你的語言。\n\n首先,你有 **Setup URI** 嗎?\n\n注意:如果你不知道那是什麼,請參閱[說明文件](${URI_DOC})。"
23873
- },
23874
- "moduleMigration.msgRecommendSetupUri": {
23875
- def: "We strongly recommend that you generate a set-up URI and use it.\nIf you do not have knowledge about it, please refer to the [documentation](${URI_DOC}) (Sorry again, but it is important).\n\nHow do you want to set it up manually?",
23876
- es: "Te recomendamos encarecidamente que generes una URI de configuración y la utilices.\nSi no tienes conocimientos al respecto, consulta la [documentación](${URI_DOC}) (Lo siento de nuevo, pero es importante).\n\n¿Cómo quieres configurarlo manualmente?",
23877
- fr: "Nous recommandons vivement de générer une URI de configuration et de l'utiliser.\nSi vous ne connaissez pas, veuillez consulter la [documentation](${URI_DOC}) (Désolé encore, mais c'est important).\n\nComment souhaitez-vous effectuer la configuration manuellement ?",
23878
- he: "אנו ממליצים בחום לייצר Setup URI ולהשתמש בו.\nאם אין לך ידע בנושא, אנא עיין ב[תיעוד](${URI_DOC}) (מתנצלים שוב, אך זה חשוב).\n\nכיצד ברצונך להגדיר ידנית?",
23879
- ja: "セットアップURIを生成して使用することを強くお勧めします。\nこれについて知識がない場合は、[documentation](${URI_DOC})を参照してください(重要です)。\n\n手動でセットアップしますか?",
23880
- ko: "Setup URI를 생성해 사용하는 것을 강력히 권장합니다.\nSetup URI가 무엇인지 잘 모르시겠다면 [문서](${URI_DOC})를 참고해 주세요. 중요한 내용이니 꼭 확인하시기 바랍니다.\n\n직접 수동 설정을 진행하시겠습니까?",
23881
- ru: "Мы рекомендуем сгенерировать Setup URI.",
23882
- zh: "我们强烈建议您生成一个设置 URI 并使用它。\n如果您对此不了解,请参阅[文档](${URI_DOC})(再次抱歉,但这很重要)。\n\n您想如何手动设置?",
23883
- "zh-tw": "我們強烈建議你產生 Setup URI 並使用它。\n如果你對此不熟悉,請參閱[說明文件](${URI_DOC})(再次抱歉,但這很重要)。\n\n你想要如何手動設定?"
23884
- },
23885
24017
  "moduleMigration.msgSinceV02321": {
23886
24018
  def: "Since v0.23.21, the self-hosted LiveSync has changed the default behaviour and database structure. The following changes have been made:\n\n1. **Case sensitivity of filenames**\n The handling of filenames is now case-insensitive. This is a beneficial change for most platforms, other than Linux and iOS, which do not manage filename case sensitivity effectively.\n (On These, a warning will be displayed for files with the same name but different cases).\n\n2. **Revision handling of the chunks**\n Chunks are immutable, which allows their revisions to be fixed. This change will enhance the performance of file saving.\n\n___However, to enable either of these changes, both remote and local databases need to be rebuilt. This process takes a few minutes, and we recommend doing it when you have ample time.___\n\n- If you wish to maintain the previous behaviour, you can skip this process by using `${KEEP}`.\n- If you do not have enough time, please choose `${DISMISS}`. You will be prompted again later.\n- If you have rebuilt the database on another device, please select `${DISMISS}` and try synchronizing again. Since a difference has been detected, you will be prompted again.",
23887
24019
  es: "Desde la versión v0.23.21, Self-hosted LiveSync ha cambiado el comportamiento predeterminado y la estructura de la base de datos. Se han realizado los siguientes cambios:\n\n1. **Sensibilidad a mayúsculas de los nombres de archivo**\n El manejo de los nombres de archivo ahora no distingue entre mayúsculas y minúsculas. Este cambio es beneficioso para la mayoría de las plataformas, excepto Linux y iOS, que no gestionan efectivamente la sensibilidad a mayúsculas de los nombres de archivo.\n (En estos, se mostrará una advertencia para archivos con el mismo nombre pero diferentes mayúsculas).\n\n2. **Manejo de revisiones de los fragmentos**\n Los fragmentos son inmutables, lo que permite que sus revisiones sean fijas. Este cambio mejorará el rendimiento al guardar archivos.\n\n___Sin embargo, para habilitar cualquiera de estos cambios, es necesario reconstruir tanto las bases de datos remota como la local. Este proceso toma unos minutos, y recomendamos hacerlo cuando tengas tiempo suficiente.___\n\n- Si deseas mantener el comportamiento anterior, puedes omitir este proceso usando `${KEEP}`.\n- Si no tienes suficiente tiempo, por favor elige `${DISMISS}`. Se te pedirá nuevamente más tarde.\n- Si has reconstruido la base de datos en otro dispositivo, selecciona `${DISMISS}` e intenta sincronizar nuevamente. Dado que se ha detectado una diferencia, se te solicitará nuevamente.",
@@ -23948,17 +24080,6 @@ var allMessages = {
23948
24080
  zh: "仅启用 #2",
23949
24081
  "zh-tw": "僅啟用"
23950
24082
  },
23951
- "moduleMigration.optionHaveSetupUri": {
23952
- def: "Yes, I have",
23953
- es: "Sí, tengo",
23954
- fr: "Oui, j'en ai une",
23955
- he: "כן, יש לי",
23956
- ja: "はい、持っています",
23957
- ko: "예, 있습니다",
23958
- ru: "Да, есть",
23959
- zh: "是的,我有",
23960
- "zh-tw": "有,我有"
23961
- },
23962
24083
  "moduleMigration.optionKeepPreviousBehaviour": {
23963
24084
  def: "Keep previous behaviour",
23964
24085
  es: "Mantener comportamiento anterior",
@@ -23970,17 +24091,6 @@ var allMessages = {
23970
24091
  zh: "保持以前的行为",
23971
24092
  "zh-tw": "保留先前的行為"
23972
24093
  },
23973
- "moduleMigration.optionManualSetup": {
23974
- def: "Set it up all manually",
23975
- es: "Configurarlo todo manualmente",
23976
- fr: "Tout configurer manuellement",
23977
- he: "הגדר הכל ידנית",
23978
- ja: "すべて手動でセットアップ",
23979
- ko: "모든 것을 수동으로 설정",
23980
- ru: "Настроить всё вручную",
23981
- zh: "全部手动设置",
23982
- "zh-tw": "全部手動設定"
23983
- },
23984
24094
  "moduleMigration.optionNoAskAgain": {
23985
24095
  def: "No, please ask again",
23986
24096
  es: "No, por favor pregúntame de nuevo",
@@ -23992,50 +24102,6 @@ var allMessages = {
23992
24102
  zh: "不,请稍后再次询问",
23993
24103
  "zh-tw": "不,請稍後再問我"
23994
24104
  },
23995
- "moduleMigration.optionNoSetupUri": {
23996
- def: "No, I do not have",
23997
- es: "No, no tengo",
23998
- fr: "Non, je n'en ai pas",
23999
- he: "לא, אין לי",
24000
- ja: "いいえ、持っていません",
24001
- ko: "아니요, 없습니다",
24002
- ru: "Нет, нет",
24003
- zh: "不,我没有",
24004
- "zh-tw": "沒有,我沒有"
24005
- },
24006
- "moduleMigration.optionRemindNextLaunch": {
24007
- def: "Remind me at the next launch",
24008
- es: "Recordármelo en el próximo inicio",
24009
- fr: "Me rappeler au prochain lancement",
24010
- he: "הזכר לי בהפעלה הבאה",
24011
- ja: "次回起動時にリマインド",
24012
- ko: "다음 시작 시 알림",
24013
- ru: "Напомнить при следующем запуске",
24014
- zh: "下次启动时提醒我",
24015
- "zh-tw": "下次啟動時提醒我"
24016
- },
24017
- "moduleMigration.optionSetupViaP2P": {
24018
- def: "Use P2P Sync to set up",
24019
- es: "Usar Sincronización P2P para configurarlo",
24020
- fr: "Utiliser Sync P2P pour configurer",
24021
- he: "השתמש ב-%{short_p2p_sync} להגדרה",
24022
- ja: "P2P Sync (試験機能)を使ってセットアップ",
24023
- ko: "P2P 동기화를 사용하여 설정",
24024
- ru: "Использовать short_p2p_sync для настройки",
24025
- zh: "Use P2P同步(实验性) to set up",
24026
- "zh-tw": "使用「P2P 同步」進行設定"
24027
- },
24028
- "moduleMigration.optionSetupWizard": {
24029
- def: "Take me into the setup wizard",
24030
- es: "Llévame al asistente de configuración",
24031
- fr: "Ouvrir l'assistant de configuration",
24032
- he: "קח אותי לאשף ההגדרה",
24033
- ja: "セットアップウィザードへ",
24034
- ko: "설정 마법사로 안내",
24035
- ru: "Перейти в мастер настройки",
24036
- zh: "带我进入设置向导",
24037
- "zh-tw": "帶我進入設定精靈"
24038
- },
24039
24105
  "moduleMigration.optionYesFetchAgain": {
24040
24106
  def: "Yes, fetch again",
24041
24107
  es: "Sí, obtener de nuevo",
@@ -24058,28 +24124,6 @@ var allMessages = {
24058
24124
  zh: "大小写敏感性",
24059
24125
  "zh-tw": "大小寫敏感性"
24060
24126
  },
24061
- "moduleMigration.titleRecommendSetupUri": {
24062
- def: "Recommendation to use Setup URI",
24063
- es: "Recomendación de usar un Setup URI",
24064
- fr: "Recommandation d'utilisation de l'URI de configuration",
24065
- he: "המלצה לשימוש ב-Setup URI",
24066
- ja: "セットアップURIの使用を推奨",
24067
- ko: "Setup URI 사용 권장",
24068
- ru: "Рекомендация использовать Setup URI",
24069
- zh: "推荐使用设置 URI",
24070
- "zh-tw": "建議使用 Setup URI"
24071
- },
24072
- "moduleMigration.titleWelcome": {
24073
- def: "Welcome to Self-hosted LiveSync",
24074
- es: "Bienvenido a Self-hosted LiveSync",
24075
- fr: "Bienvenue dans Self-hosted LiveSync",
24076
- he: "ברוך הבא ל-Self-hosted LiveSync",
24077
- ja: "Self-hosted LiveSyncへようこそ",
24078
- ko: "Self-hosted LiveSync에 오신 것을 환영합니다",
24079
- ru: "Добро пожаловать в Self-hosted LiveSync",
24080
- zh: "欢迎使用 Self-hosted LiveSync",
24081
- "zh-tw": "歡迎使用 Self-hosted LiveSync"
24082
- },
24083
24127
  "moduleObsidianMenu.replicate": {
24084
24128
  def: "Replicate",
24085
24129
  es: "Replicar",
@@ -24462,17 +24506,6 @@ var allMessages = {
24462
24506
  zh: "我明白了并且已更新",
24463
24507
  "zh-tw": "我知道了,且已更新。"
24464
24508
  },
24465
- "obsidianLiveSyncSettingTab.btnNext": {
24466
- def: "Next",
24467
- es: "Siguiente",
24468
- fr: "Suivant",
24469
- he: "הבא",
24470
- ja: "次へ",
24471
- ko: "다음",
24472
- ru: "Далее",
24473
- zh: "下一步",
24474
- "zh-tw": "下一步"
24475
- },
24476
24509
  "obsidianLiveSyncSettingTab.btnStart": {
24477
24510
  def: "Start",
24478
24511
  es: "Iniciar",
@@ -24517,17 +24550,6 @@ var allMessages = {
24517
24550
  zh: "获取",
24518
24551
  "zh-tw": "抓取"
24519
24552
  },
24520
- "obsidianLiveSyncSettingTab.buttonNext": {
24521
- def: "Next",
24522
- es: "Siguiente",
24523
- fr: "Suivant",
24524
- he: "הבא",
24525
- ja: "次へ",
24526
- ko: "다음",
24527
- ru: "Далее",
24528
- zh: "下一步",
24529
- "zh-tw": "下一步"
24530
- },
24531
24553
  "obsidianLiveSyncSettingTab.defaultLanguage": {
24532
24554
  def: "Default",
24533
24555
  es: "Predeterminado",
@@ -25213,17 +25235,6 @@ var allMessages = {
25213
25235
  zh: "要从远端服务器获取配置吗?",
25214
25236
  "zh-tw": "要從遠端伺服器抓取設定嗎?"
25215
25237
  },
25216
- "obsidianLiveSyncSettingTab.msgGenerateSetupURI": {
25217
- def: "All done! Do you want to generate a setup URI to set up other devices?",
25218
- es: "¡Todo listo! ¿Quieres generar un URI de configuración para configurar otros dispositivos?",
25219
- fr: "Tout est prêt ! Voulez-vous générer une URI de configuration pour configurer d'autres appareils ?",
25220
- he: "הכל מוכן! האם ברצונך לייצר Setup URI להגדרת מכשירים אחרים?",
25221
- ja: "完了!他のデバイスをセットアップするためのセットアップURIを生成しますか?",
25222
- ko: "모든 작업이 완료되었습니다! 다른 기기를 설정하기 위해 Setup URI를 생성하시겠습니까?",
25223
- ru: "Всё готово! Вы хотите сгенерировать Setup URI для настройки других устройств?",
25224
- zh: "全部完成!要生成设置 URI 以便配置其他设备吗?",
25225
- "zh-tw": "全部完成!要產生 Setup URI 以便設定其他裝置嗎?"
25226
- },
25227
25238
  "obsidianLiveSyncSettingTab.msgIfConfigNotPersistent": {
25228
25239
  def: "If the server configuration is not persistent (e.g., running on docker), the values here may change. Once you are able to connect, please update the settings in the server's local.ini.",
25229
25240
  es: "Si la configuración del servidor no es persistente (por ejemplo, ejecutándose en docker), los valores aquí pueden cambiar. Una vez que puedas conectarte, por favor actualiza las configuraciones en el local.ini del servidor.",
@@ -25323,17 +25334,6 @@ var allMessages = {
25323
25334
  zh: "需要重建数据库以应用更改。请选择应用更改的方法。\n\n<details>\n<summary>图例</summary>\n\n| 符号 | 含义 |\n|: ------ :| ------- |\n| ⇔ | 最新 |\n| ⇄ | 同步以平衡 |\n| ⇐,⇒ | 传输以覆盖 |\n| ⇠,⇢ | 从另一侧传输以覆盖 |\n\n</details>\n\n## ${OPTION_REBUILD_BOTH}\n概览:📄 ⇒¹ 💻 ⇒² 🛰️ ⇢ⁿ 💻 ⇄ⁿ⁺¹ 📄\n使用此设备的现有文件重建本地和远程数据库。\n这将导致其他设备被锁定,并且它们需要执行获取操作。\n## ${OPTION_FETCH}\n概览:📄 ⇄² 💻 ⇐¹ 🛰️ ⇔ 💻 ⇔ 📄\n初始化本地数据库并使用从远程数据库获取的数据重建它。\n这种情况包括您已经重建了远程数据库的情况。\n## ${OPTION_ONLY_SETTING}\n仅存储设置。**注意:这可能导致数据损坏**;通常需要重建数据库",
25324
25335
  "zh-tw": "需要重建資料庫才能套用變更。請選擇套用變更的方式。\n\n<details>\n<summary>圖例</summary>\n\n| 符號 | 含意 |\n|: ------ :| ------- |\n| ⇔ | 已是最新 |\n| ⇄ | 同步以取得一致 |\n| ⇐,⇒ | 傳輸並覆寫 |\n| ⇠,⇢ | 從另一端傳輸並覆寫 |\n\n</details>\n\n## ${OPTION_REBUILD_BOTH}\n概覽: 📄 ⇒¹ 💻 ⇒² 🛰️ ⇢ⁿ 💻 ⇄ⁿ⁺¹ 📄\n以此裝置上現有的檔案重建本機與遠端資料庫。\n這會鎖定其他裝置,它們必須執行抓取。\n## ${OPTION_FETCH}\n概覽: 📄 ⇄² 💻 ⇐¹ 🛰️ ⇔ 💻 ⇔ 📄\n初始化本機資料庫,並以從遠端資料庫抓取的資料重建。\n這也涵蓋你已重建遠端資料庫的情況。\n## ${OPTION_ONLY_SETTING}\n僅儲存設定。**注意:這可能導致資料損毀**;通常仍需要重建資料庫。"
25325
25336
  },
25326
- "obsidianLiveSyncSettingTab.msgSelectAndApplyPreset": {
25327
- def: "Please select and apply any preset item to complete the wizard.",
25328
- es: "Por favor, selecciona y aplica cualquier elemento preestablecido para completar el asistente.",
25329
- fr: "Veuillez sélectionner et appliquer un préréglage pour terminer l'assistant.",
25330
- he: "אנא בחר והחל פריט קבוע מראש כלשהו להשלמת האשף.",
25331
- ja: "ウィザードを完了するには、プリセット項目を選択して適用してください。",
25332
- ko: "마법사를 완료하려면 프리셋 항목을 선택하고 적용해 주세요.",
25333
- ru: "Выберите и примените любой пресет для завершения мастера.",
25334
- zh: "请选择并应用任一预设项以完成向导。",
25335
- "zh-tw": "請選擇並套用任一預設項目以完成精靈。"
25336
- },
25337
25337
  "obsidianLiveSyncSettingTab.msgSetCorsCredentials": {
25338
25338
  def: "Set cors.credentials",
25339
25339
  es: "Configurar cors.credentials",
@@ -25928,6 +25928,7 @@ var allMessages = {
25928
25928
  zh: "活动远程服务器",
25929
25929
  "zh-tw": "使用中的遠端伺服器"
25930
25930
  },
25931
+ "obsidianLiveSyncSettingTab.titleAdvancedSettings": { def: "Advanced settings" },
25931
25932
  "obsidianLiveSyncSettingTab.titleAppearance": {
25932
25933
  def: "Appearance",
25933
25934
  es: "Apariencia",
@@ -25950,17 +25951,6 @@ var allMessages = {
25950
25951
  zh: "冲突处理",
25951
25952
  "zh-tw": "衝突處理"
25952
25953
  },
25953
- "obsidianLiveSyncSettingTab.titleCongratulations": {
25954
- def: "Congratulations!",
25955
- es: "¡Felicidades!",
25956
- fr: "Félicitations !",
25957
- he: "מזל טוב!",
25958
- ja: "おめでとうございます!",
25959
- ko: "축하합니다!",
25960
- ru: "Поздравляем!",
25961
- zh: "恭喜!",
25962
- "zh-tw": "恭喜!"
25963
- },
25964
25954
  "obsidianLiveSyncSettingTab.titleCouchDB": {
25965
25955
  def: "CouchDB",
25966
25956
  es: "Servidor CouchDB",
@@ -26016,6 +26006,8 @@ var allMessages = {
26016
26006
  zh: "启用额外和高级功能",
26017
26007
  "zh-tw": "啟用額外與進階功能"
26018
26008
  },
26009
+ "obsidianLiveSyncSettingTab.titleExtraFeaturesGroup": { def: "Extra features" },
26010
+ "obsidianLiveSyncSettingTab.titleExtraMenus": { def: "Extra menus" },
26019
26011
  "obsidianLiveSyncSettingTab.titleFetchConfig": {
26020
26012
  def: "Fetch Config",
26021
26013
  es: "Obtener configuración",
@@ -26049,6 +26041,8 @@ var allMessages = {
26049
26041
  zh: "获取设置",
26050
26042
  "zh-tw": "抓取設定"
26051
26043
  },
26044
+ "obsidianLiveSyncSettingTab.titleHelpAndInformation": { def: "Help and information" },
26045
+ "obsidianLiveSyncSettingTab.titleHelpAndTroubleshooting": { def: "Help and troubleshooting" },
26052
26046
  "obsidianLiveSyncSettingTab.titleHiddenFiles": {
26053
26047
  def: "Hidden Files",
26054
26048
  es: "Archivos ocultos",
@@ -26071,6 +26065,7 @@ var allMessages = {
26071
26065
  zh: "日志",
26072
26066
  "zh-tw": "記錄"
26073
26067
  },
26068
+ "obsidianLiveSyncSettingTab.titleMaintenanceAndRecovery": { def: "Maintenance and recovery" },
26074
26069
  "obsidianLiveSyncSettingTab.titleMinioS3R2": {
26075
26070
  def: "Minio,S3,R2",
26076
26071
  es: "MinIO, S3, R2",
@@ -26160,7 +26155,7 @@ var allMessages = {
26160
26155
  "zh-tw": "重設"
26161
26156
  },
26162
26157
  "obsidianLiveSyncSettingTab.titleSetupOtherDevices": {
26163
- def: "To setup other devices",
26158
+ def: "Set up other devices",
26164
26159
  es: "Para configurar otros dispositivos",
26165
26160
  fr: "Pour configurer d'autres appareils",
26166
26161
  he: "להגדרת מכשירים אחרים",
@@ -26170,6 +26165,7 @@ var allMessages = {
26170
26165
  zh: "设置其他设备",
26171
26166
  "zh-tw": "設定其他裝置"
26172
26167
  },
26168
+ "obsidianLiveSyncSettingTab.titleSynchronisation": { def: "Synchronisation" },
26173
26169
  "obsidianLiveSyncSettingTab.titleSynchronizationMethod": {
26174
26170
  def: "Synchronization Method",
26175
26171
  es: "Método de sincronización",
@@ -27576,7 +27572,7 @@ var allMessages = {
27576
27572
  "zh-tw": "複寫因某個模組失敗而取消"
27577
27573
  },
27578
27574
  "Replicator.Message.VersionUpFlash": {
27579
- def: "An update has been detected. Please open the Settings dialogue and check the Change Log. Replication has been cancelled.",
27575
+ def: "Remote synchronisation is paused for compatibility review. Run the 'Review why synchronisation is paused' command for details and available actions.",
27580
27576
  es: "Se ha detectado una actualización. Abre el diálogo de ajustes y consulta el registro de cambios. La replicación se ha cancelado.",
27581
27577
  fr: "Une mise à jour a été détectée. Veuillez ouvrir la boîte de dialogue des paramètres et consulter le journal des modifications. La réplication a été annulée.",
27582
27578
  he: "זוהה עדכון. אנא פתח את דיאלוג ההגדרות ובדוק את יומן השינויים. השכפול בוטל.",
@@ -31209,6 +31205,28 @@ var allMessages = {
31209
31205
  zh: "覆盖",
31210
31206
  "zh-tw": "覆寫"
31211
31207
  },
31208
+ "Ui.SetupWizard.ApplySettingsInitialisation.ApplyWithoutInitialisation": { def: "Apply without Initialisation" },
31209
+ "Ui.SetupWizard.ApplySettingsInitialisation.Back": { def: "Review another way to apply these settings" },
31210
+ "Ui.SetupWizard.ApplySettingsInitialisation.BypassGuidance": { def: "Applying these settings alone can make this device incompatible with its existing synchronisation data. Use this only when you have confirmed that reconstruction is unnecessary." },
31211
+ "Ui.SetupWizard.ApplySettingsInitialisation.BypassTitle": { def: "Apply Settings without Initialisation?" },
31212
+ "Ui.SetupWizard.ApplySettingsInitialisation.ContinueFetch": { def: "Continue with Fetch" },
31213
+ "Ui.SetupWizard.ApplySettingsInitialisation.FetchOption": { def: "Reset Synchronisation on This Device" },
31214
+ "Ui.SetupWizard.ApplySettingsInitialisation.FetchOptionDesc": { def: "After restarting, rebuild this device's local database from the current remote synchronisation data. Files in the Vault will then be reconciled with that data." },
31215
+ "Ui.SetupWizard.ApplySettingsInitialisation.FetchOptionP2PDesc": { def: "After restarting, select an online source device. This device's local LiveSync database will be rebuilt from that source." },
31216
+ "Ui.SetupWizard.ApplySettingsInitialisation.Guidance": { def: "These setting changes alter how synchronisation data is interpreted. Apply them together with an initialisation operation after restart." },
31217
+ "Ui.SetupWizard.ApplySettingsInitialisation.KeepEditing": { def: "Keep Editing" },
31218
+ "Ui.SetupWizard.ApplySettingsInitialisation.ProceedFetch": { def: "Restart and Fetch Synchronisation Data" },
31219
+ "Ui.SetupWizard.ApplySettingsInitialisation.ProceedFetchP2P": { def: "Restart and Select a Source Device" },
31220
+ "Ui.SetupWizard.ApplySettingsInitialisation.ProceedRebuild": { def: "Restart and Overwrite Server Data" },
31221
+ "Ui.SetupWizard.ApplySettingsInitialisation.ProceedRebuildP2P": { def: "Restart and Prepare This Device" },
31222
+ "Ui.SetupWizard.ApplySettingsInitialisation.Question": { def: "Which existing data should be used after restart?" },
31223
+ "Ui.SetupWizard.ApplySettingsInitialisation.RebuildOption": { def: "Overwrite Server Data with This Device's Files" },
31224
+ "Ui.SetupWizard.ApplySettingsInitialisation.RebuildOptionDesc": { def: "Rebuild the local and remote databases from the files currently in this Vault. Other synchronising devices must reset their local synchronisation afterwards." },
31225
+ "Ui.SetupWizard.ApplySettingsInitialisation.RebuildOptionP2P": { def: "Prepare This Device from This Vault" },
31226
+ "Ui.SetupWizard.ApplySettingsInitialisation.RebuildOptionP2PDesc": { def: "Rebuild this device's local LiveSync database from the files currently in this Vault. This does not overwrite another device." },
31227
+ "Ui.SetupWizard.ApplySettingsInitialisation.RemoteVerificationGuidance": { def: "The configured remote could not be verified with the current credentials and encryption settings. Continuing may make the Fetch fail after restart." },
31228
+ "Ui.SetupWizard.ApplySettingsInitialisation.RemoteVerificationTitle": { def: "Remote Synchronisation Data Could Not Be Verified" },
31229
+ "Ui.SetupWizard.ApplySettingsInitialisation.Title": { def: "Apply Settings and Reinitialise Synchronisation" },
31212
31230
  "Ui.SetupWizard.Common.Back": {
31213
31231
  def: "No, please take me back",
31214
31232
  es: "No, volver atrás",
@@ -35218,6 +35236,17 @@ var ReplicateResultProcessor = class {
35218
35236
  }
35219
35237
  };
35220
35238
  //#endregion
35239
+ //#region ../../common/compatibilitySettings.ts
35240
+ /**
35241
+ * Returns whether persisted settings select the legacy PouchDB IndexedDB adapter.
35242
+ *
35243
+ * New local databases use IDB. Existing devices must retain this operative value until their local database has
35244
+ * been explicitly migrated, so compatibility code must not treat the setting as inert.
35245
+ */
35246
+ function usesLegacyIndexedDBAdapter(settings) {
35247
+ return settings.useIndexedDBAdapter;
35248
+ }
35249
+ //#endregion
35221
35250
  //#region ../../modules/core/ModuleReplicator.ts
35222
35251
  function isOnlineAndCanReplicate(errorManager, host, showMessage) {
35223
35252
  const errorMessage = "Network is offline";
@@ -35296,10 +35325,12 @@ var ModuleReplicator = class extends AbstractModule {
35296
35325
  return true;
35297
35326
  }
35298
35327
  /**
35299
- * Reconciles local chunks when an older IndexedDB client reports that the remote database was cleaned.
35300
- * This compatibility path remains reachable while those clients can still set `remoteCleaned`.
35301
- * @deprecated v0.24.17
35302
- * @param showMessage If true, show message to the user.
35328
+ * Reconciles an IndexedDB-backed local database after replication reports that the remote was cleaned.
35329
+ *
35330
+ * The remote milestone remains a supported compatibility signal. The user can either fetch the remote
35331
+ * database again, or purge unreferenced local chunks before accepting this device again.
35332
+ *
35333
+ * @param showMessage Whether to show the recovery choices as user-facing notices.
35303
35334
  */
35304
35335
  async cleaned(showMessage) {
35305
35336
  Logger(`The remote database has been cleaned.`, showMessage ? 64 : 32);
@@ -35349,7 +35380,7 @@ Even if you choose to clean up, you will see this option again if you exit Obsid
35349
35380
  return false;
35350
35381
  }
35351
35382
  if (activeReplicator.tweakSettingsMismatched && activeReplicator.preferredTweakValue) await this.services.tweakValue.askResolvingMismatched(activeReplicator.preferredTweakValue);
35352
- else if (activeReplicator.remoteLockedAndDeviceNotAccepted) if (activeReplicator.remoteCleaned && this.settings.useIndexedDBAdapter) await this.cleaned(showMessage);
35383
+ else if (activeReplicator.remoteLockedAndDeviceNotAccepted) if (activeReplicator.remoteCleaned && usesLegacyIndexedDBAdapter(this.settings)) await this.cleaned(showMessage);
35353
35384
  else {
35354
35385
  const message = $msg("Replicator.Dialogue.Locked.Message");
35355
35386
  const CHOICE_FETCH = $msg("Replicator.Dialogue.Locked.Action.Fetch");
@@ -54990,8 +55021,8 @@ var ModuleResolvingMismatchedTweaks = class extends AbstractModule {
54990
55021
  };
54991
55022
  //#endregion
54992
55023
  //#region ../../../node_modules/@vrtmrz/livesync-commonlib/dist/common/coreEnvVars.js
54993
- var manifestVersion = "1.0.17";
54994
- var packageVersion = "1.0.17";
55024
+ var manifestVersion = "1.0.21";
55025
+ var packageVersion = "1.0.21";
54995
55026
  //#endregion
54996
55027
  //#region ../../modules/main/ModuleLiveSyncMain.ts
54997
55028
  var ModuleLiveSyncMain = class extends AbstractModule {
@@ -55349,24 +55380,21 @@ var ModuleBasicMenu = class extends AbstractModule {
55349
55380
  async function prepareDatabaseForUse(host, log, errorManager, showingNotice = false, reopenDatabase = true, ignoreSuspending = false) {
55350
55381
  const appLifecycle = host.services.appLifecycle;
55351
55382
  appLifecycle.resetIsReady();
55352
- if (!reopenDatabase || await host.services.database.openDatabase({
55383
+ if (reopenDatabase && !await host.services.database.openDatabase({
55353
55384
  databaseEvents: host.services.databaseEvents,
55354
55385
  replicator: host.services.replicator
55355
- })) {
55356
- if (host.services.database.localDatabase.isReady) await host.services.vault.scanVault(showingNotice, ignoreSuspending);
55357
- const ERR_INITIALISATION_FAILED = `Initializing database has been failed on some module!`;
55358
- if (!await host.services.databaseEvents.onDatabaseInitialised(showingNotice)) {
55359
- errorManager.showError(ERR_INITIALISATION_FAILED, 64);
55360
- return false;
55361
- }
55362
- errorManager.clearError(ERR_INITIALISATION_FAILED);
55363
- appLifecycle.markIsReady();
55364
- await host.services.fileProcessing.commitPendingFileEvents();
55365
- return true;
55366
- } else {
55367
- appLifecycle.resetIsReady();
55386
+ })) return false;
55387
+ if (!host.services.database.isDatabaseReady()) return false;
55388
+ if (!await host.services.vault.scanVault(showingNotice, ignoreSuspending)) return false;
55389
+ const ERR_INITIALISATION_FAILED = `Initializing database has been failed on some module!`;
55390
+ if (!await host.services.databaseEvents.onDatabaseInitialised(showingNotice)) {
55391
+ errorManager.showError(ERR_INITIALISATION_FAILED, 64);
55368
55392
  return false;
55369
55393
  }
55394
+ errorManager.clearError(ERR_INITIALISATION_FAILED);
55395
+ if (!await host.services.fileProcessing.commitPendingFileEvents()) return false;
55396
+ appLifecycle.markIsReady();
55397
+ return true;
55370
55398
  }
55371
55399
  function usePrepareDatabaseForUse(host) {
55372
55400
  const log = createInstanceLogFunction("SF:prepareDatabaseForUse", host.services.API);
@@ -55916,6 +55944,7 @@ var ServiceRebuilder = class extends ServiceModuleBase {
55916
55944
  replication;
55917
55945
  database;
55918
55946
  fileHandler;
55947
+ fileProcessing;
55919
55948
  control;
55920
55949
  constructor(services) {
55921
55950
  super(services);
@@ -55932,6 +55961,7 @@ var ServiceRebuilder = class extends ServiceModuleBase {
55932
55961
  this.replication = services.replication;
55933
55962
  this.database = services.database;
55934
55963
  this.fileHandler = services.fileHandler;
55964
+ this.fileProcessing = services.fileProcessing;
55935
55965
  this.control = services.control;
55936
55966
  services.database.onDatabaseReset.addHandler(this._onResetLocalDatabase.bind(this));
55937
55967
  services.setting.suspendAllSync.addHandler(this._allSuspendAllSync.bind(this));
@@ -55974,6 +56004,7 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
55974
56004
  await this.informOptionalFeatures();
55975
56005
  }
55976
56006
  async performRebuildEverything() {
56007
+ this.appLifecycle.resetIsReady();
55977
56008
  await this.setting.suspendExtraSync();
55978
56009
  await this.setting.applyPartial({
55979
56010
  isConfigured: true,
@@ -55982,16 +56013,20 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
55982
56013
  await this.control.applySettings();
55983
56014
  await this.resetLocalDatabase();
55984
56015
  await delay$1(1e3);
55985
- await this.databaseEvents.initialiseDatabase(true, true, true);
55986
- if (this.setting.currentSettings().remoteType === REMOTE_P2P) return;
56016
+ await this.prepareLocalDatabaseForRebuild();
56017
+ if (this.setting.currentSettings().remoteType === REMOTE_P2P) {
56018
+ if (!await this.completePreparedRebuild()) throw new Error("The local P2P rebuild could not be finalised.");
56019
+ return;
56020
+ }
55987
56021
  await this.replication.markLocked();
55988
56022
  await this._tryResetRemoteDatabase();
55989
56023
  await this.replication.markLocked();
55990
56024
  await delay$1(500);
55991
56025
  await delay$1(1e3);
55992
- await this.replication.replicateAllToRemote(true);
56026
+ if (!await this.replication.replicateAllToRemoteForRebuild(true)) throw new Error("The first rebuild upload did not complete.");
55993
56027
  await delay$1(1e3);
55994
- await this.replication.replicateAllToRemote(true);
56028
+ if (!await this.replication.replicateAllToRemoteForRebuild(true)) throw new Error("The final rebuild upload did not complete.");
56029
+ if (!await this.completePreparedRebuild()) throw new Error("The rebuild could not be finalised.");
55995
56030
  }
55996
56031
  $rebuildEverything() {
55997
56032
  return this.rebuildEverything();
@@ -56068,18 +56103,43 @@ Please enable them from the settings screen after setup is complete.`, ["OK"]);
56068
56103
  });
56069
56104
  await this.setting.saveSettingData();
56070
56105
  }
56106
+ /**
56107
+ * Stage reflection resumption and perform the final reconciliation checks.
56108
+ *
56109
+ * File watching is resumed in memory before the final scan so that changes
56110
+ * made while the scan is running can enter the storage-event queue. This
56111
+ * phase deliberately does not persist the resumed settings. The owning
56112
+ * completion boundary persists them only after the scan, replication
56113
+ * pre-check, and current batch-wait release have succeeded.
56114
+ *
56115
+ * @param ignoreMinIO Whether to resume reflection for a MinIO remote.
56116
+ * @returns `true` when the applicable reconciliation checks succeeded.
56117
+ */
56071
56118
  async resumeReflectingDatabase(ignoreMinIO = false) {
56072
56119
  const settings = this.setting.currentSettings();
56073
- if (settings.doNotSuspendOnFetching) return;
56074
- if (!ignoreMinIO && settings.remoteType == REMOTE_MINIO) return;
56120
+ if (settings.doNotSuspendOnFetching) return true;
56121
+ if (!ignoreMinIO && settings.remoteType == REMOTE_MINIO) return true;
56075
56122
  this._log(`Database and storage reflection has been resumed!`, 64);
56076
56123
  await this.setting.applyPartial({
56077
56124
  suspendParseReplicationResult: false,
56078
56125
  suspendFileWatching: false
56079
56126
  });
56080
- await this.vault.scanVault(true);
56081
- await this.replication.onBeforeReplicate(false);
56082
- await this.setting.saveSettingData();
56127
+ if (!await this.vault.scanVault(true)) return false;
56128
+ if (!await this.replication.onBeforeReplicate(false)) return false;
56129
+ return true;
56130
+ }
56131
+ async prepareLocalDatabaseForRebuild() {
56132
+ if (!this.database.isDatabaseReady()) throw new Error("The selected local database is not ready for rebuild preparation.");
56133
+ if (!await this.vault.scanVault(true, true)) throw new Error("The Vault could not be scanned for rebuild preparation.");
56134
+ if (!await this.databaseEvents.onDatabaseInitialised(true)) throw new Error("The local database completion hooks failed during rebuild preparation.");
56135
+ if (!await this.fileProcessing.commitPendingFileEvents()) throw new Error("The current file-event batch could not be released for rebuild preparation.");
56136
+ }
56137
+ async completePreparedRebuild() {
56138
+ this.appLifecycle.resetIsReady();
56139
+ if (!this.database.isDatabaseReady()) return false;
56140
+ if (!await this.fileProcessing.commitPendingFileEvents()) return false;
56141
+ this.appLifecycle.markIsReady();
56142
+ return true;
56083
56143
  }
56084
56144
  async fetchLocal(makeLocalChunkBeforeSync, preventMakeLocalFilesBeforeSync, autoResume = true) {
56085
56145
  await this.setting.suspendExtraSync();
@@ -56117,26 +56177,24 @@ Are you sure you wish to proceed?`;
56117
56177
  await this.replicator.runBoundedRemoteActivity(() => this.performFetchLocal(makeLocalChunkBeforeSync, preventMakeLocalFilesBeforeSync, autoResume), { label: "rebuild-fetch" });
56118
56178
  }
56119
56179
  async performFetchLocal(makeLocalChunkBeforeSync, preventMakeLocalFilesBeforeSync, autoResume = true) {
56180
+ this.appLifecycle.resetIsReady();
56120
56181
  await this.suspendReflectingDatabase(!autoResume);
56121
56182
  await this.control.applySettings();
56122
56183
  await this.resetLocalDatabase();
56123
56184
  this.clearFastFetchCheckpoint();
56124
56185
  await delay$1(1e3);
56125
- await this.database.openDatabase({
56126
- databaseEvents: this.databaseEvents,
56127
- replicator: this.replicator
56128
- });
56129
- this.appLifecycle.markIsReady();
56130
56186
  if (makeLocalChunkBeforeSync) await this.fileHandler.createAllChunks(true);
56131
- else if (!preventMakeLocalFilesBeforeSync) await this.databaseEvents.initialiseDatabase(true, true, true);
56187
+ else if (!preventMakeLocalFilesBeforeSync) await this.prepareLocalDatabaseForRebuild();
56132
56188
  await this.replication.markResolved();
56133
56189
  await delay$1(500);
56134
- await this.replication.replicateAllFromRemote(true);
56190
+ if (!await this.replication.replicateAllFromRemoteForRebuild(true)) throw new Error("The first Standard Fetch pass did not complete.");
56135
56191
  if (this.setting.currentSettings().remoteType !== REMOTE_P2P) {
56136
56192
  await delay$1(1e3);
56137
- await this.replication.replicateAllFromRemote(true);
56193
+ if (!await this.replication.replicateAllFromRemoteForRebuild(true)) throw new Error("The final Standard Fetch pass did not complete.");
56194
+ }
56195
+ if (autoResume) {
56196
+ if (!await this.finishRebuild()) throw new Error("Standard Fetch could not be finalised.");
56138
56197
  }
56139
- if (autoResume) await this.finishRebuild();
56140
56198
  }
56141
56199
  async fetchLocalDBFast(autoResume) {
56142
56200
  await this.setting.suspendExtraSync();
@@ -56158,31 +56216,28 @@ Are you sure you wish to proceed?`;
56158
56216
  await this.replicator.runBoundedRemoteActivity(() => this.performFetchLocalDBFast(settings, autoResume), { label: "fast-fetch" });
56159
56217
  }
56160
56218
  async performFetchLocalDBFast(settings, autoResume) {
56219
+ this.appLifecycle.resetIsReady();
56161
56220
  const remote = settings.couchDB_URI.replace(/\/+$/, "") + (settings.couchDB_DBNAME == "" ? "" : "/" + settings.couchDB_DBNAME);
56162
56221
  let checkpoint = this.getFastFetchCheckpoint(remote);
56163
56222
  await this.suspendReflectingDatabase();
56164
56223
  await this.control.applySettings();
56165
56224
  let since = checkpoint?.sequence ?? "0";
56166
- if (checkpoint) this._log(`Resuming fast database fetch from sequence: ${checkpoint.sequence}`, 64, "fetch-init-resume");
56167
- else {
56225
+ if (checkpoint) {
56226
+ this._log(`Resuming fast database fetch from sequence: ${checkpoint.sequence}`, 64, "fetch-init-resume");
56227
+ if (!await this.database.openDatabase({
56228
+ databaseEvents: this.databaseEvents,
56229
+ replicator: this.replicator
56230
+ })) throw new Error("The selected local database could not be opened for Fast Fetch.");
56231
+ } else {
56168
56232
  await this.resetLocalDatabase();
56169
56233
  await delay$1(1e3);
56170
56234
  }
56171
- await this.database.openDatabase({
56172
- databaseEvents: this.databaseEvents,
56173
- replicator: this.replicator
56174
- });
56175
- this.appLifecycle.markIsReady();
56176
56235
  let localDB = this.database.localDatabase.localDatabase;
56177
56236
  if (checkpoint && (await localDB.info()).doc_count == 0) {
56178
56237
  this._log("Fast fetch checkpoint found, but the local database is empty. Starting from the beginning.", 64, "fetch-init-resume");
56179
56238
  this.clearFastFetchCheckpoint();
56180
56239
  await this.resetLocalDatabase();
56181
56240
  await delay$1(1e3);
56182
- await this.database.openDatabase({
56183
- databaseEvents: this.databaseEvents,
56184
- replicator: this.replicator
56185
- });
56186
56241
  localDB = this.database.localDatabase.localDatabase;
56187
56242
  since = "0";
56188
56243
  }
@@ -56208,16 +56263,42 @@ Total bytes fetched: ${sizeToHumanReadable(progress.totalBytes)}`, 64, "fetch-in
56208
56263
  const allDocs = await localDB.allDocs({ include_docs: false });
56209
56264
  this._log(`Fast database fetch completed. Total documents in local database: ${allDocs.total_rows}`, 64, "fetch-init-complete");
56210
56265
  await this.replication.markResolved();
56211
- if (autoResume) await this.resumeReflectingDatabase(true);
56266
+ if (autoResume) {
56267
+ if (!await this.finishRebuild()) throw new Error("Fast Fetch could not be finalised.");
56268
+ }
56212
56269
  this.clearFastFetchCheckpoint();
56213
56270
  }
56214
56271
  /**
56215
- * Finish rebuild process with resuming the reflection.
56272
+ * Complete the final rebuild phases and establish application readiness.
56273
+ *
56274
+ * A failed completion restores the previous reflection settings in memory.
56275
+ * Persistence atomicity remains a responsibility of the host setting store;
56276
+ * Commonlib cannot roll back a store which writes successfully and then
56277
+ * reports an error.
56216
56278
  *
56217
- * @param ignoreMinIO Whether to ignore minio for resuming the reflection.
56279
+ * @param ignoreMinIO Whether to resume reflection for a MinIO remote.
56280
+ * @returns `true` when finalisation completed; otherwise, `false`.
56218
56281
  */
56219
56282
  async finishRebuild(ignoreMinIO = true) {
56220
- await this.resumeReflectingDatabase(ignoreMinIO);
56283
+ this.appLifecycle.resetIsReady();
56284
+ const settings = this.setting.currentSettings();
56285
+ const controlsReflection = !settings.doNotSuspendOnFetching && (ignoreMinIO || settings.remoteType !== REMOTE_MINIO);
56286
+ const previousReflectionState = {
56287
+ suspendParseReplicationResult: settings.suspendParseReplicationResult,
56288
+ suspendFileWatching: settings.suspendFileWatching
56289
+ };
56290
+ let completed = false;
56291
+ try {
56292
+ if (!this.database.isDatabaseReady()) return false;
56293
+ if (!await this.resumeReflectingDatabase(ignoreMinIO)) return false;
56294
+ if (!await this.fileProcessing.commitPendingFileEvents()) return false;
56295
+ if (controlsReflection) await this.setting.saveSettingData();
56296
+ this.appLifecycle.markIsReady();
56297
+ completed = true;
56298
+ return true;
56299
+ } finally {
56300
+ if (!completed && controlsReflection) await this.setting.applyPartial(previousReflectionState);
56301
+ }
56221
56302
  }
56222
56303
  /**
56223
56304
  * Fetch local database with making all chunks.
@@ -56233,11 +56314,12 @@ Total bytes fetched: ${sizeToHumanReadable(progress.totalBytes)}`, 64, "fetch-in
56233
56314
  return true;
56234
56315
  }
56235
56316
  async resetLocalDatabase() {
56236
- const settings = this.setting.currentSettings();
56237
- if (settings.isConfigured && settings.additionalSuffixOfDatabaseName == "") await this.database.resetDatabase();
56238
56317
  const suffix = this.API.getAppID() || "";
56239
56318
  await this.setting.applyPartial({ additionalSuffixOfDatabaseName: suffix });
56240
- await this.database.resetDatabase();
56319
+ if (!await this.database.resetDatabaseForCurrentSettings({
56320
+ databaseEvents: this.databaseEvents,
56321
+ replicator: this.replicator
56322
+ })) throw new Error("The local database selected by the current settings could not be reset.");
56241
56323
  this.events.emitEvent(EVENT_DATABASE_REBUILT);
56242
56324
  }
56243
56325
  getFastFetchCheckpoint(remote) {
@@ -56762,24 +56844,17 @@ var ServiceFileHandlerBase = class extends ServiceModuleBase {
56762
56844
  return true;
56763
56845
  }
56764
56846
  async _anyHandlerProcessesFileEvent(item) {
56847
+ if (item.restoredFromPreviousRuntime) return await this._processRestoredFileEvent(item);
56765
56848
  const eventItem = item.args;
56766
56849
  const type = item.type;
56767
56850
  const path = eventItem.file.path;
56768
- if (!await this.vault.isTargetFile(path)) {
56769
- this._log(`File ${path} is not the target file`, 16);
56770
- return false;
56771
- }
56772
- if (shouldBeIgnored(path)) {
56773
- this._log(`File ${path} should be ignored`, 16);
56774
- return false;
56775
- }
56851
+ if (!await this.isCurrentPathSelected(path)) return false;
56776
56852
  if (type === "RENAME" && !eventItem.oldPath) {
56777
56853
  this._log(`Rename event for ${path} has no source path`, 16);
56778
56854
  return false;
56779
56855
  }
56780
56856
  const eventPaths = type === "RENAME" ? [path, eventItem.oldPath] : [path];
56781
- const documentIds = await Promise.all(eventPaths.map((eventPath) => this.path.path2id(eventPath)));
56782
- return await serializedByKeys([...new Set(documentIds)].sort().map((documentId) => `processFileEvent-${documentId}`), async () => {
56857
+ return await this.serializedByFileEventPaths(eventPaths, async () => {
56783
56858
  switch (type) {
56784
56859
  case "CREATE":
56785
56860
  case "CHANGED": return await this.storeFileToDB(item.args.file);
@@ -56792,6 +56867,138 @@ var ServiceFileHandlerBase = class extends ServiceModuleBase {
56792
56867
  }
56793
56868
  });
56794
56869
  }
56870
+ async serializedByFileEventPaths(eventPaths, callback) {
56871
+ const documentIds = await Promise.all(eventPaths.map((eventPath) => this.path.path2id(eventPath)));
56872
+ return await serializedByKeys([...new Set(documentIds)].sort().map((documentId) => `processFileEvent-${documentId}`), () => callback(documentIds.length === 2 && documentIds[0] === documentIds[1]));
56873
+ }
56874
+ /**
56875
+ * Revalidate a persisted storage operation against the current storage state.
56876
+ *
56877
+ * Snapshot entries preserve operation intent and ordering only. Their file
56878
+ * stub, timestamps, and existence assumptions can be stale after a restart.
56879
+ * Current inclusion is therefore read from storage, while destructive work
56880
+ * is allowed only after current absence has been observed.
56881
+ */
56882
+ async _processRestoredFileEvent(item) {
56883
+ const eventItem = item.args;
56884
+ const type = item.type;
56885
+ const path = eventItem.file.path;
56886
+ if (type === "RENAME" && !eventItem.oldPath) {
56887
+ this._log(`Rename event for ${path} has no source path`, 16);
56888
+ return true;
56889
+ }
56890
+ const eventPaths = type === "RENAME" ? [path, eventItem.oldPath] : [path];
56891
+ return await this.serializedByFileEventPaths(eventPaths, async (isSameDocument) => {
56892
+ let action;
56893
+ try {
56894
+ action = await this._planRestoredFileEvent(item, isSameDocument);
56895
+ } catch (ex) {
56896
+ this.logRestoredEventValidationFailure(path, ex);
56897
+ return true;
56898
+ }
56899
+ switch (action.kind) {
56900
+ case "none": return true;
56901
+ case "store": return await this.storeFileToDB(action.file);
56902
+ case "delete": return await this.deleteFileFromDB(action.path);
56903
+ case "rename": return await this.renameFileInDB(action.file, action.oldPath);
56904
+ }
56905
+ });
56906
+ }
56907
+ async _planRestoredFileEvent(item, isSameDocument) {
56908
+ const path = item.args.file.path;
56909
+ switch (item.type) {
56910
+ case "CREATE":
56911
+ case "CHANGED": {
56912
+ const current = this.getExactCurrentFile(await this.storage.getStub(path), path);
56913
+ return current && await this.isCurrentFileSelected(current) ? {
56914
+ kind: "store",
56915
+ file: current
56916
+ } : { kind: "none" };
56917
+ }
56918
+ case "DELETE": return await this.storage.getStub(path) === null && await this.canApplyRestoredDeletion(path) ? {
56919
+ kind: "delete",
56920
+ path
56921
+ } : { kind: "none" };
56922
+ case "RENAME": return await this._planRestoredRename(path, item.args.oldPath, isSameDocument);
56923
+ case "INTERNAL": return { kind: "none" };
56924
+ default:
56925
+ this._log(`Unsupported event type: ${item.type}`, 16);
56926
+ return { kind: "none" };
56927
+ }
56928
+ }
56929
+ async _planRestoredRename(newPath, oldPath, isSameDocument) {
56930
+ if (isSameDocument) {
56931
+ const currentTarget2 = this.getExactCurrentFile(await this.storage.getStub(newPath), newPath);
56932
+ if (!currentTarget2 || !await this.isCurrentFileSelected(currentTarget2)) return { kind: "none" };
56933
+ return {
56934
+ kind: "rename",
56935
+ file: currentTarget2,
56936
+ oldPath
56937
+ };
56938
+ }
56939
+ const currentTargetItem = await this.storage.getStub(newPath);
56940
+ let currentSourceItem = null;
56941
+ let sourceWasInspected = true;
56942
+ try {
56943
+ currentSourceItem = await this.storage.getStub(oldPath);
56944
+ } catch (ex) {
56945
+ sourceWasInspected = false;
56946
+ this.logRestoredEventValidationFailure(oldPath, ex);
56947
+ }
56948
+ const currentTarget = this.getExactCurrentFile(currentTargetItem, newPath);
56949
+ if (currentTargetItem !== null) {
56950
+ if (!currentTarget || !await this.isCurrentFileSelected(currentTarget)) return { kind: "none" };
56951
+ if (!sourceWasInspected || currentSourceItem !== null || !await this.canApplyRestoredDeletion(oldPath)) return {
56952
+ kind: "store",
56953
+ file: currentTarget
56954
+ };
56955
+ return {
56956
+ kind: "rename",
56957
+ file: currentTarget,
56958
+ oldPath
56959
+ };
56960
+ }
56961
+ if (!sourceWasInspected || currentSourceItem !== null || !await this.canApplyRestoredDeletion(oldPath)) return { kind: "none" };
56962
+ return {
56963
+ kind: "delete",
56964
+ path: oldPath
56965
+ };
56966
+ }
56967
+ getExactCurrentFile(current, expectedPath) {
56968
+ if (current === null || isFolderInfo(current)) return null;
56969
+ return this.storage.normalisePath(current.path) === this.storage.normalisePath(expectedPath) ? current : null;
56970
+ }
56971
+ async isCurrentFileSelected(file) {
56972
+ if (!await this.isCurrentPathSelected(file.path)) return false;
56973
+ if (this.vault.isFileSizeTooLarge(file.stat.size)) {
56974
+ this._log(`File ${file.path} exceeds the current maximum size`, 16);
56975
+ return false;
56976
+ }
56977
+ return true;
56978
+ }
56979
+ async isCurrentPathSelected(path) {
56980
+ if (!await this.vault.isTargetFile(path)) {
56981
+ this._log(`File ${path} is not the target file`, 16);
56982
+ return false;
56983
+ }
56984
+ if (shouldBeIgnored(path)) {
56985
+ this._log(`File ${path} should be ignored`, 16);
56986
+ return false;
56987
+ }
56988
+ return true;
56989
+ }
56990
+ async canApplyRestoredDeletion(path) {
56991
+ try {
56992
+ return await this.isCurrentPathSelected(path);
56993
+ } catch (ex) {
56994
+ this.logRestoredEventValidationFailure(path, ex);
56995
+ return false;
56996
+ }
56997
+ }
56998
+ logRestoredEventValidationFailure(path, ex) {
56999
+ this._log(`Could not validate the saved storage operation for ${path} against current storage; the Offline Scanner will reconcile the current state`, 64);
57000
+ this._log(ex, 16);
57001
+ }
56795
57002
  async _anyProcessReplicatedDoc(entry) {
56796
57003
  return await serialized(`processReplicatedDoc-${entry._id}`, async () => {
56797
57004
  if (!await this.vault.isTargetFile(entry.path)) {
@@ -58010,13 +58217,11 @@ var StorageEventManagerBase = class extends StorageEventManager {
58010
58217
  }
58011
58218
  /**
58012
58219
  * Snapshot restoration promise.
58013
- * Snapshot will be restored before starting to watch vault changes.
58014
- * In designed time, this has been called from Initialisation process, which has been implemented on `ModuleInitializerFile.ts`.
58220
+ * It resolves after the restored file operations have finished, before Vault watching begins.
58015
58221
  */
58016
58222
  snapShotRestored = null;
58017
58223
  /**
58018
- * Restore the previous snapshot if exists.
58019
- * @returns
58224
+ * Restore and complete the previous storage-event snapshot when it exists.
58020
58225
  */
58021
58226
  restoreState() {
58022
58227
  this.snapShotRestored = this._restoreFromSnapshot();
@@ -58274,16 +58479,39 @@ var StorageEventManagerBase = class extends StorageEventManager {
58274
58479
  const snapShot = await this._loadSnapshot();
58275
58480
  if (snapShot && Array.isArray(snapShot) && snapShot.length > 0) {
58276
58481
  this._log(`Restoring storage operation snapshot: ${snapShot.length} items`, 16);
58277
- this.bufferedQueuedItems = snapShot.map((e) => ({
58278
- ...e,
58482
+ this.bufferedQueuedItems = snapShot.map((event) => event.type === TYPE_SENTINEL_FLUSH ? event : {
58483
+ ...event,
58484
+ restoredFromPreviousRuntime: true,
58279
58485
  skipBatchWait: true
58280
- }));
58486
+ });
58281
58487
  this.updateStatus();
58282
- await this.runQueuedEvents();
58488
+ await this.runQueuedEvents({ waitForProcessing: true });
58283
58489
  } else this._log(`No snapshot to restore`, 16);
58284
58490
  }
58285
- runQueuedEvents() {
58491
+ /**
58492
+ * Dispatch buffered storage events.
58493
+ *
58494
+ * Ordinary watcher events retain the existing fire-and-forget behaviour.
58495
+ * Snapshot restoration requests completion so its caller can use the replay as
58496
+ * a lifecycle boundary. In that mode, a sentinel also waits for every operation
58497
+ * dispatched before it, preserving the ordering represented by the snapshot.
58498
+ * An individual restored operation failure is logged but does not prevent the
58499
+ * following Offline Scanner from reconciling the resulting current state.
58500
+ */
58501
+ runQueuedEvents(options = {}) {
58502
+ const waitForProcessing = options.waitForProcessing ?? false;
58286
58503
  return skipIfDuplicated("storage-event-manager-run-queued-events", async () => {
58504
+ let dispatched = [];
58505
+ const waitForDispatched = async () => {
58506
+ if (dispatched.length === 0) return;
58507
+ const pending = dispatched;
58508
+ dispatched = [];
58509
+ const results = await Promise.allSettled(pending.map(({ processing }) => processing));
58510
+ for (const [index, result] of results.entries()) if (result.status === "rejected") {
58511
+ this._log(`Restored storage operation failed for ${pending[index].path}; the Offline Scanner will reconcile the current state`, 64);
58512
+ this._log(result.reason, 16);
58513
+ }
58514
+ };
58287
58515
  do {
58288
58516
  if (this.bufferedQueuedItems.length === 0) break;
58289
58517
  const fei = this.bufferedQueuedItems.shift();
@@ -58293,12 +58521,19 @@ var StorageEventManagerBase = class extends StorageEventManager {
58293
58521
  this.updateStatus();
58294
58522
  if (fei.type === TYPE_SENTINEL_FLUSH) {
58295
58523
  this._log(`Waiting for idle`, 16);
58524
+ if (waitForProcessing) await waitForDispatched();
58296
58525
  await this.waitForIdle();
58297
58526
  this.updateStatus();
58298
58527
  continue;
58299
58528
  }
58300
- fireAndForget(() => this.processFileEvent(fei));
58529
+ const processing = this.processFileEvent(fei);
58530
+ if (waitForProcessing) dispatched.push({
58531
+ path: fei.args.file.path,
58532
+ processing
58533
+ });
58534
+ else fireAndForget(processing);
58301
58535
  } while (this.bufferedQueuedItems.length > 0);
58536
+ if (waitForProcessing) await waitForDispatched();
58302
58537
  });
58303
58538
  }
58304
58539
  processingCount = 0;
@@ -58736,6 +58971,7 @@ function initialiseServiceModulesCLI(basePath, core, services, ignoreRules, watc
58736
58971
  UI: services.UI,
58737
58972
  vault: services.vault,
58738
58973
  fileHandler,
58974
+ fileProcessing: services.fileProcessing,
58739
58975
  storageAccess,
58740
58976
  control: services.control
58741
58977
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jr2804/livesync-cli",
3
- "version": "1.0.17-cli.1",
3
+ "version": "1.0.21-cli.1",
4
4
  "description": "SEA-packaged livesync-cli from vrtmrz/obsidian-livesync — multiplatform binaries + npm",
5
5
  "type": "module",
6
6
  "bin": {