@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,58 @@
|
|
|
1
|
+
const encoder = new TextEncoder();
|
|
2
|
+
function estimateBytes(text) {
|
|
3
|
+
return encoder.encode(text).byteLength;
|
|
4
|
+
}
|
|
5
|
+
function splitIntoChunks(payload, maxBytes) {
|
|
6
|
+
if (maxBytes <= 0) return [payload];
|
|
7
|
+
if (estimateBytes(payload) <= maxBytes) return [payload];
|
|
8
|
+
const chunks = [];
|
|
9
|
+
let cursor = 0;
|
|
10
|
+
while (cursor < payload.length) {
|
|
11
|
+
let end = Math.min(payload.length, cursor + Math.max(16, Math.floor(maxBytes / 2)));
|
|
12
|
+
let part = payload.slice(cursor, end);
|
|
13
|
+
while (part.length > 1 && estimateBytes(part) > maxBytes) {
|
|
14
|
+
end = Math.max(cursor + 1, end - 1);
|
|
15
|
+
part = payload.slice(cursor, end);
|
|
16
|
+
}
|
|
17
|
+
chunks.push(part);
|
|
18
|
+
cursor = end;
|
|
19
|
+
}
|
|
20
|
+
return chunks;
|
|
21
|
+
}
|
|
22
|
+
class IncomingChunkBuffer {
|
|
23
|
+
total;
|
|
24
|
+
parts = /* @__PURE__ */ new Map();
|
|
25
|
+
constructor(total) {
|
|
26
|
+
this.total = total;
|
|
27
|
+
}
|
|
28
|
+
add(index, payload) {
|
|
29
|
+
if (index < 0 || index >= this.total) return;
|
|
30
|
+
this.parts.set(index, payload);
|
|
31
|
+
}
|
|
32
|
+
missingIndices() {
|
|
33
|
+
const missing = [];
|
|
34
|
+
for (let i = 0; i < this.total; i++) {
|
|
35
|
+
if (!this.parts.has(i)) missing.push(i);
|
|
36
|
+
}
|
|
37
|
+
return missing;
|
|
38
|
+
}
|
|
39
|
+
isComplete() {
|
|
40
|
+
return this.parts.size === this.total;
|
|
41
|
+
}
|
|
42
|
+
toPayload() {
|
|
43
|
+
let acc = "";
|
|
44
|
+
for (let i = 0; i < this.total; i++) {
|
|
45
|
+
const part = this.parts.get(i);
|
|
46
|
+
if (part === void 0) {
|
|
47
|
+
throw new Error(`Missing chunk ${i}`);
|
|
48
|
+
}
|
|
49
|
+
acc += part;
|
|
50
|
+
}
|
|
51
|
+
return acc;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
export {
|
|
55
|
+
IncomingChunkBuffer,
|
|
56
|
+
estimateBytes,
|
|
57
|
+
splitIntoChunks
|
|
58
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { JsonLike, RpcErrorCode, RpcErrorShape } from "./types.js";
|
|
2
|
+
export declare class RpcError extends Error {
|
|
3
|
+
code: RpcErrorCode;
|
|
4
|
+
details?: JsonLike;
|
|
5
|
+
constructor(code: RpcErrorCode, message: string, details?: JsonLike);
|
|
6
|
+
toShape(): RpcErrorShape;
|
|
7
|
+
}
|
|
8
|
+
export declare function asRpcErrorShape(ex: unknown): RpcErrorShape;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
class RpcError extends Error {
|
|
2
|
+
code;
|
|
3
|
+
details;
|
|
4
|
+
constructor(code, message, details) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.name = "RpcError";
|
|
7
|
+
this.code = code;
|
|
8
|
+
this.details = details;
|
|
9
|
+
}
|
|
10
|
+
toShape() {
|
|
11
|
+
return { code: this.code, message: this.message, details: this.details };
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
function asRpcErrorShape(ex) {
|
|
15
|
+
if (ex instanceof RpcError) {
|
|
16
|
+
return ex.toShape();
|
|
17
|
+
}
|
|
18
|
+
if (ex instanceof Error) {
|
|
19
|
+
return { code: "REMOTE_ERROR", message: ex.message };
|
|
20
|
+
}
|
|
21
|
+
return { code: "REMOTE_ERROR", message: "Unknown remote error" };
|
|
22
|
+
}
|
|
23
|
+
export {
|
|
24
|
+
RpcError,
|
|
25
|
+
asRpcErrorShape
|
|
26
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { RpcRoom } from "./RpcRoom.js";
|
|
2
|
+
export { RpcSession } from "./RpcSession.js";
|
|
3
|
+
export { RpcError } from "./errors.js";
|
|
4
|
+
export { exposeDB } from "./pouchdb/RpcPouchDBServer.js";
|
|
5
|
+
export { RpcPouchDBProxy } from "./pouchdb/RpcPouchDBProxy.js";
|
|
6
|
+
export type { JsonLike, RpcEnvelope, RpcErrorCode, RpcErrorShape, RpcMethodHandler, RpcRegisterOptions, RpcRoomOptions, RpcWireMessage, TransportAdapter, } from "./types.js";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RpcRoom } from "./RpcRoom.js";
|
|
2
|
+
import { RpcSession } from "./RpcSession.js";
|
|
3
|
+
import { RpcError } from "./errors.js";
|
|
4
|
+
import { exposeDB } from "./pouchdb/RpcPouchDBServer.js";
|
|
5
|
+
import { RpcPouchDBProxy } from "./pouchdb/RpcPouchDBProxy.js";
|
|
6
|
+
export {
|
|
7
|
+
RpcError,
|
|
8
|
+
RpcPouchDBProxy,
|
|
9
|
+
RpcRoom,
|
|
10
|
+
RpcSession,
|
|
11
|
+
exposeDB
|
|
12
|
+
};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import EventEmitter from "events";
|
|
2
|
+
import type { RpcSession } from "../RpcSession.js";
|
|
3
|
+
/**
|
|
4
|
+
* A PouchDB-compatible proxy that forwards all database operations to a remote
|
|
5
|
+
* peer via an {@link RpcSession}.
|
|
6
|
+
*
|
|
7
|
+
* The proxy exposes the same public interface as a PouchDB instance and can be
|
|
8
|
+
* passed directly to `PouchDB.replicate()` or `PouchDB.sync()` as either the
|
|
9
|
+
* source or the target database. It can also be used with {@link replicateShim}
|
|
10
|
+
* from `ReplicatorShim.ts`.
|
|
11
|
+
*
|
|
12
|
+
* The remote side must have called {@link exposeDB} to register the matching
|
|
13
|
+
* RPC handlers.
|
|
14
|
+
*
|
|
15
|
+
* ### Changes feed
|
|
16
|
+
* `changes()` returns an object that satisfies both the EventEmitter interface
|
|
17
|
+
* required by `pouchdb-replication` and the Promise interface required by
|
|
18
|
+
* `replicateShim` (i.e. it can be `await`ed directly).
|
|
19
|
+
*
|
|
20
|
+
* ### Error propagation
|
|
21
|
+
* PouchDB-specific error properties (`status`, `name`, `reason`) are preserved
|
|
22
|
+
* across the RPC transport and reconstructed on the proxy side so that callers
|
|
23
|
+
* such as `pouchdb-checkpointer` can inspect `err.status === 404` correctly.
|
|
24
|
+
*/
|
|
25
|
+
export declare class RpcPouchDBProxy extends EventEmitter {
|
|
26
|
+
/** The logical name of the remote database. */
|
|
27
|
+
readonly name: string;
|
|
28
|
+
/**
|
|
29
|
+
* Stub ActiveTasks object required by `pouchdb-replication`. All
|
|
30
|
+
* operations are no-ops; task state is not tracked across the RPC boundary.
|
|
31
|
+
*/
|
|
32
|
+
readonly activeTasks: {
|
|
33
|
+
add: (_task: object) => unknown;
|
|
34
|
+
get: (_id: unknown) => unknown;
|
|
35
|
+
update: (_id: unknown, _update: object) => void;
|
|
36
|
+
remove: (_id: unknown, _err?: Error) => void;
|
|
37
|
+
list: () => unknown[];
|
|
38
|
+
};
|
|
39
|
+
private readonly session;
|
|
40
|
+
private readonly ns;
|
|
41
|
+
constructor(session: RpcSession, name: string, ns?: string);
|
|
42
|
+
/**
|
|
43
|
+
* Invoke an RPC method and reconstruct PouchDB error shapes on the response.
|
|
44
|
+
*
|
|
45
|
+
* When the remote handler wraps a PouchDB error via {@link exposeDB}'s
|
|
46
|
+
* `runDB` helper, the `RpcError.details` object carries `status`, `name`,
|
|
47
|
+
* and `reason`. This method rebuilds a plain `Error` with those properties
|
|
48
|
+
* so that callers (e.g. pouchdb-checkpointer) can use `err.status` /
|
|
49
|
+
* `err.name` as expected.
|
|
50
|
+
*/
|
|
51
|
+
private callDB;
|
|
52
|
+
info(): Promise<PouchDB.Core.DatabaseInfo>;
|
|
53
|
+
id(): Promise<string>;
|
|
54
|
+
/**
|
|
55
|
+
* Returns a `Changes`-compatible object that is simultaneously:
|
|
56
|
+
* - An **EventEmitter** with `change`, `complete`, and `error` events, plus
|
|
57
|
+
* a `cancel()` method — satisfying the interface consumed by
|
|
58
|
+
* `PouchDB.replicate()` / `PouchDB.sync()`.
|
|
59
|
+
* - A **thenable** (`then` / `catch`) — allowing `await db.changes(opts)`
|
|
60
|
+
* as used by `replicateShim`.
|
|
61
|
+
*
|
|
62
|
+
* The remote changes feed is always fetched as a one-shot snapshot
|
|
63
|
+
* (`live: false`).
|
|
64
|
+
*/
|
|
65
|
+
changes(opts: PouchDB.Core.ChangesOptions): PouchDB.Core.Changes<object>;
|
|
66
|
+
get<T extends object>(id: string, opts?: PouchDB.Core.GetOptions): Promise<T & PouchDB.Core.IdMeta & PouchDB.Core.GetMeta>;
|
|
67
|
+
put<T extends object>(doc: PouchDB.Core.PutDocument<T>, opts?: PouchDB.Core.PutOptions): Promise<PouchDB.Core.Response>;
|
|
68
|
+
bulkGet<T extends object>(opts: PouchDB.Core.BulkGetOptions): Promise<PouchDB.Core.BulkGetResponse<T>>;
|
|
69
|
+
bulkDocs<T extends object>(docs: PouchDB.Core.PostDocument<T>[] | {
|
|
70
|
+
docs: PouchDB.Core.PostDocument<T>[];
|
|
71
|
+
new_edits?: boolean;
|
|
72
|
+
}, opts?: PouchDB.Core.BulkDocsOptions): Promise<(PouchDB.Core.Response | PouchDB.Core.Error)[]>;
|
|
73
|
+
revsDiff(diff: PouchDB.Core.RevisionDiffOptions): Promise<PouchDB.Core.RevisionDiffResponse>;
|
|
74
|
+
allDocs<T extends object>(opts?: PouchDB.Core.AllDocsOptions): Promise<PouchDB.Core.AllDocsResponse<T>>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import EventEmitter from "events";
|
|
2
|
+
import { RpcError } from "../errors.js";
|
|
3
|
+
const noopActiveTasks = {
|
|
4
|
+
add: (_task) => null,
|
|
5
|
+
get: (_id) => null,
|
|
6
|
+
update: (_id, _update) => {
|
|
7
|
+
},
|
|
8
|
+
remove: (_id, _err) => {
|
|
9
|
+
},
|
|
10
|
+
list: () => []
|
|
11
|
+
};
|
|
12
|
+
class RpcPouchDBProxy extends EventEmitter {
|
|
13
|
+
/** The logical name of the remote database. */
|
|
14
|
+
name;
|
|
15
|
+
/**
|
|
16
|
+
* Stub ActiveTasks object required by `pouchdb-replication`. All
|
|
17
|
+
* operations are no-ops; task state is not tracked across the RPC boundary.
|
|
18
|
+
*/
|
|
19
|
+
activeTasks = noopActiveTasks;
|
|
20
|
+
session;
|
|
21
|
+
ns;
|
|
22
|
+
constructor(session, name, ns = "pdb") {
|
|
23
|
+
super();
|
|
24
|
+
this.session = session;
|
|
25
|
+
this.name = name;
|
|
26
|
+
this.ns = ns;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Invoke an RPC method and reconstruct PouchDB error shapes on the response.
|
|
30
|
+
*
|
|
31
|
+
* When the remote handler wraps a PouchDB error via {@link exposeDB}'s
|
|
32
|
+
* `runDB` helper, the `RpcError.details` object carries `status`, `name`,
|
|
33
|
+
* and `reason`. This method rebuilds a plain `Error` with those properties
|
|
34
|
+
* so that callers (e.g. pouchdb-checkpointer) can use `err.status` /
|
|
35
|
+
* `err.name` as expected.
|
|
36
|
+
*/
|
|
37
|
+
async callDB(method, args = []) {
|
|
38
|
+
try {
|
|
39
|
+
return await this.session.call(`${this.ns}.${method}`, args);
|
|
40
|
+
} catch (err) {
|
|
41
|
+
if (err instanceof RpcError && err.code === "REMOTE_ERROR") {
|
|
42
|
+
const d = err.details;
|
|
43
|
+
if (d?.name || d?.status) {
|
|
44
|
+
const pouchErr = new Error(err.message);
|
|
45
|
+
if (d.name) pouchErr.name = d.name;
|
|
46
|
+
if (d.status) pouchErr.status = d.status;
|
|
47
|
+
if (d.reason) pouchErr.reason = d.reason;
|
|
48
|
+
throw pouchErr;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
throw err;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
info() {
|
|
55
|
+
return this.callDB("info");
|
|
56
|
+
}
|
|
57
|
+
id() {
|
|
58
|
+
return this.callDB("id");
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns a `Changes`-compatible object that is simultaneously:
|
|
62
|
+
* - An **EventEmitter** with `change`, `complete`, and `error` events, plus
|
|
63
|
+
* a `cancel()` method — satisfying the interface consumed by
|
|
64
|
+
* `PouchDB.replicate()` / `PouchDB.sync()`.
|
|
65
|
+
* - A **thenable** (`then` / `catch`) — allowing `await db.changes(opts)`
|
|
66
|
+
* as used by `replicateShim`.
|
|
67
|
+
*
|
|
68
|
+
* The remote changes feed is always fetched as a one-shot snapshot
|
|
69
|
+
* (`live: false`).
|
|
70
|
+
*/
|
|
71
|
+
changes(opts) {
|
|
72
|
+
const emitter = new EventEmitter();
|
|
73
|
+
let cancelled = false;
|
|
74
|
+
const promise = this.callDB("changes", [{ ...opts, live: false }]).then((info) => {
|
|
75
|
+
if (cancelled) return info;
|
|
76
|
+
for (const change of info.results ?? []) {
|
|
77
|
+
if (cancelled) break;
|
|
78
|
+
emitter.emit("change", change);
|
|
79
|
+
}
|
|
80
|
+
if (!cancelled) emitter.emit("complete", info);
|
|
81
|
+
return info;
|
|
82
|
+
});
|
|
83
|
+
promise.catch((err) => {
|
|
84
|
+
if (!cancelled) emitter.emit("error", err);
|
|
85
|
+
});
|
|
86
|
+
emitter.cancel = () => {
|
|
87
|
+
cancelled = true;
|
|
88
|
+
emitter.removeAllListeners();
|
|
89
|
+
};
|
|
90
|
+
emitter.then = (onfulfilled, onrejected) => promise.then(onfulfilled, onrejected);
|
|
91
|
+
emitter.catch = (onrejected) => promise.catch(onrejected);
|
|
92
|
+
return emitter;
|
|
93
|
+
}
|
|
94
|
+
get(id, opts) {
|
|
95
|
+
return this.callDB("get", [id, opts ?? {}]);
|
|
96
|
+
}
|
|
97
|
+
put(doc, opts) {
|
|
98
|
+
return this.callDB("put", [doc, opts ?? {}]);
|
|
99
|
+
}
|
|
100
|
+
bulkGet(opts) {
|
|
101
|
+
return this.callDB("bulkGet", [opts]);
|
|
102
|
+
}
|
|
103
|
+
bulkDocs(docs, opts) {
|
|
104
|
+
return this.callDB("bulkDocs", [docs, opts ?? {}]);
|
|
105
|
+
}
|
|
106
|
+
revsDiff(diff) {
|
|
107
|
+
return this.callDB("revsDiff", [diff]);
|
|
108
|
+
}
|
|
109
|
+
allDocs(opts) {
|
|
110
|
+
return this.callDB("allDocs", [opts ?? {}]);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
export {
|
|
114
|
+
RpcPouchDBProxy
|
|
115
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { RpcRoom } from "../RpcRoom.js";
|
|
2
|
+
/**
|
|
3
|
+
* Exposes a PouchDB database as a set of RPC methods registered on an
|
|
4
|
+
* {@link RpcRoom}. The remote peer can access the database via
|
|
5
|
+
* {@link RpcPouchDBProxy}.
|
|
6
|
+
*
|
|
7
|
+
* All methods are registered under the given namespace prefix `ns` (default:
|
|
8
|
+
* `'pdb'`). For example, with the default namespace the method names are
|
|
9
|
+
* `pdb.info`, `pdb.id`, `pdb.changes`, `pdb.get`, `pdb.put`, `pdb.bulkGet`,
|
|
10
|
+
* `pdb.bulkDocs`, `pdb.revsDiff`, and `pdb.allDocs`.
|
|
11
|
+
*
|
|
12
|
+
* @param room The {@link RpcRoom} on which to register handlers.
|
|
13
|
+
* @param db The PouchDB database instance to expose.
|
|
14
|
+
* @param ns Method namespace prefix (default: `'pdb'`).
|
|
15
|
+
*/
|
|
16
|
+
export declare function exposeDB(room: RpcRoom, db: PouchDB.Database<object>, ns?: string): void;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { LiveSyncError } from "../../common/LSError.js";
|
|
2
|
+
import { RpcError } from "../errors.js";
|
|
3
|
+
async function runDB(fn) {
|
|
4
|
+
try {
|
|
5
|
+
return await fn();
|
|
6
|
+
} catch (e) {
|
|
7
|
+
const err = e;
|
|
8
|
+
if (err?.status || err?.name) {
|
|
9
|
+
const details = {};
|
|
10
|
+
if (err.status) details.status = err.status;
|
|
11
|
+
if (err.name) details.name = err.name;
|
|
12
|
+
if (err.reason) details.reason = err.reason;
|
|
13
|
+
throw new RpcError("REMOTE_ERROR", err.message ?? String(LiveSyncError.fromError(err)), details);
|
|
14
|
+
}
|
|
15
|
+
throw e;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
function exposeDB(room, db, ns = "pdb") {
|
|
19
|
+
room.register(`${ns}.info`, () => runDB(() => db.info()));
|
|
20
|
+
room.register(`${ns}.id`, () => runDB(() => db.id()));
|
|
21
|
+
room.register(
|
|
22
|
+
`${ns}.changes`,
|
|
23
|
+
(_peerId, opts) => runDB(
|
|
24
|
+
() => new Promise((resolve, reject) => {
|
|
25
|
+
const feed = db.changes({ ...opts, live: false });
|
|
26
|
+
void feed.on("complete", resolve);
|
|
27
|
+
void feed.on("error", reject);
|
|
28
|
+
})
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
room.register(
|
|
32
|
+
`${ns}.get`,
|
|
33
|
+
(_peerId, id, opts) => runDB(() => db.get(id, opts ?? {}))
|
|
34
|
+
);
|
|
35
|
+
room.register(
|
|
36
|
+
`${ns}.put`,
|
|
37
|
+
(_peerId, doc, opts) => runDB(() => db.put(doc, opts ?? {}))
|
|
38
|
+
);
|
|
39
|
+
room.register(`${ns}.bulkGet`, (_peerId, opts) => runDB(() => db.bulkGet(opts)));
|
|
40
|
+
room.register(
|
|
41
|
+
`${ns}.bulkDocs`,
|
|
42
|
+
(_peerId, req, opts) => (
|
|
43
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- wrongly typed in @types/pouchdb (incorrect overload signatures)
|
|
44
|
+
runDB(() => db.bulkDocs(req, opts ?? {}))
|
|
45
|
+
)
|
|
46
|
+
);
|
|
47
|
+
room.register(`${ns}.revsDiff`, (_peerId, diff) => runDB(() => db.revsDiff(diff)));
|
|
48
|
+
room.register(
|
|
49
|
+
`${ns}.allDocs`,
|
|
50
|
+
(_peerId, opts) => runDB(() => db.allDocs(opts ?? {}))
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export {
|
|
54
|
+
exposeDB
|
|
55
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { DiagRTCStats, DiagRTCFailureDiagnosis } from "./DiagRTCPeerConnections.types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Subscribes to connection status updates. The callback will be called with the latest connection statistics whenever there is a change in the connection status of any RTCPeerConnection instance.
|
|
4
|
+
* Returns an unsubscribe function to stop receiving updates.
|
|
5
|
+
*
|
|
6
|
+
* @param callback - The function to call with the latest connection statistics.
|
|
7
|
+
* @returns A function that can be called to unsubscribe from updates.
|
|
8
|
+
*/
|
|
9
|
+
export declare function subscribeConnectionStatus(callback: (status: DiagRTCStats) => void): () => void;
|
|
10
|
+
/**
|
|
11
|
+
* Subscribes to failure diagnosis updates. The callback will be called with the diagnosis information whenever a connection failure is detected in any RTCPeerConnection instance.
|
|
12
|
+
* Returns an unsubscribe function to stop receiving updates.
|
|
13
|
+
* @param callback - The function to call with the diagnosis information.
|
|
14
|
+
* @returns A function that can be called to unsubscribe from updates.
|
|
15
|
+
*/
|
|
16
|
+
export declare function subscribeFailureDiagnosis(callback: (diagnosis: DiagRTCFailureDiagnosis) => void): () => void;
|
|
17
|
+
export type DiagRTCPeerConnectionConstructor = typeof RTCPeerConnection;
|
|
18
|
+
/**
|
|
19
|
+
* A wrapper around RTCPeerConnection to collect statistics for diagnostics.
|
|
20
|
+
* It extends the native (or globally-polyfilled) RTCPeerConnection and overrides its constructor to add event listeners for connection state changes,
|
|
21
|
+
* ice connection state changes, ice gathering state changes, and signaling state changes. It maintains a history of these states and logs the progress.
|
|
22
|
+
* It also tracks the number of new connections, failed connections, successful connections, and closed connections, and dispatches this information to subscribers.
|
|
23
|
+
*/
|
|
24
|
+
export declare function createDiagRTCPeerConnectionConstructor(): DiagRTCPeerConnectionConstructor;
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { compatGlobal } from "../../common/coreEnvFunctions.js";
|
|
2
|
+
import { LOG_LEVEL_VERBOSE, Logger } from "../../common/logger.js";
|
|
3
|
+
import { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO } from "../../common/types.js";
|
|
4
|
+
import {
|
|
5
|
+
auditRtcConnectionFailures,
|
|
6
|
+
describeRTCProgress,
|
|
7
|
+
getPeerConnectionStats
|
|
8
|
+
} from "./DiagRTCPeerConnections.utils.js";
|
|
9
|
+
let rtcInstanceCounter = 0;
|
|
10
|
+
let totalNewConnections = 0;
|
|
11
|
+
let totalFailedConnections = 0;
|
|
12
|
+
let totalSuccessfulConnections = 0;
|
|
13
|
+
let totalClosedConnections = 0;
|
|
14
|
+
const RTCConnectionStatuses = /* @__PURE__ */ new Map();
|
|
15
|
+
let connectionStatusSubscribers = [];
|
|
16
|
+
let failureDiagnosisSubscribers = [];
|
|
17
|
+
function logRtcProgress(instanceId, eventName, peer) {
|
|
18
|
+
Logger(
|
|
19
|
+
`[DiagRTC:${instanceId}] ${eventName}: connection=${peer.connectionState}, iceConnection=${peer.iceConnectionState}, iceGathering=${peer.iceGatheringState}, signaling=${peer.signalingState}`,
|
|
20
|
+
LOG_LEVEL_DEBUG
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
function dispatchStatus(status) {
|
|
24
|
+
const details = Object.fromEntries(RTCConnectionStatuses);
|
|
25
|
+
for (const subscriber of connectionStatusSubscribers) {
|
|
26
|
+
try {
|
|
27
|
+
subscriber({
|
|
28
|
+
totalNewConnections,
|
|
29
|
+
totalFailedConnections,
|
|
30
|
+
totalSuccessfulConnections,
|
|
31
|
+
totalClosedConnections,
|
|
32
|
+
details
|
|
33
|
+
});
|
|
34
|
+
} catch {
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function dispatchFailureDiagnosis(diagnosis) {
|
|
39
|
+
for (const subscriber of failureDiagnosisSubscribers) {
|
|
40
|
+
try {
|
|
41
|
+
subscriber(diagnosis);
|
|
42
|
+
} catch {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
function subscribeConnectionStatus(callback) {
|
|
47
|
+
connectionStatusSubscribers.push(callback);
|
|
48
|
+
return () => {
|
|
49
|
+
connectionStatusSubscribers = connectionStatusSubscribers.filter((cb) => cb !== callback);
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function subscribeFailureDiagnosis(callback) {
|
|
53
|
+
failureDiagnosisSubscribers.push(callback);
|
|
54
|
+
return () => {
|
|
55
|
+
failureDiagnosisSubscribers = failureDiagnosisSubscribers.filter((cb) => cb !== callback);
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function createDiagRTCPeerConnectionConstructor() {
|
|
59
|
+
if (typeof compatGlobal.RTCPeerConnection === "undefined") {
|
|
60
|
+
throw new Error("RTCPeerConnection is not available in the current environment.");
|
|
61
|
+
}
|
|
62
|
+
return class DiagRTCPeerConnection extends compatGlobal.RTCPeerConnection {
|
|
63
|
+
/**
|
|
64
|
+
* Internal unique identifier for this RTCPeerConnection instance, used for tracking and logging purposes.
|
|
65
|
+
*/
|
|
66
|
+
__instanceId;
|
|
67
|
+
/**
|
|
68
|
+
* A flag to ensure that failure statistics are logged only once per failure event, to avoid duplicate logs in case of multiple related state changes.
|
|
69
|
+
*/
|
|
70
|
+
__failureStatsLogged = false;
|
|
71
|
+
/**
|
|
72
|
+
* Histories of connection states
|
|
73
|
+
*/
|
|
74
|
+
_connectionStateHistory = [];
|
|
75
|
+
/**
|
|
76
|
+
* Histories of ice connection states
|
|
77
|
+
*/
|
|
78
|
+
_iceConnectionHistory = [];
|
|
79
|
+
/**
|
|
80
|
+
* Histories of ice gathering states
|
|
81
|
+
*/
|
|
82
|
+
_iceGatheringHistory = [];
|
|
83
|
+
/**
|
|
84
|
+
* Histories of signaling states
|
|
85
|
+
*/
|
|
86
|
+
_signalingHistory = [];
|
|
87
|
+
/**
|
|
88
|
+
* Last known connection state, used to detect changes and update statistics accordingly.
|
|
89
|
+
*/
|
|
90
|
+
_previousConnectionState = void 0;
|
|
91
|
+
/**
|
|
92
|
+
* Returns the internal state history of this RTCPeerConnection instance, including connection state history, ice connection state history,
|
|
93
|
+
* ice gathering state history, and signaling state history.
|
|
94
|
+
* This is used for diagnostics and failure analysis.
|
|
95
|
+
*/
|
|
96
|
+
get stateHistory() {
|
|
97
|
+
return {
|
|
98
|
+
connectionHistory: this._connectionStateHistory,
|
|
99
|
+
iceConnectionHistory: this._iceConnectionHistory,
|
|
100
|
+
iceGatheringHistory: this._iceGatheringHistory,
|
|
101
|
+
signalingHistory: this._signalingHistory
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
_logProgress(eventName) {
|
|
105
|
+
logRtcProgress(this.__instanceId, eventName, this);
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Notifies subscribers about the current connection progress, including the latest connection state and ice connection state, as well as the overall progress of the connection based on the state history.
|
|
109
|
+
* @param status The current connection status, including connection state and ice connection state.
|
|
110
|
+
*/
|
|
111
|
+
async notifyConnectionProgress(status) {
|
|
112
|
+
const metrics = await getPeerConnectionStats(this.__instanceId, this);
|
|
113
|
+
const progress = describeRTCProgress(this.stateHistory, metrics?.selectedPair);
|
|
114
|
+
Logger(`[DiagRTC:${this.__instanceId}]: ${progress}`, LOG_LEVEL_INFO);
|
|
115
|
+
Logger(
|
|
116
|
+
`[DiagRTC:${this.__instanceId}] status: connection=${status.connectionState}, iceConnection=${status.iceConnectionState}`,
|
|
117
|
+
LOG_LEVEL_VERBOSE
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Tracks the connection progress of this RTCPeerConnection instance, updating statistics and notifying subscribers as needed.
|
|
122
|
+
* @param instanceId The unique identifier of this RTCPeerConnection instance.
|
|
123
|
+
* @param status The current connection status, including connection state and ice connection state.
|
|
124
|
+
*/
|
|
125
|
+
trackConnectionProgress() {
|
|
126
|
+
const status = {
|
|
127
|
+
connectionState: this.connectionState,
|
|
128
|
+
iceConnectionState: this.iceConnectionState
|
|
129
|
+
};
|
|
130
|
+
const instanceId = this.__instanceId;
|
|
131
|
+
if (status.connectionState === "closed" || status.connectionState === "failed") {
|
|
132
|
+
RTCConnectionStatuses.delete(instanceId);
|
|
133
|
+
} else {
|
|
134
|
+
RTCConnectionStatuses.set(instanceId, status);
|
|
135
|
+
}
|
|
136
|
+
if (this._previousConnectionState != status.connectionState) {
|
|
137
|
+
if (status.connectionState === "connected") {
|
|
138
|
+
totalSuccessfulConnections += 1;
|
|
139
|
+
}
|
|
140
|
+
if (status.connectionState === "failed") {
|
|
141
|
+
totalFailedConnections += 1;
|
|
142
|
+
}
|
|
143
|
+
if (status.connectionState === "new") {
|
|
144
|
+
totalNewConnections += 1;
|
|
145
|
+
}
|
|
146
|
+
if (status.connectionState === "closed") {
|
|
147
|
+
totalClosedConnections += 1;
|
|
148
|
+
}
|
|
149
|
+
this._previousConnectionState = status.connectionState;
|
|
150
|
+
void this.notifyConnectionProgress(status);
|
|
151
|
+
dispatchStatus(status);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Analyses the failure of this RTCPeerConnection instance using the state history and selected pair information, and dispatches the diagnosis to subscribers.
|
|
156
|
+
*/
|
|
157
|
+
async analyseFailureAndDispatch() {
|
|
158
|
+
const history = this.stateHistory;
|
|
159
|
+
const diagnosis = await auditRtcConnectionFailures(this.__instanceId, history, this);
|
|
160
|
+
if (diagnosis) {
|
|
161
|
+
dispatchFailureDiagnosis(diagnosis.diagnosis);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
constructor(configuration) {
|
|
165
|
+
super(configuration);
|
|
166
|
+
rtcInstanceCounter += 1;
|
|
167
|
+
this.__instanceId = `rtc-${rtcInstanceCounter}`;
|
|
168
|
+
this._logProgress("created");
|
|
169
|
+
this.addEventListener("connectionstatechange", () => {
|
|
170
|
+
this._connectionStateHistory.push(this.connectionState);
|
|
171
|
+
this._logProgress("connectionstatechange");
|
|
172
|
+
this.trackConnectionProgress();
|
|
173
|
+
if (this.connectionState !== "failed") {
|
|
174
|
+
this.__failureStatsLogged = false;
|
|
175
|
+
}
|
|
176
|
+
if (this.connectionState === "failed" && !this.__failureStatsLogged) {
|
|
177
|
+
this.__failureStatsLogged = true;
|
|
178
|
+
void this.analyseFailureAndDispatch();
|
|
179
|
+
}
|
|
180
|
+
});
|
|
181
|
+
this.addEventListener("iceconnectionstatechange", () => {
|
|
182
|
+
this._iceConnectionHistory.push(this.iceConnectionState);
|
|
183
|
+
this._logProgress("iceconnectionstatechange");
|
|
184
|
+
this.trackConnectionProgress();
|
|
185
|
+
if (this.iceConnectionState !== "failed" && this.connectionState !== "failed") {
|
|
186
|
+
this.__failureStatsLogged = false;
|
|
187
|
+
}
|
|
188
|
+
if ((this.connectionState === "failed" || this.iceConnectionState === "failed") && !this.__failureStatsLogged) {
|
|
189
|
+
this.__failureStatsLogged = true;
|
|
190
|
+
void this.analyseFailureAndDispatch();
|
|
191
|
+
}
|
|
192
|
+
});
|
|
193
|
+
this.addEventListener("icegatheringstatechange", () => {
|
|
194
|
+
this._iceGatheringHistory.push(this.iceGatheringState);
|
|
195
|
+
this._logProgress("icegatheringstatechange");
|
|
196
|
+
});
|
|
197
|
+
this.addEventListener("signalingstatechange", () => {
|
|
198
|
+
this._signalingHistory.push(this.signalingState);
|
|
199
|
+
this._logProgress("signalingstatechange");
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
export {
|
|
205
|
+
createDiagRTCPeerConnectionConstructor,
|
|
206
|
+
subscribeConnectionStatus,
|
|
207
|
+
subscribeFailureDiagnosis
|
|
208
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export type DiagRTCConnectionStatus = {
|
|
2
|
+
connectionState: RTCPeerConnection["connectionState"];
|
|
3
|
+
iceConnectionState: RTCPeerConnection["iceConnectionState"];
|
|
4
|
+
};
|
|
5
|
+
export type DiagRTCStats = {
|
|
6
|
+
totalNewConnections: number;
|
|
7
|
+
totalFailedConnections: number;
|
|
8
|
+
totalSuccessfulConnections: number;
|
|
9
|
+
totalClosedConnections: number;
|
|
10
|
+
details: Record<string, DiagRTCConnectionStatus>;
|
|
11
|
+
};
|
|
12
|
+
export type DiagRTCPeerConnectionInternalStateHistory = {
|
|
13
|
+
connectionHistory: RTCPeerConnection["connectionState"][];
|
|
14
|
+
iceConnectionHistory: RTCPeerConnection["iceConnectionState"][];
|
|
15
|
+
iceGatheringHistory: RTCPeerConnection["iceGatheringState"][];
|
|
16
|
+
signalingHistory: RTCPeerConnection["signalingState"][];
|
|
17
|
+
};
|
|
18
|
+
export declare const DiagRTCFailureReasonCodes: {
|
|
19
|
+
readonly ICE_GATHERING_NOT_COMPLETED: "ICE_GATHERING_NOT_COMPLETED";
|
|
20
|
+
readonly ICE_CONNECTIVITY_FAILED: "ICE_CONNECTIVITY_FAILED";
|
|
21
|
+
readonly STUN_REQUEST_TIMEOUT: "STUN_REQUEST_TIMEOUT";
|
|
22
|
+
readonly SIGNALING_NOT_STABLE: "SIGNALING_NOT_STABLE";
|
|
23
|
+
readonly CONNECTION_DROPPED_AFTER_ESTABLISHED: "CONNECTION_DROPPED_AFTER_ESTABLISHED";
|
|
24
|
+
readonly NETWORK_INTERRUPTED: "NETWORK_INTERRUPTED";
|
|
25
|
+
readonly UNKNOWN: "UNKNOWN";
|
|
26
|
+
};
|
|
27
|
+
export type DiagRTCFailureDiagnosis = {
|
|
28
|
+
reasonCode: keyof typeof DiagRTCFailureReasonCodes;
|
|
29
|
+
userMessage: string;
|
|
30
|
+
};
|
|
31
|
+
export type DiagRTCFailureStats = {
|
|
32
|
+
diagnosis: DiagRTCFailureDiagnosis;
|
|
33
|
+
stats: {
|
|
34
|
+
reportsCount: number;
|
|
35
|
+
selectedPair: {
|
|
36
|
+
id: string;
|
|
37
|
+
state: string;
|
|
38
|
+
localCandidateId: string;
|
|
39
|
+
remoteCandidateId: string;
|
|
40
|
+
currentRoundTripTime: number | "unknown";
|
|
41
|
+
totalRoundTripTime: number | "unknown";
|
|
42
|
+
requestsSent: number | "unknown";
|
|
43
|
+
responsesReceived: number | "unknown";
|
|
44
|
+
packetsDiscardedOnSend: number | "unknown";
|
|
45
|
+
bytesSent: number | "unknown";
|
|
46
|
+
bytesReceived: number | "unknown";
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
};
|
|
50
|
+
export type DiagRTCPeerConnectionMetrics = {
|
|
51
|
+
selectedPair: Record<string, unknown> | undefined;
|
|
52
|
+
selectedPairId: string;
|
|
53
|
+
state: string;
|
|
54
|
+
localCandidateId: string;
|
|
55
|
+
remoteCandidateId: string;
|
|
56
|
+
currentRoundTripTime: number | "unknown";
|
|
57
|
+
totalRoundTripTime: number | "unknown";
|
|
58
|
+
requestsSent: number | "unknown";
|
|
59
|
+
responsesReceived: number | "unknown";
|
|
60
|
+
packetsDiscardedOnSend: number | "unknown";
|
|
61
|
+
bytesSent: number | "unknown";
|
|
62
|
+
bytesReceived: number | "unknown";
|
|
63
|
+
reports: unknown[];
|
|
64
|
+
};
|