@dittolive/ditto 4.11.2-rc.1 → 4.12.0-experimental-untangle.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.
@@ -46,6 +46,7 @@
46
46
  ptr = obj.swigCPtr;
47
47
  obj.swigCMemOwn = false;
48
48
  obj.delete();
49
+ obj.swigCPtr = 0;
49
50
  }
50
51
  return ptr;
51
52
  }
@@ -19,6 +19,8 @@ Function dittoffi_query_result_item_json(Runtime &runtime);
19
19
  Function dittoffi_query_result_free(Runtime &runtime);
20
20
  Function dittoffi_query_result_item_free(Runtime &runtime);
21
21
  Function dittoffi_query_result_item_new(Runtime &runtime);
22
+ Function dittoffi_query_result_has_commit_id(Runtime &runtime);
23
+ Function dittoffi_query_result_commit_id(Runtime &runtime);
22
24
  }
23
25
 
24
26
  #endif /* DQL_H */
@@ -10,6 +10,8 @@ namespace sharedjsi
10
10
  Function readFile(Runtime &runtime);
11
11
  Function copyFile(Runtime &runtime);
12
12
  Function createDirectory(Runtime &runtime, String &defaultDirPath);
13
+ Function getDefaultDirectory(Runtime &runtime, String &defaultDirPath);
14
+ Function dittoffi_ditto_absolute_persistence_directory(Runtime &runtime);
13
15
  }
14
16
 
15
17
  #endif /* IO_H */
@@ -11,6 +11,13 @@ Function ditto_init_sdk_version(Runtime &runtime);
11
11
  Function ditto_shutdown(Runtime &runtime);
12
12
  Function ditto_free(Runtime &runtime);
13
13
  Function dittoffi_ditto_try_new_blocking(Runtime &runtime);
14
+ Function dittoffi_ditto_open_throws(Runtime &runtime);
15
+ Function dittoffi_DEFAULT_DATABASE_ID(Runtime &runtime);
16
+ Function dittoffi_DITTO_DEVELOPMENT_PROVIDER(Runtime &runtime);
17
+ Function dittoffi_ditto_config_default(Runtime &runtime);
18
+ Function dittoffi_ditto_config(Runtime &runtime);
19
+ Function dittoffi_ditto_transport_config(Runtime &runtime);
20
+ Function dittoffi_ditto_open_async_throws(Runtime &runtime);
14
21
  }
15
22
 
16
23
  #endif /* Lifecycle_H */
@@ -1,7 +1,7 @@
1
1
  #pragma once
2
2
 
3
3
  #if defined(__APPLE__)
4
- #include "DittoReactNative/dittoffi.h"
4
+ #include "DittoCore/dittoffi.h"
5
5
  #elif defined(__ANDROID__)
6
6
  #include <dittoffi.h>
7
7
  #else
@@ -47,7 +47,11 @@ Function dittoffi_try_add_sync_subscription(Runtime &runtime)
47
47
  dittoffi_result_void_t res = ::dittoffi_try_add_sync_subscription(ditto, query, query_args_cbor);
48
48
 
49
49
  Object obj(runtime);
50
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
50
+ if (res.error != nullptr) {
51
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
52
+ } else {
53
+ obj.setProperty(runtime, "error", Value::null());
54
+ }
51
55
  return obj;
52
56
  });
53
57
  }
@@ -72,7 +76,11 @@ Function dittoffi_try_remove_sync_subscription(Runtime &runtime)
72
76
  dittoffi_result_void_t res = ::dittoffi_try_remove_sync_subscription(ditto, query, query_args_cbor);
73
77
 
74
78
  Object obj(runtime);
75
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
79
+ if (res.error != nullptr) {
80
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
81
+ } else {
82
+ obj.setProperty(runtime, "error", Value::null());
83
+ }
76
84
  return obj;
77
85
  });
78
86
  }
@@ -98,7 +106,11 @@ Function dittoffi_try_exec_statement(Runtime &runtime)
98
106
 
99
107
  Object obj(runtime);
100
108
  obj.setProperty(runtime, "success", cPointerToJSPointerObject(runtime, res.success));
