@dittolive/ditto 4.5.4 → 4.6.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/README.md +2 -2
- package/node/ditto.cjs.js +1111 -563
- 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/node/transports.darwin-arm64.node +0 -0
- package/node/transports.darwin-x64.node +0 -0
- package/package.json +45 -1
- package/react-native/android/build.gradle +1 -1
- package/react-native/android/cpp-adapter.cpp +68 -59
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKModule.java +35 -0
- package/react-native/cpp/include/Arc.hpp +1 -1
- package/react-native/cpp/include/Attachment.h +5 -1
- package/react-native/cpp/include/DQL.h +9 -9
- package/react-native/cpp/include/FFIUtils.h +14 -0
- package/react-native/cpp/include/IO.h +13 -0
- package/react-native/cpp/include/Lifecycle.h +0 -1
- package/react-native/cpp/include/Misc.h +3 -0
- package/react-native/cpp/include/Utils.h +0 -2
- package/react-native/cpp/src/Attachment.cpp +200 -13
- package/react-native/cpp/src/Authentication.cpp +3 -3
- package/react-native/cpp/src/DQL.cpp +23 -23
- package/react-native/cpp/src/Document.cpp +10 -10
- package/react-native/cpp/src/FFIUtils.cpp +64 -0
- package/react-native/cpp/src/IO.cpp +35 -0
- package/react-native/cpp/src/Identity.cpp +3 -3
- package/react-native/cpp/src/Lifecycle.cpp +2 -19
- package/react-native/cpp/src/LiveQuery.cpp +3 -5
- package/react-native/cpp/src/Logger.cpp +171 -172
- package/react-native/cpp/src/Misc.cpp +52 -4
- package/react-native/cpp/src/Presence.cpp +1 -1
- package/react-native/cpp/src/SmallPeerInfo.cpp +1 -1
- package/react-native/cpp/src/Transports.cpp +10 -5
- package/react-native/cpp/src/Utils.cpp +110 -114
- package/react-native/cpp/src/main.cpp +28 -15
- package/react-native/dittoffi/dittoffi.h +328 -280
- package/react-native/ios/DittoRNSDK.mm +123 -71
- package/react-native/src/ditto.rn.ts +30 -6
- package/react-native/src/index.ts +7 -4
- package/react-native/src/sources/@cbor-redux.ts +1 -1
- package/react-native/src/sources/attachment-fetch-event.ts +2 -2
- package/react-native/src/sources/attachment-fetcher-manager.ts +5 -4
- package/react-native/src/sources/attachment-fetcher.ts +152 -21
- package/react-native/src/sources/attachment-token.ts +94 -13
- package/react-native/src/sources/attachment.ts +66 -19
- package/react-native/src/sources/augment.ts +13 -6
- package/react-native/src/sources/base-pending-cursor-operation.ts +22 -6
- package/react-native/src/sources/base-pending-id-specific-operation.ts +3 -0
- package/react-native/src/sources/bridge.ts +2 -2
- package/react-native/src/sources/cbor.ts +0 -15
- package/react-native/src/sources/collection-interface.ts +12 -6
- package/react-native/src/sources/collection.ts +9 -2
- package/react-native/src/sources/ditto.ts +26 -18
- package/react-native/src/sources/document-id.ts +11 -7
- package/react-native/src/sources/document-path.ts +4 -2
- package/react-native/src/sources/document.ts +49 -5
- package/react-native/src/sources/error-codes.ts +28 -0
- package/react-native/src/sources/error.ts +20 -1
- package/react-native/src/sources/essentials.ts +25 -3
- package/react-native/src/sources/ffi-error.ts +2 -1
- package/react-native/src/sources/ffi.ts +180 -102
- package/react-native/src/sources/internal.ts +37 -3
- package/react-native/src/sources/live-query-manager.ts +10 -1
- package/react-native/src/sources/live-query.ts +1 -1
- package/react-native/src/sources/observer-manager.ts +7 -0
- package/react-native/src/sources/pending-id-specific-operation.ts +2 -2
- package/react-native/src/sources/presence-manager.ts +12 -2
- package/react-native/src/sources/presence.ts +5 -0
- package/react-native/src/sources/query-result-item.ts +15 -0
- package/react-native/src/sources/small-peer-info.ts +2 -2
- package/react-native/src/sources/static-tcp-client.ts +2 -0
- package/react-native/src/sources/store-observer.ts +4 -2
- package/react-native/src/sources/store.ts +253 -3
- package/react-native/src/sources/sync.ts +6 -3
- package/react-native/src/sources/transport-config.ts +2 -2
- package/react-native/src/sources/update-results-map.ts +8 -0
- package/react-native/src/sources/write-transaction-collection.ts +1 -1
- package/react-native/src/sources/write-transaction.ts +1 -1
- package/types/ditto.d.ts +2866 -2568
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
- package/react-native/.yarn/install-state.gz +0 -0
- package/react-native/.yarnrc.yml +0 -1
|
@@ -4,23 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
namespace sharedjsi
|
|
6
6
|
{
|
|
7
|
-
Function ditto_uninitialized_ditto_make(Runtime &runtime)
|
|
8
|
-
{
|
|
9
|
-
return Function::createFromHostFunction(runtime,
|
|
10
|
-
PropNameID::forAscii(runtime,
|
|
11
|
-
STRINGIFIED_FUNC_NAME()),
|
|
12
|
-
0,
|
|
13
|
-
[](Runtime &runtime,
|
|
14
|
-
const Value &thisValue,
|
|
15
|
-
const Value *arguments,
|
|
16
|
-
size_t count) -> Value
|
|
17
|
-
{
|
|
18
|
-
std::string path = jsTypedArrayToCString(runtime, arguments[0]);
|
|
19
|
-
UninitializedDitto_t *pointer = ::ditto_uninitialized_ditto_make(path.c_str());
|
|
20
|
-
return cPointerToJSPointerObject(runtime, pointer);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
7
|
Function ditto_shutdown(Runtime &runtime)
|
|
25
8
|
{
|
|
26
9
|
return Function::createFromHostFunction(runtime,
|
|
@@ -64,11 +47,11 @@ Function ditto_make(Runtime &runtime)
|
|
|
64
47
|
const Value *arguments,
|
|
65
48
|
size_t count) -> Value
|
|
66
49
|
{
|
|
67
|
-
|
|
50
|
+
std::string path = jsTypedArrayToCString(runtime, arguments[0]);
|
|
68
51
|
CIdentityConfig_t *identity_config = jsPointerObjectToCPointer<CIdentityConfig_t>(runtime, arguments[1]);
|
|
69
52
|
HistoryTracking_t history_tracking = HISTORY_TRACKING_DISABLED;
|
|
70
53
|
|
|
71
|
-
CDitto_t *pointer = ::ditto_make(
|
|
54
|
+
CDitto_t *pointer = ::ditto_make(path.c_str(), identity_config, history_tracking);
|
|
72
55
|
return cPointerToJSPointerObject(runtime, pointer);
|
|
73
56
|
});
|
|
74
57
|
}
|
|
@@ -5,8 +5,6 @@
|
|
|
5
5
|
namespace sharedjsi
|
|
6
6
|
{
|
|
7
7
|
|
|
8
|
-
// TODO: Bridge int64_t! When we'll actually reach a number as big as int64, it will crash.
|
|
9
|
-
|
|
10
8
|
Function ditto_live_query_signal_available_next(Runtime &runtime)
|
|
11
9
|
{
|
|
12
10
|
return Function::createFromHostFunction(runtime,
|
|
@@ -19,7 +17,7 @@ Function ditto_live_query_signal_available_next(Runtime &runtime)
|
|
|
19
17
|
size_t count) -> Value
|
|
20
18
|
{
|
|
21
19
|
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
22
|
-
int64_t liveQueryId = arguments[1].
|
|
20
|
+
int64_t liveQueryId = arguments[1].asBigInt(runtime).asInt64(runtime);
|
|
23
21
|
|
|
24
22
|
::ditto_live_query_signal_available_next(ditto, liveQueryId);
|
|
25
23
|
return Value();
|
|
@@ -38,7 +36,7 @@ Function ditto_live_query_start(Runtime &runtime)
|
|
|
38
36
|
size_t count) -> Value
|
|
39
37
|
{
|
|
40
38
|
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
41
|
-
int64_t liveQueryId = arguments[1].
|
|
39
|
+
int64_t liveQueryId = arguments[1].asBigInt(runtime).asInt64(runtime);
|
|
42
40
|
int32_t res = ::ditto_live_query_start(ditto, liveQueryId);
|
|
43
41
|
return static_cast<double>(res);
|
|
44
42
|
});
|
|
@@ -56,7 +54,7 @@ Function ditto_live_query_stop(Runtime &runtime)
|
|
|
56
54
|
size_t count) -> Value
|
|
57
55
|
{
|
|
58
56
|
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
59
|
-
int64_t liveQueryId = arguments[1].
|
|
57
|
+
int64_t liveQueryId = arguments[1].asBigInt(runtime).asInt64(runtime);
|
|
60
58
|
|
|
61
59
|
::ditto_live_query_stop(ditto, liveQueryId);
|
|
62
60
|
return Value();
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
#include "Logger.h"
|
|
3
2
|
#include "Utils.h"
|
|
4
3
|
|
|
@@ -7,194 +6,194 @@
|
|
|
7
6
|
namespace sharedjsi
|
|
8
7
|
{
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
auto it = lookup.find(log_level.c_str());
|
|
21
|
-
if (it != lookup.end())
|
|
22
|
-
{
|
|
23
|
-
return it->second;
|
|
24
|
-
}
|
|
25
|
-
else
|
|
26
|
-
{
|
|
27
|
-
throw std::invalid_argument("Invalid log level");
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
std::string cLogLevelToJSLogLevelString(CLogLevel_t log_level)
|
|
32
|
-
{
|
|
33
|
-
static const std::unordered_map<CLogLevel_t, std::string> lookup = {
|
|
34
|
-
{C_LOG_LEVEL_ERROR, "Error"},
|
|
35
|
-
{C_LOG_LEVEL_WARNING, "Warning"},
|
|
36
|
-
{C_LOG_LEVEL_INFO, "Info"},
|
|
37
|
-
{C_LOG_LEVEL_DEBUG, "Debug"},
|
|
38
|
-
{C_LOG_LEVEL_VERBOSE, "Verbose"},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
auto it = lookup.find(log_level);
|
|
42
|
-
if (it != lookup.end())
|
|
43
|
-
{
|
|
44
|
-
return it->second;
|
|
45
|
-
}
|
|
46
|
-
else
|
|
47
|
-
{
|
|
48
|
-
throw std::invalid_argument("Invalid log level");
|
|
49
|
-
}
|
|
9
|
+
CLogLevel_t jsLogLevelStringToCLogLevel(std::string log_level)
|
|
10
|
+
{
|
|
11
|
+
static const std::unordered_map<std::string, CLogLevel_t> lookup = {
|
|
12
|
+
{"Error", C_LOG_LEVEL_ERROR},
|
|
13
|
+
{"Warning", C_LOG_LEVEL_WARNING},
|
|
14
|
+
{"Info", C_LOG_LEVEL_INFO},
|
|
15
|
+
{"Debug", C_LOG_LEVEL_DEBUG},
|
|
16
|
+
{"Verbose", C_LOG_LEVEL_VERBOSE},
|
|
50
17
|
};
|
|
51
18
|
|
|
52
|
-
|
|
19
|
+
auto it = lookup.find(log_level.c_str());
|
|
20
|
+
if (it != lookup.end())
|
|
53
21
|
{
|
|
54
|
-
return
|
|
55
|
-
PropNameID::forAscii(runtime,
|
|
56
|
-
STRINGIFIED_FUNC_NAME()),
|
|
57
|
-
0,
|
|
58
|
-
[](Runtime &runtime,
|
|
59
|
-
const Value &thisValue,
|
|
60
|
-
const Value *arguments,
|
|
61
|
-
size_t count) -> Value
|
|
62
|
-
{
|
|
63
|
-
std::string log_level_str = arguments[0].toString(runtime).utf8(runtime);
|
|
64
|
-
CLogLevel_t log_level = jsLogLevelStringToCLogLevel(log_level_str);
|
|
65
|
-
|
|
66
|
-
std::string message_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
67
|
-
const char *message = message_str.c_str();
|
|
68
|
-
|
|
69
|
-
::ditto_log(log_level, message);
|
|
70
|
-
return Value();
|
|
71
|
-
});
|
|
22
|
+
return it->second;
|
|
72
23
|
}
|
|
73
|
-
|
|
74
|
-
Function ditto_logger_minimum_log_level_get(Runtime &runtime)
|
|
24
|
+
else
|
|
75
25
|
{
|
|
76
|
-
|
|
77
|
-
PropNameID::forAscii(runtime,
|
|
78
|
-
STRINGIFIED_FUNC_NAME()),
|
|
79
|
-
0,
|
|
80
|
-
[](Runtime &runtime,
|
|
81
|
-
const Value &thisValue,
|
|
82
|
-
const Value *arguments,
|
|
83
|
-
size_t count) -> Value
|
|
84
|
-
{
|
|
85
|
-
CLogLevel_t res = ::ditto_logger_minimum_log_level_get();
|
|
86
|
-
std::string log_level = cLogLevelToJSLogLevelString(res);
|
|
87
|
-
return String::createFromUtf8(runtime, log_level);
|
|
88
|
-
});
|
|
26
|
+
throw std::invalid_argument("Invalid log level");
|
|
89
27
|
}
|
|
28
|
+
};
|
|
90
29
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
size_t count) -> Value
|
|
101
|
-
{
|
|
102
|
-
std::string log_level_str = arguments[0].toString(runtime).utf8(runtime);
|
|
103
|
-
CLogLevel_t log_level = jsLogLevelStringToCLogLevel(log_level_str);
|
|
104
|
-
|
|
105
|
-
::ditto_logger_minimum_log_level(log_level);
|
|
106
|
-
return Value();
|
|
107
|
-
});
|
|
108
|
-
}
|
|
30
|
+
std::string cLogLevelToJSLogLevelString(CLogLevel_t log_level)
|
|
31
|
+
{
|
|
32
|
+
static const std::unordered_map<CLogLevel_t, std::string> lookup = {
|
|
33
|
+
{C_LOG_LEVEL_ERROR, "Error"},
|
|
34
|
+
{C_LOG_LEVEL_WARNING, "Warning"},
|
|
35
|
+
{C_LOG_LEVEL_INFO, "Info"},
|
|
36
|
+
{C_LOG_LEVEL_DEBUG, "Debug"},
|
|
37
|
+
{C_LOG_LEVEL_VERBOSE, "Verbose"},
|
|
38
|
+
};
|
|
109
39
|
|
|
110
|
-
|
|
40
|
+
auto it = lookup.find(log_level);
|
|
41
|
+
if (it != lookup.end())
|
|
111
42
|
{
|
|
112
|
-
return
|
|
113
|
-
PropNameID::forAscii(runtime,
|
|
114
|
-
STRINGIFIED_FUNC_NAME()),
|
|
115
|
-
0,
|
|
116
|
-
[](Runtime &runtime,
|
|
117
|
-
const Value &thisValue,
|
|
118
|
-
const Value *arguments,
|
|
119
|
-
size_t count) -> Value
|
|
120
|
-
{
|
|
121
|
-
::ditto_logger_set_log_file(arguments[0].toString(runtime).utf8(runtime).c_str());
|
|
122
|
-
return Value();
|
|
123
|
-
});
|
|
43
|
+
return it->second;
|
|
124
44
|
}
|
|
125
|
-
|
|
126
|
-
Function ditto_logger_emoji_headings_enabled(Runtime &runtime)
|
|
45
|
+
else
|
|
127
46
|
{
|
|
128
|
-
|
|
129
|
-
PropNameID::forAscii(runtime,
|
|
130
|
-
STRINGIFIED_FUNC_NAME()),
|
|
131
|
-
0,
|
|
132
|
-
[](Runtime &runtime,
|
|
133
|
-
const Value &thisValue,
|
|
134
|
-
const Value *arguments,
|
|
135
|
-
size_t count) -> Value
|
|
136
|
-
{
|
|
137
|
-
::ditto_logger_emoji_headings_enabled(arguments[0].asBool());
|
|
138
|
-
return Value();
|
|
139
|
-
});
|
|
47
|
+
throw std::invalid_argument("Invalid log level");
|
|
140
48
|
}
|
|
49
|
+
};
|
|
141
50
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
51
|
+
Function ditto_log(Runtime &runtime)
|
|
52
|
+
{
|
|
53
|
+
return Function::createFromHostFunction(runtime,
|
|
54
|
+
PropNameID::forAscii(runtime,
|
|
55
|
+
STRINGIFIED_FUNC_NAME()),
|
|
56
|
+
0,
|
|
57
|
+
[](Runtime &runtime,
|
|
58
|
+
const Value &thisValue,
|
|
59
|
+
const Value *arguments,
|
|
60
|
+
size_t count) -> Value
|
|
61
|
+
{
|
|
62
|
+
std::string log_level_str = arguments[0].toString(runtime).utf8(runtime);
|
|
63
|
+
CLogLevel_t log_level = jsLogLevelStringToCLogLevel(log_level_str);
|
|
64
|
+
|
|
65
|
+
std::string message_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
66
|
+
const char *message = message_str.c_str();
|
|
67
|
+
|
|
68
|
+
::ditto_log(log_level, message);
|
|
69
|
+
return Value();
|
|
70
|
+
});
|
|
71
|
+
}
|
|
156
72
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
73
|
+
Function ditto_logger_minimum_log_level_get(Runtime &runtime)
|
|
74
|
+
{
|
|
75
|
+
return Function::createFromHostFunction(runtime,
|
|
76
|
+
PropNameID::forAscii(runtime,
|
|
77
|
+
STRINGIFIED_FUNC_NAME()),
|
|
78
|
+
0,
|
|
79
|
+
[](Runtime &runtime,
|
|
80
|
+
const Value &thisValue,
|
|
81
|
+
const Value *arguments,
|
|
82
|
+
size_t count) -> Value
|
|
83
|
+
{
|
|
84
|
+
CLogLevel_t res = ::ditto_logger_minimum_log_level_get();
|
|
85
|
+
std::string log_level = cLogLevelToJSLogLevelString(res);
|
|
86
|
+
return String::createFromUtf8(runtime, log_level);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
171
89
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
90
|
+
Function ditto_logger_minimum_log_level(Runtime &runtime)
|
|
91
|
+
{
|
|
92
|
+
return Function::createFromHostFunction(runtime,
|
|
93
|
+
PropNameID::forAscii(runtime,
|
|
94
|
+
STRINGIFIED_FUNC_NAME()),
|
|
95
|
+
0,
|
|
96
|
+
[](Runtime &runtime,
|
|
97
|
+
const Value &thisValue,
|
|
98
|
+
const Value *arguments,
|
|
99
|
+
size_t count) -> Value
|
|
100
|
+
{
|
|
101
|
+
std::string log_level_str = arguments[0].toString(runtime).utf8(runtime);
|
|
102
|
+
CLogLevel_t log_level = jsLogLevelStringToCLogLevel(log_level_str);
|
|
103
|
+
|
|
104
|
+
::ditto_logger_minimum_log_level(log_level);
|
|
105
|
+
return Value();
|
|
106
|
+
});
|
|
107
|
+
}
|
|
187
108
|
|
|
188
|
-
|
|
109
|
+
Function ditto_logger_set_log_file(Runtime &runtime)
|
|
110
|
+
{
|
|
111
|
+
return Function::createFromHostFunction(runtime,
|
|
112
|
+
PropNameID::forAscii(runtime,
|
|
113
|
+
STRINGIFIED_FUNC_NAME()),
|
|
114
|
+
0,
|
|
115
|
+
[](Runtime &runtime,
|
|
116
|
+
const Value &thisValue,
|
|
117
|
+
const Value *arguments,
|
|
118
|
+
size_t count) -> Value
|
|
119
|
+
{
|
|
120
|
+
::ditto_logger_set_log_file(arguments[0].toString(runtime).utf8(runtime).c_str());
|
|
121
|
+
return Value();
|
|
122
|
+
});
|
|
123
|
+
}
|
|
189
124
|
|
|
190
|
-
|
|
125
|
+
Function ditto_logger_emoji_headings_enabled(Runtime &runtime)
|
|
126
|
+
{
|
|
127
|
+
return Function::createFromHostFunction(runtime,
|
|
128
|
+
PropNameID::forAscii(runtime,
|
|
129
|
+
STRINGIFIED_FUNC_NAME()),
|
|
130
|
+
0,
|
|
131
|
+
[](Runtime &runtime,
|
|
132
|
+
const Value &thisValue,
|
|
133
|
+
const Value *arguments,
|
|
134
|
+
size_t count) -> Value
|
|
135
|
+
{
|
|
136
|
+
::ditto_logger_emoji_headings_enabled(arguments[0].asBool());
|
|
137
|
+
return Value();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
Function ditto_logger_emoji_headings_enabled_get(Runtime &runtime)
|
|
142
|
+
{
|
|
143
|
+
return Function::createFromHostFunction(runtime,
|
|
144
|
+
PropNameID::forAscii(runtime,
|
|
145
|
+
STRINGIFIED_FUNC_NAME()),
|
|
146
|
+
0,
|
|
147
|
+
[](Runtime &runtime,
|
|
148
|
+
const Value &thisValue,
|
|
149
|
+
const Value *arguments,
|
|
150
|
+
size_t count) -> Value
|
|
151
|
+
{
|
|
152
|
+
return ::ditto_logger_emoji_headings_enabled_get();
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
Function ditto_logger_enabled_get(Runtime &runtime)
|
|
157
|
+
{
|
|
158
|
+
return Function::createFromHostFunction(runtime,
|
|
159
|
+
PropNameID::forAscii(runtime,
|
|
160
|
+
STRINGIFIED_FUNC_NAME()),
|
|
161
|
+
0,
|
|
162
|
+
[](Runtime &runtime,
|
|
163
|
+
const Value &thisValue,
|
|
164
|
+
const Value *arguments,
|
|
165
|
+
size_t count) -> Value
|
|
166
|
+
{
|
|
167
|
+
return ::ditto_logger_enabled_get();
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
Function ditto_logger_enabled(Runtime &runtime)
|
|
172
|
+
{
|
|
173
|
+
return Function::createFromHostFunction(runtime,
|
|
174
|
+
PropNameID::forAscii(runtime,
|
|
175
|
+
STRINGIFIED_FUNC_NAME()),
|
|
176
|
+
0,
|
|
177
|
+
[](Runtime &runtime,
|
|
178
|
+
const Value &thisValue,
|
|
179
|
+
const Value *arguments,
|
|
180
|
+
size_t count) -> Value
|
|
181
|
+
{
|
|
182
|
+
::ditto_logger_enabled(arguments[0].asBool());
|
|
183
|
+
return Value();
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
std::function<void(CLogLevel_t, const char *)> global_js_callback;
|
|
188
|
+
|
|
189
|
+
extern "C"
|
|
190
|
+
{
|
|
191
|
+
void custom_log_callback(CLogLevel_t log_level, const char *message)
|
|
192
|
+
{
|
|
193
|
+
if (global_js_callback)
|
|
191
194
|
{
|
|
192
|
-
|
|
193
|
-
{
|
|
194
|
-
if (global_js_callback)
|
|
195
|
-
{
|
|
196
|
-
global_js_callback(log_level, message);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
195
|
+
global_js_callback(log_level, message);
|
|
199
196
|
}
|
|
200
197
|
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -47,7 +47,7 @@ Function ditto_error_message(Runtime &runtime) {
|
|
|
47
47
|
size_t count) -> Value
|
|
48
48
|
{
|
|
49
49
|
char *str = ::ditto_error_message();
|
|
50
|
-
return
|
|
50
|
+
return cPointerToJSPointerObject<char>(runtime, str);
|
|
51
51
|
});
|
|
52
52
|
}
|
|
53
53
|
|
|
@@ -95,7 +95,7 @@ Function dittoffi_error_description(Runtime &runtime) {
|
|
|
95
95
|
size_t count) -> Value
|
|
96
96
|
{
|
|
97
97
|
char *res = ::dittoffi_error_description(jsPointerObjectToCPointer<dittoffi_error_t>(runtime, arguments[0]));
|
|
98
|
-
return
|
|
98
|
+
return cPointerToJSPointerObject<char>(runtime, res);
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -264,7 +264,7 @@ Function ditto_set_sync_group(Runtime &runtime) {
|
|
|
264
264
|
});
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
Function
|
|
267
|
+
Function ditto_disable_sync_with_v3(Runtime &runtime)
|
|
268
268
|
{
|
|
269
269
|
return Function::createFromHostFunction(runtime,
|
|
270
270
|
PropNameID::forAscii(runtime,
|
|
@@ -275,9 +275,57 @@ Function refCStringToString(Runtime &runtime)
|
|
|
275
275
|
const Value *arguments,
|
|
276
276
|
size_t count) -> Value
|
|
277
277
|
{
|
|
278
|
-
|
|
278
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
279
|
+
return ::ditto_disable_sync_with_v3(ditto);
|
|
279
280
|
});
|
|
280
281
|
}
|
|
281
282
|
|
|
282
283
|
|
|
284
|
+
Function dittoffi_base64_encode(Runtime &runtime)
|
|
285
|
+
{
|
|
286
|
+
return Function::createFromHostFunction(runtime,
|
|
287
|
+
PropNameID::forAscii(runtime,
|
|
288
|
+
STRINGIFIED_FUNC_NAME()),
|
|
289
|
+
0,
|
|
290
|
+
[](Runtime &runtime,
|
|
291
|
+
const Value &thisValue,
|
|
292
|
+
const Value *arguments,
|
|
293
|
+
size_t count) -> Value
|
|
294
|
+
{
|
|
295
|
+
std::vector<uint8_t> bytes_vec = jsTypedArrayToCVector(runtime, arguments[0]);
|
|
296
|
+
slice_ref_uint8_t bytes = borrowVecAsRefSlice(bytes_vec);
|
|
297
|
+
|
|
298
|
+
std::string padding_mode_str = arguments[1].toString(runtime).utf8(runtime);
|
|
299
|
+
Base64PaddingMode_t padding_mode = padding_mode_str == "Padded" ? BASE64_PADDING_MODE_PADDED : BASE64_PADDING_MODE_UNPADDED;
|
|
300
|
+
|
|
301
|
+
char *res = ::dittoffi_base64_encode(bytes, padding_mode);
|
|
302
|
+
return cPointerToJSPointerObject<char>(runtime, res);
|
|
303
|
+
});
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
Function dittoffi_try_base64_decode(Runtime &runtime)
|
|
307
|
+
{
|
|
308
|
+
return Function::createFromHostFunction(runtime,
|
|
309
|
+
PropNameID::forAscii(runtime,
|
|
310
|
+
STRINGIFIED_FUNC_NAME()),
|
|
311
|
+
0,
|
|
312
|
+
[](Runtime &runtime,
|
|
313
|
+
const Value &thisValue,
|
|
314
|
+
const Value *arguments,
|
|
315
|
+
size_t count) -> Value
|
|
316
|
+
{
|
|
317
|
+
std::string base64_str = jsTypedArrayToCString(runtime, arguments[0]);
|
|
318
|
+
const char *base64 = base64_str.c_str();
|
|
319
|
+
|
|
320
|
+
std::string padding_mode_str = arguments[1].toString(runtime).utf8(runtime);
|
|
321
|
+
Base64PaddingMode_t padding_mode = padding_mode_str == "Padded" ? BASE64_PADDING_MODE_PADDED : BASE64_PADDING_MODE_UNPADDED;
|
|
322
|
+
|
|
323
|
+
dittoffi_result_slice_boxed_uint8_t res = ::dittoffi_try_base64_decode(base64, padding_mode);
|
|
324
|
+
|
|
325
|
+
Object obj(runtime);
|
|
326
|
+
obj.setProperty(runtime, "success", cSlicedBoxToJSSlicedBox(runtime, res.success));
|
|
327
|
+
obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
|
|
328
|
+
return obj;
|
|
329
|
+
});
|
|
330
|
+
}
|
|
283
331
|
}
|
|
@@ -32,7 +32,7 @@ Function ditto_presence_v3(Runtime &runtime)
|
|
|
32
32
|
size_t count) -> Value
|
|
33
33
|
{
|
|
34
34
|
char *res = ::ditto_presence_v3(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
35
|
-
return
|
|
35
|
+
return cPointerToJSPointerObject<char>(runtime, res);
|
|
36
36
|
});
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -117,7 +117,7 @@ Function ditto_small_peer_info_get_metadata(Runtime &runtime) {
|
|
|
117
117
|
size_t count) -> Value
|
|
118
118
|
{
|
|
119
119
|
char *metadata = ::ditto_small_peer_info_get_metadata(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
120
|
-
return
|
|
120
|
+
return cPointerToJSPointerObject<char>(runtime, metadata);
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
}
|
|
@@ -52,17 +52,22 @@ Function ditto_sdk_transports_error_value(Runtime &runtime)
|
|
|
52
52
|
DittoSdkTransportsError_t *outError = jsPointerObjectToCPointer<DittoSdkTransportsError_t>(runtime, arguments[0]);
|
|
53
53
|
DittoSdkTransportsError_t error = ::ditto_sdk_transports_error_value(outError);
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
{
|
|
55
|
+
std::string error_string;
|
|
56
|
+
switch (error) {
|
|
57
57
|
case DITTO_SDK_TRANSPORTS_ERROR_NONE:
|
|
58
|
-
|
|
58
|
+
error_string = "None";
|
|
59
|
+
break;
|
|
59
60
|
case DITTO_SDK_TRANSPORTS_ERROR_GENERIC:
|
|
60
|
-
|
|
61
|
+
error_string = "Generic";
|
|
62
|
+
break;
|
|
61
63
|
case DITTO_SDK_TRANSPORTS_ERROR_UNAVAILABLE:
|
|
62
|
-
|
|
64
|
+
error_string = "Unavailable";
|
|
65
|
+
break;
|
|
63
66
|
default:
|
|
64
67
|
throw "Unimplemented error value";
|
|
65
68
|
}
|
|
69
|
+
return String::createFromUtf8(runtime, error_string);
|
|
70
|
+
|
|
66
71
|
});
|
|
67
72
|
}
|
|
68
73
|
|