@dittolive/ditto 4.5.0 → 4.5.1-experimental.aarch64-linux.1.aarch64

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 (289) hide show
  1. package/README.md +2 -2
  2. package/node/ditto.cjs.js +2 -9620
  3. package/node/{ditto.linux-x64.node → ditto.linux-arm64.node} +0 -0
  4. package/package.json +38 -34
  5. package/types/ditto.d.ts +0 -2
  6. package/web/ditto.es6.js +1 -1
  7. package/web/ditto.umd.js +1 -1
  8. package/web/ditto.wasm +0 -0
  9. package/DittoReactNative.podspec +0 -27
  10. package/node/ditto.darwin-arm64.node +0 -0
  11. package/node/ditto.darwin-x64.node +0 -0
  12. package/node/ditto.linux-arm.node +0 -0
  13. package/node/ditto.win32-x64.node +0 -0
  14. package/node/transports.darwin-arm64.node +0 -0
  15. package/node/transports.darwin-x64.node +0 -0
  16. package/react-native/android/CMakeLists.txt +0 -37
  17. package/react-native/android/build.gradle +0 -203
  18. package/react-native/android/cpp-adapter.cpp +0 -254
  19. package/react-native/android/gradle.properties +0 -5
  20. package/react-native/android/src/main/AndroidManifest.xml +0 -4
  21. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +0 -85
  22. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +0 -28
  23. package/react-native/boost/boost/assert.hpp +0 -85
  24. package/react-native/boost/boost/config/abi/borland_prefix.hpp +0 -27
  25. package/react-native/boost/boost/config/abi/borland_suffix.hpp +0 -12
  26. package/react-native/boost/boost/config/abi/msvc_prefix.hpp +0 -22
  27. package/react-native/boost/boost/config/abi/msvc_suffix.hpp +0 -8
  28. package/react-native/boost/boost/config/abi_prefix.hpp +0 -25
  29. package/react-native/boost/boost/config/abi_suffix.hpp +0 -25
  30. package/react-native/boost/boost/config/assert_cxx03.hpp +0 -211
  31. package/react-native/boost/boost/config/assert_cxx11.hpp +0 -209
  32. package/react-native/boost/boost/config/assert_cxx14.hpp +0 -47
  33. package/react-native/boost/boost/config/assert_cxx17.hpp +0 -62
  34. package/react-native/boost/boost/config/assert_cxx20.hpp +0 -59
  35. package/react-native/boost/boost/config/assert_cxx98.hpp +0 -23
  36. package/react-native/boost/boost/config/auto_link.hpp +0 -525
  37. package/react-native/boost/boost/config/compiler/borland.hpp +0 -339
  38. package/react-native/boost/boost/config/compiler/clang.hpp +0 -366
  39. package/react-native/boost/boost/config/compiler/clang_version.hpp +0 -83
  40. package/react-native/boost/boost/config/compiler/codegear.hpp +0 -385
  41. package/react-native/boost/boost/config/compiler/comeau.hpp +0 -59
  42. package/react-native/boost/boost/config/compiler/common_edg.hpp +0 -183
  43. package/react-native/boost/boost/config/compiler/compaq_cxx.hpp +0 -19
  44. package/react-native/boost/boost/config/compiler/cray.hpp +0 -446
  45. package/react-native/boost/boost/config/compiler/diab.hpp +0 -26
  46. package/react-native/boost/boost/config/compiler/digitalmars.hpp +0 -143
  47. package/react-native/boost/boost/config/compiler/gcc.hpp +0 -383
  48. package/react-native/boost/boost/config/compiler/gcc_xml.hpp +0 -114
  49. package/react-native/boost/boost/config/compiler/greenhills.hpp +0 -28
  50. package/react-native/boost/boost/config/compiler/hp_acc.hpp +0 -149
  51. package/react-native/boost/boost/config/compiler/intel.hpp +0 -577
  52. package/react-native/boost/boost/config/compiler/kai.hpp +0 -33
  53. package/react-native/boost/boost/config/compiler/metrowerks.hpp +0 -198
  54. package/react-native/boost/boost/config/compiler/mpw.hpp +0 -140
  55. package/react-native/boost/boost/config/compiler/nvcc.hpp +0 -61
  56. package/react-native/boost/boost/config/compiler/pathscale.hpp +0 -138
  57. package/react-native/boost/boost/config/compiler/pgi.hpp +0 -23
  58. package/react-native/boost/boost/config/compiler/sgi_mipspro.hpp +0 -29
  59. package/react-native/boost/boost/config/compiler/sunpro_cc.hpp +0 -222
  60. package/react-native/boost/boost/config/compiler/vacpp.hpp +0 -186
  61. package/react-native/boost/boost/config/compiler/visualc.hpp +0 -391
  62. package/react-native/boost/boost/config/compiler/xlcpp.hpp +0 -299
  63. package/react-native/boost/boost/config/compiler/xlcpp_zos.hpp +0 -173
  64. package/react-native/boost/boost/config/detail/cxx_composite.hpp +0 -203
  65. package/react-native/boost/boost/config/detail/posix_features.hpp +0 -95
  66. package/react-native/boost/boost/config/detail/select_compiler_config.hpp +0 -157
  67. package/react-native/boost/boost/config/detail/select_platform_config.hpp +0 -147
  68. package/react-native/boost/boost/config/detail/select_stdlib_config.hpp +0 -121
  69. package/react-native/boost/boost/config/detail/suffix.hpp +0 -1294
  70. package/react-native/boost/boost/config/header_deprecated.hpp +0 -26
  71. package/react-native/boost/boost/config/helper_macros.hpp +0 -37
  72. package/react-native/boost/boost/config/no_tr1/cmath.hpp +0 -28
  73. package/react-native/boost/boost/config/no_tr1/complex.hpp +0 -28
  74. package/react-native/boost/boost/config/no_tr1/functional.hpp +0 -28
  75. package/react-native/boost/boost/config/no_tr1/memory.hpp +0 -28
  76. package/react-native/boost/boost/config/no_tr1/utility.hpp +0 -28
  77. package/react-native/boost/boost/config/platform/aix.hpp +0 -33
  78. package/react-native/boost/boost/config/platform/amigaos.hpp +0 -15
  79. package/react-native/boost/boost/config/platform/beos.hpp +0 -26
  80. package/react-native/boost/boost/config/platform/bsd.hpp +0 -83
  81. package/react-native/boost/boost/config/platform/cloudabi.hpp +0 -18
  82. package/react-native/boost/boost/config/platform/cray.hpp +0 -18
  83. package/react-native/boost/boost/config/platform/cygwin.hpp +0 -71
  84. package/react-native/boost/boost/config/platform/haiku.hpp +0 -31
  85. package/react-native/boost/boost/config/platform/hpux.hpp +0 -87
  86. package/react-native/boost/boost/config/platform/irix.hpp +0 -31
  87. package/react-native/boost/boost/config/platform/linux.hpp +0 -106
  88. package/react-native/boost/boost/config/platform/macos.hpp +0 -87
  89. package/react-native/boost/boost/config/platform/qnxnto.hpp +0 -31
  90. package/react-native/boost/boost/config/platform/solaris.hpp +0 -31
  91. package/react-native/boost/boost/config/platform/symbian.hpp +0 -97
  92. package/react-native/boost/boost/config/platform/vms.hpp +0 -25
  93. package/react-native/boost/boost/config/platform/vxworks.hpp +0 -422
  94. package/react-native/boost/boost/config/platform/wasm.hpp +0 -23
  95. package/react-native/boost/boost/config/platform/win32.hpp +0 -90
  96. package/react-native/boost/boost/config/platform/zos.hpp +0 -32
  97. package/react-native/boost/boost/config/pragma_message.hpp +0 -31
  98. package/react-native/boost/boost/config/requires_threads.hpp +0 -92
  99. package/react-native/boost/boost/config/stdlib/dinkumware.hpp +0 -324
  100. package/react-native/boost/boost/config/stdlib/libcomo.hpp +0 -93
  101. package/react-native/boost/boost/config/stdlib/libcpp.hpp +0 -180
  102. package/react-native/boost/boost/config/stdlib/libstdcpp3.hpp +0 -482
  103. package/react-native/boost/boost/config/stdlib/modena.hpp +0 -79
  104. package/react-native/boost/boost/config/stdlib/msl.hpp +0 -98
  105. package/react-native/boost/boost/config/stdlib/roguewave.hpp +0 -208
  106. package/react-native/boost/boost/config/stdlib/sgi.hpp +0 -168
  107. package/react-native/boost/boost/config/stdlib/stlport.hpp +0 -258
  108. package/react-native/boost/boost/config/stdlib/vacpp.hpp +0 -74
  109. package/react-native/boost/boost/config/stdlib/xlcpp_zos.hpp +0 -61
  110. package/react-native/boost/boost/config/user.hpp +0 -133
  111. package/react-native/boost/boost/config/warning_disable.hpp +0 -47
  112. package/react-native/boost/boost/config/workaround.hpp +0 -305
  113. package/react-native/boost/boost/config.hpp +0 -67
  114. package/react-native/boost/boost/cstdint.hpp +0 -556
  115. package/react-native/boost/boost/intrusive_ptr.hpp +0 -18
  116. package/react-native/boost/boost/smart_ptr/detail/atomic_count.hpp +0 -103
  117. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc.hpp +0 -79
  118. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp +0 -63
  119. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_x86.hpp +0 -88
  120. package/react-native/boost/boost/smart_ptr/detail/atomic_count_nt.hpp +0 -66
  121. package/react-native/boost/boost/smart_ptr/detail/atomic_count_pt.hpp +0 -104
  122. package/react-native/boost/boost/smart_ptr/detail/atomic_count_spin.hpp +0 -69
  123. package/react-native/boost/boost/smart_ptr/detail/atomic_count_std_atomic.hpp +0 -67
  124. package/react-native/boost/boost/smart_ptr/detail/atomic_count_sync.hpp +0 -72
  125. package/react-native/boost/boost/smart_ptr/detail/atomic_count_win32.hpp +0 -70
  126. package/react-native/boost/boost/smart_ptr/detail/local_counted_base.hpp +0 -148
  127. package/react-native/boost/boost/smart_ptr/detail/local_sp_deleter.hpp +0 -91
  128. package/react-native/boost/boost/smart_ptr/detail/operator_bool.hpp +0 -64
  129. package/react-native/boost/boost/smart_ptr/detail/requires_cxx11.hpp +0 -23
  130. package/react-native/boost/boost/smart_ptr/detail/shared_count.hpp +0 -707
  131. package/react-native/boost/boost/smart_ptr/detail/sp_convertible.hpp +0 -92
  132. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base.hpp +0 -92
  133. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +0 -163
  134. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_aix.hpp +0 -152
  135. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +0 -185
  136. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp +0 -148
  137. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +0 -170
  138. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +0 -200
  139. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +0 -194
  140. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +0 -179
  141. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +0 -186
  142. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_nt.hpp +0 -119
  143. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_pt.hpp +0 -147
  144. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +0 -174
  145. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_spin.hpp +0 -141
  146. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +0 -147
  147. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp +0 -165
  148. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +0 -163
  149. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_w32.hpp +0 -140
  150. package/react-native/boost/boost/smart_ptr/detail/sp_counted_impl.hpp +0 -309
  151. package/react-native/boost/boost/smart_ptr/detail/sp_disable_deprecated.hpp +0 -40
  152. package/react-native/boost/boost/smart_ptr/detail/sp_forward.hpp +0 -52
  153. package/react-native/boost/boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp +0 -27
  154. package/react-native/boost/boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp +0 -69
  155. package/react-native/boost/boost/smart_ptr/detail/sp_interlocked.hpp +0 -173
  156. package/react-native/boost/boost/smart_ptr/detail/sp_noexcept.hpp +0 -48
  157. package/react-native/boost/boost/smart_ptr/detail/sp_nullptr_t.hpp +0 -45
  158. package/react-native/boost/boost/smart_ptr/detail/sp_obsolete.hpp +0 -32
  159. package/react-native/boost/boost/smart_ptr/detail/sp_thread_pause.hpp +0 -51
  160. package/react-native/boost/boost/smart_ptr/detail/sp_thread_sleep.hpp +0 -104
  161. package/react-native/boost/boost/smart_ptr/detail/sp_thread_yield.hpp +0 -100
  162. package/react-native/boost/boost/smart_ptr/detail/sp_typeinfo_.hpp +0 -58
  163. package/react-native/boost/boost/smart_ptr/detail/sp_win32_sleep.hpp +0 -49
  164. package/react-native/boost/boost/smart_ptr/intrusive_ptr.hpp +0 -409
  165. package/react-native/boost/boost/smart_ptr/intrusive_ref_counter.hpp +0 -188
  166. package/react-native/cpp/include/Attachment.h +0 -16
  167. package/react-native/cpp/include/Authentication.h +0 -23
  168. package/react-native/cpp/include/Collection.h +0 -13
  169. package/react-native/cpp/include/DQL.h +0 -21
  170. package/react-native/cpp/include/Document.h +0 -17
  171. package/react-native/cpp/include/Identity.h +0 -17
  172. package/react-native/cpp/include/Lifecycle.h +0 -16
  173. package/react-native/cpp/include/LiveQuery.h +0 -17
  174. package/react-native/cpp/include/Logger.h +0 -22
  175. package/react-native/cpp/include/Misc.h +0 -26
  176. package/react-native/cpp/include/Presence.h +0 -14
  177. package/react-native/cpp/include/RetainableState.h +0 -24
  178. package/react-native/cpp/include/SmallPeerInfo.h +0 -17
  179. package/react-native/cpp/include/Transports.h +0 -25
  180. package/react-native/cpp/include/TypedArray.hpp +0 -167
  181. package/react-native/cpp/include/Utils.h +0 -61
  182. package/react-native/cpp/include/main.h +0 -10
  183. package/react-native/cpp/src/Attachment.cpp +0 -86
  184. package/react-native/cpp/src/Authentication.cpp +0 -224
  185. package/react-native/cpp/src/Collection.cpp +0 -54
  186. package/react-native/cpp/src/DQL.cpp +0 -254
  187. package/react-native/cpp/src/Document.cpp +0 -146
  188. package/react-native/cpp/src/Identity.cpp +0 -123
  189. package/react-native/cpp/src/Lifecycle.cpp +0 -75
  190. package/react-native/cpp/src/LiveQuery.cpp +0 -64
  191. package/react-native/cpp/src/Logger.cpp +0 -200
  192. package/react-native/cpp/src/Misc.cpp +0 -271
  193. package/react-native/cpp/src/Presence.cpp +0 -77
  194. package/react-native/cpp/src/RetainableState.cpp +0 -15
  195. package/react-native/cpp/src/SmallPeerInfo.cpp +0 -108
  196. package/react-native/cpp/src/Transports.cpp +0 -270
  197. package/react-native/cpp/src/TypedArray.cpp +0 -303
  198. package/react-native/cpp/src/Utils.cpp +0 -138
  199. package/react-native/cpp/src/main.cpp +0 -149
  200. package/react-native/dittoffi/dittoffi.h +0 -4698
  201. package/react-native/dittoffi/ifaddrs.cpp +0 -385
  202. package/react-native/dittoffi/ifaddrs.h +0 -206
  203. package/react-native/ios/DittoRNSDK.h +0 -7
  204. package/react-native/ios/DittoRNSDK.mm +0 -107
  205. package/react-native/ios/YeetJSIUtils.h +0 -60
  206. package/react-native/ios/YeetJSIUtils.mm +0 -196
  207. package/react-native/lib/commonjs/ditto.rn.js +0 -93
  208. package/react-native/lib/commonjs/ditto.rn.js.map +0 -1
  209. package/react-native/lib/commonjs/index.js +0 -14
  210. package/react-native/lib/commonjs/index.js.map +0 -1
  211. package/react-native/lib/module/ditto.rn.js +0 -83
  212. package/react-native/lib/module/ditto.rn.js.map +0 -1
  213. package/react-native/lib/module/index.js +0 -13
  214. package/react-native/lib/module/index.js.map +0 -1
  215. package/react-native/lib/typescript/ditto.rn.d.ts +0 -15
  216. package/react-native/lib/typescript/ditto.rn.d.ts.map +0 -1
  217. package/react-native/lib/typescript/index.d.ts +0 -1
  218. package/react-native/lib/typescript/index.d.ts.map +0 -1
  219. package/react-native/scripts/ruby/include_local_boost.rb +0 -78
  220. package/react-native/src/ditto.rn.ts +0 -91
  221. package/react-native/src/environment/environment.fallback.ts +0 -4
  222. package/react-native/src/index.ts +0 -26
  223. package/react-native/src/sources/@cbor-redux.ts +0 -2
  224. package/react-native/src/sources/@ditto.core.ts +0 -1
  225. package/react-native/src/sources/@environment.ts +0 -2
  226. package/react-native/src/sources/attachment-fetch-event.ts +0 -54
  227. package/react-native/src/sources/attachment-fetcher-manager.ts +0 -129
  228. package/react-native/src/sources/attachment-fetcher.ts +0 -124
  229. package/react-native/src/sources/attachment-token.ts +0 -48
  230. package/react-native/src/sources/attachment.ts +0 -59
  231. package/react-native/src/sources/augment.ts +0 -89
  232. package/react-native/src/sources/authenticator.ts +0 -314
  233. package/react-native/src/sources/base-pending-cursor-operation.ts +0 -237
  234. package/react-native/src/sources/base-pending-id-specific-operation.ts +0 -109
  235. package/react-native/src/sources/bridge.ts +0 -549
  236. package/react-native/src/sources/build-time-constants.ts +0 -4
  237. package/react-native/src/sources/cbor.ts +0 -35
  238. package/react-native/src/sources/collection-interface.ts +0 -67
  239. package/react-native/src/sources/collection.ts +0 -212
  240. package/react-native/src/sources/collections-event.ts +0 -99
  241. package/react-native/src/sources/counter.ts +0 -77
  242. package/react-native/src/sources/ditto.ts +0 -945
  243. package/react-native/src/sources/document-id.ts +0 -159
  244. package/react-native/src/sources/document-path.ts +0 -303
  245. package/react-native/src/sources/document.ts +0 -192
  246. package/react-native/src/sources/epilogue.ts +0 -24
  247. package/react-native/src/sources/error-codes.ts +0 -52
  248. package/react-native/src/sources/error.ts +0 -203
  249. package/react-native/src/sources/essentials.ts +0 -53
  250. package/react-native/src/sources/ffi-error.ts +0 -117
  251. package/react-native/src/sources/ffi.ts +0 -1972
  252. package/react-native/src/sources/identity.ts +0 -163
  253. package/react-native/src/sources/init.ts +0 -70
  254. package/react-native/src/sources/internal.ts +0 -113
  255. package/react-native/src/sources/keep-alive.ts +0 -69
  256. package/react-native/src/sources/key-path.ts +0 -195
  257. package/react-native/src/sources/live-query-event.ts +0 -208
  258. package/react-native/src/sources/live-query-manager.ts +0 -101
  259. package/react-native/src/sources/live-query.ts +0 -164
  260. package/react-native/src/sources/logger.ts +0 -196
  261. package/react-native/src/sources/observer-manager.ts +0 -175
  262. package/react-native/src/sources/observer.ts +0 -77
  263. package/react-native/src/sources/pending-collections-operation.ts +0 -232
  264. package/react-native/src/sources/pending-cursor-operation.ts +0 -218
  265. package/react-native/src/sources/pending-id-specific-operation.ts +0 -216
  266. package/react-native/src/sources/presence-manager.ts +0 -160
  267. package/react-native/src/sources/presence.ts +0 -238
  268. package/react-native/src/sources/query-result-item.ts +0 -116
  269. package/react-native/src/sources/query-result.ts +0 -55
  270. package/react-native/src/sources/register.ts +0 -92
  271. package/react-native/src/sources/small-peer-info.ts +0 -176
  272. package/react-native/src/sources/static-tcp-client.ts +0 -6
  273. package/react-native/src/sources/store-observer.ts +0 -176
  274. package/react-native/src/sources/store.ts +0 -365
  275. package/react-native/src/sources/subscription-manager.ts +0 -98
  276. package/react-native/src/sources/subscription.ts +0 -88
  277. package/react-native/src/sources/sync-subscription.ts +0 -90
  278. package/react-native/src/sources/sync.ts +0 -495
  279. package/react-native/src/sources/test-helpers.ts +0 -24
  280. package/react-native/src/sources/transport-conditions-manager.ts +0 -104
  281. package/react-native/src/sources/transport-config.ts +0 -428
  282. package/react-native/src/sources/update-result.ts +0 -66
  283. package/react-native/src/sources/update-results-map.ts +0 -57
  284. package/react-native/src/sources/websocket-client.ts +0 -6
  285. package/react-native/src/sources/write-transaction-collection.ts +0 -122
  286. package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +0 -101
  287. package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +0 -72
  288. package/react-native/src/sources/write-transaction.ts +0 -119
  289. package/react-native.config.js +0 -9