101
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
109
+ if (res.error != nullptr) {
110
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
111
+ } else {
112
+ obj.setProperty(runtime, "error", Value::null());
113
+ }
102
114
  return obj;
103
115
  });
104
116
  }
@@ -145,7 +157,11 @@ Function dittoffi_try_experimental_register_change_observer_str_detached(Runtime
145
157
 
146
158
  Object obj(runtime);
147
159
  obj.setProperty(runtime, "success", int64ToBigIntOrNumber(runtime, res.success));
148
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
160
+ if (res.error != nullptr) {
161
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
162
+ } else {
163
+ obj.setProperty(runtime, "error", Value::null());
164
+ }
149
165
  return obj;
150
166
  });
151
167
  }
@@ -302,4 +318,34 @@ Function dittoffi_query_result_item_new(Runtime &runtime)
302
318
  return out;
303
319
  });
304
320
  }
321
+
322
+ Function dittoffi_query_result_has_commit_id(Runtime &runtime)
323
+ {
324
+ return Function::createFromHostFunction(runtime,
325
+ PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
326
+ 1,
327
+ [](Runtime &runtime,
328
+ const Value &thisValue,
329
+ const Value *arguments,
330
+ size_t count) -> Value
331
+ {
332
+ bool res = ::dittoffi_query_result_has_commit_id(jsPointerObjectToCPointer<dittoffi_query_result>(runtime, arguments[0]));
333
+ return res;
334
+ });
335
+ }
336
+
337
+ Function dittoffi_query_result_commit_id(Runtime &runtime)
338
+ {
339
+ return Function::createFromHostFunction(runtime,
340
+ PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
341
+ 1,
342
+ [](Runtime &runtime,
343
+ const Value &thisValue,
344
+ const Value *arguments,
345
+ size_t count) -> Value
346
+ {
347
+ uint64_t res = ::dittoffi_query_result_commit_id(jsPointerObjectToCPointer<dittoffi_query_result>(runtime, arguments[0]));
348
+ return uint64ToBigIntOrNumber(runtime, res);
349
+ });
350
+ }
305
351
  }
@@ -111,4 +111,44 @@ Function createDirectory(Runtime &runtime, String &defaultDirPath)
111
111
  return String::createFromUtf8(runtime, finalPath);
112
112
  });
113
113
  }
114
+
115
+ Function dittoffi_ditto_absolute_persistence_directory(Runtime &runtime)
116
+ {
117
+ return Function::createFromHostFunction(runtime,
118
+ PropNameID::forAscii(runtime,
119
+ STRINGIFIED_FUNC_NAME()),
120
+ 1,
121
+ [](Runtime &runtime,
122
+ const Value &thisValue,
123
+ const Value *arguments,
124
+ size_t count) -> Value
125
+ {
126
+ auto *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
127
+ char* absolute_path = ::dittoffi_ditto_absolute_persistence_directory(ditto);
128
+ return cPointerToJSPointerObject<char>(runtime, absolute_path);
129
+
130
+ });
131
+ }
132
+
133
+ Function getDefaultDirectory(Runtime &runtime, String &defaultDirPath)
134
+ {
135
+ return Function::createFromHostFunction(runtime,
136
+ PropNameID::forAscii(runtime,
137
+ STRINGIFIED_FUNC_NAME()),
138
+ 1,
139
+ [defaultDirPathStr = defaultDirPath.utf8(runtime)](Runtime &runtime,
140
+ const Value &thisValue,
141
+ const Value *arguments,
142
+ size_t count) -> Value
143
+ {
144
+ std::string path = arguments[0].asString(runtime).utf8(runtime);
145
+
146
+ std::string finalPath = path;
147
+ if (path.empty() || path[0] != '/') {
148
+ finalPath = defaultDirPathStr + "/" + path;
149
+ }
150
+
151
+ return String::createFromUtf8(runtime, finalPath);
152
+ });
153
+ }
114
154
  }
@@ -1,9 +1,13 @@
1
1
  #include "Utils.h"
2
+ #include "Arc.hpp"
2
3
 
