@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,298 @@
|
|
|
1
|
+
import { InjectableAPIService } from "../injectable/InjectableAPIService.js";
|
|
2
|
+
import { handlers } from "../../lib/HandlerUtils.js";
|
|
3
|
+
import { LOG_LEVEL_VERBOSE } from "../../../common/logger.js";
|
|
4
|
+
import { _activeDocument } from "../../../common/coreEnvFunctions.js";
|
|
5
|
+
class BrowserAPIService extends InjectableAPIService {
|
|
6
|
+
_confirmInstance;
|
|
7
|
+
commandBar = null;
|
|
8
|
+
commandButtons = /* @__PURE__ */ new Map();
|
|
9
|
+
logPanel = null;
|
|
10
|
+
logViewport = null;
|
|
11
|
+
maxLogLines = 300;
|
|
12
|
+
windowFactories = /* @__PURE__ */ new Map();
|
|
13
|
+
windowInstances = /* @__PURE__ */ new Map();
|
|
14
|
+
windowRoot = null;
|
|
15
|
+
windowTabs = null;
|
|
16
|
+
windowBody = null;
|
|
17
|
+
windowPanels = /* @__PURE__ */ new Map();
|
|
18
|
+
activeWindowType = null;
|
|
19
|
+
constructor(context, dependencies) {
|
|
20
|
+
super(context);
|
|
21
|
+
this._confirmInstance = dependencies.confirm;
|
|
22
|
+
this.addLog.setHandler((message, level, key) => {
|
|
23
|
+
if (level >= LOG_LEVEL_VERBOSE) {
|
|
24
|
+
this.appendLog(message, level, key);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
get confirm() {
|
|
29
|
+
return this._confirmInstance;
|
|
30
|
+
}
|
|
31
|
+
async showWindow(type) {
|
|
32
|
+
const factory = this.windowFactories.get(type);
|
|
33
|
+
if (!factory) {
|
|
34
|
+
this.appendLog(`Window type is not registered: ${type}`, "warn", "showWindow");
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
this.ensureWindowHost();
|
|
38
|
+
const panel = this.ensureWindowPanel(type);
|
|
39
|
+
this.activateWindow(type);
|
|
40
|
+
if (!this.windowInstances.has(type)) {
|
|
41
|
+
panel.replaceChildren();
|
|
42
|
+
const leaf = this.createLeafShim(type, panel);
|
|
43
|
+
const view = factory(leaf);
|
|
44
|
+
this.windowInstances.set(type, view);
|
|
45
|
+
if (view instanceof HTMLElement) {
|
|
46
|
+
panel.appendChild(view);
|
|
47
|
+
}
|
|
48
|
+
if (view && typeof view.onOpen === "function") {
|
|
49
|
+
await Promise.resolve(view.onOpen());
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
getCustomFetchHandler() {
|
|
54
|
+
return void 0;
|
|
55
|
+
}
|
|
56
|
+
isMobile() {
|
|
57
|
+
return false;
|
|
58
|
+
}
|
|
59
|
+
getAppID() {
|
|
60
|
+
return "browser-app";
|
|
61
|
+
}
|
|
62
|
+
getSystemVaultName = handlers().binder("getSystemVaultName");
|
|
63
|
+
getAppVersion() {
|
|
64
|
+
return `${MANIFEST_VERSION ?? "0.0.0."}`;
|
|
65
|
+
}
|
|
66
|
+
getPluginVersion() {
|
|
67
|
+
return `${MANIFEST_VERSION ?? "0.0.0."}`;
|
|
68
|
+
}
|
|
69
|
+
getPlatform() {
|
|
70
|
+
return "browser";
|
|
71
|
+
}
|
|
72
|
+
getCrypto() {
|
|
73
|
+
return globalThis.crypto;
|
|
74
|
+
}
|
|
75
|
+
nativeFetch(req, opts) {
|
|
76
|
+
return fetch(req, opts);
|
|
77
|
+
}
|
|
78
|
+
ensureLogPanel() {
|
|
79
|
+
if (this.logPanel && _activeDocument.body.contains(this.logPanel)) {
|
|
80
|
+
return this.logPanel;
|
|
81
|
+
}
|
|
82
|
+
let panel = _activeDocument.getElementById("livesync-log-panel");
|
|
83
|
+
let viewport = _activeDocument.getElementById("livesync-log-viewport");
|
|
84
|
+
if (!panel) {
|
|
85
|
+
panel = _activeDocument.createElement("div");
|
|
86
|
+
panel.id = "livesync-log-panel";
|
|
87
|
+
const header = _activeDocument.createElement("div");
|
|
88
|
+
header.textContent = "LiveSync Logs";
|
|
89
|
+
header.className = "livesync-log-header";
|
|
90
|
+
viewport = _activeDocument.createElement("div");
|
|
91
|
+
viewport.id = "livesync-log-viewport";
|
|
92
|
+
panel.appendChild(header);
|
|
93
|
+
panel.appendChild(viewport);
|
|
94
|
+
_activeDocument.body.appendChild(panel);
|
|
95
|
+
}
|
|
96
|
+
_activeDocument.body.classList.add("livesync-log-visible");
|
|
97
|
+
this.logPanel = panel;
|
|
98
|
+
this.logViewport = viewport;
|
|
99
|
+
return panel;
|
|
100
|
+
}
|
|
101
|
+
formatLogLine(message, level, key) {
|
|
102
|
+
let body;
|
|
103
|
+
if (typeof message === "string") {
|
|
104
|
+
body = message;
|
|
105
|
+
} else if (message instanceof Error) {
|
|
106
|
+
body = message.stack ?? message.message;
|
|
107
|
+
} else {
|
|
108
|
+
try {
|
|
109
|
+
body = JSON.stringify(message);
|
|
110
|
+
} catch {
|
|
111
|
+
body = String(message);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const timestamp = (/* @__PURE__ */ new Date()).toLocaleTimeString();
|
|
115
|
+
const levelLabel = level === void 0 || level === null ? "LOG" : String(level);
|
|
116
|
+
const keyLabel = key ? ` [${key}]` : "";
|
|
117
|
+
return `${timestamp} [${levelLabel}]${keyLabel} ${body}`;
|
|
118
|
+
}
|
|
119
|
+
appendLog(message, level, key) {
|
|
120
|
+
this.ensureLogPanel();
|
|
121
|
+
if (!this.logViewport) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
const line = _activeDocument.createElement("div");
|
|
125
|
+
line.textContent = this.formatLogLine(message, level, key);
|
|
126
|
+
line.className = "livesync-log-line";
|
|
127
|
+
this.logViewport.appendChild(line);
|
|
128
|
+
while (this.logViewport.childElementCount > this.maxLogLines) {
|
|
129
|
+
this.logViewport.removeChild(this.logViewport.firstElementChild);
|
|
130
|
+
}
|
|
131
|
+
this.logViewport.scrollTop = this.logViewport.scrollHeight;
|
|
132
|
+
}
|
|
133
|
+
ensureCommandBar() {
|
|
134
|
+
if (this.commandBar && _activeDocument.body.contains(this.commandBar)) {
|
|
135
|
+
return this.commandBar;
|
|
136
|
+
}
|
|
137
|
+
let host = _activeDocument.getElementById("livesync-command-bar");
|
|
138
|
+
if (!host) {
|
|
139
|
+
host = _activeDocument.createElement("div");
|
|
140
|
+
host.id = "livesync-command-bar";
|
|
141
|
+
_activeDocument.body.appendChild(host);
|
|
142
|
+
}
|
|
143
|
+
this.commandBar = host;
|
|
144
|
+
return host;
|
|
145
|
+
}
|
|
146
|
+
ensureWindowHost() {
|
|
147
|
+
if (this.windowRoot && _activeDocument.body.contains(this.windowRoot)) {
|
|
148
|
+
return this.windowRoot;
|
|
149
|
+
}
|
|
150
|
+
let root = _activeDocument.getElementById("livesync-window-root");
|
|
151
|
+
if (!root) {
|
|
152
|
+
root = _activeDocument.createElement("div");
|
|
153
|
+
root.id = "livesync-window-root";
|
|
154
|
+
const tabs = _activeDocument.createElement("div");
|
|
155
|
+
tabs.id = "livesync-window-tabs";
|
|
156
|
+
const body = _activeDocument.createElement("div");
|
|
157
|
+
body.id = "livesync-window-body";
|
|
158
|
+
root.appendChild(tabs);
|
|
159
|
+
root.appendChild(body);
|
|
160
|
+
_activeDocument.body.appendChild(root);
|
|
161
|
+
}
|
|
162
|
+
this.windowRoot = root;
|
|
163
|
+
this.windowTabs = _activeDocument.getElementById("livesync-window-tabs");
|
|
164
|
+
this.windowBody = _activeDocument.getElementById("livesync-window-body");
|
|
165
|
+
return root;
|
|
166
|
+
}
|
|
167
|
+
ensureWindowTab(type) {
|
|
168
|
+
this.ensureWindowHost();
|
|
169
|
+
const existing = this.windowTabs.querySelector(`[data-window-tab="${type}"]`);
|
|
170
|
+
if (existing) {
|
|
171
|
+
return existing;
|
|
172
|
+
}
|
|
173
|
+
const tab = _activeDocument.createElement("button");
|
|
174
|
+
tab.type = "button";
|
|
175
|
+
tab.dataset.windowTab = type;
|
|
176
|
+
tab.textContent = type;
|
|
177
|
+
tab.className = "livesync-window-tab";
|
|
178
|
+
tab.onclick = () => {
|
|
179
|
+
void this.showWindow(type);
|
|
180
|
+
};
|
|
181
|
+
this.windowTabs.appendChild(tab);
|
|
182
|
+
return tab;
|
|
183
|
+
}
|
|
184
|
+
ensureWindowPanel(type) {
|
|
185
|
+
this.ensureWindowHost();
|
|
186
|
+
const existing = this.windowPanels.get(type);
|
|
187
|
+
if (existing) {
|
|
188
|
+
return existing;
|
|
189
|
+
}
|
|
190
|
+
const panel = _activeDocument.createElement("div");
|
|
191
|
+
panel.dataset.windowPanel = type;
|
|
192
|
+
panel.className = "livesync-window-panel";
|
|
193
|
+
this.windowBody.appendChild(panel);
|
|
194
|
+
this.windowPanels.set(type, panel);
|
|
195
|
+
this.ensureWindowTab(type);
|
|
196
|
+
return panel;
|
|
197
|
+
}
|
|
198
|
+
activateWindow(type) {
|
|
199
|
+
this.activeWindowType = type;
|
|
200
|
+
for (const [windowType, panel] of this.windowPanels.entries()) {
|
|
201
|
+
panel.classList.toggle("is-active", windowType === type);
|
|
202
|
+
}
|
|
203
|
+
this.windowTabs?.querySelectorAll("button[data-window-tab]").forEach((tab) => {
|
|
204
|
+
const isActive = tab.dataset.windowTab === type;
|
|
205
|
+
tab.classList.toggle("is-active", isActive);
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
createLeafShim(type, panel) {
|
|
209
|
+
return {
|
|
210
|
+
type,
|
|
211
|
+
containerEl: panel,
|
|
212
|
+
view: void 0,
|
|
213
|
+
setViewState: async (state) => {
|
|
214
|
+
if (state?.type && state.type !== type) {
|
|
215
|
+
await this.showWindow(state.type);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
evaluateEnabled(command) {
|
|
221
|
+
if (command.checkCallback) {
|
|
222
|
+
try {
|
|
223
|
+
return command.checkCallback(true) === true;
|
|
224
|
+
} catch {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return true;
|
|
229
|
+
}
|
|
230
|
+
executeCommand(command) {
|
|
231
|
+
const enabled = this.evaluateEnabled(command);
|
|
232
|
+
if (!enabled) {
|
|
233
|
+
console.warn(`[BrowserAPIService] Command is not enabled: ${command.id}`);
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
if (command.checkCallback) {
|
|
238
|
+
const canRun = command.checkCallback(false);
|
|
239
|
+
if (canRun === false) {
|
|
240
|
+
return;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (command.callback) {
|
|
244
|
+
void Promise.resolve(command.callback()).catch((error) => {
|
|
245
|
+
console.error(`[BrowserAPIService] Command failed: ${command.id}`, error);
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
} catch (error) {
|
|
249
|
+
console.error(`[BrowserAPIService] Command failed: ${command.id}`, error);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
refreshCommandStates() {
|
|
253
|
+
for (const [id, button] of this.commandButtons.entries()) {
|
|
254
|
+
const command = button.__command;
|
|
255
|
+
if (!command) {
|
|
256
|
+
continue;
|
|
257
|
+
}
|
|
258
|
+
const enabled = this.evaluateEnabled(command);
|
|
259
|
+
button.disabled = !enabled;
|
|
260
|
+
button.classList.toggle("is-disabled", !enabled);
|
|
261
|
+
if (!enabled && !button.title) {
|
|
262
|
+
button.title = id;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
addCommand(command) {
|
|
267
|
+
const bar = this.ensureCommandBar();
|
|
268
|
+
const key = command.id || command.name;
|
|
269
|
+
let button = this.commandButtons.get(key);
|
|
270
|
+
if (!button) {
|
|
271
|
+
button = _activeDocument.createElement("button");
|
|
272
|
+
button.type = "button";
|
|
273
|
+
button.className = "livesync-command-button";
|
|
274
|
+
bar.appendChild(button);
|
|
275
|
+
this.commandButtons.set(key, button);
|
|
276
|
+
}
|
|
277
|
+
button.textContent = command.name || command.id;
|
|
278
|
+
button.title = command.id;
|
|
279
|
+
button.__command = command;
|
|
280
|
+
button.onclick = () => this.executeCommand(command);
|
|
281
|
+
return command;
|
|
282
|
+
}
|
|
283
|
+
addRibbonIcon(icon, title, callback) {
|
|
284
|
+
return _activeDocument.createElement("div");
|
|
285
|
+
}
|
|
286
|
+
registerWindow(type, factory) {
|
|
287
|
+
this.windowFactories.set(type, factory);
|
|
288
|
+
this.ensureWindowPanel(type);
|
|
289
|
+
}
|
|
290
|
+
registerProtocolHandler(action, handler) {
|
|
291
|
+
}
|
|
292
|
+
addStatusBarItem() {
|
|
293
|
+
return void 0;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
export {
|
|
297
|
+
BrowserAPIService
|
|
298
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
2
|
+
import { KeyValueDBService } from "../../base/KeyValueDBService.js";
|
|
3
|
+
import { DatabaseService } from "../../base/DatabaseService.js";
|
|
4
|
+
export declare class BrowserDatabaseService<T extends ServiceContext> extends DatabaseService<T> {
|
|
5
|
+
}
|
|
6
|
+
export declare class BrowserKeyValueDBService<T extends ServiceContext> extends KeyValueDBService<T> {
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeyValueDBService } from "../../base/KeyValueDBService.js";
|
|
2
|
+
import { DatabaseService } from "../../base/DatabaseService.js";
|
|
3
|
+
class BrowserDatabaseService extends DatabaseService {
|
|
4
|
+
}
|
|
5
|
+
class BrowserKeyValueDBService extends KeyValueDBService {
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
BrowserDatabaseService,
|
|
9
|
+
BrowserKeyValueDBService
|
|
10
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ConfigService } from "../../base/ConfigService.js";
|
|
2
|
+
import type { IAPIService, ISettingService } from "../../base/IService.js";
|
|
3
|
+
import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
4
|
+
import { createInstanceLogFunction } from "../../lib/logUtils.js";
|
|
5
|
+
export interface ConfigServiceBrowserCompatDependencies {
|
|
6
|
+
settingService: ISettingService;
|
|
7
|
+
APIService: IAPIService;
|
|
8
|
+
}
|
|
9
|
+
export declare class ConfigServiceBrowserCompat<T extends ServiceContext = ServiceContext> extends ConfigService<T> {
|
|
10
|
+
private _settingService;
|
|
11
|
+
_log: ReturnType<typeof createInstanceLogFunction>;
|
|
12
|
+
constructor(context: T, dependencies: ConfigServiceBrowserCompatDependencies);
|
|
13
|
+
getSmallConfig(key: string): string;
|
|
14
|
+
setSmallConfig(key: string, value: string): void;
|
|
15
|
+
deleteSmallConfig(key: string): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ConfigService } from "../../base/ConfigService.js";
|
|
2
|
+
import { createInstanceLogFunction } from "../../lib/logUtils.js";
|
|
3
|
+
class ConfigServiceBrowserCompat extends ConfigService {
|
|
4
|
+
_settingService;
|
|
5
|
+
_log;
|
|
6
|
+
constructor(context, dependencies) {
|
|
7
|
+
super(context);
|
|
8
|
+
this._settingService = dependencies.settingService;
|
|
9
|
+
this._log = createInstanceLogFunction("ConfigService", dependencies.APIService);
|
|
10
|
+
}
|
|
11
|
+
getSmallConfig(key) {
|
|
12
|
+
return this._settingService.getSmallConfig(key);
|
|
13
|
+
}
|
|
14
|
+
setSmallConfig(key, value) {
|
|
15
|
+
return this._settingService.setSmallConfig(key, value);
|
|
16
|
+
}
|
|
17
|
+
deleteSmallConfig(key) {
|
|
18
|
+
return this._settingService.deleteSmallConfig(key);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export {
|
|
22
|
+
ConfigServiceBrowserCompat
|
|
23
|
+
};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
2
|
+
import { InjectableAPIService } from "../injectable/InjectableAPIService.js";
|
|
3
|
+
import type { FetchHttpHandler } from "@smithy/fetch-http-handler";
|
|
4
|
+
import type { ICommandCompat } from "../../base/IService.js";
|
|
5
|
+
import type { Confirm } from "../../../interfaces/Confirm.js";
|
|
6
|
+
/**
|
|
7
|
+
* Headless implementation of Confirm that returns sensible defaults instead
|
|
8
|
+
* of throwing. Dialogs are logged to stderr so the prompts are visible in
|
|
9
|
+
* service logs, and the default/conservative action is taken automatically.
|
|
10
|
+
*/
|
|
11
|
+
export declare class HeadlessConfirm implements Confirm {
|
|
12
|
+
askYesNo(message: string): Promise<"yes" | "no">;
|
|
13
|
+
askString(title: string, key: string, placeholder: string, isPassword?: boolean): Promise<string | false>;
|
|
14
|
+
askYesNoDialog(message: string, opt: {
|
|
15
|
+
title?: string;
|
|
16
|
+
defaultOption?: "Yes" | "No";
|
|
17
|
+
timeout?: number;
|
|
18
|
+
}): Promise<"yes" | "no">;
|
|
19
|
+
askSelectString(message: string, items: string[]): Promise<string>;
|
|
20
|
+
askSelectStringDialogue<T extends readonly string[]>(message: string, buttons: T, opt: {
|
|
21
|
+
title?: string;
|
|
22
|
+
defaultAction: T[number];
|
|
23
|
+
timeout?: number;
|
|
24
|
+
}): Promise<T[number] | false>;
|
|
25
|
+
askInPopup(key: string, dialogText: string, anchorCallback: (anchor: HTMLAnchorElement) => void): void;
|
|
26
|
+
confirmWithMessage(title: string, contentMd: string, buttons: string[], defaultAction: (typeof buttons)[number], timeout?: number): Promise<(typeof buttons)[number] | false>;
|
|
27
|
+
}
|
|
28
|
+
export declare class HeadlessAPIService<T extends ServiceContext> extends InjectableAPIService<T> {
|
|
29
|
+
private _confirmInstance;
|
|
30
|
+
private _systemVaultName;
|
|
31
|
+
constructor(context: T);
|
|
32
|
+
get confirm(): Confirm;
|
|
33
|
+
showWindow(type: string): Promise<void>;
|
|
34
|
+
getCustomFetchHandler(): FetchHttpHandler;
|
|
35
|
+
isMobile(): boolean;
|
|
36
|
+
getAppID(): string;
|
|
37
|
+
getAppVersion(): string;
|
|
38
|
+
getPluginVersion(): string;
|
|
39
|
+
getPlatform(): string;
|
|
40
|
+
getCrypto(): Crypto;
|
|
41
|
+
addCommand<TCommand extends ICommandCompat>(command: TCommand): TCommand;
|
|
42
|
+
addRibbonIcon(icon: string, title: string, callback: (evt: MouseEvent) => any): HTMLElement;
|
|
43
|
+
registerWindow(type: string, factory: (leaf: any) => any): void;
|
|
44
|
+
registerProtocolHandler(action: string, handler: (params: Record<string, string>) => any): void;
|
|
45
|
+
addStatusBarItem(): HTMLElement | undefined;
|
|
46
|
+
private toSafeKeyPart;
|
|
47
|
+
private hash32;
|
|
48
|
+
private deriveSystemVaultName;
|
|
49
|
+
getSystemVaultName(): string;
|
|
50
|
+
get isOnline(): boolean;
|
|
51
|
+
nativeFetch(req: string | Request, opts?: RequestInit): Promise<Response>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { InjectableAPIService } from "../injectable/InjectableAPIService.js";
|
|
2
|
+
import module from "node:crypto";
|
|
3
|
+
import { _activeDocument } from "../../../common/coreEnvFunctions.js";
|
|
4
|
+
class HeadlessConfirm {
|
|
5
|
+
askYesNo(message) {
|
|
6
|
+
console.error(`[Headless] ${message} \u2192 no`);
|
|
7
|
+
return Promise.resolve("no");
|
|
8
|
+
}
|
|
9
|
+
askString(title, key, placeholder, isPassword) {
|
|
10
|
+
console.error(`[Headless] String input required: ${title} \u2192 declined`);
|
|
11
|
+
return Promise.resolve(false);
|
|
12
|
+
}
|
|
13
|
+
askYesNoDialog(message, opt) {
|
|
14
|
+
const result = opt.defaultOption === "Yes" ? "yes" : "no";
|
|
15
|
+
console.error(`[Headless] ${opt.title ?? "Confirm"}: ${message} \u2192 ${result}`);
|
|
16
|
+
return Promise.resolve(result);
|
|
17
|
+
}
|
|
18
|
+
askSelectString(message, items) {
|
|
19
|
+
console.error(`[Headless] ${message} \u2192 ${items[0]}`);
|
|
20
|
+
return Promise.resolve(items[0]);
|
|
21
|
+
}
|
|
22
|
+
askSelectStringDialogue(message, buttons, opt) {
|
|
23
|
+
console.error(`[Headless] ${opt.title ?? "Confirm"}: ${message} \u2192 ${String(opt.defaultAction)}`);
|
|
24
|
+
return Promise.resolve(opt.defaultAction);
|
|
25
|
+
}
|
|
26
|
+
askInPopup(key, dialogText, anchorCallback) {
|
|
27
|
+
console.error(`[Headless] Popup (${key}): ${dialogText}`);
|
|
28
|
+
}
|
|
29
|
+
confirmWithMessage(title, contentMd, buttons, defaultAction, timeout) {
|
|
30
|
+
console.error(`[Headless] ${title}: ${contentMd} \u2192 ${defaultAction}`);
|
|
31
|
+
return Promise.resolve(defaultAction);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
class HeadlessAPIService extends InjectableAPIService {
|
|
35
|
+
_confirmInstance;
|
|
36
|
+
_systemVaultName;
|
|
37
|
+
constructor(context) {
|
|
38
|
+
super(context);
|
|
39
|
+
this._confirmInstance = new HeadlessConfirm();
|
|
40
|
+
}
|
|
41
|
+
get confirm() {
|
|
42
|
+
return this._confirmInstance;
|
|
43
|
+
}
|
|
44
|
+
showWindow(type) {
|
|
45
|
+
return Promise.resolve();
|
|
46
|
+
}
|
|
47
|
+
getCustomFetchHandler() {
|
|
48
|
+
return void 0;
|
|
49
|
+
}
|
|
50
|
+
isMobile() {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
getAppID() {
|
|
54
|
+
return "headless-app";
|
|
55
|
+
}
|
|
56
|
+
getAppVersion() {
|
|
57
|
+
return `${MANIFEST_VERSION ?? "0.0.0."}`;
|
|
58
|
+
}
|
|
59
|
+
getPluginVersion() {
|
|
60
|
+
return `${MANIFEST_VERSION ?? "0.0.0."}`;
|
|
61
|
+
}
|
|
62
|
+
getPlatform() {
|
|
63
|
+
return "server";
|
|
64
|
+
}
|
|
65
|
+
getCrypto() {
|
|
66
|
+
const webcrypto = module.webcrypto;
|
|
67
|
+
return webcrypto;
|
|
68
|
+
}
|
|
69
|
+
addCommand(command) {
|
|
70
|
+
return command;
|
|
71
|
+
}
|
|
72
|
+
addRibbonIcon(icon, title, callback) {
|
|
73
|
+
return _activeDocument?.createElement("div") || {};
|
|
74
|
+
}
|
|
75
|
+
registerWindow(type, factory) {
|
|
76
|
+
}
|
|
77
|
+
registerProtocolHandler(action, handler) {
|
|
78
|
+
}
|
|
79
|
+
addStatusBarItem() {
|
|
80
|
+
return void 0;
|
|
81
|
+
}
|
|
82
|
+
toSafeKeyPart(value) {
|
|
83
|
+
const trimmed = value.trim();
|
|
84
|
+
if (trimmed === "") {
|
|
85
|
+
return "vault";
|
|
86
|
+
}
|
|
87
|
+
return trimmed.replace(/[^a-zA-Z0-9._-]/g, "_");
|
|
88
|
+
}
|
|
89
|
+
hash32(value) {
|
|
90
|
+
let hash = 2166136261;
|
|
91
|
+
for (let i = 0; i < value.length; i++) {
|
|
92
|
+
hash ^= value.charCodeAt(i);
|
|
93
|
+
hash = Math.imul(hash, 16777619);
|
|
94
|
+
}
|
|
95
|
+
return (hash >>> 0).toString(16).padStart(8, "0");
|
|
96
|
+
}
|
|
97
|
+
deriveSystemVaultName() {
|
|
98
|
+
const contextLike = this.context;
|
|
99
|
+
const explicitName = contextLike.vaultName;
|
|
100
|
+
if (typeof explicitName === "string" && explicitName.trim() !== "") {
|
|
101
|
+
return this.toSafeKeyPart(explicitName);
|
|
102
|
+
}
|
|
103
|
+
const vaultPath = contextLike.vaultPath;
|
|
104
|
+
if (typeof vaultPath === "string" && vaultPath.trim() !== "") {
|
|
105
|
+
const normalised = vaultPath.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
106
|
+
const leaf = normalised.split("/").filter((e) => e !== "").pop() ?? "vault";
|
|
107
|
+
return `${this.toSafeKeyPart(leaf)}-${this.hash32(normalised)}`;
|
|
108
|
+
}
|
|
109
|
+
return "headless-vault";
|
|
110
|
+
}
|
|
111
|
+
getSystemVaultName() {
|
|
112
|
+
if (!this._systemVaultName) {
|
|
113
|
+
this._systemVaultName = this.deriveSystemVaultName();
|
|
114
|
+
}
|
|
115
|
+
return this._systemVaultName;
|
|
116
|
+
}
|
|
117
|
+
get isOnline() {
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
nativeFetch(req, opts) {
|
|
121
|
+
return fetch(req, opts);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
export {
|
|
125
|
+
HeadlessAPIService,
|
|
126
|
+
HeadlessConfirm
|
|
127
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { KeyValueDBService } from "../../base/KeyValueDBService.js";
|
|
2
|
+
import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
3
|
+
import { DatabaseService } from "../../base/DatabaseService.js";
|
|
4
|
+
export declare class HeadlessDatabaseService<T extends ServiceContext> extends DatabaseService<T> {
|
|
5
|
+
}
|
|
6
|
+
export declare class HeadlessKeyValueDBService<T extends ServiceContext> extends KeyValueDBService<T> {
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { KeyValueDBService } from "../../base/KeyValueDBService.js";
|
|
2
|
+
import { DatabaseService } from "../../base/DatabaseService.js";
|
|
3
|
+
class HeadlessDatabaseService extends DatabaseService {
|
|
4
|
+
}
|
|
5
|
+
class HeadlessKeyValueDBService extends KeyValueDBService {
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
HeadlessDatabaseService,
|
|
9
|
+
HeadlessKeyValueDBService
|
|
10
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { APIService } from "../../base/APIService.js";
|
|
2
|
+
import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
3
|
+
export declare abstract class InjectableAPIService<T extends ServiceContext> extends APIService<T> {
|
|
4
|
+
addLog: import("../../lib/HandlerUtils.js").HandlerFunction<(message: unknown, level: import("octagonal-wheels/common/logger").LOG_LEVEL, key?: string) => void, unknown>;
|
|
5
|
+
getPlatform(): string;
|
|
6
|
+
getCrypto(): Crypto;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { APIService } from "../../base/APIService.js";
|
|
2
|
+
import { handlers } from "../../lib/HandlerUtils.js";
|
|
3
|
+
class InjectableAPIService extends APIService {
|
|
4
|
+
addLog = handlers().binder("addLog");
|
|
5
|
+
// isLastPostFailedDueToPayloadSize = handlers<IAPIService>().binder("isLastPostFailedDueToPayloadSize");
|
|
6
|
+
getPlatform() {
|
|
7
|
+
return "unknown";
|
|
8
|
+
}
|
|
9
|
+
getCrypto() {
|
|
10
|
+
if (typeof crypto !== "undefined") {
|
|
11
|
+
return crypto;
|
|
12
|
+
}
|
|
13
|
+
throw new Error("Crypto API is not available in this environment.");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
InjectableAPIService
|
|
18
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { AppLifecycleService } from "../../base/AppLifecycleService.js";
|
|
2
|
+
import type { IAppLifecycleService } from "../../base/IService.js";
|
|
3
|
+
import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
4
|
+
export declare abstract class AppLifecycleServiceBase<T extends ServiceContext> extends AppLifecycleService<T> {
|
|
5
|
+
askRestart: import("../../lib/HandlerUtils.js").HandlerFunction<(message?: string) => void, unknown>;
|
|
6
|
+
scheduleRestart: import("../../lib/HandlerUtils.js").HandlerFunction<() => void, unknown>;
|
|
7
|
+
isReloadingScheduled: import("../../lib/HandlerUtils.js").HandlerFunction<() => boolean, unknown>;
|
|
8
|
+
}
|
|
9
|
+
export declare abstract class InjectableAppLifecycleService<T extends ServiceContext = ServiceContext> extends AppLifecycleServiceBase<T> implements IAppLifecycleService {
|
|
10
|
+
performRestart: import("../../lib/HandlerUtils.js").HandlerFunction<() => void, unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { AppLifecycleService } from "../../base/AppLifecycleService.js";
|
|
2
|
+
import { handlers } from "../../lib/HandlerUtils.js";
|
|
3
|
+
class AppLifecycleServiceBase extends AppLifecycleService {
|
|
4
|
+
askRestart = handlers().binder("askRestart");
|
|
5
|
+
scheduleRestart = handlers().binder("scheduleRestart");
|
|
6
|
+
isReloadingScheduled = handlers().binder("isReloadingScheduled");
|
|
7
|
+
}
|
|
8
|
+
class InjectableAppLifecycleService extends AppLifecycleServiceBase {
|
|
9
|
+
performRestart = handlers().binder("performRestart");
|
|
10
|
+
}
|
|
11
|
+
export {
|
|
12
|
+
AppLifecycleServiceBase,
|
|
13
|
+
InjectableAppLifecycleService
|
|
14
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConflictService } from "../../base/ConflictService.js";
|
|
2
|
+
import type { ServiceContext } from "../../base/ServiceBase.js";
|
|
3
|
+
export declare class InjectableConflictService<T extends ServiceContext> extends ConflictService<T> {
|
|
4
|
+
queueCheckForIfOpen: import("../../lib/HandlerUtils.js").HandlerFunction<(path: import("../../../common/types.js").FilePathWithPrefix) => Promise<void>, unknown>;
|
|
5
|
+
queueCheckFor: import("../../lib/HandlerUtils.js").HandlerFunction<(path: import("../../../common/types.js").FilePathWithPrefix) => Promise<void>, unknown>;
|
|
6
|
+
ensureAllProcessed: import("../../lib/HandlerUtils.js").HandlerFunction<() => Promise<boolean>, unknown>;
|
|
7
|
+
resolveByDeletingRevision: import("../../lib/HandlerUtils.js").HandlerFunction<(path: import("../../../common/types.js").FilePathWithPrefix, deleteRevision: string, title: string) => Promise<typeof import("../../../common/types.js").MISSING_OR_ERROR | typeof import("../../../common/types.js").AUTO_MERGED>, unknown>;
|
|
8
|
+
resolve: import("../../lib/HandlerUtils.js").HandlerFunction<(filename: import("../../../common/types.js").FilePathWithPrefix) => Promise<void>, unknown>;
|
|
9
|
+
resolveByNewest: import("../../lib/HandlerUtils.js").HandlerFunction<(filename: import("../../../common/types.js").FilePathWithPrefix) => Promise<boolean>, unknown>;
|
|
10
|
+
resolveAllConflictedFilesByNewerOnes: import("../../lib/HandlerUtils.js").HandlerFunction<() => Promise<void>, unknown>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ConflictService } from "../../base/ConflictService.js";
|
|
2
|
+
import { handlers } from "../../lib/HandlerUtils.js";
|
|
3
|
+
class InjectableConflictService extends ConflictService {
|
|
4
|
+
queueCheckForIfOpen = handlers().binder("queueCheckForIfOpen");
|
|
5
|
+
queueCheckFor = handlers().binder("queueCheckFor");
|
|
6
|
+
ensureAllProcessed = handlers().binder("ensureAllProcessed");
|
|
7
|
+
resolveByDeletingRevision = handlers().binder("resolveByDeletingRevision");
|
|
8
|
+
resolve = handlers().binder("resolve");
|
|
9
|
+
resolveByNewest = handlers().binder("resolveByNewest");
|
|
10
|
+
resolveAllConflictedFilesByNewerOnes = handlers().binder("resolveAllConflictedFilesByNewerOnes");
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
InjectableConflictService
|
|
14
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DatabaseEventService } from "../../base/DatabaseEventService.js";
|
|
2
|
+
class InjectableDatabaseEventService extends DatabaseEventService {
|
|
3
|
+
// initialiseDatabase = handlers<IDatabaseEventService>().binder("initialiseDatabase");
|
|
4
|
+
}
|
|
5
|
+
export {
|
|
6
|
+
InjectableDatabaseEventService
|
|
7
|
+
};
|