@dittolive/ditto 4.8.2 → 4.9.0-alpha.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.
- package/DittoReactNative.podspec +0 -2
- package/README.md +2 -2
- package/node/ditto.cjs.js +952 -532
- 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-arm64.node +0 -0
- package/node/ditto.linux-x64.node +0 -0
- package/node/ditto.win32-x64.node +0 -0
- package/package.json +3 -3
- package/react-native/android/CMakeLists.txt +8 -10
- package/react-native/android/build.gradle +5 -5
- package/react-native/android/dittoffi/src/attachment_observer_interfaces.cpp +1 -0
- package/react-native/android/dittoffi/src/attachment_observer_interfaces.h +75 -0
- package/react-native/android/dittoffi/src/connection_request.cpp +1 -0
- package/react-native/android/dittoffi/src/connection_request.h +56 -0
- package/react-native/android/dittoffi/src/crash_reporter.cpp +1 -0
- package/react-native/android/dittoffi/src/crash_reporter.h +40 -0
- package/react-native/android/dittoffi/src/dittoffi_java.i +42 -0
- package/react-native/android/dittoffi/src/dittomesh_java.i +16 -0
- package/react-native/android/dittoffi/src/dittostore_java.i +430 -0
- package/react-native/android/dittoffi/src/live_query_java_interfaces.cpp +1 -0
- package/react-native/android/dittoffi/src/live_query_java_interfaces.h +64 -0
- package/react-native/android/dittoffi/src/logger_cb.cpp +3 -0
- package/react-native/android/dittoffi/src/logger_cb.h +47 -0
- package/react-native/android/dittoffi/src/logger_export.cpp +1 -0
- package/react-native/android/dittoffi/src/logger_export.h +37 -0
- package/react-native/android/dittoffi/src/mesh_java_interfaces.cpp +1 -0
- package/react-native/android/dittoffi/src/mesh_java_interfaces.h +664 -0
- package/react-native/android/dittoffi/src/presence.cpp +1 -0
- package/react-native/android/dittoffi/src/presence.h +82 -0
- package/react-native/android/dittoffi/src/retainable.cpp +1 -0
- package/react-native/android/dittoffi/src/retainable.h +47 -0
- package/react-native/android/dittoffi/src/store_observer.cpp +1 -0
- package/react-native/android/dittoffi/src/store_observer.h +57 -0
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +1 -1
- package/react-native/cpp/include/Authentication.h +1 -0
- package/react-native/cpp/include/Logger.h +1 -0
- package/react-native/cpp/src/Authentication.cpp +25 -0
- package/react-native/cpp/src/Logger.cpp +50 -6
- package/react-native/cpp/src/main.cpp +2 -0
- package/react-native/ditto.es6.js +1 -1
- package/types/ditto.d.ts +3010 -2763
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
- package/react-native/dittoffi/dittoffi.h +0 -4872
- /package/react-native/{dittoffi → android/dittoffi/src}/ifaddrs.cpp +0 -0
- /package/react-native/{dittoffi → android/dittoffi/src}/ifaddrs.h +0 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dittolive/ditto",
|
|
3
|
-
"version": "4.
|
|
4
|
-
"description": "Ditto is a cross-platform
|
|
3
|
+
"version": "4.9.0-alpha.1",
|
|
4
|
+
"description": "Ditto is a cross-platform SDK that allows apps to sync with and even without internet connectivity.",
|
|
5
5
|
"homepage": "https://ditto.live",
|
|
6
6
|
"license": "SEE LICENSE IN LICENSE.md",
|
|
7
7
|
|
|
@@ -48,6 +48,6 @@
|
|
|
48
48
|
},
|
|
49
49
|
|
|
50
50
|
"devDependencies": {
|
|
51
|
-
"serve": "^14.2.
|
|
51
|
+
"serve": "^14.2.3"
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -1,35 +1,33 @@
|
|
|
1
1
|
cmake_minimum_required(VERSION 3.9.0)
|
|
2
2
|
|
|
3
|
-
set
|
|
3
|
+
set(PACKAGE_NAME "dittorn")
|
|
4
4
|
project(PACKAGE_NAME)
|
|
5
|
-
set
|
|
5
|
+
set(BUILD_DIR ../../../)
|
|
6
6
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
|
7
7
|
set(CMAKE_CXX_STANDARD 17)
|
|
8
8
|
|
|
9
9
|
include_directories(
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
../cpp/include
|
|
11
|
+
dittoffi/src
|
|
12
12
|
)
|
|
13
13
|
|
|
14
|
-
file(GLOB SOURCES "../cpp/src/*.cpp")
|
|
14
|
+
file(GLOB SOURCES "../cpp/src/*.cpp" "dittoffi/src/*.cpp")
|
|
15
15
|
add_library(
|
|
16
16
|
${PACKAGE_NAME}
|
|
17
17
|
SHARED
|
|
18
18
|
${SOURCES}
|
|
19
|
-
../dittoffi/ifaddrs.cpp
|
|
20
19
|
./cpp-adapter.cpp
|
|
21
|
-
|
|
22
20
|
)
|
|
23
21
|
|
|
24
22
|
find_package(ReactAndroid REQUIRED CONFIG)
|
|
25
23
|
find_library(log-lib log)
|
|
26
24
|
|
|
27
|
-
add_library(
|
|
28
|
-
set_target_properties(
|
|
25
|
+
add_library(dittoffi SHARED IMPORTED)
|
|
26
|
+
set_target_properties(dittoffi PROPERTIES IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/dittoffi/libs/${ANDROID_ABI}/libdittoffi.so")
|
|
29
27
|
|
|
30
28
|
target_link_libraries(
|
|
31
29
|
${PACKAGE_NAME}
|
|
32
|
-
|
|
30
|
+
dittoffi
|
|
33
31
|
${log-lib}
|
|
34
32
|
ReactAndroid::jsi
|
|
35
33
|
android
|
|
@@ -118,11 +118,11 @@ dependencies {
|
|
|
118
118
|
//noinspection GradleDynamicVersion
|
|
119
119
|
implementation "com.facebook.react:react-native:+"
|
|
120
120
|
|
|
121
|
-
def aarFile = file('
|
|
121
|
+
def aarFile = file('dittoffi/aar/ditto.aar')
|
|
122
122
|
def aarExists = aarFile.exists()
|
|
123
123
|
|
|
124
124
|
if (aarExists) {
|
|
125
|
-
implementation files('
|
|
125
|
+
implementation files('dittoffi/aar/ditto.aar')
|
|
126
126
|
} else {
|
|
127
127
|
implementation "live.ditto:ditto:${project.version}"
|
|
128
128
|
}
|
|
@@ -133,10 +133,10 @@ task downloadBinaries {
|
|
|
133
133
|
def defaultArchitectures = ['arm64-v8a', 'armeabi-v7a', 'x86', 'x86_64']
|
|
134
134
|
|
|
135
135
|
defaultArchitectures.each { arch ->
|
|
136
|
-
def fileUrl = "https://software.ditto.live/react-native/ditto/${project.version}/android/${arch}/libdittoffi.
|
|
136
|
+
def fileUrl = "https://software.ditto.live/react-native/ditto/${project.version}/android/${arch}/libdittoffi.so"
|
|
137
137
|
|
|
138
|
-
new File("${project.projectDir}
|
|
139
|
-
def localFilePath = "${project.projectDir}
|
|
138
|
+
new File("${project.projectDir}/dittoffi/libs/${arch}").mkdirs()
|
|
139
|
+
def localFilePath = "${project.projectDir}/dittoffi/libs/${arch}/libdittoffi.so"
|
|
140
140
|
|
|
141
141
|
if (!new File(localFilePath).exists()) {
|
|
142
142
|
println "Downloading file for $arch: $fileUrl"
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#include "attachment_observer_interfaces.h"
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
extern "C" {
|
|
2
|
+
#include "dittoffi.h"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
#include "retainable.h"
|
|
6
|
+
|
|
7
|
+
#ifdef SWIG
|
|
8
|
+
%feature("director", assumeoverride=1) AttachmentObserverRust;
|
|
9
|
+
%apply(char *STRING, size_t LENGTH) { (const unsigned char *id_ptr, uintptr_t id_len) };
|
|
10
|
+
#endif
|
|
11
|
+
class AttachmentObserverRust: public Retainable {
|
|
12
|
+
public:
|
|
13
|
+
virtual ~AttachmentObserverRust() {}
|
|
14
|
+
virtual void completedEventHandler(
|
|
15
|
+
const struct AttachmentHandle *ah
|
|
16
|
+
) = 0;
|
|
17
|
+
|
|
18
|
+
virtual void progressEventHandler(
|
|
19
|
+
uint64_t downloadedBytes,
|
|
20
|
+
uint64_t totalBytes
|
|
21
|
+
) = 0;
|
|
22
|
+
|
|
23
|
+
virtual void deletedEventHandler(
|
|
24
|
+
) = 0;
|
|
25
|
+
|
|
26
|
+
static void invokeCompletedEventHandler(
|
|
27
|
+
void *ctx,
|
|
28
|
+
struct AttachmentHandle *ah
|
|
29
|
+
) {
|
|
30
|
+
auto inst = static_cast<AttachmentObserverRust*>(ctx);
|
|
31
|
+
return inst->completedEventHandler(
|
|
32
|
+
ah
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
static void invokeProgressEventHandler(
|
|
37
|
+
void *ctx,
|
|
38
|
+
uint64_t downloadedBytes,
|
|
39
|
+
uint64_t totalBytes
|
|
40
|
+
) {
|
|
41
|
+
auto inst = static_cast<AttachmentObserverRust*>(ctx);
|
|
42
|
+
return inst->progressEventHandler(
|
|
43
|
+
downloadedBytes,
|
|
44
|
+
totalBytes
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
static void invokeDeletedEventHandler(
|
|
49
|
+
void *ctx
|
|
50
|
+
) {
|
|
51
|
+
auto inst = static_cast<AttachmentObserverRust*>(ctx);
|
|
52
|
+
return inst->deletedEventHandler(
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
virtual CancelTokenResult_t resolve_attachment(
|
|
57
|
+
struct CDitto *ditto_raw,
|
|
58
|
+
const unsigned char *id_ptr,
|
|
59
|
+
uintptr_t id_len
|
|
60
|
+
) {
|
|
61
|
+
return ditto_resolve_attachment(
|
|
62
|
+
ditto_raw,
|
|
63
|
+
(slice_ref_uint8_t) {
|
|
64
|
+
.ptr = id_ptr,
|
|
65
|
+
.len = id_len,
|
|
66
|
+
},
|
|
67
|
+
this,
|
|
68
|
+
AttachmentObserverRust::invokeRetain,
|
|
69
|
+
AttachmentObserverRust::invokeRelease,
|
|
70
|
+
AttachmentObserverRust::invokeCompletedEventHandler,
|
|
71
|
+
AttachmentObserverRust::invokeProgressEventHandler,
|
|
72
|
+
AttachmentObserverRust::invokeDeletedEventHandler
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#include "connection_request.h"
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
extern "C" {
|
|
2
|
+
#include "dittoffi.h"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
#include "retainable.h"
|
|
6
|
+
|
|
7
|
+
#ifdef SWIG
|
|
8
|
+
%feature("director", assumeoverride=1) ConnectionRequestHandlerRust;
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
/** \brief
|
|
12
|
+
* Context object for Kotlin DittoConnectionRequestHandler which handles wiring up callbacks from
|
|
13
|
+
* Rust across the FFI boundary.
|
|
14
|
+
*/
|
|
15
|
+
class ConnectionRequestHandlerRust: public Retainable {
|
|
16
|
+
public:
|
|
17
|
+
virtual ~ConnectionRequestHandlerRust() {}
|
|
18
|
+
|
|
19
|
+
static void invokeEventHandler(
|
|
20
|
+
Erased_t const *ctx,
|
|
21
|
+
dittoffi_connection_request_t *connection_request
|
|
22
|
+
) {
|
|
23
|
+
auto inst = (ConnectionRequestHandlerRust *)ctx;
|
|
24
|
+
return inst->eventHandler(connection_request);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
virtual void eventHandler(
|
|
28
|
+
dittoffi_connection_request_t *connection_request
|
|
29
|
+
) = 0;
|
|
30
|
+
|
|
31
|
+
virtual void registerConnectionRequestHandler(
|
|
32
|
+
struct CDitto *ditto_raw,
|
|
33
|
+
ConnectionRequestHandlerRust *handler
|
|
34
|
+
) {
|
|
35
|
+
Erased_t* handler_pointer;
|
|
36
|
+
if (handler != nullptr) {
|
|
37
|
+
Retainable::invokeRetain(handler);
|
|
38
|
+
handler_pointer = (Erased_t *)handler;
|
|
39
|
+
} else {
|
|
40
|
+
handler_pointer = NULL; // Pass null to clear the handler
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
FfiConnectionRequestHandlerVTable_t const v_table = {
|
|
44
|
+
.release_vptr = (void (*)(Erased_t *)) ConnectionRequestHandlerRust::invokeRelease,
|
|
45
|
+
.retain_vptr = ConnectionRequestHandlerRust::invokeVirtualPtrRetain,
|
|
46
|
+
.on_connecting = ConnectionRequestHandlerRust::invokeEventHandler
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
VirtualPtr__Erased_ptr_FfiConnectionRequestHandlerVTable_t const ffi_handler = {
|
|
50
|
+
.ptr = handler_pointer,
|
|
51
|
+
.vtable = v_table
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
dittoffi_presence_set_connection_request_handler(ditto_raw, ffi_handler);
|
|
55
|
+
}
|
|
56
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#include "crash_reporter.h"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
extern "C" {
|
|
2
|
+
#include "dittoffi.h"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
#include "retainable.h"
|
|
6
|
+
|
|
7
|
+
#ifdef SWIG
|
|
8
|
+
%feature("director", assumeoverride=1) CrashReporterFfi;
|
|
9
|
+
#endif
|
|
10
|
+
|
|
11
|
+
class CrashReporterFfi: public Retainable {
|
|
12
|
+
public:
|
|
13
|
+
virtual ~CrashReporterFfi() {}
|
|
14
|
+
|
|
15
|
+
static void ffiInvokeReportCrashKotlinImplementation(
|
|
16
|
+
void *ctx,
|
|
17
|
+
dittoffi_panic_t *panic
|
|
18
|
+
) {
|
|
19
|
+
auto inst = (CrashReporterFfi *)ctx;
|
|
20
|
+
return inst->reportCrashKotlinImplementation(panic);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
virtual void reportCrashKotlinImplementation(
|
|
24
|
+
dittoffi_panic_t *panic
|
|
25
|
+
) = 0;
|
|
26
|
+
|
|
27
|
+
virtual void overrideCrashReporter(
|
|
28
|
+
struct CDitto *ditto_raw
|
|
29
|
+
) {
|
|
30
|
+
CrashReporterFfi * handler = this;
|
|
31
|
+
|
|
32
|
+
BoxDynFnMut1_void_dittoffi_panic_ptr_t ffiPanicHandler;
|
|
33
|
+
handler->retain();
|
|
34
|
+
ffiPanicHandler.env_ptr = handler;
|
|
35
|
+
ffiPanicHandler.call = CrashReporterFfi::ffiInvokeReportCrashKotlinImplementation;
|
|
36
|
+
ffiPanicHandler.free = CrashReporterFfi::invokeRelease;
|
|
37
|
+
|
|
38
|
+
dittoffi_override_crash_reporter(ffiPanicHandler);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* File: dittoffi_java.i */
|
|
2
|
+
%module(directors="1") dittoffi
|
|
3
|
+
|
|
4
|
+
%{
|
|
5
|
+
#ifdef __ANDROID__
|
|
6
|
+
#include <android/log.h>
|
|
7
|
+
#endif
|
|
8
|
+
%}
|
|
9
|
+
|
|
10
|
+
// `%include`s mean that SWIG processes the files and generates wrapper and
|
|
11
|
+
// proxy classes as appropriate for the types it encounters.
|
|
12
|
+
%{
|
|
13
|
+
#include "logger_cb.h"
|
|
14
|
+
#include "logger_export.h"
|
|
15
|
+
%}
|
|
16
|
+
// 🐉🐉
|
|
17
|
+
// Make sure to have this `%include` before that of dependent classes.
|
|
18
|
+
// SWIG won't directly error if you don't, but things will nonetheless
|
|
19
|
+
// break at runtime, which gets very hard to debug and diagnose. Fun™
|
|
20
|
+
// 🐉🐉
|
|
21
|
+
%include "retainable.h"
|
|
22
|
+
%include "logger_cb.h"
|
|
23
|
+
%include "logger_export.h"
|
|
24
|
+
%include "dittomesh_java.i"
|
|
25
|
+
%include "dittostore_java.i"
|
|
26
|
+
extern "C" {
|
|
27
|
+
%include "dittoffi.h"
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// imports
|
|
31
|
+
// http://www.swig.org/Doc4.0/Java.html#Java_imclass_pragmas
|
|
32
|
+
%pragma(java) jniclassimports=%{
|
|
33
|
+
import live.ditto.internal.NativeLibraryLoader;
|
|
34
|
+
%}
|
|
35
|
+
|
|
36
|
+
// class dittoffiJNI {
|
|
37
|
+
%pragma(java) jniclasscode=%{
|
|
38
|
+
static {
|
|
39
|
+
NativeLibraryLoader loader = new NativeLibraryLoader();
|
|
40
|
+
loader.loadDitto();
|
|
41
|
+
}
|
|
42
|
+
%}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
%{
|
|
2
|
+
#include "mesh_java_interfaces.h"
|
|
3
|
+
%}
|
|
4
|
+
typedef int int32_t;
|
|
5
|
+
|
|
6
|
+
%include "mesh_java_interfaces.h"
|
|
7
|
+
|
|
8
|
+
%include "cpointer.i"
|
|
9
|
+
%include <stdint.i>
|
|
10
|
+
|
|
11
|
+
%typemap(newfree) char * {
|
|
12
|
+
if ($1 != NULL) {
|
|
13
|
+
ditto_c_string_free($1);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
%newobject ditto_auth_client_user_id;
|