3
4
  #include <Lifecycle.h>
4
5
 
5
6
  namespace sharedjsi
6
7
  {
8
+
9
+ DEFINE_RETAIN_RELEASE_FOR(Function, v_retain, v_release);
10
+
7
11
  Function ditto_shutdown(Runtime &runtime)
8
12
  {
9
13
  return Function::createFromHostFunction(runtime,
@@ -108,10 +112,12 @@ Function ditto_init_sdk_version(Runtime &runtime)
108
112
  }
109
113
 
110
114
  Platform_t platform = PLATFORM_UNKNOWN;
111
- if (platform_str == "Ios") {
115
+ if (platform_str == "iOS") {
112
116
  platform = PLATFORM_IOS;
113
117
  } else if (platform_str == "Android") {
114
118
  platform = PLATFORM_ANDROID;
119
+ } else if (platform_str == "macOS") {
120
+ platform = PLATFORM_MAC;
115
121
  }
116
122
 
117
123
  ::ditto_init_sdk_version(platform, language, semver);
@@ -119,4 +125,178 @@ Function ditto_init_sdk_version(Runtime &runtime)
119
125
  });
120
126
  }
121
127
 
128
+ Function dittoffi_ditto_open_throws(Runtime &runtime)
129
+ {
130
+ return Function::createFromHostFunction(runtime,
131
+ PropNameID::forAscii(runtime,
132
+ STRINGIFIED_FUNC_NAME()),
133
+ 3,
134
+ [](Runtime &runtime,
135
+ const Value &thisValue,
136
+ const Value *arguments,
137
+ size_t count) -> Value
138
+ {
139
+ std::vector<uint8_t> config_cbor_vec = jsTypedArrayToCVector(runtime, arguments[0]);
140
+ slice_ref_uint8_t config_slice = borrowVecAsRefSlice(config_cbor_vec);
141
+
142
+ std::string transport_config_mode_str = arguments[1].toString(runtime).utf8(runtime);
143
+
144
+ TransportConfigMode_t transport_config_mode;
145
+ if (transport_config_mode_str == "PlatformDependent") {
146
+ transport_config_mode = TRANSPORT_CONFIG_MODE_PLATFORM_DEPENDENT;
147
+ } else if (transport_config_mode_str == "PlatformIndependent") {
148
+ transport_config_mode = TRANSPORT_CONFIG_MODE_PLATFORM_INDEPENDENT;
149
+ } else {
150
+ throw std::invalid_argument("Invalid transport configuration mode: " + transport_config_mode_str);
151
+ }
152
+
153
+ std::string default_root_dir_str = jsTypedArrayToCString(runtime, arguments[2]);
154
+ const char* default_root_directory = default_root_dir_str.c_str();
155
+
156
+ dittoffi_result_CDitto_ptr_t res = ::dittoffi_ditto_open_throws(
157
+ config_slice,
158
+ transport_config_mode,
159
+ default_root_directory
160
+ );
161
+
162
+ Object obj(runtime);
163
+ obj.setProperty(runtime, "success", cPointerToJSPointerObject(runtime, res.success));
164
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
165
+ return obj;
166
+ });
167
+ }
168
+
169
+ Function dittoffi_DEFAULT_DATABASE_ID(Runtime &runtime)
170
+ {
171
+ return Function::createFromHostFunction(runtime,
172
+ PropNameID::forAscii(runtime,
173
+ STRINGIFIED_FUNC_NAME()),
174
+ 0,
175
+ [](Runtime &runtime,
176
+ const Value &thisValue,
177
+ const Value *arguments,
178
+ size_t count) -> Value
179
+ {
180
+ const char* default_id = ::dittoffi_DEFAULT_DATABASE_ID();
181
+ return cPointerToJSPointerObject<char>(runtime, default_id);
182
+ });
183
+ }
184
+
185
+ Function dittoffi_DITTO_DEVELOPMENT_PROVIDER(Runtime &runtime)
186
+ {
187
+ return Function::createFromHostFunction(runtime,
188
+ PropNameID::forAscii(runtime,
189
+ STRINGIFIED_FUNC_NAME()),
190
+ 0,
191
+ [](Runtime &runtime,
192
+ const Value &thisValue,
193
+ const Value *arguments,
194
+ size_t count) -> Value
195
+ {
196
+ const char* dev_provider = ::dittoffi_DITTO_DEVELOPMENT_PROVIDER();
197
+ return cPointerToJSPointerObject<char>(runtime, dev_provider);
198
+ });
199
+ }
200
+
201
+ Function dittoffi_ditto_config_default(Runtime &runtime)
202
+ {
203
+ return Function::createFromHostFunction(runtime,
204
+ PropNameID::forAscii(runtime,
205
+ STRINGIFIED_FUNC_NAME()),
206
+ 0,
207
+ [](Runtime &runtime,
208
+ const Value &thisValue,
209
+ const Value *arguments,
210
+ size_t count) -> Value
211
+ {
212
+ slice_boxed_uint8_t config_cbor = ::dittoffi_ditto_config_default();
213
+ return cSlicedBoxToJSSlicedBox(runtime, config_cbor);
214
+ });
215
+ }
216
+
217
+ Function dittoffi_ditto_config(Runtime &runtime)
218
+ {
219
+ return Function::createFromHostFunction(runtime,
220
+ PropNameID::forAscii(runtime,
221
+ STRINGIFIED_FUNC_NAME()),
222
+ 1,
223
+ [](Runtime &runtime,
224
+ const Value &thisValue,
225
+ const Value *arguments,
226
+ size_t count) -> Value
227
+ {
228
+ auto *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
229
+ slice_boxed_uint8_t config_cbor = ::dittoffi_ditto_config(ditto);
230
+ return cSlicedBoxToJSSlicedBox(runtime, config_cbor);
231
+ });
232
+ }
233
+
234
+
235
+ extern "C"
236
+ {
237
+ void v_ditto_open_result(void *ctx, dittoffi_result_CDitto_ptr_t res)
238
+ {
239
+ Arc<Function> const& borrowedJsCallback = Arc<Function>::borrow_from_raw(ctx);
240
+ // copy ctor / retain so as to keep the ArcPointee<Function> alive until the enqueued_call completes.
241
+ Arc<Function> jsCallback(borrowedJsCallback);
242
+ jsi_enqueue_call([=](Runtime &runtime) {
243
+ Object obj(runtime);
244
+ obj.setProperty(runtime, "success", cPointerToJSPointerObject(runtime, res.success));
245
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
246
+ jsCallback->call(runtime, obj);
247
+ });
248
+ }
249
+ }
250
+
251
+ Function dittoffi_ditto_open_async_throws(Runtime &runtime)
252
+ {
253
+ return Function::createFromHostFunction(runtime,
254
+ PropNameID::forAscii(runtime,
255
+ STRINGIFIED_FUNC_NAME()),
256
+ 4,
257
+ [](Runtime &runtime,
258
+ const Value &thisValue,
259
+ const Value *arguments,
260
+ size_t count) -> Value
261
+ {
262
+ // Extract CBOR config from TypedArray using JSI helper
263
+ std::vector<uint8_t> config_cbor_vec = jsTypedArrayToCVector(runtime, arguments[0]);
264
+ slice_ref_uint8_t config_slice = borrowVecAsRefSlice(config_cbor_vec);
265
+
266
+ // Extract transport config mode
267
+ std::string transport_config_mode_str = arguments[1].toString(runtime).utf8(runtime);
268
+
269
+ TransportConfigMode_t transport_config_mode;
270
+ if (transport_config_mode_str == "PlatformDependent") {
271
+ transport_config_mode = TRANSPORT_CONFIG_MODE_PLATFORM_DEPENDENT;
272
+ } else if (transport_config_mode_str == "PlatformIndependent") {
273
+ transport_config_mode = TRANSPORT_CONFIG_MODE_PLATFORM_INDEPENDENT;
274
+ } else {
275
+ throw std::invalid_argument("Invalid transport configuration mode: " + transport_config_mode_str);
276
+ }
277
+
278
+ std::string default_root_dir_str = jsTypedArrayToCString(runtime, arguments[2]);
279
+ const char* default_root_directory = default_root_dir_str.c_str();
280
+
281
+ // Extract callback
282
+ Function callback = arguments[3].getObject(runtime).getFunction(runtime);
283
+ Arc<Function> wrappedStateFfiWrapper(std::move(callback));
284
+
285
+ // Call the async FFI function
286
+ ::dittoffi_ditto_open_async_throws(
287
+ config_slice,
288
+ transport_config_mode,
289
+ default_root_directory,
290
+ {
291
+ .env_ptr = Arc<Function>::into_raw(std::move(wrappedStateFfiWrapper)),
292
+ .call = v_ditto_open_result,
293
+ .free = v_release,
294
+ }
295
+ );
296
+
297
+ return Value();
298
+ });
299
+ }
300
+
301
+
122
302
  }
