@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.
Files changed (516) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +49 -0
  3. package/dist/API/DirectFileManipulator.d.ts +2 -0
  4. package/dist/API/DirectFileManipulator.js +4 -0
  5. package/dist/API/DirectFileManipulatorV2.d.ts +150 -0
  6. package/dist/API/DirectFileManipulatorV2.js +424 -0
  7. package/dist/API/processSetting.d.ts +41 -0
  8. package/dist/API/processSetting.js +140 -0
  9. package/dist/ContentSplitter/ContentSplitter.d.ts +28 -0
  10. package/dist/ContentSplitter/ContentSplitter.js +5 -0
  11. package/dist/ContentSplitter/ContentSplitterBase.d.ts +51 -0
  12. package/dist/ContentSplitter/ContentSplitterBase.js +83 -0
  13. package/dist/ContentSplitter/ContentSplitterRabinKarp.d.ts +9 -0
  14. package/dist/ContentSplitter/ContentSplitterRabinKarp.js +32 -0
  15. package/dist/ContentSplitter/ContentSplitterV1.d.ts +9 -0
  16. package/dist/ContentSplitter/ContentSplitterV1.js +34 -0
  17. package/dist/ContentSplitter/ContentSplitterV2.d.ts +9 -0
  18. package/dist/ContentSplitter/ContentSplitterV2.js +34 -0
  19. package/dist/ContentSplitter/ContentSplitters.d.ts +12 -0
  20. package/dist/ContentSplitter/ContentSplitters.js +29 -0
  21. package/dist/bureau/bureau.d.ts +7 -0
  22. package/dist/bureau/bureau.js +5 -0
  23. package/dist/common/ConnectionString.d.ts +30 -0
  24. package/dist/common/ConnectionString.js +179 -0
  25. package/dist/common/LSError.d.ts +48 -0
  26. package/dist/common/LSError.js +112 -0
  27. package/dist/common/configForDoc.d.ts +79 -0
  28. package/dist/common/configForDoc.js +312 -0
  29. package/dist/common/coreEnvFunctions.d.ts +21 -0
  30. package/dist/common/coreEnvFunctions.js +22 -0
  31. package/dist/common/coreEnvVars.d.ts +3 -0
  32. package/dist/common/coreEnvVars.js +6 -0
  33. package/dist/common/i18n.d.ts +18 -0
  34. package/dist/common/i18n.js +7193 -0
  35. package/dist/common/logger.d.ts +2 -0
  36. package/dist/common/logger.js +1 -0
  37. package/dist/common/messages/combinedMessages.dev.d.ts +7 -0
  38. package/dist/common/messages/combinedMessages.dev.js +44 -0
  39. package/dist/common/messages/combinedMessages.prod.d.ts +9264 -0
  40. package/dist/common/messages/combinedMessages.prod.js +9271 -0
  41. package/dist/common/messages/de.d.ts +297 -0
  42. package/dist/common/messages/de.js +7 -0
  43. package/dist/common/messages/def.d.ts +1119 -0
  44. package/dist/common/messages/def.js +7 -0
  45. package/dist/common/messages/es.d.ts +689 -0
  46. package/dist/common/messages/es.js +7 -0
  47. package/dist/common/messages/fr.d.ts +582 -0
  48. package/dist/common/messages/fr.js +7 -0
  49. package/dist/common/messages/he.d.ts +583 -0
  50. package/dist/common/messages/he.js +7 -0
  51. package/dist/common/messages/ja.d.ts +838 -0
  52. package/dist/common/messages/ja.js +7 -0
  53. package/dist/common/messages/ko.d.ts +800 -0
  54. package/dist/common/messages/ko.js +7 -0
  55. package/dist/common/messages/ru.d.ts +858 -0
  56. package/dist/common/messages/ru.js +7 -0
  57. package/dist/common/messages/zh-tw.d.ts +384 -0
  58. package/dist/common/messages/zh-tw.js +7 -0
  59. package/dist/common/messages/zh.d.ts +1093 -0
  60. package/dist/common/messages/zh.js +7 -0
  61. package/dist/common/messagesJson/de.json +295 -0
  62. package/dist/common/messagesJson/en.json +1117 -0
  63. package/dist/common/messagesJson/es.json +687 -0
  64. package/dist/common/messagesJson/fr.json +580 -0
  65. package/dist/common/messagesJson/he.json +581 -0
  66. package/dist/common/messagesJson/ja.json +836 -0
  67. package/dist/common/messagesJson/ko.json +798 -0
  68. package/dist/common/messagesJson/ru.json +856 -0
  69. package/dist/common/messagesJson/zh-tw.json +382 -0
  70. package/dist/common/messagesJson/zh.json +1091 -0
  71. package/dist/common/models/auth.type.d.ts +41 -0
  72. package/dist/common/models/auth.type.js +0 -0
  73. package/dist/common/models/db.const.d.ts +20 -0
  74. package/dist/common/models/db.const.js +28 -0
  75. package/dist/common/models/db.definition.d.ts +56 -0
  76. package/dist/common/models/db.definition.js +6 -0
  77. package/dist/common/models/db.type.d.ts +142 -0
  78. package/dist/common/models/db.type.js +0 -0
  79. package/dist/common/models/diff.definition.d.ts +16 -0
  80. package/dist/common/models/diff.definition.js +0 -0
  81. package/dist/common/models/fileaccess.const.d.ts +7 -0
  82. package/dist/common/models/fileaccess.const.js +16 -0
  83. package/dist/common/models/fileaccess.type.d.ts +72 -0
  84. package/dist/common/models/fileaccess.type.js +0 -0
  85. package/dist/common/models/redflag.const.d.ts +32 -0
  86. package/dist/common/models/redflag.const.js +27 -0
  87. package/dist/common/models/setting.const.d.ts +49 -0
  88. package/dist/common/models/setting.const.defaults.d.ts +3 -0
  89. package/dist/common/models/setting.const.defaults.js +185 -0
  90. package/dist/common/models/setting.const.js +68 -0
  91. package/dist/common/models/setting.const.preferred.d.ts +5 -0
  92. package/dist/common/models/setting.const.preferred.js +35 -0
  93. package/dist/common/models/setting.const.qr.d.ts +2 -0
  94. package/dist/common/models/setting.const.qr.js +174 -0
  95. package/dist/common/models/setting.type.d.ts +900 -0
  96. package/dist/common/models/setting.type.js +8 -0
  97. package/dist/common/models/shared.const.behabiour.d.ts +28 -0
  98. package/dist/common/models/shared.const.behabiour.js +36 -0
  99. package/dist/common/models/shared.const.d.ts +5 -0
  100. package/dist/common/models/shared.const.js +12 -0
  101. package/dist/common/models/shared.const.symbols.d.ts +9 -0
  102. package/dist/common/models/shared.const.symbols.js +20 -0
  103. package/dist/common/models/shared.definition.configNames.d.ts +36 -0
  104. package/dist/common/models/shared.definition.configNames.js +203 -0
  105. package/dist/common/models/shared.definition.d.ts +22 -0
  106. package/dist/common/models/shared.definition.js +24 -0
  107. package/dist/common/models/shared.type.util.d.ts +8 -0
  108. package/dist/common/models/shared.type.util.js +0 -0
  109. package/dist/common/models/sync.definition.d.ts +18 -0
  110. package/dist/common/models/sync.definition.js +20 -0
  111. package/dist/common/models/tweak.definition.d.ts +191 -0
  112. package/dist/common/models/tweak.definition.js +77 -0
  113. package/dist/common/rosetta.d.ts +42 -0
  114. package/dist/common/rosetta.js +57 -0
  115. package/dist/common/settingConstants.d.ts +216 -0
  116. package/dist/common/settingConstants.js +434 -0
  117. package/dist/common/typeUtils.d.ts +17 -0
  118. package/dist/common/typeUtils.js +51 -0
  119. package/dist/common/types.d.ts +107 -0
  120. package/dist/common/types.js +212 -0
  121. package/dist/common/utils.d.ts +129 -0
  122. package/dist/common/utils.doc.d.ts +11 -0
  123. package/dist/common/utils.doc.js +35 -0
  124. package/dist/common/utils.js +583 -0
  125. package/dist/common/utils.object.d.ts +2 -0
  126. package/dist/common/utils.object.js +14 -0
  127. package/dist/common/utils.patch.d.ts +8 -0
  128. package/dist/common/utils.patch.js +178 -0
  129. package/dist/common/utils.type.d.ts +1 -0
  130. package/dist/common/utils.type.js +0 -0
  131. package/dist/context.d.ts +8 -0
  132. package/dist/context.js +14 -0
  133. package/dist/databases/IndexedDBKeyValueDatabase.d.ts +26 -0
  134. package/dist/databases/IndexedDBKeyValueDatabase.js +130 -0
  135. package/dist/dataobject/StoredMap.d.ts +12 -0
  136. package/dist/dataobject/StoredMap.js +47 -0
  137. package/dist/dev/checks.d.ts +5 -0
  138. package/dist/dev/checks.js +38 -0
  139. package/dist/encryption/encryptHKDF.d.ts +3 -0
  140. package/dist/encryption/encryptHKDF.js +7 -0
  141. package/dist/encryption/stringEncryption.d.ts +27 -0
  142. package/dist/encryption/stringEncryption.js +59 -0
  143. package/dist/events/coreEvents.d.ts +54 -0
  144. package/dist/events/coreEvents.js +46 -0
  145. package/dist/hub/hub.d.ts +11 -0
  146. package/dist/hub/hub.js +7 -0
  147. package/dist/index.d.ts +1 -0
  148. package/dist/index.js +4 -0
  149. package/dist/interfaces/AsyncActivityRunner.d.ts +18 -0
  150. package/dist/interfaces/AsyncActivityRunner.js +7 -0
  151. package/dist/interfaces/Confirm.d.ts +17 -0
  152. package/dist/interfaces/Confirm.js +0 -0
  153. package/dist/interfaces/DatabaseFileAccess.d.ts +14 -0
  154. package/dist/interfaces/DatabaseFileAccess.js +0 -0
  155. package/dist/interfaces/DatabaseRebuilder.d.ts +13 -0
  156. package/dist/interfaces/DatabaseRebuilder.js +0 -0
  157. package/dist/interfaces/FileHandler.d.ts +13 -0
  158. package/dist/interfaces/FileHandler.js +0 -0
  159. package/dist/interfaces/KeyValueDatabase.d.ts +11 -0
  160. package/dist/interfaces/KeyValueDatabase.js +0 -0
  161. package/dist/interfaces/ServiceModule.d.ts +59 -0
  162. package/dist/interfaces/ServiceModule.js +19 -0
  163. package/dist/interfaces/StorageAccess.d.ts +44 -0
  164. package/dist/interfaces/StorageAccess.js +0 -0
  165. package/dist/interfaces/StorageEventManager.d.ts +16 -0
  166. package/dist/interfaces/StorageEventManager.js +5 -0
  167. package/dist/managers/ChangeManager.d.ts +61 -0
  168. package/dist/managers/ChangeManager.js +104 -0
  169. package/dist/managers/ChunkDeliveryCoordinator.d.ts +51 -0
  170. package/dist/managers/ChunkDeliveryCoordinator.js +136 -0
  171. package/dist/managers/ChunkFetcher.d.ts +44 -0
  172. package/dist/managers/ChunkFetcher.js +251 -0
  173. package/dist/managers/ChunkManager.d.ts +2 -0
  174. package/dist/managers/ChunkManager.js +4 -0
  175. package/dist/managers/ConflictManager.d.ts +37 -0
  176. package/dist/managers/ConflictManager.js +322 -0
  177. package/dist/managers/EntryManager/EntryManager.d.ts +37 -0
  178. package/dist/managers/EntryManager/EntryManager.js +73 -0
  179. package/dist/managers/EntryManager/EntryManagerImpls.d.ts +74 -0
  180. package/dist/managers/EntryManager/EntryManagerImpls.js +499 -0
  181. package/dist/managers/HashManager/HashManager.d.ts +60 -0
  182. package/dist/managers/HashManager/HashManager.js +97 -0
  183. package/dist/managers/HashManager/HashManagerCore.d.ts +114 -0
  184. package/dist/managers/HashManager/HashManagerCore.js +99 -0
  185. package/dist/managers/HashManager/PureJSHashManager.d.ts +77 -0
  186. package/dist/managers/HashManager/PureJSHashManager.js +84 -0
  187. package/dist/managers/HashManager/XXHashHashManager.d.ts +96 -0
  188. package/dist/managers/HashManager/XXHashHashManager.js +111 -0
  189. package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.d.ts +30 -0
  190. package/dist/managers/LayeredChunkManager/ArrivalWaitLayer.js +115 -0
  191. package/dist/managers/LayeredChunkManager/CacheLayer.d.ts +59 -0
  192. package/dist/managers/LayeredChunkManager/CacheLayer.js +161 -0
  193. package/dist/managers/LayeredChunkManager/ChunkLayerInterfaces.d.ts +37 -0
  194. package/dist/managers/LayeredChunkManager/ChunkLayerInterfaces.js +0 -0
  195. package/dist/managers/LayeredChunkManager/DatabaseReadLayer.d.ts +14 -0
  196. package/dist/managers/LayeredChunkManager/DatabaseReadLayer.js +78 -0
  197. package/dist/managers/LayeredChunkManager/DatabaseWriteLayer.d.ts +11 -0
  198. package/dist/managers/LayeredChunkManager/DatabaseWriteLayer.js +43 -0
  199. package/dist/managers/LayeredChunkManager/HotPackLayer.d.ts +9 -0
  200. package/dist/managers/LayeredChunkManager/HotPackLayer.js +8 -0
  201. package/dist/managers/LayeredChunkManager/types.d.ts +39 -0
  202. package/dist/managers/LayeredChunkManager/types.js +0 -0
  203. package/dist/managers/LayeredChunkManager.d.ts +53 -0
  204. package/dist/managers/LayeredChunkManager.js +240 -0
  205. package/dist/managers/LiveSyncManagers.d.ts +48 -0
  206. package/dist/managers/LiveSyncManagers.js +136 -0
  207. package/dist/managers/StorageEventManager.d.ts +135 -0
  208. package/dist/managers/StorageEventManager.js +564 -0
  209. package/dist/managers/StorageProcessingManager.d.ts +14 -0
  210. package/dist/managers/StorageProcessingManager.js +48 -0
  211. package/dist/managers/adapters/IStorageEventConverterAdapter.d.ts +16 -0
  212. package/dist/managers/adapters/IStorageEventConverterAdapter.js +0 -0
  213. package/dist/managers/adapters/IStorageEventManagerAdapter.d.ts +18 -0
  214. package/dist/managers/adapters/IStorageEventManagerAdapter.js +0 -0
  215. package/dist/managers/adapters/IStorageEventPersistenceAdapter.d.ts +15 -0
  216. package/dist/managers/adapters/IStorageEventPersistenceAdapter.js +0 -0
  217. package/dist/managers/adapters/IStorageEventStatusAdapter.d.ts +13 -0
  218. package/dist/managers/adapters/IStorageEventStatusAdapter.js +0 -0
  219. package/dist/managers/adapters/IStorageEventTypeGuardAdapter.d.ts +16 -0
  220. package/dist/managers/adapters/IStorageEventTypeGuardAdapter.js +0 -0
  221. package/dist/managers/adapters/IStorageEventWatchAdapter.d.ts +21 -0
  222. package/dist/managers/adapters/IStorageEventWatchAdapter.js +0 -0
  223. package/dist/managers/adapters/index.d.ts +6 -0
  224. package/dist/managers/adapters/index.js +0 -0
  225. package/dist/mock_and_interop/stores.d.ts +21 -0
  226. package/dist/mock_and_interop/stores.js +15 -0
  227. package/dist/mock_and_interop/wrapper.d.ts +7 -0
  228. package/dist/mock_and_interop/wrapper.js +37 -0
  229. package/dist/mods.d.ts +1 -0
  230. package/dist/mods.js +18 -0
  231. package/dist/platform/browser/index.d.ts +1 -0
  232. package/dist/platform/browser/index.js +10 -0
  233. package/dist/platform/browser/storage.d.ts +35 -0
  234. package/dist/platform/browser/storage.js +139 -0
  235. package/dist/platform/node/index.d.ts +23 -0
  236. package/dist/platform/node/index.js +33 -0
  237. package/dist/platform/node/storage.d.ts +31 -0
  238. package/dist/platform/node/storage.js +104 -0
  239. package/dist/platform/storagePath.d.ts +7 -0
  240. package/dist/platform/storagePath.js +20 -0
  241. package/dist/pouchdb/LiveSyncDBFunctions.d.ts +14 -0
  242. package/dist/pouchdb/LiveSyncDBFunctions.js +129 -0
  243. package/dist/pouchdb/LiveSyncLocalDB.d.ts +196 -0
  244. package/dist/pouchdb/LiveSyncLocalDB.js +381 -0
  245. package/dist/pouchdb/PouchDBConstructor.d.ts +3 -0
  246. package/dist/pouchdb/PouchDBConstructor.js +0 -0
  247. package/dist/pouchdb/ReplicatorShim.d.ts +51 -0
  248. package/dist/pouchdb/ReplicatorShim.js +109 -0
  249. package/dist/pouchdb/StreamingFetch.d.ts +19 -0
  250. package/dist/pouchdb/StreamingFetch.js +263 -0
  251. package/dist/pouchdb/chunks.d.ts +38 -0
  252. package/dist/pouchdb/chunks.js +314 -0
  253. package/dist/pouchdb/compress.d.ts +11 -0
  254. package/dist/pouchdb/compress.js +99 -0
  255. package/dist/pouchdb/encryption.d.ts +20 -0
  256. package/dist/pouchdb/encryption.js +458 -0
  257. package/dist/pouchdb/negotiation.d.ts +9 -0
  258. package/dist/pouchdb/negotiation.js +109 -0
  259. package/dist/pouchdb/pouchdb-browser.d.ts +2 -0
  260. package/dist/pouchdb/pouchdb-browser.js +96 -0
  261. package/dist/pouchdb/pouchdb-http.d.ts +2 -0
  262. package/dist/pouchdb/pouchdb-http.js +94 -0
  263. package/dist/pouchdb/pouchdb-test.d.ts +2 -0
  264. package/dist/pouchdb/pouchdb-test.js +12 -0
  265. package/dist/pouchdb/utils_couchdb.d.ts +4 -0
  266. package/dist/pouchdb/utils_couchdb.js +38 -0
  267. package/dist/replication/LiveSyncAbstractReplicator.d.ts +69 -0
  268. package/dist/replication/LiveSyncAbstractReplicator.js +92 -0
  269. package/dist/replication/SyncParamsHandler.d.ts +35 -0
  270. package/dist/replication/SyncParamsHandler.js +118 -0
  271. package/dist/replication/couchdb/LiveSyncReplicator.d.ts +85 -0
  272. package/dist/replication/couchdb/LiveSyncReplicator.js +1132 -0
  273. package/dist/replication/httplib.d.ts +75 -0
  274. package/dist/replication/httplib.js +187 -0
  275. package/dist/replication/journal/JournalSyncCore.d.ts +70 -0
  276. package/dist/replication/journal/JournalSyncCore.js +737 -0
  277. package/dist/replication/journal/JournalSyncTypes.d.ts +9 -0
  278. package/dist/replication/journal/JournalSyncTypes.js +11 -0
  279. package/dist/replication/journal/LiveSyncJournalReplicator.d.ts +40 -0
  280. package/dist/replication/journal/LiveSyncJournalReplicator.js +294 -0
  281. package/dist/replication/journal/LiveSyncJournalReplicatorEnv.d.ts +3 -0
  282. package/dist/replication/journal/LiveSyncJournalReplicatorEnv.js +0 -0
  283. package/dist/replication/journal/objectstore/JournalStorageAdapter.d.ts +15 -0
  284. package/dist/replication/journal/objectstore/JournalStorageAdapter.js +0 -0
  285. package/dist/replication/journal/objectstore/MinioStorageAdapter.d.ts +21 -0
  286. package/dist/replication/journal/objectstore/MinioStorageAdapter.js +204 -0
  287. package/dist/replication/trystero/LiveSyncTrysteroReplicator.d.ts +90 -0
  288. package/dist/replication/trystero/LiveSyncTrysteroReplicator.js +380 -0
  289. package/dist/replication/trystero/P2PLogCollector.d.ts +8 -0
  290. package/dist/replication/trystero/P2PLogCollector.js +91 -0
  291. package/dist/replication/trystero/P2PReplicatorBase.d.ts +19 -0
  292. package/dist/replication/trystero/P2PReplicatorBase.js +0 -0
  293. package/dist/replication/trystero/P2PReplicatorCore.d.ts +12 -0
  294. package/dist/replication/trystero/P2PReplicatorCore.js +126 -0
  295. package/dist/replication/trystero/P2PReplicatorPaneCommon.d.ts +41 -0
  296. package/dist/replication/trystero/P2PReplicatorPaneCommon.js +20 -0
  297. package/dist/replication/trystero/ProxiedDB.d.ts +13 -0
  298. package/dist/replication/trystero/ProxiedDB.js +20 -0
  299. package/dist/replication/trystero/TrysteroReplicator.d.ts +152 -0
  300. package/dist/replication/trystero/TrysteroReplicator.js +683 -0
  301. package/dist/replication/trystero/TrysteroReplicatorP2PClient.d.ts +19 -0
  302. package/dist/replication/trystero/TrysteroReplicatorP2PClient.js +80 -0
  303. package/dist/replication/trystero/TrysteroReplicatorP2PConnection.d.ts +2 -0
  304. package/dist/replication/trystero/TrysteroReplicatorP2PConnection.js +4 -0
  305. package/dist/replication/trystero/TrysteroReplicatorP2PServer.d.ts +117 -0
  306. package/dist/replication/trystero/TrysteroReplicatorP2PServer.js +540 -0
  307. package/dist/replication/trystero/UseP2PReplicatorResult.d.ts +11 -0
  308. package/dist/replication/trystero/UseP2PReplicatorResult.js +0 -0
  309. package/dist/replication/trystero/addP2PEventHandlers.d.ts +35 -0
  310. package/dist/replication/trystero/addP2PEventHandlers.js +43 -0
  311. package/dist/replication/trystero/rpcCompat.d.ts +1 -0
  312. package/dist/replication/trystero/rpcCompat.js +9 -0
  313. package/dist/replication/trystero/types.d.ts +95 -0
  314. package/dist/replication/trystero/types.js +27 -0
  315. package/dist/replication/trystero/useP2PReplicatorCommands.d.ts +7 -0
  316. package/dist/replication/trystero/useP2PReplicatorCommands.js +25 -0
  317. package/dist/replication/trystero/useP2PReplicatorFeature.d.ts +17 -0
  318. package/dist/replication/trystero/useP2PReplicatorFeature.js +82 -0
  319. package/dist/rpc/RpcRoom.d.ts +24 -0
  320. package/dist/rpc/RpcRoom.js +300 -0
  321. package/dist/rpc/RpcSession.d.ts +9 -0
  322. package/dist/rpc/RpcSession.js +32 -0
  323. package/dist/rpc/chunking.d.ts +11 -0
  324. package/dist/rpc/chunking.js +58 -0
  325. package/dist/rpc/errors.d.ts +8 -0
  326. package/dist/rpc/errors.js +26 -0
  327. package/dist/rpc/index.d.ts +6 -0
  328. package/dist/rpc/index.js +12 -0
  329. package/dist/rpc/pouchdb/RpcPouchDBProxy.d.ts +75 -0
  330. package/dist/rpc/pouchdb/RpcPouchDBProxy.js +115 -0
  331. package/dist/rpc/pouchdb/RpcPouchDBServer.d.ts +16 -0
  332. package/dist/rpc/pouchdb/RpcPouchDBServer.js +55 -0
  333. package/dist/rpc/transports/DiagRTCPeerConnections.d.ts +24 -0
  334. package/dist/rpc/transports/DiagRTCPeerConnections.js +208 -0
  335. package/dist/rpc/transports/DiagRTCPeerConnections.types.d.ts +64 -0
  336. package/dist/rpc/transports/DiagRTCPeerConnections.types.js +12 -0
  337. package/dist/rpc/transports/DiagRTCPeerConnections.utils.d.ts +33 -0
  338. package/dist/rpc/transports/DiagRTCPeerConnections.utils.js +217 -0
  339. package/dist/rpc/transports/TrysteroTransport.d.ts +216 -0
  340. package/dist/rpc/transports/TrysteroTransport.js +134 -0
  341. package/dist/rpc/transports/trysteroUtils.d.ts +3 -0
  342. package/dist/rpc/transports/trysteroUtils.js +37 -0
  343. package/dist/rpc/types.d.ts +75 -0
  344. package/dist/rpc/types.js +6 -0
  345. package/dist/serviceFeatures/checkRemoteSize.d.ts +28 -0
  346. package/dist/serviceFeatures/checkRemoteSize.js +178 -0
  347. package/dist/serviceFeatures/offlineScanner.d.ts +128 -0
  348. package/dist/serviceFeatures/offlineScanner.js +553 -0
  349. package/dist/serviceFeatures/prepareDatabaseForUse.d.ts +20 -0
  350. package/dist/serviceFeatures/prepareDatabaseForUse.js +39 -0
  351. package/dist/serviceFeatures/remoteConfig.d.ts +46 -0
  352. package/dist/serviceFeatures/remoteConfig.js +247 -0
  353. package/dist/serviceFeatures/setupObsidian/qrCode.d.ts +4 -0
  354. package/dist/serviceFeatures/setupObsidian/qrCode.js +67 -0
  355. package/dist/serviceFeatures/setupObsidian/setupUri.d.ts +7 -0
  356. package/dist/serviceFeatures/setupObsidian/setupUri.js +70 -0
  357. package/dist/serviceFeatures/setupObsidian/types.d.ts +2 -0
  358. package/dist/serviceFeatures/setupObsidian/types.js +0 -0
  359. package/dist/serviceFeatures/targetFilter.d.ts +24 -0
  360. package/dist/serviceFeatures/targetFilter.js +178 -0
  361. package/dist/serviceModules/FileAccessBase.d.ts +93 -0
  362. package/dist/serviceModules/FileAccessBase.js +219 -0
  363. package/dist/serviceModules/Rebuilder.d.ts +92 -0
  364. package/dist/serviceModules/Rebuilder.js +449 -0
  365. package/dist/serviceModules/ServiceDatabaseFileAccessBase.d.ts +40 -0
  366. package/dist/serviceModules/ServiceDatabaseFileAccessBase.js +306 -0
  367. package/dist/serviceModules/ServiceFileAccessBase.d.ts +64 -0
  368. package/dist/serviceModules/ServiceFileAccessBase.js +312 -0
  369. package/dist/serviceModules/ServiceFileHandlerBase.d.ts +52 -0
  370. package/dist/serviceModules/ServiceFileHandlerBase.js +493 -0
  371. package/dist/serviceModules/ServiceModuleBase.d.ts +10 -0
  372. package/dist/serviceModules/ServiceModuleBase.js +13 -0
  373. package/dist/serviceModules/adapters/IConversionAdapter.d.ts +15 -0
  374. package/dist/serviceModules/adapters/IConversionAdapter.js +0 -0
  375. package/dist/serviceModules/adapters/IFileSystemAdapter.d.ts +47 -0
  376. package/dist/serviceModules/adapters/IFileSystemAdapter.js +0 -0
  377. package/dist/serviceModules/adapters/IPathAdapter.d.ts +15 -0
  378. package/dist/serviceModules/adapters/IPathAdapter.js +0 -0
  379. package/dist/serviceModules/adapters/IStorageAdapter.d.ts +56 -0
  380. package/dist/serviceModules/adapters/IStorageAdapter.js +0 -0
  381. package/dist/serviceModules/adapters/ITypeGuardAdapter.d.ts +14 -0
  382. package/dist/serviceModules/adapters/ITypeGuardAdapter.js +0 -0
  383. package/dist/serviceModules/adapters/IVaultAdapter.d.ts +51 -0
  384. package/dist/serviceModules/adapters/IVaultAdapter.js +0 -0
  385. package/dist/serviceModules/adapters/index.d.ts +6 -0
  386. package/dist/serviceModules/adapters/index.js +0 -0
  387. package/dist/services/BrowserServices.d.ts +36 -0
  388. package/dist/services/BrowserServices.js +123 -0
  389. package/dist/services/HeadlessServices.d.ts +14 -0
  390. package/dist/services/HeadlessServices.js +144 -0
  391. package/dist/services/InjectableServices.d.ts +1 -0
  392. package/dist/services/InjectableServices.js +4 -0
  393. package/dist/services/ServiceHub.d.ts +82 -0
  394. package/dist/services/ServiceHub.js +66 -0
  395. package/dist/services/base/APIService.d.ts +93 -0
  396. package/dist/services/base/APIService.js +44 -0
  397. package/dist/services/base/AppLifecycleService.d.ts +132 -0
  398. package/dist/services/base/AppLifecycleService.js +123 -0
  399. package/dist/services/base/ConfigService.d.ts +7 -0
  400. package/dist/services/base/ConfigService.js +6 -0
  401. package/dist/services/base/ConflictService.d.ts +54 -0
  402. package/dist/services/base/ConflictService.js +22 -0
  403. package/dist/services/base/ControlService.d.ts +54 -0
  404. package/dist/services/base/ControlService.js +103 -0
  405. package/dist/services/base/DatabaseEventService.d.ts +38 -0
  406. package/dist/services/base/DatabaseEventService.js +38 -0
  407. package/dist/services/base/DatabaseService.d.ts +40 -0
  408. package/dist/services/base/DatabaseService.js +79 -0
  409. package/dist/services/base/FileProcessingService.d.ts +25 -0
  410. package/dist/services/base/FileProcessingService.js +28 -0
  411. package/dist/services/base/IService.d.ts +284 -0
  412. package/dist/services/base/IService.js +1 -0
  413. package/dist/services/base/KeyValueDBService.d.ts +42 -0
  414. package/dist/services/base/KeyValueDBService.js +133 -0
  415. package/dist/services/base/MessageTranslator.d.ts +6 -0
  416. package/dist/services/base/MessageTranslator.js +4 -0
  417. package/dist/services/base/PathService.d.ts +38 -0
  418. package/dist/services/base/PathService.js +66 -0
  419. package/dist/services/base/RemoteService.d.ts +61 -0
  420. package/dist/services/base/RemoteService.js +212 -0
  421. package/dist/services/base/ReplicationService.d.ts +92 -0
  422. package/dist/services/base/ReplicationService.js +261 -0
  423. package/dist/services/base/ReplicatorService.d.ts +66 -0
  424. package/dist/services/base/ReplicatorService.js +164 -0
  425. package/dist/services/base/ServiceBase.d.ts +33 -0
  426. package/dist/services/base/ServiceBase.js +27 -0
  427. package/dist/services/base/SettingService.d.ts +112 -0
  428. package/dist/services/base/SettingService.js +543 -0
  429. package/dist/services/base/TestService.d.ts +28 -0
  430. package/dist/services/base/TestService.js +19 -0
  431. package/dist/services/base/TweakValueService.d.ts +40 -0
  432. package/dist/services/base/TweakValueService.js +6 -0
  433. package/dist/services/base/UnresolvedErrorManager.d.ts +15 -0
  434. package/dist/services/base/UnresolvedErrorManager.js +44 -0
  435. package/dist/services/base/VaultService.d.ts +69 -0
  436. package/dist/services/base/VaultService.js +70 -0
  437. package/dist/services/implements/base/SvelteDialog.d.ts +79 -0
  438. package/dist/services/implements/base/SvelteDialog.js +134 -0
  439. package/dist/services/implements/base/UIService.d.ts +24 -0
  440. package/dist/services/implements/base/UIService.js +37 -0
  441. package/dist/services/implements/browser/BrowserAPIService.d.ts +54 -0
  442. package/dist/services/implements/browser/BrowserAPIService.js +298 -0
  443. package/dist/services/implements/browser/BrowserDatabaseService.d.ts +7 -0
  444. package/dist/services/implements/browser/BrowserDatabaseService.js +10 -0
  445. package/dist/services/implements/browser/ConfigServiceBrowserCompat.d.ts +16 -0
  446. package/dist/services/implements/browser/ConfigServiceBrowserCompat.js +23 -0
  447. package/dist/services/implements/headless/HeadlessAPIService.d.ts +52 -0
  448. package/dist/services/implements/headless/HeadlessAPIService.js +127 -0
  449. package/dist/services/implements/headless/HeadlessDatabaseService.d.ts +7 -0
  450. package/dist/services/implements/headless/HeadlessDatabaseService.js +10 -0
  451. package/dist/services/implements/injectable/InjectableAPIService.d.ts +7 -0
  452. package/dist/services/implements/injectable/InjectableAPIService.js +18 -0
  453. package/dist/services/implements/injectable/InjectableAppLifecycleService.d.ts +11 -0
  454. package/dist/services/implements/injectable/InjectableAppLifecycleService.js +14 -0
  455. package/dist/services/implements/injectable/InjectableConflictService.d.ts +11 -0
  456. package/dist/services/implements/injectable/InjectableConflictService.js +14 -0
  457. package/dist/services/implements/injectable/InjectableDatabaseEventService.d.ts +4 -0
  458. package/dist/services/implements/injectable/InjectableDatabaseEventService.js +7 -0
  459. package/dist/services/implements/injectable/InjectableFileProcessingService.d.ts +4 -0
  460. package/dist/services/implements/injectable/InjectableFileProcessingService.js +6 -0
  461. package/dist/services/implements/injectable/InjectablePathService.d.ts +12 -0
  462. package/dist/services/implements/injectable/InjectablePathService.js +36 -0
  463. package/dist/services/implements/injectable/InjectableRemoteService.d.ts +4 -0
  464. package/dist/services/implements/injectable/InjectableRemoteService.js +7 -0
  465. package/dist/services/implements/injectable/InjectableReplicationService.d.ts +4 -0
  466. package/dist/services/implements/injectable/InjectableReplicationService.js +6 -0
  467. package/dist/services/implements/injectable/InjectableReplicatorService.d.ts +4 -0
  468. package/dist/services/implements/injectable/InjectableReplicatorService.js +7 -0
  469. package/dist/services/implements/injectable/InjectableServiceHub.d.ts +72 -0
  470. package/dist/services/implements/injectable/InjectableServiceHub.js +125 -0
  471. package/dist/services/implements/injectable/InjectableServices.d.ts +36 -0
  472. package/dist/services/implements/injectable/InjectableServices.js +1 -0
  473. package/dist/services/implements/injectable/InjectableSettingService.d.ts +11 -0
  474. package/dist/services/implements/injectable/InjectableSettingService.js +33 -0
  475. package/dist/services/implements/injectable/InjectableTestService.d.ts +5 -0
  476. package/dist/services/implements/injectable/InjectableTestService.js +8 -0
  477. package/dist/services/implements/injectable/InjectableTweakValueService.d.ts +15 -0
  478. package/dist/services/implements/injectable/InjectableTweakValueService.js +12 -0
  479. package/dist/services/implements/injectable/InjectableVaultService.d.ts +9 -0
  480. package/dist/services/implements/injectable/InjectableVaultService.js +20 -0
  481. package/dist/services/lib/HandlerUtils.d.ts +374 -0
  482. package/dist/services/lib/HandlerUtils.js +412 -0
  483. package/dist/services/lib/logUtils.d.ts +13 -0
  484. package/dist/services/lib/logUtils.js +28 -0
  485. package/dist/services/lib/remoteActivity.d.ts +13 -0
  486. package/dist/services/lib/remoteActivity.js +11 -0
  487. package/dist/string_and_binary/chunks.d.ts +10 -0
  488. package/dist/string_and_binary/chunks.js +561 -0
  489. package/dist/string_and_binary/convert.d.ts +8 -0
  490. package/dist/string_and_binary/convert.js +46 -0
  491. package/dist/string_and_binary/hash.d.ts +2 -0
  492. package/dist/string_and_binary/hash.js +1 -0
  493. package/dist/string_and_binary/path.d.ts +35 -0
  494. package/dist/string_and_binary/path.js +240 -0
  495. package/dist/worker/bg.common.d.ts +2 -0
  496. package/dist/worker/bg.common.js +6 -0
  497. package/dist/worker/bg.worker.d.ts +1 -0
  498. package/dist/worker/bg.worker.encryption.d.ts +7 -0
  499. package/dist/worker/bg.worker.encryption.js +30 -0
  500. package/dist/worker/bg.worker.js +14 -0
  501. package/dist/worker/bg.worker.splitting.d.ts +6 -0
  502. package/dist/worker/bg.worker.splitting.js +36 -0
  503. package/dist/worker/bgWorker.d.ts +25 -0
  504. package/dist/worker/bgWorker.direct.d.ts +40 -0
  505. package/dist/worker/bgWorker.direct.js +65 -0
  506. package/dist/worker/bgWorker.encryption.d.ts +22 -0
  507. package/dist/worker/bgWorker.encryption.js +40 -0
  508. package/dist/worker/bgWorker.js +348 -0
  509. package/dist/worker/bgWorker.splitting.d.ts +27 -0
  510. package/dist/worker/bgWorker.splitting.js +123 -0
  511. package/dist/worker/universalTypes.d.ts +63 -0
  512. package/dist/worker/universalTypes.js +4 -0
  513. package/docs/development.md +51 -0
  514. package/docs/platform-storage.md +60 -0
  515. package/docs/releasing.md +69 -0
  516. package/package.json +693 -0
