@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,564 @@
|
|
|
1
|
+
import { shouldBeIgnored } from "../string_and_binary/path.js";
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_SETTINGS,
|
|
4
|
+
LOG_LEVEL_DEBUG,
|
|
5
|
+
LOG_LEVEL_INFO,
|
|
6
|
+
LOG_LEVEL_NOTICE,
|
|
7
|
+
LOG_LEVEL_VERBOSE
|
|
8
|
+
} from "../common/types.js";
|
|
9
|
+
import { delay, fireAndForget, throttle } from "../common/utils.js";
|
|
10
|
+
import {} from "../common/types.js";
|
|
11
|
+
import { serialized, skipIfDuplicated } from "octagonal-wheels/concurrency/lock";
|
|
12
|
+
import { isWaitingForTimeout } from "octagonal-wheels/concurrency/task";
|
|
13
|
+
import { Semaphore } from "octagonal-wheels/concurrency/semaphore";
|
|
14
|
+
import { promiseWithResolvers } from "octagonal-wheels/promises";
|
|
15
|
+
import { StorageEventManager } from "../interfaces/StorageEventManager.js";
|
|
16
|
+
import { createInstanceLogFunction } from "../services/lib/logUtils.js";
|
|
17
|
+
import { compatGlobal } from "../common/coreEnvFunctions.js";
|
|
18
|
+
const TYPE_SENTINEL_FLUSH = "SENTINEL_FLUSH";
|
|
19
|
+
class StorageEventManagerBase extends StorageEventManager {
|
|
20
|
+
_log;
|
|
21
|
+
setting;
|
|
22
|
+
vaultService;
|
|
23
|
+
fileProcessing;
|
|
24
|
+
storageAccess;
|
|
25
|
+
adapter;
|
|
26
|
+
get shouldBatchSave() {
|
|
27
|
+
return this.settings?.batchSave && this.settings?.liveSync != true;
|
|
28
|
+
}
|
|
29
|
+
get batchSaveMinimumDelay() {
|
|
30
|
+
return this.settings?.batchSaveMinimumDelay ?? DEFAULT_SETTINGS.batchSaveMinimumDelay;
|
|
31
|
+
}
|
|
32
|
+
get batchSaveMaximumDelay() {
|
|
33
|
+
return this.settings?.batchSaveMaximumDelay ?? DEFAULT_SETTINGS.batchSaveMaximumDelay;
|
|
34
|
+
}
|
|
35
|
+
get settings() {
|
|
36
|
+
return this.setting.currentSettings();
|
|
37
|
+
}
|
|
38
|
+
constructor(adapter, dependencies) {
|
|
39
|
+
super();
|
|
40
|
+
this.adapter = adapter;
|
|
41
|
+
this.setting = dependencies.setting;
|
|
42
|
+
this.vaultService = dependencies.vaultService;
|
|
43
|
+
this.fileProcessing = dependencies.fileProcessing;
|
|
44
|
+
this.storageAccess = dependencies.storageAccessManager;
|
|
45
|
+
this._log = createInstanceLogFunction("StorageEventManager", dependencies.APIService);
|
|
46
|
+
}
|
|
47
|
+
// Delegated methods to adapter
|
|
48
|
+
_saveSnapshot(snapshot) {
|
|
49
|
+
return this.adapter.persistence.saveSnapshot(snapshot);
|
|
50
|
+
}
|
|
51
|
+
_loadSnapshot() {
|
|
52
|
+
return this.adapter.persistence.loadSnapshot();
|
|
53
|
+
}
|
|
54
|
+
// Type guard methods delegated to adapter
|
|
55
|
+
isFolder(file) {
|
|
56
|
+
return this.adapter.typeGuard.isFolder(file);
|
|
57
|
+
}
|
|
58
|
+
isFile(file) {
|
|
59
|
+
return this.adapter.typeGuard.isFile(file);
|
|
60
|
+
}
|
|
61
|
+
updateStatus() {
|
|
62
|
+
const allFileEventItems = this.bufferedQueuedItems.filter((e) => "args" in e);
|
|
63
|
+
const allItems = allFileEventItems.filter((e) => !e.cancelled);
|
|
64
|
+
const totalItems = allItems.length + this.concurrentProcessing.waiting;
|
|
65
|
+
const processing = this.processingCount;
|
|
66
|
+
const batchedCount = this._waitingMap.size;
|
|
67
|
+
this.adapter.status.updateStatus({
|
|
68
|
+
batched: batchedCount,
|
|
69
|
+
processing,
|
|
70
|
+
totalQueued: totalItems + batchedCount + processing
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Snapshot restoration promise.
|
|
75
|
+
* Snapshot will be restored before starting to watch vault changes.
|
|
76
|
+
* In designed time, this has been called from Initialisation process, which has been implemented on `ModuleInitializerFile.ts`.
|
|
77
|
+
*/
|
|
78
|
+
snapShotRestored = null;
|
|
79
|
+
/**
|
|
80
|
+
* Restore the previous snapshot if exists.
|
|
81
|
+
* @returns
|
|
82
|
+
*/
|
|
83
|
+
restoreState() {
|
|
84
|
+
this.snapShotRestored = this._restoreFromSnapshot();
|
|
85
|
+
return this.snapShotRestored;
|
|
86
|
+
}
|
|
87
|
+
async appendQueue(params, ctx) {
|
|
88
|
+
const settings = this.settings;
|
|
89
|
+
if (!settings.isConfigured) return;
|
|
90
|
+
if (settings.suspendFileWatching) return;
|
|
91
|
+
if (settings.maxMTimeForReflectEvents > 0) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
this.fileProcessing.onStorageFileEvent();
|
|
95
|
+
for (const param of params) {
|
|
96
|
+
const atomicKey = [0, 0, 0, 0, 0, 0].map((e) => `${Math.floor(Math.random() * 1e5)}`).join("-");
|
|
97
|
+
let type = param.type;
|
|
98
|
+
let file = param.file;
|
|
99
|
+
const oldPath = param.oldPath;
|
|
100
|
+
if (this.isFolder(file)) {
|
|
101
|
+
this._log(`Folder event skipped: ${file.path}`, LOG_LEVEL_VERBOSE);
|
|
102
|
+
continue;
|
|
103
|
+
}
|
|
104
|
+
const isTargetPath = async (path) => {
|
|
105
|
+
if (shouldBeIgnored(path)) return false;
|
|
106
|
+
if (!settings.syncInternalFiles && path.startsWith(".")) return false;
|
|
107
|
+
return await this.vaultService.isTargetFile(path);
|
|
108
|
+
};
|
|
109
|
+
if (type === "RENAME") {
|
|
110
|
+
const renamedFile = file;
|
|
111
|
+
if (!oldPath || !this.isFile(file) || !renamedFile.stat) {
|
|
112
|
+
this._log(`Invalid rename event skipped: ${file.path}`, LOG_LEVEL_VERBOSE);
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
const oldPathIsTarget = await isTargetPath(oldPath);
|
|
116
|
+
let newPathIsTarget = await isTargetPath(file.path);
|
|
117
|
+
if (newPathIsTarget && this.vaultService.isFileSizeTooLarge(renamedFile.stat.size)) {
|
|
118
|
+
this._log(
|
|
119
|
+
`The storage file has been changed but exceeds the maximum size. Skipping: ${param.file.path}`,
|
|
120
|
+
LOG_LEVEL_NOTICE
|
|
121
|
+
);
|
|
122
|
+
newPathIsTarget = false;
|
|
123
|
+
}
|
|
124
|
+
if (!oldPathIsTarget && !newPathIsTarget) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (oldPathIsTarget && !newPathIsTarget) {
|
|
128
|
+
type = "DELETE";
|
|
129
|
+
file = {
|
|
130
|
+
path: oldPath,
|
|
131
|
+
name: oldPath.split("/").pop() ?? file.name,
|
|
132
|
+
stat: renamedFile.stat,
|
|
133
|
+
deleted: true
|
|
134
|
+
};
|
|
135
|
+
} else if (!oldPathIsTarget && newPathIsTarget) {
|
|
136
|
+
type = "CREATE";
|
|
137
|
+
}
|
|
138
|
+
} else {
|
|
139
|
+
if (!await isTargetPath(file.path)) continue;
|
|
140
|
+
if (type !== "INTERNAL") {
|
|
141
|
+
const size = file.stat.size;
|
|
142
|
+
if (this.vaultService.isFileSizeTooLarge(size) && (type == "CREATE" || type == "CHANGED")) {
|
|
143
|
+
this._log(
|
|
144
|
+
`The storage file has been changed but exceeds the maximum size. Skipping: ${param.file.path}`,
|
|
145
|
+
LOG_LEVEL_NOTICE
|
|
146
|
+
);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (this.isFile(file)) {
|
|
152
|
+
if (type == "CREATE" || type == "CHANGED" || type == "RENAME") {
|
|
153
|
+
await delay(10);
|
|
154
|
+
if (this.storageAccess.recentlyTouched({
|
|
155
|
+
path: file.path,
|
|
156
|
+
stat: file.stat ?? { ctime: 0, mtime: 0, size: 0 }
|
|
157
|
+
})) {
|
|
158
|
+
continue;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
let cache = void 0;
|
|
163
|
+
if (param.cachedData) {
|
|
164
|
+
cache = param.cachedData;
|
|
165
|
+
}
|
|
166
|
+
void this.enqueue({
|
|
167
|
+
type,
|
|
168
|
+
args: {
|
|
169
|
+
file,
|
|
170
|
+
oldPath: type === "RENAME" ? oldPath : void 0,
|
|
171
|
+
cache,
|
|
172
|
+
ctx
|
|
173
|
+
},
|
|
174
|
+
skipBatchWait: param.skipBatchWait,
|
|
175
|
+
key: atomicKey
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
// Cache file and waiting to can be proceed.
|
|
180
|
+
bufferedQueuedItems = [];
|
|
181
|
+
enqueue(newItem) {
|
|
182
|
+
if (newItem.type == "DELETE" || newItem.type == "RENAME") {
|
|
183
|
+
this.bufferedQueuedItems.push({
|
|
184
|
+
type: TYPE_SENTINEL_FLUSH
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
this.updateStatus();
|
|
188
|
+
this.bufferedQueuedItems.push(newItem);
|
|
189
|
+
fireAndForget(() => this._takeSnapshot().then(() => this.runQueuedEvents()));
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Immediately take snapshot.
|
|
193
|
+
*/
|
|
194
|
+
_triggerTakeSnapshot() {
|
|
195
|
+
void this._takeSnapshot();
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Trigger taking snapshot after throttled period.
|
|
199
|
+
*/
|
|
200
|
+
triggerTakeSnapshot = throttle(() => this._triggerTakeSnapshot(), 100);
|
|
201
|
+
// Limit concurrent processing to reduce the IO load. file-processing + scheduler (1), so file events can be processed in 4 slots.
|
|
202
|
+
concurrentProcessing = Semaphore(5);
|
|
203
|
+
_waitingMap = /* @__PURE__ */ new Map();
|
|
204
|
+
_waitForIdle = null;
|
|
205
|
+
/**
|
|
206
|
+
* Wait until all queued events are processed.
|
|
207
|
+
* Subsequent new events will not be waited, but new events will not be added.
|
|
208
|
+
* @returns
|
|
209
|
+
*/
|
|
210
|
+
waitForIdle() {
|
|
211
|
+
if (this._waitingMap.size === 0) {
|
|
212
|
+
return Promise.resolve();
|
|
213
|
+
}
|
|
214
|
+
if (this._waitForIdle) {
|
|
215
|
+
return this._waitForIdle;
|
|
216
|
+
}
|
|
217
|
+
const promises = [...this._waitingMap.entries()].map(([key, waitInfo]) => {
|
|
218
|
+
return new Promise((resolve) => {
|
|
219
|
+
waitInfo.canProceed.promise.then(() => {
|
|
220
|
+
this._log(`Processing ${key}: Wait for idle completed`, LOG_LEVEL_DEBUG);
|
|
221
|
+
}).catch((e) => {
|
|
222
|
+
this._log(`Processing ${key}: Wait for idle error`, LOG_LEVEL_INFO);
|
|
223
|
+
this._log(e, LOG_LEVEL_VERBOSE);
|
|
224
|
+
}).finally(() => {
|
|
225
|
+
resolve();
|
|
226
|
+
});
|
|
227
|
+
this._proceedWaiting(key);
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
const waitPromise = Promise.all(promises).then(() => {
|
|
231
|
+
this._waitForIdle = null;
|
|
232
|
+
this._log(`All wait for idle completed`, LOG_LEVEL_VERBOSE);
|
|
233
|
+
});
|
|
234
|
+
this._waitForIdle = waitPromise;
|
|
235
|
+
return waitPromise;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Proceed waiting for the given key immediately.
|
|
239
|
+
*/
|
|
240
|
+
_proceedWaiting(key) {
|
|
241
|
+
const waitInfo = this._waitingMap.get(key);
|
|
242
|
+
if (waitInfo) {
|
|
243
|
+
waitInfo.canProceed.resolve(true);
|
|
244
|
+
compatGlobal.clearTimeout(waitInfo.timerHandler);
|
|
245
|
+
this._waitingMap.delete(key);
|
|
246
|
+
}
|
|
247
|
+
this.triggerTakeSnapshot();
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Cancel waiting for the given key.
|
|
251
|
+
*/
|
|
252
|
+
_cancelWaiting(key) {
|
|
253
|
+
const waitInfo = this._waitingMap.get(key);
|
|
254
|
+
if (waitInfo) {
|
|
255
|
+
waitInfo.canProceed.resolve(false);
|
|
256
|
+
compatGlobal.clearTimeout(waitInfo.timerHandler);
|
|
257
|
+
this._waitingMap.delete(key);
|
|
258
|
+
}
|
|
259
|
+
this.triggerTakeSnapshot();
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Add waiting for the given key.
|
|
263
|
+
* @param key
|
|
264
|
+
* @param event
|
|
265
|
+
* @param waitedSince Optional waited since timestamp to calculate the remaining delay.
|
|
266
|
+
*/
|
|
267
|
+
_addWaiting(key, event, waitedSince) {
|
|
268
|
+
if (this._waitingMap.has(key)) {
|
|
269
|
+
throw new Error(`Already waiting for key: ${key}`);
|
|
270
|
+
}
|
|
271
|
+
const resolver = promiseWithResolvers();
|
|
272
|
+
const now = Date.now();
|
|
273
|
+
const since = waitedSince ?? now;
|
|
274
|
+
const elapsed = now - since;
|
|
275
|
+
const maxDelay = this.batchSaveMaximumDelay * 1e3;
|
|
276
|
+
const remainingDelay = Math.max(0, maxDelay - elapsed);
|
|
277
|
+
const nextDelay = Math.min(remainingDelay, this.batchSaveMinimumDelay * 1e3);
|
|
278
|
+
if (elapsed >= maxDelay) {
|
|
279
|
+
this._log(`Processing ${key}: Batch save maximum delay already exceeded: ${event.type}`, LOG_LEVEL_DEBUG);
|
|
280
|
+
} else {
|
|
281
|
+
this._log(
|
|
282
|
+
`Processing ${key}: Adding waiting for batch save: ${event.type} (${nextDelay}ms)`,
|
|
283
|
+
LOG_LEVEL_DEBUG
|
|
284
|
+
);
|
|
285
|
+
}
|
|
286
|
+
const waitInfo = {
|
|
287
|
+
since,
|
|
288
|
+
type: event.type,
|
|
289
|
+
event,
|
|
290
|
+
canProceed: resolver,
|
|
291
|
+
timerHandler: compatGlobal.setTimeout(() => {
|
|
292
|
+
this._log(`Processing ${key}: Batch save timeout reached: ${event.type}`, LOG_LEVEL_DEBUG);
|
|
293
|
+
this._proceedWaiting(key);
|
|
294
|
+
}, nextDelay)
|
|
295
|
+
};
|
|
296
|
+
this._waitingMap.set(key, waitInfo);
|
|
297
|
+
this.triggerTakeSnapshot();
|
|
298
|
+
return waitInfo;
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* Process the given file event.
|
|
302
|
+
*/
|
|
303
|
+
async processFileEvent(fei) {
|
|
304
|
+
const releaser = await this.concurrentProcessing.acquire();
|
|
305
|
+
try {
|
|
306
|
+
this.updateStatus();
|
|
307
|
+
const filename = fei.args.file.path;
|
|
308
|
+
const waitingKey = `${filename}`;
|
|
309
|
+
const previous = this._waitingMap.get(waitingKey);
|
|
310
|
+
let isShouldBeCancelled = fei.skipBatchWait || false;
|
|
311
|
+
let previousPromise = Promise.resolve(true);
|
|
312
|
+
let waitPromise = Promise.resolve(true);
|
|
313
|
+
if (previous) {
|
|
314
|
+
previousPromise = previous.canProceed.promise;
|
|
315
|
+
if (isShouldBeCancelled) {
|
|
316
|
+
this._log(
|
|
317
|
+
`Processing ${filename}: Requested to perform immediately, cancelling previous waiting: ${fei.type}`,
|
|
318
|
+
LOG_LEVEL_DEBUG
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
if (!isShouldBeCancelled && fei.type === "DELETE") {
|
|
322
|
+
this._log(
|
|
323
|
+
`Processing ${filename}: DELETE requested, cancelling previous waiting: ${fei.type}`,
|
|
324
|
+
LOG_LEVEL_DEBUG
|
|
325
|
+
);
|
|
326
|
+
isShouldBeCancelled = true;
|
|
327
|
+
}
|
|
328
|
+
if (!isShouldBeCancelled && previous.type === fei.type) {
|
|
329
|
+
this._log(`Processing ${filename}: Cancelling previous waiting: ${fei.type}`, LOG_LEVEL_DEBUG);
|
|
330
|
+
isShouldBeCancelled = true;
|
|
331
|
+
}
|
|
332
|
+
if (isShouldBeCancelled) {
|
|
333
|
+
this._cancelWaiting(waitingKey);
|
|
334
|
+
this._log(`Processing ${filename}: Previous cancelled: ${fei.type}`, LOG_LEVEL_DEBUG);
|
|
335
|
+
isShouldBeCancelled = true;
|
|
336
|
+
}
|
|
337
|
+
if (!isShouldBeCancelled) {
|
|
338
|
+
this._log(`Processing ${filename}: Waiting for previous to complete: ${fei.type}`, LOG_LEVEL_DEBUG);
|
|
339
|
+
this._proceedWaiting(waitingKey);
|
|
340
|
+
this._log(`Processing ${filename}: Previous completed: ${fei.type}`, LOG_LEVEL_DEBUG);
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
await previousPromise;
|
|
344
|
+
if (this.shouldBatchSave && !fei.skipBatchWait) {
|
|
345
|
+
if (fei.type == "CREATE" || fei.type == "CHANGED") {
|
|
346
|
+
const info = this._addWaiting(waitingKey, fei, previous?.since);
|
|
347
|
+
waitPromise = info.canProceed.promise;
|
|
348
|
+
} else if (fei.type == "DELETE") {
|
|
349
|
+
}
|
|
350
|
+
this._log(`Processing ${filename}: Waiting for batch save: ${fei.type}`, LOG_LEVEL_DEBUG);
|
|
351
|
+
const canProceed = await waitPromise;
|
|
352
|
+
if (!canProceed) {
|
|
353
|
+
this._log(`Processing ${filename}: Cancelled by new queue: ${fei.type}`, LOG_LEVEL_DEBUG);
|
|
354
|
+
return;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
await this.requestProcessQueue(fei);
|
|
358
|
+
} finally {
|
|
359
|
+
await this._takeSnapshot();
|
|
360
|
+
releaser();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
async _takeSnapshot() {
|
|
364
|
+
const processingEvents = [...this._waitingMap.values()].map((e) => e.event);
|
|
365
|
+
const waitingEvents = this.bufferedQueuedItems;
|
|
366
|
+
const snapShot = [...processingEvents, ...waitingEvents];
|
|
367
|
+
await this._saveSnapshot(snapShot);
|
|
368
|
+
this.updateStatus();
|
|
369
|
+
}
|
|
370
|
+
async _restoreFromSnapshot() {
|
|
371
|
+
const snapShot = await this._loadSnapshot();
|
|
372
|
+
if (snapShot && Array.isArray(snapShot) && snapShot.length > 0) {
|
|
373
|
+
this._log(`Restoring storage operation snapshot: ${snapShot.length} items`, LOG_LEVEL_VERBOSE);
|
|
374
|
+
this.bufferedQueuedItems = snapShot.map((e) => ({ ...e, skipBatchWait: true }));
|
|
375
|
+
this.updateStatus();
|
|
376
|
+
await this.runQueuedEvents();
|
|
377
|
+
} else {
|
|
378
|
+
this._log(`No snapshot to restore`, LOG_LEVEL_VERBOSE);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
runQueuedEvents() {
|
|
382
|
+
return skipIfDuplicated("storage-event-manager-run-queued-events", async () => {
|
|
383
|
+
do {
|
|
384
|
+
if (this.bufferedQueuedItems.length === 0) {
|
|
385
|
+
break;
|
|
386
|
+
}
|
|
387
|
+
const fei = this.bufferedQueuedItems.shift();
|
|
388
|
+
await this._takeSnapshot();
|
|
389
|
+
this.updateStatus();
|
|
390
|
+
const releaser = await this.concurrentProcessing.acquire();
|
|
391
|
+
releaser();
|
|
392
|
+
this.updateStatus();
|
|
393
|
+
if (fei.type === TYPE_SENTINEL_FLUSH) {
|
|
394
|
+
this._log(`Waiting for idle`, LOG_LEVEL_VERBOSE);
|
|
395
|
+
await this.waitForIdle();
|
|
396
|
+
this.updateStatus();
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
fireAndForget(() => this.processFileEvent(fei));
|
|
400
|
+
} while (this.bufferedQueuedItems.length > 0);
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
processingCount = 0;
|
|
404
|
+
async requestProcessQueue(fei) {
|
|
405
|
+
try {
|
|
406
|
+
this.processingCount++;
|
|
407
|
+
this.updateStatus();
|
|
408
|
+
await this.handleFileEvent(fei);
|
|
409
|
+
await this._takeSnapshot();
|
|
410
|
+
} finally {
|
|
411
|
+
this.processingCount--;
|
|
412
|
+
this.updateStatus();
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
isWaiting(filename) {
|
|
416
|
+
return isWaitingForTimeout(`storage-event-manager-batchsave-${filename}`);
|
|
417
|
+
}
|
|
418
|
+
async handleFileEvent(queue) {
|
|
419
|
+
const file = queue.args.file;
|
|
420
|
+
const lockKey = `handleFile:${file.path}`;
|
|
421
|
+
await serialized(lockKey, async () => {
|
|
422
|
+
if (queue.cancelled) {
|
|
423
|
+
this._log(`File event cancelled before processing: ${file.path}`, LOG_LEVEL_INFO);
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
if (queue.type == "INTERNAL" || file.isInternal) {
|
|
427
|
+
await this.fileProcessing.processOptionalFileEvent(file.path);
|
|
428
|
+
} else {
|
|
429
|
+
const last = 0;
|
|
430
|
+
if (queue.type == "DELETE") {
|
|
431
|
+
await this.fileProcessing.processFileEvent(queue);
|
|
432
|
+
} else {
|
|
433
|
+
if (file.stat.mtime == last) {
|
|
434
|
+
this._log(
|
|
435
|
+
`File has been already scanned on ${queue.type}, skip: ${file.path}`,
|
|
436
|
+
LOG_LEVEL_VERBOSE
|
|
437
|
+
);
|
|
438
|
+
return;
|
|
439
|
+
}
|
|
440
|
+
if (!await this.fileProcessing.processFileEvent(queue)) {
|
|
441
|
+
this._log(
|
|
442
|
+
`STORAGE -> DB: Handler failed, cancel the relative operations: ${file.path}`,
|
|
443
|
+
LOG_LEVEL_INFO
|
|
444
|
+
);
|
|
445
|
+
this.cancelRelativeEvent(queue);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
});
|
|
451
|
+
this.updateStatus();
|
|
452
|
+
return;
|
|
453
|
+
}
|
|
454
|
+
cancelRelativeEvent(item) {
|
|
455
|
+
this._cancelWaiting(item.args.file.path);
|
|
456
|
+
}
|
|
457
|
+
/**
|
|
458
|
+
* Begin watching for storage events
|
|
459
|
+
*/
|
|
460
|
+
async beginWatch() {
|
|
461
|
+
await this.snapShotRestored;
|
|
462
|
+
await this.adapter.watch.beginWatch({
|
|
463
|
+
onCreate: (file, ctx) => this.watchVaultCreate(file, ctx),
|
|
464
|
+
onChange: (file, ctx) => this.watchVaultChange(file, ctx),
|
|
465
|
+
onDelete: (file, ctx) => this.watchVaultDelete(file, ctx),
|
|
466
|
+
onRename: (file, oldPath, ctx) => this.watchVaultRename(file, oldPath, ctx),
|
|
467
|
+
onRaw: (path) => this.watchVaultRawEvents(path),
|
|
468
|
+
onEditorChange: (editor, info) => this.watchEditorChange(editor, info)
|
|
469
|
+
});
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Platform-agnostic event handlers
|
|
473
|
+
*/
|
|
474
|
+
watchEditorChange(editor, info) {
|
|
475
|
+
if (typeof info !== "object" || info === null) {
|
|
476
|
+
return;
|
|
477
|
+
}
|
|
478
|
+
if (!("path" in info)) {
|
|
479
|
+
return;
|
|
480
|
+
}
|
|
481
|
+
if (!this.shouldBatchSave) {
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
if (!("file" in info)) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
const file = info?.file;
|
|
488
|
+
if (!file) return;
|
|
489
|
+
const path = this.adapter.typeGuard.isFile(file) ? file.path : info.path;
|
|
490
|
+
if (!path) return;
|
|
491
|
+
if (this.storageAccess.isFileProcessing(path)) {
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
if (!this.isWaiting(path)) {
|
|
495
|
+
return;
|
|
496
|
+
}
|
|
497
|
+
const data = info?.data;
|
|
498
|
+
const fi = {
|
|
499
|
+
type: "CHANGED",
|
|
500
|
+
file: this.adapter.converter.toFileInfo(file),
|
|
501
|
+
cachedData: data
|
|
502
|
+
};
|
|
503
|
+
void this.appendQueue([fi]);
|
|
504
|
+
}
|
|
505
|
+
watchVaultCreate(file, ctx) {
|
|
506
|
+
if (this.adapter.typeGuard.isFolder(file)) return;
|
|
507
|
+
const path = file.path;
|
|
508
|
+
if (this.storageAccess.isFileProcessing(path)) {
|
|
509
|
+
return;
|
|
510
|
+
}
|
|
511
|
+
const fileInfo = this.adapter.converter.toFileInfo(file);
|
|
512
|
+
void this.appendQueue([{ type: "CREATE", file: fileInfo }], ctx);
|
|
513
|
+
}
|
|
514
|
+
watchVaultChange(file, ctx) {
|
|
515
|
+
if (this.adapter.typeGuard.isFolder(file)) return;
|
|
516
|
+
const path = file.path;
|
|
517
|
+
if (this.storageAccess.isFileProcessing(path)) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const fileInfo = this.adapter.converter.toFileInfo(file);
|
|
521
|
+
void this.appendQueue([{ type: "CHANGED", file: fileInfo }], ctx);
|
|
522
|
+
}
|
|
523
|
+
watchVaultDelete(file, ctx) {
|
|
524
|
+
if (this.adapter.typeGuard.isFolder(file)) return;
|
|
525
|
+
const path = file.path;
|
|
526
|
+
if (this.storageAccess.isFileProcessing(path)) {
|
|
527
|
+
return;
|
|
528
|
+
}
|
|
529
|
+
const fileInfo = this.adapter.converter.toFileInfo(file, true);
|
|
530
|
+
void this.appendQueue([{ type: "DELETE", file: fileInfo }], ctx);
|
|
531
|
+
}
|
|
532
|
+
watchVaultRename(file, oldPath, ctx) {
|
|
533
|
+
if (this.adapter.typeGuard.isFile(file)) {
|
|
534
|
+
const fileInfo = this.adapter.converter.toFileInfo(file);
|
|
535
|
+
void this.appendQueue(
|
|
536
|
+
[
|
|
537
|
+
{
|
|
538
|
+
type: "RENAME",
|
|
539
|
+
file: fileInfo,
|
|
540
|
+
oldPath,
|
|
541
|
+
skipBatchWait: true
|
|
542
|
+
}
|
|
543
|
+
],
|
|
544
|
+
ctx
|
|
545
|
+
);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
watchVaultRawEvents(path) {
|
|
549
|
+
if (this.storageAccess.isFileProcessing(path)) {
|
|
550
|
+
return;
|
|
551
|
+
}
|
|
552
|
+
if (!this.settings) return;
|
|
553
|
+
if (this.settings.useIgnoreFiles) {
|
|
554
|
+
void this.vaultService.isTargetFile(path).then(() => this._watchVaultRawEvents(path));
|
|
555
|
+
} else {
|
|
556
|
+
void this._watchVaultRawEvents(path);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
async _watchVaultRawEvents(path) {
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
export {
|
|
563
|
+
StorageEventManagerBase
|
|
564
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { FilePathWithPrefix } from "../common/models/db.type.js";
|
|
2
|
+
import type { UXFileInfoStub } from "../common/models/fileaccess.type.js";
|
|
3
|
+
import type { IStorageAccessManager } from "../interfaces/StorageAccess.js";
|
|
4
|
+
import type { FileWithFileStat, FileWithStatAsProp } from "../common/models/fileaccess.type.js";
|
|
5
|
+
export declare class StorageAccessManager implements IStorageAccessManager {
|
|
6
|
+
processingFiles: Set<FilePathWithPrefix>;
|
|
7
|
+
processWriteFile<T>(file: UXFileInfoStub | FilePathWithPrefix, proc: () => Promise<T>): Promise<T>;
|
|
8
|
+
processReadFile<T>(file: UXFileInfoStub | FilePathWithPrefix, proc: () => Promise<T>): Promise<T>;
|
|
9
|
+
isFileProcessing(file: UXFileInfoStub | FilePathWithPrefix): boolean;
|
|
10
|
+
private touchedFiles;
|
|
11
|
+
touch(file: FileWithFileStat | FileWithStatAsProp): void;
|
|
12
|
+
recentlyTouched(file: FileWithStatAsProp | FileWithFileStat): boolean;
|
|
13
|
+
clearTouched(): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { serialized } from "octagonal-wheels/concurrency/lock";
|
|
2
|
+
const fileLockPrefix = "file-lock:";
|
|
3
|
+
class StorageAccessManager {
|
|
4
|
+
processingFiles = /* @__PURE__ */ new Set();
|
|
5
|
+
processWriteFile(file, proc) {
|
|
6
|
+
const path = typeof file === "string" ? file : file.path;
|
|
7
|
+
return serialized(`${fileLockPrefix}${path}`, async () => {
|
|
8
|
+
try {
|
|
9
|
+
this.processingFiles.add(path);
|
|
10
|
+
return await proc();
|
|
11
|
+
} finally {
|
|
12
|
+
this.processingFiles.delete(path);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
processReadFile(file, proc) {
|
|
17
|
+
const path = typeof file === "string" ? file : file.path;
|
|
18
|
+
return serialized(`${fileLockPrefix}${path}`, async () => {
|
|
19
|
+
try {
|
|
20
|
+
this.processingFiles.add(path);
|
|
21
|
+
return await proc();
|
|
22
|
+
} finally {
|
|
23
|
+
this.processingFiles.delete(path);
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
isFileProcessing(file) {
|
|
28
|
+
const path = typeof file === "string" ? file : file.path;
|
|
29
|
+
return this.processingFiles.has(path);
|
|
30
|
+
}
|
|
31
|
+
touchedFiles = [];
|
|
32
|
+
touch(file) {
|
|
33
|
+
const key = "stat" in file ? `${file.path}-${file.stat.mtime}-${file.stat.size}` : `${file.path}-${file.mtime}-${file.size}`;
|
|
34
|
+
this.touchedFiles.unshift(key);
|
|
35
|
+
this.touchedFiles = this.touchedFiles.slice(0, 100);
|
|
36
|
+
}
|
|
37
|
+
recentlyTouched(file) {
|
|
38
|
+
const key = "stat" in file ? `${file.path}-${file.stat.mtime}-${file.stat.size}` : `${file.path}-${file.mtime}-${file.size}`;
|
|
39
|
+
if (this.touchedFiles.indexOf(key) == -1) return false;
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
clearTouched() {
|
|
43
|
+
this.touchedFiles = [];
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
StorageAccessManager
|
|
48
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { FilePath, UXFileInfoStub, UXInternalFileInfoStub } from "../../common/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Adapter interface for converting platform-specific file types to UX types
|
|
4
|
+
*
|
|
5
|
+
* @template TFile - Platform-specific file type
|
|
6
|
+
*/
|
|
7
|
+
export interface IStorageEventConverterAdapter<TFile> {
|
|
8
|
+
/**
|
|
9
|
+
* Convert platform-specific file to UXFileInfoStub
|
|
10
|
+
*/
|
|
11
|
+
toFileInfo(file: TFile, deleted?: boolean): UXFileInfoStub;
|
|
12
|
+
/**
|
|
13
|
+
* Convert path to UXInternalFileInfoStub
|
|
14
|
+
*/
|
|
15
|
+
toInternalFileInfo(path: FilePath): UXInternalFileInfoStub;
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { IStorageEventTypeGuardAdapter } from "./IStorageEventTypeGuardAdapter.js";
|
|
2
|
+
import type { IStorageEventPersistenceAdapter } from "./IStorageEventPersistenceAdapter.js";
|
|
3
|
+
import type { IStorageEventWatchAdapter } from "./IStorageEventWatchAdapter.js";
|
|
4
|
+
import type { IStorageEventStatusAdapter } from "./IStorageEventStatusAdapter.js";
|
|
5
|
+
import type { IStorageEventConverterAdapter } from "./IStorageEventConverterAdapter.js";
|
|
6
|
+
/**
|
|
7
|
+
* Composite adapter interface for StorageEventManager
|
|
8
|
+
*
|
|
9
|
+
* @template TFile - Platform-specific file type
|
|
10
|
+
* @template TFolder - Platform-specific folder type
|
|
11
|
+
*/
|
|
12
|
+
export interface IStorageEventManagerAdapter<TFile, TFolder> {
|
|
13
|
+
readonly typeGuard: IStorageEventTypeGuardAdapter<TFile, TFolder>;
|
|
14
|
+
readonly persistence: IStorageEventPersistenceAdapter;
|
|
15
|
+
readonly watch: IStorageEventWatchAdapter<TFile, unknown>;
|
|
16
|
+
readonly status: IStorageEventStatusAdapter;
|
|
17
|
+
readonly converter: IStorageEventConverterAdapter<TFile>;
|
|
18
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { FileEventItem } from "../../common/types.js";
|
|
2
|
+
import type { FileEventItemSentinel } from "../StorageEventManager.js";
|
|
3
|
+
/**
|
|
4
|
+
* Adapter interface for snapshot persistence operations
|
|
5
|
+
*/
|
|
6
|
+
export interface IStorageEventPersistenceAdapter {
|
|
7
|
+
/**
|
|
8
|
+
* Save the snapshot of pending events
|
|
9
|
+
*/
|
|
10
|
+
saveSnapshot(snapshot: (FileEventItem | FileEventItemSentinel)[]): Promise<void>;
|
|
11
|
+
/**
|
|
12
|
+
* Load the snapshot of pending events
|
|
13
|
+
*/
|
|
14
|
+
loadSnapshot(): Promise<(FileEventItem | FileEventItemSentinel)[] | null>;
|
|
15
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter interface for status update operations
|
|
3
|
+
*/
|
|
4
|
+
export interface IStorageEventStatusAdapter {
|
|
5
|
+
/**
|
|
6
|
+
* Update the status display
|
|
7
|
+
*/
|
|
8
|
+
updateStatus(status: {
|
|
9
|
+
batched: number;
|
|
10
|
+
processing: number;
|
|
11
|
+
totalQueued: number;
|
|
12
|
+
}): void;
|
|
13
|
+
}
|