@@ -8,7 +8,7 @@ namespace sharedjsi
8
8
  {
9
9
 
10
10
  extern "C" {
11
- void v_call(void *ctx, dittoffi_result_uint64 res)
11
+ void v_call(void *ctx, dittoffi_result_uint64_t res)
12
12
  {
13
13
  Arc<Function> const& borrowedJsCallback = Arc<Function>::borrow_from_raw(ctx);
14
14
  // copy ctor / retain so as to keep the ArcPointee<Function> alive until the enqueued_call completes.
@@ -75,6 +75,9 @@ String getErrorCodeString(jsi::Runtime &runtime, dittoffi_error_code_t error_cod
75
75
  case DITTOFFI_ERROR_CODE_VALIDATION_INVALID_JSON: return "ValidationInvalidJson";
76
76
  case DITTOFFI_ERROR_CODE_ACTIVATION_NOT_ACTIVATED: return "ActivationNotActivated";
77
77
  case DITTOFFI_ERROR_CODE_VALIDATION_INVALID_TRANSPORT_CONFIG: return "ValidationInvalidTransportConfig";
78
+ case DITTOFFI_ERROR_CODE_AUTHENTICATION_EXPIRATION_HANDLER_MISSING: return "AuthenticationExpirationHandlerMissing";
79
+ case DITTOFFI_ERROR_CODE_DIFFER_IDENTITY_KEY_PATH_INVALID: return "DifferIdentityKeyPathInvalid";
80
+ case DITTOFFI_ERROR_CODE_VALIDATION_INVALID_DITTO_CONFIG: return "ValidationInvalidDittoConfig";
78
81
  case DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_TOKEN_INVALID: return "ActivationLicenseTokenInvalid";
79
82
  case DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_TOKEN_EXPIRED: return "ActivationLicenseTokenExpired";
80
83
  case DITTOFFI_ERROR_CODE_ACTIVATION_LICENSE_UNSUPPORTED_FUTURE_VERSION: return "ActivationLicenseUnsupportedFutureVersion";
@@ -189,7 +192,11 @@ Function dittoffi_try_verify_license(Runtime &runtime) {
189
192
  dittoffi_result_void_t res = ::dittoffi_try_verify_license(ditto, license.c_str());
190
193
 
191
194
  Object obj(runtime);
192
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
195
+ if (res.error != nullptr) {
196
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
197
+ } else {
198
+ obj.setProperty(runtime, "error", Value::null());
199
+ }
193
200
  return obj;
194
201
  });
195
202
  }
@@ -269,7 +276,11 @@ Function dittoffi_try_base64_decode(Runtime &runtime)
269
276
 
270
277
  Object obj(runtime);
271
278
  obj.setProperty(runtime, "success", cSlicedBoxToJSSlicedBox(runtime, res.success));
272
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
279
+ if (res.error != nullptr) {
280
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
281
+ } else {
282
+ obj.setProperty(runtime, "error", Value::null());
283
+ }
273
284
  return obj;
274
285
  });