@@ -0,0 +1,93 @@
1
+ import type { FetchHttpHandler } from "@smithy/fetch-http-handler";
2
+ import type { LOG_LEVEL } from "../../common/logger.js";
3
+ import type { IAPIService, ICommandCompat } from "./IService.js";
4
+ import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
5
+ import type { Confirm } from "../../interfaces/Confirm.js";
6
+ /**
7
+ * The APIService provides methods for interacting with the plug-in's API,
8
+ */
9
+ export declare abstract class APIService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IAPIService {
10
+ /**
11
+ * Get a custom fetch handler for making HTTP requests (e.g., S3 without CORS issues).
12
+ */
13
+ abstract getCustomFetchHandler(): FetchHttpHandler;
14
+ /**
15
+ * Add a log entry to the log (Now not used).
16
+ * @param message The log message.
17
+ * @param level The log level.
18
+ * @param key The log key.
19
+ */
20
+ abstract addLog(message: unknown, level: LOG_LEVEL, key: string): void;
21
+ /**
22
+ * Check if the app is running on a mobile device.
23
+ * @returns true if running on mobile, false otherwise.
24
+ */
25
+ abstract isMobile(): boolean;
26
+ /**
27
+ * Show a window (or in Obsidian, a leaf).
28
+ * @param type The type of window to show.
29
+ */
30
+ abstract showWindow(type: string): Promise<void>;
31
+ /**
32
+ * Show a window on the right sidebar when supported.
33
+ * Platforms that do not support sidebars can fall back to showWindow.
34
+ */
35
+ showWindowOnRight(type: string): Promise<void>;
36
+ /**
37
+ * returns App ID. In Obsidian, it is vault ID.
38
+ */
39
+ abstract getAppID(): string;
40
+ /**
41
+ * Returns the vaultName which system has identified, without any additional suffix.
42
+ */
43
+ abstract getSystemVaultName(): string;
44
+ /**
45
+ * Check if the last POST request failed due to payload size.
46
+ */
47
+ abstract getPlatform(): string;
48
+ abstract getAppVersion(): string;
49
+ abstract getPluginVersion(): string;
50
+ abstract getCrypto(): Crypto;
51
+ /**
52
+ * Register a command to the runtime.
53
+ * @param command
54
+ */
55
+ abstract addCommand<TCommand extends ICommandCompat>(command: TCommand): TCommand;
56
+ /**
57
+ * Register a window (or leaf) type to the runtime.
58
+ * @param type
59
+ * @param factory
60
+ */
61
+ abstract registerWindow<T>(type: string, factory: (leaf: T) => unknown): void;
62
+ /**
63
+ * Add a ribbon icon to the UI.
64
+ * @param icon
65
+ * @param title
66
+ * @param callback
67
+ */
68
+ abstract addRibbonIcon(icon: string, title: string, callback: (evt: MouseEvent) => unknown): HTMLElement;
69
+ /**
70
+ * Register a protocol handler.
71
+ * @param action The action string for the protocol.
72
+ * @param handler The handler function for the protocol.
73
+ */
74
+ abstract registerProtocolHandler(action: string, handler: (params: Record<string, string>) => unknown): void;
75
+ /**
76
+ * Get the basic UI component for showing a confirmation dialog to the user.
77
+ */
78
+ abstract get confirm(): Confirm;
79
+ requestCount: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
80
+ responseCount: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
81
+ get isOnline(): boolean;
82
+ webCompatFetch(req: string | Request, opts?: RequestInit): Promise<Response>;
83
+ nativeFetch(req: string | Request, opts?: RequestInit): Promise<Response>;
84
+ abstract addStatusBarItem(): HTMLElement | undefined;
85
+ setInterval(handler: () => void, timeout: number): number;
86
+ clearInterval(timerId: number): void;
87
+ /**
88
+ * Get the system configuration directory.
89
+ * This is used for storing configuration files in a consistent location across platforms.
90
+ * @returns
91
+ */
92
+ getSystemConfigDir(): string;
93
+ }
@@ -0,0 +1,44 @@
1
+ import { ServiceBase } from "./ServiceBase.js";
2
+ import { reactiveSource } from "octagonal-wheels/dataobject/reactive";
3
+ import { _fetch, compatGlobal } from "../../common/coreEnvFunctions.js";
4
+ class APIService extends ServiceBase {
5
+ /**
6
+ * Show a window on the right sidebar when supported.
7
+ * Platforms that do not support sidebars can fall back to showWindow.
8
+ */
9
+ showWindowOnRight(type) {
10
+ return this.showWindow(type);
11
+ }
12
+ requestCount = reactiveSource(0);
13
+ responseCount = reactiveSource(0);
14
+ get isOnline() {
15
+ if ("navigator" in compatGlobal) {
16
+ return compatGlobal.navigator.onLine;
17
+ }
18
+ return true;
19
+ }
20
+ webCompatFetch(req, opts) {
21
+ return _fetch(req, opts);
22
+ }
23
+ // By default, nativeFetch is not implemented. It can be overridden by platforms that support it (e.g., ObsidianAPIService).
24
+ nativeFetch(req, opts) {
25
+ throw new Error("nativeFetch is not implemented for this platform");
26
+ }
27
+ setInterval(handler, timeout) {
28
+ return compatGlobal.setInterval(handler, timeout);
29
+ }
30
+ clearInterval(timerId) {
31
+ compatGlobal.clearInterval(timerId);
32
+ }
33
+ /**
34
+ * Get the system configuration directory.
35
+ * This is used for storing configuration files in a consistent location across platforms.
36
+ * @returns
37
+ */
38
+ getSystemConfigDir() {
39
+ return ".livesync";
40
+ }
41
+ }
42
+ export {
43
+ APIService
44
+ };
@@ -0,0 +1,132 @@
1
+ import type { IAppLifecycleService, ISettingService } from "./IService.js";
2
+ import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
3
+ export interface AppLifecycleServiceDependencies {
4
+ settingService: ISettingService;
5
+ }
6
+ /**
7
+ * The AppLifecycleService provides methods for managing the plug-in's lifecycle events.
8
+ */
9
+ export declare abstract class AppLifecycleService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IAppLifecycleService {
10
+ protected readonly settingService: ISettingService;
11
+ constructor(context: T, dependencies: AppLifecycleServiceDependencies);
12
+ /**
13
+ * Event triggered when the plug-in's layout is ready.
14
+ * In Obsidian, it is after the workspace is ready.
15
+ */
16
+ readonly onLayoutReady: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
17
+ /**
18
+ * Event triggered when the plug-in is being initialized for the first time.
19
+ * This is only called once per plug-in lifecycle.
20
+ */
21
+ readonly onFirstInitialise: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
22
+ /**
23
+ * Event triggered when the plug-in is fully ready.
24
+ * This is called after all initialisation processes are complete.
25
+ */
26
+ readonly onReady: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
27
+ /**
28
+ * Event triggered to wire up necessary event listeners.
29
+ * This is typically called during the initialisation phase.
30
+ */
31
+ readonly onWireUpEvents: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
32
+ /**
33
+ * Event triggered when the plug-in is being initialised.
34
+ */
35
+ readonly onInitialise: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
36
+ /**
37
+ * Event triggered when the plug-in is loading.
38
+ * This is typically called during the quite early initialisation phase, before everything.
39
+ * In Obsidian, it is in the onload() method of the plugin.
40
+ */
41
+ readonly onLoad: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
42
+ /**
43
+ * Event triggered when the plug-in's settings have been loaded and applied.
44
+ */
45
+ readonly onSettingLoaded: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
46
+ /**
47
+ * Event triggered when the plug-in has fully loaded.
48
+ * This is typically called after all initialisation and loading processes are complete.
49
+ */
50
+ readonly onLoaded: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
51
+ /**
52
+ * Scan for any startup issues that may affect the plug-in's operation.
53
+ */
54
+ readonly onScanningStartupIssues: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
55
+ /**
56
+ * Event triggered when the plug-in is unloading (e.g., during app shutdown or plug-in disable).
57
+ * This is typically called during the unload() method of the plugin.
58
+ * Entry point to unload everything.
59
+ */
60
+ readonly onAppUnload: import("../lib/HandlerUtils.js").CollectiveHandlerFunction<() => Promise<undefined[]>, unknown>;
61
+ /**
62
+ * Event triggered before the plug-in is unloaded.
63
+ * This is typically used to perform any necessary cleanup or save state before the plug-in is unloaded.
64
+ */
65
+ readonly onBeforeUnload: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
66
+ /**
67
+ * Event triggered when the plug-in is being unloaded.
68
+ */
69
+ readonly onUnload: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
70
+ /**
71
+ * Perform an immediate restart of the application.
72
+ * Note that this is not graceful, and not only the plug-in. APPLICATION (means Obsidian) will be restarted.
73
+ */
74
+ abstract performRestart(): void;
75
+ /**
76
+ * Ask the user for a restart.
77
+ * @param message Optional message to display to the user when asking for a restart.
78
+ */
79
+ abstract askRestart(message?: string): void;
80
+ /**
81
+ * Schedule a restart of the application.
82
+ * After the current operation is done, the application will be restarted.
83
+ * Note that this is not graceful, and not only the plug-in. APPLICATION (means Obsidian) will be restarted.
84
+ */
85
+ abstract scheduleRestart(): void;
86
+ /**
87
+ * Event triggered when the application is being suspended (e.g., system sleep).
88
+ */
89
+ readonly onSuspending: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
90
+ /**
91
+ * Event triggered when the application is resuming from a suspended state.
92
+ */
93
+ readonly onResuming: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
94
+ /**
95
+ * Event triggered after the application has resumed from a suspended state.
96
+ */
97
+ readonly onResumed: import("../lib/HandlerUtils.js").BooleanMultipleHandlerFunction<() => Promise<boolean>>;
98
+ private _isSuspended;
99
+ /**
100
+ * Check if the plug-in is currently suspended.
101
+ * Also consider the plug-in as suspended if it is not configured, to prevent any issues before configuration.
102
+ */
103
+ isSuspended(): boolean;
104
+ /**
105
+ * Set the suspension state of the plug-in.
106
+ * @param suspend Set to true to suspend the plug-in, false to resume.
107
+ */
108
+ setSuspended(suspend: boolean): void;
109
+ private _isReady;
110
+ /**
111
+ * Check if the plug-in is ready.
112
+ * A ready plug-in means it has been fully initialised and is operational.
113
+ * If not ready, most operations will be blocked.
114
+ */
115
+ isReady(): boolean;
116
+ /**
117
+ * Mark the plug-in as ready.
118
+ */
119
+ markIsReady(): void;
120
+ /**
121
+ * Reset the ready state of the plug-in.
122
+ */
123
+ resetIsReady(): void;
124
+ /**
125
+ * Check if a restart has been scheduled.
126
+ */
127
+ abstract isReloadingScheduled(): boolean;
128
+ /**
129
+ * Get unresolved error messages.
130
+ */
131
+ readonly getUnresolvedMessages: import("../lib/HandlerUtils.js").CollectiveHandlerFunction<() => Promise<(string | Error)[][]>, unknown>;
132
+ }
@@ -0,0 +1,123 @@
1
+ import { handlers } from "../lib/HandlerUtils.js";
2
+ import { ServiceBase } from "./ServiceBase.js";
3
+ class AppLifecycleService extends ServiceBase {
4
+ settingService;
5
+ constructor(context, dependencies) {
6
+ super(context);
7
+ this.settingService = dependencies.settingService;
8
+ }
9
+ /**
10
+ * Event triggered when the plug-in's layout is ready.
11
+ * In Obsidian, it is after the workspace is ready.
12
+ */
13
+ onLayoutReady = handlers().bailFirstFailure("onLayoutReady");
14
+ /**
15
+ * Event triggered when the plug-in is being initialized for the first time.
16
+ * This is only called once per plug-in lifecycle.
17
+ */
18
+ onFirstInitialise = handlers().bailFirstFailure("onFirstInitialise");
19
+ /**
20
+ * Event triggered when the plug-in is fully ready.
21
+ * This is called after all initialisation processes are complete.
22
+ */
23
+ onReady = handlers().bailFirstFailure("onReady");
24
+ /**
25
+ * Event triggered to wire up necessary event listeners.
26
+ * This is typically called during the initialisation phase.
27
+ */
28
+ onWireUpEvents = handlers().bailFirstFailure("onWireUpEvents");
29
+ /**
30
+ * Event triggered when the plug-in is being initialised.
31
+ */
32
+ onInitialise = handlers().bailFirstFailure("onInitialise");
33
+ /**
34
+ * Event triggered when the plug-in is loading.
35
+ * This is typically called during the quite early initialisation phase, before everything.
36
+ * In Obsidian, it is in the onload() method of the plugin.
37
+ */
38
+ onLoad = handlers().bailFirstFailure("onLoad");
39
+ /**
40
+ * Event triggered when the plug-in's settings have been loaded and applied.
41
+ */
42
+ onSettingLoaded = handlers().bailFirstFailure("onSettingLoaded");
43
+ /**
44
+ * Event triggered when the plug-in has fully loaded.
45
+ * This is typically called after all initialisation and loading processes are complete.
46
+ */
47
+ onLoaded = handlers().bailFirstFailure("onLoaded");
48
+ /**
49
+ * Scan for any startup issues that may affect the plug-in's operation.
50
+ */
51
+ onScanningStartupIssues = handlers().all("onScanningStartupIssues");
52
+ /**
53
+ * Event triggered when the plug-in is unloading (e.g., during app shutdown or plug-in disable).
54
+ * This is typically called during the unload() method of the plugin.
55
+ * Entry point to unload everything.
56
+ */
57
+ onAppUnload = handlers().dispatchParallel("onAppUnload");
58
+ /**
59
+ * Event triggered before the plug-in is unloaded.
60
+ * This is typically used to perform any necessary cleanup or save state before the plug-in is unloaded.
61
+ */
62
+ onBeforeUnload = handlers().all("onBeforeUnload");
63
+ /**
64
+ * Event triggered when the plug-in is being unloaded.
65
+ */
66
+ onUnload = handlers().all("onUnload");
67
+ /**
68
+ * Event triggered when the application is being suspended (e.g., system sleep).
69
+ */
70
+ onSuspending = handlers().bailFirstFailure("onSuspending");
71
+ /**
72
+ * Event triggered when the application is resuming from a suspended state.
73
+ */
74
+ onResuming = handlers().bailFirstFailure("onResuming");
75
+ /**
76
+ * Event triggered after the application has resumed from a suspended state.
77
+ */
78
+ onResumed = handlers().bailFirstFailure("onResumed");
79
+ _isSuspended = false;
80
+ /**
81
+ * Check if the plug-in is currently suspended.
82
+ * Also consider the plug-in as suspended if it is not configured, to prevent any issues before configuration.
83
+ */
84
+ isSuspended() {
85
+ const settings = this.settingService.currentSettings();
86
+ return this._isSuspended || !settings?.isConfigured;
87
+ }
88
+ /**
89
+ * Set the suspension state of the plug-in.
90
+ * @param suspend Set to true to suspend the plug-in, false to resume.
91
+ */
92
+ setSuspended(suspend) {
93
+ this._isSuspended = suspend;
94
+ }
95
+ _isReady = false;
96
+ /**
97
+ * Check if the plug-in is ready.
98
+ * A ready plug-in means it has been fully initialised and is operational.
99
+ * If not ready, most operations will be blocked.
100
+ */
101
+ isReady() {
102
+ return this._isReady;
103
+ }
104
+ /**
105
+ * Mark the plug-in as ready.
106
+ */
107
+ markIsReady() {
108
+ this._isReady = true;
109
+ }
110
+ /**
111
+ * Reset the ready state of the plug-in.
112
+ */
113
+ resetIsReady() {
114
+ this._isReady = false;
115
+ }
116
+ /**
117
+ * Get unresolved error messages.
118
+ */
119
+ getUnresolvedMessages = handlers().dispatchParallel("getUnresolvedMessages");
120
+ }
121
+ export {
122
+ AppLifecycleService
123
+ };
@@ -0,0 +1,7 @@
1
+ import type { IConfigService } from "./IService.js";
2
+ import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
3
+ export declare abstract class ConfigService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IConfigService {
4
+ abstract getSmallConfig(key: string): string | null;
5
+ abstract setSmallConfig(key: string, value: string): void;
6
+ abstract deleteSmallConfig(key: string): void;
7
+ }
@@ -0,0 +1,6 @@
1
+ import { ServiceBase } from "./ServiceBase.js";
2
+ class ConfigService extends ServiceBase {
3
+ }
4
+ export {
5
+ ConfigService
6
+ };
@@ -0,0 +1,54 @@
1
+ import type { FilePathWithPrefix, MISSING_OR_ERROR, AUTO_MERGED } from "../../common/types.js";
2
+ import type { IConflictService } from "./IService.js";
3
+ import { ServiceBase } from "./ServiceBase.js";
4
+ import type { ServiceContext } from "./ServiceBase.js";
5
+ /**
6
+ * The ConflictService provides methods for handling file conflicts.
7
+ */
8
+ export declare abstract class ConflictService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IConflictService {
9
+ /**
10
+ * Get an optional conflict check method for a given file (virtual) path.
11
+ */
12
+ readonly getOptionalConflictCheckMethod: import("../lib/HandlerUtils.js").MultipleHandlerFunction<(path: FilePathWithPrefix) => Promise<boolean | undefined | "newer">, unknown>;
13
+ /**
14
+ * Queue a check for conflicts if the file is currently open in the editor.
15
+ * @param path The file (virtual) path to check for conflicts.
16
+ */
17
+ abstract queueCheckForIfOpen(path: FilePathWithPrefix): Promise<void>;
18
+ /**
19
+ * Queue a check for conflicts for a given file (virtual) path.
20
+ * @param path The file (virtual) path to check for conflicts.
21
+ */
22
+ abstract queueCheckFor(path: FilePathWithPrefix): Promise<void>;
23
+ /**
24
+ * Ensure all queued file conflict checks are processed.
25
+ */
26
+ abstract ensureAllProcessed(): Promise<boolean>;
27
+ /**
28
+ * Resolve a conflict by user interaction (e.g., showing a modal dialog).
29
+ * @param filename The file (virtual) path with conflict.
30
+ * @param conflictCheckResult The result of the conflict check.
31
+ * @returns A promise that resolves to true if the conflict was resolved, false if not, or undefined if no action was taken.
32
+ */
33
+ readonly resolveByUserInteraction: import("../lib/HandlerUtils.js").MultipleHandlerFunction<(filename: FilePathWithPrefix, conflictCheckResult: import("../../common/types.js").diff_result) => Promise<boolean | undefined>, unknown>;
34
+ /**
35
+ * Resolve a conflict by deleting a specific revision.
36
+ * @param path The file (virtual) path with conflict.
37
+ * @param deleteRevision The revision to delete.
38
+ * @param title The title of the conflict (for user display).
39
+ */
40
+ abstract resolveByDeletingRevision(path: FilePathWithPrefix, deleteRevision: string, title: string): Promise<typeof MISSING_OR_ERROR | typeof AUTO_MERGED>;
41
+ /**
42
+ * Resolve a conflict as several possible strategies.
43
+ * It may involve user interaction (means raising resolveByUserInteraction).
44
+ * @param filename The file (virtual) path to resolve.
45
+ */
46
+ abstract resolve(filename: FilePathWithPrefix): Promise<void>;
47
+ /**
48
+ * Resolve a conflict by choosing the newest version.
49
+ * @param filename The file (virtual) path to resolve.
50
+ */
51
+ abstract resolveByNewest(filename: FilePathWithPrefix): Promise<boolean>;
52
+ abstract resolveAllConflictedFilesByNewerOnes(): Promise<void>;
53
+ conflictProcessQueueCount: import("octagonal-wheels/dataobject/reactive_v2").ReactiveSource<number>;
54
+ }
@@ -0,0 +1,22 @@
1
+ import { handlers } from "../lib/HandlerUtils.js";
2
+ import { ServiceBase } from "./ServiceBase.js";
3
+ import { reactiveSource } from "octagonal-wheels/dataobject/reactive";
4
+ class ConflictService extends ServiceBase {
5
+ /**
6
+ * Get an optional conflict check method for a given file (virtual) path.
7
+ */
8
+ getOptionalConflictCheckMethod = handlers().firstResult(
9
+ "getOptionalConflictCheckMethod"
10
+ );
11
+ /**
12
+ * Resolve a conflict by user interaction (e.g., showing a modal dialog).
13
+ * @param filename The file (virtual) path with conflict.
14
+ * @param conflictCheckResult The result of the conflict check.
15
+ * @returns A promise that resolves to true if the conflict was resolved, false if not, or undefined if no action was taken.
16
+ */
17
+ resolveByUserInteraction = handlers().firstResult("resolveByUserInteraction");
18
+ conflictProcessQueueCount = reactiveSource(0);
19
+ }
20
+ export {
21
+ ConflictService
22
+ };
@@ -0,0 +1,54 @@
1
+ import { createInstanceLogFunction } from "../lib/logUtils.js";
2
+ import type { APIService } from "./APIService.js";
3
+ import type { DatabaseService } from "./DatabaseService.js";
4
+ import type { IControlService, IFileProcessingService, IReplicatorService, ISettingService } from "./IService.js";
5
+ import { ServiceBase, type ServiceContext } from "./ServiceBase.js";
6
+ import { type PromiseWithResolvers } from "octagonal-wheels/promises";
7
+ import type { AppLifecycleService } from "./AppLifecycleService.js";
8
+ export interface ControlServiceDependencies {
9
+ appLifecycleService: AppLifecycleService;
10
+ replicatorService: IReplicatorService;
11
+ settingService: ISettingService;
12
+ databaseService: DatabaseService;
13
+ fileProcessingService: IFileProcessingService;
14
+ APIService: APIService;
15
+ }
16
+ /**
17
+ * The ControlService provides methods for controlling the overall behaviour of the plugin, such as applying settings or handling lifecycle events.
18
+ */
19
+ export declare class ControlService<T extends ServiceContext = ServiceContext> extends ServiceBase<T> implements IControlService {
20
+ protected services: ControlServiceDependencies;
21
+ protected _log: ReturnType<typeof createInstanceLogFunction>;
22
+ protected _unloaded: boolean;
23
+ protected _activated: PromiseWithResolvers<boolean>;
24
+ /**
25
+ * Check if the plug-in has been unloaded.
26
+ */
27
+ hasUnloaded(): boolean;
28
+ constructor(context: T, dependencies: ControlServiceDependencies);
29
+ get activated(): Promise<boolean>;
30
+ private onActivated;
31
+ /**
32
+ * Apply current settings to reflect the changes immediately.
33
+ * @returns
34
+ */
35
+ applySettings(): Promise<void>;
36
+ private _onLiveSyncUnload;
37
+ /**
38
+ * Called when the plugin is loaded. It will trigger the app lifecycle event onLoad.
39
+ * Main process should be called in onReady.
40
+ * @returns
41
+ */
42
+ onLoad(): Promise<boolean>;
43
+ /**
44
+ * Main entry point of the plugin. It will trigger the app lifecycle event onReady.
45
+ * Usually it should be called on `app.workspace.onLayoutReady`
46
+ * @returns
47
+ */
48
+ onReady(): Promise<boolean>;
49
+ /**
50
+ * On unload event of the plugin. It will trigger the app lifecycle event onUnload.
51
+ * @returns
52
+ */
53
+ onUnload(): Promise<void>;
54
+ }
@@ -0,0 +1,103 @@
1
+ import { LOG_LEVEL_URGENT } from "octagonal-wheels/common/logger";
2
+ import { createInstanceLogFunction } from "../lib/logUtils.js";
3
+ import { ServiceBase } from "./ServiceBase.js";
4
+ import { EVENT_PLATFORM_UNLOADED, EVENT_PLUGIN_UNLOADED } from "../../events/coreEvents.js";
5
+ import { cancelAllPeriodicTask, cancelAllTasks } from "octagonal-wheels/concurrency/task";
6
+ import { stopAllRunningProcessors } from "octagonal-wheels/concurrency/processor";
7
+ import { promiseWithResolvers } from "octagonal-wheels/promises";
8
+ class ControlService extends ServiceBase {
9
+ services;
10
+ _log;
11
+ _unloaded = false;
12
+ _activated;
13
+ /**
14
+ * Check if the plug-in has been unloaded.
15
+ */
16
+ hasUnloaded() {
17
+ return this._unloaded;
18
+ }
19
+ constructor(context, dependencies) {
20
+ super(context);
21
+ this.services = dependencies;
22
+ this._log = createInstanceLogFunction("ControlService", this.services.APIService);
23
+ this._activated = promiseWithResolvers();
24
+ this.services.appLifecycleService.onLoaded.addHandler(() => {
25
+ this.onActivated();
26
+ return Promise.resolve(true);
27
+ });
28
+ }
29
+ get activated() {
30
+ return this._activated.promise;
31
+ }
32
+ onActivated() {
33
+ this._activated.resolve(true);
34
+ }
35
+ /**
36
+ * Apply current settings to reflect the changes immediately.
37
+ * @returns
38
+ */
39
+ async applySettings() {
40
+ await this.services.appLifecycleService.onSuspending();
41
+ await this.services.settingService.onBeforeRealiseSetting();
42
+ this.services.databaseService.localDatabase.refreshSettings();
43
+ await this.services.fileProcessingService.commitPendingFileEvents();
44
+ await this.services.settingService.onRealiseSetting();
45
+ if (this.services.appLifecycleService.isSuspended()) return;
46
+ await this.services.appLifecycleService.onResuming();
47
+ await this.services.appLifecycleService.onResumed();
48
+ await this.services.settingService.onSettingRealised();
49
+ }
50
+ async _onLiveSyncUnload() {
51
+ this.context.events.emitEvent(EVENT_PLUGIN_UNLOADED);
52
+ await this.services.appLifecycleService.onBeforeUnload();
53
+ await Promise.resolve(this.services.appLifecycleService.onAppUnload());
54
+ cancelAllPeriodicTask();
55
+ cancelAllTasks();
56
+ stopAllRunningProcessors();
57
+ await this.services.appLifecycleService.onUnload();
58
+ this._unloaded = true;
59
+ const localDatabase = this.services.databaseService.localDatabaseDirect;
60
+ if (localDatabase != null) {
61
+ const activeReplicator = this.services.replicatorService.getActiveReplicator();
62
+ if (activeReplicator) {
63
+ activeReplicator.closeReplication();
64
+ }
65
+ localDatabase.onunload();
66
+ await localDatabase.close();
67
+ }
68
+ this.context.events.emitEvent(EVENT_PLATFORM_UNLOADED);
69
+ this.context.events.offAll();
70
+ this._log(this.context.translate("moduleLiveSyncMain.logUnloadingPlugin"));
71
+ return;
72
+ }
73
+ /**
74
+ * Called when the plugin is loaded. It will trigger the app lifecycle event onLoad.
75
+ * Main process should be called in onReady.
76
+ * @returns
77
+ */
78
+ async onLoad() {
79
+ if (!await this.services.appLifecycleService.onLoad()) {
80
+ this._log("Self-hosted LiveSync cannot be initialised, exiting loading.", LOG_LEVEL_URGENT);
81
+ return false;
82
+ }
83
+ return true;
84
+ }
85
+ /**
86
+ * Main entry point of the plugin. It will trigger the app lifecycle event onReady.
87
+ * Usually it should be called on `app.workspace.onLayoutReady`
88
+ * @returns
89
+ */
90
+ async onReady() {
91
+ return await this.services.appLifecycleService.onReady();
92
+ }
93
+ /**
94
+ * On unload event of the plugin. It will trigger the app lifecycle event onUnload.
95
+ * @returns
96
+ */
97
+ async onUnload() {
98
+ return await this._onLiveSyncUnload();
99
+ }
100
+ }
101
+ export {
102
+ ControlService
103
+ };