@dittolive/ditto 4.12.0 → 5.0.0-experimental.js-cocoapods-publishing.3
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/README.md +2 -2
- package/node/ditto.cjs.js +247 -425
- package/node/ditto.darwin-arm64.node +0 -0
- package/node/ditto.darwin-x64.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 +1 -1
- package/react-native/android/dittoffi/src/ditto_c_string.i +33 -0
- package/react-native/android/dittoffi/src/dittoffi.h +68 -80
- package/react-native/android/dittoffi/src/dittoffi_java.cpp +761 -1174
- package/react-native/android/dittoffi/src/dittoffi_java.h +2 -8
- package/react-native/android/dittoffi/src/dittoffi_java.i +1 -0
- package/react-native/android/dittoffi/src/dittomesh_java.i +0 -9
- package/react-native/android/dittoffi/src/dittostore_java.i +12 -13
- package/react-native/android/dittoffi/src/presence.h +0 -36
- package/react-native/cpp/include/DQL.h +0 -2
- package/react-native/cpp/include/Presence.h +0 -2
- package/react-native/cpp/include/SyncSubscription.h +20 -0
- package/react-native/cpp/src/DQL.cpp +0 -59
- package/react-native/cpp/src/Lifecycle.cpp +1 -6
- package/react-native/cpp/src/Presence.cpp +0 -40
- package/react-native/cpp/src/SyncSubscription.cpp +180 -0
- package/react-native/cpp/src/main.cpp +27 -19
- package/react-native/ditto.es6.js +1 -1
- package/types/ditto.d.ts +44 -65
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
|
@@ -350,21 +350,15 @@ public:
|
|
|
350
350
|
virtual ~SwigDirector_PresenceRust();
|
|
351
351
|
virtual void java_retain();
|
|
352
352
|
virtual void java_release();
|
|
353
|
-
virtual void v1Callback(char const *const json);
|
|
354
|
-
virtual void v2Callback(char const *const json);
|
|
355
353
|
virtual void v3Callback(char const *const json);
|
|
356
|
-
virtual void register_v1();
|
|
357
|
-
virtual void register_v2();
|
|
358
354
|
virtual void register_v3();
|
|
359
|
-
virtual void requestV1Update();
|
|
360
|
-
virtual void requestV2Update();
|
|
361
355
|
virtual void requestV3Update();
|
|
362
356
|
public:
|
|
363
357
|
bool swig_overrides(int n) {
|
|
364
|
-
return (n <
|
|
358
|
+
return (n < 5 ? swig_override[n] : false);
|
|
365
359
|
}
|
|
366
360
|
protected:
|
|
367
|
-
Swig::BoolArray<
|
|
361
|
+
Swig::BoolArray<5> swig_override;
|
|
368
362
|
};
|
|
369
363
|
|
|
370
364
|
class SwigDirector_StoreObserverHandlerRust : public StoreObserverHandlerRust, public Swig::Director {
|
|
@@ -17,15 +17,6 @@ typedef int int32_t;
|
|
|
17
17
|
%include "cpointer.i"
|
|
18
18
|
%include <stdint.i>
|
|
19
19
|
|
|
20
|
-
%typemap(newfree) char * {
|
|
21
|
-
if ($1 != NULL) {
|
|
22
|
-
ditto_c_string_free($1);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
%newobject ditto_auth_client_user_id;
|
|
26
|
-
%newobject dittoffi_authentication_status_user_id;
|
|
27
|
-
%newobject ditto_set_device_name;
|
|
28
|
-
|
|
29
20
|
%typemap(in, numinputs=0) EnvMarker {
|
|
30
21
|
// This code runs inside the JNI wrapper, where 'jenv' is available.
|
|
31
22
|
current_env = jenv;
|
|
@@ -454,21 +454,20 @@
|
|
|
454
454
|
) {
|
|
455
455
|
return unsigned_long_ints[index];
|
|
456
456
|
}
|
|
457
|
-
}
|
|
458
|
-
%}
|
|
459
457
|
|
|
460
|
-
//
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
458
|
+
// This makes working with sync subscriptions easier
|
|
459
|
+
dittoffi_sync_subscription_t const * dittoffi_sync_subscription_at_index(
|
|
460
|
+
dittoffi_sync_subscription_t const * * subscriptions,
|
|
461
|
+
unsigned long int index
|
|
462
|
+
) {
|
|
463
|
+
if (subscriptions == nullptr) {
|
|
464
|
+
throw std::invalid_argument("subscriptions pointer is null");
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
return subscriptions[index];
|
|
468
|
+
}
|
|
466
469
|
}
|
|
467
|
-
}
|
|
468
|
-
%newobject ditto_error_message;
|
|
469
|
-
%newobject ditto_get_complete_attachment_path;
|
|
470
|
-
%newobject ditto_get_sdk_version;
|
|
471
|
-
%newobject ditto_document_id_query_compatible;
|
|
470
|
+
%}
|
|
472
471
|
|
|
473
472
|
// To make it possible (or at least a lot easier) to work with pointers to some
|
|
474
473
|
// of the Ditto_* types we use the `%pointer_functions` directive to provide a
|
|
@@ -17,55 +17,19 @@ public:
|
|
|
17
17
|
explicit PresenceRust(CDitto_t *ditto) : ditto(ditto) {}
|
|
18
18
|
~PresenceRust() override = default;
|
|
19
19
|
|
|
20
|
-
virtual void v1Callback(const char *const json) = 0;
|
|
21
|
-
virtual void v2Callback(const char *const json) = 0;
|
|
22
20
|
virtual void v3Callback(const char *const json) = 0;
|
|
23
21
|
|
|
24
|
-
static void invokeV1Callback(void *const ctx, const char *json) {
|
|
25
|
-
const auto inst = static_cast<PresenceRust *>(ctx);
|
|
26
|
-
return inst->v1Callback(json);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
static void invokeV2Callback(void *const ctx, const char *const json) {
|
|
30
|
-
const auto inst = static_cast<PresenceRust *>(ctx);
|
|
31
|
-
return inst->v2Callback(json);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
22
|
static void invokeV3Callback(void *const ctx, const char *const json) {
|
|
35
23
|
const auto inst = static_cast<PresenceRust *>(ctx);
|
|
36
24
|
return inst->v3Callback(json);
|
|
37
25
|
}
|
|
38
26
|
|
|
39
|
-
virtual void register_v1() {
|
|
40
|
-
ditto_register_presence_v1_callback(ditto, this, PresenceRust::invokeRetain,
|
|
41
|
-
PresenceRust::invokeRelease,
|
|
42
|
-
PresenceRust::invokeV1Callback);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
virtual void register_v2() {
|
|
46
|
-
ditto_register_presence_v2_callback(ditto, this, PresenceRust::invokeRetain,
|
|
47
|
-
PresenceRust::invokeRelease,
|
|
48
|
-
PresenceRust::invokeV2Callback);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
27
|
virtual void register_v3() {
|
|
52
28
|
ditto_register_presence_callback_v3(ditto, this, PresenceRust::invokeRetain,
|
|
53
29
|
PresenceRust::invokeRelease,
|
|
54
30
|
PresenceRust::invokeV3Callback);
|
|
55
31
|
}
|
|
56
32
|
|
|
57
|
-
virtual void requestV1Update() {
|
|
58
|
-
auto json = ditto_presence_v1(ditto);
|
|
59
|
-
v1Callback(json);
|
|
60
|
-
ditto_c_string_free(json);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
virtual void requestV2Update() {
|
|
64
|
-
auto json = ditto_presence_v2(ditto);
|
|
65
|
-
v2Callback(json);
|
|
66
|
-
ditto_c_string_free(json);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
33
|
// Handler for a single update. Called immediately after register_v3 is invoked to deliver a
|
|
70
34
|
// fresh value to the observer.
|
|
71
35
|
virtual void requestV3Update() {
|
|
@@ -7,8 +7,6 @@ using namespace facebook::jsi;
|
|
|
7
7
|
|
|
8
8
|
namespace sharedjsi {
|
|
9
9
|
Function dittoffi_try_experimental_register_change_observer_str_detached(Runtime &runtime);
|
|
10
|
-
Function dittoffi_try_add_sync_subscription(Runtime &runtime);
|
|
11
|
-
Function dittoffi_try_remove_sync_subscription(Runtime &runtime);
|
|
12
10
|
Function dittoffi_try_exec_statement(Runtime &runtime);
|
|
13
11
|
Function dittoffi_query_result_item_count(Runtime &runtime);
|
|
14
12
|
Function dittoffi_query_result_item_at(Runtime &runtime);
|
|
@@ -13,8 +13,6 @@ Function ditto_clear_presence_v3_callback(Runtime &runtime);
|
|
|
13
13
|
Function dittoffi_presence_peer_metadata_json(Runtime &runtime);
|
|
14
14
|
Function dittoffi_presence_try_set_peer_metadata_json(Runtime &runtime);
|
|
15
15
|
Function dittoffi_presence_set_connection_request_handler(Runtime &runtime);
|
|
16
|
-
Function ditto_presence_v1(Runtime &runtime);
|
|
17
|
-
Function ditto_register_presence_v1_callback(Runtime &runtime);
|
|
18
16
|
Function ditto_clear_presence_callback(Runtime &runtime);
|
|
19
17
|
}
|
|
20
18
|
#endif /* Presence_H */
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#ifndef SyncSubscription_H
|
|
2
|
+
#define SyncSubscription_H
|
|
3
|
+
|
|
4
|
+
#include <jsi/jsi.h>
|
|
5
|
+
|
|
6
|
+
using namespace facebook::jsi;
|
|
7
|
+
|
|
8
|
+
namespace sharedjsi {
|
|
9
|
+
Function dittoffi_sync_register_subscription_throws(Runtime &runtime);
|
|
10
|
+
Function dittoffi_sync_subscriptions(Runtime &runtime);
|
|
11
|
+
Function dittoffi_sync_subscription_id(Runtime &runtime);
|
|
12
|
+
Function dittoffi_sync_subscription_query_string(Runtime &runtime);
|
|
13
|
+
Function dittoffi_sync_subscription_query_arguments_cbor(Runtime &runtime);
|
|
14
|
+
Function dittoffi_sync_subscription_query_arguments_json(Runtime &runtime);
|
|
15
|
+
Function dittoffi_sync_subscription_cancel(Runtime &runtime);
|
|
16
|
+
Function dittoffi_sync_subscription_is_cancelled(Runtime &runtime);
|
|
17
|
+
Function dittoffi_sync_subscription_free(Runtime &runtime);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
#endif /* SyncSubscription_H */
|
|
@@ -26,65 +26,6 @@ void v_change_handler_with_query_result(void *ctx, ChangeHandlerWithQueryResult_
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
Function dittoffi_try_add_sync_subscription(Runtime &runtime)
|
|
30
|
-
{
|
|
31
|
-
return Function::createFromHostFunction(runtime,
|
|
32
|
-
PropNameID::forAscii(runtime,
|
|
33
|
-
STRINGIFIED_FUNC_NAME()),
|
|
34
|
-
0,
|
|
35
|
-
[](Runtime &runtime,
|
|
36
|
-
const Value &thisValue,
|
|
37
|
-
const Value *arguments,
|
|
38
|
-
size_t count) -> Value
|
|
39
|
-
{
|
|
40
|
-
auto *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
41
|
-
std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
42
|
-
const char *query = query_str.c_str();
|
|
43
|
-
|
|
44
|
-
std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
|
|
45
|
-
slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
|
|
46
|
-
|
|
47
|
-
dittoffi_result_void_t res = ::dittoffi_try_add_sync_subscription(ditto, query, query_args_cbor);
|
|
48
|
-
|
|
49
|
-
Object obj(runtime);
|
|
50
|
-
if (res.error != nullptr) {
|
|
51
|
-
obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
|
|
52
|
-
} else {
|
|
53
|
-
obj.setProperty(runtime, "error", Value::null());
|
|
54
|
-
}
|
|
55
|
-
return obj;
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
Function dittoffi_try_remove_sync_subscription(Runtime &runtime)
|
|
60
|
-
{
|
|
61
|
-
return Function::createFromHostFunction(runtime,
|
|
62
|
-
PropNameID::forAscii(runtime,
|
|
63
|
-
STRINGIFIED_FUNC_NAME()),
|
|
64
|
-
0,
|
|
65
|
-
[](Runtime &runtime,
|
|
66
|
-
const Value &thisValue,
|
|
67
|
-
const Value *arguments,
|
|
68
|
-
size_t count) -> Value
|
|
69
|
-
{
|
|
70
|
-
auto *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
71
|
-
std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
72
|
-
const char *query = query_str.c_str();
|
|
73
|
-
|
|
74
|
-
std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
|
|
75
|
-
slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
|
|
76
|
-
dittoffi_result_void_t res = ::dittoffi_try_remove_sync_subscription(ditto, query, query_args_cbor);
|
|
77
|
-
|
|
78
|
-
Object obj(runtime);
|
|
79
|
-
if (res.error != nullptr) {
|
|
80
|
-
obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
|
|
81
|
-
} else {
|
|
82
|
-
obj.setProperty(runtime, "error", Value::null());
|
|
83
|
-
}
|
|
84
|
-
return obj;
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
29
|
Function dittoffi_try_exec_statement(Runtime &runtime)
|
|
89
30
|
{
|
|
90
31
|
return Function::createFromHostFunction(runtime,
|
|
@@ -57,11 +57,6 @@ Function dittoffi_ditto_try_new_blocking(Runtime &runtime)
|
|
|
57
57
|
std::string experimental_passphrase = jsTypedArrayToCString(runtime, arguments[3]);
|
|
58
58
|
std::string transport_config_mode_str = arguments[4].toString(runtime).utf8(runtime);
|
|
59
59
|
|
|
60
|
-
Function createDirFunc = runtime.global().getPropertyAsFunction(runtime, "createDirectory");
|
|
61
|
-
Value pathArg = String::createFromUtf8(runtime, path);
|
|
62
|
-
Value resolvedPathValue = createDirFunc.call(runtime, pathArg);
|
|
63
|
-
std::string finalPath = resolvedPathValue.asString(runtime).utf8(runtime);
|
|
64
|
-
|
|
65
60
|
HistoryTracking_t history_tracking;
|
|
66
61
|
if (history_tracking_str == "Disabled") {
|
|
67
62
|
history_tracking = HISTORY_TRACKING_DISABLED;
|
|
@@ -81,7 +76,7 @@ Function dittoffi_ditto_try_new_blocking(Runtime &runtime)
|
|
|
81
76
|
}
|
|
82
77
|
|
|
83
78
|
dittoffi_result_CDitto_ptr_t res = ::dittoffi_ditto_try_new_blocking(
|
|
84
|
-
|
|
79
|
+
path.c_str(),
|
|
85
80
|
identity_config,
|
|
86
81
|
history_tracking,
|
|
87
82
|
experimental_passphrase.empty() ? nullptr: experimental_passphrase.c_str(),
|
|
@@ -165,46 +165,6 @@ Function dittoffi_presence_set_connection_request_handler(Runtime &runtime)
|
|
|
165
165
|
});
|
|
166
166
|
}
|
|
167
167
|
|
|
168
|
-
Function ditto_presence_v1(Runtime &runtime)
|
|
169
|
-
{
|
|
170
|
-
return Function::createFromHostFunction(runtime,
|
|
171
|
-
PropNameID::forAscii(runtime,
|
|
172
|
-
STRINGIFIED_FUNC_NAME()),
|
|
173
|
-
0,
|
|
174
|
-
[](Runtime &runtime,
|
|
175
|
-
const Value &thisValue,
|
|
176
|
-
const Value *arguments,
|
|
177
|
-
size_t count) -> Value
|
|
178
|
-
{
|
|
179
|
-
char *res = ::ditto_presence_v1(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
180
|
-
return cPointerToJSPointerObject<char>(runtime, res);
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
Function ditto_register_presence_v1_callback(Runtime &runtime)
|
|
185
|
-
{
|
|
186
|
-
return Function::createFromHostFunction(runtime,
|
|
187
|
-
PropNameID::forAscii(runtime,
|
|
188
|
-
STRINGIFIED_FUNC_NAME()),
|
|
189
|
-
0,
|
|
190
|
-
[](Runtime &runtime,
|
|
191
|
-
const Value &thisValue,
|
|
192
|
-
const Value *arguments,
|
|
193
|
-
size_t count) -> Value
|
|
194
|
-
{
|
|
195
|
-
auto *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
196
|
-
Function presence_callback = arguments[1].getObject(runtime).getFunction(runtime);
|
|
197
|
-
Arc<Function> wrappedStateFfiWrapper /* = */ (std::move(presence_callback));
|
|
198
|
-
|
|
199
|
-
::ditto_register_presence_v1_callback(ditto,
|
|
200
|
-
Arc<Function>::as_raw(wrappedStateFfiWrapper),
|
|
201
|
-
v_retain,
|
|
202
|
-
v_release,
|
|
203
|
-
v_presence_callback);
|
|
204
|
-
return {};
|
|
205
|
-
});
|
|
206
|
-
}
|
|
207
|
-
|
|
208
168
|
Function ditto_clear_presence_callback(Runtime &runtime)
|
|
209
169
|
{
|
|
210
170
|
return Function::createFromHostFunction(runtime,
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
#include <SyncSubscription.h>
|
|
2
|
+
|
|
3
|
+
#include "Utils.h"
|
|
4
|
+
|
|
5
|
+
namespace sharedjsi
|
|
6
|
+
{
|
|
7
|
+
|
|
8
|
+
Function dittoffi_sync_register_subscription_throws(Runtime &runtime)
|
|
9
|
+
{
|
|
10
|
+
return Function::createFromHostFunction(runtime,
|
|
11
|
+
PropNameID::forAscii(runtime,
|
|
12
|
+
STRINGIFIED_FUNC_NAME()),
|
|
13
|
+
0,
|
|
14
|
+
[](Runtime &runtime,
|
|
15
|
+
const Value &thisValue,
|
|
16
|
+
const Value *arguments,
|
|
17
|
+
size_t count) -> Value
|
|
18
|
+
{
|
|
19
|
+
auto *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
20
|
+
std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
21
|
+
const char *query = query_str.c_str();
|
|
22
|
+
|
|
23
|
+
std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
|
|
24
|
+
slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
|
|
25
|
+
|
|
26
|
+
dittoffi_result_dittoffi_sync_subscription_ptr_t res = ::dittoffi_sync_register_subscription_throws(ditto, query, query_args_cbor);
|
|
27
|
+
|
|
28
|
+
Object obj(runtime);
|
|
29
|
+
obj.setProperty(runtime, "success", cPointerToJSPointerObject(runtime, res.success));
|
|
30
|
+
obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
|
|
31
|
+
return obj;
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
Function dittoffi_sync_subscriptions(Runtime &runtime)
|
|
36
|
+
{
|
|
37
|
+
return Function::createFromHostFunction(runtime,
|
|
38
|
+
PropNameID::forAscii(runtime,
|
|
39
|
+
STRINGIFIED_FUNC_NAME()),
|
|
40
|
+
0,
|
|
41
|
+
[](Runtime &runtime,
|
|
42
|
+
const Value &thisValue,
|
|
43
|
+
const Value *arguments,
|
|
44
|
+
size_t count) -> Value
|
|
45
|
+
{
|
|
46
|
+
auto *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
47
|
+
Vec_dittoffi_sync_subscription_ptr_t res = ::dittoffi_sync_subscriptions(ditto);
|
|
48
|
+
|
|
49
|
+
jsi::Array jsArray(runtime, res.len);
|
|
50
|
+
|
|
51
|
+
for (size_t i = 0; i < res.len; ++i) {
|
|
52
|
+
dittoffi_sync_subscription_t *ffi_subscription = res.ptr[i];
|
|
53
|
+
auto jsObj = cPointerToJSPointerObject<dittoffi_sync_subscription_t>(runtime, ffi_subscription);
|
|
54
|
+
jsArray.setValueAtIndex(runtime, i, jsObj);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
::dittoffi_sync_subscriptions_free_sparse(res);
|
|
58
|
+
|
|
59
|
+
return jsArray;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
Function dittoffi_sync_subscription_id(Runtime &runtime)
|
|
64
|
+
{
|
|
65
|
+
return Function::createFromHostFunction(runtime,
|
|
66
|
+
PropNameID::forAscii(runtime,
|
|
67
|
+
STRINGIFIED_FUNC_NAME()),
|
|
68
|
+
0,
|
|
69
|
+
[](Runtime &runtime,
|
|
70
|
+
const Value &thisValue,
|
|
71
|
+
const Value *arguments,
|
|
72
|
+
size_t count) -> Value
|
|
73
|
+
{
|
|
74
|
+
auto *ffi_sync_subscription = jsPointerObjectToCPointer<dittoffi_sync_subscription_t>(runtime, arguments[0]);
|
|
75
|
+
slice_boxed_uint8_t id_cbor = ::dittoffi_sync_subscription_id(ffi_sync_subscription);
|
|
76
|
+
return cSlicedBoxToJSSlicedBox(runtime, id_cbor);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Function dittoffi_sync_subscription_query_string(Runtime &runtime)
|
|
81
|
+
{
|
|
82
|
+
return Function::createFromHostFunction(runtime,
|
|
83
|
+
PropNameID::forAscii(runtime,
|
|
84
|
+
STRINGIFIED_FUNC_NAME()),
|
|
85
|
+
0,
|
|
86
|
+
[](Runtime &runtime,
|
|
87
|
+
const Value &thisValue,
|
|
88
|
+
const Value *arguments,
|
|
89
|
+
size_t count) -> Value
|
|
90
|
+
{
|
|
91
|
+
auto *ffi_sync_subscription = jsPointerObjectToCPointer<dittoffi_sync_subscription_t>(runtime, arguments[0]);
|
|
92
|
+
char *res = ::dittoffi_sync_subscription_query_string(ffi_sync_subscription);
|
|
93
|
+
return cPointerToJSPointerObject<char>(runtime, res);
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
Function dittoffi_sync_subscription_query_arguments_cbor(Runtime &runtime)
|
|
98
|
+
{
|
|
99
|
+
return Function::createFromHostFunction(runtime,
|
|
100
|
+
PropNameID::forAscii(runtime,
|
|
101
|
+
STRINGIFIED_FUNC_NAME()),
|
|
102
|
+
0,
|
|
103
|
+
[](Runtime &runtime,
|
|
104
|
+
const Value &thisValue,
|
|
105
|
+
const Value *arguments,
|
|
106
|
+
size_t count) -> Value
|
|
107
|
+
{
|
|
108
|
+
auto *ffi_sync_subscription = jsPointerObjectToCPointer<dittoffi_sync_subscription_t>(runtime, arguments[0]);
|
|
109
|
+
slice_boxed_uint8_t id_cbor = ::dittoffi_sync_subscription_query_arguments_cbor(ffi_sync_subscription);
|
|
110
|
+
return cSlicedBoxToJSSlicedBox(runtime, id_cbor);
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
Function dittoffi_sync_subscription_query_arguments_json(Runtime &runtime)
|
|
115
|
+
{
|
|
116
|
+
return Function::createFromHostFunction(runtime,
|
|
117
|
+
PropNameID::forAscii(runtime,
|
|
118
|
+
STRINGIFIED_FUNC_NAME()),
|
|
119
|
+
0,
|
|
120
|
+
[](Runtime &runtime,
|
|
121
|
+
const Value &thisValue,
|
|
122
|
+
const Value *arguments,
|
|
123
|
+
size_t count) -> Value
|
|
124
|
+
{
|
|
125
|
+
auto *ffi_sync_subscription = jsPointerObjectToCPointer<dittoffi_sync_subscription_t>(runtime, arguments[0]);
|
|
126
|
+
slice_boxed_uint8_t id_json_bytes = ::dittoffi_sync_subscription_query_arguments_json(ffi_sync_subscription);
|
|
127
|
+
return cSlicedBoxToJSSlicedBox(runtime, id_json_bytes);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
Function dittoffi_sync_subscription_cancel(Runtime &runtime)
|
|
132
|
+
{
|
|
133
|
+
return Function::createFromHostFunction(runtime,
|
|
134
|
+
PropNameID::forAscii(runtime,
|
|
135
|
+
STRINGIFIED_FUNC_NAME()),
|
|
136
|
+
0,
|
|
137
|
+
[](Runtime &runtime,
|
|
138
|
+
const Value &thisValue,
|
|
139
|
+
const Value *arguments,
|
|
140
|
+
size_t count) -> Value
|
|
141
|
+
{
|
|
142
|
+
auto *ffi_sync_subscription = jsPointerObjectToCPointer<dittoffi_sync_subscription_t>(runtime, arguments[0]);
|
|
143
|
+
::dittoffi_sync_subscription_cancel(ffi_sync_subscription);
|
|
144
|
+
return {};
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
Function dittoffi_sync_subscription_is_cancelled(Runtime &runtime)
|
|
149
|
+
{
|
|
150
|
+
return Function::createFromHostFunction(runtime,
|
|
151
|
+
PropNameID::forAscii(runtime,
|
|
152
|
+
STRINGIFIED_FUNC_NAME()),
|
|
153
|
+
0,
|
|
154
|
+
[](Runtime &runtime,
|
|
155
|
+
const Value &thisValue,
|
|
156
|
+
const Value *arguments,
|
|
157
|
+
size_t count) -> Value
|
|
158
|
+
{
|
|
159
|
+
auto *ffi_sync_subscription = jsPointerObjectToCPointer<dittoffi_sync_subscription_t>(runtime, arguments[0]);
|
|
160
|
+
return ::dittoffi_sync_subscription_is_cancelled(ffi_sync_subscription);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
Function dittoffi_sync_subscription_free(Runtime &runtime)
|
|
165
|
+
{
|
|
166
|
+
return Function::createFromHostFunction(runtime,
|
|
167
|
+
PropNameID::forAscii(runtime,
|
|
168
|
+
STRINGIFIED_FUNC_NAME()),
|
|
169
|
+
0,
|
|
170
|
+
[](Runtime &runtime,
|
|
171
|
+
const Value &thisValue,
|
|
172
|
+
const Value *arguments,
|
|
173
|
+
size_t count) -> Value
|
|
174
|
+
{
|
|
175
|
+
auto *ffi_sync_subscription = jsPointerObjectToCPointer<dittoffi_sync_subscription_t>(runtime, arguments[0]);
|
|
176
|
+
::dittoffi_sync_subscription_free(ffi_sync_subscription);
|
|
177
|
+
return {};
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
}
|
|
@@ -1,27 +1,29 @@
|
|
|
1
1
|
#include <jsi/jsi.h>
|
|
2
2
|
|
|
3
3
|
#include "main.h"
|
|
4
|
-
|
|
5
|
-
#include "
|
|
4
|
+
|
|
5
|
+
#include "Authentication.h"
|
|
6
|
+
#include "Attachment.h"
|
|
7
|
+
#include "Collection.h"
|
|
8
|
+
#include "ConnectionRequest.h"
|
|
6
9
|
#include "Differ.h"
|
|
7
10
|
#include "Document.h"
|
|
8
|
-
#include "
|
|
9
|
-
#include "
|
|
10
|
-
#include "
|
|
11
|
-
#include "Misc.h"
|
|
11
|
+
#include "DQL.h"
|
|
12
|
+
#include "FFIUtils.h"
|
|
13
|
+
#include "GlobalCallInvoker.h"
|
|
12
14
|
#include "Identity.h"
|
|
13
|
-
#include "
|
|
14
|
-
#include "
|
|
15
|
+
#include "IO.h"
|
|
16
|
+
#include "Lifecycle.h"
|
|
15
17
|
#include "LiveQuery.h"
|
|
16
|
-
#include "Collection.h"
|
|
17
18
|
#include "Logger.h"
|
|
19
|
+
#include "Misc.h"
|
|
20
|
+
#include "Presence.h"
|
|
18
21
|
#include "SmallPeerInfo.h"
|
|
19
|
-
#include "
|
|
20
|
-
#include "
|
|
21
|
-
#include "FFIUtils.h"
|
|
22
|
-
#include "ConnectionRequest.h"
|
|
23
|
-
#include "GlobalCallInvoker.h"
|
|
22
|
+
#include "Sync.h"
|
|
23
|
+
#include "SyncSubscription.h"
|
|
24
24
|
#include "Transaction.h"
|
|
25
|
+
#include "Transports.h"
|
|
26
|
+
#include "Utils.h"
|
|
25
27
|
|
|
26
28
|
// Note: `runtime` variable must exist in scope.
|
|
27
29
|
#define REGISTER_JS_FUNCTION(fname) runtime.global().setProperty(runtime, STRINGIFY(fname), fname(runtime));
|
|
@@ -95,8 +97,6 @@ namespace sharedjsi
|
|
|
95
97
|
|
|
96
98
|
// DQL
|
|
97
99
|
REGISTER_JS_FUNCTION(dittoffi_try_experimental_register_change_observer_str_detached);
|
|
98
|
-
REGISTER_JS_FUNCTION(dittoffi_try_add_sync_subscription);
|
|
99
|
-
REGISTER_JS_FUNCTION(dittoffi_try_remove_sync_subscription);
|
|
100
100
|
REGISTER_JS_FUNCTION(dittoffi_try_exec_statement);
|
|
101
101
|
REGISTER_JS_FUNCTION(dittoffi_query_result_item_count);
|
|
102
102
|
REGISTER_JS_FUNCTION(dittoffi_query_result_item_at);
|
|
@@ -115,6 +115,17 @@ namespace sharedjsi
|
|
|
115
115
|
REGISTER_JS_FUNCTION(dittoffi_differ_diff);
|
|
116
116
|
REGISTER_JS_FUNCTION(dittoffi_differ_free);
|
|
117
117
|
|
|
118
|
+
// SyncSubscription
|
|
119
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_register_subscription_throws);
|
|
120
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_subscriptions);
|
|
121
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_subscription_id);
|
|
122
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_subscription_query_string);
|
|
123
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_subscription_query_arguments_cbor);
|
|
124
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_subscription_query_arguments_json);
|
|
125
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_subscription_cancel);
|
|
126
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_subscription_is_cancelled);
|
|
127
|
+
REGISTER_JS_FUNCTION(dittoffi_sync_subscription_free);
|
|
128
|
+
|
|
118
129
|
// Documents
|
|
119
130
|
REGISTER_JS_FUNCTION(ditto_document_id_query_compatible);
|
|
120
131
|
REGISTER_JS_FUNCTION(ditto_document_id);
|
|
@@ -123,9 +134,6 @@ namespace sharedjsi
|
|
|
123
134
|
REGISTER_JS_FUNCTION(ditto_validate_document_id);
|
|
124
135
|
|
|
125
136
|
// Presence
|
|
126
|
-
REGISTER_JS_FUNCTION(ditto_presence_v1);
|
|
127
|
-
REGISTER_JS_FUNCTION(ditto_register_presence_v1_callback);
|
|
128
|
-
REGISTER_JS_FUNCTION(ditto_clear_presence_callback);
|
|
129
137
|
REGISTER_JS_FUNCTION(ditto_presence_v3);
|
|
130
138
|
REGISTER_JS_FUNCTION(ditto_register_presence_v3_callback);
|
|
131
139
|
REGISTER_JS_FUNCTION(ditto_clear_presence_v3_callback);
|