@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,93 @@
|
|
|
1
|
+
import type { FilePath, UXDataWriteOptions, UXFileInfoStub, UXFolderInfo } from "../common/types.js";
|
|
2
|
+
import type { IStorageAccessManager } from "../interfaces/StorageAccess.js";
|
|
3
|
+
import type { IAPIService, IPathService, ISettingService, IVaultService } from "../services/base/IService.js";
|
|
4
|
+
import { createInstanceLogFunction } from "../services/lib/logUtils.js";
|
|
5
|
+
import type { FileWithFileStat } from "../common/models/fileaccess.type.js";
|
|
6
|
+
import type { IFileSystemAdapter } from "./adapters/index.js";
|
|
7
|
+
export declare function toArrayBuffer(arr: Uint8Array<ArrayBuffer> | ArrayBuffer | DataView<ArrayBuffer>): ArrayBuffer;
|
|
8
|
+
export interface FileAccessBaseDependencies {
|
|
9
|
+
vaultService: IVaultService;
|
|
10
|
+
storageAccessManager: IStorageAccessManager;
|
|
11
|
+
settingService: ISettingService;
|
|
12
|
+
pathService: IPathService;
|
|
13
|
+
APIService: IAPIService;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Type helper to extract the abstract file type from a file system adapter
|
|
17
|
+
*/
|
|
18
|
+
export type ExtractAbstractFile<T> = T extends IFileSystemAdapter<infer A, any, any, any> ? A : never;
|
|
19
|
+
/**
|
|
20
|
+
* Type helper to extract the file type from a file system adapter
|
|
21
|
+
*/
|
|
22
|
+
export type ExtractFile<T> = T extends IFileSystemAdapter<any, infer F, any, any> ? F : never;
|
|
23
|
+
/**
|
|
24
|
+
* Type helper to extract the folder type from a file system adapter
|
|
25
|
+
*/
|
|
26
|
+
export type ExtractFolder<T> = T extends IFileSystemAdapter<any, any, infer D, any> ? D : never;
|
|
27
|
+
/**
|
|
28
|
+
* Type helper to extract the stat type from a file system adapter
|
|
29
|
+
*/
|
|
30
|
+
export type ExtractStat<T> = T extends IFileSystemAdapter<any, any, any, infer S> ? S : never;
|
|
31
|
+
/**
|
|
32
|
+
* Base class for file access operations
|
|
33
|
+
* Uses adapter pattern for platform-specific implementations
|
|
34
|
+
*
|
|
35
|
+
* @template TAdapter - The file system adapter type, which determines all native file types
|
|
36
|
+
*/
|
|
37
|
+
export declare class FileAccessBase<TAdapter extends IFileSystemAdapter<any, any, any, any>> {
|
|
38
|
+
protected storageAccessManager: IStorageAccessManager;
|
|
39
|
+
protected vaultService: IVaultService;
|
|
40
|
+
protected settingService: ISettingService;
|
|
41
|
+
protected APIService: IAPIService;
|
|
42
|
+
protected path: IPathService;
|
|
43
|
+
protected adapter: TAdapter;
|
|
44
|
+
_log: ReturnType<typeof createInstanceLogFunction>;
|
|
45
|
+
constructor(adapter: TAdapter, dependencies: FileAccessBaseDependencies);
|
|
46
|
+
isFile(file: UXFileInfoStub | ExtractAbstractFile<TAdapter> | FilePath | ExtractFolder<TAdapter> | ExtractFile<TAdapter> | null): file is ExtractFile<TAdapter>;
|
|
47
|
+
isFolder(item: UXFileInfoStub | ExtractAbstractFile<TAdapter> | FilePath | ExtractFolder<TAdapter> | ExtractFile<TAdapter> | null): item is ExtractFolder<TAdapter>;
|
|
48
|
+
getPath(file: ExtractAbstractFile<TAdapter> | string): FilePath;
|
|
49
|
+
nativeFileToUXFileInfoStub(file: ExtractFile<TAdapter>): UXFileInfoStub;
|
|
50
|
+
nativeFolderToUXFolder(file: ExtractFolder<TAdapter>): UXFolderInfo;
|
|
51
|
+
normalisePath(path: string): string;
|
|
52
|
+
protected _writeOp<T extends ExtractAbstractFile<TAdapter> | string, U>(file: T, callback: (path: FilePath, file: T) => Promise<U>): Promise<U>;
|
|
53
|
+
protected _readOp<T extends ExtractAbstractFile<TAdapter> | string, U>(file: T, callback: (path: FilePath, file: T) => Promise<U>): Promise<U>;
|
|
54
|
+
tryAdapterStat(file: ExtractFile<TAdapter> | string): Promise<any>;
|
|
55
|
+
adapterStat(file: ExtractFile<TAdapter> | string): Promise<ExtractStat<TAdapter> | null>;
|
|
56
|
+
adapterExists(file: ExtractFile<TAdapter> | string): Promise<boolean>;
|
|
57
|
+
adapterRemove(file: ExtractFile<TAdapter> | string): Promise<void>;
|
|
58
|
+
adapterRead(file: ExtractFile<TAdapter> | string): Promise<string>;
|
|
59
|
+
adapterReadBinary(file: ExtractFile<TAdapter> | string): Promise<ArrayBuffer>;
|
|
60
|
+
adapterReadAuto(file: ExtractFile<TAdapter> | string): Promise<string | ArrayBuffer>;
|
|
61
|
+
adapterWrite(file: ExtractFile<TAdapter> | string, data: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options?: UXDataWriteOptions): Promise<void>;
|
|
62
|
+
adapterList(basePath: string): Promise<{
|
|
63
|
+
files: string[];
|
|
64
|
+
folders: string[];
|
|
65
|
+
}>;
|
|
66
|
+
vaultCacheRead(file: ExtractFile<TAdapter>): Promise<string>;
|
|
67
|
+
vaultRead(file: ExtractFile<TAdapter>): Promise<string>;
|
|
68
|
+
vaultReadBinary(file: ExtractFile<TAdapter>): Promise<ArrayBuffer>;
|
|
69
|
+
vaultReadAuto(file: ExtractFile<TAdapter>): Promise<string | ArrayBuffer>;
|
|
70
|
+
vaultModify(file: ExtractFile<TAdapter>, data: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options?: UXDataWriteOptions): Promise<boolean>;
|
|
71
|
+
vaultCreate(path: string, data: string | ArrayBuffer | Uint8Array<ArrayBuffer>, options?: UXDataWriteOptions): Promise<ExtractFile<TAdapter>>;
|
|
72
|
+
vaultRename(file: ExtractFile<TAdapter>, newPath: string): Promise<ExtractFile<TAdapter>>;
|
|
73
|
+
trigger(name: string, ...data: unknown[]): void;
|
|
74
|
+
reconcileInternalFile(path: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Append data to a file using the adapter's append method. This is useful for large files that cannot be read into memory.
|
|
77
|
+
* Please note that this method does not check concurrent modifications.
|
|
78
|
+
* @param normalizedPath
|
|
79
|
+
* @param data
|
|
80
|
+
* @param options
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
adapterAppend(normalizedPath: string, data: string, options?: UXDataWriteOptions): Promise<void>;
|
|
84
|
+
delete(file: ExtractAbstractFile<TAdapter> | ExtractFolder<TAdapter>, force?: boolean): Promise<void>;
|
|
85
|
+
trash(file: ExtractAbstractFile<TAdapter> | ExtractFolder<TAdapter>, force?: boolean): Promise<void>;
|
|
86
|
+
protected isStorageInsensitive(): boolean;
|
|
87
|
+
getAbstractFileByPath(path: FilePath | string): Promise<ExtractAbstractFile<TAdapter> | null>;
|
|
88
|
+
getFiles(): Promise<ExtractFile<TAdapter>[]>;
|
|
89
|
+
ensureDirectory(fullPath: string): Promise<void>;
|
|
90
|
+
touch(file: ExtractFile<TAdapter> | FilePath): Promise<void>;
|
|
91
|
+
recentlyTouched(file: ExtractFile<TAdapter> | UXFileInfoStub | FileWithFileStat): boolean;
|
|
92
|
+
clearTouched(): void;
|
|
93
|
+
}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { isPlainText } from "../string_and_binary/path.js";
|
|
2
|
+
import { createBinaryBlob, isDocContentSame } from "../common/utils.js";
|
|
3
|
+
import { createInstanceLogFunction } from "../services/lib/logUtils.js";
|
|
4
|
+
function toArrayBuffer(arr) {
|
|
5
|
+
if (arr instanceof Uint8Array) {
|
|
6
|
+
return arr.buffer;
|
|
7
|
+
}
|
|
8
|
+
if (arr instanceof DataView) {
|
|
9
|
+
return arr.buffer;
|
|
10
|
+
}
|
|
11
|
+
return arr;
|
|
12
|
+
}
|
|
13
|
+
class FileAccessBase {
|
|
14
|
+
storageAccessManager;
|
|
15
|
+
vaultService;
|
|
16
|
+
settingService;
|
|
17
|
+
APIService;
|
|
18
|
+
path;
|
|
19
|
+
adapter;
|
|
20
|
+
_log;
|
|
21
|
+
constructor(adapter, dependencies) {
|
|
22
|
+
this.adapter = adapter;
|
|
23
|
+
this.storageAccessManager = dependencies.storageAccessManager;
|
|
24
|
+
this.vaultService = dependencies.vaultService;
|
|
25
|
+
this.settingService = dependencies.settingService;
|
|
26
|
+
this.APIService = dependencies.APIService;
|
|
27
|
+
this.path = dependencies.pathService;
|
|
28
|
+
this._log = createInstanceLogFunction("FileAccess", this.APIService);
|
|
29
|
+
}
|
|
30
|
+
// Delegated methods to adapter
|
|
31
|
+
isFile(file) {
|
|
32
|
+
return this.adapter.typeGuard.isFile(file);
|
|
33
|
+
}
|
|
34
|
+
isFolder(item) {
|
|
35
|
+
return this.adapter.typeGuard.isFolder(item);
|
|
36
|
+
}
|
|
37
|
+
getPath(file) {
|
|
38
|
+
return this.adapter.path.getPath(file);
|
|
39
|
+
}
|
|
40
|
+
nativeFileToUXFileInfoStub(file) {
|
|
41
|
+
return this.adapter.conversion.nativeFileToUXFileInfoStub(file);
|
|
42
|
+
}
|
|
43
|
+
nativeFolderToUXFolder(file) {
|
|
44
|
+
return this.adapter.conversion.nativeFolderToUXFolder(file);
|
|
45
|
+
}
|
|
46
|
+
normalisePath(path) {
|
|
47
|
+
return this.adapter.path.normalisePath(path);
|
|
48
|
+
}
|
|
49
|
+
_writeOp(file, callback) {
|
|
50
|
+
const path = this.getPath(file);
|
|
51
|
+
return this.storageAccessManager.processWriteFile(path, async () => await callback(path, file));
|
|
52
|
+
}
|
|
53
|
+
_readOp(file, callback) {
|
|
54
|
+
const path = this.getPath(file);
|
|
55
|
+
return this.storageAccessManager.processReadFile(path, async () => await callback(path, file));
|
|
56
|
+
}
|
|
57
|
+
async tryAdapterStat(file) {
|
|
58
|
+
return await this._readOp(file, async (path) => await this.adapter.storage.trystat(path));
|
|
59
|
+
}
|
|
60
|
+
async adapterStat(file) {
|
|
61
|
+
return await this._readOp(file, async (path) => await this.adapter.storage.stat(path));
|
|
62
|
+
}
|
|
63
|
+
async adapterExists(file) {
|
|
64
|
+
return await this._readOp(file, async (path) => await this.adapter.storage.exists(path));
|
|
65
|
+
}
|
|
66
|
+
async adapterRemove(file) {
|
|
67
|
+
return await this._writeOp(file, async (path) => await this.adapter.storage.remove(path));
|
|
68
|
+
}
|
|
69
|
+
async adapterRead(file) {
|
|
70
|
+
return await this._readOp(file, async (path) => await this.adapter.storage.read(path));
|
|
71
|
+
}
|
|
72
|
+
async adapterReadBinary(file) {
|
|
73
|
+
return await this._readOp(file, async (path) => await this.adapter.storage.readBinary(path));
|
|
74
|
+
}
|
|
75
|
+
async adapterReadAuto(file) {
|
|
76
|
+
const path = this.getPath(file);
|
|
77
|
+
if (isPlainText(path)) {
|
|
78
|
+
return await this._readOp(file, async (path2) => await this.adapter.storage.read(path2));
|
|
79
|
+
}
|
|
80
|
+
return await this._readOp(file, async (path2) => await this.adapter.storage.readBinary(path2));
|
|
81
|
+
}
|
|
82
|
+
async adapterWrite(file, data, options) {
|
|
83
|
+
if (typeof data === "string") {
|
|
84
|
+
return await this._writeOp(file, async (path) => await this.adapter.storage.write(path, data, options));
|
|
85
|
+
} else {
|
|
86
|
+
return await this._writeOp(
|
|
87
|
+
file,
|
|
88
|
+
async (path) => await this.adapter.storage.writeBinary(path, toArrayBuffer(data), options)
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
adapterList(basePath) {
|
|
93
|
+
return this.adapter.storage.list(basePath);
|
|
94
|
+
}
|
|
95
|
+
async vaultCacheRead(file) {
|
|
96
|
+
return await this._readOp(file, async (path) => await this.adapter.vault.cachedRead(file));
|
|
97
|
+
}
|
|
98
|
+
vaultRead(file) {
|
|
99
|
+
return this._readOp(file, async (path) => await this.adapter.vault.read(file));
|
|
100
|
+
}
|
|
101
|
+
vaultReadBinary(file) {
|
|
102
|
+
return this._readOp(file, async (path) => await this.adapter.vault.readBinary(file));
|
|
103
|
+
}
|
|
104
|
+
async vaultReadAuto(file) {
|
|
105
|
+
const path = this.getPath(file);
|
|
106
|
+
if (isPlainText(path)) {
|
|
107
|
+
return await this._readOp(path, async (path2) => await this.adapter.vault.read(file));
|
|
108
|
+
}
|
|
109
|
+
return await this._readOp(path, async (path2) => await this.adapter.vault.readBinary(file));
|
|
110
|
+
}
|
|
111
|
+
async vaultModify(file, data, options) {
|
|
112
|
+
if (typeof data === "string") {
|
|
113
|
+
return await this._writeOp(file, async (path) => {
|
|
114
|
+
const oldData = await this.adapter.vault.read(file);
|
|
115
|
+
if (data === oldData) {
|
|
116
|
+
const stat = await this.adapter.statFromNative(file);
|
|
117
|
+
if (options && options.mtime) this.path.markChangesAreSame(path, stat.mtime, options.mtime);
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
await this.adapter.vault.modify(file, data, options);
|
|
121
|
+
return true;
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
return await this._writeOp(file, async (path) => {
|
|
125
|
+
const oldData = await this.adapter.vault.readBinary(file);
|
|
126
|
+
if (await isDocContentSame(createBinaryBlob(oldData), createBinaryBlob(data))) {
|
|
127
|
+
const stat = await this.adapter.statFromNative(file);
|
|
128
|
+
if (options && options.mtime) this.path.markChangesAreSame(path, stat.mtime, options.mtime);
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
await this.adapter.vault.modifyBinary(file, toArrayBuffer(data), options);
|
|
132
|
+
return true;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
async vaultCreate(path, data, options) {
|
|
137
|
+
if (typeof data === "string") {
|
|
138
|
+
return await this._writeOp(path, () => this.adapter.vault.create(path, data, options));
|
|
139
|
+
} else {
|
|
140
|
+
return await this._writeOp(
|
|
141
|
+
path,
|
|
142
|
+
() => this.adapter.vault.createBinary(path, toArrayBuffer(data), options)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
async vaultRename(file, newPath) {
|
|
147
|
+
return await this._writeOp(file, async () => await this.adapter.renameFile(file, newPath));
|
|
148
|
+
}
|
|
149
|
+
trigger(name, ...data) {
|
|
150
|
+
return this.adapter.vault.trigger(name, ...data);
|
|
151
|
+
}
|
|
152
|
+
async reconcileInternalFile(path) {
|
|
153
|
+
return await this.adapter.reconcileInternalFile(path);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Append data to a file using the adapter's append method. This is useful for large files that cannot be read into memory.
|
|
157
|
+
* Please note that this method does not check concurrent modifications.
|
|
158
|
+
* @param normalizedPath
|
|
159
|
+
* @param data
|
|
160
|
+
* @param options
|
|
161
|
+
* @returns
|
|
162
|
+
*/
|
|
163
|
+
async adapterAppend(normalizedPath, data, options) {
|
|
164
|
+
return await this.adapter.storage.append(normalizedPath, data, options);
|
|
165
|
+
}
|
|
166
|
+
async delete(file, force) {
|
|
167
|
+
return await this._writeOp(file, async (path, file2) => await this.adapter.vault.delete(file2, force));
|
|
168
|
+
}
|
|
169
|
+
async trash(file, force) {
|
|
170
|
+
return await this._writeOp(file, async (path, file2) => await this.adapter.vault.trash(file2, force));
|
|
171
|
+
}
|
|
172
|
+
isStorageInsensitive() {
|
|
173
|
+
return this.vaultService.isStorageInsensitive();
|
|
174
|
+
}
|
|
175
|
+
async getAbstractFileByPath(path) {
|
|
176
|
+
const setting = this.settingService.currentSettings();
|
|
177
|
+
if (!setting.handleFilenameCaseSensitive || this.isStorageInsensitive()) {
|
|
178
|
+
return await this.adapter.getAbstractFileByPathInsensitive(path);
|
|
179
|
+
}
|
|
180
|
+
return await this.adapter.getAbstractFileByPath(path);
|
|
181
|
+
}
|
|
182
|
+
async getFiles() {
|
|
183
|
+
return await this.adapter.getFiles();
|
|
184
|
+
}
|
|
185
|
+
async ensureDirectory(fullPath) {
|
|
186
|
+
const pathElements = fullPath.split("/");
|
|
187
|
+
pathElements.pop();
|
|
188
|
+
let c = "";
|
|
189
|
+
for (const v of pathElements) {
|
|
190
|
+
c += v;
|
|
191
|
+
try {
|
|
192
|
+
await this.adapter.storage.mkdir(c);
|
|
193
|
+
} catch (ex) {
|
|
194
|
+
if (ex?.message == "Folder already exists.") {
|
|
195
|
+
} else {
|
|
196
|
+
this._log("Folder Create Error");
|
|
197
|
+
this._log(ex);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
c += "/";
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
async touch(file) {
|
|
204
|
+
const path = this.getPath(file);
|
|
205
|
+
const statOrg = this.isFile(file) ? file.stat : await this.adapter.storage.stat(path);
|
|
206
|
+
return this.storageAccessManager.touch({ path, stat: statOrg || { ctime: 0, mtime: 0, size: 0 } });
|
|
207
|
+
}
|
|
208
|
+
recentlyTouched(file) {
|
|
209
|
+
const path = file.path;
|
|
210
|
+
return this.storageAccessManager.recentlyTouched({ ...file, path });
|
|
211
|
+
}
|
|
212
|
+
clearTouched() {
|
|
213
|
+
return this.storageAccessManager.clearTouched();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
export {
|
|
217
|
+
FileAccessBase,
|
|
218
|
+
toArrayBuffer
|
|
219
|
+
};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import type { IFileHandler } from "../interfaces/FileHandler.js";
|
|
2
|
+
import type { APIService } from "../services/base/APIService.js";
|
|
3
|
+
import type { AppLifecycleService } from "../services/base/AppLifecycleService.js";
|
|
4
|
+
import type { DatabaseEventService } from "../services/base/DatabaseEventService.js";
|
|
5
|
+
import type { DatabaseService } from "../services/base/DatabaseService.js";
|
|
6
|
+
import type { RemoteService } from "../services/base/RemoteService.js";
|
|
7
|
+
import type { ReplicationService } from "../services/base/ReplicationService.js";
|
|
8
|
+
import type { ReplicatorService } from "../services/base/ReplicatorService.js";
|
|
9
|
+
import type { SettingService } from "../services/base/SettingService.js";
|
|
10
|
+
import type { VaultService } from "../services/base/VaultService.js";
|
|
11
|
+
import type { UIService } from "../services/implements/base/UIService.js";
|
|
12
|
+
import type { Rebuilder } from "../interfaces/DatabaseRebuilder.js";
|
|
13
|
+
import type { StorageAccess } from "../interfaces/StorageAccess.js";
|
|
14
|
+
import type { LiveSyncEventHub } from "../hub/hub.js";
|
|
15
|
+
import { ServiceModuleBase } from "./ServiceModuleBase.js";
|
|
16
|
+
import type { ControlService } from "../services/base/ControlService.js";
|
|
17
|
+
export interface ServiceRebuilderDependencies {
|
|
18
|
+
events: LiveSyncEventHub;
|
|
19
|
+
appLifecycle: AppLifecycleService;
|
|
20
|
+
API: APIService;
|
|
21
|
+
UI: UIService;
|
|
22
|
+
setting: SettingService;
|
|
23
|
+
remote: RemoteService;
|
|
24
|
+
databaseEvents: DatabaseEventService;
|
|
25
|
+
storageAccess: StorageAccess;
|
|
26
|
+
replicator: ReplicatorService;
|
|
27
|
+
vault: VaultService;
|
|
28
|
+
replication: ReplicationService;
|
|
29
|
+
database: DatabaseService;
|
|
30
|
+
fileHandler: IFileHandler;
|
|
31
|
+
control: ControlService;
|
|
32
|
+
}
|
|
33
|
+
export declare class ServiceRebuilder extends ServiceModuleBase<ServiceRebuilderDependencies> implements Rebuilder {
|
|
34
|
+
private events;
|
|
35
|
+
private appLifecycle;
|
|
36
|
+
private API;
|
|
37
|
+
private UI;
|
|
38
|
+
private setting;
|
|
39
|
+
private remote;
|
|
40
|
+
private databaseEvents;
|
|
41
|
+
private storageAccess;
|
|
42
|
+
private replicator;
|
|
43
|
+
private vault;
|
|
44
|
+
private replication;
|
|
45
|
+
private database;
|
|
46
|
+
private fileHandler;
|
|
47
|
+
private control;
|
|
48
|
+
constructor(services: ServiceRebuilderDependencies);
|
|
49
|
+
$performRebuildDB(method: "localOnly" | "remoteOnly" | "rebuildBothByThisDevice" | "localOnlyWithChunks"): Promise<void>;
|
|
50
|
+
informOptionalFeatures(): Promise<void>;
|
|
51
|
+
askUsingOptionalFeature(opt: {
|
|
52
|
+
enableFetch?: boolean;
|
|
53
|
+
enableOverwrite?: boolean;
|
|
54
|
+
}): Promise<void>;
|
|
55
|
+
rebuildRemote(): Promise<void>;
|
|
56
|
+
private performRemoteRebuild;
|
|
57
|
+
$rebuildRemote(): Promise<void>;
|
|
58
|
+
rebuildEverything(): Promise<void>;
|
|
59
|
+
private performRebuildEverything;
|
|
60
|
+
$rebuildEverything(): Promise<void>;
|
|
61
|
+
$fetchLocal(makeLocalChunkBeforeSync?: boolean, preventMakeLocalFilesBeforeSync?: boolean): Promise<void>;
|
|
62
|
+
$fetchLocalDBFast(autoResume: boolean): Promise<void>;
|
|
63
|
+
scheduleRebuild(): Promise<void>;
|
|
64
|
+
scheduleFetch(): Promise<void>;
|
|
65
|
+
private _tryResetRemoteDatabase;
|
|
66
|
+
private _onResetLocalDatabase;
|
|
67
|
+
suspendAllSync(): Promise<void>;
|
|
68
|
+
suspendReflectingDatabase(ignoreMinIO?: boolean): Promise<void>;
|
|
69
|
+
resumeReflectingDatabase(ignoreMinIO?: boolean): Promise<void>;
|
|
70
|
+
fetchLocal(makeLocalChunkBeforeSync?: boolean, preventMakeLocalFilesBeforeSync?: boolean, autoResume?: boolean): Promise<void>;
|
|
71
|
+
private performFetchLocal;
|
|
72
|
+
fetchLocalDBFast(autoResume: boolean): Promise<void>;
|
|
73
|
+
private performFetchLocalDBFast;
|
|
74
|
+
/**
|
|
75
|
+
* Finish rebuild process with resuming the reflection.
|
|
76
|
+
*
|
|
77
|
+
* @param ignoreMinIO Whether to ignore minio for resuming the reflection.
|
|
78
|
+
*/
|
|
79
|
+
finishRebuild(ignoreMinIO?: boolean): Promise<void>;
|
|
80
|
+
/**
|
|
81
|
+
* Fetch local database with making all chunks.
|
|
82
|
+
* This is a wrapper for {@link fetchLocal} with makeLocalChunkBeforeSync = true.
|
|
83
|
+
*
|
|
84
|
+
* @returns
|
|
85
|
+
*/
|
|
86
|
+
fetchLocalWithRebuild(): Promise<void>;
|
|
87
|
+
private _allSuspendAllSync;
|
|
88
|
+
resetLocalDatabase(): Promise<void>;
|
|
89
|
+
private getFastFetchCheckpoint;
|
|
90
|
+
private saveFastFetchCheckpoint;
|
|
91
|
+
private clearFastFetchCheckpoint;
|
|
92
|
+
}
|