@vrtmrz/livesync-commonlib 0.1.0-rc.1 → 0.1.0-rc.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +90 -20
- package/dist/API/DirectFileManipulatorV2.d.ts +3 -0
- package/dist/common/configForDoc.d.ts +1 -0
- package/dist/common/configForDoc.js +24 -7
- package/dist/common/models/setting.const.defaults.d.ts +19 -0
- package/dist/common/models/setting.const.defaults.js +21 -2
- package/dist/common/models/setting.const.preferred.js +1 -2
- package/dist/common/models/setting.lifecycle.d.ts +33 -0
- package/dist/common/models/setting.lifecycle.js +121 -0
- package/dist/common/models/setting.type.d.ts +10 -4
- package/dist/common/models/shared.definition.configNames.js +3 -3
- package/dist/common/models/tweak.definition.d.ts +1 -1
- package/dist/common/models/tweak.definition.js +1 -6
- package/dist/common/settingConstants.d.ts +3 -2
- package/dist/common/settingConstants.js +6 -6
- package/dist/common/types.d.ts +4 -2
- package/dist/common/types.js +16 -1
- package/dist/context.d.ts +2 -1
- package/dist/context.js +4 -0
- package/dist/interfaces/Confirm.d.ts +10 -2
- package/dist/interfaces/DatabaseFileAccess.d.ts +8 -0
- package/dist/interfaces/DatabaseRebuilder.d.ts +12 -2
- package/dist/interfaces/FileReflectionProvenance.d.ts +32 -0
- package/dist/interfaces/FileReflectionProvenance.js +25 -0
- package/dist/managers/ConflictManager.js +42 -9
- package/dist/managers/EntryManager/EntryManager.d.ts +1 -0
- package/dist/managers/EntryManager/EntryManager.js +5 -1
- package/dist/managers/EntryManager/EntryManagerImpls.d.ts +1 -0
- package/dist/managers/EntryManager/EntryManagerImpls.js +29 -1
- package/dist/platform/node/storage.d.ts +10 -1
- package/dist/platform/node/storage.js +86 -25
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +1 -0
- package/dist/pouchdb/LiveSyncLocalDB.js +3 -0
- package/dist/remoteConfigurations.d.ts +9 -0
- package/dist/remoteConfigurations.js +14 -0
- package/dist/replication/LiveSyncAbstractReplicator.d.ts +3 -3
- package/dist/replication/couchdb/LiveSyncReplicator.d.ts +0 -1
- package/dist/replication/couchdb/LiveSyncReplicator.js +0 -3
- package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +0 -1
- package/dist/replication/journal/LiveSyncJournalReplicator.js +0 -3
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +5 -3
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.js +42 -30
- package/dist/replication/trystero/P2PReplicatorCore.d.ts +2 -6
- package/dist/replication/trystero/P2PReplicatorCore.js +16 -86
- package/dist/replication/trystero/TrysteroReplicator.d.ts +2 -1
- package/dist/replication/trystero/TrysteroReplicator.js +10 -4
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +4 -5
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +22 -30
- package/dist/replication/trystero/UseP2PReplicatorResult.d.ts +10 -2
- package/dist/replication/trystero/addP2PEventHandlers.d.ts +4 -2
- package/dist/replication/trystero/addP2PEventHandlers.js +9 -10
- package/dist/replication/trystero/types.d.ts +2 -0
- package/dist/replication/trystero/useP2PReplicatorCommands.d.ts +1 -1
- package/dist/replication/trystero/useP2PReplicatorCommands.js +3 -1
- package/dist/replication/trystero/useP2PReplicatorFeature.js +25 -15
- package/dist/rpc/RpcRoom.d.ts +1 -1
- package/dist/rpc/RpcRoom.js +22 -16
- package/dist/rpc/transports/TrysteroTransport.d.ts +2 -0
- package/dist/rpc/transports/TrysteroTransport.js +24 -17
- package/dist/rpc/transports/trysteroRoomEvents.d.ts +14 -0
- package/dist/rpc/transports/trysteroRoomEvents.js +34 -0
- package/dist/serviceFeatures/checkRemoteSize.d.ts +5 -3
- package/dist/serviceFeatures/checkRemoteSize.js +51 -11
- package/dist/serviceFeatures/remoteConfig.d.ts +37 -1
- package/dist/serviceFeatures/remoteConfig.js +90 -0
- package/dist/serviceModules/Rebuilder.d.ts +3 -6
- package/dist/serviceModules/Rebuilder.js +31 -22
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.d.ts +5 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.js +69 -13
- package/dist/serviceModules/ServiceFileHandlerBase.d.ts +20 -0
- package/dist/serviceModules/ServiceFileHandlerBase.js +224 -40
- package/dist/services/BrowserServices.d.ts +2 -0
- package/dist/services/BrowserServices.js +4 -1
- package/dist/services/HeadlessServices.d.ts +2 -0
- package/dist/services/HeadlessServices.js +2 -1
- package/dist/services/base/CommonlibMessages.d.ts +318 -0
- package/dist/services/base/CommonlibMessages.js +313 -0
- package/dist/services/base/IService.d.ts +13 -6
- package/dist/services/base/KeyValueDBService.d.ts +1 -1
- package/dist/services/base/KeyValueDBService.js +3 -1
- package/dist/services/base/MessageTranslator.d.ts +5 -2
- package/dist/services/base/MessageTranslator.js +21 -0
- package/dist/services/base/ReplicationService.d.ts +4 -2
- package/dist/services/base/ReplicationService.js +11 -16
- package/dist/services/base/ServiceBase.d.ts +1 -1
- package/dist/services/base/ServiceBase.js +2 -4
- package/dist/services/base/SettingService.d.ts +17 -9
- package/dist/services/base/SettingService.js +38 -19
- package/dist/services/implements/headless/HeadlessAPIService.d.ts +3 -3
- package/dist/services/implements/headless/HeadlessAPIService.js +2 -2
- package/dist/services/implements/injectable/InjectableTweakValueService.d.ts +3 -3
- package/dist/settings.d.ts +10 -0
- package/dist/settings.js +32 -0
- package/dist/worker/bgWorker.js +1 -1
- package/docs/conflict-resolution.md +161 -0
- package/docs/development.md +106 -7
- package/docs/p2p-transport-lifecycle.md +62 -0
- package/docs/platform-storage.md +4 -0
- package/docs/proven-in-use.md +65 -0
- package/docs/releasing.md +26 -6
- package/docs/remote-configurations.md +63 -0
- package/docs/settings-lifecycle.md +85 -0
- package/package.json +17 -27
- package/dist/common/i18n.d.ts +0 -18
- package/dist/common/i18n.js +0 -7193
- package/dist/common/messages/combinedMessages.dev.d.ts +0 -7
- package/dist/common/messages/combinedMessages.dev.js +0 -44
- package/dist/common/messages/combinedMessages.prod.d.ts +0 -9264
- package/dist/common/messages/combinedMessages.prod.js +0 -9271
- package/dist/common/messages/de.d.ts +0 -297
- package/dist/common/messages/de.js +0 -7
- package/dist/common/messages/def.d.ts +0 -1119
- package/dist/common/messages/def.js +0 -7
- package/dist/common/messages/es.d.ts +0 -689
- package/dist/common/messages/es.js +0 -7
- package/dist/common/messages/fr.d.ts +0 -582
- package/dist/common/messages/fr.js +0 -7
- package/dist/common/messages/he.d.ts +0 -583
- package/dist/common/messages/he.js +0 -7
- package/dist/common/messages/ja.d.ts +0 -838
- package/dist/common/messages/ja.js +0 -7
- package/dist/common/messages/ko.d.ts +0 -800
- package/dist/common/messages/ko.js +0 -7
- package/dist/common/messages/ru.d.ts +0 -858
- package/dist/common/messages/ru.js +0 -7
- package/dist/common/messages/zh-tw.d.ts +0 -384
- package/dist/common/messages/zh-tw.js +0 -7
- package/dist/common/messages/zh.d.ts +0 -1093
- package/dist/common/messages/zh.js +0 -7
- package/dist/common/messagesJson/de.json +0 -295
- package/dist/common/messagesJson/en.json +0 -1117
- package/dist/common/messagesJson/es.json +0 -687
- package/dist/common/messagesJson/fr.json +0 -580
- package/dist/common/messagesJson/he.json +0 -581
- package/dist/common/messagesJson/ja.json +0 -836
- package/dist/common/messagesJson/ko.json +0 -798
- package/dist/common/messagesJson/ru.json +0 -856
- package/dist/common/messagesJson/zh-tw.json +0 -382
- package/dist/common/messagesJson/zh.json +0 -1091
- package/dist/common/rosetta.d.ts +0 -42
- package/dist/common/rosetta.js +0 -57
|
@@ -1,13 +1,16 @@
|
|
|
1
|
-
import { type ObsidianLiveSyncSettings } from "../../common/types.js";
|
|
1
|
+
import { type ObsidianLiveSyncSettings, type SettingsMigrationState } from "../../common/types.js";
|
|
2
2
|
import type { IAPIService, ISettingService } from "./IService.js";
|
|
3
3
|
import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
|
|
4
4
|
import { createInstanceLogFunction } from "../lib/logUtils.js";
|
|
5
5
|
export interface SettingServiceDependencies {
|
|
6
6
|
APIService: IAPIService;
|
|
7
|
+
/** Optional host hook for applying the loaded display language to its catalogue. */
|
|
8
|
+
onDisplayLanguageChanged?: (language: ObsidianLiveSyncSettings["displayLanguage"]) => void;
|
|
7
9
|
}
|
|
8
10
|
export declare abstract class SettingService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements ISettingService {
|
|
9
11
|
deviceAndVaultName: string;
|
|
10
12
|
protected APIService: IAPIService;
|
|
13
|
+
private readonly onDisplayLanguageChanged?;
|
|
11
14
|
protected abstract setItem(key: string, value: string): void;
|
|
12
15
|
protected abstract getItem(key: string): string;
|
|
13
16
|
protected abstract deleteItem(key: string): void;
|
|
@@ -17,6 +20,8 @@ export declare abstract class SettingService<T extends ServiceContext = ServiceC
|
|
|
17
20
|
protected abstract saveData(setting: ObsidianLiveSyncSettings): Promise<void>;
|
|
18
21
|
protected abstract loadData(): Promise<ObsidianLiveSyncSettings | undefined>;
|
|
19
22
|
private _lastPersistedSettings?;
|
|
23
|
+
private _settingsMigrationState?;
|
|
24
|
+
getSettingsMigrationState(): SettingsMigrationState | undefined;
|
|
20
25
|
_log: ReturnType<typeof createInstanceLogFunction>;
|
|
21
26
|
constructor(context: T, dependencies: SettingServiceDependencies);
|
|
22
27
|
/**
|
|
@@ -37,6 +42,17 @@ export declare abstract class SettingService<T extends ServiceContext = ServiceC
|
|
|
37
42
|
* Save the current device and vault name to settings, aside from the main settings.
|
|
38
43
|
*/
|
|
39
44
|
saveDeviceAndVaultName(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Read an exact key from the host's device-local configuration store.
|
|
47
|
+
*
|
|
48
|
+
* Unlike the main settings document, this state is not synchronised. Callers
|
|
49
|
+
* which need Vault namespacing should normally use {@link getSmallConfig}.
|
|
50
|
+
*/
|
|
51
|
+
getDeviceLocalConfig(key: string): string | null;
|
|
52
|
+
/** Store an exact key in the host's non-synchronised configuration store. */
|
|
53
|
+
setDeviceLocalConfig(key: string, value: string): void;
|
|
54
|
+
/** Delete an exact key from the host's non-synchronised configuration store. */
|
|
55
|
+
deleteDeviceLocalConfig(key: string): void;
|
|
40
56
|
private additionalSuffixOfDatabaseName;
|
|
41
57
|
private getKey;
|
|
42
58
|
setSmallConfig(key: string, value: string): void;
|
|
@@ -69,16 +85,8 @@ export declare abstract class SettingService<T extends ServiceContext = ServiceC
|
|
|
69
85
|
* Suspend extra synchronisation activities, e.g., hidden files sync.
|
|
70
86
|
*/
|
|
71
87
|
readonly suspendExtraSync: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
|
|
72
|
-
/**
|
|
73
|
-
* Suggest enabling optional features to the user.
|
|
74
|
-
*/
|
|
75
|
-
readonly suggestOptionalFeatures: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(opt: {
|
|
76
|
-
enableFetch?: boolean;
|
|
77
|
-
enableOverwrite?: boolean;
|
|
78
|
-
}) => Promise<boolean>>;
|
|
79
88
|
/**
|
|
80
89
|
* Enable an optional feature and save to the settings.
|
|
81
|
-
* It may also raised from `handleSuggestOptionalFeatures` if the user agrees.
|
|
82
90
|
* @param mode The optional feature to enable.
|
|
83
91
|
*/
|
|
84
92
|
readonly enableOptionalFeature: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<(mode: keyof OPTIONAL_SYNC_FEATURES) => Promise<boolean>>;
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ChunkAlgorithmNames,
|
|
3
|
-
DEFAULT_SETTINGS,
|
|
4
3
|
LOG_LEVEL_NOTICE,
|
|
5
4
|
LOG_LEVEL_URGENT,
|
|
6
5
|
LOG_LEVEL_VERBOSE,
|
|
7
6
|
SALT_OF_PASSPHRASE,
|
|
8
|
-
SETTING_KEY_P2P_DEVICE_NAME
|
|
7
|
+
SETTING_KEY_P2P_DEVICE_NAME,
|
|
8
|
+
prepareSettingsForLoad
|
|
9
9
|
} from "../../common/types.js";
|
|
10
10
|
import { handlers } from "../lib/HandlerUtils.js";
|
|
11
11
|
import { ServiceBase } from "./ServiceBase.js";
|
|
12
12
|
import { createInstanceLogFunction } from "../lib/logUtils.js";
|
|
13
13
|
import { isCloudantURI } from "../../pouchdb/utils_couchdb.js";
|
|
14
14
|
import { decryptString, encryptString } from "../../encryption/stringEncryption.js";
|
|
15
|
-
import { setLang } from "../../common/i18n.js";
|
|
16
15
|
import {
|
|
17
16
|
activateP2PRemoteConfiguration,
|
|
18
17
|
activateRemoteConfiguration,
|
|
@@ -23,6 +22,7 @@ import { ConnectionStringParser } from "../../common/ConnectionString.js";
|
|
|
23
22
|
class SettingService extends ServiceBase {
|
|
24
23
|
deviceAndVaultName = "";
|
|
25
24
|
APIService;
|
|
25
|
+
onDisplayLanguageChanged;
|
|
26
26
|
_settings;
|
|
27
27
|
get settings() {
|
|
28
28
|
return this._settings;
|
|
@@ -31,10 +31,15 @@ class SettingService extends ServiceBase {
|
|
|
31
31
|
this._settings = value;
|
|
32
32
|
}
|
|
33
33
|
_lastPersistedSettings;
|
|
34
|
+
_settingsMigrationState;
|
|
35
|
+
getSettingsMigrationState() {
|
|
36
|
+
return this._settingsMigrationState;
|
|
37
|
+
}
|
|
34
38
|
_log;
|
|
35
39
|
constructor(context, dependencies) {
|
|
36
40
|
super(context);
|
|
37
41
|
this.APIService = dependencies.APIService;
|
|
42
|
+
this.onDisplayLanguageChanged = dependencies.onDisplayLanguageChanged;
|
|
38
43
|
this._log = createInstanceLogFunction("SettingService", this.APIService);
|
|
39
44
|
}
|
|
40
45
|
/**
|
|
@@ -88,7 +93,24 @@ class SettingService extends ServiceBase {
|
|
|
88
93
|
*/
|
|
89
94
|
saveDeviceAndVaultName() {
|
|
90
95
|
const lsKey = "obsidian-live-sync-vaultanddevicename-" + this.APIService.getSystemVaultName() + this.additionalSuffixOfDatabaseName();
|
|
91
|
-
this.
|
|
96
|
+
this.setDeviceLocalConfig(lsKey, this.deviceAndVaultName);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Read an exact key from the host's device-local configuration store.
|
|
100
|
+
*
|
|
101
|
+
* Unlike the main settings document, this state is not synchronised. Callers
|
|
102
|
+
* which need Vault namespacing should normally use {@link getSmallConfig}.
|
|
103
|
+
*/
|
|
104
|
+
getDeviceLocalConfig(key) {
|
|
105
|
+
return this.getItem(key);
|
|
106
|
+
}
|
|
107
|
+
/** Store an exact key in the host's non-synchronised configuration store. */
|
|
108
|
+
setDeviceLocalConfig(key, value) {
|
|
109
|
+
this.setItem(key, value);
|
|
110
|
+
}
|
|
111
|
+
/** Delete an exact key from the host's non-synchronised configuration store. */
|
|
112
|
+
deleteDeviceLocalConfig(key) {
|
|
113
|
+
this.deleteItem(key);
|
|
92
114
|
}
|
|
93
115
|
additionalSuffixOfDatabaseName() {
|
|
94
116
|
const suffix = this.settings?.additionalSuffixOfDatabaseName;
|
|
@@ -105,15 +127,15 @@ class SettingService extends ServiceBase {
|
|
|
105
127
|
}
|
|
106
128
|
setSmallConfig(key, value) {
|
|
107
129
|
const dbKey = this.getKey(key);
|
|
108
|
-
this.
|
|
130
|
+
this.setDeviceLocalConfig(dbKey, value);
|
|
109
131
|
}
|
|
110
132
|
getSmallConfig(key) {
|
|
111
133
|
const dbKey = this.getKey(key);
|
|
112
|
-
return this.
|
|
134
|
+
return this.getDeviceLocalConfig(dbKey) ?? "";
|
|
113
135
|
}
|
|
114
136
|
deleteSmallConfig(key) {
|
|
115
137
|
const dbKey = this.getKey(key);
|
|
116
|
-
this.
|
|
138
|
+
this.deleteDeviceLocalConfig(dbKey);
|
|
117
139
|
}
|
|
118
140
|
/**
|
|
119
141
|
* Save the current settings to storage.
|
|
@@ -266,13 +288,8 @@ class SettingService extends ServiceBase {
|
|
|
266
288
|
* Suspend extra synchronisation activities, e.g., hidden files sync.
|
|
267
289
|
*/
|
|
268
290
|
suspendExtraSync = handlers().all("suspendExtraSync");
|
|
269
|
-
/**
|
|
270
|
-
* Suggest enabling optional features to the user.
|
|
271
|
-
*/
|
|
272
|
-
suggestOptionalFeatures = handlers().all("suggestOptionalFeatures");
|
|
273
291
|
/**
|
|
274
292
|
* Enable an optional feature and save to the settings.
|
|
275
|
-
* It may also raised from `handleSuggestOptionalFeatures` if the user agrees.
|
|
276
293
|
* @param mode The optional feature to enable.
|
|
277
294
|
*/
|
|
278
295
|
enableOptionalFeature = handlers().all("enableOptionalFeature");
|
|
@@ -332,7 +349,7 @@ class SettingService extends ServiceBase {
|
|
|
332
349
|
getPassphrase(settings) {
|
|
333
350
|
const methods = {
|
|
334
351
|
"": () => Promise.resolve("*"),
|
|
335
|
-
LOCALSTORAGE: () => Promise.resolve(this.
|
|
352
|
+
LOCALSTORAGE: () => Promise.resolve(this.getDeviceLocalConfig("ls-setting-passphrase") ?? false),
|
|
336
353
|
ASK_AT_LAUNCH: () => this.APIService.confirm.askString("Passphrase", "passphrase", "")
|
|
337
354
|
};
|
|
338
355
|
const method = settings.configPassphraseStore;
|
|
@@ -445,10 +462,12 @@ class SettingService extends ServiceBase {
|
|
|
445
462
|
return settings;
|
|
446
463
|
}
|
|
447
464
|
async loadSettings() {
|
|
448
|
-
const
|
|
465
|
+
const prepared = prepareSettingsForLoad(await this.loadData());
|
|
466
|
+
const { settings, ...migrationState } = prepared;
|
|
467
|
+
this._settingsMigrationState = migrationState;
|
|
449
468
|
const hadRemoteConfigurations = Object.keys(settings.remoteConfigurations ?? {}).length > 0;
|
|
450
469
|
if (typeof settings.isConfigured == "undefined") {
|
|
451
|
-
if (
|
|
470
|
+
if (!prepared.isNewVault) {
|
|
452
471
|
settings.isConfigured = true;
|
|
453
472
|
} else {
|
|
454
473
|
const appId = this.APIService.getAppID();
|
|
@@ -457,7 +476,7 @@ class SettingService extends ServiceBase {
|
|
|
457
476
|
}
|
|
458
477
|
}
|
|
459
478
|
this.settings = await this.decryptSettings(settings);
|
|
460
|
-
|
|
479
|
+
this.onDisplayLanguageChanged?.(this.settings.displayLanguage);
|
|
461
480
|
await this.adjustSettings(this.settings);
|
|
462
481
|
const migratedLegacyRemoteConfigurations = !hadRemoteConfigurations && Object.keys(this.settings.remoteConfigurations ?? {}).length > 0;
|
|
463
482
|
const migratedP2PActiveRemoteConfiguration = migratedLegacyRemoteConfigurations && migrateP2PActiveRemoteConfigurationIdInPlace(this.settings);
|
|
@@ -493,7 +512,7 @@ class SettingService extends ServiceBase {
|
|
|
493
512
|
}
|
|
494
513
|
const lsKey = "obsidian-live-sync-vaultanddevicename-" + this.APIService.getSystemVaultName() + this.additionalSuffixOfDatabaseName();
|
|
495
514
|
if (this.settings.deviceAndVaultName != "") {
|
|
496
|
-
if (!this.
|
|
515
|
+
if (!this.getDeviceLocalConfig(lsKey)) {
|
|
497
516
|
this.setDeviceAndVaultName(this.settings.deviceAndVaultName);
|
|
498
517
|
this.saveDeviceAndVaultName();
|
|
499
518
|
this.settings.deviceAndVaultName = "";
|
|
@@ -506,14 +525,14 @@ class SettingService extends ServiceBase {
|
|
|
506
525
|
);
|
|
507
526
|
this.settings.customChunkSize = 0;
|
|
508
527
|
}
|
|
509
|
-
this.setDeviceAndVaultName(this.
|
|
528
|
+
this.setDeviceAndVaultName(this.getDeviceLocalConfig(lsKey) || "");
|
|
510
529
|
if (this.getDeviceAndVaultName() == "") {
|
|
511
530
|
if (this.settings.usePluginSync) {
|
|
512
531
|
this._log("Device name missing. Disabling plug-in sync.", LOG_LEVEL_NOTICE);
|
|
513
532
|
this.settings.usePluginSync = false;
|
|
514
533
|
}
|
|
515
534
|
}
|
|
516
|
-
if (migratedLegacyRemoteConfigurations || migratedP2PActiveRemoteConfiguration) {
|
|
535
|
+
if (!prepared.isFromFutureSchema && (prepared.changed || migratedLegacyRemoteConfigurations || migratedP2PActiveRemoteConfiguration)) {
|
|
517
536
|
await this.saveSettingData();
|
|
518
537
|
}
|
|
519
538
|
this._lastPersistedSettings = this.cloneSettings(this.settings);
|
|
@@ -2,7 +2,7 @@ import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
|
2
2
|
import { InjectableAPIService } from "../injectable/InjectableAPIService.js";
|
|
3
3
|
import type { FetchHttpHandler } from "@smithy/fetch-http-handler";
|
|
4
4
|
import type { ICommandCompat } from "../../base/IService.js";
|
|
5
|
-
import type { Confirm } from "../../../interfaces/Confirm.js";
|
|
5
|
+
import type { Confirm, ConfirmActionLayout } from "../../../interfaces/Confirm.js";
|
|
6
6
|
/**
|
|
7
7
|
* Headless implementation of Confirm that returns sensible defaults instead
|
|
8
8
|
* of throwing. Dialogs are logged to stderr so the prompts are visible in
|
|
@@ -22,8 +22,8 @@ export declare class HeadlessConfirm implements Confirm {
|
|
|
22
22
|
defaultAction: T[number];
|
|
23
23
|
timeout?: number;
|
|
24
24
|
}): Promise<T[number] | false>;
|
|
25
|
-
askInPopup(key: string, dialogText: string, anchorCallback: (anchor: HTMLAnchorElement) => void): void;
|
|
26
|
-
confirmWithMessage(title: string, contentMd: string, buttons: string[], defaultAction: (typeof buttons)[number], timeout?: number): Promise<(typeof buttons)[number] | false>;
|
|
25
|
+
askInPopup(key: string, dialogText: string, anchorCallback: (anchor: HTMLAnchorElement) => void, durationMs?: number): void;
|
|
26
|
+
confirmWithMessage(title: string, contentMd: string, buttons: string[], defaultAction: (typeof buttons)[number], timeout?: number, _actionLayout?: ConfirmActionLayout): Promise<(typeof buttons)[number] | false>;
|
|
27
27
|
}
|
|
28
28
|
export declare class HeadlessAPIService<T extends ServiceContext> extends InjectableAPIService<T> {
|
|
29
29
|
private _confirmInstance;
|
|
@@ -23,10 +23,10 @@ class HeadlessConfirm {
|
|
|
23
23
|
console.error(`[Headless] ${opt.title ?? "Confirm"}: ${message} \u2192 ${String(opt.defaultAction)}`);
|
|
24
24
|
return Promise.resolve(opt.defaultAction);
|
|
25
25
|
}
|
|
26
|
-
askInPopup(key, dialogText, anchorCallback) {
|
|
26
|
+
askInPopup(key, dialogText, anchorCallback, durationMs) {
|
|
27
27
|
console.error(`[Headless] Popup (${key}): ${dialogText}`);
|
|
28
28
|
}
|
|
29
|
-
confirmWithMessage(title, contentMd, buttons, defaultAction, timeout) {
|
|
29
|
+
confirmWithMessage(title, contentMd, buttons, defaultAction, timeout, _actionLayout) {
|
|
30
30
|
console.error(`[Headless] ${title}: ${contentMd} \u2192 ${defaultAction}`);
|
|
31
31
|
return Promise.resolve(defaultAction);
|
|
32
32
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
2
2
|
import { TweakValueService } from "../../base/TweakValueService.js";
|
|
3
3
|
export declare class InjectableTweakValueService<T extends ServiceContext> extends TweakValueService<T> {
|
|
4
|
-
fetchRemotePreferred: import("../../lib/HandlerUtils.js").HandlerFunction<(trialSetting: import("../../../
|
|
4
|
+
fetchRemotePreferred: import("../../lib/HandlerUtils.js").HandlerFunction<(trialSetting: import("../../../settings.js").RemoteDBSettings) => Promise<import("../../../common/types.js").TweakValues | false>, unknown>;
|
|
5
5
|
checkAndAskResolvingMismatched: import("../../lib/HandlerUtils.js").HandlerFunction<(preferred: Partial<import("../../../common/types.js").TweakValues>) => Promise<[import("../../../common/types.js").TweakValues | boolean, boolean]>, unknown>;
|
|
6
6
|
askResolvingMismatched: import("../../lib/HandlerUtils.js").HandlerFunction<(preferredSource: import("../../../common/types.js").TweakValues) => Promise<"OK" | "CHECKAGAIN" | "IGNORE">, unknown>;
|
|
7
|
-
checkAndAskUseRemoteConfiguration: import("../../lib/HandlerUtils.js").HandlerFunction<(settings: import("../../../
|
|
7
|
+
checkAndAskUseRemoteConfiguration: import("../../lib/HandlerUtils.js").HandlerFunction<(settings: import("../../../settings.js").RemoteDBSettings) => Promise<{
|
|
8
8
|
result: false | import("../../../common/types.js").TweakValues;
|
|
9
9
|
requireFetch: boolean;
|
|
10
10
|
}>, unknown>;
|
|
11
|
-
askUseRemoteConfiguration: import("../../lib/HandlerUtils.js").HandlerFunction<(trialSetting: import("../../../
|
|
11
|
+
askUseRemoteConfiguration: import("../../lib/HandlerUtils.js").HandlerFunction<(trialSetting: import("../../../settings.js").RemoteDBSettings, preferred: import("../../../common/types.js").TweakValues) => Promise<{
|
|
12
12
|
result: false | import("../../../common/types.js").TweakValues;
|
|
13
13
|
requireFetch: boolean;
|
|
14
14
|
}>, unknown>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Settings defaults and migration contracts shared by maintained hosts.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*/
|
|
6
|
+
export { DEFAULT_SETTINGS, NEW_VAULT_SETTINGS, P2P_DEFAULT_SETTINGS, SETTINGS_SCHEMA_DEFAULTS, createNewVaultSettings, } from "./common/models/setting.const.defaults.js";
|
|
7
|
+
export { PREFERRED_BASE, PREFERRED_JOURNAL_SYNC, PREFERRED_SETTING_CLOUDANT, PREFERRED_SETTING_SELF_HOSTED, } from "./common/models/setting.const.preferred.js";
|
|
8
|
+
export { CURRENT_SETTING_VERSION } from "./common/models/setting.const.js";
|
|
9
|
+
export { prepareSettingsForLoad, SettingsMigrationReviewCodes, type PreparedSettings, type SettingsMigrationReviewCode, type SettingsMigrationReviewReason, type SettingsMigrationState, } from "./common/models/setting.lifecycle.js";
|
|
10
|
+
export type { ObsidianLiveSyncSettings, RemoteDBSettings, RemoteTypeSettings, } from "./common/models/setting.type.js";
|
package/dist/settings.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_SETTINGS,
|
|
3
|
+
NEW_VAULT_SETTINGS,
|
|
4
|
+
P2P_DEFAULT_SETTINGS,
|
|
5
|
+
SETTINGS_SCHEMA_DEFAULTS,
|
|
6
|
+
createNewVaultSettings
|
|
7
|
+
} from "./common/models/setting.const.defaults.js";
|
|
8
|
+
import {
|
|
9
|
+
PREFERRED_BASE,
|
|
10
|
+
PREFERRED_JOURNAL_SYNC,
|
|
11
|
+
PREFERRED_SETTING_CLOUDANT,
|
|
12
|
+
PREFERRED_SETTING_SELF_HOSTED
|
|
13
|
+
} from "./common/models/setting.const.preferred.js";
|
|
14
|
+
import { CURRENT_SETTING_VERSION } from "./common/models/setting.const.js";
|
|
15
|
+
import {
|
|
16
|
+
prepareSettingsForLoad,
|
|
17
|
+
SettingsMigrationReviewCodes
|
|
18
|
+
} from "./common/models/setting.lifecycle.js";
|
|
19
|
+
export {
|
|
20
|
+
CURRENT_SETTING_VERSION,
|
|
21
|
+
DEFAULT_SETTINGS,
|
|
22
|
+
NEW_VAULT_SETTINGS,
|
|
23
|
+
P2P_DEFAULT_SETTINGS,
|
|
24
|
+
PREFERRED_BASE,
|
|
25
|
+
PREFERRED_JOURNAL_SYNC,
|
|
26
|
+
PREFERRED_SETTING_CLOUDANT,
|
|
27
|
+
PREFERRED_SETTING_SELF_HOSTED,
|
|
28
|
+
SETTINGS_SCHEMA_DEFAULTS,
|
|
29
|
+
SettingsMigrationReviewCodes,
|
|
30
|
+
createNewVaultSettings,
|
|
31
|
+
prepareSettingsForLoad
|
|
32
|
+
};
|