275
286
  }
@@ -127,7 +127,11 @@ Function dittoffi_presence_try_set_peer_metadata_json(Runtime &runtime)
127
127
  dittoffi_result_void_t res = ::dittoffi_presence_try_set_peer_metadata_json(ditto, peer_info);
128
128
 
129
129
  Object obj(runtime);
130
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
130
+ if (res.error != nullptr) {
131
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
132
+ } else {
133
+ obj.setProperty(runtime, "error", Value::null());
134
+ }
131
135
  return obj;
132
136
  });
133
137
  }
@@ -48,7 +48,11 @@ Function dittoffi_ditto_try_start_sync(Runtime &runtime)
48
48
  dittoffi_result_void_t res = ::dittoffi_ditto_try_start_sync(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
49
49
 
50
50
  Object obj(runtime);
51
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
51
+ if (res.error != nullptr) {
52
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
53
+ } else {
54
+ obj.setProperty(runtime, "error", Value::null());
55
+ }
52
56
 
53
57
  return obj;
54
58
  });
@@ -161,12 +161,17 @@ Function dittoffi_ditto_try_set_transport_config(Runtime &runtime)
161
161
  dittoffi_result_void_t res = ::dittoffi_ditto_try_set_transport_config(ditto, transport_config_cbor, should_validate);