@@ -1,89 +0,0 @@
1
- //
2
- // Copyright © 2021 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import * as FFI from './ffi'
6
- import { DocumentID } from './document-id'
7
- import { AttachmentToken } from './attachment-token'
8
- import { Attachment } from './attachment'
9
- import { Counter } from './counter'
10
- import { Register } from './register'
11
-
12
- export function augmentJSONValue(json, mutDoc, workingPath) {
13
- if (json && typeof json === 'object') {
14
- if (Array.isArray(json)) {
15
- return json.map((v, idx) => augmentJSONValue(v, mutDoc, `${workingPath}[${idx}]`))
16
- } else if (json[FFI.DittoCRDTTypeKey] === FFI.DittoCRDTType.counter) {
17
- return Counter['@ditto.create'](mutDoc, workingPath, json[FFI.DittoCRDTValueKey])
18
- } else if (json[FFI.DittoCRDTTypeKey] === FFI.DittoCRDTType.register) {
19
- return Register['@ditto.create'](mutDoc, workingPath, json[FFI.DittoCRDTValueKey])
20
- } else if (json[FFI.DittoCRDTTypeKey] === FFI.DittoCRDTType.attachment) {
21
- return new AttachmentToken(json)
22
- } else {
23
- for (const [key, value] of Object.entries(json)) {
24
- json[key] = augmentJSONValue(value, mutDoc, `${workingPath}['${key}']`)
25
- }
26
- return json
27
- }
28
- } else {
29
- return json
30
- }
31
- }
32
-
33
- /**
34
- * Converts objects that may contain instances of classes of this SDK, i.e.
35
- * `DocumentID`, `Counter`, `Register` and `Attachment`, into plain JS objects
36
- * that can be passed to the FFI layer.
37
- */
38
- export function desugarJSObject(jsObj: any, atRoot: boolean = false): any {
39
- if (jsObj && typeof jsObj === 'object') {
40
- if (Array.isArray(jsObj)) {
41
- return jsObj.map((v, idx) => desugarJSObject(v, false))
42
- } else if (jsObj instanceof DocumentID) {
43
- return jsObj.value
44
- } else if (jsObj instanceof Counter) {
45
- const counterJSON = {}
46
- counterJSON[FFI.DittoCRDTTypeKey] = FFI.DittoCRDTType.counter
47
- counterJSON[FFI.DittoCRDTValueKey] = jsObj.value
48
- return counterJSON
49
- } else if (jsObj instanceof Register) {
50
- const registerJSON = {}
51
- registerJSON[FFI.DittoCRDTTypeKey] = FFI.DittoCRDTType.register
52
- registerJSON[FFI.DittoCRDTValueKey] = jsObj.value
53
- return registerJSON
54
- } else if (jsObj instanceof Attachment) {
55
- const attachmentJSON = {
56
- _id: jsObj.token.id,
57
- _len: jsObj.token.len,
58
- _meta: jsObj.token.metadata,
59
- }
60
- attachmentJSON[FFI.DittoCRDTTypeKey] = FFI.DittoCRDTType.attachment
61
- return attachmentJSON
62
- } else {
63
- for (const [key, value] of Object.entries(jsObj)) {
64
- jsObj[key] = desugarJSObject(value, false)
65
- }
66
- return jsObj
67
- }
68
- } else {
69
- checkForUnsupportedValues(jsObj)
70
- return jsObj
71
- }
72
- }
73
-
74
- /**
75
- * Throws an error if input is a non-finite float value.
76
- *
77
- * Workaround while we don't have a reliable way of receiving error messages
78
- * from `dittoCore.ditto_collection_insert_value()`.
79
- *
80
- * See https://github.com/getditto/ditto/issues/8657 for details.
81
- *
82
- * @param jsObj The object to check.
83
- * @throws {Error} If `jsObj` is a non-finite float value.
84
- */
85
- function checkForUnsupportedValues(jsObj: any): void {
86
- if (Number.isNaN(jsObj) || jsObj === Infinity || jsObj === -Infinity) {
87
- throw new Error('Non-finite float values are not supported')
88
- }
89
- }
@@ -1,314 +0,0 @@
1
- //
2
- // Copyright © 2021 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import * as FFI from './ffi'
6
-
7
- import { Bridge } from './bridge'
8
- import { Logger } from './logger'
9
- import { Observer } from './observer'
10
- import { ObserverManager } from './observer-manager'
11
-
12
- import type { Ditto } from './ditto'
13
- import type { KeepAlive } from './keep-alive'
14
-
15
-
16
- // -----------------------------------------------------------------------------
17
-
18
- /**
19
- * Provides info about the authentication status.
20
- */
21
- export type AuthenticationStatus = {
22
- /**
23
- * Returns `true` if authenticated, otherwise returns `false`.
24
- */
25
- isAuthenticated: boolean
26
-
27
- /**
28
- * If authenticated, returns the `userID` if one was provided by the
29
- * authentication service. Otherwise returns `null`.
30
- */
31
- userID: string | null
32
- }
33
-
34
- /**
35
- * Provides feedback to the developer about Ditto authentication status.
36
- */
37
- export interface AuthenticationHandler {
38
- /**
39
- * There is no Ditto authentication token or it has expired. Sync will not
40
- * work until there is a successful login using one of the login methods on
41
- * {@link Authenticator}.
42
- */
43
- authenticationRequired: (authenticator: Authenticator) => void
44
-
45
- /**
46
- * Warns that the Ditto authentication token is getting old.
47
- *
48
- * Ditto will attempt to refresh tokens periodically, starting from halfway
49
- * through the token's validity period. This reduces the risk of
50
- * authentication expiring while the user is offline.
51
- *
52
- * The refresh will happen automatically if Ditto has a suitable refresh
53
- * token. If new credentials are required, such as a third-party token or a
54
- * username/password, then Ditto does not cache that information and you must
55
- * submit it again using one of the `login` methods on {@link Authenticator}.
56
- */
57
- authenticationExpiringSoon: (authenticator: Authenticator, secondsRemaining: number) => void
58
-
59
- /**
60
- * Notifies the authentication handler that the authentication status did
61
- * change. Use the `authenticator`s property `status` to query for the current
62
- * authentication status.
63
- *
64
- * This method is **optional**.
65
- */
66
- authenticationStatusDidChange?: (authenticator: Authenticator) => void
67
- }
68
-
69
- // -----------------------------------------------------------------------------
70
-
71
- /**
72
- * Log in to a remote authentication service, using an
73
- * `OnlineWithAuthentication` or an `Online` identity.
74
- */
75
- export class Authenticator {
76
- /**
77
- * Returns `true` if authentication is available and the login methods can be
78
- * used, otherwise returns `false`. Currently, authentication is only
79
- * available if Ditto was initialized with an identity of type
80
- * {@link IdentityOnlineWithAuthentication | 'onlineWithAuthentication'}.
81
- */
82
- readonly loginSupported: boolean
83
-
84
- /**
85
- Returns the current authentication status.
86
- */
87
- get status(): AuthenticationStatus {
88
- return this._status
89
- }
90
-
91
- /**
92
- * Log in to Ditto with a third-party token. Throws if authentication is not
93
- * available, which can be checked with {@link loginSupported}.
94
- *
95
- * @param token the authentication token required to log in.
96
- * @param provider the name of the authentication provider.
97
- */
98
- loginWithToken(token: string, provider: string): Promise<void> {
99
- throw new Error(`Authenticator.loginWithToken() is abstract and must be implemented by subclasses.`)
100
- }
101
-
102
- /**
103
- * Log in to Ditto with a username and password. Throws if authentication is
104
- * not available, which can be checked with {@link loginSupported}.
105
- *
106
- * @param username the username component of the credentials used for log in.
107
- * @param password the password component of the credentials used for log in.
108
- * @param provider the name of the authentication provider.
109
- */
110
- loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<void> {
111
- throw new Error(`Authenticator.loginWithUsernameAndPassword() is abstract and must be implemented by subclasses.`)
112
- }
113
-
114
- /**
115
- * Log out of Ditto.
116
- *
117
- * This will stop sync, shut down all replication sessions, and remove any
118
- * cached authentication credentials. Note that this does not remove any data
119
- * from the store. If you wish to delete data from the store then use the
120
- * optional `cleanupFn` parameter to perform any required cleanup.
121
- *
122
- * @param cleanupFn An optional function that will be called with the relevant
123
- * [Ditto] instance as the sole argument that allows you to perform any
124
- * required cleanup of the store as part of the logout process.
125
- */
126
- logout(cleanupFn?: (ditto: Ditto) => void): Promise<void> {
127
- throw new Error(`Authenticator.logout() is abstract and must be implemented by subclasses.`)
128
- }
129
-
130
- /*
131
- * Registers a callback that is called whenever the authentication status
132
- * changes. Returns an `Observer` object that needs to be retained as long as
133
- * you want to receive the updates.
134
- */
135
- observeStatus(callback: (authenticationStatus: AuthenticationStatus) => void): Observer {
136
- const token = this.observerManager.addObserver(callback)
137
- return new Observer(this.observerManager, token, { stopsWhenFinalized: true })
138
- }
139
-
140
- /** @internal */
141
- constructor(keepAlive: KeepAlive) {
142
- this.keepAlive = keepAlive
143
- this._status = { isAuthenticated: false, userID: null }
144
- this.loginSupported = false
145
- this.observerManager = new ObserverManager('AuthenticationStatusObservation', { keepAlive })
146
- }
147
-
148
- /** @internal */
149
- '@ditto.authenticationExpiring'(number): void {
150
- throw new Error(`Authenticator['@ditto.authenticationExpiring']() is abstract and must be implemented by subclasses.`)
151
- }
152
-
153
- /** @internal */
154
- '@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): void {
155
- throw new Error(`Authenticator['@ditto.authClientValidityChanged']() is abstract and must be implemented by subclasses.`)
156
- }
157
-
158
- /** @internal */
159
- close() {
160
- this.observerManager.close()
161
- }
162
-
163
- /** @internal */
164
- protected keepAlive: KeepAlive
165
-
166
- /** @internal */
167
- protected observerManager: ObserverManager
168
-
169
- /** @internal */
170
- protected _status: AuthenticationStatus
171
- }
172
-
173
- // -----------------------------------------------------------------------------
174
-
175
- /** @internal */
176
- export class OnlineAuthenticator extends Authenticator {
177
- readonly loginSupported: boolean = true
178
-
179
- async loginWithToken(token: string, provider: string): Promise<void> {
180
- const ditto = this.ditto.deref()
181
- if (!ditto) {
182
- return
183
- }
184
-
185
- const dittoHandle = Bridge.ditto.handleFor(ditto)
186
- const dittoPointer = dittoHandle.derefOrNull()
187
- if (!dittoPointer) {
188
- return
189
- }
190
-
191
- return ditto.deferCloseAsync(async () => {
192
- await FFI.dittoAuthClientLoginWithToken(dittoPointer, token, provider)
193
- })
194
- }
195
-
196
- async loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<void> {
197
- const ditto = this.ditto.deref()
198
- if (!ditto) {
199
- return
200
- }
201
- const dittoHandle = Bridge.ditto.handleFor(ditto)
202
- const dittoPointer = dittoHandle.derefOrNull()
203
-
204
- if (!dittoPointer) {
205
- return
206
- }
207
-
208
- return ditto.deferCloseAsync(async () => {
209
- await FFI.dittoAuthClientLoginWithUsernameAndPassword(dittoPointer, username, password, provider)
210
- })
211
- }
212
-
213
- async logout(cleanupFn?: (ditto: Ditto) => void): Promise<void> {
214
- const ditto = this.ditto.deref()
215
- if (!ditto) {
216
- return
217
- }
218
-
219
- const dittoHandle = Bridge.ditto.handleFor(ditto)
220
- const dittoPointer = dittoHandle.derefOrNull()
221
-
222
- if (!dittoPointer) {
223
- return
224
- }
225
-
226
- return ditto.deferCloseAsync(async () => {
227
- await FFI.dittoAuthClientLogout(dittoPointer)
228
- ditto.stopSync()
229
- cleanupFn?.(ditto)
230
- })
231
- }
232
-
233
- readonly authenticationHandler: AuthenticationHandler
234
-
235
- private ditto: WeakRef<Ditto>
236
-
237
- constructor(keepAlive: KeepAlive, ditto: Ditto, authenticationHandler: AuthenticationHandler) {
238
- super(keepAlive)
239
- this._status = { isAuthenticated: false, userID: null }
240
- this.ditto = new WeakRef<Ditto>(ditto)
241
- this.authenticationHandler = authenticationHandler
242
- this.updateAndNotify(false)
243
- }
244
-
245
- '@ditto.authenticationExpiring'(secondsRemaining: number): void {
246
- const authenticationHandler = this.authenticationHandler
247
- if (secondsRemaining > 0) {
248
- authenticationHandler.authenticationExpiringSoon(this, secondsRemaining)
249
- } else {
250
- authenticationHandler.authenticationRequired(this)
251
- }
252
- }
253
-
254
- '@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): void {
255
- this.updateAndNotify(true)
256
- }
257
-
258
- private updateAndNotify(shouldNotify: boolean) {
259
- const ditto = this.ditto.deref()
260
- if (!ditto) {
261
- Logger.debug('Unable to update auth status and notify, related Ditto object does not exist anymore.')
262
- return
263
- }
264
-
265
- const dittoHandle = Bridge.ditto.handleFor(ditto)
266
- const dittoPointer = dittoHandle.derefOrNull()
267
- if (!dittoPointer) {
268
- Logger.debug('Unable to update auth status and notify, related Ditto object does not exist anymore.')
269
- return
270
- }
271
-
272
- const wasAuthenticated = this.status.isAuthenticated
273
- const previousUserID = this.status.userID
274
-
275
- const isAuthenticated = FFI.dittoAuthClientIsWebValid(dittoPointer)
276
- const userID = FFI.dittoAuthClientUserID(dittoPointer)
277
- const status = { isAuthenticated, userID }
278
-
279
- this._status = status
280
-
281
- if (shouldNotify) {
282
- const sameStatus = !!wasAuthenticated === !!isAuthenticated && previousUserID === userID
283
- if (!sameStatus) {
284
- this.authenticationHandler.authenticationStatusDidChange?.call(this.authenticationHandler, this)
285
- this.observerManager.notify(status)
286
- }
287
- }
288
- }
289
- }
290
-
291
- // -----------------------------------------------------------------------------
292
-
293
- /** @internal */
294
- export class NotAvailableAuthenticator extends Authenticator {
295
- async loginWithToken(token: string, provider: string): Promise<never> {
296
- throw new Error(`Can't login, authentication is not supported for the identity in use, please use an onlineWithAuthentication identity.`)
297
- }
298
-
299
- async loginWithUsernameAndPassword(username: string, password: string, provider: string): Promise<never> {
300
- throw new Error(`Can't login, authentication is not supported for the identity in use, please use an onlineWithAuthentication identity.`)
301
- }
302
-
303
- logout(cleanupFn?: (ditto: Ditto) => void): Promise<never> {
304
- throw new Error(`Can't logout, authentication is not supported for the identity in use, please use an onlineWithAuthentication identity.`)
305
- }
306
-
307
- '@ditto.authenticationExpiring'(secondsRemaining: number): never {
308
- throw new Error(`Internal inconsistency, authentication is not available, yet the @ditto.authenticationExpiring() was called on authenticator: ${this}`)
309
- }
310
-
311
- '@ditto.authClientValidityChanged'(isWebValid: boolean, isX509Valid: boolean): never {
312
- throw new Error(`Internal inconsistency, authentication is not available, yet the @ditto.authClientValidityChanged() was called on authenticator: ${this}`)
313
- }
314
- }
@@ -1,237 +0,0 @@
1
- //
2
- // Copyright © 2023 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import * as FFI from './ffi'
6
-
7
- import { Document, MutableDocument } from './document'
8
- import { UpdateResultsMap } from './update-results-map'
9
- import { CBOR } from './cbor'
10
- import { validateQuery } from './internal'
11
- import { performAsyncToWorkaroundNonAsyncFFIAPI } from './internal'
12
- import { Bridge } from './bridge'
13
-
14
- import type { DocumentID } from './document-id'
15
- import type { QueryArguments, SortDirection } from './essentials'
16
- import type { UpdateResult } from './update-result'
17
- import type { CollectionInterface } from './collection-interface'
18
-
19
- export abstract class BasePendingCursorOperation implements PromiseLike<Document[]> {
20
- /**
21
- * Removes all documents that match the query generated by the preceding
22
- * function chaining.
23
- *
24
- * @returns An array promise containing the IDs of the documents that were
25
- * removed.
26
- */
27
- abstract remove(): Promise<DocumentID[]>
28
-
29
- /**
30
- * Evicts all documents that match the query generated by the preceding
31
- * function chaining.
32
- *
33
- * @return An array promise containing the IDs of the documents that were
34
- * evicted.
35
- */
36
- abstract evict(): Promise<DocumentID[]>
37
-
38
- /**
39
- * Updates documents that match the query generated by the preceding function
40
- * chaining.
41
- *
42
- * @param closure A closure that gets called with all of the documents
43
- * matching the query. The documents are instances of {@link MutableDocument}
44
- * so you can call update-related functions on them.
45
- *
46
- * @returns An {@link UpdateResultsMap} promise mapping document IDs to lists
47
- * of {@link UpdateResult | update results} that describe the updates that
48
- * were performed for each document.
49
- */
50
- abstract update(closure: (documents: MutableDocument[]) => void): Promise<UpdateResultsMap>
51
-
52
- // ----------------------------------------------------------- Public --------
53
-
54
- /** The query the receiver is operating with. */
55
- readonly query: string
56
-
57
- /** The named arguments for the {@link query}. */
58
- readonly queryArgs: QueryArguments | null
59
-
60
- /** The collection the receiver is operating on. */
61
- readonly collection: CollectionInterface
62
-
63
- /**
64
- * Sorts the documents that match the query provided in the preceding
65
- * `find`-like function call.
66
- *
67
- * @param query The query specifies the logic to be used when sorting the
68
- * matching documents.
69
- *
70
- * @param direction Specify whether you want the sorting order to be
71
- * `Ascending` or `Descending`.
72
- *
73
- * @return A cursor that you can chain further function calls and then either
74
- * get the matching documents immediately or get updates about them over time.
75
- */
76
- sort(propertyPath: string, direction: SortDirection = 'ascending'): BasePendingCursorOperation {
77
- this.orderBys.push({
78
- query: propertyPath,
79
- direction: direction === 'ascending' ? 'Ascending' : 'Descending',
80
- })
81
- return this
82
- }
83
-
84
- /**
85
- * Offsets the resulting set of matching documents.
86
- *
87
- * This is useful if you aren't interested in the first N matching documents
88
- * for one reason or another. For example, you might already have queried the
89
- * collection and obtained the first 20 matching documents and so you might
90
- * want to run the same query as you did previously but ignore the first 20
91
- * matching documents, and that is when you would use `offset`.
92
- *
93
- * @param offset The number of matching documents that you want the eventual
94
- * resulting set of matching documents to be offset by (and thus not include).
95
- *
96
- * @return A cursor that you can chain further function calls and then either
97
- * get the matching documents immediately or get updates about them over time.
98
- */
99
- offset(offset: number): BasePendingCursorOperation {
100
- if (offset < 0) throw new Error(`Can't offset by '${offset}', offset must be >= 0`)
101
- if (!Number.isFinite(offset)) throw new Error(`Can't offset by '${offset}', offset must be a finite number`)
102
- if (Number.isNaN(offset)) throw new Error(`Can't offset by '${offset}', offset must be a valid number`)
103
-
104
- const integerOffset = Math.round(offset)
105
- if (offset !== integerOffset) throw new Error(`Can't offset by '${offset}', offset must be an integer number`)
106
-
107
- this.currentOffset = offset
108
- return this
109
- }
110
-
111
- /**
112
- * Limits the number of documents that get returned when querying a collection
113
- * for matching documents.
114
- *
115
- * @param limit The maximum number of documents that will be returned.
116
- *
117
- * @return A cursor that you can chain further function calls and then either
118
- * get the matching documents immediately or get updates about them over time.
119
- */
120
- limit(limit: number): BasePendingCursorOperation {
121
- if (limit < -1) throw new Error(`Can't limit to '${limit}', limit must be >= -1 (where -1 means unlimited)`)
122
- if (!Number.isFinite(limit)) throw new Error(`Can't limit to '${limit}', limit must be a finite number`)
123
- if (Number.isNaN(limit)) throw new Error(`Can't limit to '${limit}', limit must be a valid number`)
124
-
125
- const integerLimit = Math.round(limit)
126
- if (limit !== integerLimit) throw new Error(`Can't limit to '${limit}', limit must be an integer number`)
127
-
128
- this.currentLimit = limit
129
- return this
130
- }
131
-
132
- /**
133
- * Executes the query generated by the preceding function chaining and return
134
- * the list of matching documents.
135
- *
136
- * @returns An array promise containing {@link Document | documents} matching
137
- * the query generated by the preceding function chaining.
138
- */
139
- async exec(): Promise<Document[]> {
140
- const ditto = this.collection.store.ditto
141
- const dittoHandle = Bridge.ditto.handleFor(ditto)
142
- return ditto.deferCloseAsync(async () => {
143
- const query = this.query
144
-
145
- const documentPointers: FFI.Pointer<FFI.FFIDocument>[] = await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {
146
- return await FFI.collectionExecQueryStr(dittoHandle.deref(), this.collection.name, null, query, this.queryArgsCBOR, this.orderBys, this.currentLimit, this.currentOffset)
147
- })
148
-
149
- return documentPointers.map((documentPointer) => {
150
- return Bridge.document.bridge(documentPointer)
151
- })
152
- })
153
- }
154
-
155
- // ----------------------------------------------------------- Internal ------
156
-
157
- /**
158
- * Updates documents that match the query generated by the preceding function
159
- * chaining.
160
- *
161
- * @param closure A closure that gets called with all of the documents
162
- * matching the query. The documents are instances of {@link MutableDocument}
163
- * so you can call update-related functions on them.
164
- * @param writeTransactionX a transaction to perform the operation in.
165
- *
166
- * @returns An {@link UpdateResultsMap} promise mapping document IDs to lists
167
- * of {@link UpdateResult | update results} that describe the updates that
168
- * were performed for each document.
169
- * @internal
170
- */
171
- async updateWithTransaction(closure: (documents: MutableDocument[]) => void, writeTransactionX: FFI.Pointer<FFI.FFIWriteTransaction>): Promise<UpdateResultsMap> {
172
- const ditto = this.collection.store.ditto
173
- const dittoHandle = Bridge.ditto.handleFor(ditto)
174
- return ditto.deferCloseAsync(async () => {
175
- return await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {
176
- const query = this.query
177
-
178
- const documentsX = await FFI.collectionExecQueryStr(dittoHandle.deref(), this.collection.name, writeTransactionX, query, this.queryArgsCBOR, this.orderBys, this.currentLimit, this.currentOffset)
179
-
180
- const mutableDocuments: MutableDocument[] = documentsX.map((documentX) => {
181
- return Bridge.mutableDocument.bridge(documentX, () => new MutableDocument())
182
- })
183
-
184
- closure(mutableDocuments)
185
-
186
- const updateResultsDocumentIDs = []
187
- const updateResultsByDocumentIDString: { [documentID: string]: UpdateResult[] } = {}
188
-
189
- for (const mutableDocument of mutableDocuments) {
190
- const documentID = mutableDocument.id
191
- const documentIDString = documentID.toString()
192
- const updateResults = mutableDocument['@ditto.updateResults']
193
-
194
- if (updateResultsByDocumentIDString[documentIDString]) {
195
- throw new Error(`Internal inconsistency, update results for document ID as string already exist: ${documentIDString}`)
196
- }
197
-
198
- updateResultsDocumentIDs.push(documentID)
199
- updateResultsByDocumentIDString[documentIDString] = updateResults
200
-
201
- Bridge.mutableDocument.unregister(mutableDocument)
202
- }
203
-
204
- await FFI.collectionUpdateMultiple(dittoHandle.deref(), this.collection.name, writeTransactionX, documentsX)
205
-
206
- return new UpdateResultsMap(updateResultsDocumentIDs, updateResultsByDocumentIDString)
207
- })
208
- })
209
- }
210
-
211
- /** @internal */
212
- constructor(query: string, queryArgs: QueryArguments | null, collection: CollectionInterface) {
213
- this.query = validateQuery(query)
214
- this.queryArgs = queryArgs ? Object.freeze({ ...queryArgs }) : null
215
- this.collection = collection
216
- this.queryArgsCBOR = queryArgs ? CBOR.encode(queryArgs) : null
217
- }
218
-
219
- /** @internal */
220
- then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2> {
221
- return this.exec().then(onfulfilled, onrejected)
222
- }
223
-
224
- // ---------------------------------------------------------- Protected ------
225
-
226
- /** @internal */
227
- protected queryArgsCBOR: Uint8Array | null
228
-
229
- /** @internal */
230
- protected currentLimit = -1
231
-
232
- /** @internal */
233
- protected currentOffset = 0
234
-
235
- /** @internal */
236
- protected orderBys: FFI.OrderBy[] = []
237
- }