@vrtmrz/livesync-commonlib 0.1.0-rc.0
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/LICENSE +21 -0
- package/README.md +49 -0
- package/dist/API/DirectFileManipulator.d.ts +2 -0
- package/dist/API/DirectFileManipulator.js +4 -0
- package/dist/API/DirectFileManipulatorV2.d.ts +150 -0
- package/dist/API/DirectFileManipulatorV2.js +424 -0
- package/dist/API/processSetting.d.ts +41 -0
- package/dist/API/processSetting.js +140 -0
- package/dist/ContentSplitter/ContentSplitter.d.ts +28 -0
- package/dist/ContentSplitter/ContentSplitter.js +5 -0
- package/dist/ContentSplitter/ContentSplitterBase.d.ts +51 -0
- package/dist/ContentSplitter/ContentSplitterBase.js +83 -0
- package/dist/ContentSplitter/ContentSplitterRabinKarp.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterRabinKarp.js +32 -0
- package/dist/ContentSplitter/ContentSplitterV1.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterV1.js +34 -0
- package/dist/ContentSplitter/ContentSplitterV2.d.ts +9 -0
- package/dist/ContentSplitter/ContentSplitterV2.js +34 -0
- package/dist/ContentSplitter/ContentSplitters.d.ts +12 -0
- package/dist/ContentSplitter/ContentSplitters.js +29 -0
- package/dist/bureau/bureau.d.ts +7 -0
- package/dist/bureau/bureau.js +5 -0
- package/dist/common/ConnectionString.d.ts +30 -0
- package/dist/common/ConnectionString.js +179 -0
- package/dist/common/LSError.d.ts +48 -0
- package/dist/common/LSError.js +112 -0
- package/dist/common/configForDoc.d.ts +79 -0
- package/dist/common/configForDoc.js +312 -0
- package/dist/common/coreEnvFunctions.d.ts +21 -0
- package/dist/common/coreEnvFunctions.js +22 -0
- package/dist/common/coreEnvVars.d.ts +3 -0
- package/dist/common/coreEnvVars.js +6 -0
- package/dist/common/i18n.d.ts +18 -0
- package/dist/common/i18n.js +7193 -0
- package/dist/common/logger.d.ts +2 -0
- package/dist/common/logger.js +1 -0
- package/dist/common/messages/combinedMessages.dev.d.ts +7 -0
- package/dist/common/messages/combinedMessages.dev.js +44 -0
- package/dist/common/messages/combinedMessages.prod.d.ts +9264 -0
- package/dist/common/messages/combinedMessages.prod.js +9271 -0
- package/dist/common/messages/de.d.ts +297 -0
- package/dist/common/messages/de.js +7 -0
- package/dist/common/messages/def.d.ts +1119 -0
- package/dist/common/messages/def.js +7 -0
- package/dist/common/messages/es.d.ts +689 -0
- package/dist/common/messages/es.js +7 -0
- package/dist/common/messages/fr.d.ts +582 -0
- package/dist/common/messages/fr.js +7 -0
- package/dist/common/messages/he.d.ts +583 -0
- package/dist/common/messages/he.js +7 -0
- package/dist/common/messages/ja.d.ts +838 -0
- package/dist/common/messages/ja.js +7 -0
- package/dist/common/messages/ko.d.ts +800 -0
- package/dist/common/messages/ko.js +7 -0
- package/dist/common/messages/ru.d.ts +858 -0
- package/dist/common/messages/ru.js +7 -0
- package/dist/common/messages/zh-tw.d.ts +384 -0
- package/dist/common/messages/zh-tw.js +7 -0
- package/dist/common/messages/zh.d.ts +1093 -0
- package/dist/common/messages/zh.js +7 -0
- package/dist/common/messagesJson/de.json +295 -0
- package/dist/common/messagesJson/en.json +1117 -0
- package/dist/common/messagesJson/es.json +687 -0
- package/dist/common/messagesJson/fr.json +580 -0
- package/dist/common/messagesJson/he.json +581 -0
- package/dist/common/messagesJson/ja.json +836 -0
- package/dist/common/messagesJson/ko.json +798 -0
- package/dist/common/messagesJson/ru.json +856 -0
- package/dist/common/messagesJson/zh-tw.json +382 -0
- package/dist/common/messagesJson/zh.json +1091 -0
- package/dist/common/models/auth.type.d.ts +41 -0
- package/dist/common/models/auth.type.js +0 -0
- package/dist/common/models/db.const.d.ts +20 -0
- package/dist/common/models/db.const.js +28 -0
- package/dist/common/models/db.definition.d.ts +56 -0
- package/dist/common/models/db.definition.js +6 -0
- package/dist/common/models/db.type.d.ts +142 -0
- package/dist/common/models/db.type.js +0 -0
- package/dist/common/models/diff.definition.d.ts +16 -0
- package/dist/common/models/diff.definition.js +0 -0
- package/dist/common/models/fileaccess.const.d.ts +7 -0
- package/dist/common/models/fileaccess.const.js +16 -0
- package/dist/common/models/fileaccess.type.d.ts +72 -0
- package/dist/common/models/fileaccess.type.js +0 -0
- package/dist/common/models/redflag.const.d.ts +32 -0
- package/dist/common/models/redflag.const.js +27 -0
- package/dist/common/models/setting.const.d.ts +49 -0
- package/dist/common/models/setting.const.defaults.d.ts +3 -0
- package/dist/common/models/setting.const.defaults.js +185 -0
- package/dist/common/models/setting.const.js +68 -0
- package/dist/common/models/setting.const.preferred.d.ts +5 -0
- package/dist/common/models/setting.const.preferred.js +35 -0
- package/dist/common/models/setting.const.qr.d.ts +2 -0
- package/dist/common/models/setting.const.qr.js +174 -0
- package/dist/common/models/setting.type.d.ts +900 -0
- package/dist/common/models/setting.type.js +8 -0
- package/dist/common/models/shared.const.behabiour.d.ts +28 -0
- package/dist/common/models/shared.const.behabiour.js +36 -0
- package/dist/common/models/shared.const.d.ts +5 -0
- package/dist/common/models/shared.const.js +12 -0
- package/dist/common/models/shared.const.symbols.d.ts +9 -0
- package/dist/common/models/shared.const.symbols.js +20 -0
- package/dist/common/models/shared.definition.configNames.d.ts +36 -0
- package/dist/common/models/shared.definition.configNames.js +203 -0
- package/dist/common/models/shared.definition.d.ts +22 -0
- package/dist/common/models/shared.definition.js +24 -0
- package/dist/common/models/shared.type.util.d.ts +8 -0
- package/dist/common/models/shared.type.util.js +0 -0
- package/dist/common/models/sync.definition.d.ts +18 -0
- package/dist/common/models/sync.definition.js +20 -0
- package/dist/common/models/tweak.definition.d.ts +191 -0
- package/dist/common/models/tweak.definition.js +77 -0
- package/dist/common/rosetta.d.ts +42 -0
- package/dist/common/rosetta.js +57 -0
- package/dist/common/settingConstants.d.ts +216 -0
- package/dist/common/settingConstants.js +434 -0
- package/dist/common/typeUtils.d.ts +17 -0
- package/dist/common/typeUtils.js +51 -0
- package/dist/common/types.d.ts +107 -0
- package/dist/common/types.js +212 -0
- package/dist/common/utils.d.ts +129 -0
- package/dist/common/utils.doc.d.ts +11 -0
- package/dist/common/utils.doc.js +35 -0
- package/dist/common/utils.js +583 -0
- package/dist/common/utils.object.d.ts +2 -0
- package/dist/common/utils.object.js +14 -0
- package/dist/common/utils.patch.d.ts +8 -0
- package/dist/common/utils.patch.js +178 -0
- package/dist/common/utils.type.d.ts +1 -0
- package/dist/common/utils.type.js +0 -0
- package/dist/context.d.ts +8 -0
- package/dist/context.js +14 -0
- package/dist/databases/IndexedDBKeyValueDatabase.d.ts +26 -0
- package/dist/databases/IndexedDBKeyValueDatabase.js +130 -0
- package/dist/dataobject/StoredMap.d.ts +12 -0
- package/dist/dataobject/StoredMap.js +47 -0
- package/dist/dev/checks.d.ts +5 -0
- package/dist/dev/checks.js +38 -0
- package/dist/encryption/encryptHKDF.d.ts +3 -0
- package/dist/encryption/encryptHKDF.js +7 -0
- package/dist/encryption/stringEncryption.d.ts +27 -0
- package/dist/encryption/stringEncryption.js +59 -0
- package/dist/events/coreEvents.d.ts +54 -0
- package/dist/events/coreEvents.js +46 -0
- package/dist/hub/hub.d.ts +11 -0
- package/dist/hub/hub.js +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +4 -0
- package/dist/interfaces/AsyncActivityRunner.d.ts +18 -0
- package/dist/interfaces/AsyncActivityRunner.js +7 -0
- package/dist/interfaces/Confirm.d.ts +17 -0
- package/dist/interfaces/Confirm.js +0 -0
- package/dist/interfaces/DatabaseFileAccess.d.ts +14 -0
- package/dist/interfaces/DatabaseFileAccess.js +0 -0
- package/dist/interfaces/DatabaseRebuilder.d.ts +13 -0
- package/dist/interfaces/DatabaseRebuilder.js +0 -0
- package/dist/interfaces/FileHandler.d.ts +13 -0
- package/dist/interfaces/FileHandler.js +0 -0
- package/dist/interfaces/KeyValueDatabase.d.ts +11 -0
- package/dist/interfaces/KeyValueDatabase.js +0 -0
- package/dist/interfaces/ServiceModule.d.ts +59 -0
- package/dist/interfaces/ServiceModule.js +19 -0
- package/dist/interfaces/StorageAccess.d.ts +44 -0
- package/dist/interfaces/StorageAccess.js +0 -0
- package/dist/interfaces/StorageEventManager.d.ts +16 -0
- package/dist/interfaces/StorageEventManager.js +5 -0
- package/dist/managers/ChangeManager.d.ts +61 -0
- package/dist/managers/ChangeManager.js +104 -0
- package/dist/managers/ChunkDeliveryCoordinator.d.ts +51 -0
- package/dist/managers/ChunkDeliveryCoordinator.js +136 -0
- package/dist/managers/ChunkFetcher.d.ts +44 -0
- package/dist/managers/ChunkFetcher.js +251 -0
- package/dist/managers/ChunkManager.d.ts +2 -0
- package/dist/managers/ChunkManager.js +4 -0
- package/dist/managers/ConflictManager.d.ts +37 -0
- package/dist/managers/ConflictManager.js +322 -0
- package/dist/managers/EntryManager/EntryManager.d.ts +37 -0
- package/dist/managers/EntryManager/EntryManager.js +73 -0
- package/dist/managers/EntryManager/EntryManagerImpls.d.ts +74 -0
- package/dist/managers/EntryManager/EntryManagerImpls.js +499 -0
- package/dist/managers/HashManager/HashManager.d.ts +60 -0
- package/dist/managers/HashManager/HashManager.js +97 -0
- package/dist/managers/HashManager/HashManagerCore.d.ts +114 -0
- package/dist/managers/HashManager/HashManagerCore.js +99 -0
- package/dist/managers/HashManager/PureJSHashManager.d.ts +77 -0
- package/dist/managers/HashManager/PureJSHashManager.js +84 -0
- package/dist/managers/HashManager/XXHashHashManager.d.ts +96 -0
- package/dist/managers/HashManager/XXHashHashManager.js +111 -0
- package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.d.ts +30 -0
- package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.js +115 -0
- package/dist/managers/LayeredChunkManager/CacheLayer.d.ts +59 -0
- package/dist/managers/LayeredChunkManager/CacheLayer.js +161 -0
- package/dist/managers/LayeredChunkManager/ChunkLayerInterfaces.d.ts +37 -0
- package/dist/managers/LayeredChunkManager/ChunkLayerInterfaces.js +0 -0
- package/dist/managers/LayeredChunkManager/DatabaseReadLayer.d.ts +14 -0
- package/dist/managers/LayeredChunkManager/DatabaseReadLayer.js +78 -0
- package/dist/managers/LayeredChunkManager/DatabaseWriteLayer.d.ts +11 -0
- package/dist/managers/LayeredChunkManager/DatabaseWriteLayer.js +43 -0
- package/dist/managers/LayeredChunkManager/HotPackLayer.d.ts +9 -0
- package/dist/managers/LayeredChunkManager/HotPackLayer.js +8 -0
- package/dist/managers/LayeredChunkManager/types.d.ts +39 -0
- package/dist/managers/LayeredChunkManager/types.js +0 -0
- package/dist/managers/LayeredChunkManager.d.ts +53 -0
- package/dist/managers/LayeredChunkManager.js +240 -0
- package/dist/managers/LiveSyncManagers.d.ts +48 -0
- package/dist/managers/LiveSyncManagers.js +136 -0
- package/dist/managers/StorageEventManager.d.ts +135 -0
- package/dist/managers/StorageEventManager.js +564 -0
- package/dist/managers/StorageProcessingManager.d.ts +14 -0
- package/dist/managers/StorageProcessingManager.js +48 -0
- package/dist/managers/adapters/IStorageEventConverterAdapter.d.ts +16 -0
- package/dist/managers/adapters/IStorageEventConverterAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventManagerAdapter.d.ts +18 -0
- package/dist/managers/adapters/IStorageEventManagerAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventPersistenceAdapter.d.ts +15 -0
- package/dist/managers/adapters/IStorageEventPersistenceAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventStatusAdapter.d.ts +13 -0
- package/dist/managers/adapters/IStorageEventStatusAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventTypeGuardAdapter.d.ts +16 -0
- package/dist/managers/adapters/IStorageEventTypeGuardAdapter.js +0 -0
- package/dist/managers/adapters/IStorageEventWatchAdapter.d.ts +21 -0
- package/dist/managers/adapters/IStorageEventWatchAdapter.js +0 -0
- package/dist/managers/adapters/index.d.ts +6 -0
- package/dist/managers/adapters/index.js +0 -0
- package/dist/mock_and_interop/stores.d.ts +21 -0
- package/dist/mock_and_interop/stores.js +15 -0
- package/dist/mock_and_interop/wrapper.d.ts +7 -0
- package/dist/mock_and_interop/wrapper.js +37 -0
- package/dist/mods.d.ts +1 -0
- package/dist/mods.js +18 -0
- package/dist/platform/browser/index.d.ts +1 -0
- package/dist/platform/browser/index.js +10 -0
- package/dist/platform/browser/storage.d.ts +35 -0
- package/dist/platform/browser/storage.js +139 -0
- package/dist/platform/node/index.d.ts +23 -0
- package/dist/platform/node/index.js +33 -0
- package/dist/platform/node/storage.d.ts +31 -0
- package/dist/platform/node/storage.js +104 -0
- package/dist/platform/storagePath.d.ts +7 -0
- package/dist/platform/storagePath.js +20 -0
- package/dist/pouchdb/LiveSyncDBFunctions.d.ts +14 -0
- package/dist/pouchdb/LiveSyncDBFunctions.js +129 -0
- package/dist/pouchdb/LiveSyncLocalDB.d.ts +196 -0
- package/dist/pouchdb/LiveSyncLocalDB.js +381 -0
- package/dist/pouchdb/PouchDBConstructor.d.ts +3 -0
- package/dist/pouchdb/PouchDBConstructor.js +0 -0
- package/dist/pouchdb/ReplicatorShim.d.ts +51 -0
- package/dist/pouchdb/ReplicatorShim.js +109 -0
- package/dist/pouchdb/StreamingFetch.d.ts +19 -0
- package/dist/pouchdb/StreamingFetch.js +263 -0
- package/dist/pouchdb/chunks.d.ts +38 -0
- package/dist/pouchdb/chunks.js +314 -0
- package/dist/pouchdb/compress.d.ts +11 -0
- package/dist/pouchdb/compress.js +99 -0
- package/dist/pouchdb/encryption.d.ts +20 -0
- package/dist/pouchdb/encryption.js +458 -0
- package/dist/pouchdb/negotiation.d.ts +9 -0
- package/dist/pouchdb/negotiation.js +109 -0
- package/dist/pouchdb/pouchdb-browser.d.ts +2 -0
- package/dist/pouchdb/pouchdb-browser.js +96 -0
- package/dist/pouchdb/pouchdb-http.d.ts +2 -0
- package/dist/pouchdb/pouchdb-http.js +94 -0
- package/dist/pouchdb/pouchdb-test.d.ts +2 -0
- package/dist/pouchdb/pouchdb-test.js +12 -0
- package/dist/pouchdb/utils_couchdb.d.ts +4 -0
- package/dist/pouchdb/utils_couchdb.js +38 -0
- package/dist/replication/LiveSyncAbstractReplicator.d.ts +69 -0
- package/dist/replication/LiveSyncAbstractReplicator.js +92 -0
- package/dist/replication/SyncParamsHandler.d.ts +35 -0
- package/dist/replication/SyncParamsHandler.js +118 -0
- package/dist/replication/couchdb/LiveSyncReplicator.d.ts +85 -0
- package/dist/replication/couchdb/LiveSyncReplicator.js +1132 -0
- package/dist/replication/httplib.d.ts +75 -0
- package/dist/replication/httplib.js +187 -0
- package/dist/replication/journal/JournalSyncCore.d.ts +70 -0
- package/dist/replication/journal/JournalSyncCore.js +737 -0
- package/dist/replication/journal/JournalSyncTypes.d.ts +9 -0
- package/dist/replication/journal/JournalSyncTypes.js +11 -0
- package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +40 -0
- package/dist/replication/journal/LiveSyncJournalReplicator.js +294 -0
- package/dist/replication/journal/LiveSyncJournalReplicatorEnv.d.ts +3 -0
- package/dist/replication/journal/LiveSyncJournalReplicatorEnv.js +0 -0
- package/dist/replication/journal/objectstore/JournalStorageAdapter.d.ts +15 -0
- package/dist/replication/journal/objectstore/JournalStorageAdapter.js +0 -0
- package/dist/replication/journal/objectstore/MinioStorageAdapter.d.ts +21 -0
- package/dist/replication/journal/objectstore/MinioStorageAdapter.js +204 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +90 -0
- package/dist/replication/trystero/LiveSyncTrysteroReplicator.js +380 -0
- package/dist/replication/trystero/P2PLogCollector.d.ts +8 -0
- package/dist/replication/trystero/P2PLogCollector.js +91 -0
- package/dist/replication/trystero/P2PReplicatorBase.d.ts +19 -0
- package/dist/replication/trystero/P2PReplicatorBase.js +0 -0
- package/dist/replication/trystero/P2PReplicatorCore.d.ts +12 -0
- package/dist/replication/trystero/P2PReplicatorCore.js +126 -0
- package/dist/replication/trystero/P2PReplicatorPaneCommon.d.ts +41 -0
- package/dist/replication/trystero/P2PReplicatorPaneCommon.js +20 -0
- package/dist/replication/trystero/ProxiedDB.d.ts +13 -0
- package/dist/replication/trystero/ProxiedDB.js +20 -0
- package/dist/replication/trystero/TrysteroReplicator.d.ts +152 -0
- package/dist/replication/trystero/TrysteroReplicator.js +683 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +19 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +80 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PConnection.d.ts +2 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PConnection.js +4 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +117 -0
- package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +540 -0
- package/dist/replication/trystero/UseP2PReplicatorResult.d.ts +11 -0
- package/dist/replication/trystero/UseP2PReplicatorResult.js +0 -0
- package/dist/replication/trystero/addP2PEventHandlers.d.ts +35 -0
- package/dist/replication/trystero/addP2PEventHandlers.js +43 -0
- package/dist/replication/trystero/rpcCompat.d.ts +1 -0
- package/dist/replication/trystero/rpcCompat.js +9 -0
- package/dist/replication/trystero/types.d.ts +95 -0
- package/dist/replication/trystero/types.js +27 -0
- package/dist/replication/trystero/useP2PReplicatorCommands.d.ts +7 -0
- package/dist/replication/trystero/useP2PReplicatorCommands.js +25 -0
- package/dist/replication/trystero/useP2PReplicatorFeature.d.ts +17 -0
- package/dist/replication/trystero/useP2PReplicatorFeature.js +82 -0
- package/dist/rpc/RpcRoom.d.ts +24 -0
- package/dist/rpc/RpcRoom.js +300 -0
- package/dist/rpc/RpcSession.d.ts +9 -0
- package/dist/rpc/RpcSession.js +32 -0
- package/dist/rpc/chunking.d.ts +11 -0
- package/dist/rpc/chunking.js +58 -0
- package/dist/rpc/errors.d.ts +8 -0
- package/dist/rpc/errors.js +26 -0
- package/dist/rpc/index.d.ts +6 -0
- package/dist/rpc/index.js +12 -0
- package/dist/rpc/pouchdb/RpcPouchDBProxy.d.ts +75 -0
- package/dist/rpc/pouchdb/RpcPouchDBProxy.js +115 -0
- package/dist/rpc/pouchdb/RpcPouchDBServer.d.ts +16 -0
- package/dist/rpc/pouchdb/RpcPouchDBServer.js +55 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.d.ts +24 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.js +208 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.types.d.ts +64 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.types.js +12 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.utils.d.ts +33 -0
- package/dist/rpc/transports/DiagRTCPeerConnections.utils.js +217 -0
- package/dist/rpc/transports/TrysteroTransport.d.ts +216 -0
- package/dist/rpc/transports/TrysteroTransport.js +134 -0
- package/dist/rpc/transports/trysteroUtils.d.ts +3 -0
- package/dist/rpc/transports/trysteroUtils.js +37 -0
- package/dist/rpc/types.d.ts +75 -0
- package/dist/rpc/types.js +6 -0
- package/dist/serviceFeatures/checkRemoteSize.d.ts +28 -0
- package/dist/serviceFeatures/checkRemoteSize.js +178 -0
- package/dist/serviceFeatures/offlineScanner.d.ts +128 -0
- package/dist/serviceFeatures/offlineScanner.js +553 -0
- package/dist/serviceFeatures/prepareDatabaseForUse.d.ts +20 -0
- package/dist/serviceFeatures/prepareDatabaseForUse.js +39 -0
- package/dist/serviceFeatures/remoteConfig.d.ts +46 -0
- package/dist/serviceFeatures/remoteConfig.js +247 -0
- package/dist/serviceFeatures/setupObsidian/qrCode.d.ts +4 -0
- package/dist/serviceFeatures/setupObsidian/qrCode.js +67 -0
- package/dist/serviceFeatures/setupObsidian/setupUri.d.ts +7 -0
- package/dist/serviceFeatures/setupObsidian/setupUri.js +70 -0
- package/dist/serviceFeatures/setupObsidian/types.d.ts +2 -0
- package/dist/serviceFeatures/setupObsidian/types.js +0 -0
- package/dist/serviceFeatures/targetFilter.d.ts +24 -0
- package/dist/serviceFeatures/targetFilter.js +178 -0
- package/dist/serviceModules/FileAccessBase.d.ts +93 -0
- package/dist/serviceModules/FileAccessBase.js +219 -0
- package/dist/serviceModules/Rebuilder.d.ts +92 -0
- package/dist/serviceModules/Rebuilder.js +449 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.d.ts +40 -0
- package/dist/serviceModules/ServiceDatabaseFileAccessBase.js +306 -0
- package/dist/serviceModules/ServiceFileAccessBase.d.ts +64 -0
- package/dist/serviceModules/ServiceFileAccessBase.js +312 -0
- package/dist/serviceModules/ServiceFileHandlerBase.d.ts +52 -0
- package/dist/serviceModules/ServiceFileHandlerBase.js +493 -0
- package/dist/serviceModules/ServiceModuleBase.d.ts +10 -0
- package/dist/serviceModules/ServiceModuleBase.js +13 -0
- package/dist/serviceModules/adapters/IConversionAdapter.d.ts +15 -0
- package/dist/serviceModules/adapters/IConversionAdapter.js +0 -0
- package/dist/serviceModules/adapters/IFileSystemAdapter.d.ts +47 -0
- package/dist/serviceModules/adapters/IFileSystemAdapter.js +0 -0
- package/dist/serviceModules/adapters/IPathAdapter.d.ts +15 -0
- package/dist/serviceModules/adapters/IPathAdapter.js +0 -0
- package/dist/serviceModules/adapters/IStorageAdapter.d.ts +56 -0
- package/dist/serviceModules/adapters/IStorageAdapter.js +0 -0
- package/dist/serviceModules/adapters/ITypeGuardAdapter.d.ts +14 -0
- package/dist/serviceModules/adapters/ITypeGuardAdapter.js +0 -0
- package/dist/serviceModules/adapters/IVaultAdapter.d.ts +51 -0
- package/dist/serviceModules/adapters/IVaultAdapter.js +0 -0
- package/dist/serviceModules/adapters/index.d.ts +6 -0
- package/dist/serviceModules/adapters/index.js +0 -0
- package/dist/services/BrowserServices.d.ts +36 -0
- package/dist/services/BrowserServices.js +123 -0
- package/dist/services/HeadlessServices.d.ts +14 -0
- package/dist/services/HeadlessServices.js +144 -0
- package/dist/services/InjectableServices.d.ts +1 -0
- package/dist/services/InjectableServices.js +4 -0
- package/dist/services/ServiceHub.d.ts +82 -0
- package/dist/services/ServiceHub.js +66 -0
- package/dist/services/base/APIService.d.ts +93 -0
- package/dist/services/base/APIService.js +44 -0
- package/dist/services/base/AppLifecycleService.d.ts +132 -0
- package/dist/services/base/AppLifecycleService.js +123 -0
- package/dist/services/base/ConfigService.d.ts +7 -0
- package/dist/services/base/ConfigService.js +6 -0
- package/dist/services/base/ConflictService.d.ts +54 -0
- package/dist/services/base/ConflictService.js +22 -0
- package/dist/services/base/ControlService.d.ts +54 -0
- package/dist/services/base/ControlService.js +103 -0
- package/dist/services/base/DatabaseEventService.d.ts +38 -0
- package/dist/services/base/DatabaseEventService.js +38 -0
- package/dist/services/base/DatabaseService.d.ts +40 -0
- package/dist/services/base/DatabaseService.js +79 -0
- package/dist/services/base/FileProcessingService.d.ts +25 -0
- package/dist/services/base/FileProcessingService.js +28 -0
- package/dist/services/base/IService.d.ts +284 -0
- package/dist/services/base/IService.js +1 -0
- package/dist/services/base/KeyValueDBService.d.ts +42 -0
- package/dist/services/base/KeyValueDBService.js +133 -0
- package/dist/services/base/MessageTranslator.d.ts +6 -0
- package/dist/services/base/MessageTranslator.js +4 -0
- package/dist/services/base/PathService.d.ts +38 -0
- package/dist/services/base/PathService.js +66 -0
- package/dist/services/base/RemoteService.d.ts +61 -0
- package/dist/services/base/RemoteService.js +212 -0
- package/dist/services/base/ReplicationService.d.ts +92 -0
- package/dist/services/base/ReplicationService.js +261 -0
- package/dist/services/base/ReplicatorService.d.ts +66 -0
- package/dist/services/base/ReplicatorService.js +164 -0
- package/dist/services/base/ServiceBase.d.ts +33 -0
- package/dist/services/base/ServiceBase.js +27 -0
- package/dist/services/base/SettingService.d.ts +112 -0
- package/dist/services/base/SettingService.js +543 -0
- package/dist/services/base/TestService.d.ts +28 -0
- package/dist/services/base/TestService.js +19 -0
- package/dist/services/base/TweakValueService.d.ts +40 -0
- package/dist/services/base/TweakValueService.js +6 -0
- package/dist/services/base/UnresolvedErrorManager.d.ts +15 -0
- package/dist/services/base/UnresolvedErrorManager.js +44 -0
- package/dist/services/base/VaultService.d.ts +69 -0
- package/dist/services/base/VaultService.js +70 -0
- package/dist/services/implements/base/SvelteDialog.d.ts +79 -0
- package/dist/services/implements/base/SvelteDialog.js +134 -0
- package/dist/services/implements/base/UIService.d.ts +24 -0
- package/dist/services/implements/base/UIService.js +37 -0
- package/dist/services/implements/browser/BrowserAPIService.d.ts +54 -0
- package/dist/services/implements/browser/BrowserAPIService.js +298 -0
- package/dist/services/implements/browser/BrowserDatabaseService.d.ts +7 -0
- package/dist/services/implements/browser/BrowserDatabaseService.js +10 -0
- package/dist/services/implements/browser/ConfigServiceBrowserCompat.d.ts +16 -0
- package/dist/services/implements/browser/ConfigServiceBrowserCompat.js +23 -0
- package/dist/services/implements/headless/HeadlessAPIService.d.ts +52 -0
- package/dist/services/implements/headless/HeadlessAPIService.js +127 -0
- package/dist/services/implements/headless/HeadlessDatabaseService.d.ts +7 -0
- package/dist/services/implements/headless/HeadlessDatabaseService.js +10 -0
- package/dist/services/implements/injectable/InjectableAPIService.d.ts +7 -0
- package/dist/services/implements/injectable/InjectableAPIService.js +18 -0
- package/dist/services/implements/injectable/InjectableAppLifecycleService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableAppLifecycleService.js +14 -0
- package/dist/services/implements/injectable/InjectableConflictService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableConflictService.js +14 -0
- package/dist/services/implements/injectable/InjectableDatabaseEventService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableDatabaseEventService.js +7 -0
- package/dist/services/implements/injectable/InjectableFileProcessingService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableFileProcessingService.js +6 -0
- package/dist/services/implements/injectable/InjectablePathService.d.ts +12 -0
- package/dist/services/implements/injectable/InjectablePathService.js +36 -0
- package/dist/services/implements/injectable/InjectableRemoteService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableRemoteService.js +7 -0
- package/dist/services/implements/injectable/InjectableReplicationService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableReplicationService.js +6 -0
- package/dist/services/implements/injectable/InjectableReplicatorService.d.ts +4 -0
- package/dist/services/implements/injectable/InjectableReplicatorService.js +7 -0
- package/dist/services/implements/injectable/InjectableServiceHub.d.ts +72 -0
- package/dist/services/implements/injectable/InjectableServiceHub.js +125 -0
- package/dist/services/implements/injectable/InjectableServices.d.ts +36 -0
- package/dist/services/implements/injectable/InjectableServices.js +1 -0
- package/dist/services/implements/injectable/InjectableSettingService.d.ts +11 -0
- package/dist/services/implements/injectable/InjectableSettingService.js +33 -0
- package/dist/services/implements/injectable/InjectableTestService.d.ts +5 -0
- package/dist/services/implements/injectable/InjectableTestService.js +8 -0
- package/dist/services/implements/injectable/InjectableTweakValueService.d.ts +15 -0
- package/dist/services/implements/injectable/InjectableTweakValueService.js +12 -0
- package/dist/services/implements/injectable/InjectableVaultService.d.ts +9 -0
- package/dist/services/implements/injectable/InjectableVaultService.js +20 -0
- package/dist/services/lib/HandlerUtils.d.ts +374 -0
- package/dist/services/lib/HandlerUtils.js +412 -0
- package/dist/services/lib/logUtils.d.ts +13 -0
- package/dist/services/lib/logUtils.js +28 -0
- package/dist/services/lib/remoteActivity.d.ts +13 -0
- package/dist/services/lib/remoteActivity.js +11 -0
- package/dist/string_and_binary/chunks.d.ts +10 -0
- package/dist/string_and_binary/chunks.js +561 -0
- package/dist/string_and_binary/convert.d.ts +8 -0
- package/dist/string_and_binary/convert.js +46 -0
- package/dist/string_and_binary/hash.d.ts +2 -0
- package/dist/string_and_binary/hash.js +1 -0
- package/dist/string_and_binary/path.d.ts +35 -0
- package/dist/string_and_binary/path.js +240 -0
- package/dist/worker/bg.common.d.ts +2 -0
- package/dist/worker/bg.common.js +6 -0
- package/dist/worker/bg.worker.d.ts +1 -0
- package/dist/worker/bg.worker.encryption.d.ts +7 -0
- package/dist/worker/bg.worker.encryption.js +30 -0
- package/dist/worker/bg.worker.js +14 -0
- package/dist/worker/bg.worker.splitting.d.ts +6 -0
- package/dist/worker/bg.worker.splitting.js +36 -0
- package/dist/worker/bgWorker.d.ts +25 -0
- package/dist/worker/bgWorker.direct.d.ts +40 -0
- package/dist/worker/bgWorker.direct.js +65 -0
- package/dist/worker/bgWorker.encryption.d.ts +22 -0
- package/dist/worker/bgWorker.encryption.js +40 -0
- package/dist/worker/bgWorker.js +348 -0
- package/dist/worker/bgWorker.splitting.d.ts +27 -0
- package/dist/worker/bgWorker.splitting.js +123 -0
- package/dist/worker/universalTypes.d.ts +63 -0
- package/dist/worker/universalTypes.js +4 -0
- package/docs/development.md +51 -0
- package/docs/platform-storage.md +60 -0
- package/docs/releasing.md +69 -0
- package/package.json +693 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export declare const RPC_VERSION_MAJOR = 1;
|
|
2
|
+
export declare const RPC_VERSION_MINOR = 0;
|
|
3
|
+
export type JsonLike = null | boolean | number | string | JsonLike[] | {
|
|
4
|
+
[key: string]: JsonLike;
|
|
5
|
+
};
|
|
6
|
+
export type RpcErrorCode = "TIMEOUT" | "NOT_CONNECTED" | "REMOTE_ERROR" | "CANCELLED" | "PROTOCOL_ERROR";
|
|
7
|
+
export type RpcErrorShape = {
|
|
8
|
+
code: RpcErrorCode;
|
|
9
|
+
message: string;
|
|
10
|
+
details?: JsonLike;
|
|
11
|
+
};
|
|
12
|
+
export type RpcRequestEnvelope = {
|
|
13
|
+
kind: "request";
|
|
14
|
+
requestId: string;
|
|
15
|
+
method: string;
|
|
16
|
+
args: JsonLike[];
|
|
17
|
+
};
|
|
18
|
+
export type RpcResponseEnvelope = {
|
|
19
|
+
kind: "response";
|
|
20
|
+
requestId: string;
|
|
21
|
+
ok: true;
|
|
22
|
+
data: JsonLike;
|
|
23
|
+
};
|
|
24
|
+
export type RpcResponseErrorEnvelope = {
|
|
25
|
+
kind: "response";
|
|
26
|
+
requestId: string;
|
|
27
|
+
ok: false;
|
|
28
|
+
error: RpcErrorShape;
|
|
29
|
+
};
|
|
30
|
+
export type RpcCancelEnvelope = {
|
|
31
|
+
kind: "cancel";
|
|
32
|
+
requestId: string;
|
|
33
|
+
};
|
|
34
|
+
export type RpcHandshakeEnvelope = {
|
|
35
|
+
kind: "handshake";
|
|
36
|
+
versionMajor: number;
|
|
37
|
+
versionMinor: number;
|
|
38
|
+
};
|
|
39
|
+
export type RpcEnvelope = RpcRequestEnvelope | RpcResponseEnvelope | RpcResponseErrorEnvelope | RpcCancelEnvelope | RpcHandshakeEnvelope;
|
|
40
|
+
export type RpcWireMessageRaw = {
|
|
41
|
+
wire: "raw";
|
|
42
|
+
payload: string;
|
|
43
|
+
};
|
|
44
|
+
export type RpcWireMessageChunk = {
|
|
45
|
+
wire: "chunk";
|
|
46
|
+
streamId: string;
|
|
47
|
+
index: number;
|
|
48
|
+
total: number;
|
|
49
|
+
payload: string;
|
|
50
|
+
};
|
|
51
|
+
export type RpcWireMessageChunkAck = {
|
|
52
|
+
wire: "chunk-ack";
|
|
53
|
+
streamId: string;
|
|
54
|
+
missing: number[];
|
|
55
|
+
};
|
|
56
|
+
export type RpcWireMessage = RpcWireMessageRaw | RpcWireMessageChunk | RpcWireMessageChunkAck;
|
|
57
|
+
export type TransportOnMessage = (message: RpcWireMessage, peerId: string) => void;
|
|
58
|
+
export type TransportOnPeer = (peerId: string) => void;
|
|
59
|
+
export interface TransportAdapter {
|
|
60
|
+
send(message: RpcWireMessage, peerId: string): void | Promise<void>;
|
|
61
|
+
onMessage(handler: TransportOnMessage): () => void;
|
|
62
|
+
onPeerJoin?(handler: TransportOnPeer): () => void;
|
|
63
|
+
onPeerLeave?(handler: TransportOnPeer): () => void;
|
|
64
|
+
}
|
|
65
|
+
export type RpcRoomOptions = {
|
|
66
|
+
transport: TransportAdapter;
|
|
67
|
+
maxWirePayloadBytes?: number;
|
|
68
|
+
chunkMissingRetryMs?: number;
|
|
69
|
+
canAcceptRequest?: (peerId: string, method: string) => boolean | Promise<boolean>;
|
|
70
|
+
onProtocolWarning?: (message: string, peerId?: string) => void;
|
|
71
|
+
};
|
|
72
|
+
export type RpcMethodHandler<T extends JsonLike[], U> = (peerId: string, ...args: T) => U | Promise<U>;
|
|
73
|
+
export type RpcRegisterOptions = {
|
|
74
|
+
serial?: boolean;
|
|
75
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createInstanceLogFunction, type LogFunction } from "../services/lib/logUtils.js";
|
|
2
|
+
import type { NecessaryServices } from "../interfaces/ServiceModule.js";
|
|
3
|
+
/**
|
|
4
|
+
* Notify when checking remote storage size is not configured.
|
|
5
|
+
* @returns true if the check is passed or user has configured the notification, false to block subsequent processes. (always true).
|
|
6
|
+
*/
|
|
7
|
+
export declare function onNotifyRemoteSizeNotConfiguredFactory(host: NecessaryServices<"appLifecycle" | "API" | "setting", never>, log: ReturnType<typeof createInstanceLogFunction>): () => Promise<boolean>;
|
|
8
|
+
/**
|
|
9
|
+
* Notify when the remote storage size exceed the threshold.
|
|
10
|
+
* @returns true if the check is passed or user has chosen to ignore the warning, false to block subsequent processes.
|
|
11
|
+
* @param host
|
|
12
|
+
* @param log
|
|
13
|
+
* @returns
|
|
14
|
+
*/
|
|
15
|
+
export declare function onNotifyRemoteSizeExceedFactory(host: NecessaryServices<"API" | "setting" | "replicator", "rebuilder">, log: ReturnType<typeof createInstanceLogFunction>): () => Promise<boolean>;
|
|
16
|
+
/**
|
|
17
|
+
* Scan the remote storage size and notify if it is not configured or exceed the threshold.
|
|
18
|
+
* @param host The necessary services required for the operation.
|
|
19
|
+
* @param log The logging function to use for logging messages.
|
|
20
|
+
* @param resetThreshold Whether to reset the notification threshold before scanning. This is useful when you want to force the notification to show up again.
|
|
21
|
+
* @returns A promise that resolves to true if all checks pass or user has configured the notification.
|
|
22
|
+
*/
|
|
23
|
+
export declare function scanAllStat(host: NecessaryServices<"API" | "setting" | "replicator" | "appLifecycle", "rebuilder">, log: LogFunction, resetThreshold?: boolean): Promise<boolean>;
|
|
24
|
+
/**
|
|
25
|
+
* Associate the remote storage size check feature with the app lifecycle events.
|
|
26
|
+
* @param host
|
|
27
|
+
*/
|
|
28
|
+
export declare function useCheckRemoteSize(host: NecessaryServices<"API" | "setting" | "replicator" | "appLifecycle", "rebuilder">): void;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { sizeToHumanReadable } from "octagonal-wheels/number";
|
|
2
|
+
import { LOG_LEVEL_INFO, LOG_LEVEL_NOTICE, LOG_LEVEL_VERBOSE } from "../common/types.js";
|
|
3
|
+
import { createInstanceLogFunction } from "../services/lib/logUtils.js";
|
|
4
|
+
import { EVENT_REQUEST_CHECK_REMOTE_SIZE } from "../events/coreEvents.js";
|
|
5
|
+
function onNotifyRemoteSizeNotConfiguredFactory(host, log) {
|
|
6
|
+
return async () => {
|
|
7
|
+
const translate = host.services.context.translate;
|
|
8
|
+
log(translate("moduleCheckRemoteSize.logCheckingStorageSizes"), LOG_LEVEL_VERBOSE);
|
|
9
|
+
const settings = host.services.setting.currentSettings();
|
|
10
|
+
if (settings.notifyThresholdOfRemoteStorageSize >= 0) {
|
|
11
|
+
return true;
|
|
12
|
+
}
|
|
13
|
+
const message = translate("moduleCheckRemoteSize.msgSetDBCapacity");
|
|
14
|
+
const ANSWER_0 = translate("moduleCheckRemoteSize.optionNoWarn");
|
|
15
|
+
const ANSWER_800 = translate("moduleCheckRemoteSize.option800MB");
|
|
16
|
+
const ANSWER_2000 = translate("moduleCheckRemoteSize.option2GB");
|
|
17
|
+
const ASK_ME_NEXT_TIME = translate("moduleCheckRemoteSize.optionAskMeLater");
|
|
18
|
+
const ret = await host.services.API.confirm.askSelectStringDialogue(
|
|
19
|
+
message,
|
|
20
|
+
[ANSWER_0, ANSWER_800, ANSWER_2000, ASK_ME_NEXT_TIME],
|
|
21
|
+
{
|
|
22
|
+
defaultAction: ASK_ME_NEXT_TIME,
|
|
23
|
+
title: translate("moduleCheckRemoteSize.titleDatabaseSizeNotify"),
|
|
24
|
+
timeout: 40
|
|
25
|
+
}
|
|
26
|
+
);
|
|
27
|
+
if (ret == ANSWER_0) {
|
|
28
|
+
await host.services.setting.applyPartial(
|
|
29
|
+
{
|
|
30
|
+
notifyThresholdOfRemoteStorageSize: 0
|
|
31
|
+
},
|
|
32
|
+
true
|
|
33
|
+
);
|
|
34
|
+
} else if (ret == ANSWER_800) {
|
|
35
|
+
await host.services.setting.applyPartial(
|
|
36
|
+
{
|
|
37
|
+
notifyThresholdOfRemoteStorageSize: 800
|
|
38
|
+
},
|
|
39
|
+
true
|
|
40
|
+
);
|
|
41
|
+
} else if (ret == ANSWER_2000) {
|
|
42
|
+
await host.services.setting.applyPartial(
|
|
43
|
+
{
|
|
44
|
+
notifyThresholdOfRemoteStorageSize: 2e3
|
|
45
|
+
},
|
|
46
|
+
true
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return true;
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function onNotifyRemoteSizeExceedFactory(host, log) {
|
|
53
|
+
return async () => {
|
|
54
|
+
const translate = host.services.context.translate;
|
|
55
|
+
const settings = host.services.setting.currentSettings();
|
|
56
|
+
if (settings.notifyThresholdOfRemoteStorageSize <= 0) {
|
|
57
|
+
log("User has chosen to not receive remote storage size exceed notification.", LOG_LEVEL_INFO);
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
if (host.services.API.isOnline === false) {
|
|
61
|
+
log("Network is offline, skipping remote size exceed check.", LOG_LEVEL_INFO);
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
const replicator = host.services.replicator.getActiveReplicator();
|
|
65
|
+
const remoteStat = await replicator?.getRemoteStatus(host.services.setting.currentSettings());
|
|
66
|
+
if (!remoteStat) {
|
|
67
|
+
log("Failed to get remote status, skipping remote size exceed check.", LOG_LEVEL_INFO);
|
|
68
|
+
return true;
|
|
69
|
+
}
|
|
70
|
+
const estimatedSize = remoteStat.estimatedSize;
|
|
71
|
+
if (estimatedSize) {
|
|
72
|
+
const maxSize = settings.notifyThresholdOfRemoteStorageSize * 1024 * 1024;
|
|
73
|
+
if (estimatedSize <= maxSize) {
|
|
74
|
+
log(
|
|
75
|
+
translate("moduleCheckRemoteSize.logCurrentStorageSize", {
|
|
76
|
+
measuredSize: sizeToHumanReadable(estimatedSize)
|
|
77
|
+
}),
|
|
78
|
+
LOG_LEVEL_INFO
|
|
79
|
+
);
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
const message = translate("moduleCheckRemoteSize.msgDatabaseGrowing", {
|
|
83
|
+
estimatedSize: sizeToHumanReadable(estimatedSize),
|
|
84
|
+
maxSize: sizeToHumanReadable(maxSize)
|
|
85
|
+
});
|
|
86
|
+
const newMax = ~~(estimatedSize / 1024 / 1024) + 100;
|
|
87
|
+
const ANSWER_ENLARGE_LIMIT = translate("moduleCheckRemoteSize.optionIncreaseLimit", {
|
|
88
|
+
newMax: newMax.toString()
|
|
89
|
+
});
|
|
90
|
+
const ANSWER_REBUILD = translate("moduleCheckRemoteSize.optionRebuildAll");
|
|
91
|
+
const ANSWER_IGNORE = translate("moduleCheckRemoteSize.optionDismiss");
|
|
92
|
+
const ret = await host.services.API.confirm.askSelectStringDialogue(
|
|
93
|
+
message,
|
|
94
|
+
[ANSWER_ENLARGE_LIMIT, ANSWER_REBUILD, ANSWER_IGNORE],
|
|
95
|
+
{
|
|
96
|
+
defaultAction: ANSWER_IGNORE,
|
|
97
|
+
title: translate("moduleCheckRemoteSize.titleDatabaseSizeLimitExceeded"),
|
|
98
|
+
timeout: 60
|
|
99
|
+
}
|
|
100
|
+
);
|
|
101
|
+
if (ret == ANSWER_REBUILD) {
|
|
102
|
+
const ret2 = await host.services.API.confirm.askYesNoDialog(
|
|
103
|
+
translate("moduleCheckRemoteSize.msgConfirmRebuild"),
|
|
104
|
+
{ defaultOption: "No" }
|
|
105
|
+
);
|
|
106
|
+
if (ret2 == "yes") {
|
|
107
|
+
await host.services.setting.applyPartial(
|
|
108
|
+
{
|
|
109
|
+
notifyThresholdOfRemoteStorageSize: -1
|
|
110
|
+
},
|
|
111
|
+
true
|
|
112
|
+
);
|
|
113
|
+
await host.serviceModules.rebuilder.scheduleRebuild();
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
return true;
|
|
117
|
+
}
|
|
118
|
+
if (ret == ANSWER_ENLARGE_LIMIT) {
|
|
119
|
+
const newThreshold = ~~(estimatedSize / 1024 / 1024) + 100;
|
|
120
|
+
log(
|
|
121
|
+
translate("moduleCheckRemoteSize.logThresholdEnlarged", {
|
|
122
|
+
size: newThreshold.toString()
|
|
123
|
+
}),
|
|
124
|
+
LOG_LEVEL_NOTICE
|
|
125
|
+
);
|
|
126
|
+
await host.services.setting.applyPartial(
|
|
127
|
+
{
|
|
128
|
+
notifyThresholdOfRemoteStorageSize: newThreshold
|
|
129
|
+
},
|
|
130
|
+
true
|
|
131
|
+
);
|
|
132
|
+
return true;
|
|
133
|
+
}
|
|
134
|
+
log(
|
|
135
|
+
translate("moduleCheckRemoteSize.logExceededWarning", {
|
|
136
|
+
measuredSize: sizeToHumanReadable(estimatedSize),
|
|
137
|
+
notifySize: sizeToHumanReadable(settings.notifyThresholdOfRemoteStorageSize * 1024 * 1024)
|
|
138
|
+
}),
|
|
139
|
+
LOG_LEVEL_INFO
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
return true;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
async function scanAllStat(host, log, resetThreshold = false) {
|
|
146
|
+
if (resetThreshold) {
|
|
147
|
+
await host.services.setting.applyPartial(
|
|
148
|
+
{
|
|
149
|
+
notifyThresholdOfRemoteStorageSize: -1
|
|
150
|
+
},
|
|
151
|
+
true
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
const onNotifyNotConfigured = onNotifyRemoteSizeNotConfiguredFactory(host, log);
|
|
155
|
+
const onNotifyExceed = onNotifyRemoteSizeExceedFactory(host, log);
|
|
156
|
+
return await onNotifyNotConfigured() && await onNotifyExceed();
|
|
157
|
+
}
|
|
158
|
+
function useCheckRemoteSize(host) {
|
|
159
|
+
const log = createInstanceLogFunction("SFCheckRemoteSize", host.services.API);
|
|
160
|
+
host.services.appLifecycle.onScanningStartupIssues.addHandler(() => scanAllStat(host, log, false));
|
|
161
|
+
host.services.appLifecycle.onInitialise.addHandler(() => {
|
|
162
|
+
host.services.API.addCommand({
|
|
163
|
+
id: "livesync-reset-remote-size-threshold-and-check",
|
|
164
|
+
name: "Reset notification threshold and check the remote database usage",
|
|
165
|
+
callback: async () => {
|
|
166
|
+
await scanAllStat(host, log, true);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
host.services.context.events.onEvent(EVENT_REQUEST_CHECK_REMOTE_SIZE, () => scanAllStat(host, log, true));
|
|
170
|
+
return Promise.resolve(true);
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
export {
|
|
174
|
+
onNotifyRemoteSizeExceedFactory,
|
|
175
|
+
onNotifyRemoteSizeNotConfiguredFactory,
|
|
176
|
+
scanAllStat,
|
|
177
|
+
useCheckRemoteSize
|
|
178
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { type FilePathWithPrefix, type FilePathWithPrefixLC, type MetaEntry, type UXFileInfoStub, type ObsidianLiveSyncSettings, type LOG_LEVEL } from "../common/types.js";
|
|
2
|
+
import { type LogFunction } from "../services/lib/logUtils.js";
|
|
3
|
+
import type { NecessaryServices } from "../interfaces/ServiceModule.js";
|
|
4
|
+
import { UnresolvedErrorManager } from "../services/base/UnresolvedErrorManager.js";
|
|
5
|
+
/**
|
|
6
|
+
* Collect deleted files that have expired according to retention policy.
|
|
7
|
+
* @param host Services container
|
|
8
|
+
* @param log Logging function
|
|
9
|
+
* @returns Array of expired deletion history
|
|
10
|
+
*/
|
|
11
|
+
export declare function collectDeletedFiles(host: NecessaryServices<"setting" | "database", never>, log: LogFunction): Promise<void>;
|
|
12
|
+
/**
|
|
13
|
+
* Get the file path from a meta entry.
|
|
14
|
+
* This is a helper function to extract path from various document types.
|
|
15
|
+
* @param doc Meta entry document
|
|
16
|
+
* @returns Path string
|
|
17
|
+
*/
|
|
18
|
+
export declare function getPathFromEntry(host: NecessaryServices<"path", never>, doc: MetaEntry): FilePathWithPrefix;
|
|
19
|
+
/**
|
|
20
|
+
* Synchronise a single file between database and storage based on freshness comparison.
|
|
21
|
+
* @param host Services container
|
|
22
|
+
* @param log Logging function
|
|
23
|
+
* @param file Storage file information
|
|
24
|
+
* @param doc Database entry
|
|
25
|
+
*/
|
|
26
|
+
export declare function syncFileBetweenDBandStorage(host: NecessaryServices<"setting" | "vault" | "path", "storageAccess" | "fileHandler">, log: LogFunction, file: UXFileInfoStub, doc: MetaEntry): Promise<void>;
|
|
27
|
+
export declare function canProceedScan(host: NecessaryServices<"keyValueDB" | "setting", never>, errorManager: UnresolvedErrorManager, log: LogFunction, showingNotice?: boolean, ignoreSuspending?: boolean): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Convert file path to lower case if the settings indicate that filename case should be handled insensitively.
|
|
30
|
+
* @param settings
|
|
31
|
+
* @param path
|
|
32
|
+
* @returns
|
|
33
|
+
*/
|
|
34
|
+
export declare function convertCase<T extends FilePathWithPrefix>(settings: ObsidianLiveSyncSettings, path: T): FilePathWithPrefixLC;
|
|
35
|
+
export declare function collectFilesOnStorage(host: NecessaryServices<"vault", "storageAccess">, settings: ObsidianLiveSyncSettings, log: LogFunction): Promise<{
|
|
36
|
+
storageFileNameMap: {
|
|
37
|
+
[k: string]: UXFileInfoStub;
|
|
38
|
+
};
|
|
39
|
+
storageFileNames: FilePathWithPrefix[];
|
|
40
|
+
storageFileNameCI2CS: Record<FilePathWithPrefixLC, FilePathWithPrefix>;
|
|
41
|
+
}>;
|
|
42
|
+
export declare function collectDatabaseFiles(host: NecessaryServices<"database" | "vault" | "path", never>, settings: ObsidianLiveSyncSettings, log: LogFunction, showingNotice: boolean): Promise<{
|
|
43
|
+
databaseFileNameMap: {
|
|
44
|
+
[k: string]: MetaEntry;
|
|
45
|
+
};
|
|
46
|
+
databaseFileNames: FilePathWithPrefix[];
|
|
47
|
+
databaseFileNameCI2CS: Record<FilePathWithPrefix, FilePathWithPrefixLC>;
|
|
48
|
+
}>;
|
|
49
|
+
export declare function updateToDatabase(host: NecessaryServices<"vault", "fileHandler">, log: LogFunction, logLevel: LOG_LEVEL, file: UXFileInfoStub): Promise<void>;
|
|
50
|
+
export declare function updateToStorage(host: NecessaryServices<"vault" | "path", "fileHandler">, log: LogFunction, logLevel: LOG_LEVEL, w: MetaEntry): Promise<void>;
|
|
51
|
+
export declare function syncStorageAndDatabase(host: NecessaryServices<"setting" | "vault" | "path", "storageAccess" | "fileHandler">, log: LogFunction, file: UXFileInfoStub, logLevel: LOG_LEVEL, doc: MetaEntry): Promise<void>;
|
|
52
|
+
export declare const FullScanModes: {
|
|
53
|
+
readonly DB_APPLY: "db-apply";
|
|
54
|
+
readonly NEWER_WINS: "newer-wins";
|
|
55
|
+
};
|
|
56
|
+
export declare const ExtraOnRemote: {
|
|
57
|
+
/**
|
|
58
|
+
* Delete database entries if they are missing on storage.
|
|
59
|
+
*/
|
|
60
|
+
readonly DELETE_LOCAL_MISSING: "delete-local-missing";
|
|
61
|
+
};
|
|
62
|
+
export declare const ExtraOnLocal: {
|
|
63
|
+
/**
|
|
64
|
+
* Delete local files if they were deleted on database.
|
|
65
|
+
*/
|
|
66
|
+
readonly DELETE_DB_DELETED: "delete-db-deleted";
|
|
67
|
+
/**
|
|
68
|
+
* Delete local files if they are missing on database or were deleted on database.
|
|
69
|
+
*/
|
|
70
|
+
readonly DELETE_DB_MISSING: "delete-db-missing";
|
|
71
|
+
/**
|
|
72
|
+
* Merge local files to database
|
|
73
|
+
*/
|
|
74
|
+
readonly APPEND_STORAGE_ONLY: "append-storage-only";
|
|
75
|
+
};
|
|
76
|
+
export interface FullScanOptions {
|
|
77
|
+
mode: FullScanMode;
|
|
78
|
+
extraOnLocal?: (typeof ExtraOnLocal)[keyof typeof ExtraOnLocal];
|
|
79
|
+
extraOnRemote?: (typeof ExtraOnRemote)[keyof typeof ExtraOnRemote];
|
|
80
|
+
omitEvents?: boolean;
|
|
81
|
+
showingNotice?: boolean;
|
|
82
|
+
ignoreSuspending?: boolean;
|
|
83
|
+
}
|
|
84
|
+
export type FullScanMode = (typeof FullScanModes)[keyof typeof FullScanModes];
|
|
85
|
+
type FilePair = {
|
|
86
|
+
file: UXFileInfoStub;
|
|
87
|
+
doc: MetaEntry;
|
|
88
|
+
} | {
|
|
89
|
+
file: undefined;
|
|
90
|
+
doc: MetaEntry;
|
|
91
|
+
} | {
|
|
92
|
+
file: UXFileInfoStub;
|
|
93
|
+
doc: undefined;
|
|
94
|
+
};
|
|
95
|
+
type FilePairState = "storage-only" | "db-only" | "db-only-deleted" | "both" | "both-db-deleted";
|
|
96
|
+
type FilePairAction = "update-db" | "update-storage" | "sync-newer" | "delete-local" | "delete-db" | "skip";
|
|
97
|
+
export declare function getFilePairState(pair: FilePair): FilePairState;
|
|
98
|
+
/**
|
|
99
|
+
* Determine the action to be taken for a file pair based on its state and the selected scan options.
|
|
100
|
+
*/
|
|
101
|
+
export declare function resolveFilePairAction(state: FilePairState, options: FullScanOptions): FilePairAction;
|
|
102
|
+
/**
|
|
103
|
+
* Synchronise all files between database and storage based on the selected mode and options.
|
|
104
|
+
* @param host Core
|
|
105
|
+
* @param log Logging function
|
|
106
|
+
* @param errorManager Error manager
|
|
107
|
+
* @param options Full scan options
|
|
108
|
+
*/
|
|
109
|
+
export declare function synchroniseAllFilesBetweenDBandStorage(host: NecessaryServices<"setting" | "vault" | "path" | "fileProcessing" | "database" | "keyValueDB", "storageAccess" | "fileHandler">, log: LogFunction, errorManager: UnresolvedErrorManager, options: FullScanOptions): Promise<boolean>;
|
|
110
|
+
export declare function normaliseFullScanOptions(showingNoticeOrOptions: Partial<FullScanOptions> | boolean | undefined, ignoreSuspending?: boolean): FullScanOptions;
|
|
111
|
+
/**
|
|
112
|
+
* Perform a full scan and synchronisation between database and storage.
|
|
113
|
+
* @param host Services container
|
|
114
|
+
* @param log Logging function
|
|
115
|
+
* @param errorManager Error manager
|
|
116
|
+
* @param showingNotice Whether to show notices during scanning
|
|
117
|
+
* @param ignoreSuspending Whether to ignore suspension settings
|
|
118
|
+
* @returns True if scan completed successfully
|
|
119
|
+
*/
|
|
120
|
+
export declare function performFullScan(host: NecessaryServices<"setting" | "vault" | "path" | "fileProcessing" | "database" | "keyValueDB", "storageAccess" | "fileHandler">, log: LogFunction, errorManager: UnresolvedErrorManager, options?: Partial<FullScanOptions>): Promise<boolean>;
|
|
121
|
+
export declare function performFullScan(host: NecessaryServices<"setting" | "vault" | "path" | "fileProcessing" | "database" | "keyValueDB", "storageAccess" | "fileHandler">, log: LogFunction, errorManager: UnresolvedErrorManager, showingNotice?: boolean, ignoreSuspending?: boolean): Promise<boolean>;
|
|
122
|
+
/**
|
|
123
|
+
* Associate the initialiser file feature with the app lifecycle events.
|
|
124
|
+
* This function binds initialization handlers to the appropriate lifecycle events.
|
|
125
|
+
* @param host Services container with required dependencies
|
|
126
|
+
*/
|
|
127
|
+
export declare function useOfflineScanner(host: NecessaryServices<"API" | "appLifecycle" | "setting" | "vault" | "path" | "database" | "databaseEvents" | "fileProcessing" | "keyValueDB" | "replicator", "storageAccess" | "fileHandler">): void;
|
|
128
|
+
export {};
|