@dittolive/ditto 4.4.5 → 4.5.1

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 (542) hide show
  1. package/DittoReactNative.podspec +28 -0
  2. package/README.md +68 -51
  3. package/node/ditto.cjs.js +1718 -897
  4. package/node/ditto.darwin-arm64.node +0 -0
  5. package/node/ditto.darwin-x64.node +0 -0
  6. package/node/ditto.linux-arm.node +0 -0
  7. package/node/ditto.linux-x64.node +0 -0
  8. package/node/ditto.win32-x64.node +0 -0
  9. package/node/transports.darwin-arm64.node +0 -0
  10. package/node/transports.darwin-x64.node +0 -0
  11. package/package.json +27 -31
  12. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/query/client-agp/cache-v2 +0 -0
  13. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/query/client-agp/cmakeFiles-v1 +0 -0
  14. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/query/client-agp/codemodel-v2 +0 -0
  15. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/reply/cache-v2-970081f7c58ab1625a1a.json +1303 -0
  16. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/reply/cmakeFiles-v1-e1bacde094ce7e389294.json +203 -0
  17. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/reply/codemodel-v2-54964c7f44134b1cec4d.json +60 -0
  18. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json +14 -0
  19. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/reply/index-2023-12-06T19-58-48-0479.json +92 -0
  20. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.cmake/api/v1/reply/target-cpp-Debug-a438adda6ad6df71f898.json +314 -0
  21. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.ninja_deps +0 -0
  22. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/.ninja_log +21 -0
  23. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeCache.txt +393 -0
  24. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CMakeCCompiler.cmake +79 -0
  25. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CMakeCXXCompiler.cmake +90 -0
  26. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CMakeDetermineCompilerABI_C.bin +0 -0
  27. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CMakeDetermineCompilerABI_CXX.bin +0 -0
  28. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CMakeSystem.cmake +113 -0
  29. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CompilerIdC/CMakeCCompilerId.c +803 -0
  30. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CompilerIdC/CMakeCCompilerId.o +0 -0
  31. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CompilerIdCXX/CMakeCXXCompilerId.cpp +791 -0
  32. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/3.22.1-g37088a8/CompilerIdCXX/CMakeCXXCompilerId.o +0 -0
  33. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/CMakeOutput.log +320 -0
  34. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/TargetDirectories.txt +3 -0
  35. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cmake.check_cache +1 -0
  36. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Attachment.cpp.o +0 -0
  37. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Authentication.cpp.o +0 -0
  38. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Collection.cpp.o +0 -0
  39. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/DQL.cpp.o +0 -0
  40. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Document.cpp.o +0 -0
  41. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Identity.cpp.o +0 -0
  42. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Lifecycle.cpp.o +0 -0
  43. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/LiveQuery.cpp.o +0 -0
  44. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Logger.cpp.o +0 -0
  45. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Misc.cpp.o +0 -0
  46. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Presence.cpp.o +0 -0
  47. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/RetainableState.cpp.o +0 -0
  48. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/SmallPeerInfo.cpp.o +0 -0
  49. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Transports.cpp.o +0 -0
  50. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/TypedArray.cpp.o +0 -0
  51. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Utils.cpp.o +0 -0
  52. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/main.cpp.o +0 -0
  53. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/dittoffi/ifaddrs.cpp.o +0 -0
  54. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/cpp.dir/cpp-adapter.cpp.o +0 -0
  55. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/CMakeFiles/rules.ninja +64 -0
  56. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/additional_project_files.txt +0 -0
  57. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/android_gradle_build.json +42 -0
  58. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/android_gradle_build_mini.json +31 -0
  59. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/build.ninja +297 -0
  60. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/build_file_index.txt +3 -0
  61. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/cmake_install.cmake +54 -0
  62. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/compile_commands.json +97 -0
  63. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/compile_commands.json.bin +0 -0
  64. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/configure_fingerprint.bin +8755 -0
  65. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/metadata_generation_command.txt +21 -0
  66. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/prefab_config.json +8 -0
  67. package/react-native/android/.cxx/Debug/6p5m3p3q/arm64-v8a/symbol_folder_index.txt +1 -0
  68. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/query/client-agp/cache-v2 +0 -0
  69. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/query/client-agp/cmakeFiles-v1 +0 -0
  70. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/query/client-agp/codemodel-v2 +0 -0
  71. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/reply/cache-v2-0cc74b41e95a51ba0457.json +1303 -0
  72. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/reply/cmakeFiles-v1-ee90fea936bce5771631.json +203 -0
  73. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/reply/codemodel-v2-82fa8946198e6eba430b.json +60 -0
  74. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json +14 -0
  75. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/reply/index-2023-12-06T19-58-48-0893.json +92 -0
  76. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.cmake/api/v1/reply/target-cpp-Debug-1e9d0b1a457f7fe5c618.json +314 -0
  77. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.ninja_deps +0 -0
  78. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/.ninja_log +21 -0
  79. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeCache.txt +393 -0
  80. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CMakeCCompiler.cmake +79 -0
  81. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CMakeCXXCompiler.cmake +90 -0
  82. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CMakeDetermineCompilerABI_C.bin +0 -0
  83. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CMakeDetermineCompilerABI_CXX.bin +0 -0
  84. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CMakeSystem.cmake +115 -0
  85. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CompilerIdC/CMakeCCompilerId.c +803 -0
  86. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CompilerIdC/CMakeCCompilerId.o +0 -0
  87. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CompilerIdCXX/CMakeCXXCompilerId.cpp +791 -0
  88. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/3.22.1-g37088a8/CompilerIdCXX/CMakeCXXCompilerId.o +0 -0
  89. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/CMakeOutput.log +304 -0
  90. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/TargetDirectories.txt +3 -0
  91. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cmake.check_cache +1 -0
  92. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Attachment.cpp.o +0 -0
  93. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Authentication.cpp.o +0 -0
  94. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Collection.cpp.o +0 -0
  95. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/DQL.cpp.o +0 -0
  96. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Document.cpp.o +0 -0
  97. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Identity.cpp.o +0 -0
  98. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Lifecycle.cpp.o +0 -0
  99. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/LiveQuery.cpp.o +0 -0
  100. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Logger.cpp.o +0 -0
  101. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Misc.cpp.o +0 -0
  102. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Presence.cpp.o +0 -0
  103. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/RetainableState.cpp.o +0 -0
  104. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/SmallPeerInfo.cpp.o +0 -0
  105. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Transports.cpp.o +0 -0
  106. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/TypedArray.cpp.o +0 -0
  107. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Utils.cpp.o +0 -0
  108. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/main.cpp.o +0 -0
  109. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/dittoffi/ifaddrs.cpp.o +0 -0
  110. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/cpp.dir/cpp-adapter.cpp.o +0 -0
  111. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/CMakeFiles/rules.ninja +64 -0
  112. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/additional_project_files.txt +0 -0
  113. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/android_gradle_build.json +42 -0
  114. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/android_gradle_build_mini.json +31 -0
  115. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/build.ninja +297 -0
  116. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/build_file_index.txt +3 -0
  117. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/cmake_install.cmake +54 -0
  118. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/compile_commands.json +97 -0
  119. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/compile_commands.json.bin +0 -0
  120. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/configure_fingerprint.bin +8755 -0
  121. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/metadata_generation_command.txt +21 -0
  122. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/prefab_config.json +8 -0
  123. package/react-native/android/.cxx/Debug/6p5m3p3q/armeabi-v7a/symbol_folder_index.txt +1 -0
  124. package/react-native/android/.cxx/Debug/6p5m3p3q/hash_key.txt +28 -0
  125. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/arm64-v8a/prefab/lib/aarch64-linux-android/cmake/ReactAndroid/ReactAndroidConfig.cmake +261 -0
  126. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/arm64-v8a/prefab/lib/aarch64-linux-android/cmake/ReactAndroid/ReactAndroidConfigVersion.cmake +9 -0
  127. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/arm64-v8a/prefab/lib/aarch64-linux-android/cmake/fbjni/fbjniConfig.cmake +9 -0
  128. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/arm64-v8a/prefab/lib/aarch64-linux-android/cmake/fbjni/fbjniConfigVersion.cmake +9 -0
  129. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/armeabi-v7a/prefab/lib/arm-linux-androideabi/cmake/ReactAndroid/ReactAndroidConfig.cmake +261 -0
  130. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/armeabi-v7a/prefab/lib/arm-linux-androideabi/cmake/ReactAndroid/ReactAndroidConfigVersion.cmake +9 -0
  131. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/armeabi-v7a/prefab/lib/arm-linux-androideabi/cmake/fbjni/fbjniConfig.cmake +9 -0
  132. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/armeabi-v7a/prefab/lib/arm-linux-androideabi/cmake/fbjni/fbjniConfigVersion.cmake +9 -0
  133. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/x86/prefab/lib/i686-linux-android/cmake/ReactAndroid/ReactAndroidConfig.cmake +261 -0
  134. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/x86/prefab/lib/i686-linux-android/cmake/ReactAndroid/ReactAndroidConfigVersion.cmake +9 -0
  135. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/x86/prefab/lib/i686-linux-android/cmake/fbjni/fbjniConfig.cmake +9 -0
  136. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/x86/prefab/lib/i686-linux-android/cmake/fbjni/fbjniConfigVersion.cmake +9 -0
  137. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/x86_64/prefab/lib/x86_64-linux-android/cmake/ReactAndroid/ReactAndroidConfig.cmake +261 -0
  138. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/x86_64/prefab/lib/x86_64-linux-android/cmake/ReactAndroid/ReactAndroidConfigVersion.cmake +9 -0
  139. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/x86_64/prefab/lib/x86_64-linux-android/cmake/fbjni/fbjniConfig.cmake +9 -0
  140. package/react-native/android/.cxx/Debug/6p5m3p3q/prefab/x86_64/prefab/lib/x86_64-linux-android/cmake/fbjni/fbjniConfigVersion.cmake +9 -0
  141. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/query/client-agp/cache-v2 +0 -0
  142. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/query/client-agp/cmakeFiles-v1 +0 -0
  143. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/query/client-agp/codemodel-v2 +0 -0
  144. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/reply/cache-v2-6c4a25b4c6713ffdc5da.json +1303 -0
  145. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/reply/cmakeFiles-v1-f4200ba0f2ce507c91da.json +203 -0
  146. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/reply/codemodel-v2-9ea6ff99336eeb9a9ce9.json +60 -0
  147. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json +14 -0
  148. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/reply/index-2023-12-06T19-58-49-0301.json +92 -0
  149. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.cmake/api/v1/reply/target-cpp-Debug-a88e6d0219517e1d531b.json +314 -0
  150. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.ninja_deps +0 -0
  151. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/.ninja_log +21 -0
  152. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeCache.txt +393 -0
  153. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CMakeCCompiler.cmake +79 -0
  154. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CMakeCXXCompiler.cmake +90 -0
  155. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CMakeDetermineCompilerABI_C.bin +0 -0
  156. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CMakeDetermineCompilerABI_CXX.bin +0 -0
  157. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CMakeSystem.cmake +113 -0
  158. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CompilerIdC/CMakeCCompilerId.c +803 -0
  159. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CompilerIdC/CMakeCCompilerId.o +0 -0
  160. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CompilerIdCXX/CMakeCXXCompilerId.cpp +791 -0
  161. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/3.22.1-g37088a8/CompilerIdCXX/CMakeCXXCompilerId.o +0 -0
  162. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/CMakeOutput.log +322 -0
  163. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/TargetDirectories.txt +3 -0
  164. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cmake.check_cache +1 -0
  165. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Attachment.cpp.o +0 -0
  166. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Authentication.cpp.o +0 -0
  167. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Collection.cpp.o +0 -0
  168. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/DQL.cpp.o +0 -0
  169. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Document.cpp.o +0 -0
  170. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Identity.cpp.o +0 -0
  171. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Lifecycle.cpp.o +0 -0
  172. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/LiveQuery.cpp.o +0 -0
  173. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Logger.cpp.o +0 -0
  174. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Misc.cpp.o +0 -0
  175. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Presence.cpp.o +0 -0
  176. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/RetainableState.cpp.o +0 -0
  177. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/SmallPeerInfo.cpp.o +0 -0
  178. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Transports.cpp.o +0 -0
  179. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/TypedArray.cpp.o +0 -0
  180. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Utils.cpp.o +0 -0
  181. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/main.cpp.o +0 -0
  182. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/dittoffi/ifaddrs.cpp.o +0 -0
  183. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/cpp.dir/cpp-adapter.cpp.o +0 -0
  184. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/CMakeFiles/rules.ninja +64 -0
  185. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/additional_project_files.txt +0 -0
  186. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/android_gradle_build.json +42 -0
  187. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/android_gradle_build_mini.json +31 -0
  188. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/build.ninja +297 -0
  189. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/build_file_index.txt +3 -0
  190. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/cmake_install.cmake +54 -0
  191. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/compile_commands.json +97 -0
  192. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/compile_commands.json.bin +0 -0
  193. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/metadata_generation_command.txt +21 -0
  194. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/prefab_config.json +8 -0
  195. package/react-native/android/.cxx/Debug/6p5m3p3q/x86/symbol_folder_index.txt +1 -0
  196. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/query/client-agp/cache-v2 +0 -0
  197. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/query/client-agp/cmakeFiles-v1 +0 -0
  198. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/query/client-agp/codemodel-v2 +0 -0
  199. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/reply/cache-v2-dae9c0e6f8d6c826f86e.json +1303 -0
  200. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/reply/cmakeFiles-v1-77b66408bf04fa403cf4.json +203 -0
  201. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/reply/codemodel-v2-00d5bd5dc4a882f89004.json +60 -0
  202. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/reply/directory-.-Debug-f5ebdc15457944623624.json +14 -0
  203. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/reply/index-2023-12-06T19-58-49-0701.json +92 -0
  204. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.cmake/api/v1/reply/target-cpp-Debug-ed2a7b63dedc1886a528.json +314 -0
  205. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.ninja_deps +0 -0
  206. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/.ninja_log +21 -0
  207. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeCache.txt +393 -0
  208. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CMakeCCompiler.cmake +79 -0
  209. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CMakeCXXCompiler.cmake +90 -0
  210. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CMakeDetermineCompilerABI_C.bin +0 -0
  211. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CMakeDetermineCompilerABI_CXX.bin +0 -0
  212. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CMakeSystem.cmake +113 -0
  213. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CompilerIdC/CMakeCCompilerId.c +803 -0
  214. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CompilerIdC/CMakeCCompilerId.o +0 -0
  215. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CompilerIdCXX/CMakeCXXCompilerId.cpp +791 -0
  216. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/3.22.1-g37088a8/CompilerIdCXX/CMakeCXXCompilerId.o +0 -0
  217. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/CMakeOutput.log +322 -0
  218. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/TargetDirectories.txt +3 -0
  219. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cmake.check_cache +1 -0
  220. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Attachment.cpp.o +0 -0
  221. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Authentication.cpp.o +0 -0
  222. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Collection.cpp.o +0 -0
  223. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/DQL.cpp.o +0 -0
  224. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Document.cpp.o +0 -0
  225. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Identity.cpp.o +0 -0
  226. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Lifecycle.cpp.o +0 -0
  227. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/LiveQuery.cpp.o +0 -0
  228. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Logger.cpp.o +0 -0
  229. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Misc.cpp.o +0 -0
  230. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Presence.cpp.o +0 -0
  231. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/RetainableState.cpp.o +0 -0
  232. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/SmallPeerInfo.cpp.o +0 -0
  233. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Transports.cpp.o +0 -0
  234. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/TypedArray.cpp.o +0 -0
  235. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/Utils.cpp.o +0 -0
  236. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/cpp/src/main.cpp.o +0 -0
  237. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/Users/teodorc/Projects/IntegrationTest/node_modules/@dittolive/ditto/react-native/dittoffi/ifaddrs.cpp.o +0 -0
  238. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/cpp.dir/cpp-adapter.cpp.o +0 -0
  239. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/CMakeFiles/rules.ninja +64 -0
  240. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/additional_project_files.txt +0 -0
  241. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/android_gradle_build.json +42 -0
  242. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/android_gradle_build_mini.json +31 -0
  243. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/build.ninja +297 -0
  244. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/build_file_index.txt +3 -0
  245. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/cmake_install.cmake +54 -0
  246. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/compile_commands.json +97 -0
  247. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/compile_commands.json.bin +0 -0
  248. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/configure_fingerprint.bin +8755 -0
  249. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/metadata_generation_command.txt +21 -0
  250. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/prefab_config.json +8 -0
  251. package/react-native/android/.cxx/Debug/6p5m3p3q/x86_64/symbol_folder_index.txt +1 -0
  252. package/react-native/android/.cxx/tools/debug/arm64-v8a/compile_commands.json +97 -0
  253. package/react-native/android/.cxx/tools/debug/armeabi-v7a/compile_commands.json +97 -0
  254. package/react-native/android/.cxx/tools/debug/x86/compile_commands.json +97 -0
  255. package/react-native/android/.cxx/tools/debug/x86_64/compile_commands.json +97 -0
  256. package/react-native/android/.gradle/8.5/checksums/checksums.lock +0 -0
  257. package/react-native/android/.gradle/8.5/dependencies-accessors/dependencies-accessors.lock +0 -0
  258. package/react-native/android/.gradle/8.5/dependencies-accessors/gc.properties +0 -0
  259. package/react-native/android/.gradle/8.5/fileChanges/last-build.bin +0 -0
  260. package/react-native/android/.gradle/8.5/fileHashes/fileHashes.lock +0 -0
  261. package/react-native/android/.gradle/8.5/gc.properties +0 -0
  262. package/react-native/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
  263. package/react-native/android/.gradle/buildOutputCleanup/cache.properties +2 -0
  264. package/react-native/android/.gradle/vcs-1/gc.properties +0 -0
  265. package/react-native/android/CMakeLists.txt +37 -0
  266. package/react-native/android/build.gradle +203 -0
  267. package/react-native/android/cpp-adapter.cpp +254 -0
  268. package/react-native/android/gradle.properties +5 -0
  269. package/react-native/android/src/main/AndroidManifest.xml +4 -0
  270. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +85 -0
  271. package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +28 -0
  272. package/react-native/boost/boost/assert.hpp +85 -0
  273. package/react-native/boost/boost/config/abi/borland_prefix.hpp +27 -0
  274. package/react-native/boost/boost/config/abi/borland_suffix.hpp +12 -0
  275. package/react-native/boost/boost/config/abi/msvc_prefix.hpp +22 -0
  276. package/react-native/boost/boost/config/abi/msvc_suffix.hpp +8 -0
  277. package/react-native/boost/boost/config/abi_prefix.hpp +25 -0
  278. package/react-native/boost/boost/config/abi_suffix.hpp +25 -0
  279. package/react-native/boost/boost/config/assert_cxx03.hpp +211 -0
  280. package/react-native/boost/boost/config/assert_cxx11.hpp +209 -0
  281. package/react-native/boost/boost/config/assert_cxx14.hpp +47 -0
  282. package/react-native/boost/boost/config/assert_cxx17.hpp +62 -0
  283. package/react-native/boost/boost/config/assert_cxx20.hpp +59 -0
  284. package/react-native/boost/boost/config/assert_cxx98.hpp +23 -0
  285. package/react-native/boost/boost/config/auto_link.hpp +525 -0
  286. package/react-native/boost/boost/config/compiler/borland.hpp +339 -0
  287. package/react-native/boost/boost/config/compiler/clang.hpp +366 -0
  288. package/react-native/boost/boost/config/compiler/clang_version.hpp +83 -0
  289. package/react-native/boost/boost/config/compiler/codegear.hpp +385 -0
  290. package/react-native/boost/boost/config/compiler/comeau.hpp +59 -0
  291. package/react-native/boost/boost/config/compiler/common_edg.hpp +183 -0
  292. package/react-native/boost/boost/config/compiler/compaq_cxx.hpp +19 -0
  293. package/react-native/boost/boost/config/compiler/cray.hpp +446 -0
  294. package/react-native/boost/boost/config/compiler/diab.hpp +26 -0
  295. package/react-native/boost/boost/config/compiler/digitalmars.hpp +143 -0
  296. package/react-native/boost/boost/config/compiler/gcc.hpp +383 -0
  297. package/react-native/boost/boost/config/compiler/gcc_xml.hpp +114 -0
  298. package/react-native/boost/boost/config/compiler/greenhills.hpp +28 -0
  299. package/react-native/boost/boost/config/compiler/hp_acc.hpp +149 -0
  300. package/react-native/boost/boost/config/compiler/intel.hpp +577 -0
  301. package/react-native/boost/boost/config/compiler/kai.hpp +33 -0
  302. package/react-native/boost/boost/config/compiler/metrowerks.hpp +198 -0
  303. package/react-native/boost/boost/config/compiler/mpw.hpp +140 -0
  304. package/react-native/boost/boost/config/compiler/nvcc.hpp +61 -0
  305. package/react-native/boost/boost/config/compiler/pathscale.hpp +138 -0
  306. package/react-native/boost/boost/config/compiler/pgi.hpp +23 -0
  307. package/react-native/boost/boost/config/compiler/sgi_mipspro.hpp +29 -0
  308. package/react-native/boost/boost/config/compiler/sunpro_cc.hpp +222 -0
  309. package/react-native/boost/boost/config/compiler/vacpp.hpp +186 -0
  310. package/react-native/boost/boost/config/compiler/visualc.hpp +391 -0
  311. package/react-native/boost/boost/config/compiler/xlcpp.hpp +299 -0
  312. package/react-native/boost/boost/config/compiler/xlcpp_zos.hpp +173 -0
  313. package/react-native/boost/boost/config/detail/cxx_composite.hpp +203 -0
  314. package/react-native/boost/boost/config/detail/posix_features.hpp +95 -0
  315. package/react-native/boost/boost/config/detail/select_compiler_config.hpp +157 -0
  316. package/react-native/boost/boost/config/detail/select_platform_config.hpp +147 -0
  317. package/react-native/boost/boost/config/detail/select_stdlib_config.hpp +121 -0
  318. package/react-native/boost/boost/config/detail/suffix.hpp +1294 -0
  319. package/react-native/boost/boost/config/header_deprecated.hpp +26 -0
  320. package/react-native/boost/boost/config/helper_macros.hpp +37 -0
  321. package/react-native/boost/boost/config/no_tr1/cmath.hpp +28 -0
  322. package/react-native/boost/boost/config/no_tr1/complex.hpp +28 -0
  323. package/react-native/boost/boost/config/no_tr1/functional.hpp +28 -0
  324. package/react-native/boost/boost/config/no_tr1/memory.hpp +28 -0
  325. package/react-native/boost/boost/config/no_tr1/utility.hpp +28 -0
  326. package/react-native/boost/boost/config/platform/aix.hpp +33 -0
  327. package/react-native/boost/boost/config/platform/amigaos.hpp +15 -0
  328. package/react-native/boost/boost/config/platform/beos.hpp +26 -0
  329. package/react-native/boost/boost/config/platform/bsd.hpp +83 -0
  330. package/react-native/boost/boost/config/platform/cloudabi.hpp +18 -0
  331. package/react-native/boost/boost/config/platform/cray.hpp +18 -0
  332. package/react-native/boost/boost/config/platform/cygwin.hpp +71 -0
  333. package/react-native/boost/boost/config/platform/haiku.hpp +31 -0
  334. package/react-native/boost/boost/config/platform/hpux.hpp +87 -0
  335. package/react-native/boost/boost/config/platform/irix.hpp +31 -0
  336. package/react-native/boost/boost/config/platform/linux.hpp +106 -0
  337. package/react-native/boost/boost/config/platform/macos.hpp +87 -0
  338. package/react-native/boost/boost/config/platform/qnxnto.hpp +31 -0
  339. package/react-native/boost/boost/config/platform/solaris.hpp +31 -0
  340. package/react-native/boost/boost/config/platform/symbian.hpp +97 -0
  341. package/react-native/boost/boost/config/platform/vms.hpp +25 -0
  342. package/react-native/boost/boost/config/platform/vxworks.hpp +422 -0
  343. package/react-native/boost/boost/config/platform/wasm.hpp +23 -0
  344. package/react-native/boost/boost/config/platform/win32.hpp +90 -0
  345. package/react-native/boost/boost/config/platform/zos.hpp +32 -0
  346. package/react-native/boost/boost/config/pragma_message.hpp +31 -0
  347. package/react-native/boost/boost/config/requires_threads.hpp +92 -0
  348. package/react-native/boost/boost/config/stdlib/dinkumware.hpp +324 -0
  349. package/react-native/boost/boost/config/stdlib/libcomo.hpp +93 -0
  350. package/react-native/boost/boost/config/stdlib/libcpp.hpp +180 -0
  351. package/react-native/boost/boost/config/stdlib/libstdcpp3.hpp +482 -0
  352. package/react-native/boost/boost/config/stdlib/modena.hpp +79 -0
  353. package/react-native/boost/boost/config/stdlib/msl.hpp +98 -0
  354. package/react-native/boost/boost/config/stdlib/roguewave.hpp +208 -0
  355. package/react-native/boost/boost/config/stdlib/sgi.hpp +168 -0
  356. package/react-native/boost/boost/config/stdlib/stlport.hpp +258 -0
  357. package/react-native/boost/boost/config/stdlib/vacpp.hpp +74 -0
  358. package/react-native/boost/boost/config/stdlib/xlcpp_zos.hpp +61 -0
  359. package/react-native/boost/boost/config/user.hpp +133 -0
  360. package/react-native/boost/boost/config/warning_disable.hpp +47 -0
  361. package/react-native/boost/boost/config/workaround.hpp +305 -0
  362. package/react-native/boost/boost/config.hpp +67 -0
  363. package/react-native/boost/boost/cstdint.hpp +556 -0
  364. package/react-native/boost/boost/intrusive_ptr.hpp +18 -0
  365. package/react-native/boost/boost/smart_ptr/detail/atomic_count.hpp +103 -0
  366. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc.hpp +79 -0
  367. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp +63 -0
  368. package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_x86.hpp +88 -0
  369. package/react-native/boost/boost/smart_ptr/detail/atomic_count_nt.hpp +66 -0
  370. package/react-native/boost/boost/smart_ptr/detail/atomic_count_pt.hpp +104 -0
  371. package/react-native/boost/boost/smart_ptr/detail/atomic_count_spin.hpp +69 -0
  372. package/react-native/boost/boost/smart_ptr/detail/atomic_count_std_atomic.hpp +67 -0
  373. package/react-native/boost/boost/smart_ptr/detail/atomic_count_sync.hpp +72 -0
  374. package/react-native/boost/boost/smart_ptr/detail/atomic_count_win32.hpp +70 -0
  375. package/react-native/boost/boost/smart_ptr/detail/local_counted_base.hpp +148 -0
  376. package/react-native/boost/boost/smart_ptr/detail/local_sp_deleter.hpp +91 -0
  377. package/react-native/boost/boost/smart_ptr/detail/operator_bool.hpp +64 -0
  378. package/react-native/boost/boost/smart_ptr/detail/requires_cxx11.hpp +23 -0
  379. package/react-native/boost/boost/smart_ptr/detail/shared_count.hpp +707 -0
  380. package/react-native/boost/boost/smart_ptr/detail/sp_convertible.hpp +92 -0
  381. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base.hpp +92 -0
  382. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +163 -0
  383. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_aix.hpp +152 -0
  384. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +185 -0
  385. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp +148 -0
  386. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +170 -0
  387. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +200 -0
  388. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +194 -0
  389. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +179 -0
  390. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +186 -0
  391. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_nt.hpp +119 -0
  392. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_pt.hpp +147 -0
  393. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +174 -0
  394. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_spin.hpp +141 -0
  395. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +147 -0
  396. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp +165 -0
  397. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +163 -0
  398. package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_w32.hpp +140 -0
  399. package/react-native/boost/boost/smart_ptr/detail/sp_counted_impl.hpp +309 -0
  400. package/react-native/boost/boost/smart_ptr/detail/sp_disable_deprecated.hpp +40 -0
  401. package/react-native/boost/boost/smart_ptr/detail/sp_forward.hpp +52 -0
  402. package/react-native/boost/boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp +27 -0
  403. package/react-native/boost/boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp +69 -0
  404. package/react-native/boost/boost/smart_ptr/detail/sp_interlocked.hpp +173 -0
  405. package/react-native/boost/boost/smart_ptr/detail/sp_noexcept.hpp +48 -0
  406. package/react-native/boost/boost/smart_ptr/detail/sp_nullptr_t.hpp +45 -0
  407. package/react-native/boost/boost/smart_ptr/detail/sp_obsolete.hpp +32 -0
  408. package/react-native/boost/boost/smart_ptr/detail/sp_thread_pause.hpp +51 -0
  409. package/react-native/boost/boost/smart_ptr/detail/sp_thread_sleep.hpp +104 -0
  410. package/react-native/boost/boost/smart_ptr/detail/sp_thread_yield.hpp +100 -0
  411. package/react-native/boost/boost/smart_ptr/detail/sp_typeinfo_.hpp +58 -0
  412. package/react-native/boost/boost/smart_ptr/detail/sp_win32_sleep.hpp +49 -0
  413. package/react-native/boost/boost/smart_ptr/intrusive_ptr.hpp +409 -0
  414. package/react-native/boost/boost/smart_ptr/intrusive_ref_counter.hpp +188 -0
  415. package/react-native/cpp/include/Attachment.h +16 -0
  416. package/react-native/cpp/include/Authentication.h +23 -0
  417. package/react-native/cpp/include/Collection.h +13 -0
  418. package/react-native/cpp/include/DQL.h +21 -0
  419. package/react-native/cpp/include/Document.h +17 -0
  420. package/react-native/cpp/include/Identity.h +17 -0
  421. package/react-native/cpp/include/Lifecycle.h +16 -0
  422. package/react-native/cpp/include/LiveQuery.h +17 -0
  423. package/react-native/cpp/include/Logger.h +22 -0
  424. package/react-native/cpp/include/Misc.h +26 -0
  425. package/react-native/cpp/include/Presence.h +14 -0
  426. package/react-native/cpp/include/RetainableState.h +24 -0
  427. package/react-native/cpp/include/SmallPeerInfo.h +17 -0
  428. package/react-native/cpp/include/Transports.h +25 -0
  429. package/react-native/cpp/include/TypedArray.hpp +167 -0
  430. package/react-native/cpp/include/Utils.h +61 -0
  431. package/react-native/cpp/include/main.h +10 -0
  432. package/react-native/cpp/src/Attachment.cpp +86 -0
  433. package/react-native/cpp/src/Authentication.cpp +224 -0
  434. package/react-native/cpp/src/Collection.cpp +54 -0
  435. package/react-native/cpp/src/DQL.cpp +254 -0
  436. package/react-native/cpp/src/Document.cpp +146 -0
  437. package/react-native/cpp/src/Identity.cpp +123 -0
  438. package/react-native/cpp/src/Lifecycle.cpp +75 -0
  439. package/react-native/cpp/src/LiveQuery.cpp +64 -0
  440. package/react-native/cpp/src/Logger.cpp +200 -0
  441. package/react-native/cpp/src/Misc.cpp +271 -0
  442. package/react-native/cpp/src/Presence.cpp +77 -0
  443. package/react-native/cpp/src/RetainableState.cpp +15 -0
  444. package/react-native/cpp/src/SmallPeerInfo.cpp +108 -0
  445. package/react-native/cpp/src/Transports.cpp +270 -0
  446. package/react-native/cpp/src/TypedArray.cpp +303 -0
  447. package/react-native/cpp/src/Utils.cpp +138 -0
  448. package/react-native/cpp/src/main.cpp +149 -0
  449. package/react-native/dittoffi/dittoffi.h +4698 -0
  450. package/react-native/dittoffi/ifaddrs.cpp +385 -0
  451. package/react-native/dittoffi/ifaddrs.h +206 -0
  452. package/react-native/ios/DittoRNSDK.h +7 -0
  453. package/react-native/ios/DittoRNSDK.mm +107 -0
  454. package/react-native/ios/YeetJSIUtils.h +60 -0
  455. package/react-native/ios/YeetJSIUtils.mm +196 -0
  456. package/react-native/lib/commonjs/ditto.rn.js +93 -0
  457. package/react-native/lib/commonjs/ditto.rn.js.map +1 -0
  458. package/react-native/lib/commonjs/index.js +14 -0
  459. package/react-native/lib/commonjs/index.js.map +1 -0
  460. package/react-native/lib/module/ditto.rn.js +83 -0
  461. package/react-native/lib/module/ditto.rn.js.map +1 -0
  462. package/react-native/lib/module/index.js +13 -0
  463. package/react-native/lib/module/index.js.map +1 -0
  464. package/react-native/lib/typescript/ditto.rn.d.ts +15 -0
  465. package/react-native/lib/typescript/ditto.rn.d.ts.map +1 -0
  466. package/react-native/lib/typescript/index.d.ts +1 -0
  467. package/react-native/lib/typescript/index.d.ts.map +1 -0
  468. package/react-native/scripts/ruby/include_local_boost.rb +78 -0
  469. package/react-native/src/ditto.rn.ts +91 -0
  470. package/react-native/src/environment/environment.fallback.ts +4 -0
  471. package/react-native/src/index.ts +26 -0
  472. package/react-native/src/sources/@cbor-redux.ts +2 -0
  473. package/react-native/src/sources/@ditto.core.ts +1 -0
  474. package/react-native/src/sources/@environment.ts +2 -0
  475. package/react-native/src/sources/attachment-fetch-event.ts +54 -0
  476. package/react-native/src/sources/attachment-fetcher-manager.ts +129 -0
  477. package/react-native/src/sources/attachment-fetcher.ts +124 -0
  478. package/react-native/src/sources/attachment-token.ts +48 -0
  479. package/react-native/src/sources/attachment.ts +59 -0
  480. package/react-native/src/sources/augment.ts +89 -0
  481. package/react-native/src/sources/authenticator.ts +314 -0
  482. package/react-native/src/sources/base-pending-cursor-operation.ts +237 -0
  483. package/react-native/src/sources/base-pending-id-specific-operation.ts +109 -0
  484. package/react-native/src/sources/bridge.ts +549 -0
  485. package/react-native/src/sources/build-time-constants.ts +4 -0
  486. package/react-native/src/sources/cbor.ts +35 -0
  487. package/react-native/src/sources/collection-interface.ts +67 -0
  488. package/react-native/src/sources/collection.ts +212 -0
  489. package/react-native/src/sources/collections-event.ts +99 -0
  490. package/react-native/src/sources/counter.ts +77 -0
  491. package/react-native/src/sources/ditto.ts +945 -0
  492. package/react-native/src/sources/document-id.ts +159 -0
  493. package/react-native/src/sources/document-path.ts +303 -0
  494. package/react-native/src/sources/document.ts +192 -0
  495. package/react-native/src/sources/epilogue.ts +24 -0
  496. package/react-native/src/sources/error-codes.ts +52 -0
  497. package/react-native/src/sources/error.ts +203 -0
  498. package/react-native/src/sources/essentials.ts +53 -0
  499. package/react-native/src/sources/ffi-error.ts +117 -0
  500. package/react-native/src/sources/ffi.ts +1972 -0
  501. package/react-native/src/sources/identity.ts +163 -0
  502. package/react-native/src/sources/init.ts +70 -0
  503. package/react-native/src/sources/internal.ts +113 -0
  504. package/react-native/src/sources/keep-alive.ts +69 -0
  505. package/react-native/src/sources/key-path.ts +195 -0
  506. package/react-native/src/sources/live-query-event.ts +208 -0
  507. package/react-native/src/sources/live-query-manager.ts +101 -0
  508. package/react-native/src/sources/live-query.ts +164 -0
  509. package/react-native/src/sources/logger.ts +196 -0
  510. package/react-native/src/sources/observer-manager.ts +175 -0
  511. package/react-native/src/sources/observer.ts +77 -0
  512. package/react-native/src/sources/pending-collections-operation.ts +232 -0
  513. package/react-native/src/sources/pending-cursor-operation.ts +218 -0
  514. package/react-native/src/sources/pending-id-specific-operation.ts +216 -0
  515. package/react-native/src/sources/presence-manager.ts +160 -0
  516. package/react-native/src/sources/presence.ts +238 -0
  517. package/react-native/src/sources/query-result-item.ts +116 -0
  518. package/react-native/src/sources/query-result.ts +55 -0
  519. package/react-native/src/sources/register.ts +92 -0
  520. package/react-native/src/sources/small-peer-info.ts +176 -0
  521. package/react-native/src/sources/static-tcp-client.ts +6 -0
  522. package/react-native/src/sources/store-observer.ts +176 -0
  523. package/react-native/src/sources/store.ts +365 -0
  524. package/react-native/src/sources/subscription-manager.ts +98 -0
  525. package/react-native/src/sources/subscription.ts +88 -0
  526. package/react-native/src/sources/sync-subscription.ts +90 -0
  527. package/react-native/src/sources/sync.ts +495 -0
  528. package/react-native/src/sources/test-helpers.ts +24 -0
  529. package/react-native/src/sources/transport-conditions-manager.ts +104 -0
  530. package/react-native/src/sources/transport-config.ts +428 -0
  531. package/react-native/src/sources/update-result.ts +66 -0
  532. package/react-native/src/sources/update-results-map.ts +57 -0
  533. package/react-native/src/sources/websocket-client.ts +6 -0
  534. package/react-native/src/sources/write-transaction-collection.ts +122 -0
  535. package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +101 -0
  536. package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +72 -0
  537. package/react-native/src/sources/write-transaction.ts +119 -0
  538. package/react-native.config.js +9 -0
  539. package/types/ditto.d.ts +1228 -798
  540. package/web/ditto.es6.js +1 -1
  541. package/web/ditto.umd.js +1 -1
  542. package/web/ditto.wasm +0 -0