162
162
 
163
163
  Object obj(runtime);
164
- obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
164
+ if (res.error != nullptr) {
165
+ obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
166
+ } else {
167
+ obj.setProperty(runtime, "error", Value::null());
168
+ }
165
169
  return obj;
166
170
  });
167
171
  }
168
172
 
169
- Function dittoffi_ditto_transport_config(Runtime &runtime)
173
+
174
+ Function dittoffi_ditto_set_cloud_sync_enabled(Runtime &runtime)
170
175
  {
171
176
  return Function::createFromHostFunction(runtime,
172
177
  PropNameID::forAscii(runtime,
@@ -177,13 +182,15 @@ Function dittoffi_ditto_transport_config(Runtime &runtime)
177
182
  const Value *arguments,
178
183
  size_t count) -> Value
179
184
  {
185
+ CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
186
+ bool enable_ditto_cloud_sync = arguments[1].asBool();
180
187
 
181
- slice_boxed_uint8_t transport_config_cbor = ::dittoffi_ditto_transport_config(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
182
- return cSlicedBoxToJSSlicedBox(runtime, transport_config_cbor);
188
+ ::dittoffi_ditto_set_cloud_sync_enabled(ditto, enable_ditto_cloud_sync);
189
+ return {};
183
190
  });
184
191
  }
185
192
 
186
- Function dittoffi_ditto_set_cloud_sync_enabled(Runtime &runtime)
193
+ Function ditto_register_transport_condition_changed_callback(Runtime &runtime)
187
194
  {
188
195
  return Function::createFromHostFunction(runtime,
189
196
  PropNameID::forAscii(runtime,
@@ -195,30 +202,28 @@ Function dittoffi_ditto_set_cloud_sync_enabled(Runtime &runtime)
195
202
  size_t count) -> Value
196
203
  {
197
204
  CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
198
- bool enable_ditto_cloud_sync = arguments[1].asBool();
199
-
200
- ::dittoffi_ditto_set_cloud_sync_enabled(ditto, enable_ditto_cloud_sync);
205
+ Function jsCallback = arguments[1].getObject(runtime).getFunction(runtime);
206
+ Arc<Function> wrappedStateFfiWrapper(std::move(jsCallback));
207
+
208
+ ::ditto_register_transport_condition_changed_callback(ditto, Arc<Function>::as_raw(wrappedStateFfiWrapper), v_retain, v_release, v_transport_condition_change_cb);
201
209
  return {};
202
210
  });
203
211
  }
204
212
 
205
- Function ditto_register_transport_condition_changed_callback(Runtime &runtime)
213
+ Function dittoffi_ditto_transport_config(Runtime &runtime)
206
214
  {
207
215
  return Function::createFromHostFunction(runtime,
208
216
  PropNameID::forAscii(runtime,
209
217
  STRINGIFIED_FUNC_NAME()),
210
- 0,
218
+ 1,
211
219
  [](Runtime &runtime,
212
220
  const Value &thisValue,
213
221
  const Value *arguments,
214
222
  size_t count) -> Value
215
223
  {
216
- CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
217
- Function jsCallback = arguments[1].getObject(runtime).getFunction(runtime);
218
- Arc<Function> wrappedStateFfiWrapper(std::move(jsCallback));
219
-
220
- ::ditto_register_transport_condition_changed_callback(ditto, Arc<Function>::as_raw(wrappedStateFfiWrapper), v_retain, v_release, v_transport_condition_change_cb);
221
- return {};
224
+ auto *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
225
+ slice_boxed_uint8_t transport_config_cbor = ::dittoffi_ditto_transport_config(ditto);
226
+ return cSlicedBoxToJSSlicedBox(runtime, transport_config_cbor);
222
227
  });
223
228
  }
224
229
  }
