@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
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Adapter interface for type guard operations in StorageEventManager
|
|
3
|
+
*
|
|
4
|
+
* @template TFile - Platform-specific file type
|
|
5
|
+
* @template TFolder - Platform-specific folder type
|
|
6
|
+
*/
|
|
7
|
+
export interface IStorageEventTypeGuardAdapter<TFile, TFolder> {
|
|
8
|
+
/**
|
|
9
|
+
* Check if the given item is a file
|
|
10
|
+
*/
|
|
11
|
+
isFile(file: unknown): file is TFile;
|
|
12
|
+
/**
|
|
13
|
+
* Check if the given item is a folder
|
|
14
|
+
*/
|
|
15
|
+
isFolder(item: unknown): item is TFolder;
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FilePath } from "../../common/types.js";
|
|
2
|
+
/**
|
|
3
|
+
* Event handlers for storage events
|
|
4
|
+
*/
|
|
5
|
+
export interface IStorageEventWatchHandlers<TFile = unknown, TCtx = unknown> {
|
|
6
|
+
onCreate: (file: TFile, ctx?: TCtx) => void;
|
|
7
|
+
onChange: (file: TFile, ctx?: TCtx) => void;
|
|
8
|
+
onDelete: (file: TFile, ctx?: TCtx) => void;
|
|
9
|
+
onRename: (file: TFile, oldPath: string, ctx?: TCtx) => void;
|
|
10
|
+
onRaw: (path: FilePath) => void;
|
|
11
|
+
onEditorChange?: <TEditor = unknown, TInfo = unknown>(editor: TEditor, info: TInfo) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Adapter interface for watching vault/storage events
|
|
15
|
+
*/
|
|
16
|
+
export interface IStorageEventWatchAdapter<TFile = unknown, TCtx = unknown> {
|
|
17
|
+
/**
|
|
18
|
+
* Begin watching for storage events
|
|
19
|
+
*/
|
|
20
|
+
beginWatch(handlers: IStorageEventWatchHandlers<TFile, TCtx>): Promise<void>;
|
|
21
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export type { IStorageEventTypeGuardAdapter } from "./IStorageEventTypeGuardAdapter.js";
|
|
2
|
+
export type { IStorageEventPersistenceAdapter } from "./IStorageEventPersistenceAdapter.js";
|
|
3
|
+
export type { IStorageEventWatchAdapter, IStorageEventWatchHandlers } from "./IStorageEventWatchAdapter.js";
|
|
4
|
+
export type { IStorageEventStatusAdapter } from "./IStorageEventStatusAdapter.js";
|
|
5
|
+
export type { IStorageEventConverterAdapter } from "./IStorageEventConverterAdapter.js";
|
|
6
|
+
export type { IStorageEventManagerAdapter } from "./IStorageEventManagerAdapter.js";
|
|
File without changes
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { LOG_LEVEL } from "../common/types.js";
|
|
2
|
+
export type LockStats = {
|
|
3
|
+
pending: string[];
|
|
4
|
+
running: string[];
|
|
5
|
+
count: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const lockStats: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<{
|
|
8
|
+
pending: any[];
|
|
9
|
+
running: any[];
|
|
10
|
+
count: number;
|
|
11
|
+
}>;
|
|
12
|
+
export declare const collectingChunks: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
|
|
13
|
+
export declare const pluginScanningCount: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
|
|
14
|
+
export declare const hiddenFilesProcessingCount: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
|
|
15
|
+
export declare const hiddenFilesEventCount: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
|
|
16
|
+
export type LogEntry = {
|
|
17
|
+
message: string | Error;
|
|
18
|
+
level?: LOG_LEVEL;
|
|
19
|
+
key?: string;
|
|
20
|
+
};
|
|
21
|
+
export declare const logMessages: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<string[]>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { reactiveSource } from "octagonal-wheels/dataobject/reactive";
|
|
2
|
+
const lockStats = reactiveSource({ pending: [], running: [], count: 0 });
|
|
3
|
+
const collectingChunks = reactiveSource(0);
|
|
4
|
+
const pluginScanningCount = reactiveSource(0);
|
|
5
|
+
const hiddenFilesProcessingCount = reactiveSource(0);
|
|
6
|
+
const hiddenFilesEventCount = reactiveSource(0);
|
|
7
|
+
const logMessages = reactiveSource([]);
|
|
8
|
+
export {
|
|
9
|
+
collectingChunks,
|
|
10
|
+
hiddenFilesEventCount,
|
|
11
|
+
hiddenFilesProcessingCount,
|
|
12
|
+
lockStats,
|
|
13
|
+
logMessages,
|
|
14
|
+
pluginScanningCount
|
|
15
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare class WrappedNotice {
|
|
2
|
+
constructor(message: string | DocumentFragment, timeout?: number);
|
|
3
|
+
setMessage(message: string | DocumentFragment): this;
|
|
4
|
+
hide(): void;
|
|
5
|
+
}
|
|
6
|
+
export declare function setNoticeClass(notice: typeof WrappedNotice): void;
|
|
7
|
+
export declare function NewNotice(message: string | DocumentFragment, timeout?: number): WrappedNotice;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { Logger } from "../common/logger.js";
|
|
2
|
+
import { LOG_LEVEL_NOTICE } from "../common/types.js";
|
|
3
|
+
class WrappedNotice {
|
|
4
|
+
constructor(message, timeout) {
|
|
5
|
+
let strMessage = "";
|
|
6
|
+
if (message instanceof DocumentFragment) {
|
|
7
|
+
strMessage = message.textContent ?? "";
|
|
8
|
+
} else {
|
|
9
|
+
strMessage = message;
|
|
10
|
+
}
|
|
11
|
+
Logger(strMessage, LOG_LEVEL_NOTICE);
|
|
12
|
+
}
|
|
13
|
+
setMessage(message) {
|
|
14
|
+
let strMessage = "";
|
|
15
|
+
if (message instanceof DocumentFragment) {
|
|
16
|
+
strMessage = message.textContent ?? "";
|
|
17
|
+
} else {
|
|
18
|
+
strMessage = message;
|
|
19
|
+
}
|
|
20
|
+
Logger(strMessage, LOG_LEVEL_NOTICE);
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
hide() {
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
let _notice = WrappedNotice;
|
|
27
|
+
function setNoticeClass(notice) {
|
|
28
|
+
_notice = notice;
|
|
29
|
+
}
|
|
30
|
+
function NewNotice(message, timeout) {
|
|
31
|
+
return new _notice(message, timeout);
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
NewNotice,
|
|
35
|
+
WrappedNotice,
|
|
36
|
+
setNoticeClass
|
|
37
|
+
};
|
package/dist/mods.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getWebCrypto(): Promise<Crypto>;
|
package/dist/mods.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { compatGlobal } from "./common/coreEnvFunctions.js";
|
|
2
|
+
let webcrypto;
|
|
3
|
+
async function getWebCrypto() {
|
|
4
|
+
if (webcrypto) {
|
|
5
|
+
return webcrypto;
|
|
6
|
+
}
|
|
7
|
+
if (compatGlobal.crypto) {
|
|
8
|
+
webcrypto = compatGlobal.crypto;
|
|
9
|
+
return webcrypto;
|
|
10
|
+
} else {
|
|
11
|
+
const module = await import("crypto");
|
|
12
|
+
webcrypto = module.webcrypto;
|
|
13
|
+
return webcrypto;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
export {
|
|
17
|
+
getWebCrypto
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FileSystemAccessStorageAdapter, createFileSystemAccessStorage, validateStoragePath, type CreateFileSystemAccessStorageOptions, type FileSystemAccessStorageStat, } from "./storage.js";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { UXDataWriteOptions, UXStat } from "../../common/types.js";
|
|
2
|
+
import type { IStorageAdapter } from "../../serviceModules/adapters/IStorageAdapter.js";
|
|
3
|
+
export type FileSystemAccessStorageStat = UXStat;
|
|
4
|
+
export interface CreateFileSystemAccessStorageOptions {
|
|
5
|
+
/** A directory handle already selected and authorised by the host application. */
|
|
6
|
+
rootHandle: FileSystemDirectoryHandle;
|
|
7
|
+
}
|
|
8
|
+
/** Rooted storage adapter backed by the browser File System Access API. */
|
|
9
|
+
export declare class FileSystemAccessStorageAdapter implements IStorageAdapter<FileSystemAccessStorageStat> {
|
|
10
|
+
private readonly rootHandle;
|
|
11
|
+
constructor(rootHandle: FileSystemDirectoryHandle);
|
|
12
|
+
private resolvePath;
|
|
13
|
+
private getFileHandle;
|
|
14
|
+
private getDirectoryHandle;
|
|
15
|
+
private resolveWritablePath;
|
|
16
|
+
exists(path: string): Promise<boolean>;
|
|
17
|
+
trystat(path: string): Promise<FileSystemAccessStorageStat | null>;
|
|
18
|
+
stat(path: string): Promise<FileSystemAccessStorageStat | null>;
|
|
19
|
+
mkdir(path: string): Promise<void>;
|
|
20
|
+
remove(path: string): Promise<void>;
|
|
21
|
+
read(path: string): Promise<string>;
|
|
22
|
+
readBinary(path: string): Promise<ArrayBuffer>;
|
|
23
|
+
write(path: string, data: string, _options?: UXDataWriteOptions): Promise<void>;
|
|
24
|
+
writeBinary(path: string, data: ArrayBuffer, _options?: UXDataWriteOptions): Promise<void>;
|
|
25
|
+
append(path: string, data: string, options?: UXDataWriteOptions): Promise<void>;
|
|
26
|
+
list(basePath: string): Promise<{
|
|
27
|
+
files: string[];
|
|
28
|
+
folders: string[];
|
|
29
|
+
}>;
|
|
30
|
+
private requireFileHandle;
|
|
31
|
+
private writeValue;
|
|
32
|
+
}
|
|
33
|
+
/** Bind a browser storage adapter to an explicitly selected and authorised directory handle. */
|
|
34
|
+
export declare function createFileSystemAccessStorage({ rootHandle, }: CreateFileSystemAccessStorageOptions): FileSystemAccessStorageAdapter;
|
|
35
|
+
export { validateStoragePath } from "../storagePath.js";
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { validateStoragePath } from "../storagePath.js";
|
|
2
|
+
class FileSystemAccessStorageAdapter {
|
|
3
|
+
constructor(rootHandle) {
|
|
4
|
+
this.rootHandle = rootHandle;
|
|
5
|
+
}
|
|
6
|
+
rootHandle;
|
|
7
|
+
async resolvePath(path) {
|
|
8
|
+
validateStoragePath(path, false);
|
|
9
|
+
try {
|
|
10
|
+
const parts = path.split("/").filter((part) => part !== "");
|
|
11
|
+
let currentHandle = this.rootHandle;
|
|
12
|
+
const fileName = parts[parts.length - 1];
|
|
13
|
+
for (let index = 0; index < parts.length - 1; index++) {
|
|
14
|
+
currentHandle = await currentHandle.getDirectoryHandle(parts[index]);
|
|
15
|
+
}
|
|
16
|
+
return { dirHandle: currentHandle, fileName };
|
|
17
|
+
} catch {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async getFileHandle(path) {
|
|
22
|
+
validateStoragePath(path);
|
|
23
|
+
if (path === "") return null;
|
|
24
|
+
const resolved = await this.resolvePath(path);
|
|
25
|
+
if (!resolved) return null;
|
|
26
|
+
try {
|
|
27
|
+
return await resolved.dirHandle.getFileHandle(resolved.fileName);
|
|
28
|
+
} catch {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
async getDirectoryHandle(path) {
|
|
33
|
+
validateStoragePath(path);
|
|
34
|
+
try {
|
|
35
|
+
const parts = path.split("/").filter((part) => part !== "");
|
|
36
|
+
let currentHandle = this.rootHandle;
|
|
37
|
+
for (const part of parts) currentHandle = await currentHandle.getDirectoryHandle(part);
|
|
38
|
+
return currentHandle;
|
|
39
|
+
} catch {
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async resolveWritablePath(path) {
|
|
44
|
+
validateStoragePath(path, false);
|
|
45
|
+
const parts = path.split("/").filter((part) => part !== "");
|
|
46
|
+
const fileName = parts.pop();
|
|
47
|
+
const parentPath = parts.join("/");
|
|
48
|
+
await this.mkdir(parentPath);
|
|
49
|
+
const dirHandle = await this.getDirectoryHandle(parentPath);
|
|
50
|
+
return dirHandle ? { dirHandle, fileName } : null;
|
|
51
|
+
}
|
|
52
|
+
async exists(path) {
|
|
53
|
+
return await this.getFileHandle(path) !== null || await this.getDirectoryHandle(path) !== null;
|
|
54
|
+
}
|
|
55
|
+
async trystat(path) {
|
|
56
|
+
const fileHandle = await this.getFileHandle(path);
|
|
57
|
+
if (fileHandle) {
|
|
58
|
+
const file = await fileHandle.getFile();
|
|
59
|
+
return {
|
|
60
|
+
size: file.size,
|
|
61
|
+
mtime: file.lastModified,
|
|
62
|
+
ctime: file.lastModified,
|
|
63
|
+
type: "file"
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (await this.getDirectoryHandle(path)) {
|
|
67
|
+
return { size: 0, mtime: Date.now(), ctime: Date.now(), type: "folder" };
|
|
68
|
+
}
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
async stat(path) {
|
|
72
|
+
return await this.trystat(path);
|
|
73
|
+
}
|
|
74
|
+
async mkdir(path) {
|
|
75
|
+
validateStoragePath(path);
|
|
76
|
+
let currentHandle = this.rootHandle;
|
|
77
|
+
for (const part of path.split("/").filter((part2) => part2 !== "")) {
|
|
78
|
+
currentHandle = await currentHandle.getDirectoryHandle(part, { create: true });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
async remove(path) {
|
|
82
|
+
const resolved = await this.resolvePath(path);
|
|
83
|
+
if (!resolved) return;
|
|
84
|
+
await resolved.dirHandle.removeEntry(resolved.fileName, { recursive: true });
|
|
85
|
+
}
|
|
86
|
+
async read(path) {
|
|
87
|
+
const handle = await this.requireFileHandle(path);
|
|
88
|
+
return await (await handle.getFile()).text();
|
|
89
|
+
}
|
|
90
|
+
async readBinary(path) {
|
|
91
|
+
const handle = await this.requireFileHandle(path);
|
|
92
|
+
return await (await handle.getFile()).arrayBuffer();
|
|
93
|
+
}
|
|
94
|
+
async write(path, data, _options) {
|
|
95
|
+
await this.writeValue(path, data);
|
|
96
|
+
}
|
|
97
|
+
async writeBinary(path, data, _options) {
|
|
98
|
+
await this.writeValue(path, data);
|
|
99
|
+
}
|
|
100
|
+
async append(path, data, options) {
|
|
101
|
+
await this.write(path, await this.exists(path) ? await this.read(path) + data : data, options);
|
|
102
|
+
}
|
|
103
|
+
async list(basePath) {
|
|
104
|
+
const dirHandle = await this.getDirectoryHandle(basePath);
|
|
105
|
+
if (!dirHandle) return { files: [], folders: [] };
|
|
106
|
+
const files = [];
|
|
107
|
+
const folders = [];
|
|
108
|
+
for await (const [name, entry] of dirHandle.entries()) {
|
|
109
|
+
const entryPath = basePath ? `${basePath}/${name}` : name;
|
|
110
|
+
if (entry.kind === "directory") folders.push(entryPath);
|
|
111
|
+
else if (entry.kind === "file") files.push(entryPath);
|
|
112
|
+
}
|
|
113
|
+
return { files, folders };
|
|
114
|
+
}
|
|
115
|
+
async requireFileHandle(path) {
|
|
116
|
+
const handle = await this.getFileHandle(path);
|
|
117
|
+
if (!handle) throw new Error(`File not found: ${path}`);
|
|
118
|
+
return handle;
|
|
119
|
+
}
|
|
120
|
+
async writeValue(path, data) {
|
|
121
|
+
const resolved = await this.resolveWritablePath(path);
|
|
122
|
+
if (!resolved) throw new Error(`Invalid path: ${path}`);
|
|
123
|
+
const handle = await resolved.dirHandle.getFileHandle(resolved.fileName, { create: true });
|
|
124
|
+
const writable = await handle.createWritable();
|
|
125
|
+
await writable.write(data);
|
|
126
|
+
await writable.close();
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function createFileSystemAccessStorage({
|
|
130
|
+
rootHandle
|
|
131
|
+
}) {
|
|
132
|
+
return new FileSystemAccessStorageAdapter(rootHandle);
|
|
133
|
+
}
|
|
134
|
+
import { validateStoragePath as validateStoragePath2 } from "../storagePath.js";
|
|
135
|
+
export {
|
|
136
|
+
FileSystemAccessStorageAdapter,
|
|
137
|
+
createFileSystemAccessStorage,
|
|
138
|
+
validateStoragePath2 as validateStoragePath
|
|
139
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Node-only host capabilities for Commonlib headless and CLI consumers. */
|
|
2
|
+
import * as nodeFs from "node:fs";
|
|
3
|
+
import * as nodePath from "node:path";
|
|
4
|
+
import * as nodeReadlinePromises from "node:readline/promises";
|
|
5
|
+
import * as nodeOs from "node:os";
|
|
6
|
+
import { isBuiltin as nodeIsBuiltin } from "node:module";
|
|
7
|
+
export { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
+
export type { Stats } from "node:fs";
|
|
9
|
+
/** Synchronous Node file-system API. */
|
|
10
|
+
export declare const fs: typeof nodeFs;
|
|
11
|
+
/** Promise-based Node file-system API. */
|
|
12
|
+
export declare const fsPromises: typeof nodeFs.promises;
|
|
13
|
+
/** Node path API. */
|
|
14
|
+
export declare const path: nodePath.PlatformPath;
|
|
15
|
+
/** Node operating-system API. */
|
|
16
|
+
export declare const os: typeof nodeOs;
|
|
17
|
+
/** Promise-based Node readline API. */
|
|
18
|
+
export declare const readline: typeof nodeReadlinePromises;
|
|
19
|
+
/** Names recognised by the current Node runtime as built-in modules. */
|
|
20
|
+
export declare const builtinModules: readonly string[];
|
|
21
|
+
/** Returns whether a module specifier refers to a Node built-in. */
|
|
22
|
+
export declare const isBuiltin: typeof nodeIsBuiltin;
|
|
23
|
+
export { NodeStorageAdapter, createNodeStorage, validateStoragePath, type CreateNodeStorageOptions, type NodeStorageStat, } from "./storage.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as nodeFs from "node:fs";
|
|
2
|
+
import * as nodeFsPromises from "node:fs/promises";
|
|
3
|
+
import * as nodePath from "node:path";
|
|
4
|
+
import * as nodeReadlinePromises from "node:readline/promises";
|
|
5
|
+
import * as nodeOs from "node:os";
|
|
6
|
+
import { builtinModules as nodeBuiltinModules, isBuiltin as nodeIsBuiltin } from "node:module";
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
8
|
+
const fs = nodeFs;
|
|
9
|
+
const fsPromises = nodeFsPromises;
|
|
10
|
+
const path = nodePath;
|
|
11
|
+
const os = nodeOs;
|
|
12
|
+
const readline = nodeReadlinePromises;
|
|
13
|
+
const builtinModules = nodeBuiltinModules;
|
|
14
|
+
const isBuiltin = nodeIsBuiltin;
|
|
15
|
+
import {
|
|
16
|
+
NodeStorageAdapter,
|
|
17
|
+
createNodeStorage,
|
|
18
|
+
validateStoragePath
|
|
19
|
+
} from "./storage.js";
|
|
20
|
+
export {
|
|
21
|
+
NodeStorageAdapter,
|
|
22
|
+
builtinModules,
|
|
23
|
+
createNodeStorage,
|
|
24
|
+
fileURLToPath,
|
|
25
|
+
fs,
|
|
26
|
+
fsPromises,
|
|
27
|
+
isBuiltin,
|
|
28
|
+
os,
|
|
29
|
+
path,
|
|
30
|
+
pathToFileURL,
|
|
31
|
+
readline,
|
|
32
|
+
validateStoragePath
|
|
33
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { UXDataWriteOptions, UXStat } from "../../common/types.js";
|
|
2
|
+
import type { IStorageAdapter } from "../../serviceModules/adapters/IStorageAdapter.js";
|
|
3
|
+
export type NodeStorageStat = UXStat;
|
|
4
|
+
export interface CreateNodeStorageOptions {
|
|
5
|
+
/** Absolute or process-relative directory which bounds every adapter operation. */
|
|
6
|
+
rootPath: string;
|
|
7
|
+
}
|
|
8
|
+
/** Rooted storage adapter backed by Node's file-system APIs. */
|
|
9
|
+
export declare class NodeStorageAdapter implements IStorageAdapter<NodeStorageStat> {
|
|
10
|
+
private readonly rootPath;
|
|
11
|
+
constructor(rootPath: string);
|
|
12
|
+
private resolvePath;
|
|
13
|
+
exists(path: string): Promise<boolean>;
|
|
14
|
+
trystat(path: string): Promise<NodeStorageStat | null>;
|
|
15
|
+
stat(path: string): Promise<NodeStorageStat | null>;
|
|
16
|
+
mkdir(path: string): Promise<void>;
|
|
17
|
+
remove(path: string): Promise<void>;
|
|
18
|
+
read(path: string): Promise<string>;
|
|
19
|
+
readBinary(path: string): Promise<ArrayBuffer>;
|
|
20
|
+
write(path: string, data: string, options?: UXDataWriteOptions): Promise<void>;
|
|
21
|
+
writeBinary(path: string, data: ArrayBuffer, options?: UXDataWriteOptions): Promise<void>;
|
|
22
|
+
append(path: string, data: string, options?: UXDataWriteOptions): Promise<void>;
|
|
23
|
+
list(basePath: string): Promise<{
|
|
24
|
+
files: string[];
|
|
25
|
+
folders: string[];
|
|
26
|
+
}>;
|
|
27
|
+
private applyTimes;
|
|
28
|
+
}
|
|
29
|
+
/** Bind a Node storage adapter to an explicitly selected root directory. */
|
|
30
|
+
export declare function createNodeStorage({ rootPath }: CreateNodeStorageOptions): NodeStorageAdapter;
|
|
31
|
+
export { validateStoragePath } from "../storagePath.js";
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import * as nodeFsPromises from "node:fs/promises";
|
|
2
|
+
import * as nodePath from "node:path";
|
|
3
|
+
import { validateStoragePath } from "../storagePath.js";
|
|
4
|
+
class NodeStorageAdapter {
|
|
5
|
+
constructor(rootPath) {
|
|
6
|
+
this.rootPath = rootPath;
|
|
7
|
+
}
|
|
8
|
+
rootPath;
|
|
9
|
+
resolvePath(path, allowRoot = true) {
|
|
10
|
+
return nodePath.join(this.rootPath, validateStoragePath(path, allowRoot));
|
|
11
|
+
}
|
|
12
|
+
async exists(path) {
|
|
13
|
+
const fullPath = this.resolvePath(path);
|
|
14
|
+
try {
|
|
15
|
+
await nodeFsPromises.access(fullPath);
|
|
16
|
+
return true;
|
|
17
|
+
} catch {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
async trystat(path) {
|
|
22
|
+
try {
|
|
23
|
+
const stat = await nodeFsPromises.stat(this.resolvePath(path));
|
|
24
|
+
return {
|
|
25
|
+
size: stat.size,
|
|
26
|
+
mtime: Math.floor(stat.mtimeMs),
|
|
27
|
+
ctime: Math.floor(stat.ctimeMs),
|
|
28
|
+
type: stat.isDirectory() ? "folder" : "file"
|
|
29
|
+
};
|
|
30
|
+
} catch {
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async stat(path) {
|
|
35
|
+
return await this.trystat(path);
|
|
36
|
+
}
|
|
37
|
+
async mkdir(path) {
|
|
38
|
+
await nodeFsPromises.mkdir(this.resolvePath(path), { recursive: true });
|
|
39
|
+
}
|
|
40
|
+
async remove(path) {
|
|
41
|
+
const fullPath = this.resolvePath(path, false);
|
|
42
|
+
const stat = await nodeFsPromises.stat(fullPath);
|
|
43
|
+
if (stat.isDirectory()) {
|
|
44
|
+
await nodeFsPromises.rm(fullPath, { recursive: true, force: true });
|
|
45
|
+
} else {
|
|
46
|
+
await nodeFsPromises.unlink(fullPath);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
async read(path) {
|
|
50
|
+
return await nodeFsPromises.readFile(this.resolvePath(path, false), "utf-8");
|
|
51
|
+
}
|
|
52
|
+
async readBinary(path) {
|
|
53
|
+
const buffer = await nodeFsPromises.readFile(this.resolvePath(path, false));
|
|
54
|
+
return buffer.buffer.slice(buffer.byteOffset, buffer.byteOffset + buffer.byteLength);
|
|
55
|
+
}
|
|
56
|
+
async write(path, data, options) {
|
|
57
|
+
const fullPath = this.resolvePath(path, false);
|
|
58
|
+
await nodeFsPromises.mkdir(nodePath.dirname(fullPath), { recursive: true });
|
|
59
|
+
await nodeFsPromises.writeFile(fullPath, data, "utf-8");
|
|
60
|
+
await this.applyTimes(fullPath, options);
|
|
61
|
+
}
|
|
62
|
+
async writeBinary(path, data, options) {
|
|
63
|
+
const fullPath = this.resolvePath(path, false);
|
|
64
|
+
await nodeFsPromises.mkdir(nodePath.dirname(fullPath), { recursive: true });
|
|
65
|
+
await nodeFsPromises.writeFile(fullPath, new Uint8Array(data));
|
|
66
|
+
await this.applyTimes(fullPath, options);
|
|
67
|
+
}
|
|
68
|
+
async append(path, data, options) {
|
|
69
|
+
const fullPath = this.resolvePath(path, false);
|
|
70
|
+
await nodeFsPromises.mkdir(nodePath.dirname(fullPath), { recursive: true });
|
|
71
|
+
await nodeFsPromises.appendFile(fullPath, data, "utf-8");
|
|
72
|
+
await this.applyTimes(fullPath, options);
|
|
73
|
+
}
|
|
74
|
+
async list(basePath) {
|
|
75
|
+
try {
|
|
76
|
+
const entries = await nodeFsPromises.readdir(this.resolvePath(basePath), { withFileTypes: true });
|
|
77
|
+
const files = [];
|
|
78
|
+
const folders = [];
|
|
79
|
+
for (const entry of entries) {
|
|
80
|
+
const entryPath = nodePath.join(basePath, entry.name).replace(/\\/g, "/");
|
|
81
|
+
if (entry.isDirectory()) folders.push(entryPath);
|
|
82
|
+
else if (entry.isFile()) files.push(entryPath);
|
|
83
|
+
}
|
|
84
|
+
return { files, folders };
|
|
85
|
+
} catch {
|
|
86
|
+
return { files: [], folders: [] };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
async applyTimes(fullPath, options) {
|
|
90
|
+
if (!options?.mtime && !options?.ctime) return;
|
|
91
|
+
const accessTime = options.mtime ? new Date(options.mtime) : /* @__PURE__ */ new Date();
|
|
92
|
+
const modificationTime = options.mtime ? new Date(options.mtime) : /* @__PURE__ */ new Date();
|
|
93
|
+
await nodeFsPromises.utimes(fullPath, accessTime, modificationTime);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function createNodeStorage({ rootPath }) {
|
|
97
|
+
return new NodeStorageAdapter(rootPath);
|
|
98
|
+
}
|
|
99
|
+
import { validateStoragePath as validateStoragePath2 } from "../storagePath.js";
|
|
100
|
+
export {
|
|
101
|
+
NodeStorageAdapter,
|
|
102
|
+
createNodeStorage,
|
|
103
|
+
validateStoragePath2 as validateStoragePath
|
|
104
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Validate the platform-neutral path vocabulary used by rooted storage adapters.
|
|
3
|
+
*
|
|
4
|
+
* Paths are slash-separated and relative to the root bound to the adapter. Root
|
|
5
|
+
* selection and authorisation happen before the adapter is constructed.
|
|
6
|
+
*/
|
|
7
|
+
export declare function validateStoragePath(storagePath: string, allowRoot?: boolean): string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
function validateStoragePath(storagePath, allowRoot = true) {
|
|
2
|
+
if (storagePath === "") {
|
|
3
|
+
if (allowRoot) return storagePath;
|
|
4
|
+
throw new Error("The storage root is not a valid entry path");
|
|
5
|
+
}
|
|
6
|
+
if (storagePath.startsWith("/") || storagePath.startsWith("\\") || /^[A-Za-z]:/.test(storagePath)) {
|
|
7
|
+
throw new Error(`Storage paths must be relative to the configured root: ${storagePath}`);
|
|
8
|
+
}
|
|
9
|
+
if (storagePath.includes("\\")) {
|
|
10
|
+
throw new Error(`Storage paths must use forward slashes: ${storagePath}`);
|
|
11
|
+
}
|
|
12
|
+
const segments = storagePath.split("/");
|
|
13
|
+
if (segments.some((segment) => segment === "." || segment === "..")) {
|
|
14
|
+
throw new Error(`Storage paths must not contain traversal segments: ${storagePath}`);
|
|
15
|
+
}
|
|
16
|
+
return storagePath;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
validateStoragePath
|
|
20
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type EntryDoc, type EntryMilestoneInfo, type RemoteDBSettings, type ChunkVersionRange, type TweakValues, type DeviceInfo } from "../common/types.js";
|
|
2
|
+
export type ENSURE_DB_RESULT = "OK" | "INCOMPATIBLE" | "LOCKED" | "NODE_LOCKED" | "NODE_CLEANED" | ["MISMATCHED", TweakValues];
|
|
3
|
+
/**
|
|
4
|
+
* Ensures that the remote database is compatible with the current device.
|
|
5
|
+
*
|
|
6
|
+
* @param infoSrc - The information about the remote database (which retrieved from the remote).
|
|
7
|
+
* @param setting - The current settings.
|
|
8
|
+
* @param deviceNodeID - The ID of the current device node.
|
|
9
|
+
* @param currentVersionRange - The current version range of the database.
|
|
10
|
+
* @param updateCallback - The callback function to update the remote milestone.
|
|
11
|
+
* @returns A promise that resolves to the result of ensuring compatibility.
|
|
12
|
+
*/
|
|
13
|
+
export declare function ensureRemoteIsCompatible(infoSrc: EntryMilestoneInfo | false, setting: RemoteDBSettings, deviceNodeID: string, currentVersionRange: ChunkVersionRange, nodeDeviceInfo: DeviceInfo, updateCallback: (info: EntryMilestoneInfo) => Promise<void>): Promise<ENSURE_DB_RESULT>;
|
|
14
|
+
export declare function ensureDatabaseIsCompatible(db: PouchDB.Database<EntryDoc>, setting: RemoteDBSettings, deviceNodeID: string, currentVersionRange: ChunkVersionRange, nodeDeviceInfo: DeviceInfo): Promise<ENSURE_DB_RESULT>;
|