@@ -0,0 +1,1972 @@
1
+ //
2
+ // Copyright © 2023 DittoLive Incorporated. All rights reserved.
3
+ //
4
+
5
+ import * as dittoCore from './@ditto.core'
6
+ import * as Environment from './@environment'
7
+ import { throwOnErrorResult } from './ffi-error'
8
+
9
+ // -------------------------------------------------------------- Prelude ------
10
+
11
+ /** @internal */
12
+ export type Pointer<Type> = { type: Type; addr: string }
13
+
14
+ /** @internal */
15
+ export var isTracingEnabled = false
16
+
17
+ /** @internal */
18
+ export const DittoCRDTTypeKey = '_ditto_internal_type_jkb12973t4b'
19
+
20
+ /** @internal */
21
+ export const DittoCRDTValueKey = '_value'
22
+
23
+ // ---------------------------------------------------------------- Types ------
24
+
25
+ /** @internal */
26
+ export type FFIError = 'dittoffi_error_t'
27
+
28
+ /** @internal */
29
+ export type FFIWriteStrategy = 'merge' | 'insertIfAbsent' | 'insertDefaultIfAbsent'
30
+
31
+ /** @internal */
32
+ export type FFIDocument = 'CDocument_t'
33
+
34
+ /** @internal */
35
+ export type FFIDqlResult = 'CDqlResult_t'
36
+
37
+ /** @internal */
38
+ export type FFIDqlResponse = 'CDqlResponse_t'
39
+
40
+ /** @internal */
41
+ export type FFIReadTransaction = 'CReadTransaction_t'
42
+
43
+ /** @internal */
44
+ export type FFIWriteTransaction = 'CWriteTransaction_t'
45
+
46
+ /** @internal */
47
+ export type FFIUninitializedDitto = 'CUninitializedDitto_t'
48
+
49
+ /** @internal */
50
+ export type FFIDitto = 'CDitto_t'
51
+
52
+ /** @internal */
53
+ export type FFIIdentityConfig = 'CIdentityConfig_t'
54
+
55
+ /** @internal */
56
+ export type FFILoginProvider = 'CLoginProvider_t'
57
+
58
+ /** @internal */
59
+ export type FFIAuthServerAuthRequest = 'CAuthServerAuthRequest_t'
60
+
61
+ /** @internal */
62
+ export type FFIAuthServerRefreshRequest = 'CAuthServerRefreshRequest_t'
63
+
64
+ /** @internal */
65
+ export type FFIStaticTCPClient = 'TransportHandle_StaticTCPClientPlatformEvent_t'
66
+
67
+ /** @internal */
68
+ export type FFIWebsocketClient = 'TransportHandle_WebsocketClientPlatformEvent_t'
69
+
70
+ /** @internal */
71
+ export type FFISmallPeerInfoSyncScope = 'LocalPeerOnly' | 'BigPeerOnly'
72
+
73
+ /** @internal */
74
+ export type LiveQueryAvailability = 'Always' | 'WhenSignalled'
75
+
76
+ /** @internal */
77
+ export type StringPrimitiveFormat = 'WithQuotes' | 'WithoutQuotes'
78
+
79
+ /** @internal */
80
+ export type LogLevel = 'Error' | 'Warning' | 'Info' | 'Debug' | 'Verbose'
81
+
82
+ /** @internal */
83
+ export type LicenseVerificationResult = 'LicenseOk' | 'VerificationFailed' | 'LicenseExpired' | 'UnsupportedFutureVersion'
84
+
85
+ /** @internal */
86
+ export type WebsocketMode = 'Enabled' | 'Disabled'
87
+
88
+ /** @internal */
89
+ export type HistoryTracking = 'Enabled' | 'Disabled'
90
+
91
+ /** @internal */
92
+ export type ConditionSource = 'Bluetooth' | 'Tcp' | 'Awdl' | 'Mdns'
93
+
94
+ /** @internal */
95
+ export type TransportCondition = 'Unknown' | 'Ok' | 'GenericFailure' | 'AppInBackground' | 'MdnsFailure' | 'TcpListenFailure' | 'NoBleCentralPermission' | 'NoBlePeripheralPermission' | 'CannotEstablishConnection' | 'BleDisabled' | 'NoBleHardware' | 'WifiDisabled' | 'TemporarilyUnavailable'
96
+
97
+ /** @internal */
98
+ export type TransportsError = 'None' | 'Generic' | 'Unavailable'
99
+
100
+ /** @internal */
101
+ export type TransportBluetooth = 'DittoTransportsBLE_t'
102
+
103
+ /** @internal */
104
+ export type TransportAWDL = 'DittoTransportsAWDL_t'
105
+
106
+ /** @internal */
107
+ export type TransportLAN = 'DittoTransportsLAN_t'
108
+
109
+ /** @internal */
110
+ export type TransportMdnsClient = 'DittoTransportsMdnsClient_t'
111
+
112
+ /** @internal */
113
+ export type TransportMdnsServer = 'DittoTransportsMdnsServer_t'
114
+
115
+ /** @internal */
116
+ export type Platform = 'Windows' | 'Mac' | 'Ios' | 'Android' | 'Linux' | 'Web' | 'Unknown'
117
+
118
+ /** @internal */
119
+ export type Language = 'Swift' | 'ObjectiveC' | 'CPlusPlus' | 'CSharp' | 'JavaScript' | 'Unknown' | 'Rust'
120
+
121
+ /** @internal */
122
+ export type OrderBy = { query: string; direction: 'Ascending' | 'Descending' }
123
+
124
+ /** @internal */
125
+ export type PathAccessorType = 'String' | 'Number' | 'Int' | 'UInt' | 'Float' | 'Double' | 'Bool' | 'Null' | 'Object' | 'Array' | 'Any' | 'Counter' | 'Register' | 'Attachment' | 'Rga' | 'RWMap'
126
+
127
+ /** @internal */
128
+ export enum DittoCRDTType {
129
+ counter = 0,
130
+ register = 1,
131
+ attachment = 2,
132
+ rga = 3,
133
+ rwMap = 4,
134
+ }
135
+
136
+ /** @internal */
137
+ export type CBParamsDocs = {
138
+ documents: Pointer<FFIDocument>[]
139
+ is_initial: boolean
140
+ old_documents: Pointer<FFIDocument>[]
141
+ insertions: number[]
142
+ deletions: number[]
143
+ updates: number[]
144
+ moves: [number, number][]
145
+ }
146
+
147
+ /** @internal */
148
+ export type CBParamsQueryResult = {
149
+ query_result: Pointer<FFIDqlResponse>
150
+ }
151
+
152
+ /** @internal */
153
+ export type CBORPathResult = {
154
+ statusCode: number
155
+ cbor: Uint8Array
156
+ }
157
+
158
+ /** Various options to pass the web assembly module to Ditto. */
159
+ export type WebAssemblyModule = RequestInfo | URL | Response | BufferSource | WebAssembly.Module | string | null
160
+
161
+ /** @internal */
162
+ export type AttachmentFileOperation = 'Copy' | 'Move'
163
+
164
+ /** @internal */
165
+ export type AttachmentHandle = 'AttachmentHandle_t'
166
+
167
+ /** @internal */
168
+ export type RawAttachment = {
169
+ id: Uint8Array
170
+ len: number | BigInt
171
+ handle: Pointer<AttachmentHandle>
172
+ }
173
+
174
+ // -------------------------------------- Linux & Windows Transports Hack ------
175
+
176
+ export function dittoAddInternalBLEClientTransport(ditto: Pointer<FFIDitto>): any {
177
+ if (Environment.isNodeBuild) {
178
+ return dittoCore.ditto_add_internal_ble_client_transport(ditto)
179
+ }
180
+
181
+ if (Environment.isWebBuild) {
182
+ throw new Error(`Internal inconsistency, can't add internal BLE client, only available for non-apple Ditto Node builds.`)
183
+ }
184
+ }
185
+
186
+ export function dittoAddInternalBLEServerTransport(ditto: Pointer<FFIDitto>): any {
187
+ if (Environment.isNodeBuild) {
188
+ return dittoCore.ditto_add_internal_ble_server_transport(ditto)
189
+ }
190
+
191
+ if (Environment.isWebBuild) {
192
+ throw new Error(`Internal inconsistency, can't add internal BLE server, only available for non-apple Ditto Node builds.`)
193
+ }
194
+ }
195
+
196
+ export function bleClientFreeHandle(handle: any) {
197
+ if (Environment.isNodeBuild) {
198
+ return dittoCore.ble_client_free_handle(handle)
199
+ }
200
+
201
+ if (Environment.isWebBuild) {
202
+ throw new Error(`Internal inconsistency, can't free BLE client handle, only available for non-apple Ditto Node builds.`)
203
+ }
204
+ }
205
+
206
+ export function bleServerFreeHandle(handle: any) {
207
+ if (Environment.isNodeBuild) {
208
+ return dittoCore.ble_server_free_handle(handle)
209
+ }
210
+
211
+ if (Environment.isWebBuild) {
212
+ throw new Error(`Internal inconsistency, can't free BLE server handle, only available for non-apple Ditto Node builds.`)
213
+ }
214
+ }
215
+
216
+ export function dittoAddInternalMdnsTransport(ditto: Pointer<FFIDitto>): any {
217
+ if (Environment.isNodeBuild) {
218
+ return dittoCore.ditto_add_internal_mdns_client_transport(ditto)
219
+ }
220
+
221
+ if (Environment.isWebBuild) {
222
+ throw new Error(`Internal inconsistency, can't add internal MDNS transport/client, only available for non-apple Ditto Node builds.`)
223
+ }
224
+ }
225
+
226
+ export function mdnsClientFreeHandle(handle: any) {
227
+ if (Environment.isNodeBuild) {
228
+ return dittoCore.mdns_client_free_handle(handle)
229
+ }
230
+
231
+ if (Environment.isWebBuild) {
232
+ throw new Error(`Internal inconsistency, can't free MDNS transport/client handle, only available for non-apple Ditto Node builds.`)
233
+ }
234
+ }
235
+
236
+ export function dittoAddInternalMdnsAdvertiser(ditto: Pointer<FFIDitto>): any {
237
+ if (Environment.isNodeBuild) {
238
+ return dittoCore.ditto_add_internal_mdns_server_transport(ditto)
239
+ }
240
+
241
+ if (Environment.isWebBuild) {
242
+ throw new Error(`Internal inconsistency, can't add internal MDNS advertiser/server, only available for non-apple Ditto Node builds.`)
243
+ }
244
+ }
245
+
246
+ export function mdnsServerFreeHandle(handle: any) {
247
+ if (Environment.isNodeBuild) {
248
+ return dittoCore.mdns_server_free_handle(handle)
249
+ }
250
+
251
+ if (Environment.isWebBuild) {
252
+ throw new Error(`Internal inconsistency, can't free MDNS advertiser/server handle, only available for non-apple Ditto Node builds.`)
253
+ }
254
+ }
255
+
256
+ // ------------------------------------------------------------- Document ------
257
+
258
+ /** @internal */
259
+ export function documentSetCBORWithTimestamp(document: Pointer<FFIDocument>, path: string, cbor: Uint8Array, timestamp: number) {
260
+ trace()
261
+ ensureInitialized()
262
+
263
+ const pathX = bytesFromString(path)
264
+ const errorCode = dittoCore.ditto_document_set_cbor_with_timestamp(document, pathX, cbor, timestamp)
265
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_document_set_cbor_with_timestamp() failed with error code: ${errorCode}`)
266
+ }
267
+
268
+ /** @internal */
269
+ export function documentSetCBOR(document: Pointer<FFIDocument>, path: string, cbor: Uint8Array) {
270
+ trace()
271
+ ensureInitialized()
272
+
273
+ const pathX = bytesFromString(path)
274
+ const errorCode = dittoCore.ditto_document_set_cbor(document, pathX, cbor)
275
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_document_set_cbor() failed with error code: ${errorCode}`)
276
+ }
277
+
278
+ /** @internal */
279
+ export function documentID(self: Pointer<FFIDocument>): Uint8Array {
280
+ trace()
281
+ ensureInitialized()
282
+
283
+ const documentIDX = dittoCore.ditto_document_id(self)
284
+ return dittoCore.boxCBytesIntoBuffer(documentIDX)
285
+ }
286
+
287
+ /** @internal */
288
+ export function documentCBOR(self: Pointer<FFIDocument>): Uint8Array {
289
+ trace()
290
+ ensureInitialized()
291
+
292
+ const cborBytes = dittoCore.ditto_document_cbor(self)
293
+ return dittoCore.boxCBytesIntoBuffer(cborBytes)
294
+ }
295
+
296
+ /** @internal */
297
+ export function documentGetCBORWithPathType(document: Pointer<FFIDocument>, path: string, pathType: PathAccessorType): CBORPathResult {
298
+ trace()
299
+ ensureInitialized()
300
+
301
+ const pathBytes = bytesFromString(path)
302
+ const cborPathResultRaw = dittoCore.ditto_document_get_cbor_with_path_type(document, pathBytes, pathType)
303
+
304
+ const cborPathResult: CBORPathResult = {
305
+ statusCode: cborPathResultRaw.status_code,
306
+ cbor: dittoCore.boxCBytesIntoBuffer(cborPathResultRaw.cbor),
307
+ }
308
+
309
+ return cborPathResult
310
+ }
311
+
312
+ /** @internal */
313
+ export function documentRemove(document: Pointer<FFIDocument>, path: string) {
314
+ trace()
315
+ ensureInitialized()
316
+
317
+ const pathBytes = bytesFromString(path)
318
+ const errorCode = dittoCore.ditto_document_remove(document, pathBytes)
319
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_document_remove() failed with error code: ${errorCode}`)
320
+ }
321
+
322
+ /** @internal */
323
+ export function documentIncrementCounter(document: Pointer<FFIDocument>, path: string, amount: number) {
324
+ trace()
325
+ ensureInitialized()
326
+
327
+ const pathBytes = bytesFromString(path)
328
+ const errorCode = dittoCore.ditto_document_increment_counter(document, pathBytes, amount)
329
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_document_increment_counter() failed with error code: ${errorCode}`)
330
+ }
331
+
332
+ /** @internal */
333
+ export function documentFree(self: Pointer<FFIDocument>) {
334
+ trace()
335
+ ensureInitialized()
336
+
337
+ dittoCore.ditto_document_free(self)
338
+ }
339
+
340
+ // ----------------------------------------------------------- DocumentID ------
341
+
342
+ /** @internal */
343
+ export function documentIDQueryCompatible(docID: Uint8Array, stringPrimitiveFormat: StringPrimitiveFormat): string {
344
+ trace()
345
+ ensureInitialized()
346
+
347
+ const docIDString = dittoCore.ditto_document_id_query_compatible(docID, stringPrimitiveFormat)
348
+ return dittoCore.boxCStringIntoString(docIDString)
349
+ }
350
+
351
+ /** @internal */
352
+ export function validateDocumentID(docID: Uint8Array): Uint8Array {
353
+ trace()
354
+ ensureInitialized()
355
+
356
+ const cborCBytes = dittoCore.withOutBoxCBytes((outCBOR) => {
357
+ const errorCode = dittoCore.ditto_validate_document_id(docID, outCBOR)
358
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_validate_document_id() failed with error code: ${errorCode}`)
359
+ return outCBOR
360
+ })
361
+
362
+ return dittoCore.boxCBytesIntoBuffer(cborCBytes)
363
+ }
364
+
365
+ // ----------------------------------------------------------- Collection ------
366
+
367
+ /** @internal */
368
+ export async function collectionGet(ditto: Pointer<FFIDitto>, collectionName: string, documentID: Uint8Array, readTransaction: Pointer<FFIReadTransaction>): Promise<Pointer<FFIDocument> | null> {
369
+ trace()
370
+ ensureInitialized()
371
+
372
+ const collectionNameX = bytesFromString(collectionName)
373
+
374
+ const { status_code: errorCode, document } = await dittoCore.ditto_collection_get(ditto, collectionNameX, documentID, readTransaction)
375
+ if (errorCode === NOT_FOUND_ERROR_CODE) return null
376
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_get() failed with error code: ${errorCode}`)
377
+ return document
378
+ }
379
+
380
+ /** @internal */
381
+ export async function collectionInsertValue(ditto: Pointer<FFIDitto>, collectionName: string, doc_cbor: Uint8Array, writeStrategy: FFIWriteStrategy, writeTransaction?: Pointer<FFIWriteTransaction>): Promise<Uint8Array> {
382
+ trace()
383
+ ensureInitialized()
384
+
385
+ const collectionNameX = bytesFromString(collectionName)
386
+
387
+ let strategy
388
+ switch (writeStrategy) {
389
+ case 'merge':
390
+ strategy = 'Merge'
391
+ break
392
+ case 'insertIfAbsent':
393
+ strategy = 'InsertIfAbsent'
394
+ break
395
+ case 'insertDefaultIfAbsent':
396
+ strategy = 'InsertDefaultIfAbsent'
397
+ break
398
+ default:
399
+ throw new Error('Invalid write strategy provided')
400
+ }
401
+
402
+ const { status_code: errorCode, id } = await dittoCore.ditto_collection_insert_value(ditto, collectionNameX, doc_cbor, strategy, null, writeTransaction ?? null)
403
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_insert_value() failed with error code: ${errorCode}`)
404
+ return dittoCore.boxCBytesIntoBuffer(id)
405
+ }
406
+
407
+ /** @internal */
408
+ export async function collectionRemove(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, documentID: Uint8Array): Promise<boolean> {
409
+ trace()
410
+ ensureInitialized()
411
+
412
+ const collectionNameX = bytesFromString(collectionName)
413
+
414
+ const { status_code: errorCode, bool_value: didRemove } = await dittoCore.ditto_collection_remove(ditto, collectionNameX, writeTransaction, documentID)
415
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_remove() failed with error code: ${errorCode}`)
416
+ return didRemove
417
+ }
418
+
419
+ /** @internal */
420
+ export async function collectionEvict(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, documentID: Uint8Array): Promise<boolean> {
421
+ trace()
422
+ ensureInitialized()
423
+
424
+ const collectionNameX = bytesFromString(collectionName)
425
+
426
+ const { status_code: errorCode, bool_value: didEvict } = await dittoCore.ditto_collection_evict(ditto, collectionNameX, writeTransaction, documentID)
427
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_evict() failed with error code: ${errorCode}`)
428
+ return didEvict
429
+ }
430
+
431
+ /** @internal */
432
+ export async function collectionUpdate(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, document: Pointer<FFIDocument>): Promise<void> {
433
+ trace()
434
+ ensureInitialized()
435
+
436
+ const collectionNameX = bytesFromString(collectionName)
437
+ const errorCode = await dittoCore.ditto_collection_update(ditto, collectionNameX, writeTransaction, document)
438
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_update() failed with error code: ${errorCode}`)
439
+ }
440
+
441
+ /** @internal */
442
+ export async function collectionUpdateMultiple(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, documents: Pointer<FFIDocument>[]): Promise<void> {
443
+ trace()
444
+ ensureInitialized()
445
+
446
+ const collectionNameX = bytesFromString(collectionName)
447
+ const cDocuments = dittoCore.jsDocsToCDocs(documents)
448
+ const errorCode = await dittoCore.ditto_collection_update_multiple(ditto, collectionNameX, writeTransaction, cDocuments)
449
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_collection_update_multiple() failed with error code: ${errorCode}`)
450
+ }
451
+
452
+ /** @internal */
453
+ export async function collectionExecQueryStr(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number): Promise<Pointer<FFIDocument>[]> {
454
+ trace()
455
+ ensureInitialized()
456
+
457
+ const collectionNameX = bytesFromString(collectionName)
458
+ const queryX = bytesFromString(query)
459
+ return await dittoCore.ditto_collection_exec_query_str(ditto, collectionNameX, writeTransaction, queryX, queryArgsCBOR, orderBy, limit, offset)
460
+ }
461
+
462
+ /** @internal */
463
+ export async function collectionRemoveQueryStr(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number): Promise<Uint8Array[]> {
464
+ trace()
465
+ ensureInitialized()
466
+
467
+ const collectionNameX = bytesFromString(collectionName)
468
+ const queryX = bytesFromString(query)
469
+ return await dittoCore.ditto_collection_remove_query_str(ditto, collectionNameX, writeTransaction, queryX, queryArgsCBOR, orderBy, limit, offset)
470
+ }
471
+
472
+ /** @internal */
473
+ export async function collectionEvictQueryStr(ditto: Pointer<FFIDitto>, collectionName: string, writeTransaction: Pointer<FFIWriteTransaction>, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number): Promise<Uint8Array[]> {
474
+ trace()
475
+ ensureInitialized()
476
+
477
+ const collectionNameX = bytesFromString(collectionName)
478
+ const queryX = bytesFromString(query)
479
+ return await dittoCore.ditto_collection_evict_query_str(ditto, collectionNameX, writeTransaction, queryX, queryArgsCBOR, orderBy, limit, offset)
480
+ }
481
+
482
+ /**
483
+ * This FFI can error:
484
+ * - DQL parser error
485
+ * - Incorrect arguments to query parameters
486
+ * - Collection is not found.
487
+ *
488
+ * @internal
489
+ */
490
+ export async function tryExperimentalExecQueryStr(ditto: Pointer<FFIDitto>, writeTransaction: Pointer<FFIWriteTransaction> | null, query: string, queryArgsCBOR: Uint8Array | null): Promise<Pointer<FFIDqlResponse>> {
491
+ trace()
492
+ ensureInitialized()
493
+
494
+ const queryBytesPointer = bytesFromString(query)
495
+ const result = await dittoCore.dittoffi_try_experimental_exec_statement_str(ditto, writeTransaction, queryBytesPointer, queryArgsCBOR)
496
+ throwOnErrorResult(result.error, 'dittoffi_try_experimental_exec_statement_str')
497
+ return result.success
498
+ }
499
+
500
+ /** @internal */
501
+ export function addSubscription(ditto: Pointer<FFIDitto>, collectionName: string, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number) {
502
+ trace()
503
+ ensureInitialized()
504
+
505
+ const collectionNameX = bytesFromString(collectionName)
506
+ const queryX = bytesFromString(query)
507
+ return dittoCore.ditto_add_subscription(ditto, collectionNameX, queryX, queryArgsCBOR, orderBy, limit, offset)
508
+ }
509
+
510
+ /** @internal */
511
+ export function removeSubscription(ditto: Pointer<FFIDitto>, collectionName: string, query: string, queryArgsCBOR: Uint8Array | null, orderBy: OrderBy[], limit: number, offset: number) {
512
+ trace()
513
+ ensureInitialized()
514
+
515
+ const collectionNameX = bytesFromString(collectionName)
516
+ const queryX = bytesFromString(query)
517
+ return dittoCore.ditto_remove_subscription(ditto, collectionNameX, queryX, queryArgsCBOR, orderBy, limit, offset)
518
+ }
519
+
520
+ /** @internal */
521
+ export function tryExperimentalAddDQLSubscription(dittoPointer: Pointer<FFIDitto>, query: string, queryArgsCBOR: Uint8Array | null): void {
522
+ trace()
523
+ ensureInitialized()
524
+
525
+ const queryBuffer = bytesFromString(query)
526
+ const result = dittoCore.dittoffi_try_experimental_add_dql_subscription(dittoPointer, queryBuffer, queryArgsCBOR)
527
+ throwOnErrorResult(result.error, 'dittoffi_try_experimental_add_dql_subscription')
528
+ return
529
+ }
530
+
531
+ /** @internal */
532
+ export function tryExperimentalRemoveDQLSubscription(dittoPointer: Pointer<FFIDitto>, query: string, queryArgsCBOR: Uint8Array | null): void {
533
+ trace()
534
+ ensureInitialized()
535
+
536
+ const queryBuffer = bytesFromString(query)
537
+ const result = dittoCore.dittoffi_try_experimental_remove_dql_subscription(dittoPointer, queryBuffer, queryArgsCBOR)
538
+ throwOnErrorResult(result.error, 'dittoffi_try_experimental_remove_dql_subscription')
539
+ return
540
+ }
541
+
542
+ // ----------------------------------------------------------- DqlResponse ------
543
+
544
+ /**
545
+ * Doesn't error
546
+ *
547
+ * @internal
548
+ */
549
+ export function dqlResponseFree(responsePointer: Pointer<FFIDqlResponse>) {
550
+ trace()
551
+ ensureInitialized()
552
+
553
+ dittoCore.ditto_dql_response_free(responsePointer)
554
+ }
555
+
556
+ /**
557
+ * Doesn't error
558
+ *
559
+ * @internal
560
+ */
561
+ export function dqlResultFree(resultPointer: Pointer<FFIDqlResult>) {
562
+ trace()
563
+ ensureInitialized()
564
+
565
+ dittoCore.ditto_dql_result_free(resultPointer)
566
+ }
567
+
568
+ /**
569
+ * Can error only on internal bug.
570
+ *
571
+ * @internal */
572
+ export function dqlResponseResults(responsePointer: Pointer<FFIDqlResponse>): Pointer<FFIDqlResult>[] {
573
+ trace()
574
+ ensureInitialized()
575
+
576
+ const rv = []
577
+ const resultCount = dittoCore.ditto_dql_response_result_count(responsePointer)
578
+ for (let i = 0; i < resultCount; i++) {
579
+ rv.push(dittoCore.ditto_dql_response_result_at(responsePointer, i))
580
+ }
581
+ return rv
582
+ }
583
+
584
+ /**
585
+ * Doesn't error
586
+ *
587
+ * @internal
588
+ */
589
+ export function dqlMutatedDocumentIDs(responsePointer: Pointer<FFIDqlResponse>): Uint8Array[] {
590
+ trace()
591
+ ensureInitialized()
592
+
593
+ const rv = []
594
+ const resultCount = dittoCore.ditto_dql_response_affected_document_id_count(responsePointer)
595
+ for (let i = 0; i < resultCount; i++) {
596
+ const cborBytes = dittoCore.ditto_dql_response_affected_document_id_at(responsePointer, i)
597
+ rv.push(dittoCore.boxCBytesIntoBuffer(cborBytes))
598
+ }
599
+ return rv
600
+ }
601
+
602
+ /**
603
+ * The result CBOR contains a map/object with fields and values.
604
+ * No CRDTs are present there as they are not needed. Currently
605
+ * only values from registers are returned and non-register fields are
606
+ * ignored. Reading values from other CRDTs will be supported with
607
+ * definition support.
608
+ *
609
+ * Doesn't error
610
+ *
611
+ * @internal
612
+ */
613
+ export function dqlResultCBOR(resultPointer: Pointer<FFIDqlResult>): Uint8Array {
614
+ trace()
615
+ ensureInitialized()
616
+
617
+ const cborBytes = dittoCore.ditto_result_cbor(resultPointer)
618
+ return dittoCore.boxCBytesIntoBuffer(cborBytes)
619
+ }
620
+
621
+ /**
622
+ * Returns JSON-encoded results given a DQL result pointer.
623
+ *
624
+ * Compare for {@link dqlResultCBOR} above.
625
+ *
626
+ * Doesn't error
627
+ *
628
+ * @internal
629
+ */
630
+ export function dqlResultJSON(resultPointer: Pointer<FFIDqlResult>): string {
631
+ trace()
632
+ ensureInitialized()
633
+
634
+ const jsonBytes = dittoCore.ditto_result_json(resultPointer)
635
+ return dittoCore.boxCStringIntoString(jsonBytes)
636
+ }
637
+
638
+ // ------------------------------------------------------------ LiveQuery ------
639
+
640
+ /** @internal */
641
+ export function liveQueryRegister(
642
+ ditto: Pointer<FFIDitto>,
643
+ collectionName: string,
644
+ query: string,
645
+ queryArgsCBOR: Uint8Array | null,
646
+ orderBy: OrderBy[],
647
+ limit: number,
648
+ offset: number,
649
+ eventHandler: (cbParams: CBParamsDocs) => any,
650
+ onError?: (error: any) => void,
651
+ ): number {
652
+ trace()
653
+ ensureInitialized()
654
+
655
+ const collectionNameBuffer = bytesFromString(collectionName)
656
+ const queryBuffer = bytesFromString(query)
657
+ const { status_code: errorCode, i64: id } = dittoCore.ditto_live_query_register_str_detached(ditto, collectionNameBuffer, queryBuffer, queryArgsCBOR, orderBy, limit, offset, wrapBackgroundCbForFFI(onError, eventHandler))
658
+ if (errorCode !== 0) throw new Error(errorMessage() || `\`ditto_live_query_register_str()\` failed with error code: ${errorCode}`)
659
+ return id
660
+ }
661
+
662
+ /** @internal */
663
+ export function tryExperimentalRegisterChangeObserver(ditto: Pointer<FFIDitto>, query: string, queryArgsCBOR: Uint8Array | null, changeHandler: (cbParams: CBParamsQueryResult) => any): number {
664
+ trace()
665
+ ensureInitialized()
666
+
667
+ const errorHandler = (err: any) => log('Error', `The registered store observer callback failed with ${err}`)
668
+ const wrappedCallback = wrapBackgroundCbForFFI(errorHandler, changeHandler)
669
+ const queryBuffer = bytesFromString(query)
670
+ const result = dittoCore.dittoffi_try_experimental_register_change_observer_str_detached(ditto, queryBuffer, queryArgsCBOR, wrappedCallback)
671
+ throwOnErrorResult(result.error, 'dittoffi_try_experimental_register_change_observer_str_detached')
672
+ return result.success
673
+ }
674
+
675
+ /** @internal */
676
+ export async function liveQueryStart(ditto: Pointer<FFIDitto>, liveQueryID: number): Promise<void> {
677
+ trace()
678
+ ensureInitialized()
679
+
680
+ const errorCode = await dittoCore.ditto_live_query_start(ditto, liveQueryID)
681
+ if (errorCode !== 0) throw new Error(errorMessage() || `\`ditto_live_query_start()\` failed with error code: ${errorCode}`)
682
+ }
683
+
684
+ /** @internal */
685
+ export function liveQueryStop(ditto: Pointer<FFIDitto>, liveQueryID: number) {
686
+ trace()
687
+ ensureInitialized()
688
+
689
+ dittoCore.ditto_live_query_stop(ditto, liveQueryID)
690
+ }
691
+
692
+ /** @internal */
693
+ export async function liveQuerySignalAvailableNext(ditto: Pointer<FFIDitto>, liveQueryID: number): Promise<void> {
694
+ trace()
695
+ ensureInitialized()
696
+
697
+ await dittoCore.ditto_live_query_signal_available_next(ditto, liveQueryID)
698
+ }
699
+
700
+ // ------------------------------------------------------------ Webhook ------
701
+
702
+ /** @internal */
703
+ export async function liveQueryWebhookRegister(ditto: Pointer<FFIDitto>, collectionName: string, query: string, orderBy: OrderBy[], limit: number, offset: number, url: string): Promise<Uint8Array> {
704
+ trace()
705
+ ensureInitialized()
706
+ const collectionNameBuffer = bytesFromString(collectionName)
707
+ const queryBuffer = bytesFromString(query)
708
+ const urlBuffer = bytesFromString(url)
709
+
710
+ const { status_code: errorCode, id } = await dittoCore.ditto_live_query_webhook_register_str(ditto, collectionNameBuffer, queryBuffer, orderBy, limit, offset, urlBuffer)
711
+ if (errorCode !== 0) throw new Error(errorMessage() || `\`ditto_live_query_webhook_register_str()\` failed with error code: ${errorCode}`)
712
+
713
+ return dittoCore.boxCBytesIntoBuffer(id)
714
+ }
715
+
716
+ /** @internal */
717
+ export async function tryExperimentalWebhookRegisterDqlLiveQuery(ditto: Pointer<FFIDitto>, query: string, queryArgsCBOR: Uint8Array | null, url: string): Promise<Uint8Array> {
718
+ trace()
719
+ ensureInitialized()
720
+
721
+ const queryBuffer = bytesFromString(query)
722
+ const urlBuffer = bytesFromString(url)
723
+
724
+ const result = await dittoCore.dittoffi_try_experimental_webhook_register_dql_live_query_str(ditto, queryBuffer, queryArgsCBOR, urlBuffer)
725
+ throwOnErrorResult(result.error, 'dittoffi_try_experimental_webhook_register_dql_live_query_str')
726
+ const documentIdCBOR = result.success
727
+
728
+ return dittoCore.boxCBytesIntoBuffer(documentIdCBOR)
729
+ }
730
+
731
+ // ------------------------------------------------------ ReadTransaction ------
732
+
733
+ /** @internal */
734
+ export async function readTransaction(ditto: Pointer<FFIDitto>): Promise<Pointer<FFIReadTransaction>> {
735
+ trace()
736
+ ensureInitialized()
737
+
738
+
739
+ const { status_code: errorCode, txn: readTransaction } = await dittoCore.ditto_read_transaction(ditto)
740
+ if (errorCode !== 0) throw new Error(errorMessage() || `\`ditto_read_transaction()\` failed with error code: ${errorCode}`)
741
+ return readTransaction
742
+ }
743
+
744
+ /** @internal */
745
+ export function readTransactionFree(self: Pointer<FFIReadTransaction>) {
746
+ trace()
747
+ ensureInitialized()
748
+
749
+ return dittoCore.ditto_read_transaction_free(self)
750
+ }
751
+
752
+ // ----------------------------------------------------- WriteTransaction ------
753
+
754
+ /** @internal */
755
+ export async function writeTransaction(ditto: Pointer<FFIDitto>): Promise<Pointer<FFIWriteTransaction>> {
756
+ trace()
757
+ ensureInitialized()
758
+
759
+
760
+ const { status_code: errorCode, txn: writeTransaction } = await dittoCore.ditto_write_transaction(ditto, null)
761
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_write_transaction() failed with error code: ${errorCode}`)
762
+ return writeTransaction
763
+ }
764
+
765
+ /** @internal */
766
+ export async function writeTransactionCommit(ditto: Pointer<FFIDitto>, self: Pointer<FFIWriteTransaction>): Promise<void> {
767
+ trace()
768
+ ensureInitialized()
769
+
770
+ const errorCode = await dittoCore.ditto_write_transaction_commit(ditto, self)
771
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_write_transaction_commit() failed with error code: ${errorCode}`)
772
+ }
773
+
774
+ /** @internal */
775
+ export async function writeTransactionRollback(ditto: Pointer<FFIDitto>, transaction: Pointer<FFIWriteTransaction>): Promise<void> {
776
+ trace()
777
+ ensureInitialized()
778
+
779
+ const errorCode = await dittoCore.ditto_write_transaction_rollback(ditto, transaction)
780
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_write_transaction_rollback() failed with error code: ${errorCode}`)
781
+ }
782
+
783
+ // ------------------------------------------------------ StaticTCPClient ------
784
+
785
+ /** @internal */
786
+ export function addStaticTCPClient(ditto: Pointer<FFIDitto>, address: string): Pointer<FFIStaticTCPClient> {
787
+ trace()
788
+ ensureInitialized()
789
+
790
+ const addressBuffer = bytesFromString(address)
791
+ return dittoCore.ditto_add_static_tcp_client(ditto, addressBuffer)
792
+ }
793
+
794
+ /** @internal */
795
+ export function staticTCPClientFreeHandle(self: Pointer<FFIStaticTCPClient>) {
796
+ trace()
797
+ dittoCore.static_tcp_client_free_handle(self)
798
+ }
799
+
800
+ // ------------------------------------------------------ WebsocketClient ------
801
+
802
+ /** @internal */
803
+ export function addWebsocketClient(ditto: Pointer<FFIDitto>, address: string, routingHint: number): Pointer<FFIWebsocketClient> {
804
+ trace()
805
+ ensureInitialized()
806
+
807
+ const addressBuffer = bytesFromString(address)
808
+ return dittoCore.ditto_add_websocket_client(ditto, addressBuffer, routingHint)
809
+ }
810
+
811
+ /** @internal */
812
+ export function websocketClientFreeHandle(self: Pointer<FFIWebsocketClient>) {
813
+ trace()
814
+ ensureInitialized()
815
+ dittoCore.websocket_client_free_handle(self)
816
+ }
817
+
818
+ // --------------------------------------------------------------- Logger ------
819
+
820
+ /** @internal */
821
+ export function loggerInit() {
822
+ trace()
823
+ ensureInitialized()
824
+ dittoCore.ditto_logger_init()
825
+ }
826
+
827
+ /** @internal */
828
+ export async function loggerSetCustomLogCb(cb: null | ((lvl: LogLevel, msg: string) => void)): Promise<void> {
829
+ trace()
830
+ ensureInitialized()
831
+
832
+ if (null === cb) {
833
+ await dittoCore.ditto_logger_set_custom_log_cb(null)
834
+ } else {
835
+ const wrappedCallback = wrapBackgroundCbForFFI(null, (loglevel: LogLevel, cMsg: Pointer<'char'>) => {
836
+ try {
837
+ const msg: string = dittoCore.boxCStringIntoString(cMsg)
838
+ cb(loglevel, msg)
839
+ } catch (e) {
840
+ log('Error', `The registered cb in \`ditto_logger_set_custom_log_cb()\` failed with: ${e}`)
841
+ }
842
+ })
843
+ await dittoCore.ditto_logger_set_custom_log_cb(wrappedCallback)
844
+ }
845
+ }
846
+
847
+ /** @internal */
848
+ export function loggerEnabled(enabled: boolean) {
849
+ trace()
850
+ ensureInitialized()
851
+ dittoCore.ditto_logger_enabled(!!enabled)
852
+ }
853
+
854
+ /** @internal */
855
+ export function loggerEnabledGet(): boolean {
856
+ trace()
857
+ ensureInitialized()
858
+ return !!dittoCore.ditto_logger_enabled_get()
859
+ }
860
+
861
+ /** @internal */
862
+ export function loggerEmojiHeadingsEnabled(loggerEmojiHeadingsEnabled: boolean) {
863
+ trace()
864
+ ensureInitialized()
865
+ dittoCore.ditto_logger_emoji_headings_enabled(loggerEmojiHeadingsEnabled)
866
+ }
867
+
868
+ /** @internal */
869
+ export function loggerEmojiHeadingsEnabledGet() {
870
+ trace()
871
+ ensureInitialized()
872
+ return dittoCore.ditto_logger_emoji_headings_enabled_get()
873
+ }
874
+
875
+ /** @internal */
876
+ export function loggerMinimumLogLevel(logLevel: LogLevel) {
877
+ trace()
878
+ ensureInitialized()
879
+ dittoCore.ditto_logger_minimum_log_level(logLevel)
880
+ }
881
+
882
+ /** @internal */
883
+ export function loggerMinimumLogLevelGet() {
884
+ trace()
885
+ ensureInitialized()
886
+ return dittoCore.ditto_logger_minimum_log_level_get()
887
+ }
888
+
889
+ /** @internal */
890
+ export function loggerSetLogFile(path?: string) {
891
+ trace()
892
+ ensureInitialized()
893
+ const pathBytesOrNull = path ? bytesFromString(path) : null
894
+ const errorCode = dittoCore.ditto_logger_set_log_file(pathBytesOrNull)
895
+ if (errorCode !== 0) {
896
+ const message = errorMessage()
897
+ throw new Error(`Can't set log file, due to error: ${errorMessage}`)
898
+ }
899
+ }
900
+
901
+ /** @internal */
902
+ export function log(level: LogLevel, message: string) {
903
+ trace()
904
+ ensureInitialized()
905
+ const messageBuffer = bytesFromString(message)
906
+ dittoCore.ditto_log(level, messageBuffer)
907
+ }
908
+
909
+ // ----------------------------------------------------------- AuthClient ------
910
+
911
+ /** @internal */
912
+ export function dittoIdentityConfigMakeOnlinePlayground(appID: string, sharedToken: string, baseURL: string): Pointer<FFIIdentityConfig> {
913
+ trace()
914
+ ensureInitialized()
915
+
916
+ const appIDX = bytesFromString(appID)
917
+ const sharedTokenX = bytesFromString(sharedToken)
918
+ const baseURLX = bytesFromString(baseURL)
919
+
920
+ const { status_code: errorCode, identity_config: identityConfig } = dittoCore.ditto_identity_config_make_online_playground(appIDX, sharedTokenX, baseURLX)
921
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_identity_config_make_online_playground() failed with error code: ${errorCode}`)
922
+ return identityConfig
923
+ }
924
+
925
+ /** @internal */
926
+ export function dittoIdentityConfigMakeOnlineWithAuthentication(appID: string, baseURL: string): Pointer<FFIIdentityConfig> {
927
+ trace()
928
+ ensureInitialized()
929
+
930
+ const appIDX = bytesFromString(appID)
931
+ const baseURLX = bytesFromString(baseURL)
932
+
933
+ const { status_code: errorCode, identity_config: identityConfig } = dittoCore.ditto_identity_config_make_online_with_authentication(appIDX, baseURLX)
934
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_identity_config_make_online_with_authentication() failed with error code: ${errorCode}`)
935
+ return identityConfig
936
+ }
937
+
938
+ /** @internal */
939
+ export function dittoIdentityConfigMakeOfflinePlayground(appId: string, siteID: number | BigInt): Pointer<FFIIdentityConfig> {
940
+ trace()
941
+ ensureInitialized()
942
+
943
+ const appIdX = bytesFromString(appId)
944
+ const siteIDX = Number(siteID)
945
+ const { status_code: errorCode, identity_config: identityConfig } = dittoCore.ditto_identity_config_make_offline_playground(appIdX, siteIDX)
946
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_identity_config_make_offline_playground() failed with error code: ${errorCode}`)
947
+ return identityConfig
948
+ }
949
+
950
+ /** @internal */
951
+ export function dittoIdentityConfigMakeSharedKey(appId: string, sharedKey: string, siteID: number | BigInt): Pointer<FFIIdentityConfig> {
952
+ trace()
953
+ ensureInitialized()
954
+
955
+ const appIdX = bytesFromString(appId)
956
+ const sharedKeyX = bytesFromString(sharedKey)
957
+ const siteIDX = Number(siteID)
958
+ const { status_code: errorCode, identity_config: identityConfig } = dittoCore.ditto_identity_config_make_shared_key(appIdX, sharedKeyX, siteIDX)
959
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_identity_config_make_shared_key() failed with error code: ${errorCode}`)
960
+ return identityConfig
961
+ }
962
+
963
+ /** @internal */
964
+ export function dittoIdentityConfigMakeManual(configCBORBase64: string): Pointer<FFIIdentityConfig> {
965
+ trace()
966
+ ensureInitialized()
967
+
968
+ const configCBORBase64X = bytesFromString(configCBORBase64)
969
+
970
+ const { status_code: errorCode, identity_config: identityConfig } = dittoCore.ditto_identity_config_make_manual_v0(configCBORBase64X)
971
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_identity_config_make_manual_v0() failed with error code: ${errorCode}`)
972
+ return identityConfig
973
+ }
974
+
975
+ /** @internal */
976
+ export function dittoAuthClientGetSiteID(ditto: Pointer<FFIDitto>): number | BigInt {
977
+ trace()
978
+ ensureInitialized()
979
+ return dittoCore.ditto_auth_client_get_site_id(ditto)
980
+ }
981
+
982
+ /** @internal */
983
+ export function dittoAuthClientGetAppID(ditto: Pointer<FFIDitto>): string {
984
+ trace()
985
+ ensureInitialized()
986
+ const cString = dittoCore.ditto_auth_client_get_app_id(ditto)
987
+ return dittoCore.boxCStringIntoString(cString)
988
+ }
989
+
990
+ export function dittoAuthClientUserID(ditto: Pointer<FFIDitto>): string {
991
+ trace()
992
+ ensureInitialized()
993
+ const cStr = dittoCore.ditto_auth_client_user_id(ditto)
994
+ return dittoCore.boxCStringIntoString(cStr)
995
+ }
996
+
997
+ /** @internal */
998
+ export function dittoAuthClientIsWebValid(ditto: Pointer<FFIDitto>): boolean {
999
+ trace()
1000
+ ensureInitialized()
1001
+ return dittoCore.ditto_auth_client_is_web_valid(ditto) !== 0
1002
+ }
1003
+
1004
+ export function dittoAuthClientIsX509Valid(ditto: Pointer<FFIDitto>): boolean {
1005
+ trace()
1006
+ ensureInitialized()
1007
+ return dittoCore.ditto_auth_client_is_x509_valid(ditto) !== 0
1008
+ }
1009
+
1010
+ export async function dittoAuthClientLoginWithToken(ditto: Pointer<FFIDitto>, token: string, provider: string) {
1011
+ trace()
1012
+ ensureInitialized()
1013
+
1014
+ const tokenBytes = bytesFromString(token)
1015
+ const providerBytes = bytesFromString(provider)
1016
+
1017
+ const errorCode = await dittoCore.ditto_auth_client_login_with_token(ditto, tokenBytes, providerBytes)
1018
+ if (errorCode !== 0) throw new Error(errorMessage() || `Ditto failed to authenticate (error code: ${errorCode}).`)
1019
+ }
1020
+
1021
+ export async function dittoAuthClientLoginWithUsernameAndPassword(ditto: Pointer<FFIDitto>, username: string, password: string, provider: string) {
1022
+ trace()
1023
+ ensureInitialized()
1024
+
1025
+ const usernameBytes = bytesFromString(username)
1026
+ const passwordBytes = bytesFromString(password)
1027
+ const providerBytes = bytesFromString(provider)
1028
+
1029
+ const errorCode = await dittoCore.ditto_auth_client_login_with_credentials(ditto, usernameBytes, passwordBytes, providerBytes)
1030
+ if (errorCode !== 0) throw new Error(errorMessage() || `Ditto failed to authenticate (error code: ${errorCode}).`)
1031
+ }
1032
+
1033
+ export async function dittoAuthClientLogout(ditto: Pointer<FFIDitto>) {
1034
+ trace()
1035
+ ensureInitialized()
1036
+
1037
+ const errorCode = await dittoCore.ditto_auth_client_logout(ditto)
1038
+ if (errorCode !== 0) throw new Error(errorMessage() || `Ditto failed to logout (error code: ${errorCode}).`)
1039
+ }
1040
+
1041
+ // ---------------------------------------------------------------- Ditto ------
1042
+
1043
+ /** @internal */
1044
+ export function uninitializedDittoMake(path: string): Pointer<FFIUninitializedDitto> {
1045
+ trace()
1046
+ ensureInitialized()
1047
+ const pathX = bytesFromString(path)
1048
+ return dittoCore.uninitialized_ditto_make(pathX)
1049
+ }
1050
+
1051
+ /** @internal */
1052
+ export function dittoMake(uninitializedDitto: Pointer<FFIUninitializedDitto>, identityConfig: Pointer<FFIIdentityConfig>): Pointer<FFIDitto> {
1053
+ trace()
1054
+ ensureInitialized()
1055
+ return dittoCore.ditto_make(uninitializedDitto, identityConfig, 'Disabled')
1056
+ }
1057
+
1058
+ /** @internal */
1059
+ export async function dittoGetCollectionNames(self: Pointer<FFIDitto>): Promise<string[]> {
1060
+ trace()
1061
+ ensureInitialized()
1062
+
1063
+ const result = await dittoCore.ditto_get_collection_names(self)
1064
+ const errorCode = result.status_code
1065
+ const cStringVec: { ptr: Pointer<'char *'>; len: number; cap: number } = result.names
1066
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_get_collection_names() failed with error code: ${errorCode}`)
1067
+
1068
+ const strings: string[] = dittoCore.cStringVecToStringArray(cStringVec) as string[]
1069
+ return strings
1070
+ }
1071
+
1072
+ /** @internal */
1073
+ export function dittoFree(self: Pointer<FFIDitto>) {
1074
+ trace()
1075
+ ensureInitialized()
1076
+
1077
+ return dittoCore.ditto_free(self)
1078
+ }
1079
+
1080
+ /** @internal */
1081
+ export function getDeadlockTimeout(): number {
1082
+ trace()
1083
+ ensureInitialized()
1084
+
1085
+ return dittoCore.getDeadlockTimeout()
1086
+ }
1087
+
1088
+ /** @internal */
1089
+ export function setDeadlockTimeout(duration: number): void {
1090
+ trace()
1091
+ ensureInitialized()
1092
+
1093
+ dittoCore.setDeadlockTimeout(duration)
1094
+ }
1095
+
1096
+ /** @internal */
1097
+ export async function dittoRegisterPresenceV1Callback(self: Pointer<FFIDitto>, cb: (string) => void): Promise<void> {
1098
+ trace()
1099
+ ensureInitialized()
1100
+
1101
+ dittoCore.ditto_register_presence_v1_callback(
1102
+ self,
1103
+ wrapBackgroundCbForFFI(
1104
+ (err) => log('Error', `The registered presence callback v1 errored with ${err}`),
1105
+ (cJsonStr: Pointer<'char'>) => {
1106
+ const jsonStr: string = dittoCore.refCStringToString(cJsonStr)
1107
+ cb(jsonStr)
1108
+ },
1109
+ ),
1110
+ )
1111
+ }
1112
+
1113
+ /** @internal */
1114
+ export async function dittoClearPresenceCallback(self: Pointer<FFIDitto>): Promise<void> {
1115
+ trace()
1116
+ ensureInitialized()
1117
+ await dittoCore.ditto_clear_presence_callback(self)
1118
+ }
1119
+
1120
+ /** @internal */
1121
+ export async function dittoRegisterPresenceV3Callback(self: Pointer<FFIDitto>, cb: (string) => void) {
1122
+ trace()
1123
+ ensureInitialized()
1124
+
1125
+ dittoCore.ditto_register_presence_v3_callback(
1126
+ self,
1127
+ wrapBackgroundCbForFFI(
1128
+ (err) => log('Error', `The registered presence callback v3 errored with ${err}`),
1129
+ (cJsonStr: Pointer<'char'>) => {
1130
+ const jsonStr: string = dittoCore.refCStringToString(cJsonStr)
1131
+ cb(jsonStr)
1132
+ },
1133
+ ),
1134
+ )
1135
+ }
1136
+
1137
+ /** @internal */
1138
+ export async function dittoClearPresenceV3Callback(self: Pointer<FFIDitto>) {
1139
+ trace()
1140
+ ensureInitialized()
1141
+ dittoCore.ditto_clear_presence_v3_callback(self)
1142
+ }
1143
+
1144
+ /** @internal */
1145
+ export function dittoSmallPeerInfoGetIsEnabled(dittoPointer: Pointer<FFIDitto>): boolean {
1146
+ trace()
1147
+ ensureInitialized()
1148
+
1149
+ return dittoCore.ditto_small_peer_info_get_is_enabled(dittoPointer)
1150
+ }
1151
+
1152
+ /** @internal */
1153
+ export async function dittoSmallPeerInfoSetEnabled(dittoPointer: Pointer<FFIDitto>, isEnabled: boolean): Promise<void> {
1154
+ trace()
1155
+ ensureInitialized()
1156
+
1157
+ dittoCore.ditto_small_peer_info_set_enabled(dittoPointer, isEnabled)
1158
+ }
1159
+
1160
+ /** @internal */
1161
+ export async function dittoSmallPeerInfoGetSyncScope(dittoPointer: Pointer<FFIDitto>): Promise<FFISmallPeerInfoSyncScope> {
1162
+ trace()
1163
+ ensureInitialized()
1164
+
1165
+ return dittoCore.ditto_small_peer_info_get_sync_scope(dittoPointer)
1166
+ }
1167
+
1168
+ /** @internal */
1169
+ export async function dittoSmallPeerInfoSetSyncScope(dittoPointer: Pointer<FFIDitto>, syncScope: FFISmallPeerInfoSyncScope): Promise<void> {
1170
+ trace()
1171
+ ensureInitialized()
1172
+
1173
+ return dittoCore.ditto_small_peer_info_set_sync_scope(dittoPointer, syncScope)
1174
+ }
1175
+
1176
+ /** @internal */
1177
+ export function dittoSmallPeerInfoGetMetadata(dittoPointer: Pointer<FFIDitto>): string {
1178
+ trace()
1179
+ ensureInitialized()
1180
+
1181
+ const cString = dittoCore.ditto_small_peer_info_get_metadata(dittoPointer)
1182
+ return dittoCore.boxCStringIntoString(cString)
1183
+ }
1184
+
1185
+ /** @internal */
1186
+ export function dittoSmallPeerInfoSetMetadata(dittoPointer: Pointer<FFIDitto>, metadata: string): void {
1187
+ trace()
1188
+ ensureInitialized()
1189
+
1190
+ const metadataCString = bytesFromString(metadata)
1191
+ const statusCode = dittoCore.ditto_small_peer_info_set_metadata(dittoPointer, metadataCString)
1192
+ switch (statusCode) {
1193
+ case 0:
1194
+ return
1195
+ case -1:
1196
+ throw new Error('Internal inconsistency, the observability subsystem is unavailable.')
1197
+ case 1:
1198
+ throw new Error(`Validation error, size limit exceeded: ${errorMessage() || 'metadata is too big'}`)
1199
+ case 2:
1200
+ throw new Error(`Validation error, ${errorMessage() || 'depth limit for metadata object exceeded'}`)
1201
+ case 3:
1202
+ throw new Error(`Validation error, ${errorMessage() || `'${metadata}' is not a valid JSON object`}`)
1203
+ default:
1204
+ throw new Error(errorMessage() || `Internal inconsistency, ditto_small_peer_info_set_metadata() returned an unknown error code: ${statusCode}`)
1205
+ }
1206
+ }
1207
+
1208
+ /** @internal */
1209
+ export async function dittoSmallPeerInfoCollectionSetTransportConfigData(self: Pointer<FFIDitto>, transportConfigData: Uint8Array) {
1210
+ trace()
1211
+ ensureInitialized()
1212
+ dittoCore.ditto_small_peer_info_set_transport_config_data(self, transportConfigData)
1213
+ }
1214
+
1215
+ /** @internal */
1216
+ export function dittoRegisterTransportConditionChangedCallback(self: Pointer<FFIDitto>, cb: null | ((ConditionSource, TransportCondition) => void)) {
1217
+ trace()
1218
+ ensureInitialized()
1219
+
1220
+ if (!cb) {
1221
+ dittoCore.ditto_register_transport_condition_changed_callback(self, null)
1222
+ } else {
1223
+ dittoCore.ditto_register_transport_condition_changed_callback(
1224
+ self,
1225
+ wrapBackgroundCbForFFI((err) => log('Error', `The registered "transport condition changed" callback errored with ${err}`), cb),
1226
+ )
1227
+ }
1228
+ }
1229
+
1230
+ /** @internal */
1231
+ export function dittoSetDeviceName(dittoPointer: Pointer<FFIDitto>, deviceName: string) {
1232
+ trace()
1233
+ ensureInitialized()
1234
+
1235
+ let deviceNameCString = bytesFromString(deviceName)
1236
+
1237
+ if (Environment.isWebBuild) {
1238
+ if (deviceNameCString.length > 64) {
1239
+
1240
+ const sanitizedDeviceName = deviceName.replace(/[^ -~]+/g, '')
1241
+ deviceNameCString = bytesFromString(sanitizedDeviceName.substr(0, 63))
1242
+
1243
+ }
1244
+ }
1245
+
1246
+ return dittoCore.ditto_set_device_name(dittoPointer, deviceNameCString)
1247
+ }
1248
+
1249
+ /** @internal */
1250
+ export function dittoSetConnectRetryInterval(dittoPointer: Pointer<FFIDitto>, retryInterval: number) {
1251
+ trace()
1252
+ ensureInitialized()
1253
+
1254
+ const UINT32_MAX = 4_294_967_295
1255
+ const clampedInterval = Math.min(Math.max(0, retryInterval), UINT32_MAX)
1256
+
1257
+ return dittoCore.ditto_set_connect_retry_interval(dittoPointer, clampedInterval)
1258
+ }
1259
+
1260
+ /** @internal */
1261
+ export function dittoSetSyncGroup(dittoPointer: Pointer<FFIDitto>, syncGroup: number) {
1262
+ trace()
1263
+ ensureInitialized()
1264
+
1265
+ return dittoCore.ditto_set_sync_group(dittoPointer, syncGroup)
1266
+ }
1267
+
1268
+ /** @internal */
1269
+ export function dittoNewAttachmentFromFile(ditto: Pointer<FFIDitto>, sourcePath: string, fileOperation: AttachmentFileOperation): RawAttachment {
1270
+ trace()
1271
+ ensureInitialized()
1272
+
1273
+ const sourcePathCString = bytesFromString(sourcePath)
1274
+ const outAttachment: any = {}
1275
+ const errorCode = dittoCore.ditto_new_attachment_from_file(ditto, sourcePathCString, fileOperation, outAttachment)
1276
+ if (errorCode !== 0) {
1277
+ throw new Error(errorMessage() || `ditto_new_attachment_from_file() failed with error code: ${errorCode}`)
1278
+ }
1279
+ return outAttachment
1280
+ }
1281
+
1282
+ /** @internal */
1283
+ export async function dittoNewAttachmentFromBytes(ditto: Pointer<FFIDitto>, bytes: Uint8Array): Promise<RawAttachment> {
1284
+ trace()
1285
+ ensureInitialized()
1286
+
1287
+ const outAttachment: any = {}
1288
+ const errorCode = await dittoCore.ditto_new_attachment_from_bytes(ditto, bytes, outAttachment)
1289
+ if (errorCode !== 0) {
1290
+ throw new Error(errorMessage() || `ditto_new_attachment_from_bytes() failed with error code: ${errorCode}`)
1291
+ }
1292
+ return outAttachment
1293
+ }
1294
+
1295
+ /** @internal */
1296
+ export async function dittoResolveAttachment(
1297
+ ditto: Pointer<FFIDitto>,
1298
+ id: Uint8Array,
1299
+ namedCallbacks: {
1300
+ onComplete: (attachmentHandlePointer: Pointer<AttachmentHandle>) => void
1301
+ onProgress: (downloaded: number | BigInt, toDownload: number | BigInt) => void
1302
+ onDelete: () => void
1303
+ },
1304
+ onError?: (error: any) => void,
1305
+ ): Promise<number | BigInt> {
1306
+ trace()
1307
+ ensureInitialized()
1308
+
1309
+ const { onComplete, onProgress, onDelete } = namedCallbacks
1310
+ const { status_code: errorCode, cancel_token: cancelToken } = await dittoCore.ditto_resolve_attachment(ditto, id, wrapBackgroundCbForFFI(onError, onComplete), wrapBackgroundCbForFFI(onError, onProgress), wrapBackgroundCbForFFI(onError, onDelete))
1311
+ if (errorCode !== 0) {
1312
+ throw new Error(errorMessage() || `ditto_resolve_attachment() failed with error code: ${errorCode}`)
1313
+ }
1314
+ return cancelToken
1315
+ }
1316
+
1317
+ /** @internal */
1318
+ export function dittoCancelResolveAttachment(dittoPointer: Pointer<FFIDitto>, id: Uint8Array, cancelToken: any) {
1319
+ trace()
1320
+ ensureInitialized()
1321
+
1322
+ const errorCode = dittoCore.ditto_cancel_resolve_attachment(dittoPointer, id, cancelToken)
1323
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_cancel_resolve_attachment() failed with error code: ${errorCode}`)
1324
+ }
1325
+
1326
+ /** @internal */
1327
+ export function freeAttachmentHandle(attachmentHandlePointer: Pointer<AttachmentHandle>) {
1328
+ trace()
1329
+ ensureInitialized()
1330
+ dittoCore.ditto_free_attachment_handle(attachmentHandlePointer)
1331
+ }
1332
+
1333
+ /** @internal */
1334
+ export async function dittoGetAttachmentStatus(dittoPointer: Pointer<FFIDitto>, id: Uint8Array): Promise<Pointer<AttachmentHandle>> {
1335
+ trace()
1336
+ ensureInitialized()
1337
+
1338
+ const { status_code: errorCode, handle: attachmentHandle } = await dittoCore.ditto_get_attachment_status(dittoPointer, id)
1339
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_get_attachment_status() failed with error code: ${errorCode}`)
1340
+ return attachmentHandle
1341
+ }
1342
+
1343
+ /** @internal */
1344
+ export async function dittoGetCompleteAttachmentData(dittoPointer: Pointer<FFIDitto>, attachmentHandlePointer: Pointer<AttachmentHandle>): Promise<Uint8Array> {
1345
+ trace()
1346
+ ensureInitialized()
1347
+
1348
+ const { status: errorCode, data } = await dittoCore.ditto_get_complete_attachment_data(dittoPointer, attachmentHandlePointer)
1349
+ if (errorCode !== 0) throw new Error(errorMessage() || `\`ditto_get_complete_attachment_data()\` failed with error code: ${errorCode}`)
1350
+ return dittoCore.boxCBytesIntoBuffer(data)
1351
+ }
1352
+
1353
+ /** @internal */
1354
+ export function dittoGetCompleteAttachmentPath(dittoPointer: Pointer<FFIDitto>, attachmentHandlePointer: Pointer<AttachmentHandle>): string {
1355
+ trace()
1356
+ ensureInitialized()
1357
+
1358
+ const pathCString = dittoCore.ditto_get_complete_attachment_path(dittoPointer, attachmentHandlePointer)
1359
+ return dittoCore.refCStringToString(pathCString)
1360
+ }
1361
+
1362
+ /** @internal */
1363
+ export function dittoGetSDKVersion(ditto: Pointer<FFIDitto>): string {
1364
+ trace()
1365
+ ensureInitialized()
1366
+
1367
+ const cString = dittoCore.ditto_get_sdk_version(ditto)
1368
+ return dittoCore.boxCStringIntoString(cString)
1369
+ }
1370
+
1371
+ /** @internal */
1372
+ export function dittoGetSDKSemver(): string {
1373
+ trace()
1374
+ ensureInitialized()
1375
+
1376
+ const cString = dittoCore.dittoffi_get_sdk_semver()
1377
+ return dittoCore.boxCStringIntoString(cString)
1378
+ }
1379
+
1380
+ /** @internal */
1381
+ export function dittoPresenceV1(self: Pointer<FFIDitto>): string {
1382
+ trace()
1383
+ ensureInitialized()
1384
+
1385
+ const cString = dittoCore.ditto_presence_v1(self)
1386
+ return dittoCore.boxCStringIntoString(cString)
1387
+ }
1388
+
1389
+ /** @internal */
1390
+ export function dittoPresenceV2(self: Pointer<FFIDitto>): string {
1391
+ trace()
1392
+ ensureInitialized()
1393
+
1394
+ const cString = dittoCore.ditto_presence_v2(self)
1395
+ return dittoCore.boxCStringIntoString(cString)
1396
+ }
1397
+
1398
+ /** @internal */
1399
+ export function dittoPresenceV3(self: Pointer<FFIDitto>): string {
1400
+ trace()
1401
+ ensureInitialized()
1402
+
1403
+ const cString = dittoCore.ditto_presence_v3(self)
1404
+ return dittoCore.boxCStringIntoString(cString)
1405
+ }
1406
+
1407
+ /** @internal */
1408
+ export function dittoStartTCPServer(dittoPointer: Pointer<FFIDitto>, bind: string) {
1409
+ trace()
1410
+ ensureInitialized()
1411
+
1412
+ const bindBuffer = bytesFromString(bind)
1413
+ return dittoCore.ditto_start_tcp_server(dittoPointer, bindBuffer)
1414
+ }
1415
+
1416
+ /** @internal */
1417
+ export function dittoStopTCPServer(dittoPointer: Pointer<FFIDitto>) {
1418
+ trace()
1419
+ ensureInitialized()
1420
+
1421
+ return dittoCore.ditto_stop_tcp_server(dittoPointer)
1422
+ }
1423
+
1424
+ /** @internal */
1425
+ export async function dittoShutdown(dittoPointer: Pointer<FFIDitto>): Promise<void> {
1426
+ trace()
1427
+ ensureInitialized()
1428
+
1429
+ return await dittoCore.ditto_shutdown(dittoPointer)
1430
+ }
1431
+
1432
+ /** @internal */
1433
+ export function dittoAddMulticastTransport(dittoPointer: Pointer<FFIDitto>) {
1434
+ trace()
1435
+ ensureInitialized()
1436
+
1437
+ return dittoCore.ditto_add_multicast_transport(dittoPointer)
1438
+ }
1439
+
1440
+ /** @internal */
1441
+ export function dittoRemoveMulticastTransport(dittoPointer: Pointer<FFIDitto>) {
1442
+ trace()
1443
+ ensureInitialized()
1444
+
1445
+ return dittoCore.ditto_remove_multicast_transport(dittoPointer)
1446
+ }
1447
+
1448
+ /** @internal */
1449
+ export function dittoStartHTTPServer(dittoPointer: Pointer<FFIDitto>, bind: string, staticPath: string | null, websocketMode: WebsocketMode, tlsCertPath: string | null, tlsKeyPath: string | null) {
1450
+ trace()
1451
+ ensureInitialized()
1452
+
1453
+ const bindBuffer = bytesFromString(bind)
1454
+ const staticPathBuffer = bytesFromString(staticPath)
1455
+ const tlsCertPathBuffer = bytesFromString(tlsCertPath)
1456
+ const tlsKeyPathBuffer = bytesFromString(tlsKeyPath)
1457
+ return dittoCore.ditto_start_http_server(dittoPointer, bindBuffer, staticPathBuffer, websocketMode, tlsCertPathBuffer, tlsKeyPathBuffer)
1458
+ }
1459
+
1460
+ /** @internal */
1461
+ export function dittoStopHTTPServer(dittoPointer: Pointer<FFIDitto>) {
1462
+ trace()
1463
+ ensureInitialized()
1464
+ return dittoCore.ditto_stop_http_server(dittoPointer)
1465
+ }
1466
+
1467
+ /** @internal */
1468
+ export function dittoRunGarbageCollection(dittoPointer: Pointer<FFIDitto>) {
1469
+ trace()
1470
+ ensureInitialized()
1471
+ return dittoCore.ditto_run_garbage_collection(dittoPointer)
1472
+ }
1473
+
1474
+ /** @internal */
1475
+ export async function dittoDisableSyncWithV3(dittoPointer: Pointer<FFIDitto>): Promise<void> {
1476
+ trace()
1477
+ ensureInitialized()
1478
+ const errorCode = await dittoCore.ditto_disable_sync_with_v3(dittoPointer)
1479
+ if (errorCode !== 0) throw new Error(errorMessage() || `ditto_disable_sync_with_v3() failed with error code: ${errorCode}`)
1480
+ }
1481
+
1482
+ export function dittoSetStaticTCPClients(ditto: Pointer<FFIDitto>, listOfServers: string[]) {
1483
+ trace()
1484
+ ensureInitialized()
1485
+
1486
+
1487
+ if (Environment.isNodeBuild) {
1488
+ const listOfServersBytes = listOfServers.map((server) => bytesFromString(server))
1489
+ dittoCore.ditto_set_static_tcp_clients(ditto, listOfServersBytes)
1490
+ }
1491
+
1492
+ if (Environment.isWebBuild) {
1493
+
1494
+ if (listOfServers.length > 0) {
1495
+ throw new Error(`Web variant of Ditto does not support connecting to TCP servers: ${listOfServers.join(', ')}`)
1496
+ }
1497
+ }
1498
+ }
1499
+
1500
+ export function dittoSetStaticWebsocketClients(ditto: Pointer<FFIDitto>, listOfServers: string[], routingHint: number) {
1501
+ trace()
1502
+ ensureInitialized()
1503
+ const listOfServersBytes = listOfServers.map((server) => bytesFromString(server))
1504
+ dittoCore.ditto_set_static_websocket_clients(ditto, listOfServersBytes, routingHint)
1505
+ }
1506
+
1507
+ // ------------------------------------------------------ Hash & Mnemonic ------
1508
+
1509
+ /** @internal */
1510
+ export function documentsHash(documents: Pointer<FFIDocument>[]): BigInt {
1511
+ trace()
1512
+ ensureInitialized()
1513
+ const { status_code: errorCode, u64: hash } = dittoCore.ditto_documents_hash(documents)
1514
+ if (errorCode !== 0) throw new Error(errorMessage() || `\`ditto_documents_hash()\` failed with error code: ${errorCode}`)
1515
+ return BigInt(hash)
1516
+ }
1517
+
1518
+ /** @internal */
1519
+ export function documentsHashMnemonic(documents: Pointer<FFIDocument>[]): string {
1520
+ trace()
1521
+ ensureInitialized()
1522
+ const { status_code: errorCode, c_string } = dittoCore.ditto_documents_hash_mnemonic(documents)
1523
+ if (errorCode !== 0) throw new Error(errorMessage() || `\`ditto_documents_hash_mnemonic()\` failed with error code: ${errorCode}`)
1524
+ return dittoCore.boxCStringIntoString(c_string)
1525
+ }
1526
+
1527
+ // ------------------------------------------------------------- Auth ----------
1528
+
1529
+ /** @internal */
1530
+ export function authServerAuthSubmitWithSuccess(req: Pointer<FFIAuthServerAuthRequest>, successCbor: Uint8Array): void {
1531
+ trace()
1532
+ ensureInitialized()
1533
+ return dittoCore.auth_server_auth_submit_with_success(req, successCbor)
1534
+ }
1535
+
1536
+ /** @internal */
1537
+ export function authServerAuthSubmitWithError(req: Pointer<FFIAuthServerAuthRequest>, errorCode: number): void {
1538
+ trace()
1539
+ ensureInitialized()
1540
+ return dittoCore.auth_server_auth_submit_with_error(req, errorCode)
1541
+ }
1542
+
1543
+ /** @internal */
1544
+ export function authServerRefreshSubmitWithSuccess(req: Pointer<FFIAuthServerRefreshRequest>, successCbor: Uint8Array): void {
1545
+ trace()
1546
+ ensureInitialized()
1547
+ return dittoCore.auth_server_refresh_submit_with_success(req, successCbor)
1548
+ }
1549
+
1550
+ /** @internal */
1551
+ export function authServerRefreshSubmitWithError(req: Pointer<FFIAuthServerRefreshRequest>, errorCode: number): void {
1552
+ trace()
1553
+ ensureInitialized()
1554
+ return dittoCore.auth_server_refresh_submit_with_error(req, errorCode)
1555
+ }
1556
+
1557
+ /** @internal */
1558
+ export function dittoUnregisterLocalAuthServer(ditto: Pointer<FFIDitto>): void {
1559
+ trace()
1560
+ ensureInitialized()
1561
+ return dittoCore.ditto_unregister_local_auth_server(ditto)
1562
+ }
1563
+
1564
+ /** @internal */
1565
+ export function dittoRegisterLocalAuthServer(namedArgs: {
1566
+ ditto: Pointer<FFIDitto>
1567
+ signingKeyPem: string
1568
+ verifyingKeysPem: string[]
1569
+ caKeyPem?: string
1570
+ authCb: (authRequest: Pointer<FFIAuthServerAuthRequest>, cbor: Uint8Array) => void
1571
+ refreshCb: (authRequest: Pointer<FFIAuthServerRefreshRequest>, cbor: Uint8Array) => void
1572
+ onError?: (error: any) => void
1573
+ }): void {
1574
+ const { ditto, signingKeyPem, verifyingKeysPem, caKeyPem, authCb, refreshCb, onError } = namedArgs
1575
+ trace()
1576
+ ensureInitialized()
1577
+
1578
+ const signingKeyPemFfi = bytesFromString(signingKeyPem)
1579
+ const verifyingKeysPemFfi = verifyingKeysPem.map(bytesFromString)
1580
+ const caKeyPemFfi = typeof caKeyPem !== 'undefined' ? bytesFromString(caKeyPem) : null
1581
+ const authCbFfi = wrapBackgroundCbForFFI(onError, authCb)
1582
+ const refreshCbFfi = wrapBackgroundCbForFFI(onError, refreshCb)
1583
+ return dittoCore.ditto_register_local_auth_server(ditto, signingKeyPemFfi, verifyingKeysPemFfi, caKeyPemFfi, authCbFfi, refreshCbFfi)
1584
+ }
1585
+
1586
+ /** @internal */
1587
+ export async function dittoAuthSetLoginProvider(ditto: Pointer<FFIDitto>, loginProvider: Pointer<FFILoginProvider>): Promise<void> {
1588
+ trace()
1589
+ ensureInitialized()
1590
+
1591
+ return await dittoCore.ditto_auth_set_login_provider(ditto, loginProvider)
1592
+ }
1593
+
1594
+ /** @internal */
1595
+ export function dittoAuthClientMakeLoginProvider(
1596
+ expiringCb: (secs_until_expiry: number) => void,
1597
+ onError?: (error: any) => void,
1598
+ ): Pointer<FFILoginProvider> {
1599
+ trace()
1600
+ ensureInitialized()
1601
+
1602
+ return dittoCore.ditto_auth_client_make_login_provider(wrapBackgroundCbForFFI(onError, expiringCb))
1603
+ }
1604
+
1605
+ /** @internal */
1606
+ export function dittoAuthClientSetValidityListener(
1607
+ ditto: Pointer<FFIDitto>,
1608
+ validityUpdateCb: (isWebValid: boolean, isX509Valid: boolean) => void,
1609
+ onError?: (error: any) => void,
1610
+ ): void {
1611
+ trace()
1612
+ ensureInitialized()
1613
+
1614
+ const validityUpdateRawCb = wrapBackgroundCbForFFI(onError, function (isWebValidInt: number, isX509ValidInt: number) {
1615
+ return validityUpdateCb(isWebValidInt === 1, isX509ValidInt === 1)
1616
+ })
1617
+
1618
+ return dittoCore.ditto_auth_client_set_validity_listener(ditto, validityUpdateRawCb)
1619
+ }
1620
+
1621
+ // ----------------------------------------------------------- Transports ------
1622
+
1623
+ /**
1624
+ * We currently don't initialize transports through this function but rather in
1625
+ * the NAPI module registration in `transports.c` due to an issue with importing
1626
+ * the functions required by this function.
1627
+ * See https://github.com/getditto/ditto/issues/10723
1628
+ *
1629
+ * @internal
1630
+ */
1631
+ export function transportsInit(): void {
1632
+ trace()
1633
+ ensureInitialized()
1634
+
1635
+ const transportsErrorPointer = dittoCore.ditto_sdk_transports_error_new()
1636
+ const wasInitialized = dittoCore.ditto_sdk_transports_init(transportsErrorPointer)
1637
+
1638
+ const errorType: TransportsError = dittoCore.ditto_sdk_transports_error_value(transportsErrorPointer)
1639
+ dittoCore.ditto_sdk_transports_error_free(transportsErrorPointer)
1640
+
1641
+ if (wasInitialized === false) {
1642
+ throw new Error(`Failed to initialize transports (${errorType} error)`)
1643
+ }
1644
+ }
1645
+
1646
+ /** @internal */
1647
+ export function transportsBLEIsAvailable(ditto: Pointer<FFIDitto>): boolean {
1648
+ trace()
1649
+ ensureInitialized()
1650
+
1651
+ return dittoCore.ditto_sdk_transports_ble_is_available(ditto)
1652
+ }
1653
+
1654
+ /** @internal */
1655
+ export function transportsBLECreate(ditto: Pointer<FFIDitto>): Pointer<TransportBluetooth> | null | void {
1656
+ trace()
1657
+ ensureInitialized()
1658
+
1659
+ const transportsErrorPointer = dittoCore.ditto_sdk_transports_error_new()
1660
+ const blePointer: Pointer<TransportBluetooth> = dittoCore.ditto_sdk_transports_ble_create(ditto, transportsErrorPointer)
1661
+
1662
+ const errorType: TransportsError = dittoCore.ditto_sdk_transports_error_value(transportsErrorPointer)
1663
+ dittoCore.ditto_sdk_transports_error_free(transportsErrorPointer)
1664
+
1665
+ if (blePointer != null) {
1666
+ log('Info', `Bluetooth transport created.`)
1667
+ } else {
1668
+ log('Error', `Can't create bluetooth transport (${errorType} error).`)
1669
+ }
1670
+
1671
+ return blePointer
1672
+ }
1673
+
1674
+ /** @internal */
1675
+ export function transportsBLEDestroy(ble: Pointer<TransportBluetooth>): boolean | void {
1676
+ trace()
1677
+ ensureInitialized()
1678
+
1679
+ const ffiError = dittoCore.ditto_sdk_transports_error_new()
1680
+ const wasDestroyed = dittoCore.ditto_sdk_transports_ble_destroy(ble, ffiError)
1681
+
1682
+ const errorType: TransportsError = dittoCore.ditto_sdk_transports_error_value(ffiError)
1683
+ dittoCore.ditto_sdk_transports_error_free(ffiError)
1684
+
1685
+ if (wasDestroyed === true) {
1686
+ log('Info', 'Bluetooth transport disabled.')
1687
+ } else {
1688
+ log('Error', `Bluetooth transport could not be disabled (${errorType} error).`)
1689
+ }
1690
+ return wasDestroyed
1691
+ }
1692
+
1693
+ /** @internal */
1694
+ export function transportsLANIsAvailable(ditto: Pointer<FFIDitto>): boolean {
1695
+ trace()
1696
+ ensureInitialized()
1697
+
1698
+ return dittoCore.ditto_sdk_transports_lan_is_available(ditto)
1699
+ }
1700
+
1701
+ /** @internal */
1702
+ export function transportsLANCreate(ditto: Pointer<FFIDitto>): Pointer<TransportLAN> | void {
1703
+ trace()
1704
+ ensureInitialized()
1705
+
1706
+ const transportsErrorPointer = dittoCore.ditto_sdk_transports_error_new()
1707
+ const lanPointer: Pointer<TransportLAN> = dittoCore.ditto_sdk_transports_lan_create(ditto, transportsErrorPointer)
1708
+
1709
+ const errorType: TransportsError = dittoCore.ditto_sdk_transports_error_value(transportsErrorPointer)
1710
+ dittoCore.ditto_sdk_transports_error_free(transportsErrorPointer)
1711
+
1712
+ if (lanPointer != null) {
1713
+ log('Info', `LAN transport created.`)
1714
+ } else {
1715
+ log('Error', `Can't create LAN transport (${errorType} error).`)
1716
+ }
1717
+
1718
+ return lanPointer
1719
+ }
1720
+
1721
+ /** @internal */
1722
+ export function transportsLANDestroy(lan: Pointer<TransportLAN>): boolean | void {
1723
+ trace()
1724
+ ensureInitialized()
1725
+
1726
+ const ffiError = dittoCore.ditto_sdk_transports_error_new()
1727
+ const wasDestroyed = dittoCore.ditto_sdk_transports_lan_destroy(lan, ffiError)
1728
+
1729
+ const error: TransportsError = dittoCore.ditto_sdk_transports_error_value(ffiError)
1730
+ dittoCore.ditto_sdk_transports_error_free(ffiError)
1731
+
1732
+ if (wasDestroyed === true) {
1733
+ log('Info', 'LAN transport disabled.')
1734
+ } else {
1735
+ log('Error', `LAN transport could not be disabled (${error} error).`)
1736
+ }
1737
+ return wasDestroyed
1738
+ }
1739
+
1740
+ /** @internal */
1741
+ export function transportsAWDLIsAvailable(ditto: Pointer<FFIDitto>): boolean {
1742
+ trace()
1743
+ ensureInitialized()
1744
+
1745
+ return dittoCore.ditto_sdk_transports_awdl_is_available(ditto)
1746
+ }
1747
+
1748
+ /** @internal */
1749
+ export function transportsAWDLCreate(ditto: Pointer<FFIDitto>): Pointer<TransportAWDL> | null | void {
1750
+ trace()
1751
+ ensureInitialized()
1752
+
1753
+ const transportsErrorPointer = dittoCore.ditto_sdk_transports_error_new()
1754
+ const awdlPointer: Pointer<TransportAWDL> = dittoCore.ditto_sdk_transports_awdl_create(ditto, transportsErrorPointer)
1755
+
1756
+ const errorType: TransportsError = dittoCore.ditto_sdk_transports_error_value(transportsErrorPointer)
1757
+ dittoCore.ditto_sdk_transports_error_free(transportsErrorPointer)
1758
+
1759
+ if (awdlPointer != null) {
1760
+ log('Info', `AWDL transport created.`)
1761
+ } else {
1762
+ log('Error', `Can't create AWDL transport (${errorType} error).`)
1763
+ }
1764
+
1765
+ return awdlPointer
1766
+ }
1767
+
1768
+ /** @internal */
1769
+ export function transportsAWDLDestroy(awdl: Pointer<TransportAWDL>): boolean | void {
1770
+ trace()
1771
+ ensureInitialized()
1772
+
1773
+ const ffiError = dittoCore.ditto_sdk_transports_error_new()
1774
+ const wasDestroyed = dittoCore.ditto_sdk_transports_awdl_destroy(awdl, ffiError)
1775
+
1776
+ const errorType: TransportsError = dittoCore.ditto_sdk_transports_error_value(ffiError)
1777
+ dittoCore.ditto_sdk_transports_error_free(ffiError)
1778
+
1779
+ if (wasDestroyed === true) {
1780
+ log('Info', 'AWDL transport disabled.')
1781
+ } else {
1782
+ log('Error', `AWDL transport could not be disabled (${errorType} error).`)
1783
+ }
1784
+ return wasDestroyed
1785
+ }
1786
+
1787
+ // ---------------------------------------------------------------- Other ------
1788
+
1789
+ /** @internal */
1790
+ let isInitialized = false
1791
+
1792
+ /** @internal */
1793
+ let withOutPtr: (ptr_type: string, callback: any) => any
1794
+
1795
+ if (Environment.isNodeBuild) {
1796
+ isInitialized = true
1797
+ withOutPtr = wrapFFIOutFunction(dittoCore.withOutPtr)
1798
+ }
1799
+
1800
+ if (Environment.isReactNativeBuild) {
1801
+ isInitialized = true
1802
+ }
1803
+
1804
+ /** @internal */
1805
+ export async function init(webAssemblyModule?: WebAssemblyModule): Promise<void> {
1806
+ if (Environment.isWebBuild) {
1807
+ if (webAssemblyModule) {
1808
+ await dittoCore.init(webAssemblyModule as any)
1809
+ } else {
1810
+ await dittoCore.init()
1811
+ }
1812
+
1813
+ isInitialized = true
1814
+ withOutPtr = wrapFFIOutFunction(dittoCore.withOutPtr)
1815
+ }
1816
+ }
1817
+
1818
+ /** @internal */
1819
+ export function initSDKVersion(platform: Platform, language: Language, semVer: string) {
1820
+ trace()
1821
+ ensureInitialized()
1822
+
1823
+ const platformCString = bytesFromString(platform)
1824
+ const languageCString = bytesFromString(language)
1825
+ const semVerCString = bytesFromString(semVer)
1826
+
1827
+ const errorCode = dittoCore.ditto_init_sdk_version(platform, language, semVerCString)
1828
+ if (typeof errorCode !== 'undefined' && errorCode !== 0) throw new Error(errorMessage() || `ditto_init_sdk_version() failed with error code: ${errorCode}`)
1829
+ }
1830
+
1831
+ /** @internal */
1832
+ export function verifyLicense(license: string): { result: LicenseVerificationResult; errorMessage?: string } {
1833
+ trace()
1834
+ ensureInitialized()
1835
+
1836
+ const licenseBuffer = bytesFromString(license)
1837
+ let result: LicenseVerificationResult
1838
+ const errorMessageCString = withOutPtr('char *', (outErrorMessage) => {
1839
+ result = dittoCore.verify_license(licenseBuffer, outErrorMessage)
1840
+ return outErrorMessage
1841
+ })
1842
+
1843
+ const errorMessage = dittoCore.boxCStringIntoString(errorMessageCString)
1844
+ return { result, errorMessage }
1845
+ }
1846
+
1847
+ // ---------------------------------------------------- React Native only ------
1848
+
1849
+ /** @internal */
1850
+ export function getDeviceName(): string | void {
1851
+ if (Environment.isReactNativeBuild) {
1852
+ return dittoCore.getDeviceName()
1853
+ }
1854
+ }
1855
+
1856
+ /** @internal */
1857
+ export function getRandomValues<T extends ArrayBufferView>(array: T): T | void {
1858
+ if (Environment.isReactNativeBuild) {
1859
+ return dittoCore.getRandomValues(array)
1860
+ }
1861
+ }
1862
+
1863
+ /** @internal */
1864
+ export function createDirectory(path: string): string | void {
1865
+ if (Environment.isReactNativeBuild) {
1866
+ return dittoCore.createDirectory(path)
1867
+ }
1868
+ }
1869
+
1870
+ // -------------------------------------------------------------- Private ------
1871
+
1872
+ /** @internal */
1873
+ const NOT_FOUND_ERROR_CODE = -30798
1874
+
1875
+ /** @internal */
1876
+ function wrapBackgroundCbForFFI(onError: null | ((err: any) => void), cb: any): any {
1877
+
1878
+ if (Environment.isReactNativeBuild) {
1879
+ return cb
1880
+ }
1881
+ if (onError === undefined) {
1882
+ onError = (err: any) => log('Error', `The registered callback failed with ${err}`)
1883
+ }
1884
+ return (ret_sender, ...args) => {
1885
+ let ret
1886
+ try {
1887
+ ret = cb(...args)
1888
+ } catch (err) {
1889
+ try {
1890
+ onError(err)
1891
+ } catch (nested_error) {
1892
+ log('Error', `Internal error: \`onError()\` handler oughtn't throw, but it did throw ${nested_error}`)
1893
+ }
1894
+ }
1895
+ return ret_sender(ret)
1896
+ }
1897
+ }
1898
+
1899
+ /** @internal */
1900
+ function wrapFFIOutFunction(ffiOutFunction: any): any {
1901
+ return function (...args) {
1902
+ let occurredError = undefined
1903
+ let callbackResult = undefined
1904
+ let isCallbackResultOutParameter = false
1905
+
1906
+ const callback = args[args.length - 1]
1907
+ const previous_args = args.splice(0, args.length - 1)
1908
+
1909
+ const dittoCoreResult = ffiOutFunction(...previous_args, (outParameter) => {
1910
+ try {
1911
+ callbackResult = callback(outParameter)
1912
+ isCallbackResultOutParameter = callbackResult === outParameter
1913
+ } catch (error) {
1914
+ occurredError = error
1915
+ }
1916
+ })
1917
+
1918
+ if (occurredError) {
1919
+ throw occurredError
1920
+ }
1921
+
1922
+ return isCallbackResultOutParameter ? dittoCoreResult : callbackResult
1923
+ }
1924
+ }
1925
+
1926
+ /** @internal */
1927
+ function bytesFromString(jsString: string | null | undefined): Uint8Array | null | undefined {
1928
+ if (typeof jsString === 'undefined') return undefined
1929
+ if (jsString === null) return null
1930
+ if (typeof jsString !== 'string') throw new Error(`Can't convert string to Uint8Array, not a string: ${jsString}`)
1931
+ const textEncoder = new TextEncoder()
1932
+ return textEncoder.encode(`${jsString}\0`)
1933
+ }
1934
+
1935
+ /**
1936
+ * This is the legacy error-message retrieving function, using thread-local
1937
+ * storage.
1938
+ *
1939
+ * @internal
1940
+ */
1941
+ function errorMessage(): string {
1942
+ trace()
1943
+ ensureInitialized()
1944
+
1945
+ // eslint-disable-next-line
1946
+ const errorMessageCString = dittoCore.ditto_error_message()
1947
+ return dittoCore.boxCStringIntoString(errorMessageCString)
1948
+ }
1949
+
1950
+ /** @internal */
1951
+ function trace() {
1952
+ if (isTracingEnabled) {
1953
+
1954
+ const error = new Error()
1955
+ const stack = error.stack
1956
+ let caller = '<unknown>'
1957
+ try {
1958
+ caller = stack.split('\n')[2].trim().split(/\s+/)[1].replace('Module.', '')
1959
+ } catch (error) {
1960
+ }
1961
+
1962
+
1963
+ console.log(`💗 [TRACE] ${caller}()`)
1964
+ }
1965
+ }
1966
+
1967
+ /** @internal */
1968
+ function ensureInitialized() {
1969
+ if (!isInitialized) {
1970
+ throw new Error('Ditto needs to be initialized before using any of its API, please make sure to call `await init()` first.')
1971
+ }
1972
+ }