@@ -46,6 +46,13 @@ namespace sharedjsi
46
46
  // Lifecycle
47
47
  REGISTER_JS_FUNCTION(ditto_init_sdk_version);
48
48
  REGISTER_JS_FUNCTION(dittoffi_ditto_try_new_blocking);
49
+ REGISTER_JS_FUNCTION(dittoffi_ditto_open_throws);
50
+ REGISTER_JS_FUNCTION(dittoffi_DEFAULT_DATABASE_ID);
51
+ REGISTER_JS_FUNCTION(dittoffi_DITTO_DEVELOPMENT_PROVIDER);
52
+ REGISTER_JS_FUNCTION(dittoffi_ditto_config_default);
53
+ REGISTER_JS_FUNCTION(dittoffi_ditto_config);
54
+ REGISTER_JS_FUNCTION(dittoffi_ditto_transport_config);
55
+ REGISTER_JS_FUNCTION(dittoffi_ditto_open_async_throws);
49
56
  REGISTER_JS_FUNCTION(ditto_shutdown);
50
57
  REGISTER_JS_FUNCTION(ditto_free);
51
58
 
@@ -100,6 +107,8 @@ namespace sharedjsi
100
107
  REGISTER_JS_FUNCTION(dittoffi_query_result_free);
101
108
  REGISTER_JS_FUNCTION(dittoffi_query_result_item_free);
102
109
  REGISTER_JS_FUNCTION(dittoffi_query_result_item_new);
110
+ REGISTER_JS_FUNCTION(dittoffi_query_result_has_commit_id);
111
+ REGISTER_JS_FUNCTION(dittoffi_query_result_commit_id);
103
112
 
104
113
  // Differ
105
114
  REGISTER_JS_FUNCTION(dittoffi_differ_new);
@@ -169,7 +178,6 @@ namespace sharedjsi
169
178
  REGISTER_JS_FUNCTION(ditto_sdk_transports_error_value);
170
179
  REGISTER_JS_FUNCTION(ditto_sdk_transports_error_free);
171
180
  REGISTER_JS_FUNCTION(dittoffi_ditto_try_set_transport_config);
172
- REGISTER_JS_FUNCTION(dittoffi_ditto_transport_config);
173
181
  REGISTER_JS_FUNCTION(dittoffi_ditto_set_cloud_sync_enabled);
174
182
  REGISTER_JS_FUNCTION(ditto_register_transport_condition_changed_callback);
175
183
 
@@ -200,9 +208,11 @@ namespace sharedjsi
200
208
  // IO
201
209
  REGISTER_JS_FUNCTION(readFile);
202
210
  REGISTER_JS_FUNCTION(copyFile);
211
+ REGISTER_JS_FUNCTION(dittoffi_ditto_absolute_persistence_directory);
203
212
 
204
213
  // createDirectory() doesn't fit our macro, as it requires an additional parameter
205
214
  String defaultDirectory = parameters.getProperty(runtime, "defaultDirectory").asString(runtime);
206
215
  runtime.global().setProperty(runtime, "createDirectory", createDirectory(runtime, defaultDirectory));
216
+ runtime.global().setProperty(runtime, "getDefaultDirectory", getDefaultDirectory(runtime, defaultDirectory));
207
217
  }
208
218
  }