@dittolive/ditto 4.7.4-rc.2 → 4.7.4
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 +2 -2
- package/node/ditto.cjs.js +1 -1
- 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 +5 -2
- package/react-native/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/react-native/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/react-native/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/react-native/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/react-native/android/.gradle/8.9/gc.properties +0 -0
- package/react-native/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/react-native/android/.gradle/buildOutputCleanup/cache.properties +2 -0
- package/react-native/android/.gradle/vcs-1/gc.properties +0 -0
- package/react-native/android/CMakeLists.txt +36 -0
- package/react-native/android/build.gradle +190 -0
- package/react-native/android/cpp-adapter.cpp +259 -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 +120 -0
- package/react-native/android/src/main/java/com/dittolive/rnsdk/DittoRNSDKPackage.java +28 -0
- package/react-native/cpp/include/Arc.hpp +159 -0
- package/react-native/cpp/include/Attachment.h +20 -0
- package/react-native/cpp/include/Authentication.h +23 -0
- package/react-native/cpp/include/Collection.h +13 -0
- package/react-native/cpp/include/ConnectionRequest.h +18 -0
- package/react-native/cpp/include/DQL.h +21 -0
- package/react-native/cpp/include/Document.h +17 -0
- package/react-native/cpp/include/FFIUtils.h +16 -0
- package/react-native/cpp/include/IO.h +13 -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 +30 -0
- package/react-native/cpp/include/Presence.h +18 -0
- package/react-native/cpp/include/SmallPeerInfo.h +19 -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 +70 -0
- package/react-native/cpp/include/main.h +10 -0
- package/react-native/cpp/src/Attachment.cpp +272 -0
- package/react-native/cpp/src/Authentication.cpp +227 -0
- package/react-native/cpp/src/Collection.cpp +56 -0
- package/react-native/cpp/src/ConnectionRequest.cpp +123 -0
- package/react-native/cpp/src/DQL.cpp +256 -0
- package/react-native/cpp/src/Document.cpp +146 -0
- package/react-native/cpp/src/FFIUtils.cpp +122 -0
- package/react-native/cpp/src/IO.cpp +35 -0
- package/react-native/cpp/src/Identity.cpp +122 -0
- package/react-native/cpp/src/Lifecycle.cpp +93 -0
- package/react-native/cpp/src/LiveQuery.cpp +63 -0
- package/react-native/cpp/src/Logger.cpp +199 -0
- package/react-native/cpp/src/Misc.cpp +322 -0
- package/react-native/cpp/src/Presence.cpp +166 -0
- package/react-native/cpp/src/SmallPeerInfo.cpp +142 -0
- package/react-native/cpp/src/Transports.cpp +275 -0
- package/react-native/cpp/src/TypedArray.cpp +303 -0
- package/react-native/cpp/src/Utils.cpp +139 -0
- package/react-native/cpp/src/main.cpp +178 -0
- package/react-native/dittoffi/dittoffi.h +4873 -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 +159 -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 +61 -0
- package/react-native/lib/commonjs/index.js.map +1 -0
- package/react-native/lib/module/ditto.rn.js +89 -0
- package/react-native/lib/module/ditto.rn.js.map +1 -0
- package/react-native/lib/module/index.js +27 -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/src/ditto.rn.ts +123 -0
- package/react-native/src/environment/environment.fallback.ts +4 -0
- package/react-native/src/index.ts +29 -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 +1 -0
- package/react-native/src/sources/attachment-fetch-event.ts +54 -0
- package/react-native/src/sources/attachment-fetcher-manager.ts +145 -0
- package/react-native/src/sources/attachment-fetcher.ts +265 -0
- package/react-native/src/sources/attachment-token.ts +129 -0
- package/react-native/src/sources/attachment.ts +121 -0
- package/react-native/src/sources/augment.ts +108 -0
- package/react-native/src/sources/authenticator.ts +314 -0
- package/react-native/src/sources/base-pending-cursor-operation.ts +255 -0
- package/react-native/src/sources/base-pending-id-specific-operation.ts +112 -0
- package/react-native/src/sources/bridge.ts +557 -0
- package/react-native/src/sources/build-time-constants.ts +8 -0
- package/react-native/src/sources/cbor.ts +20 -0
- package/react-native/src/sources/collection-interface.ts +73 -0
- package/react-native/src/sources/collection.ts +219 -0
- package/react-native/src/sources/collections-event.ts +99 -0
- package/react-native/src/sources/connection-request.ts +142 -0
- package/react-native/src/sources/counter.ts +82 -0
- package/react-native/src/sources/ditto.ts +991 -0
- package/react-native/src/sources/document-id.ts +163 -0
- package/react-native/src/sources/document-path.ts +308 -0
- package/react-native/src/sources/document.ts +237 -0
- package/react-native/src/sources/epilogue.ts +32 -0
- package/react-native/src/sources/error-codes.ts +114 -0
- package/react-native/src/sources/error.ts +256 -0
- package/react-native/src/sources/essentials.ts +81 -0
- package/react-native/src/sources/ffi-error.ts +134 -0
- package/react-native/src/sources/ffi.ts +2190 -0
- package/react-native/src/sources/identity.ts +163 -0
- package/react-native/src/sources/init.ts +71 -0
- package/react-native/src/sources/internal.ts +143 -0
- package/react-native/src/sources/keep-alive.ts +73 -0
- package/react-native/src/sources/key-path.ts +198 -0
- package/react-native/src/sources/live-query-event.ts +208 -0
- package/react-native/src/sources/live-query-manager.ts +110 -0
- package/react-native/src/sources/live-query.ts +167 -0
- package/react-native/src/sources/logger.ts +196 -0
- package/react-native/src/sources/main.ts +61 -0
- package/react-native/src/sources/observer-manager.ts +185 -0
- package/react-native/src/sources/observer.ts +79 -0
- package/react-native/src/sources/pending-collections-operation.ts +241 -0
- package/react-native/src/sources/pending-cursor-operation.ts +218 -0
- package/react-native/src/sources/pending-id-specific-operation.ts +218 -0
- package/react-native/src/sources/presence-manager.ts +170 -0
- package/react-native/src/sources/presence.ts +427 -0
- package/react-native/src/sources/query-result-item.ts +131 -0
- package/react-native/src/sources/query-result.ts +55 -0
- package/react-native/src/sources/register.ts +95 -0
- package/react-native/src/sources/small-peer-info.ts +166 -0
- package/react-native/src/sources/static-tcp-client.ts +8 -0
- package/react-native/src/sources/store-observer.ts +170 -0
- package/react-native/src/sources/store.ts +630 -0
- package/react-native/src/sources/subscription-manager.ts +99 -0
- package/react-native/src/sources/subscription.ts +89 -0
- package/react-native/src/sources/sync-subscription.ts +90 -0
- package/react-native/src/sources/sync.ts +561 -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 +430 -0
- package/react-native/src/sources/update-result.ts +66 -0
- package/react-native/src/sources/update-results-map.ts +65 -0
- package/react-native/src/sources/websocket-client.ts +7 -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 +74 -0
- package/react-native/src/sources/write-transaction.ts +121 -0
- package/react-native.config.js +9 -0
- package/web/ditto.es6.js +1 -1
- package/web/ditto.umd.js +1 -1
- package/web/ditto.wasm +0 -0
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
#include "Utils.h"
|
|
2
|
+
#include "Arc.hpp"
|
|
3
|
+
|
|
4
|
+
#include <Authentication.h>
|
|
5
|
+
|
|
6
|
+
namespace sharedjsi
|
|
7
|
+
{
|
|
8
|
+
|
|
9
|
+
DEFINE_RETAIN_RELEASE_FOR(Function, v_retain, v_release);
|
|
10
|
+
extern "C"
|
|
11
|
+
{
|
|
12
|
+
void v_auth_client_validity_update(void *ctx, int is_web_valid, int is_x509_valid)
|
|
13
|
+
{
|
|
14
|
+
Arc<Function> const& borrowedJsCallback = Arc<Function>::borrow_from_raw(ctx);
|
|
15
|
+
// copy ctor / retain so as to keep the ArcPointee<Function> alive until the enqueued_call completes.
|
|
16
|
+
ditto_enqueue_call([=, jsCallback=Arc<Function>(borrowedJsCallback)](Runtime *runtime) {
|
|
17
|
+
jsCallback->call(*runtime,
|
|
18
|
+
Value(static_cast<double>(is_web_valid)),
|
|
19
|
+
Value(static_cast<double>(is_x509_valid)));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
void v_auth_client_expiring_callback(void *ctx, uint32_t secs_until_expiry)
|
|
24
|
+
{
|
|
25
|
+
Arc<Function> const& borrowedJsCallback = Arc<Function>::borrow_from_raw(ctx);
|
|
26
|
+
// copy ctor / retain so as to keep the ArcPointee<Function> alive until the enqueued_call completes.
|
|
27
|
+
ditto_enqueue_call([=, jsCallback=Arc<Function>(borrowedJsCallback)](Runtime *runtime) {
|
|
28
|
+
jsCallback->call(*runtime,
|
|
29
|
+
Value(static_cast<double>(secs_until_expiry)));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
Function ditto_auth_client_set_validity_listener(Runtime &runtime)
|
|
35
|
+
{
|
|
36
|
+
return Function::createFromHostFunction(runtime, PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()), 0, [](Runtime &runtime, Value const &thisValue, Value const *arguments, size_t count) -> Value
|
|
37
|
+
{
|
|
38
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
39
|
+
Function jsCallback = arguments[1].getObject(runtime).getFunction(runtime);
|
|
40
|
+
Arc<Function> wrappedStateFfiWrapper /* = */ (std::move(jsCallback));
|
|
41
|
+
|
|
42
|
+
::ditto_auth_client_set_validity_listener(
|
|
43
|
+
ditto,
|
|
44
|
+
Arc<Function>::as_raw(wrappedStateFfiWrapper),
|
|
45
|
+
v_retain,
|
|
46
|
+
v_release,
|
|
47
|
+
v_auth_client_validity_update);
|
|
48
|
+
|
|
49
|
+
return Value();
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Function ditto_auth_client_is_web_valid(Runtime &runtime)
|
|
54
|
+
{
|
|
55
|
+
return Function::createFromHostFunction(runtime,
|
|
56
|
+
PropNameID::forAscii(runtime,
|
|
57
|
+
STRINGIFIED_FUNC_NAME()),
|
|
58
|
+
0,
|
|
59
|
+
[](Runtime &runtime,
|
|
60
|
+
const Value &thisValue,
|
|
61
|
+
const Value *arguments,
|
|
62
|
+
size_t count) -> Value
|
|
63
|
+
{
|
|
64
|
+
return ::ditto_auth_client_is_web_valid(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
Function ditto_auth_client_is_x509_valid(Runtime &runtime)
|
|
69
|
+
{
|
|
70
|
+
return Function::createFromHostFunction(runtime,
|
|
71
|
+
PropNameID::forAscii(runtime,
|
|
72
|
+
STRINGIFIED_FUNC_NAME()),
|
|
73
|
+
0,
|
|
74
|
+
[](Runtime &runtime,
|
|
75
|
+
const Value &thisValue,
|
|
76
|
+
const Value *arguments,
|
|
77
|
+
size_t count) -> Value
|
|
78
|
+
{
|
|
79
|
+
return ::ditto_auth_client_is_x509_valid(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
Function ditto_auth_client_get_app_id(Runtime &runtime)
|
|
84
|
+
{
|
|
85
|
+
return Function::createFromHostFunction(runtime,
|
|
86
|
+
PropNameID::forAscii(runtime,
|
|
87
|
+
STRINGIFIED_FUNC_NAME()),
|
|
88
|
+
0,
|
|
89
|
+
[](Runtime &runtime,
|
|
90
|
+
const Value &thisValue,
|
|
91
|
+
const Value *arguments,
|
|
92
|
+
size_t count) -> Value
|
|
93
|
+
{
|
|
94
|
+
char *appId = ::ditto_auth_client_get_app_id(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
95
|
+
return cPointerToJSPointerObject<char>(runtime, appId);
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
Function ditto_auth_client_get_site_id(Runtime &runtime)
|
|
100
|
+
{
|
|
101
|
+
return Function::createFromHostFunction(runtime,
|
|
102
|
+
PropNameID::forAscii(runtime,
|
|
103
|
+
STRINGIFIED_FUNC_NAME()),
|
|
104
|
+
0,
|
|
105
|
+
[](Runtime &runtime,
|
|
106
|
+
const Value &thisValue,
|
|
107
|
+
const Value *arguments,
|
|
108
|
+
size_t count) -> Value
|
|
109
|
+
{
|
|
110
|
+
uint64_t siteId = ::ditto_auth_client_get_site_id(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
111
|
+
return uint64ToBigIntOrNumber(runtime, siteId);
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
Function ditto_auth_client_make_login_provider(Runtime &runtime)
|
|
116
|
+
{
|
|
117
|
+
return Function::createFromHostFunction(runtime,
|
|
118
|
+
PropNameID::forAscii(runtime,
|
|
119
|
+
STRINGIFIED_FUNC_NAME()),
|
|
120
|
+
0,
|
|
121
|
+
[](Runtime &runtime,
|
|
122
|
+
const Value &thisValue,
|
|
123
|
+
const Value *arguments,
|
|
124
|
+
size_t count) -> Value
|
|
125
|
+
{
|
|
126
|
+
Function expiringCallback = arguments[0].getObject(runtime).getFunction(runtime);
|
|
127
|
+
Arc<Function> wrappedStateFfiWrapper(std::move(expiringCallback));
|
|
128
|
+
|
|
129
|
+
CLoginProvider_t *loginProvider = ::ditto_auth_client_make_login_provider(Arc<Function>::as_raw(wrappedStateFfiWrapper),
|
|
130
|
+
v_retain,
|
|
131
|
+
v_release,
|
|
132
|
+
v_auth_client_expiring_callback);
|
|
133
|
+
|
|
134
|
+
return cPointerToJSPointerObject(runtime, loginProvider);
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
Function ditto_auth_set_login_provider(Runtime &runtime)
|
|
139
|
+
{
|
|
140
|
+
return Function::createFromHostFunction(runtime,
|
|
141
|
+
PropNameID::forAscii(runtime,
|
|
142
|
+
STRINGIFIED_FUNC_NAME()),
|
|
143
|
+
0,
|
|
144
|
+
[](Runtime &runtime,
|
|
145
|
+
const Value &thisValue,
|
|
146
|
+
const Value *arguments,
|
|
147
|
+
size_t count) -> Value
|
|
148
|
+
{
|
|
149
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
150
|
+
CLoginProvider_t *loginProvider = jsPointerObjectToCPointer<CLoginProvider_t>(runtime, arguments[1]);
|
|
151
|
+
|
|
152
|
+
::ditto_auth_set_login_provider(ditto, loginProvider);
|
|
153
|
+
return Value();
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
Function ditto_auth_client_login_with_token(Runtime &runtime)
|
|
158
|
+
{
|
|
159
|
+
return Function::createFromHostFunction(runtime,
|
|
160
|
+
PropNameID::forAscii(runtime,
|
|
161
|
+
STRINGIFIED_FUNC_NAME()),
|
|
162
|
+
0,
|
|
163
|
+
[](Runtime &runtime,
|
|
164
|
+
const Value &thisValue,
|
|
165
|
+
const Value *arguments,
|
|
166
|
+
size_t count) -> Value
|
|
167
|
+
{
|
|
168
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
169
|
+
std::string token = jsTypedArrayToCString(runtime, arguments[1]);
|
|
170
|
+
std::string provider = jsTypedArrayToCString(runtime, arguments[2]);
|
|
171
|
+
|
|
172
|
+
return ::ditto_auth_client_login_with_token(ditto, token.c_str(), provider.c_str());
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
Function ditto_auth_client_login_with_credentials(Runtime &runtime)
|
|
177
|
+
{
|
|
178
|
+
return Function::createFromHostFunction(runtime,
|
|
179
|
+
PropNameID::forAscii(runtime,
|
|
180
|
+
STRINGIFIED_FUNC_NAME()),
|
|
181
|
+
0,
|
|
182
|
+
[](Runtime &runtime,
|
|
183
|
+
const Value &thisValue,
|
|
184
|
+
const Value *arguments,
|
|
185
|
+
size_t count) -> Value
|
|
186
|
+
{
|
|
187
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
188
|
+
|
|
189
|
+
std::string username = jsTypedArrayToCString(runtime, arguments[1]);
|
|
190
|
+
std::string password = jsTypedArrayToCString(runtime, arguments[2]);
|
|
191
|
+
std::string provider = jsTypedArrayToCString(runtime, arguments[3]);
|
|
192
|
+
|
|
193
|
+
return ::ditto_auth_client_login_with_credentials(ditto, username.c_str(), password.c_str(), provider.c_str());
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
Function ditto_auth_client_logout(Runtime &runtime)
|
|
198
|
+
{
|
|
199
|
+
return Function::createFromHostFunction(runtime,
|
|
200
|
+
PropNameID::forAscii(runtime,
|
|
201
|
+
STRINGIFIED_FUNC_NAME()),
|
|
202
|
+
0,
|
|
203
|
+
[](Runtime &runtime,
|
|
204
|
+
const Value &thisValue,
|
|
205
|
+
const Value *arguments,
|
|
206
|
+
size_t count) -> Value
|
|
207
|
+
{
|
|
208
|
+
return ::ditto_auth_client_logout(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
Function ditto_auth_client_user_id(Runtime &runtime)
|
|
213
|
+
{
|
|
214
|
+
return Function::createFromHostFunction(runtime,
|
|
215
|
+
PropNameID::forAscii(runtime,
|
|
216
|
+
STRINGIFIED_FUNC_NAME()),
|
|
217
|
+
0,
|
|
218
|
+
[](Runtime &runtime,
|
|
219
|
+
const Value &thisValue,
|
|
220
|
+
const Value *arguments,
|
|
221
|
+
size_t count) -> Value
|
|
222
|
+
{
|
|
223
|
+
char *res = ::ditto_auth_client_user_id(jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]));
|
|
224
|
+
return cPointerToJSPointerObject<char>(runtime, res);
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
#include "Utils.h"
|
|
2
|
+
|
|
3
|
+
#include <Collection.h>
|
|
4
|
+
|
|
5
|
+
namespace sharedjsi
|
|
6
|
+
{
|
|
7
|
+
|
|
8
|
+
Function ditto_collection_insert_value(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
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
20
|
+
|
|
21
|
+
std::string collection_name_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
22
|
+
const char *collectionName = collection_name_str.c_str();
|
|
23
|
+
|
|
24
|
+
TypedArrayBase typedArrayBase(runtime, arguments[2].asObject(runtime));
|
|
25
|
+
std::vector<uint8_t> docCborVector = typedArrayBase.toVector(runtime);
|
|
26
|
+
slice_ref_uint8_t docCbor = { .ptr = docCborVector.data(), .len = docCborVector.size() };
|
|
27
|
+
|
|
28
|
+
WriteStrategyRs_t writeStrategy;
|
|
29
|
+
std::string writeStrategyStr = arguments[3].asString(runtime).utf8(runtime);
|
|
30
|
+
|
|
31
|
+
if (writeStrategyStr == "Merge") {
|
|
32
|
+
writeStrategy = WRITE_STRATEGY_RS_MERGE;
|
|
33
|
+
} else if (writeStrategyStr == "InsertIfAbsent") {
|
|
34
|
+
writeStrategy = WRITE_STRATEGY_RS_INSERT_IF_ABSENT;
|
|
35
|
+
} else if (writeStrategyStr == "InsertDefaultIfAbsent") {
|
|
36
|
+
writeStrategy = WRITE_STRATEGY_RS_INSERT_DEFAULT_IF_ABSENT;
|
|
37
|
+
} else if (writeStrategyStr == "UpdateDifferentValues") {
|
|
38
|
+
writeStrategy = WRITE_STRATEGY_RS_UPDATE_DIFFERENT_VALUES;
|
|
39
|
+
} else {
|
|
40
|
+
throw std::invalid_argument("Invalid write strategy");
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
std::string log_hint_str = jsTypedArrayToCString(runtime, arguments[4]);
|
|
44
|
+
const char *log_hint = log_hint_str.c_str();
|
|
45
|
+
|
|
46
|
+
CWriteTransaction_t *writeTransaction = jsPointerObjectToCPointer<CWriteTransaction_t>(runtime, arguments[5]);
|
|
47
|
+
|
|
48
|
+
DocIdResult_t res = ::ditto_collection_insert_value(ditto, collectionName, docCbor, writeStrategy, log_hint, writeTransaction);
|
|
49
|
+
|
|
50
|
+
Object obj(runtime);
|
|
51
|
+
obj.setProperty(runtime, "status_code", static_cast<double>(res.status_code));
|
|
52
|
+
obj.setProperty(runtime, "id", pointerToHexString(res.id.ptr));
|
|
53
|
+
return obj;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#include "Utils.h"
|
|
2
|
+
#include "ConnectionRequest.h"
|
|
3
|
+
#include <unordered_map>
|
|
4
|
+
|
|
5
|
+
namespace sharedjsi
|
|
6
|
+
{
|
|
7
|
+
|
|
8
|
+
Function dittoffi_connection_request_peer_key_string(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 connection_request = jsPointerObjectToCPointer<dittoffi_connection_request_t>(runtime, arguments[0]);
|
|
20
|
+
char *res = ::dittoffi_connection_request_peer_key_string(connection_request);
|
|
21
|
+
return cPointerToJSPointerObject<char>(runtime, res);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
Function dittoffi_connection_request_peer_metadata_json(Runtime &runtime)
|
|
26
|
+
{
|
|
27
|
+
return Function::createFromHostFunction(runtime,
|
|
28
|
+
PropNameID::forAscii(runtime,
|
|
29
|
+
STRINGIFIED_FUNC_NAME()),
|
|
30
|
+
0,
|
|
31
|
+
[](Runtime &runtime,
|
|
32
|
+
const Value &thisValue,
|
|
33
|
+
const Value *arguments,
|
|
34
|
+
size_t count) -> Value
|
|
35
|
+
{
|
|
36
|
+
auto connection_request = jsPointerObjectToCPointer<dittoffi_connection_request_t>(runtime, arguments[0]);
|
|
37
|
+
slice_ref_uint8_t res = ::dittoffi_connection_request_peer_metadata_json(connection_request);
|
|
38
|
+
return cSlicedBoxToJSSlicedBox(runtime, res);
|
|
39
|
+
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
Function dittoffi_connection_request_identity_service_metadata_json(Runtime &runtime)
|
|
44
|
+
{
|
|
45
|
+
return Function::createFromHostFunction(runtime,
|
|
46
|
+
PropNameID::forAscii(runtime,
|
|
47
|
+
STRINGIFIED_FUNC_NAME()),
|
|
48
|
+
0,
|
|
49
|
+
[](Runtime &runtime,
|
|
50
|
+
const Value &thisValue,
|
|
51
|
+
const Value *arguments,
|
|
52
|
+
size_t count) -> Value
|
|
53
|
+
{
|
|
54
|
+
auto connection_request = jsPointerObjectToCPointer<dittoffi_connection_request_t>(runtime, arguments[0]);
|
|
55
|
+
slice_ref_uint8_t res = ::dittoffi_connection_request_identity_service_metadata_json(connection_request);
|
|
56
|
+
return cSlicedBoxToJSSlicedBox(runtime, res);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
Function dittoffi_connection_request_authorize(Runtime &runtime)
|
|
61
|
+
{
|
|
62
|
+
return Function::createFromHostFunction(runtime,
|
|
63
|
+
PropNameID::forAscii(runtime,
|
|
64
|
+
STRINGIFIED_FUNC_NAME()),
|
|
65
|
+
0,
|
|
66
|
+
[](Runtime &runtime,
|
|
67
|
+
const Value &thisValue,
|
|
68
|
+
const Value *arguments,
|
|
69
|
+
size_t count) -> Value
|
|
70
|
+
{
|
|
71
|
+
auto connection_request = jsPointerObjectToCPointer<dittoffi_connection_request_t>(runtime, arguments[0]);
|
|
72
|
+
auto authorized_string = arguments[1].toString(runtime).utf8(runtime);
|
|
73
|
+
auto authorized = authorized_string == "Allow" ? DITTOFFI_CONNECTION_REQUEST_AUTHORIZATION_ALLOW : DITTOFFI_CONNECTION_REQUEST_AUTHORIZATION_DENY;
|
|
74
|
+
|
|
75
|
+
::dittoffi_connection_request_authorize(connection_request, authorized);
|
|
76
|
+
return Value();
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
Function dittoffi_connection_request_connection_type(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
|
+
dittoffi_connection_type_t res = ::dittoffi_connection_request_connection_type(jsPointerObjectToCPointer<dittoffi_connection_request_t>(runtime, arguments[0]));
|
|
92
|
+
|
|
93
|
+
static const std::unordered_map<dittoffi_connection_type_t, std::string> lookup = {
|
|
94
|
+
{DITTOFFI_CONNECTION_TYPE_BLUETOOTH, "Bluetooth"},
|
|
95
|
+
{DITTOFFI_CONNECTION_TYPE_ACCESS_POINT, "AccessPoint"},
|
|
96
|
+
{DITTOFFI_CONNECTION_TYPE_P2_P_WI_FI, "P2PWiFi"},
|
|
97
|
+
{DITTOFFI_CONNECTION_TYPE_WEB_SOCKET, "WebSocket"},
|
|
98
|
+
};
|
|
99
|
+
auto it = lookup.find(res);
|
|
100
|
+
if (it != lookup.end()) {
|
|
101
|
+
return String::createFromUtf8(runtime, it->second);
|
|
102
|
+
} else {
|
|
103
|
+
throw std::invalid_argument("Invalid dittoffi_connection_type_t type");
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
Function dittoffi_connection_request_free(Runtime &runtime)
|
|
109
|
+
{
|
|
110
|
+
return Function::createFromHostFunction(runtime,
|
|
111
|
+
PropNameID::forAscii(runtime,
|
|
112
|
+
STRINGIFIED_FUNC_NAME()),
|
|
113
|
+
0,
|
|
114
|
+
[](Runtime &runtime,
|
|
115
|
+
const Value &thisValue,
|
|
116
|
+
const Value *arguments,
|
|
117
|
+
size_t count) -> Value
|
|
118
|
+
{
|
|
119
|
+
::dittoffi_connection_request_free(jsPointerObjectToCPointer<dittoffi_connection_request_t>(runtime, arguments[0]));
|
|
120
|
+
return Value();
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
#include <DQL.h>
|
|
2
|
+
#include <dittoffi.h>
|
|
3
|
+
|
|
4
|
+
#include "Arc.hpp"
|
|
5
|
+
#include "Utils.h"
|
|
6
|
+
#include "LiveQuery.h"
|
|
7
|
+
|
|
8
|
+
namespace sharedjsi
|
|
9
|
+
{
|
|
10
|
+
|
|
11
|
+
DEFINE_RETAIN_RELEASE_FOR(Function, v_retain, v_release);
|
|
12
|
+
|
|
13
|
+
extern "C" {
|
|
14
|
+
void v_change_handler_with_query_result(void *ctx, ChangeHandlerWithQueryResult_t result)
|
|
15
|
+
{
|
|
16
|
+
Arc<Function> const& borrowedJsCallback = Arc<Function>::borrow_from_raw(ctx);
|
|
17
|
+
// copy ctor / retain so as to keep the ArcPointee<Function> alive until the enqueued_call completes.
|
|
18
|
+
Arc<Function> jsCallback /* = */ (borrowedJsCallback);
|
|
19
|
+
ditto_enqueue_call([=](Runtime *jsi) {
|
|
20
|
+
Runtime &runtime = *jsi;
|
|
21
|
+
dittoffi_query_result_t *query_result = result.query_result;
|
|
22
|
+
|
|
23
|
+
Object obj(runtime);
|
|
24
|
+
obj.setProperty(runtime, "query_result", cPointerToJSPointerObject(runtime, query_result));
|
|
25
|
+
|
|
26
|
+
jsCallback->call(runtime, obj);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
Function dittoffi_try_add_sync_subscription(Runtime &runtime)
|
|
32
|
+
{
|
|
33
|
+
return Function::createFromHostFunction(runtime,
|
|
34
|
+
PropNameID::forAscii(runtime,
|
|
35
|
+
STRINGIFIED_FUNC_NAME()),
|
|
36
|
+
0,
|
|
37
|
+
[](Runtime &runtime,
|
|
38
|
+
const Value &thisValue,
|
|
39
|
+
const Value *arguments,
|
|
40
|
+
size_t count) -> Value
|
|
41
|
+
{
|
|
42
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
43
|
+
std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
44
|
+
const char *query = query_str.c_str();
|
|
45
|
+
|
|
46
|
+
std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
|
|
47
|
+
slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
|
|
48
|
+
|
|
49
|
+
dittoffi_result_void_t res = ::dittoffi_try_add_sync_subscription(ditto, query, query_args_cbor);
|
|
50
|
+
|
|
51
|
+
Object obj(runtime);
|
|
52
|
+
obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
|
|
53
|
+
return obj;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
Function dittoffi_try_remove_sync_subscription(Runtime &runtime)
|
|
58
|
+
{
|
|
59
|
+
return Function::createFromHostFunction(runtime,
|
|
60
|
+
PropNameID::forAscii(runtime,
|
|
61
|
+
STRINGIFIED_FUNC_NAME()),
|
|
62
|
+
0,
|
|
63
|
+
[](Runtime &runtime,
|
|
64
|
+
const Value &thisValue,
|
|
65
|
+
const Value *arguments,
|
|
66
|
+
size_t count) -> Value
|
|
67
|
+
{
|
|
68
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
69
|
+
std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
70
|
+
const char *query = query_str.c_str();
|
|
71
|
+
|
|
72
|
+
std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
|
|
73
|
+
slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
|
|
74
|
+
dittoffi_result_void_t res = ::dittoffi_try_remove_sync_subscription(ditto, query, query_args_cbor);
|
|
75
|
+
|
|
76
|
+
Object obj(runtime);
|
|
77
|
+
obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
|
|
78
|
+
return obj;
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
Function dittoffi_try_exec_statement(Runtime &runtime)
|
|
83
|
+
{
|
|
84
|
+
return Function::createFromHostFunction(runtime,
|
|
85
|
+
PropNameID::forAscii(runtime,
|
|
86
|
+
STRINGIFIED_FUNC_NAME()),
|
|
87
|
+
0,
|
|
88
|
+
[](Runtime &runtime,
|
|
89
|
+
const Value &thisValue,
|
|
90
|
+
const Value *arguments,
|
|
91
|
+
size_t count) -> Value
|
|
92
|
+
{
|
|
93
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
94
|
+
CWriteTransaction *writeTransaction = jsPointerObjectToCPointer<CWriteTransaction_t>(runtime, arguments[1]);
|
|
95
|
+
std::string query_vec = jsTypedArrayToCString(runtime, arguments[2]);
|
|
96
|
+
const char *query = query_vec.c_str();
|
|
97
|
+
|
|
98
|
+
std::vector<uint8_t> args_vec = jsTypedArrayToCVector(runtime, arguments[3]);
|
|
99
|
+
slice_ref_uint8_t args_cbor = borrowVecAsOptRefSlice(args_vec);
|
|
100
|
+
dittoffi_result_dittoffi_query_result_ptr res = ::dittoffi_try_exec_statement(ditto, writeTransaction, query, args_cbor);
|
|
101
|
+
|
|
102
|
+
Object obj(runtime);
|
|
103
|
+
obj.setProperty(runtime, "success", cPointerToJSPointerObject(runtime, res.success));
|
|
104
|
+
obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
|
|
105
|
+
return obj;
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
Function dittoffi_try_experimental_register_change_observer_str_detached(Runtime &runtime)
|
|
110
|
+
{
|
|
111
|
+
return Function::createFromHostFunction(runtime,
|
|
112
|
+
PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
|
|
113
|
+
0,
|
|
114
|
+
[](Runtime &runtime,
|
|
115
|
+
const Value &thisValue,
|
|
116
|
+
const Value *arguments,
|
|
117
|
+
size_t count) -> Value
|
|
118
|
+
{
|
|
119
|
+
CDitto_t *ditto = jsPointerObjectToCPointer<CDitto_t>(runtime, arguments[0]);
|
|
120
|
+
std::string query_str = jsTypedArrayToCString(runtime, arguments[1]);
|
|
121
|
+
const char *query = query_str.c_str();
|
|
122
|
+
|
|
123
|
+
std::vector<uint8_t> query_args_cbor_vec = jsTypedArrayToCVector(runtime, arguments[2]);
|
|
124
|
+
slice_ref_uint8_t query_args_cbor = borrowVecAsOptRefSlice(query_args_cbor_vec);
|
|
125
|
+
|
|
126
|
+
Function jsCallback = arguments[3].getObject(runtime).getFunction(runtime);
|
|
127
|
+
Arc<Function> wrappedStateFfiWrapper(std::move(jsCallback));
|
|
128
|
+
|
|
129
|
+
LiveQueryAvailability lq_availability = LIVE_QUERY_AVAILABILITY_ALWAYS;
|
|
130
|
+
// std::string lq_availability_str = arguments[3].getString(runtime).utf8(runtime);
|
|
131
|
+
// if (lq_availability_str == "Always") {
|
|
132
|
+
// lq_availability = LIVE_QUERY_AVAILABILITY_ALWAYS;
|
|
133
|
+
// } if (lq_availability_str == "WhenSignalled") {
|
|
134
|
+
// lq_availability = LIVE_QUERY_AVAILABILITY_WHEN_SIGNALLED;
|
|
135
|
+
// } else {
|
|
136
|
+
// throw std::invalid_argument("Invalid live query string");
|
|
137
|
+
// }
|
|
138
|
+
|
|
139
|
+
dittoffi_result_int64_t res = ::dittoffi_try_experimental_register_change_observer_str(
|
|
140
|
+
ditto,
|
|
141
|
+
query,
|
|
142
|
+
query_args_cbor,
|
|
143
|
+
lq_availability,
|
|
144
|
+
Arc<Function>::as_raw(wrappedStateFfiWrapper),
|
|
145
|
+
v_retain,
|
|
146
|
+
v_release,
|
|
147
|
+
v_change_handler_with_query_result);
|
|
148
|
+
|
|
149
|
+
Object obj(runtime);
|
|
150
|
+
obj.setProperty(runtime, "success", int64ToBigIntOrNumber(runtime, res.success));
|
|
151
|
+
obj.setProperty(runtime, "error", cPointerToJSPointerObject(runtime, res.error));
|
|
152
|
+
return obj;
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
Function dittoffi_query_result_item_count(Runtime &runtime)
|
|
158
|
+
{
|
|
159
|
+
return Function::createFromHostFunction(runtime,
|
|
160
|
+
PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
|
|
161
|
+
0,
|
|
162
|
+
[](Runtime &runtime,
|
|
163
|
+
const Value &thisValue,
|
|
164
|
+
const Value *arguments,
|
|
165
|
+
size_t count) -> Value
|
|
166
|
+
{
|
|
167
|
+
size_t res = ::dittoffi_query_result_item_count(jsPointerObjectToCPointer<dittoffi_query_result>(runtime, arguments[0]));
|
|
168
|
+
return static_cast<double>(res);
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
Function dittoffi_query_result_item_at(Runtime &runtime)
|
|
174
|
+
{
|
|
175
|
+
return Function::createFromHostFunction(runtime,
|
|
176
|
+
PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
|
|
177
|
+
0,
|
|
178
|
+
[](Runtime &runtime,
|
|
179
|
+
const Value &thisValue,
|
|
180
|
+
const Value *arguments,
|
|
181
|
+
size_t count) -> Value
|
|
182
|
+
{
|
|
183
|
+
|
|
184
|
+
dittoffi_query_result *dql_response = jsPointerObjectToCPointer<dittoffi_query_result>(runtime, arguments[0]);
|
|
185
|
+
size_t idx = arguments[1].asNumber();
|
|
186
|
+
|
|
187
|
+
dittoffi_query_result_item_t *res = ::dittoffi_query_result_item_at(dql_response, idx);
|
|
188
|
+
return cPointerToJSPointerObject(runtime, res);
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
Function dittoffi_query_result_mutated_document_id_count(Runtime &runtime)
|
|
193
|
+
{
|
|
194
|
+
return Function::createFromHostFunction(runtime,
|
|
195
|
+
PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
|
|
196
|
+
0,
|
|
197
|
+
[](Runtime &runtime,
|
|
198
|
+
const Value &thisValue,
|
|
199
|
+
const Value *arguments,
|
|
200
|
+
size_t count) -> Value
|
|
201
|
+
{
|
|
202
|
+
size_t res = ::dittoffi_query_result_mutated_document_id_count(jsPointerObjectToCPointer<dittoffi_query_result>(runtime, arguments[0]));
|
|
203
|
+
return static_cast<double>(res);
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
Function dittoffi_query_result_mutated_document_id_at(Runtime &runtime)
|
|
208
|
+
{
|
|
209
|
+
return Function::createFromHostFunction(runtime,
|
|
210
|
+
PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
|
|
211
|
+
0,
|
|
212
|
+
[](Runtime &runtime,
|
|
213
|
+
const Value &thisValue,
|
|
214
|
+
const Value *arguments,
|
|
215
|
+
size_t count) -> Value
|
|
216
|
+
{
|
|
217
|
+
|
|
218
|
+
dittoffi_query_result *dql_response = jsPointerObjectToCPointer<dittoffi_query_result>(runtime, arguments[0]);
|
|
219
|
+
size_t idx = arguments[1].asNumber();
|
|
220
|
+
|
|
221
|
+
slice_boxed_uint8_t res = ::dittoffi_query_result_mutated_document_id_at(dql_response, idx);
|
|
222
|
+
return cSlicedBoxToJSSlicedBox(runtime, res);
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
Function dittoffi_query_result_item_cbor(Runtime &runtime)
|
|
227
|
+
{
|
|
228
|
+
return Function::createFromHostFunction(runtime,
|
|
229
|
+
PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
|
|
230
|
+
0,
|
|
231
|
+
[](Runtime &runtime,
|
|
232
|
+
const Value &thisValue,
|
|
233
|
+
const Value *arguments,
|
|
234
|
+
size_t count) -> Value
|
|
235
|
+
{
|
|
236
|
+
slice_boxed_uint8_t res = ::dittoffi_query_result_item_cbor(jsPointerObjectToCPointer<dittoffi_query_result_item_t>(runtime, arguments[0]));
|
|
237
|
+
return cSlicedBoxToJSSlicedBox(runtime, res);
|
|
238
|
+
});
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
Function dittoffi_query_result_item_json(Runtime &runtime)
|
|
242
|
+
{
|
|
243
|
+
return Function::createFromHostFunction(runtime,
|
|
244
|
+
PropNameID::forAscii(runtime, STRINGIFIED_FUNC_NAME()),
|
|
245
|
+
0,
|
|
246
|
+
[](Runtime &runtime,
|
|
247
|
+
const Value &thisValue,
|
|
248
|
+
const Value *arguments,
|
|
249
|
+
size_t count) -> Value
|
|
250
|
+
{
|
|
251
|
+
|
|
252
|
+
char *res = ::dittoffi_query_result_item_json(jsPointerObjectToCPointer<dittoffi_query_result_item_t>(runtime, arguments[0]));
|
|
253
|
+
return cPointerToJSPointerObject<char>(runtime, res);
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}
|