@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,109 +0,0 @@
1
- //
2
- // Copyright © 2023 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import * as FFI from './ffi'
6
-
7
- import { Bridge } from './bridge'
8
- import { performAsyncToWorkaroundNonAsyncFFIAPI } from './internal'
9
-
10
- import type { Document, MutableDocument } from './document'
11
- import type { DocumentID } from './document-id'
12
- import type { CollectionInterface } from './collection-interface'
13
- import type { UpdateResult } from './update-result'
14
-
15
- /**
16
- * These objects are returned when using
17
- * {@link Collection.findByID | findByID()} functionality on
18
- * {@link Collection | collections}.
19
- *
20
- * You can either call {@link exec | exec()} on the object to get an immediate
21
- * return value, or chain calls to update, evict or remove the document.
22
- *
23
- * Live queries and subscriptions are only available outside of a transaction.
24
- */
25
- export abstract class BasePendingIDSpecificOperation implements PromiseLike<Document | undefined> {
26
- /**
27
- * Removes the document with the matching ID.
28
- *
29
- * @returns `true` promise if the document was found and removed. `false`
30
- * promise if the document wasn't found and therefore wasn't removed.
31
- */
32
- abstract remove(): Promise<boolean>
33
-
34
- /**
35
- * Evicts the document with the matching ID.
36
- *
37
- * @returns `true` promise if the document was found and evicted. `false`
38
- * promise if the document wasn't found and therefore wasn't evicted.
39
- */
40
- abstract evict(): Promise<boolean>
41
-
42
- /**
43
- * Updates the document with the matching ID.
44
- *
45
- * @param closure A closure that gets called with the document matching the
46
- * ID. If found, the document is a {@link MutableDocument}, so you can call
47
- * update-related functions on it. If the document is not found then the value
48
- * provided to the closure will be `undefined`.
49
- *
50
- * @return An array promise of {@link UpdateResult | update results} that
51
- * describe the updates that were performed on the document.
52
- */
53
- abstract update(closure: (document: MutableDocument) => void): Promise<UpdateResult[]>
54
-
55
- // ----------------------------------------------------------- Public --------
56
-
57
- /** The ID of the document this operation operates on. */
58
- readonly documentID: DocumentID
59
-
60
- /** The collection the receiver is operating on. */
61
- readonly collection: CollectionInterface
62
-
63
- /**
64
- * Executes the find operation to return the document with the matching ID.
65
- *
66
- * @returns The {@link Document} promise with the ID provided in the
67
- * {@link Collection.findByID | findByID()} call or `undefined` if the document was
68
- * not found.
69
- */
70
- async exec(): Promise<Document | undefined> {
71
- const ditto = this.collection.store.ditto
72
- const dittoHandle = Bridge.ditto.handleFor(ditto)
73
- return ditto.deferCloseAsync(async () => {
74
- return await performAsyncToWorkaroundNonAsyncFFIAPI(async () => {
75
- const readTransactionX = await FFI.readTransaction(dittoHandle.deref())
76
- const documentX = await FFI.collectionGet(dittoHandle.deref(), this.collection.name, this.documentIDCBOR, readTransactionX)
77
-
78
- let document: Document | undefined = undefined
79
- if (documentX) document = Bridge.document.bridge(documentX)
80
-
81
- FFI.readTransactionFree(readTransactionX)
82
- return document
83
- })
84
- })
85
- }
86
-
87
- // ----------------------------------------------------------- Internal ------
88
-
89
- /** @internal */
90
- constructor(documentID: DocumentID, collection: CollectionInterface) {
91
- this.documentID = documentID
92
- this.collection = collection
93
- this.documentIDCBOR = documentID.toCBOR()
94
- }
95
-
96
- /** @internal */
97
- then<TResult1 = any, TResult2 = never>(onfulfilled?: ((value: any) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PromiseLike<TResult1 | TResult2> {
98
- return this.exec().then(onfulfilled, onrejected)
99
- }
100
-
101
- /** @internal */
102
- get query(): string {
103
- return `_id == ${this.documentID.toQueryCompatibleString()}`
104
- }
105
-
106
- // ---------------------------------------------------------- Protected ------
107
-
108
- protected documentIDCBOR: Uint8Array
109
- }
@@ -1,549 +0,0 @@
1
- //
2
- // Copyright © 2023 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import * as FFI from './ffi'
6
-
7
- import { Logger } from './logger'
8
- import { QueryResult } from './query-result'
9
- import { QueryResultItem } from './query-result-item'
10
-
11
- import type { Document, MutableDocument } from './document'
12
- import type { Attachment } from './attachment'
13
-
14
- import type { StaticTCPClient } from './static-tcp-client'
15
- import type { WebsocketClient } from './websocket-client'
16
-
17
- import type { Ditto } from './ditto'
18
-
19
- const DEBUG_TYPE_NAMES: string[] = []
20
- const DEBUG_ALL_TYPES = false
21
-
22
- // -----------------------------------------------------------------------------
23
-
24
- /**
25
- * A JavaScript class that identifies a bridge's type and may be used to create
26
- * new instances.
27
- */
28
- export type BridgeType<T extends object> = new (...args: any[]) => T
29
-
30
- /**
31
- * A handle serves as a safe wrapper around a pointer to a native object.
32
- *
33
- * A bridge keeps track of all handles that have been created on its
34
- * {@link Bridge.handlesByAddress | `handlesByAddress`} property, which allows
35
- * enumerating all objects that are currently managed by the bridge.
36
- *
37
- * @internal */
38
- export class Handle<T extends object, FFIType> {
39
- readonly bridge: Bridge<T, FFIType>
40
- readonly pointer: FFI.Pointer<FFIType>
41
-
42
- private objectWeakRef: WeakRef<T>
43
-
44
- readonly isClosed: boolean = false
45
- readonly isFinalized: boolean = false
46
- readonly isUnregistered: boolean = false
47
-
48
- /**
49
- * Warning: Do not call this constructor directly. Use
50
- * {@link Bridge.handleFor | `Bridge.<type>.handleFor()`} instead.
51
- *
52
- * @internal
53
- */
54
- constructor(bridge: Bridge<T, FFIType>, object: T, pointer: FFI.Pointer<FFIType>) {
55
- this.bridge = bridge
56
- this.objectWeakRef = new WeakRef(object)
57
- this.pointer = pointer
58
- }
59
-
60
- /** The type of this handle's bridge */
61
- get type(): BridgeType<T> {
62
- return this.bridge.type
63
- }
64
-
65
- /**
66
- * Returns the pointer associated with this handle.
67
- *
68
- * @throws {Error} if the object has already been closed, garbage collected,
69
- * or unregistered from the bridge.
70
- */
71
- deref(): FFI.Pointer<FFIType> {
72
- if (this.isClosed) {
73
- throw new Error(`Bridging error: can't get pointer for an object that has been closed.`)
74
- }
75
-
76
- if (this.isFinalized) {
77
- throw new Error(`Bridging error: can't get pointer for an object that has been finalized.`)
78
- }
79
-
80
- if (this.isUnregistered) {
81
- throw new Error(`Bridging error: can't get pointer for an object that has been unregistered.`)
82
- }
83
-
84
- return this.pointer
85
- }
86
-
87
- /**
88
- * Returns the pointer associated with this handle or `null` if the object
89
- * has been closed, garbage collected, or unregistered.
90
- */
91
- derefOrNull(): FFI.Pointer<FFIType> | null {
92
- if (this.isClosed) {
93
- return null
94
- }
95
-
96
- if (this.isFinalized) {
97
- return null
98
- }
99
-
100
- if (this.isUnregistered) {
101
- return null
102
- }
103
-
104
- return this.pointer ?? null
105
- }
106
-
107
- /**
108
- * Returns the object associated with this handle.
109
- *
110
- * @throws {Error} if the object has been closed, unregistered, or garbage collected,
111
- * closed or unregistered.
112
- */
113
- object(): T {
114
- const object = this.objectWeakRef.deref()
115
- if (object == null) {
116
- throw new Error(`Bridging error: ${this.bridge.type.name} object has been garbage collected.`)
117
- }
118
-
119
- if (this.isClosed) {
120
- throw new Error(`Bridging error: ${this.bridge.type.name} object has been closed.`)
121
- }
122
-
123
- if (this.isUnregistered) {
124
- throw new Error(`Bridging error: ${this.bridge.type.name} object has been unregistered.`)
125
- }
126
-
127
- return object
128
- }
129
-
130
- /**
131
- * Returns the object associated with this handle or `null` if the object
132
- * has been closed, unregistered, or garbage collected.
133
- */
134
- objectOrNull(): T | null {
135
- return this.objectWeakRef.deref() ?? null
136
- }
137
-
138
- /** @internal */
139
- toString(): string {
140
- const pointer = this.derefOrNull()
141
- return `{ Handle | type: ${this.bridge.type}, object: ${this.objectWeakRef.deref()}, FFI address: ${pointer?.addr}, FFI type: ${pointer?.type} }`
142
- }
143
-
144
- /** @internal */
145
- bridgeWillClose() {
146
- // @ts-expect-error setting readonly property
147
- this.isClosed = true
148
- }
149
-
150
- /** @internal */
151
- bridgeDidClose() {
152
- // @ts-expect-error setting readonly property
153
- this.pointer = null
154
- }
155
-
156
- /** @internal */
157
- bridgeWillFinalize() {
158
- // @ts-expect-error setting readonly property
159
- this.isFinalized = true
160
- }
161
-
162
- /** @internal */
163
- bridgeDidFinalize() {
164
- // @ts-expect-error setting readonly property
165
- this.pointer = null
166
- }
167
-
168
- /** @internal */
169
- bridgeWillUnregister() {
170
- // @ts-expect-error setting readonly property
171
- this.isUnregistered = true
172
- }
173
-
174
- /** @internal */
175
- bridgeDidUnregister() {
176
- // @ts-expect-error setting readonly property
177
- this.pointer = null
178
- }
179
- }
180
-
181
- /**
182
- * Use this for passing arrays of pointers to the FFI.
183
- */
184
- export class Handles<T extends object, FFIType> {
185
- readonly handles: Handle<T, FFIType>[]
186
-
187
- /**
188
- * @throws {Error} if any of the objects are not registered in the bridge.
189
- * @throws {Error} if any of the objects have already been garbage collected.
190
- */
191
- constructor(bridge: Bridge<T, FFIType>, objects: T[]) {
192
- this.handles = objects.map((object) => bridge.handleFor(object))
193
- }
194
-
195
- deref(): FFI.Pointer<FFIType>[] {
196
- return this.handles.map((handle) => handle.deref())
197
- }
198
- }
199
-
200
- /**
201
- * A bridge manages memory allocated by the FFI that is used in the JS SDK.
202
- *
203
- * The main purpose of a bridge is keeping track of JavaScript objects that
204
- * require access to memory allocated by the FFI. When such objects are
205
- * garbage collected in JavaScript, the bridge instructs the FFI to free the
206
- * corresponding memory. Every managed memory pointer corresponds to exactly
207
- * one JS Object.
208
- *
209
- * There is a static `Bridge` instance for every class of objects that can be
210
- * managed:
211
- *
212
- * - {@link Attachment}: `Bridge.attachment`
213
- * - {@link Ditto}: `Bridge.ditto`
214
- * - {@link Document}: `Bridge.document`
215
- * - {@link MutableDocument}: `Bridge.mutableDocument`
216
- * - {@link StaticTCPClient}: `Bridge.staticTCPClient`
217
- * - {@link WebsocketClient}: `Bridge.websocketClient`
218
- *
219
- * Use `Bridge.<type>.handleFor()` to obtain a handle, which is a wrapper around
220
- * the raw pointer, and `Bridge.<type>.bridge()` to get or create the matching
221
- * object for a memory address.
222
- *
223
- * @internal */
224
- export class Bridge<T extends object, FFIType> {
225
- readonly release: (pointer: FFI.Pointer<FFIType>) => void | Promise<void>
226
-
227
- /**
228
- * Creates a new bridge for objects of `type`. Requires a `release` function
229
- * that is called whenever a registered object is garbage collected, passing
230
- * the associated `pointer` to it. The release function is then responsible
231
- * to free or drop the corresponding native object.
232
- *
233
- * **IMPORTANT**: The `type` of all bridges needs to be set in `epilogue.ts`
234
- * after initiating the bridge instance. This helps avoid import cycles
235
- * (otherwise anything importing the bridge instance, would also have to
236
- * import the type, which usually leads to import cycles).
237
- *
238
- * @private
239
- */
240
- constructor(release: (pointer: FFI.Pointer<FFIType>) => void | Promise<void>) {
241
- this.release = release
242
- this.handlesByAddress = {}
243
- this.handlesByObject = new WeakMap()
244
- this.finalizationRegistry = new FinalizationRegistry(this.finalize.bind(this))
245
-
246
- Bridge.all.push(new WeakRef(this))
247
- }
248
-
249
- /**
250
- * The type of a bridge is the JavaScript `Class` of objects it represents.
251
- *
252
- * @internal */
253
- get type(): BridgeType<T> {
254
- if (this.internalType == null) {
255
- throw new Error('Bridge type has not been registered yet.')
256
- }
257
- return this.internalType
258
- }
259
-
260
- /**
261
- * All bridges' types have to be registered in `epilogue.ts` before using
262
- * them.
263
- *
264
- * @internal */
265
- registerType(value: BridgeType<T>) {
266
- if (this.internalType === value) {
267
- return
268
- }
269
-
270
- if (this.internalType) {
271
- throw new Error(`Can't register bridged type '${value.name}', another type was already registered: ${this.internalType}`)
272
- }
273
-
274
- this.internalType = value
275
- }
276
-
277
- /**
278
- * Returns the handle for a bridged object.
279
- *
280
- * Use `handle.deref()` to get the pointer for the object at the time of use.
281
- *
282
- * @throws {Error} if the object is not registered.
283
- *
284
- * @internal
285
- */
286
- handleFor(object: T): Handle<T, FFIType> {
287
- const handle = this.handlesByObject.get(object)
288
- if (handle == null) {
289
- throw new Error(`Bridging error: ${this.type.name} object is not currently registered in this bridge.`)
290
- }
291
-
292
- return handle
293
- }
294
-
295
- /**
296
- * Returns a `Handles` instance for an array of objects.
297
- *
298
- * @internal
299
- */
300
- handlesFor(objects: T[]): Handles<T, FFIType> {
301
- return new Handles(this, objects)
302
- }
303
-
304
- /**
305
- * Convenience method, returns the object for the FFI `pointer` if registered,
306
- * otherwise returns `undefined`. If the object associated with the `pointer`
307
- * has been unregistered before, returns `undefined`, too.
308
- *
309
- * @internal
310
- */
311
- objectFor(pointer: FFI.Pointer<FFIType>): T | undefined {
312
- const handle = this.handlesByAddress[pointer.addr]
313
- if (!handle) return undefined
314
- if (handle.type !== this.type) throw new Error(`Can't return object for pointer, pointer is associated with an object of type ${handle.type} but this bridge is configured for ${this.type}`)
315
-
316
-
317
- return handle.object()
318
- }
319
-
320
- /**
321
- * Returns the object for the FFI `pointer` if registered. Otherwise, calls
322
- * the passed in `create` function to create a new object, which it then
323
- * returns after registering. If no `create` function is given, uses the
324
- * type of the bridge as a constructor and creates a new instance of it
325
- * without passing any parameters.
326
- *
327
- * @param pointer reference to the FFi instance for the object
328
- * @param objectOrCreate can either be the JS object, or a function that returns the instance when called. If undefined, an object is created based on the Bridge type.
329
- * @throws {Error} if `objectOrCreate` is a function that returns an object that is not an instance of the bridge's type.
330
- * @internal
331
- */
332
- bridge(pointer: FFI.Pointer<FFIType>, objectOrCreate?: T | (() => T)): T {
333
- const existingObject = this.objectFor(pointer)
334
- if (existingObject) {
335
- return existingObject
336
- }
337
-
338
- if (!objectOrCreate) {
339
- objectOrCreate = () => {
340
- return Reflect.construct(this.type, [])
341
- }
342
- }
343
-
344
- let object: T
345
- if (typeof objectOrCreate === 'function') {
346
- object = objectOrCreate()
347
- if (!(object instanceof this.type)) {
348
- throw new Error(`Can't bridge, expected passed in create function to return a ${this.type.name} object but got: ${object}`)
349
- }
350
- } else {
351
- object = objectOrCreate
352
- }
353
-
354
- this.register(object, pointer)
355
- return object
356
- }
357
-
358
- /**
359
- * Registers an instance in this bridge's {@link FinalizationRegistry}.
360
- *
361
- * This causes the FFI to drop the memory linked to the object as soon as it
362
- * is garbage collected in JavaScript.
363
- *
364
- * If you want to control the order with which a number of objects' memory is
365
- * dropped, use {@link Bridge.unregister | Bridge.unregister()}
366
- *
367
- * @private */
368
- register(object: T, pointer: FFI.Pointer<FFIType>) {
369
- const objectType = object.constructor as BridgeType<T>
370
- if (objectType !== this.type) throw new Error(`Can't register, bridge is configured for type ${this.type.name} but passed in object is of type ${objectType.name}`)
371
-
372
- const existingHandle = this.handlesByObject.get(object)
373
- const existingPointer = existingHandle ? existingHandle.pointer : null
374
-
375
- if (existingPointer != null && existingHandle != null) throw new Error(`Can't register, an object for the passed in pointer has previously been registered: ${existingHandle.object()}`)
376
-
377
- if (existingPointer != null && existingHandle == null) throw new Error(`Internal inconsistency, trying to register an object which has an associated pointer but no handle entry: ${objectType.name} at ${existingPointer.type} ${existingPointer.addr}`)
378
- if (existingPointer == null && existingHandle != null) throw new Error(`Internal inconsistency, trying to register an object which has a handle entry but no associated pointer: ${objectType.name} ${object}`)
379
-
380
- const handle = new Handle<T, FFIType>(this, object, pointer)
381
- this.handlesByAddress[pointer.addr] = handle
382
- this.handlesByObject.set(object, handle)
383
-
384
- this.finalizationRegistry.register(object as object, handle, object as object)
385
-
386
- if (DEBUG_TYPE_NAMES.includes(this.type.name) || DEBUG_ALL_TYPES) {
387
- Logger.debug(`[VERBOSE] Bridge REGISTERED a new instance of ${this.type.name}, current count: ${Object.keys(this.handlesByAddress).length}`)
388
- }
389
- }
390
-
391
- /**
392
- * Removes an instance from this bridge's {@link FinalizationRegistry}.
393
- *
394
- * This lets you control the order with which memory is dropped in the FFI.
395
- * After calling this function, manually call the FFI function to drop the
396
- * memory then finally delete the JavaScript instance.
397
- *
398
- * @internal */
399
- unregister(object: T) {
400
- const objectType = object.constructor
401
- const bridgeType = this.type
402
- if (objectType !== bridgeType) throw new Error(`Can't unregister, bridge is configured for type ${bridgeType.name} but passed in object is of type ${objectType.name}`)
403
-
404
- const handle = this.handlesByObject.get(object)
405
- if (handle == null) throw new Error(`Can't unregister, object has not been registered before: ${object}`)
406
- if (handle.type !== bridgeType) throw new Error(`Internal inconsistency, trying to unregister an object that has a handle with a different type than that of the bridge: ${handle}`)
407
- if (handle.objectOrNull() !== object) throw new Error(`Internal inconsistency, trying to unregister an object whose associated handle holds a different object: ${handle}`)
408
-
409
- if (handle.isClosed) throw new Error(`Can't unregister, object has been closed before: ${object}`)
410
- if (handle.isFinalized) throw new Error(`Can't unregister, object has been finalized before: ${object}`)
411
- if (handle.isUnregistered) throw new Error(`Can't unregister, object has been unregistered already: ${object}`)
412
-
413
- handle.bridgeWillUnregister()
414
- this.finalizationRegistry.unregister(object as object)
415
- delete this.handlesByAddress[handle.pointer.addr]
416
- this.handlesByObject.delete(object)
417
- handle.bridgeDidUnregister()
418
-
419
- if (DEBUG_TYPE_NAMES.includes(this.type.name) || DEBUG_ALL_TYPES) {
420
- Logger.debug(`[VERBOSE] Bridge UNREGISTERED an instance of ${this.type.name}, current count: ${Object.keys(this.handlesByAddress).length}`)
421
- }
422
- }
423
-
424
- /** @internal */
425
- unregisterAll() {
426
- if (DEBUG_TYPE_NAMES.includes(this.type.name) || DEBUG_ALL_TYPES) {
427
- Logger.debug(`[VERBOSE] Unregistering ALL bridged instances of type ${this.type.name}.`)
428
- }
429
-
430
- for (const handle of Object.values(this.handlesByAddress)) {
431
- const object = handle.object()
432
- if (object) {
433
- this.unregister(object)
434
- }
435
- }
436
- }
437
-
438
- /**
439
- * Closes the object by calling `release()` and `null`-ing its pointer, such
440
- * that its handle can't be `deref()`-ed afterwards.
441
- *
442
- * @internal */
443
- async close(object: T): Promise<void> {
444
- const objectType = object.constructor
445
- const bridgeType = this.type
446
- if (objectType !== bridgeType) throw new Error(`Can't close, bridge is configured for type ${bridgeType.name} but passed in object is of type ${objectType.name}`)
447
-
448
- const handle = this.handlesByObject.get(object)
449
- if (handle == null) throw new Error(`Can't close an object that has not been registered before: ${object}`)
450
- if (handle.type !== bridgeType) throw new Error(`Internal inconsistency, trying to close an object that has a handle with a different type than that of the bridge: ${handle}`)
451
-
452
- if (handle.isUnregistered) throw new Error(`Can't close object, object has been unregistered.`)
453
- if (handle.isFinalized) throw new Error(`Internal inconsistency, trying to close an object that has already been finalized.`)
454
- if (handle.isClosed) return
455
-
456
- const pointer = handle.pointer
457
- if (!pointer) throw new Error(`Internal inconsistency, trying to close an object whose pointer is null.`)
458
-
459
- handle.bridgeWillClose()
460
- delete this.handlesByAddress[pointer.addr]
461
- await this.release(pointer)
462
- handle.bridgeDidClose()
463
-
464
- if (DEBUG_TYPE_NAMES.includes(this.type.name) || DEBUG_ALL_TYPES) {
465
- Logger.debug(`[VERBOSE] Bridge CLOSED an instance of ${this.type.name}, current count: ${Object.keys(this.handlesByAddress).length}`)
466
- }
467
- }
468
-
469
- /** @internal */
470
- get count(): number {
471
- return Object.keys(this.handlesByAddress).length
472
- }
473
-
474
- /**
475
- * Keeps track of all bridges for debugging and test purposes. With this, we
476
- * can iterate over all bridges and make sure everything is deallocated after
477
- * a test, or a suite of tests, has run.
478
- *
479
- * @internal */
480
- static readonly all: Array<WeakRef<Bridge<any, any>>> = []
481
-
482
- /** @internal */
483
- static readonly attachment = new Bridge<Attachment, FFI.AttachmentHandle>(FFI.freeAttachmentHandle)
484
-
485
- /** @internal */
486
- static readonly document = new Bridge<Document, FFI.FFIDocument>(FFI.documentFree)
487
-
488
- /** @internal */
489
- static readonly mutableDocument = new Bridge<MutableDocument, FFI.FFIDocument>(FFI.documentFree)
490
-
491
- /** @internal */
492
- static readonly dqlResponse = new Bridge<QueryResult, FFI.FFIDqlResponse>(FFI.dqlResponseFree)
493
-
494
- /** @internal */
495
- static readonly dqlResult = new Bridge<QueryResultItem, FFI.FFIDqlResult>(FFI.dqlResultFree)
496
-
497
- /** @internal */
498
- static readonly staticTCPClient = new Bridge<StaticTCPClient, FFI.FFIStaticTCPClient>(FFI.staticTCPClientFreeHandle)
499
-
500
- /** @internal */
501
- static readonly websocketClient = new Bridge<WebsocketClient, FFI.FFIWebsocketClient>(FFI.websocketClientFreeHandle)
502
-
503
- /** @internal */
504
- static readonly ditto = new Bridge<Ditto, FFI.FFIDitto>(async (dittoPointer) => {
505
- FFI.dittoClearPresenceCallback(dittoPointer)
506
- await FFI.dittoShutdown(dittoPointer)
507
- FFI.dittoFree(dittoPointer)
508
- })
509
-
510
- // ------ Private ------
511
-
512
- private internalType: BridgeType<T> | null = null
513
-
514
- /**
515
- * All bridged objects' {@link Handle} entries for lookup by pointer address.
516
- */
517
- private handlesByAddress: { [key: FFI.Pointer<T>['addr']]: Handle<T, FFIType> }
518
-
519
- /**
520
- * Look up a handle given its object.
521
- *
522
- * As `WeakMap` does not allow for enumeration, use `this.handlesByAddress` to
523
- * iterate over all handles.
524
- */
525
- private handlesByObject: WeakMap<T, Handle<T, FFIType>>
526
-
527
- private finalizationRegistry: FinalizationRegistry<any>
528
-
529
- private async finalize(handle: Handle<T, FFIType>): Promise<void> {
530
- if (handle.isFinalized) throw new Error(`Internal inconsistency, trying to finalize an object that has already been finalized.`)
531
- if (handle.isUnregistered) throw new Error(`Internal inconsistency, trying to finalize an object that has been unregistered before.`)
532
-
533
- handle.bridgeWillFinalize()
534
-
535
- if (!handle.isClosed) {
536
- const pointer = handle.pointer
537
- if (!pointer) throw new Error(`Internal inconsistency, trying to finalize an object whose pointer is null.`)
538
-
539
- delete this.handlesByAddress[pointer.addr]
540
- await this.release(pointer)
541
- }
542
-
543
- handle.bridgeDidFinalize()
544
-
545
- if (DEBUG_TYPE_NAMES.includes(this.type.name) || DEBUG_ALL_TYPES) {
546
- Logger.debug(`[VERBOSE] Bridge FINALIZED an instance of ${this.type.name}, current count: ${Object.keys(this.handlesByAddress).length}`)
547
- }
548
- }
549
- }
@@ -1,4 +0,0 @@
1
-
2
- export const fullBuildVersionString = '{full-build-version-string}'
3
-
4
- export const defaultDittoWasmFileURL = '{default-ditto-wasm-file-url}'
@@ -1,35 +0,0 @@
1
- //
2
- // Copyright © 2021 DittoLive Incorporated. All rights reserved.
3
- //
4
-
5
- import { CBOR as CBORRedux } from './@cbor-redux'
6
-
7
- import { DocumentID } from './document-id'
8
-
9
- /** @internal */
10
- export class CBOR {
11
- /** @internal */
12
- static encode(data: any, replacer?: (key: any, value: any) => any): Uint8Array {
13
- const arrayBuffer = CBORRedux.encode(data, replacer)
14
- return new Uint8Array(arrayBuffer)
15
- }
16
-
17
- /** @internal */
18
- static decode(data: Uint8Array, reviver?: (key: any, value: any) => any): any {
19
- const arrayBuffer = data.buffer
20
- return CBORRedux.decode(arrayBuffer, reviver)
21
- }
22
- }
23
-
24
- /**
25
- * Custom replacer that converts `DocumentID` instances to their string
26
- * representation.
27
- *
28
- * @internal
29
- */
30
- export function documentIDReplacer(key: any, value: any): any {
31
- if (value instanceof DocumentID) {
32
- return value.toString()
33
- }
34
- return value
35
- }