@dittolive/ditto 4.4.5 → 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DittoReactNative.podspec +27 -0
- package/README.md +68 -51
- package/node/ditto.cjs.js +1639 -851
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.node +0 -0
- package/node/ditto.linux-arm.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/ditto.win32-x64.node +0 -0
- package/node/transports.darwin-arm64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +34 -38
- package/react-native/android/CMakeLists.txt +37 -0
- package/react-native/android/build.gradle +203 -0
- package/react-native/android/cpp-adapter.cpp +254 -0
- package/react-native/android/gradle.properties +5 -0
- package/react-native/android/src/main/AndroidManifest.xml +4 -0
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +85 -0
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +28 -0
- package/react-native/boost/boost/assert.hpp +85 -0
- package/react-native/boost/boost/config/abi/borland_prefix.hpp +27 -0
- package/react-native/boost/boost/config/abi/borland_suffix.hpp +12 -0
- package/react-native/boost/boost/config/abi/msvc_prefix.hpp +22 -0
- package/react-native/boost/boost/config/abi/msvc_suffix.hpp +8 -0
- package/react-native/boost/boost/config/abi_prefix.hpp +25 -0
- package/react-native/boost/boost/config/abi_suffix.hpp +25 -0
- package/react-native/boost/boost/config/assert_cxx03.hpp +211 -0
- package/react-native/boost/boost/config/assert_cxx11.hpp +209 -0
- package/react-native/boost/boost/config/assert_cxx14.hpp +47 -0
- package/react-native/boost/boost/config/assert_cxx17.hpp +62 -0
- package/react-native/boost/boost/config/assert_cxx20.hpp +59 -0
- package/react-native/boost/boost/config/assert_cxx98.hpp +23 -0
- package/react-native/boost/boost/config/auto_link.hpp +525 -0
- package/react-native/boost/boost/config/compiler/borland.hpp +339 -0
- package/react-native/boost/boost/config/compiler/clang.hpp +366 -0
- package/react-native/boost/boost/config/compiler/clang_version.hpp +83 -0
- package/react-native/boost/boost/config/compiler/codegear.hpp +385 -0
- package/react-native/boost/boost/config/compiler/comeau.hpp +59 -0
- package/react-native/boost/boost/config/compiler/common_edg.hpp +183 -0
- package/react-native/boost/boost/config/compiler/compaq_cxx.hpp +19 -0
- package/react-native/boost/boost/config/compiler/cray.hpp +446 -0
- package/react-native/boost/boost/config/compiler/diab.hpp +26 -0
- package/react-native/boost/boost/config/compiler/digitalmars.hpp +143 -0
- package/react-native/boost/boost/config/compiler/gcc.hpp +383 -0
- package/react-native/boost/boost/config/compiler/gcc_xml.hpp +114 -0
- package/react-native/boost/boost/config/compiler/greenhills.hpp +28 -0
- package/react-native/boost/boost/config/compiler/hp_acc.hpp +149 -0
- package/react-native/boost/boost/config/compiler/intel.hpp +577 -0
- package/react-native/boost/boost/config/compiler/kai.hpp +33 -0
- package/react-native/boost/boost/config/compiler/metrowerks.hpp +198 -0
- package/react-native/boost/boost/config/compiler/mpw.hpp +140 -0
- package/react-native/boost/boost/config/compiler/nvcc.hpp +61 -0
- package/react-native/boost/boost/config/compiler/pathscale.hpp +138 -0
- package/react-native/boost/boost/config/compiler/pgi.hpp +23 -0
- package/react-native/boost/boost/config/compiler/sgi_mipspro.hpp +29 -0
- package/react-native/boost/boost/config/compiler/sunpro_cc.hpp +222 -0
- package/react-native/boost/boost/config/compiler/vacpp.hpp +186 -0
- package/react-native/boost/boost/config/compiler/visualc.hpp +391 -0
- package/react-native/boost/boost/config/compiler/xlcpp.hpp +299 -0
- package/react-native/boost/boost/config/compiler/xlcpp_zos.hpp +173 -0
- package/react-native/boost/boost/config/detail/cxx_composite.hpp +203 -0
- package/react-native/boost/boost/config/detail/posix_features.hpp +95 -0
- package/react-native/boost/boost/config/detail/select_compiler_config.hpp +157 -0
- package/react-native/boost/boost/config/detail/select_platform_config.hpp +147 -0
- package/react-native/boost/boost/config/detail/select_stdlib_config.hpp +121 -0
- package/react-native/boost/boost/config/detail/suffix.hpp +1294 -0
- package/react-native/boost/boost/config/header_deprecated.hpp +26 -0
- package/react-native/boost/boost/config/helper_macros.hpp +37 -0
- package/react-native/boost/boost/config/no_tr1/cmath.hpp +28 -0
- package/react-native/boost/boost/config/no_tr1/complex.hpp +28 -0
- package/react-native/boost/boost/config/no_tr1/functional.hpp +28 -0
- package/react-native/boost/boost/config/no_tr1/memory.hpp +28 -0
- package/react-native/boost/boost/config/no_tr1/utility.hpp +28 -0
- package/react-native/boost/boost/config/platform/aix.hpp +33 -0
- package/react-native/boost/boost/config/platform/amigaos.hpp +15 -0
- package/react-native/boost/boost/config/platform/beos.hpp +26 -0
- package/react-native/boost/boost/config/platform/bsd.hpp +83 -0
- package/react-native/boost/boost/config/platform/cloudabi.hpp +18 -0
- package/react-native/boost/boost/config/platform/cray.hpp +18 -0
- package/react-native/boost/boost/config/platform/cygwin.hpp +71 -0
- package/react-native/boost/boost/config/platform/haiku.hpp +31 -0
- package/react-native/boost/boost/config/platform/hpux.hpp +87 -0
- package/react-native/boost/boost/config/platform/irix.hpp +31 -0
- package/react-native/boost/boost/config/platform/linux.hpp +106 -0
- package/react-native/boost/boost/config/platform/macos.hpp +87 -0
- package/react-native/boost/boost/config/platform/qnxnto.hpp +31 -0
- package/react-native/boost/boost/config/platform/solaris.hpp +31 -0
- package/react-native/boost/boost/config/platform/symbian.hpp +97 -0
- package/react-native/boost/boost/config/platform/vms.hpp +25 -0
- package/react-native/boost/boost/config/platform/vxworks.hpp +422 -0
- package/react-native/boost/boost/config/platform/wasm.hpp +23 -0
- package/react-native/boost/boost/config/platform/win32.hpp +90 -0
- package/react-native/boost/boost/config/platform/zos.hpp +32 -0
- package/react-native/boost/boost/config/pragma_message.hpp +31 -0
- package/react-native/boost/boost/config/requires_threads.hpp +92 -0
- package/react-native/boost/boost/config/stdlib/dinkumware.hpp +324 -0
- package/react-native/boost/boost/config/stdlib/libcomo.hpp +93 -0
- package/react-native/boost/boost/config/stdlib/libcpp.hpp +180 -0
- package/react-native/boost/boost/config/stdlib/libstdcpp3.hpp +482 -0
- package/react-native/boost/boost/config/stdlib/modena.hpp +79 -0
- package/react-native/boost/boost/config/stdlib/msl.hpp +98 -0
- package/react-native/boost/boost/config/stdlib/roguewave.hpp +208 -0
- package/react-native/boost/boost/config/stdlib/sgi.hpp +168 -0
- package/react-native/boost/boost/config/stdlib/stlport.hpp +258 -0
- package/react-native/boost/boost/config/stdlib/vacpp.hpp +74 -0
- package/react-native/boost/boost/config/stdlib/xlcpp_zos.hpp +61 -0
- package/react-native/boost/boost/config/user.hpp +133 -0
- package/react-native/boost/boost/config/warning_disable.hpp +47 -0
- package/react-native/boost/boost/config/workaround.hpp +305 -0
- package/react-native/boost/boost/config.hpp +67 -0
- package/react-native/boost/boost/cstdint.hpp +556 -0
- package/react-native/boost/boost/intrusive_ptr.hpp +18 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count.hpp +103 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc.hpp +79 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_atomic.hpp +63 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_gcc_x86.hpp +88 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_nt.hpp +66 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_pt.hpp +104 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_spin.hpp +69 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_std_atomic.hpp +67 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_sync.hpp +72 -0
- package/react-native/boost/boost/smart_ptr/detail/atomic_count_win32.hpp +70 -0
- package/react-native/boost/boost/smart_ptr/detail/local_counted_base.hpp +148 -0
- package/react-native/boost/boost/smart_ptr/detail/local_sp_deleter.hpp +91 -0
- package/react-native/boost/boost/smart_ptr/detail/operator_bool.hpp +64 -0
- package/react-native/boost/boost/smart_ptr/detail/requires_cxx11.hpp +23 -0
- package/react-native/boost/boost/smart_ptr/detail/shared_count.hpp +707 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_convertible.hpp +92 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base.hpp +92 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_acc_ia64.hpp +163 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_aix.hpp +152 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_cw_ppc.hpp +185 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_atomic.hpp +148 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ia64.hpp +170 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_mips.hpp +200 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_ppc.hpp +194 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_sparc.hpp +179 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_gcc_x86.hpp +186 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_nt.hpp +119 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_pt.hpp +147 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_snc_ps3.hpp +174 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_spin.hpp +141 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_std_atomic.hpp +147 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_sync.hpp +165 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_vacpp_ppc.hpp +163 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_base_w32.hpp +140 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_counted_impl.hpp +309 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_disable_deprecated.hpp +40 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_forward.hpp +52 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_has_gcc_intrinsics.hpp +27 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_has_sync_intrinsics.hpp +69 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_interlocked.hpp +173 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_noexcept.hpp +48 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_nullptr_t.hpp +45 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_obsolete.hpp +32 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_thread_pause.hpp +51 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_thread_sleep.hpp +104 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_thread_yield.hpp +100 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_typeinfo_.hpp +58 -0
- package/react-native/boost/boost/smart_ptr/detail/sp_win32_sleep.hpp +49 -0
- package/react-native/boost/boost/smart_ptr/intrusive_ptr.hpp +409 -0
- package/react-native/boost/boost/smart_ptr/intrusive_ref_counter.hpp +188 -0
- package/react-native/cpp/include/Attachment.h +16 -0
- package/react-native/cpp/include/Authentication.h +23 -0
- package/react-native/cpp/include/Collection.h +13 -0
- package/react-native/cpp/include/DQL.h +21 -0
- package/react-native/cpp/include/Document.h +17 -0
- package/react-native/cpp/include/Identity.h +17 -0
- package/react-native/cpp/include/Lifecycle.h +16 -0
- package/react-native/cpp/include/LiveQuery.h +17 -0
- package/react-native/cpp/include/Logger.h +22 -0
- package/react-native/cpp/include/Misc.h +26 -0
- package/react-native/cpp/include/Presence.h +14 -0
- package/react-native/cpp/include/RetainableState.h +24 -0
- package/react-native/cpp/include/SmallPeerInfo.h +17 -0
- package/react-native/cpp/include/Transports.h +25 -0
- package/react-native/cpp/include/TypedArray.hpp +167 -0
- package/react-native/cpp/include/Utils.h +61 -0
- package/react-native/cpp/include/main.h +10 -0
- package/react-native/cpp/src/Attachment.cpp +86 -0
- package/react-native/cpp/src/Authentication.cpp +224 -0
- package/react-native/cpp/src/Collection.cpp +54 -0
- package/react-native/cpp/src/DQL.cpp +254 -0
- package/react-native/cpp/src/Document.cpp +146 -0
- package/react-native/cpp/src/Identity.cpp +123 -0
- package/react-native/cpp/src/Lifecycle.cpp +75 -0
- package/react-native/cpp/src/LiveQuery.cpp +64 -0
- package/react-native/cpp/src/Logger.cpp +200 -0
- package/react-native/cpp/src/Misc.cpp +271 -0
- package/react-native/cpp/src/Presence.cpp +77 -0
- package/react-native/cpp/src/RetainableState.cpp +15 -0
- package/react-native/cpp/src/SmallPeerInfo.cpp +108 -0
- package/react-native/cpp/src/Transports.cpp +270 -0
- package/react-native/cpp/src/TypedArray.cpp +303 -0
- package/react-native/cpp/src/Utils.cpp +138 -0
- package/react-native/cpp/src/main.cpp +149 -0
- package/react-native/dittoffi/dittoffi.h +4698 -0
- package/react-native/dittoffi/ifaddrs.cpp +385 -0
- package/react-native/dittoffi/ifaddrs.h +206 -0
- package/react-native/ios/DittoRNSDK.h +7 -0
- package/react-native/ios/DittoRNSDK.mm +107 -0
- package/react-native/ios/YeetJSIUtils.h +60 -0
- package/react-native/ios/YeetJSIUtils.mm +196 -0
- package/react-native/lib/commonjs/ditto.rn.js +93 -0
- package/react-native/lib/commonjs/ditto.rn.js.map +1 -0
- package/react-native/lib/commonjs/index.js +14 -0
- package/react-native/lib/commonjs/index.js.map +1 -0
- package/react-native/lib/module/ditto.rn.js +83 -0
- package/react-native/lib/module/ditto.rn.js.map +1 -0
- package/react-native/lib/module/index.js +13 -0
- package/react-native/lib/module/index.js.map +1 -0
- package/react-native/lib/typescript/ditto.rn.d.ts +15 -0
- package/react-native/lib/typescript/ditto.rn.d.ts.map +1 -0
- package/react-native/lib/typescript/index.d.ts +1 -0
- package/react-native/lib/typescript/index.d.ts.map +1 -0
- package/react-native/scripts/ruby/include_local_boost.rb +78 -0
- package/react-native/src/ditto.rn.ts +91 -0
- package/react-native/src/environment/environment.fallback.ts +4 -0
- package/react-native/src/index.ts +26 -0
- package/react-native/src/sources/@cbor-redux.ts +2 -0
- package/react-native/src/sources/@ditto.core.ts +1 -0
- package/react-native/src/sources/@environment.ts +2 -0
- package/react-native/src/sources/attachment-fetch-event.ts +54 -0
- package/react-native/src/sources/attachment-fetcher-manager.ts +129 -0
- package/react-native/src/sources/attachment-fetcher.ts +124 -0
- package/react-native/src/sources/attachment-token.ts +48 -0
- package/react-native/src/sources/attachment.ts +59 -0
- package/react-native/src/sources/augment.ts +89 -0
- package/react-native/src/sources/authenticator.ts +314 -0
- package/react-native/src/sources/base-pending-cursor-operation.ts +237 -0
- package/react-native/src/sources/base-pending-id-specific-operation.ts +109 -0
- package/react-native/src/sources/bridge.ts +549 -0
- package/react-native/src/sources/build-time-constants.ts +4 -0
- package/react-native/src/sources/cbor.ts +35 -0
- package/react-native/src/sources/collection-interface.ts +67 -0
- package/react-native/src/sources/collection.ts +212 -0
- package/react-native/src/sources/collections-event.ts +99 -0
- package/react-native/src/sources/counter.ts +77 -0
- package/react-native/src/sources/ditto.ts +945 -0
- package/react-native/src/sources/document-id.ts +159 -0
- package/react-native/src/sources/document-path.ts +303 -0
- package/react-native/src/sources/document.ts +192 -0
- package/react-native/src/sources/epilogue.ts +24 -0
- package/react-native/src/sources/error-codes.ts +52 -0
- package/react-native/src/sources/error.ts +203 -0
- package/react-native/src/sources/essentials.ts +53 -0
- package/react-native/src/sources/ffi-error.ts +117 -0
- package/react-native/src/sources/ffi.ts +1972 -0
- package/react-native/src/sources/identity.ts +163 -0
- package/react-native/src/sources/init.ts +70 -0
- package/react-native/src/sources/internal.ts +113 -0
- package/react-native/src/sources/keep-alive.ts +69 -0
- package/react-native/src/sources/key-path.ts +195 -0
- package/react-native/src/sources/live-query-event.ts +208 -0
- package/react-native/src/sources/live-query-manager.ts +101 -0
- package/react-native/src/sources/live-query.ts +164 -0
- package/react-native/src/sources/logger.ts +196 -0
- package/react-native/src/sources/observer-manager.ts +175 -0
- package/react-native/src/sources/observer.ts +77 -0
- package/react-native/src/sources/pending-collections-operation.ts +232 -0
- package/react-native/src/sources/pending-cursor-operation.ts +218 -0
- package/react-native/src/sources/pending-id-specific-operation.ts +216 -0
- package/react-native/src/sources/presence-manager.ts +160 -0
- package/react-native/src/sources/presence.ts +238 -0
- package/react-native/src/sources/query-result-item.ts +116 -0
- package/react-native/src/sources/query-result.ts +55 -0
- package/react-native/src/sources/register.ts +92 -0
- package/react-native/src/sources/small-peer-info.ts +176 -0
- package/react-native/src/sources/static-tcp-client.ts +6 -0
- package/react-native/src/sources/store-observer.ts +176 -0
- package/react-native/src/sources/store.ts +365 -0
- package/react-native/src/sources/subscription-manager.ts +98 -0
- package/react-native/src/sources/subscription.ts +88 -0
- package/react-native/src/sources/sync-subscription.ts +90 -0
- package/react-native/src/sources/sync.ts +495 -0
- package/react-native/src/sources/test-helpers.ts +24 -0
- package/react-native/src/sources/transport-conditions-manager.ts +104 -0
- package/react-native/src/sources/transport-config.ts +428 -0
- package/react-native/src/sources/update-result.ts +66 -0
- package/react-native/src/sources/update-results-map.ts +57 -0
- package/react-native/src/sources/websocket-client.ts +6 -0
- package/react-native/src/sources/write-transaction-collection.ts +122 -0
- package/react-native/src/sources/write-transaction-pending-cursor-operation.ts +101 -0
- package/react-native/src/sources/write-transaction-pending-id-specific-operation.ts +72 -0
- package/react-native/src/sources/write-transaction.ts +119 -0
- package/react-native.config.js +9 -0
- package/types/ditto.d.ts +1230 -798
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
#import "DittoRNSDK.h"
|
|
2
|
+
#import <React/RCTBridge+Private.h>
|
|
3
|
+
#import <React/RCTUtils.h>
|
|
4
|
+
#import <jsi/jsi.h>
|
|
5
|
+
#import "main.h"
|
|
6
|
+
#import <sys/utsname.h>
|
|
7
|
+
#import "YeetJSIUtils.h"
|
|
8
|
+
#import <React/RCTBridge+Private.h>
|
|
9
|
+
#import "TypedArray.hpp"
|
|
10
|
+
|
|
11
|
+
using namespace facebook::jsi;
|
|
12
|
+
|
|
13
|
+
@implementation DittoRNSDK
|
|
14
|
+
|
|
15
|
+
@synthesize bridge = _bridge;
|
|
16
|
+
@synthesize methodQueue = _methodQueue;
|
|
17
|
+
|
|
18
|
+
RCT_EXPORT_MODULE()
|
|
19
|
+
|
|
20
|
+
+ (BOOL)requiresMainQueueSetup
|
|
21
|
+
{
|
|
22
|
+
return YES;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(install)
|
|
26
|
+
{
|
|
27
|
+
RCTBridge* bridge = [RCTBridge currentBridge];
|
|
28
|
+
RCTCxxBridge* cxxBridge = (RCTCxxBridge*)bridge;
|
|
29
|
+
Runtime *jsiRuntime = (Runtime *) cxxBridge.runtime;
|
|
30
|
+
|
|
31
|
+
sharedjsi::install(*jsiRuntime);
|
|
32
|
+
install(*jsiRuntime);
|
|
33
|
+
|
|
34
|
+
return @true;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
static void install(jsi::Runtime &jsiRuntime) {
|
|
38
|
+
auto getDeviceName = Function::createFromHostFunction(jsiRuntime,
|
|
39
|
+
PropNameID::forAscii(jsiRuntime,
|
|
40
|
+
"getDeviceName"),
|
|
41
|
+
0,
|
|
42
|
+
[](Runtime &runtime,
|
|
43
|
+
const Value &thisValue,
|
|
44
|
+
const Value *arguments,
|
|
45
|
+
size_t count) -> Value {
|
|
46
|
+
|
|
47
|
+
return convertNSStringToJSIString(runtime, [[UIDevice currentDevice] name]);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
jsiRuntime.global().setProperty(jsiRuntime, "getDeviceName", std::move(getDeviceName));
|
|
51
|
+
|
|
52
|
+
auto createDirectory = Function::createFromHostFunction(jsiRuntime,
|
|
53
|
+
PropNameID::forAscii(jsiRuntime,
|
|
54
|
+
"createDirectory"),
|
|
55
|
+
0,
|
|
56
|
+
[](Runtime &runtime,
|
|
57
|
+
const Value &thisValue,
|
|
58
|
+
const Value *arguments,
|
|
59
|
+
size_t count) -> Value {
|
|
60
|
+
|
|
61
|
+
NSFileManager *fileManager = [NSFileManager defaultManager];
|
|
62
|
+
NSString *path = convertJSIStringToNSString(runtime, arguments[0].toString(runtime));
|
|
63
|
+
NSString *finalPath = path;
|
|
64
|
+
|
|
65
|
+
if (![path hasPrefix:@"/"]) {
|
|
66
|
+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
67
|
+
NSString *documentsDirectory = [paths objectAtIndex:0];
|
|
68
|
+
finalPath = [documentsDirectory stringByAppendingPathComponent:path];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
if (![fileManager fileExistsAtPath:finalPath]) {
|
|
72
|
+
NSError *error;
|
|
73
|
+
[fileManager createDirectoryAtPath:finalPath withIntermediateDirectories:YES attributes:nil error:&error];
|
|
74
|
+
if (error) {
|
|
75
|
+
NSLog(@"Error creating directory: %@", error.localizedDescription);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return convertNSStringToJSIString(runtime, finalPath);
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
jsiRuntime.global().setProperty(jsiRuntime, "createDirectory", std::move(createDirectory));
|
|
83
|
+
|
|
84
|
+
auto getRandomValues = jsi::Function::createFromHostFunction(jsiRuntime,
|
|
85
|
+
jsi::PropNameID::forUtf8(jsiRuntime, "getRandomValues"),
|
|
86
|
+
1,
|
|
87
|
+
[](jsi::Runtime& runtime,
|
|
88
|
+
const jsi::Value& thisArg,
|
|
89
|
+
const jsi::Value* args,
|
|
90
|
+
size_t count) -> jsi::Value {
|
|
91
|
+
TypedArrayBase typedArrayBase(runtime, args[0].asObject(runtime));
|
|
92
|
+
auto byteLength = typedArrayBase.byteLength(runtime);
|
|
93
|
+
|
|
94
|
+
NSMutableData *data = [NSMutableData dataWithLength:byteLength];
|
|
95
|
+
int result = SecRandomCopyBytes(kSecRandomDefault, byteLength, data.mutableBytes);
|
|
96
|
+
if (result != errSecSuccess) { }
|
|
97
|
+
|
|
98
|
+
auto typedArray = TypedArray<TypedArrayKind::Uint16Array>(runtime, byteLength);
|
|
99
|
+
auto arrayBuffer = typedArray.getBuffer(runtime);
|
|
100
|
+
memcpy(arrayBuffer.data(runtime), data.bytes, data.length);
|
|
101
|
+
return typedArray;
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
jsiRuntime.global().setProperty(jsiRuntime, "getRandomValues", std::move(getRandomValues));
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
//
|
|
2
|
+
// YeetJSIUTils.h
|
|
3
|
+
// yeet
|
|
4
|
+
//
|
|
5
|
+
// Created by Jarred WSumner on 1/30/20.
|
|
6
|
+
// Copyright © 2020 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#import <Foundation/Foundation.h>
|
|
10
|
+
#import <jsi/jsi.h>
|
|
11
|
+
#import <React/RCTBridgeModule.h>
|
|
12
|
+
|
|
13
|
+
using namespace facebook;
|
|
14
|
+
/**
|
|
15
|
+
* All static helper functions are ObjC++ specific.
|
|
16
|
+
*/
|
|
17
|
+
jsi::Value convertNSNumberToJSIBoolean(jsi::Runtime &runtime, NSNumber *value);
|
|
18
|
+
jsi::Value convertNSNumberToJSINumber(jsi::Runtime &runtime, NSNumber *value);
|
|
19
|
+
jsi::String convertNSStringToJSIString(jsi::Runtime &runtime, NSString *value);
|
|
20
|
+
jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value);;
|
|
21
|
+
jsi::Object convertNSDictionaryToJSIObject(jsi::Runtime &runtime, NSDictionary *value);
|
|
22
|
+
jsi::Array convertNSArrayToJSIArray(jsi::Runtime &runtime, NSArray *value);
|
|
23
|
+
std::vector<jsi::Value> convertNSArrayToStdVector(jsi::Runtime &runtime, NSArray *value);
|
|
24
|
+
jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value);
|
|
25
|
+
id convertJSIValueToObjCObject(
|
|
26
|
+
jsi::Runtime &runtime,
|
|
27
|
+
const jsi::Value &value);
|
|
28
|
+
NSString* convertJSIStringToNSString(jsi::Runtime &runtime, const jsi::String &value);
|
|
29
|
+
NSArray* convertJSIArrayToNSArray(
|
|
30
|
+
jsi::Runtime &runtime,
|
|
31
|
+
const jsi::Array &value);
|
|
32
|
+
NSDictionary *convertJSIObjectToNSDictionary(
|
|
33
|
+
jsi::Runtime &runtime,
|
|
34
|
+
const jsi::Object &value);
|
|
35
|
+
RCTResponseSenderBlock convertJSIFunctionToCallback(
|
|
36
|
+
jsi::Runtime &runtime,
|
|
37
|
+
const jsi::Function &value);
|
|
38
|
+
id convertJSIValueToObjCObject(
|
|
39
|
+
jsi::Runtime &runtime,
|
|
40
|
+
const jsi::Value &value);
|
|
41
|
+
RCTResponseSenderBlock convertJSIFunctionToCallback(
|
|
42
|
+
jsi::Runtime &runtime,
|
|
43
|
+
const jsi::Function &value);
|
|
44
|
+
|
|
45
|
+
struct Promise {
|
|
46
|
+
Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject);
|
|
47
|
+
|
|
48
|
+
void resolve(const jsi::Value &result);
|
|
49
|
+
void reject(const std::string &error);
|
|
50
|
+
|
|
51
|
+
jsi::Runtime &runtime_;
|
|
52
|
+
jsi::Function resolve_;
|
|
53
|
+
jsi::Function reject_;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
using PromiseSetupFunctionType =
|
|
57
|
+
std::function<void(jsi::Runtime &rt, std::shared_ptr<Promise>)>;
|
|
58
|
+
jsi::Value createPromiseAsJSIValue(
|
|
59
|
+
jsi::Runtime &rt,
|
|
60
|
+
const PromiseSetupFunctionType func);
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
//
|
|
2
|
+
// REAJsiUtilities.cpp
|
|
3
|
+
// RNReanimated
|
|
4
|
+
//
|
|
5
|
+
// Created by Christian Falch on 25/04/2019.
|
|
6
|
+
// Copyright © 2019 Facebook. All rights reserved.
|
|
7
|
+
//
|
|
8
|
+
|
|
9
|
+
#include "YeetJSIUtils.h"
|
|
10
|
+
#import <React/RCTConvert.h>
|
|
11
|
+
#import <React/RCTBridgeModule.h>
|
|
12
|
+
//#import <ReactCommon/TurboModuleUtils.h>
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* All helper functions are ObjC++ specific.
|
|
16
|
+
*/
|
|
17
|
+
jsi::Value convertNSNumberToJSIBoolean(jsi::Runtime &runtime, NSNumber *value)
|
|
18
|
+
{
|
|
19
|
+
return jsi::Value((bool)[value boolValue]);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
jsi::Value convertNSNumberToJSINumber(jsi::Runtime &runtime, NSNumber *value)
|
|
23
|
+
{
|
|
24
|
+
return jsi::Value([value doubleValue]);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
jsi::String convertNSStringToJSIString(jsi::Runtime &runtime, NSString *value)
|
|
28
|
+
{
|
|
29
|
+
return jsi::String::createFromUtf8(runtime, [value UTF8String] ?: "");
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value);
|
|
33
|
+
jsi::Object convertNSDictionaryToJSIObject(jsi::Runtime &runtime, NSDictionary *value)
|
|
34
|
+
{
|
|
35
|
+
jsi::Object result = jsi::Object(runtime);
|
|
36
|
+
for (NSString *k in value) {
|
|
37
|
+
result.setProperty(runtime, [k UTF8String], convertObjCObjectToJSIValue(runtime, value[k]));
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
jsi::Array convertNSArrayToJSIArray(jsi::Runtime &runtime, NSArray *value)
|
|
43
|
+
{
|
|
44
|
+
jsi::Array result = jsi::Array(runtime, value.count);
|
|
45
|
+
for (size_t i = 0; i < value.count; i++) {
|
|
46
|
+
result.setValueAtIndex(runtime, i, convertObjCObjectToJSIValue(runtime, value[i]));
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
std::vector<jsi::Value> convertNSArrayToStdVector(jsi::Runtime &runtime, NSArray *value)
|
|
52
|
+
{
|
|
53
|
+
std::vector<jsi::Value> result;
|
|
54
|
+
for (size_t i = 0; i < value.count; i++) {
|
|
55
|
+
result.emplace_back(convertObjCObjectToJSIValue(runtime, value[i]));
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
jsi::Value convertObjCObjectToJSIValue(jsi::Runtime &runtime, id value)
|
|
61
|
+
{
|
|
62
|
+
if ([value isKindOfClass:[NSString class]]) {
|
|
63
|
+
return convertNSStringToJSIString(runtime, (NSString *)value);
|
|
64
|
+
} else if ([value isKindOfClass:[NSNumber class]]) {
|
|
65
|
+
if ([value isKindOfClass:[@YES class]]) {
|
|
66
|
+
return convertNSNumberToJSIBoolean(runtime, (NSNumber *)value);
|
|
67
|
+
}
|
|
68
|
+
return convertNSNumberToJSINumber(runtime, (NSNumber *)value);
|
|
69
|
+
} else if ([value isKindOfClass:[NSDictionary class]]) {
|
|
70
|
+
return convertNSDictionaryToJSIObject(runtime, (NSDictionary *)value);
|
|
71
|
+
} else if ([value isKindOfClass:[NSArray class]]) {
|
|
72
|
+
return convertNSArrayToJSIArray(runtime, (NSArray *)value);
|
|
73
|
+
} else if (value == (id)kCFNull) {
|
|
74
|
+
return jsi::Value::null();
|
|
75
|
+
}
|
|
76
|
+
return jsi::Value::undefined();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
id convertJSIValueToObjCObject(
|
|
80
|
+
jsi::Runtime &runtime,
|
|
81
|
+
const jsi::Value &value);
|
|
82
|
+
NSString *convertJSIStringToNSString(jsi::Runtime &runtime, const jsi::String &value)
|
|
83
|
+
{
|
|
84
|
+
return [NSString stringWithUTF8String:value.utf8(runtime).c_str()];
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
NSArray *convertJSIArrayToNSArray(
|
|
88
|
+
jsi::Runtime &runtime,
|
|
89
|
+
const jsi::Array &value)
|
|
90
|
+
{
|
|
91
|
+
size_t size = value.size(runtime);
|
|
92
|
+
NSMutableArray *result = [NSMutableArray new];
|
|
93
|
+
for (size_t i = 0; i < size; i++) {
|
|
94
|
+
// Insert kCFNull when it's `undefined` value to preserve the indices.
|
|
95
|
+
[result
|
|
96
|
+
addObject:convertJSIValueToObjCObject(runtime, value.getValueAtIndex(runtime, i)) ?: (id)kCFNull];
|
|
97
|
+
}
|
|
98
|
+
return [result copy];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
NSDictionary *convertJSIObjectToNSDictionary(
|
|
102
|
+
jsi::Runtime &runtime,
|
|
103
|
+
const jsi::Object &value)
|
|
104
|
+
{
|
|
105
|
+
jsi::Array propertyNames = value.getPropertyNames(runtime);
|
|
106
|
+
size_t size = propertyNames.size(runtime);
|
|
107
|
+
NSMutableDictionary *result = [NSMutableDictionary new];
|
|
108
|
+
for (size_t i = 0; i < size; i++) {
|
|
109
|
+
jsi::String name = propertyNames.getValueAtIndex(runtime, i).getString(runtime);
|
|
110
|
+
NSString *k = convertJSIStringToNSString(runtime, name);
|
|
111
|
+
id v = convertJSIValueToObjCObject(runtime, value.getProperty(runtime, name));
|
|
112
|
+
if (v) {
|
|
113
|
+
result[k] = v;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
return [result copy];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
RCTResponseSenderBlock convertJSIFunctionToCallback(
|
|
120
|
+
jsi::Runtime &runtime,
|
|
121
|
+
const jsi::Function &value)
|
|
122
|
+
{
|
|
123
|
+
__block auto cb = value.getFunction(runtime);
|
|
124
|
+
|
|
125
|
+
return ^(NSArray *responses) {
|
|
126
|
+
cb.call(runtime, convertNSArrayToJSIArray(runtime, responses), 2);
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
id convertJSIValueToObjCObject(
|
|
131
|
+
jsi::Runtime &runtime,
|
|
132
|
+
const jsi::Value &value)
|
|
133
|
+
{
|
|
134
|
+
if (value.isUndefined() || value.isNull()) {
|
|
135
|
+
return nil;
|
|
136
|
+
}
|
|
137
|
+
if (value.isBool()) {
|
|
138
|
+
return @(value.getBool());
|
|
139
|
+
}
|
|
140
|
+
if (value.isNumber()) {
|
|
141
|
+
return @(value.getNumber());
|
|
142
|
+
}
|
|
143
|
+
if (value.isString()) {
|
|
144
|
+
return convertJSIStringToNSString(runtime, value.getString(runtime));
|
|
145
|
+
}
|
|
146
|
+
if (value.isObject()) {
|
|
147
|
+
jsi::Object o = value.getObject(runtime);
|
|
148
|
+
if (o.isArray(runtime)) {
|
|
149
|
+
return convertJSIArrayToNSArray(runtime, o.getArray(runtime));
|
|
150
|
+
}
|
|
151
|
+
if (o.isFunction(runtime)) {
|
|
152
|
+
return convertJSIFunctionToCallback(runtime, std::move(o.getFunction(runtime)));
|
|
153
|
+
}
|
|
154
|
+
return convertJSIObjectToNSDictionary(runtime, o);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
throw std::runtime_error("Unsupported jsi::jsi::Value kind");
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
Promise::Promise(jsi::Runtime &rt, jsi::Function resolve, jsi::Function reject)
|
|
161
|
+
: runtime_(rt), resolve_(std::move(resolve)), reject_(std::move(reject)) {}
|
|
162
|
+
|
|
163
|
+
void Promise::resolve(const jsi::Value &result) {
|
|
164
|
+
resolve_.call(runtime_, result);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
void Promise::reject(const std::string &message) {
|
|
168
|
+
jsi::Object error(runtime_);
|
|
169
|
+
error.setProperty(
|
|
170
|
+
runtime_, "message", jsi::String::createFromUtf8(runtime_, message));
|
|
171
|
+
reject_.call(runtime_, error);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
jsi::Value createPromiseAsJSIValue(
|
|
175
|
+
jsi::Runtime &rt,
|
|
176
|
+
const PromiseSetupFunctionType func) {
|
|
177
|
+
jsi::Function JSPromise = rt.global().getPropertyAsFunction(rt, "Promise");
|
|
178
|
+
jsi::Function fn = jsi::Function::createFromHostFunction(
|
|
179
|
+
rt,
|
|
180
|
+
jsi::PropNameID::forAscii(rt, "fn"),
|
|
181
|
+
2,
|
|
182
|
+
[func](
|
|
183
|
+
jsi::Runtime &rt2,
|
|
184
|
+
const jsi::Value &thisVal,
|
|
185
|
+
const jsi::Value *args,
|
|
186
|
+
size_t count) {
|
|
187
|
+
jsi::Function resolve = args[0].getObject(rt2).getFunction(rt2);
|
|
188
|
+
jsi::Function reject = args[1].getObject(rt2).getFunction(rt2);
|
|
189
|
+
auto wrapper = std::make_shared<Promise>(
|
|
190
|
+
rt2, std::move(resolve), std::move(reject));
|
|
191
|
+
func(rt2, wrapper);
|
|
192
|
+
return jsi::Value::undefined();
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
return JSPromise.callAsConstructor(rt, fn);
|
|
196
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.boxCBytesIntoBuffer = boxCBytesIntoBuffer;
|
|
7
|
+
exports.boxCStringIntoString = boxCStringIntoString;
|
|
8
|
+
exports.ditto_sdk_transports_init = ditto_sdk_transports_init;
|
|
9
|
+
exports.getDeadlockTimeout = getDeadlockTimeout;
|
|
10
|
+
exports.getMissingAndroidPermissions = getMissingAndroidPermissions;
|
|
11
|
+
exports.setDeadlockTimeout = setDeadlockTimeout;
|
|
12
|
+
var _reactNative = require("react-native");
|
|
13
|
+
var _weakrefs = require("@ungap/weakrefs");
|
|
14
|
+
require("fastestsmallesttextencoderdecoder");
|
|
15
|
+
// HACK: We're currently filling weakrefs with a broken implementation that is
|
|
16
|
+
// leaking. (#10730)
|
|
17
|
+
// @ts-ignore No types provided by the 3rd party
|
|
18
|
+
// No need to define types for each of them as these will not be used anywhere,
|
|
19
|
+
// but rather just pollute and require maintenance. It's good to highlight that
|
|
20
|
+
// these will be exported, though.
|
|
21
|
+
const dittoCore = global;
|
|
22
|
+
const isLoaded = typeof dittoCore.getDeviceName === 'function';
|
|
23
|
+
if (!isLoaded) {
|
|
24
|
+
var _NativeModules$DittoR;
|
|
25
|
+
const result = (_NativeModules$DittoR = _reactNative.NativeModules.DittoRNSDK) === null || _NativeModules$DittoR === void 0 ? void 0 : _NativeModules$DittoR.install();
|
|
26
|
+
if (!result) {
|
|
27
|
+
throw new Error('JSI bindings were not installed for: DittoRNSDK Module');
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// We're queueing JSI background tasks and poll them at specific intervals,
|
|
31
|
+
// as JSI doesn't give us a proper solution (yet).
|
|
32
|
+
// TODO: Improve / fine-tune workaround. (#10685)
|
|
33
|
+
setInterval(() => {
|
|
34
|
+
dittoCore.ditto_tick();
|
|
35
|
+
}, 50);
|
|
36
|
+
|
|
37
|
+
// Stay as close as possible to the JS SDK with the API
|
|
38
|
+
// We have to rename the shim that has a different name.
|
|
39
|
+
if (typeof global.FinalizationRegistry === 'undefined' && typeof _weakrefs.FinalizationGroup !== 'undefined') {
|
|
40
|
+
global.FinalizationRegistry = _weakrefs.FinalizationGroup;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Export JSI methods.
|
|
45
|
+
Object.keys(dittoCore)
|
|
46
|
+
// we will provide our own decorated implementation.
|
|
47
|
+
.filter(key => key !== 'ditto_sdk_transports_init').forEach(key => {
|
|
48
|
+
exports[key] = dittoCore[key];
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
//
|
|
52
|
+
// Needed as for JS SDK API's.
|
|
53
|
+
//
|
|
54
|
+
|
|
55
|
+
// Decorated implementation with an extra step of setting the context for
|
|
56
|
+
// Transports to work on Android.
|
|
57
|
+
function ditto_sdk_transports_init(transportsErrorPointer) {
|
|
58
|
+
if (_reactNative.Platform.OS === 'android') {
|
|
59
|
+
const res = dittoCore.ditto_sdk_transports_set_android_context();
|
|
60
|
+
if (!res) {
|
|
61
|
+
throw new Error("Couldn't manage to set Android context with `ditto_sdk_transports_set_android_context()`");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return dittoCore.ditto_sdk_transports_init(transportsErrorPointer);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Get the list of missing Android permissions for syncing. The returned value
|
|
69
|
+
* can be passed directly to `PermissionsAndroid.requestMultiple()`.
|
|
70
|
+
*
|
|
71
|
+
* Returns an empty array on other platforms.
|
|
72
|
+
*/
|
|
73
|
+
function getMissingAndroidPermissions() {
|
|
74
|
+
if (_reactNative.Platform.OS !== 'android') {
|
|
75
|
+
return [];
|
|
76
|
+
}
|
|
77
|
+
return dittoCore.ditto_sdk_transports_android_missing_permissions();
|
|
78
|
+
}
|
|
79
|
+
function boxCStringIntoString(something) {
|
|
80
|
+
return something;
|
|
81
|
+
}
|
|
82
|
+
function boxCBytesIntoBuffer(cborBytes) {
|
|
83
|
+
// @ts-ignore
|
|
84
|
+
const bytes = dittoCore.sliceBoxedToUInt8Array(cborBytes);
|
|
85
|
+
return bytes ? new Uint8Array(bytes) : null;
|
|
86
|
+
}
|
|
87
|
+
function getDeadlockTimeout() {
|
|
88
|
+
return 0;
|
|
89
|
+
}
|
|
90
|
+
function setDeadlockTimeout(something) {
|
|
91
|
+
return something;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=ditto.rn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_weakrefs","dittoCore","global","isLoaded","getDeviceName","_NativeModules$DittoR","result","NativeModules","DittoRNSDK","install","Error","setInterval","ditto_tick","FinalizationRegistry","FinalizationGroup","Object","keys","filter","key","forEach","exports","ditto_sdk_transports_init","transportsErrorPointer","Platform","OS","res","ditto_sdk_transports_set_android_context","getMissingAndroidPermissions","ditto_sdk_transports_android_missing_permissions","boxCStringIntoString","something","boxCBytesIntoBuffer","cborBytes","bytes","sliceBoxedToUInt8Array","Uint8Array","getDeadlockTimeout","setDeadlockTimeout"],"sourceRoot":"../../src","sources":["ditto.rn.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAIA,IAAAC,SAAA,GAAAD,OAAA;AACAA,OAAA;AAJA;AACA;AACA;AAIA;AACA;AACA;AAmBA,MAAME,SAAS,GAAGC,MAAkC;AACpD,MAAMC,QAAQ,GAAG,OAAOF,SAAS,CAACG,aAAa,KAAK,UAAU;AAC9D,IAAI,CAACD,QAAQ,EAAE;EAAA,IAAAE,qBAAA;EACb,MAAMC,MAAM,IAAAD,qBAAA,GAAGE,0BAAa,CAACC,UAAU,cAAAH,qBAAA,uBAAxBA,qBAAA,CAA0BI,OAAO,CAAC,CAAC;EAElD,IAAI,CAACH,MAAM,EAAE;IACX,MAAM,IAAII,KAAK,CAAC,wDAAwD,CAAC;EAC3E;;EAEA;EACA;EACA;EACAC,WAAW,CAAC,MAAM;IAChBV,SAAS,CAACW,UAAU,CAAC,CAAC;EACxB,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA;EACA,IACE,OAAOV,MAAM,CAACW,oBAAoB,KAAK,WAAW,IAClD,OAAOC,2BAAiB,KAAK,WAAW,EACxC;IACAZ,MAAM,CAACW,oBAAoB,GAAGC,2BAAiB;EACjD;AACF;;AAEA;AACAC,MAAM,CAACC,IAAI,CAACf,SAAS;AACnB;AAAA,CACCgB,MAAM,CAAEC,GAAG,IAAKA,GAAG,KAAK,2BAA2B,CAAC,CACpDC,OAAO,CAAED,GAAG,IAAK;EAChBE,OAAO,CAACF,GAAG,CAAC,GAAGjB,SAAS,CAACiB,GAAG,CAAwB;AACtD,CAAC,CAAC;;AAEJ;AACA;AACA;;AAEA;AACA;AACO,SAASG,yBAAyBA,CACvCC,sBAA2B,EAClB;EACT,IAAIC,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;IAC7B,MAAMC,GAAG,GAAGxB,SAAS,CAACyB,wCAAwC,CAAC,CAAC;IAChE,IAAI,CAACD,GAAG,EAAE;MACR,MAAM,IAAIf,KAAK,CACb,0FACF,CAAC;IACH;EACF;EAEA,OAAOT,SAAS,CAACoB,yBAAyB,CAACC,sBAAsB,CAAC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACO,SAASK,4BAA4BA,CAAA,EAAiB;EAC3D,IAAIJ,qBAAQ,CAACC,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAO,EAAE;EACX;EACA,OAAOvB,SAAS,CAAC2B,gDAAgD,CAAC,CAAC;AACrE;AAEO,SAASC,oBAAoBA,CAACC,SAAc,EAAE;EACnD,OAAOA,SAAS;AAClB;AAEO,SAASC,mBAAmBA,CAACC,SAAc,EAAE;EAClD;EACA,MAAMC,KAAK,GAAGhC,SAAS,CAACiC,sBAAsB,CAACF,SAAS,CAAC;EACzD,OAAOC,KAAK,GAAG,IAAIE,UAAU,CAACF,KAAK,CAAC,GAAG,IAAI;AAC7C;AAEO,SAASG,kBAAkBA,CAAA,EAAW;EAC3C,OAAO,CAAC;AACV;AAEO,SAASC,kBAAkBA,CAACP,SAAc,EAAE;EACjD,OAAOA,SAAS;AAClB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export {getMissingAndroidPermissions} from './ditto.rn';
|
|
2
|
+
export {TransportConfig} from '../../sources/transport-config';
|
|
3
|
+
export {Ditto} from '../../sources/ditto';
|
|
4
|
+
export {Logger} from '../../sources/logger';
|
|
5
|
+
|
|
6
|
+
export type {AuthenticationHandler} from '../../sources/authenticator';
|
|
7
|
+
export type {Identity} from '../../sources/identity';
|
|
8
|
+
export type {QueryResult} from '../../sources/query-result';
|
|
9
|
+
export type {QueryResultItem} from '../../sources/query-result-item';
|
|
10
|
+
export type {LogLevel} from '../../sources/logger';
|
|
11
|
+
|
|
12
|
+
export * from '../../sources/epilogue';
|
|
13
|
+
('use strict');
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA;AAAA"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { NativeModules, Platform } from 'react-native';
|
|
2
|
+
// HACK: We're currently filling weakrefs with a broken implementation that is
|
|
3
|
+
// leaking. (#10730)
|
|
4
|
+
// @ts-ignore No types provided by the 3rd party
|
|
5
|
+
import { FinalizationGroup } from '@ungap/weakrefs';
|
|
6
|
+
import 'fastestsmallesttextencoderdecoder';
|
|
7
|
+
|
|
8
|
+
// No need to define types for each of them as these will not be used anywhere,
|
|
9
|
+
// but rather just pollute and require maintenance. It's good to highlight that
|
|
10
|
+
// these will be exported, though.
|
|
11
|
+
const dittoCore = global;
|
|
12
|
+
const isLoaded = typeof dittoCore.getDeviceName === 'function';
|
|
13
|
+
if (!isLoaded) {
|
|
14
|
+
var _NativeModules$DittoR;
|
|
15
|
+
const result = (_NativeModules$DittoR = NativeModules.DittoRNSDK) === null || _NativeModules$DittoR === void 0 ? void 0 : _NativeModules$DittoR.install();
|
|
16
|
+
if (!result) {
|
|
17
|
+
throw new Error('JSI bindings were not installed for: DittoRNSDK Module');
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// We're queueing JSI background tasks and poll them at specific intervals,
|
|
21
|
+
// as JSI doesn't give us a proper solution (yet).
|
|
22
|
+
// TODO: Improve / fine-tune workaround. (#10685)
|
|
23
|
+
setInterval(() => {
|
|
24
|
+
dittoCore.ditto_tick();
|
|
25
|
+
}, 50);
|
|
26
|
+
|
|
27
|
+
// Stay as close as possible to the JS SDK with the API
|
|
28
|
+
// We have to rename the shim that has a different name.
|
|
29
|
+
if (typeof global.FinalizationRegistry === 'undefined' && typeof FinalizationGroup !== 'undefined') {
|
|
30
|
+
global.FinalizationRegistry = FinalizationGroup;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Export JSI methods.
|
|
35
|
+
Object.keys(dittoCore)
|
|
36
|
+
// we will provide our own decorated implementation.
|
|
37
|
+
.filter(key => key !== 'ditto_sdk_transports_init').forEach(key => {
|
|
38
|
+
exports[key] = dittoCore[key];
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
//
|
|
42
|
+
// Needed as for JS SDK API's.
|
|
43
|
+
//
|
|
44
|
+
|
|
45
|
+
// Decorated implementation with an extra step of setting the context for
|
|
46
|
+
// Transports to work on Android.
|
|
47
|
+
export function ditto_sdk_transports_init(transportsErrorPointer) {
|
|
48
|
+
if (Platform.OS === 'android') {
|
|
49
|
+
const res = dittoCore.ditto_sdk_transports_set_android_context();
|
|
50
|
+
if (!res) {
|
|
51
|
+
throw new Error("Couldn't manage to set Android context with `ditto_sdk_transports_set_android_context()`");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return dittoCore.ditto_sdk_transports_init(transportsErrorPointer);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Get the list of missing Android permissions for syncing. The returned value
|
|
59
|
+
* can be passed directly to `PermissionsAndroid.requestMultiple()`.
|
|
60
|
+
*
|
|
61
|
+
* Returns an empty array on other platforms.
|
|
62
|
+
*/
|
|
63
|
+
export function getMissingAndroidPermissions() {
|
|
64
|
+
if (Platform.OS !== 'android') {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
return dittoCore.ditto_sdk_transports_android_missing_permissions();
|
|
68
|
+
}
|
|
69
|
+
export function boxCStringIntoString(something) {
|
|
70
|
+
return something;
|
|
71
|
+
}
|
|
72
|
+
export function boxCBytesIntoBuffer(cborBytes) {
|
|
73
|
+
// @ts-ignore
|
|
74
|
+
const bytes = dittoCore.sliceBoxedToUInt8Array(cborBytes);
|
|
75
|
+
return bytes ? new Uint8Array(bytes) : null;
|
|
76
|
+
}
|
|
77
|
+
export function getDeadlockTimeout() {
|
|
78
|
+
return 0;
|
|
79
|
+
}
|
|
80
|
+
export function setDeadlockTimeout(something) {
|
|
81
|
+
return something;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=ditto.rn.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","FinalizationGroup","dittoCore","global","isLoaded","getDeviceName","_NativeModules$DittoR","result","DittoRNSDK","install","Error","setInterval","ditto_tick","FinalizationRegistry","Object","keys","filter","key","forEach","exports","ditto_sdk_transports_init","transportsErrorPointer","OS","res","ditto_sdk_transports_set_android_context","getMissingAndroidPermissions","ditto_sdk_transports_android_missing_permissions","boxCStringIntoString","something","boxCBytesIntoBuffer","cborBytes","bytes","sliceBoxedToUInt8Array","Uint8Array","getDeadlockTimeout","setDeadlockTimeout"],"sourceRoot":"../../src","sources":["ditto.rn.ts"],"mappings":"AAAA,SAASA,aAAa,EAAEC,QAAQ,QAAyB,cAAc;AACvE;AACA;AACA;AACA,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,OAAO,mCAAmC;;AAE1C;AACA;AACA;AAmBA,MAAMC,SAAS,GAAGC,MAAkC;AACpD,MAAMC,QAAQ,GAAG,OAAOF,SAAS,CAACG,aAAa,KAAK,UAAU;AAC9D,IAAI,CAACD,QAAQ,EAAE;EAAA,IAAAE,qBAAA;EACb,MAAMC,MAAM,IAAAD,qBAAA,GAAGP,aAAa,CAACS,UAAU,cAAAF,qBAAA,uBAAxBA,qBAAA,CAA0BG,OAAO,CAAC,CAAC;EAElD,IAAI,CAACF,MAAM,EAAE;IACX,MAAM,IAAIG,KAAK,CAAC,wDAAwD,CAAC;EAC3E;;EAEA;EACA;EACA;EACAC,WAAW,CAAC,MAAM;IAChBT,SAAS,CAACU,UAAU,CAAC,CAAC;EACxB,CAAC,EAAE,EAAE,CAAC;;EAEN;EACA;EACA,IACE,OAAOT,MAAM,CAACU,oBAAoB,KAAK,WAAW,IAClD,OAAOZ,iBAAiB,KAAK,WAAW,EACxC;IACAE,MAAM,CAACU,oBAAoB,GAAGZ,iBAAiB;EACjD;AACF;;AAEA;AACAa,MAAM,CAACC,IAAI,CAACb,SAAS;AACnB;AAAA,CACCc,MAAM,CAAEC,GAAG,IAAKA,GAAG,KAAK,2BAA2B,CAAC,CACpDC,OAAO,CAAED,GAAG,IAAK;EAChBE,OAAO,CAACF,GAAG,CAAC,GAAGf,SAAS,CAACe,GAAG,CAAwB;AACtD,CAAC,CAAC;;AAEJ;AACA;AACA;;AAEA;AACA;AACA,OAAO,SAASG,yBAAyBA,CACvCC,sBAA2B,EAClB;EACT,IAAIrB,QAAQ,CAACsB,EAAE,KAAK,SAAS,EAAE;IAC7B,MAAMC,GAAG,GAAGrB,SAAS,CAACsB,wCAAwC,CAAC,CAAC;IAChE,IAAI,CAACD,GAAG,EAAE;MACR,MAAM,IAAIb,KAAK,CACb,0FACF,CAAC;IACH;EACF;EAEA,OAAOR,SAAS,CAACkB,yBAAyB,CAACC,sBAAsB,CAAC;AACpE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,4BAA4BA,CAAA,EAAiB;EAC3D,IAAIzB,QAAQ,CAACsB,EAAE,KAAK,SAAS,EAAE;IAC7B,OAAO,EAAE;EACX;EACA,OAAOpB,SAAS,CAACwB,gDAAgD,CAAC,CAAC;AACrE;AAEA,OAAO,SAASC,oBAAoBA,CAACC,SAAc,EAAE;EACnD,OAAOA,SAAS;AAClB;AAEA,OAAO,SAASC,mBAAmBA,CAACC,SAAc,EAAE;EAClD;EACA,MAAMC,KAAK,GAAG7B,SAAS,CAAC8B,sBAAsB,CAACF,SAAS,CAAC;EACzD,OAAOC,KAAK,GAAG,IAAIE,UAAU,CAACF,KAAK,CAAC,GAAG,IAAI;AAC7C;AAEA,OAAO,SAASG,kBAAkBA,CAAA,EAAW;EAC3C,OAAO,CAAC;AACV;AAEA,OAAO,SAASC,kBAAkBA,CAACP,SAAc,EAAE;EACjD,OAAOA,SAAS;AAClB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export {getMissingAndroidPermissions} from './ditto.rn';
|
|
2
|
+
export {TransportConfig} from '../../sources/transport-config';
|
|
3
|
+
export {Ditto} from '../../sources/ditto';
|
|
4
|
+
export {Logger} from '../../sources/logger';
|
|
5
|
+
|
|
6
|
+
export type {AuthenticationHandler} from '../../sources/authenticator';
|
|
7
|
+
export type {Identity} from '../../sources/identity';
|
|
8
|
+
export type {QueryResult} from '../../sources/query-result';
|
|
9
|
+
export type {QueryResultItem} from '../../sources/query-result-item';
|
|
10
|
+
export type {LogLevel} from '../../sources/logger';
|
|
11
|
+
|
|
12
|
+
export * from '../../sources/epilogue';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;;AAEA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Permission } from 'react-native';
|
|
2
|
+
import 'fastestsmallesttextencoderdecoder';
|
|
3
|
+
export declare function ditto_sdk_transports_init(transportsErrorPointer: any): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Get the list of missing Android permissions for syncing. The returned value
|
|
6
|
+
* can be passed directly to `PermissionsAndroid.requestMultiple()`.
|
|
7
|
+
*
|
|
8
|
+
* Returns an empty array on other platforms.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getMissingAndroidPermissions(): Permission[];
|
|
11
|
+
export declare function boxCStringIntoString(something: any): any;
|
|
12
|
+
export declare function boxCBytesIntoBuffer(cborBytes: any): Uint8Array | null;
|
|
13
|
+
export declare function getDeadlockTimeout(): number;
|
|
14
|
+
export declare function setDeadlockTimeout(something: any): any;
|
|
15
|
+
//# sourceMappingURL=ditto.rn.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ditto.rn.d.ts","sourceRoot":"","sources":["../../src/ditto.rn.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAKxE,OAAO,mCAAmC,CAAC;AA+D3C,wBAAgB,yBAAyB,CACvC,sBAAsB,EAAE,GAAG,GAC1B,OAAO,CAWT;AAED;;;;;GAKG;AACH,wBAAgB,4BAA4B,IAAI,UAAU,EAAE,CAK3D;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,GAAG,OAElD;AAED,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,GAAG,qBAIjD;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,GAAG,OAEhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":""}
|