@json-eval-rs/react-native 0.0.54 → 0.0.56
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/android/src/main/cpp/json-eval-rn.cpp +94 -16
- package/android/src/main/java/com/jsonevalrs/JsonEvalRsModule.kt +59 -0
- package/android/src/main/jniLibs/arm64-v8a/libjson_eval_rs.so +0 -0
- package/android/src/main/jniLibs/armeabi-v7a/libjson_eval_rs.so +0 -0
- package/android/src/main/jniLibs/x86/libjson_eval_rs.so +0 -0
- package/android/src/main/jniLibs/x86_64/libjson_eval_rs.so +0 -0
- package/cpp/json-eval-bridge.cpp +156 -0
- package/cpp/json-eval-bridge.h +62 -0
- package/ios/JsonEvalRs.mm +99 -0
- package/ios/JsonEvalRs.xcframework/Info.plist +5 -5
- package/ios/JsonEvalRs.xcframework/ios-arm64/libjson_eval_rs.a +0 -0
- package/ios/JsonEvalRs.xcframework/ios-arm64_x86_64-simulator/libjson_eval_rs.a +0 -0
- package/lib/commonjs/index.js +85 -17
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/index.js +86 -17
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/index.d.ts +47 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.tsx +413 -124
|
@@ -330,6 +330,82 @@ Java_com_jsonevalrs_JsonEvalRsModule_nativeGetSchemaValueAsync(
|
|
|
330
330
|
});
|
|
331
331
|
}
|
|
332
332
|
|
|
333
|
+
JNIEXPORT void JNICALL
|
|
334
|
+
Java_com_jsonevalrs_JsonEvalRsModule_nativeGetSchemaValueArrayAsync(
|
|
335
|
+
JNIEnv* env,
|
|
336
|
+
jobject /* this */,
|
|
337
|
+
jstring handle,
|
|
338
|
+
jobject promise
|
|
339
|
+
) {
|
|
340
|
+
std::string handleStr = jstringToString(env, handle);
|
|
341
|
+
|
|
342
|
+
runAsyncWithPromise(env, promise, "GET_SCHEMA_VALUE_ARRAY_ERROR", [handleStr](auto callback) {
|
|
343
|
+
JsonEvalBridge::getSchemaValueArrayAsync(handleStr, callback);
|
|
344
|
+
});
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
JNIEXPORT void JNICALL
|
|
348
|
+
Java_com_jsonevalrs_JsonEvalRsModule_nativeGetSchemaValueObjectAsync(
|
|
349
|
+
JNIEnv* env,
|
|
350
|
+
jobject /* this */,
|
|
351
|
+
jstring handle,
|
|
352
|
+
jobject promise
|
|
353
|
+
) {
|
|
354
|
+
std::string handleStr = jstringToString(env, handle);
|
|
355
|
+
|
|
356
|
+
runAsyncWithPromise(env, promise, "GET_SCHEMA_VALUE_OBJECT_ERROR", [handleStr](auto callback) {
|
|
357
|
+
JsonEvalBridge::getSchemaValueObjectAsync(handleStr, callback);
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
JNIEXPORT void JNICALL
|
|
362
|
+
Java_com_jsonevalrs_JsonEvalRsModule_nativeGetSchemaValueSubformAsync(
|
|
363
|
+
JNIEnv* env,
|
|
364
|
+
jobject /* this */,
|
|
365
|
+
jstring handle,
|
|
366
|
+
jstring subformPath,
|
|
367
|
+
jobject promise
|
|
368
|
+
) {
|
|
369
|
+
std::string handleStr = jstringToString(env, handle);
|
|
370
|
+
std::string subformPathStr = jstringToString(env, subformPath);
|
|
371
|
+
|
|
372
|
+
runAsyncWithPromise(env, promise, "GET_SCHEMA_VALUE_SUBFORM_ERROR", [handleStr, subformPathStr](auto callback) {
|
|
373
|
+
JsonEvalBridge::getSchemaValueSubformAsync(handleStr, subformPathStr, callback);
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
JNIEXPORT void JNICALL
|
|
378
|
+
Java_com_jsonevalrs_JsonEvalRsModule_nativeGetSchemaValueArraySubformAsync(
|
|
379
|
+
JNIEnv* env,
|
|
380
|
+
jobject /* this */,
|
|
381
|
+
jstring handle,
|
|
382
|
+
jstring subformPath,
|
|
383
|
+
jobject promise
|
|
384
|
+
) {
|
|
385
|
+
std::string handleStr = jstringToString(env, handle);
|
|
386
|
+
std::string subformPathStr = jstringToString(env, subformPath);
|
|
387
|
+
|
|
388
|
+
runAsyncWithPromise(env, promise, "GET_SCHEMA_VALUE_ARRAY_SUBFORM_ERROR", [handleStr, subformPathStr](auto callback) {
|
|
389
|
+
JsonEvalBridge::getSchemaValueArraySubformAsync(handleStr, subformPathStr, callback);
|
|
390
|
+
});
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
JNIEXPORT void JNICALL
|
|
394
|
+
Java_com_jsonevalrs_JsonEvalRsModule_nativeGetSchemaValueObjectSubformAsync(
|
|
395
|
+
JNIEnv* env,
|
|
396
|
+
jobject /* this */,
|
|
397
|
+
jstring handle,
|
|
398
|
+
jstring subformPath,
|
|
399
|
+
jobject promise
|
|
400
|
+
) {
|
|
401
|
+
std::string handleStr = jstringToString(env, handle);
|
|
402
|
+
std::string subformPathStr = jstringToString(env, subformPath);
|
|
403
|
+
|
|
404
|
+
runAsyncWithPromise(env, promise, "GET_SCHEMA_VALUE_OBJECT_SUBFORM_ERROR", [handleStr, subformPathStr](auto callback) {
|
|
405
|
+
JsonEvalBridge::getSchemaValueObjectSubformAsync(handleStr, subformPathStr, callback);
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
|
|
333
409
|
JNIEXPORT void JNICALL
|
|
334
410
|
Java_com_jsonevalrs_JsonEvalRsModule_nativeGetEvaluatedSchemaWithoutParamsAsync(
|
|
335
411
|
JNIEnv* env,
|
|
@@ -684,6 +760,24 @@ Java_com_jsonevalrs_JsonEvalRsModule_nativeCompileAndRunLogicAsync(
|
|
|
684
760
|
});
|
|
685
761
|
}
|
|
686
762
|
|
|
763
|
+
JNIEXPORT void JNICALL
|
|
764
|
+
Java_com_jsonevalrs_JsonEvalRsModule_nativeEvaluateLogicAsync(
|
|
765
|
+
JNIEnv* env,
|
|
766
|
+
jobject /* this */,
|
|
767
|
+
jstring logicStr,
|
|
768
|
+
jstring data,
|
|
769
|
+
jstring context,
|
|
770
|
+
jobject promise
|
|
771
|
+
) {
|
|
772
|
+
std::string logicStrCpp = jstringToString(env, logicStr);
|
|
773
|
+
std::string dataStr = jstringToString(env, data);
|
|
774
|
+
std::string contextStr = jstringToString(env, context);
|
|
775
|
+
|
|
776
|
+
runAsyncWithPromise(env, promise, "EVALUATE_LOGIC_ERROR", [logicStrCpp, dataStr, contextStr](auto callback) {
|
|
777
|
+
JsonEvalBridge::evaluateLogicAsync(logicStrCpp, dataStr, contextStr, callback);
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
|
|
687
781
|
// ============================================================================
|
|
688
782
|
// Subform Methods
|
|
689
783
|
// ============================================================================
|
|
@@ -770,22 +864,6 @@ Java_com_jsonevalrs_JsonEvalRsModule_nativeGetEvaluatedSchemaSubformAsync(
|
|
|
770
864
|
});
|
|
771
865
|
}
|
|
772
866
|
|
|
773
|
-
JNIEXPORT void JNICALL
|
|
774
|
-
Java_com_jsonevalrs_JsonEvalRsModule_nativeGetSchemaValueSubformAsync(
|
|
775
|
-
JNIEnv* env,
|
|
776
|
-
jobject /* this */,
|
|
777
|
-
jstring handle,
|
|
778
|
-
jstring subformPath,
|
|
779
|
-
jobject promise
|
|
780
|
-
) {
|
|
781
|
-
std::string handleStr = jstringToString(env, handle);
|
|
782
|
-
std::string subformPathStr = jstringToString(env, subformPath);
|
|
783
|
-
|
|
784
|
-
runAsyncWithPromise(env, promise, "GET_SCHEMA_VALUE_SUBFORM_ERROR", [handleStr, subformPathStr](auto callback) {
|
|
785
|
-
JsonEvalBridge::getSchemaValueSubformAsync(handleStr, subformPathStr, callback);
|
|
786
|
-
});
|
|
787
|
-
}
|
|
788
|
-
|
|
789
867
|
JNIEXPORT void JNICALL
|
|
790
868
|
Java_com_jsonevalrs_JsonEvalRsModule_nativeGetEvaluatedSchemaWithoutParamsSubformAsync(
|
|
791
869
|
JNIEnv* env,
|
|
@@ -83,6 +83,22 @@ class JsonEvalRsModule(reactContext: ReactApplicationContext) :
|
|
|
83
83
|
nativeGetSchemaValueAsync(handle, promise)
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
@ReactMethod
|
|
87
|
+
fun getSchemaValueArray(
|
|
88
|
+
handle: String,
|
|
89
|
+
promise: Promise
|
|
90
|
+
) {
|
|
91
|
+
nativeGetSchemaValueArrayAsync(handle, promise)
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@ReactMethod
|
|
95
|
+
fun getSchemaValueObject(
|
|
96
|
+
handle: String,
|
|
97
|
+
promise: Promise
|
|
98
|
+
) {
|
|
99
|
+
nativeGetSchemaValueObjectAsync(handle, promise)
|
|
100
|
+
}
|
|
101
|
+
|
|
86
102
|
@ReactMethod
|
|
87
103
|
fun getEvaluatedSchemaWithoutParams(
|
|
88
104
|
handle: String,
|
|
@@ -300,6 +316,16 @@ class JsonEvalRsModule(reactContext: ReactApplicationContext) :
|
|
|
300
316
|
nativeCompileAndRunLogicAsync(handle, logicStr, data ?: "", context ?: "", promise)
|
|
301
317
|
}
|
|
302
318
|
|
|
319
|
+
@ReactMethod
|
|
320
|
+
fun evaluateLogic(
|
|
321
|
+
logicStr: String,
|
|
322
|
+
data: String?,
|
|
323
|
+
context: String?,
|
|
324
|
+
promise: Promise
|
|
325
|
+
) {
|
|
326
|
+
nativeEvaluateLogicAsync(logicStr, data ?: "", context ?: "", promise)
|
|
327
|
+
}
|
|
328
|
+
|
|
303
329
|
@ReactMethod
|
|
304
330
|
fun compileLogic(
|
|
305
331
|
handle: String,
|
|
@@ -387,6 +413,24 @@ class JsonEvalRsModule(reactContext: ReactApplicationContext) :
|
|
|
387
413
|
nativeGetSchemaValueSubformAsync(handle, subformPath, promise)
|
|
388
414
|
}
|
|
389
415
|
|
|
416
|
+
@ReactMethod
|
|
417
|
+
fun getSchemaValueArraySubform(
|
|
418
|
+
handle: String,
|
|
419
|
+
subformPath: String,
|
|
420
|
+
promise: Promise
|
|
421
|
+
) {
|
|
422
|
+
nativeGetSchemaValueArraySubformAsync(handle, subformPath, promise)
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
@ReactMethod
|
|
426
|
+
fun getSchemaValueObjectSubform(
|
|
427
|
+
handle: String,
|
|
428
|
+
subformPath: String,
|
|
429
|
+
promise: Promise
|
|
430
|
+
) {
|
|
431
|
+
nativeGetSchemaValueObjectSubformAsync(handle, subformPath, promise)
|
|
432
|
+
}
|
|
433
|
+
|
|
390
434
|
@ReactMethod
|
|
391
435
|
fun getEvaluatedSchemaWithoutParamsSubform(
|
|
392
436
|
handle: String,
|
|
@@ -485,6 +529,16 @@ class JsonEvalRsModule(reactContext: ReactApplicationContext) :
|
|
|
485
529
|
nativeCancel(handle)
|
|
486
530
|
}
|
|
487
531
|
|
|
532
|
+
@ReactMethod
|
|
533
|
+
fun version(promise: Promise) {
|
|
534
|
+
try {
|
|
535
|
+
val version = nativeVersion()
|
|
536
|
+
promise.resolve(version)
|
|
537
|
+
} catch (e: Exception) {
|
|
538
|
+
promise.reject("VERSION_ERROR", e.message, e)
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
488
542
|
@ReactMethod
|
|
489
543
|
fun multiply(a: Double, b: Double, promise: Promise) {
|
|
490
544
|
promise.resolve(a * b)
|
|
@@ -514,6 +568,8 @@ class JsonEvalRsModule(reactContext: ReactApplicationContext) :
|
|
|
514
568
|
)
|
|
515
569
|
private external fun nativeGetEvaluatedSchemaAsync(handle: String, skipLayout: Boolean, promise: Promise)
|
|
516
570
|
private external fun nativeGetSchemaValueAsync(handle: String, promise: Promise)
|
|
571
|
+
private external fun nativeGetSchemaValueArrayAsync(handle: String, promise: Promise)
|
|
572
|
+
private external fun nativeGetSchemaValueObjectAsync(handle: String, promise: Promise)
|
|
517
573
|
private external fun nativeGetEvaluatedSchemaWithoutParamsAsync(handle: String, skipLayout: Boolean, promise: Promise)
|
|
518
574
|
private external fun nativeGetEvaluatedSchemaByPathAsync(handle: String, path: String, skipLayout: Boolean, promise: Promise)
|
|
519
575
|
private external fun nativeGetEvaluatedSchemaByPathsAsync(handle: String, pathsJson: String, skipLayout: Boolean, format: Int, promise: Promise)
|
|
@@ -531,6 +587,7 @@ class JsonEvalRsModule(reactContext: ReactApplicationContext) :
|
|
|
531
587
|
private external fun nativeValidatePathsAsync(handle: String, data: String, context: String, pathsJson: String, promise: Promise)
|
|
532
588
|
private external fun nativeResolveLayoutAsync(handle: String, evaluate: Boolean, promise: Promise)
|
|
533
589
|
private external fun nativeCompileAndRunLogicAsync(handle: String, logicStr: String, data: String, context: String, promise: Promise)
|
|
590
|
+
private external fun nativeEvaluateLogicAsync(logicStr: String, data: String, context: String, promise: Promise)
|
|
534
591
|
private external fun nativeCompileLogic(handle: String, logicStr: String): Double
|
|
535
592
|
private external fun nativeRunLogicAsync(handle: String, logicId: Double, data: String, context: String, promise: Promise)
|
|
536
593
|
private external fun nativeSetTimezoneOffset(handle: String, offsetMinutes: Int)
|
|
@@ -583,6 +640,8 @@ class JsonEvalRsModule(reactContext: ReactApplicationContext) :
|
|
|
583
640
|
private external fun nativeResolveLayoutSubformAsync(handle: String, subformPath: String, evaluate: Boolean, promise: Promise)
|
|
584
641
|
private external fun nativeGetEvaluatedSchemaSubformAsync(handle: String, subformPath: String, resolveLayout: Boolean, promise: Promise)
|
|
585
642
|
private external fun nativeGetSchemaValueSubformAsync(handle: String, subformPath: String, promise: Promise)
|
|
643
|
+
private external fun nativeGetSchemaValueArraySubformAsync(handle: String, subformPath: String, promise: Promise)
|
|
644
|
+
private external fun nativeGetSchemaValueObjectSubformAsync(handle: String, subformPath: String, promise: Promise)
|
|
586
645
|
private external fun nativeGetEvaluatedSchemaWithoutParamsSubformAsync(handle: String, subformPath: String, resolveLayout: Boolean, promise: Promise)
|
|
587
646
|
private external fun nativeGetEvaluatedSchemaByPathSubformAsync(handle: String, subformPath: String, schemaPath: String, skipLayout: Boolean, promise: Promise)
|
|
588
647
|
private external fun nativeGetEvaluatedSchemaByPathsSubformAsync(handle: String, subformPath: String, schemaPathsJson: String, skipLayout: Boolean, format: Int, promise: Promise)
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/cpp/json-eval-bridge.cpp
CHANGED
|
@@ -25,6 +25,8 @@ extern "C" {
|
|
|
25
25
|
FFIResult json_eval_evaluate_dependents(JSONEvalHandle* handle, const char* changed_path, const char* data, const char* context, int re_evaluate);
|
|
26
26
|
FFIResult json_eval_get_evaluated_schema(JSONEvalHandle* handle, bool skip_layout);
|
|
27
27
|
FFIResult json_eval_get_schema_value(JSONEvalHandle* handle);
|
|
28
|
+
FFIResult json_eval_get_schema_value_array(JSONEvalHandle* handle);
|
|
29
|
+
FFIResult json_eval_get_schema_value_object(JSONEvalHandle* handle);
|
|
28
30
|
FFIResult json_eval_get_evaluated_schema_without_params(JSONEvalHandle* handle, bool skip_layout);
|
|
29
31
|
FFIResult json_eval_get_evaluated_schema_by_path(JSONEvalHandle* handle, const char* path, bool skip_layout);
|
|
30
32
|
FFIResult json_eval_get_evaluated_schema_by_paths(JSONEvalHandle* handle, const char* paths_json, bool skip_layout, uint8_t format);
|
|
@@ -45,6 +47,7 @@ extern "C" {
|
|
|
45
47
|
FFIResult json_eval_disable_cache(JSONEvalHandle* handle);
|
|
46
48
|
int json_eval_is_cache_enabled(JSONEvalHandle* handle);
|
|
47
49
|
FFIResult json_eval_validate_paths(JSONEvalHandle* handle, const char* data, const char* context, const char* paths_json);
|
|
50
|
+
FFIResult json_eval_evaluate_logic_pure(const char* logic_str, const char* data, const char* context);
|
|
48
51
|
|
|
49
52
|
// Subform FFI methods
|
|
50
53
|
FFIResult json_eval_evaluate_subform(JSONEvalHandle* handle, const char* subform_path, const char* data, const char* context, const char* paths_json);
|
|
@@ -53,6 +56,8 @@ extern "C" {
|
|
|
53
56
|
FFIResult json_eval_resolve_layout_subform(JSONEvalHandle* handle, const char* subform_path, bool evaluate);
|
|
54
57
|
FFIResult json_eval_get_evaluated_schema_subform(JSONEvalHandle* handle, const char* subform_path, bool resolve_layout);
|
|
55
58
|
FFIResult json_eval_get_schema_value_subform(JSONEvalHandle* handle, const char* subform_path);
|
|
59
|
+
FFIResult json_eval_get_schema_value_array_subform(JSONEvalHandle* handle, const char* subform_path);
|
|
60
|
+
FFIResult json_eval_get_schema_value_object_subform(JSONEvalHandle* handle, const char* subform_path);
|
|
56
61
|
FFIResult json_eval_get_evaluated_schema_without_params_subform(JSONEvalHandle* handle, const char* subform_path, bool resolve_layout);
|
|
57
62
|
FFIResult json_eval_get_evaluated_schema_by_path_subform(JSONEvalHandle* handle, const char* subform_path, const char* schema_path, bool skip_layout);
|
|
58
63
|
FFIResult json_eval_get_evaluated_schema_by_paths_subform(JSONEvalHandle* handle, const char* subform_path, const char* schema_paths_json, bool skip_layout, uint8_t format);
|
|
@@ -299,6 +304,35 @@ void JsonEvalBridge::validateAsync(
|
|
|
299
304
|
}, callback);
|
|
300
305
|
}
|
|
301
306
|
|
|
307
|
+
void JsonEvalBridge::evaluateLogicAsync(
|
|
308
|
+
const std::string& logicStr,
|
|
309
|
+
const std::string& data,
|
|
310
|
+
const std::string& context,
|
|
311
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
312
|
+
) {
|
|
313
|
+
runAsync([logicStr, data, context]() -> std::string {
|
|
314
|
+
const char* dt = data.empty() ? nullptr : data.c_str();
|
|
315
|
+
const char* ctx = context.empty() ? nullptr : context.c_str();
|
|
316
|
+
|
|
317
|
+
FFIResult result = json_eval_evaluate_logic_pure(logicStr.c_str(), dt, ctx);
|
|
318
|
+
|
|
319
|
+
if (!result.success) {
|
|
320
|
+
std::string error = result.error ? result.error : "Unknown error";
|
|
321
|
+
json_eval_free_result(result);
|
|
322
|
+
throw std::runtime_error(error);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
std::string resultStr;
|
|
326
|
+
if (result.data_ptr && result.data_len > 0) {
|
|
327
|
+
resultStr.assign(reinterpret_cast<const char*>(result.data_ptr), result.data_len);
|
|
328
|
+
} else {
|
|
329
|
+
resultStr = "null";
|
|
330
|
+
}
|
|
331
|
+
json_eval_free_result(result);
|
|
332
|
+
return resultStr;
|
|
333
|
+
}, callback);
|
|
334
|
+
}
|
|
335
|
+
|
|
302
336
|
void JsonEvalBridge::evaluateDependentsAsync(
|
|
303
337
|
const std::string& handleId,
|
|
304
338
|
const std::string& changedPathsJson,
|
|
@@ -437,6 +471,66 @@ void JsonEvalBridge::getSchemaValueAsync(
|
|
|
437
471
|
}, callback);
|
|
438
472
|
}
|
|
439
473
|
|
|
474
|
+
void JsonEvalBridge::getSchemaValueArrayAsync(
|
|
475
|
+
const std::string& handleId,
|
|
476
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
477
|
+
) {
|
|
478
|
+
runAsync([handleId]() -> std::string {
|
|
479
|
+
std::lock_guard<std::mutex> lock(handlesMutex);
|
|
480
|
+
auto it = handles.find(handleId);
|
|
481
|
+
if (it == handles.end()) {
|
|
482
|
+
throw std::runtime_error("Invalid handle");
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
FFIResult result = json_eval_get_schema_value_array(it->second);
|
|
486
|
+
|
|
487
|
+
if (!result.success) {
|
|
488
|
+
std::string error = result.error ? result.error : "Unknown error";
|
|
489
|
+
json_eval_free_result(result);
|
|
490
|
+
throw std::runtime_error(error);
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
std::string resultStr;
|
|
494
|
+
if (result.data_ptr && result.data_len > 0) {
|
|
495
|
+
resultStr.assign(reinterpret_cast<const char*>(result.data_ptr), result.data_len);
|
|
496
|
+
} else {
|
|
497
|
+
resultStr = "[]";
|
|
498
|
+
}
|
|
499
|
+
json_eval_free_result(result);
|
|
500
|
+
return resultStr;
|
|
501
|
+
}, callback);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
void JsonEvalBridge::getSchemaValueObjectAsync(
|
|
505
|
+
const std::string& handleId,
|
|
506
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
507
|
+
) {
|
|
508
|
+
runAsync([handleId]() -> std::string {
|
|
509
|
+
std::lock_guard<std::mutex> lock(handlesMutex);
|
|
510
|
+
auto it = handles.find(handleId);
|
|
511
|
+
if (it == handles.end()) {
|
|
512
|
+
throw std::runtime_error("Invalid handle");
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
FFIResult result = json_eval_get_schema_value_object(it->second);
|
|
516
|
+
|
|
517
|
+
if (!result.success) {
|
|
518
|
+
std::string error = result.error ? result.error : "Unknown error";
|
|
519
|
+
json_eval_free_result(result);
|
|
520
|
+
throw std::runtime_error(error);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
std::string resultStr;
|
|
524
|
+
if (result.data_ptr && result.data_len > 0) {
|
|
525
|
+
resultStr.assign(reinterpret_cast<const char*>(result.data_ptr), result.data_len);
|
|
526
|
+
} else {
|
|
527
|
+
resultStr = "{}";
|
|
528
|
+
}
|
|
529
|
+
json_eval_free_result(result);
|
|
530
|
+
return resultStr;
|
|
531
|
+
}, callback);
|
|
532
|
+
}
|
|
533
|
+
|
|
440
534
|
void JsonEvalBridge::getEvaluatedSchemaWithoutParamsAsync(
|
|
441
535
|
const std::string& handleId,
|
|
442
536
|
bool skipLayout,
|
|
@@ -1141,6 +1235,68 @@ void JsonEvalBridge::getSchemaValueSubformAsync(
|
|
|
1141
1235
|
}, callback);
|
|
1142
1236
|
}
|
|
1143
1237
|
|
|
1238
|
+
void JsonEvalBridge::getSchemaValueArraySubformAsync(
|
|
1239
|
+
const std::string& handleId,
|
|
1240
|
+
const std::string& subformPath,
|
|
1241
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
1242
|
+
) {
|
|
1243
|
+
runAsync([handleId, subformPath]() -> std::string {
|
|
1244
|
+
std::lock_guard<std::mutex> lock(handlesMutex);
|
|
1245
|
+
auto it = handles.find(handleId);
|
|
1246
|
+
if (it == handles.end()) {
|
|
1247
|
+
throw std::runtime_error("Invalid handle");
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
FFIResult result = json_eval_get_schema_value_array_subform(it->second, subformPath.c_str());
|
|
1251
|
+
|
|
1252
|
+
if (!result.success) {
|
|
1253
|
+
std::string error = result.error ? result.error : "Unknown error";
|
|
1254
|
+
json_eval_free_result(result);
|
|
1255
|
+
throw std::runtime_error(error);
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
std::string resultStr;
|
|
1259
|
+
if (result.data_ptr && result.data_len > 0) {
|
|
1260
|
+
resultStr.assign(reinterpret_cast<const char*>(result.data_ptr), result.data_len);
|
|
1261
|
+
} else {
|
|
1262
|
+
resultStr = "[]";
|
|
1263
|
+
}
|
|
1264
|
+
json_eval_free_result(result);
|
|
1265
|
+
return resultStr;
|
|
1266
|
+
}, callback);
|
|
1267
|
+
}
|
|
1268
|
+
|
|
1269
|
+
void JsonEvalBridge::getSchemaValueObjectSubformAsync(
|
|
1270
|
+
const std::string& handleId,
|
|
1271
|
+
const std::string& subformPath,
|
|
1272
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
1273
|
+
) {
|
|
1274
|
+
runAsync([handleId, subformPath]() -> std::string {
|
|
1275
|
+
std::lock_guard<std::mutex> lock(handlesMutex);
|
|
1276
|
+
auto it = handles.find(handleId);
|
|
1277
|
+
if (it == handles.end()) {
|
|
1278
|
+
throw std::runtime_error("Invalid handle");
|
|
1279
|
+
}
|
|
1280
|
+
|
|
1281
|
+
FFIResult result = json_eval_get_schema_value_object_subform(it->second, subformPath.c_str());
|
|
1282
|
+
|
|
1283
|
+
if (!result.success) {
|
|
1284
|
+
std::string error = result.error ? result.error : "Unknown error";
|
|
1285
|
+
json_eval_free_result(result);
|
|
1286
|
+
throw std::runtime_error(error);
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
std::string resultStr;
|
|
1290
|
+
if (result.data_ptr && result.data_len > 0) {
|
|
1291
|
+
resultStr.assign(reinterpret_cast<const char*>(result.data_ptr), result.data_len);
|
|
1292
|
+
} else {
|
|
1293
|
+
resultStr = "{}";
|
|
1294
|
+
}
|
|
1295
|
+
json_eval_free_result(result);
|
|
1296
|
+
return resultStr;
|
|
1297
|
+
}, callback);
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1144
1300
|
void JsonEvalBridge::getEvaluatedSchemaWithoutParamsSubformAsync(
|
|
1145
1301
|
const std::string& handleId,
|
|
1146
1302
|
const std::string& subformPath,
|
package/cpp/json-eval-bridge.h
CHANGED
|
@@ -134,6 +134,28 @@ public:
|
|
|
134
134
|
std::function<void(const std::string&, const std::string&)> callback
|
|
135
135
|
);
|
|
136
136
|
|
|
137
|
+
/**
|
|
138
|
+
* Get all schema values as array of path-value pairs (async)
|
|
139
|
+
* Returns [{path: "", value: ""}, ...]
|
|
140
|
+
* @param handle Instance handle
|
|
141
|
+
* @param callback Result callback
|
|
142
|
+
*/
|
|
143
|
+
static void getSchemaValueArrayAsync(
|
|
144
|
+
const std::string& handle,
|
|
145
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
146
|
+
);
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Get all schema values as object with dotted path keys (async)
|
|
150
|
+
* Returns {path: value, ...}
|
|
151
|
+
* @param handle Instance handle
|
|
152
|
+
* @param callback Result callback
|
|
153
|
+
*/
|
|
154
|
+
static void getSchemaValueObjectAsync(
|
|
155
|
+
const std::string& handle,
|
|
156
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
157
|
+
);
|
|
158
|
+
|
|
137
159
|
/**
|
|
138
160
|
* Get evaluated schema without $params field (async)
|
|
139
161
|
* @param handle Instance handle
|
|
@@ -378,6 +400,20 @@ public:
|
|
|
378
400
|
std::function<void(const std::string&, const std::string&)> callback
|
|
379
401
|
);
|
|
380
402
|
|
|
403
|
+
/**
|
|
404
|
+
* Evaluate independent logic expression (async) - No schema required
|
|
405
|
+
* @param logicStr JSON logic expression
|
|
406
|
+
* @param data Optional JSON data (can be empty/null)
|
|
407
|
+
* @param context Optional context data (can be empty/null)
|
|
408
|
+
* @param callback Result callback
|
|
409
|
+
*/
|
|
410
|
+
static void evaluateLogicAsync(
|
|
411
|
+
const std::string& logicStr,
|
|
412
|
+
const std::string& data,
|
|
413
|
+
const std::string& context,
|
|
414
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
415
|
+
);
|
|
416
|
+
|
|
381
417
|
// ========================================================================
|
|
382
418
|
// Subform Methods
|
|
383
419
|
// ========================================================================
|
|
@@ -474,6 +510,32 @@ public:
|
|
|
474
510
|
std::function<void(const std::string&, const std::string&)> callback
|
|
475
511
|
);
|
|
476
512
|
|
|
513
|
+
/**
|
|
514
|
+
* Get all schema values as array of path-value pairs from subform (async)
|
|
515
|
+
* Returns [{path: "", value: ""}, ...]
|
|
516
|
+
* @param handleId Instance handle
|
|
517
|
+
* @param subformPath Path to the subform
|
|
518
|
+
* @param callback Result callback
|
|
519
|
+
*/
|
|
520
|
+
static void getSchemaValueArraySubformAsync(
|
|
521
|
+
const std::string& handleId,
|
|
522
|
+
const std::string& subformPath,
|
|
523
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
524
|
+
);
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* Get all schema values as object with dotted path keys from subform (async)
|
|
528
|
+
* Returns {path: value, ...}
|
|
529
|
+
* @param handleId Instance handle
|
|
530
|
+
* @param subformPath Path to the subform
|
|
531
|
+
* @param callback Result callback
|
|
532
|
+
*/
|
|
533
|
+
static void getSchemaValueObjectSubformAsync(
|
|
534
|
+
const std::string& handleId,
|
|
535
|
+
const std::string& subformPath,
|
|
536
|
+
std::function<void(const std::string&, const std::string&)> callback
|
|
537
|
+
);
|
|
538
|
+
|
|
477
539
|
/**
|
|
478
540
|
* Get evaluated schema without $params from subform (async)
|
|
479
541
|
* @param handleId Instance handle
|
package/ios/JsonEvalRs.mm
CHANGED
|
@@ -141,6 +141,27 @@ RCT_EXPORT_METHOD(runLogic:(NSString *)handle
|
|
|
141
141
|
);
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
+
RCT_EXPORT_METHOD(evaluateLogic:(NSString *)logicStr
|
|
145
|
+
data:(NSString *)data
|
|
146
|
+
context:(NSString *)context
|
|
147
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
148
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
149
|
+
{
|
|
150
|
+
std::string logicString = [self stdStringFromNSString:logicStr];
|
|
151
|
+
std::string dataStr = [self stdStringFromNSString:data];
|
|
152
|
+
std::string contextStr = [self stdStringFromNSString:context];
|
|
153
|
+
|
|
154
|
+
JsonEvalBridge::evaluateLogicAsync(logicString, dataStr, contextStr,
|
|
155
|
+
[resolve, reject](const std::string& result, const std::string& error) {
|
|
156
|
+
if (error.empty()) {
|
|
157
|
+
resolve([NSString stringWithUTF8String:result.c_str()]);
|
|
158
|
+
} else {
|
|
159
|
+
reject(@"EVALUATE_LOGIC_ERROR", [NSString stringWithUTF8String:error.c_str()], nil);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
144
165
|
RCT_EXPORT_METHOD(validate:(NSString *)handle
|
|
145
166
|
data:(NSString *)data
|
|
146
167
|
context:(NSString *)context
|
|
@@ -221,6 +242,40 @@ RCT_EXPORT_METHOD(getSchemaValue:(NSString *)handle
|
|
|
221
242
|
);
|
|
222
243
|
}
|
|
223
244
|
|
|
245
|
+
RCT_EXPORT_METHOD(getSchemaValueArray:(NSString *)handle
|
|
246
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
247
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
248
|
+
{
|
|
249
|
+
std::string handleStr = [self stdStringFromNSString:handle];
|
|
250
|
+
|
|
251
|
+
JsonEvalBridge::getSchemaValueArrayAsync(handleStr,
|
|
252
|
+
[resolve, reject](const std::string& result, const std::string& error) {
|
|
253
|
+
if (error.empty()) {
|
|
254
|
+
resolve([NSString stringWithUTF8String:result.c_str()]);
|
|
255
|
+
} else {
|
|
256
|
+
reject(@"GET_SCHEMA_VALUE_ARRAY_ERROR", [NSString stringWithUTF8String:error.c_str()], nil);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
RCT_EXPORT_METHOD(getSchemaValueObject:(NSString *)handle
|
|
263
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
264
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
265
|
+
{
|
|
266
|
+
std::string handleStr = [self stdStringFromNSString:handle];
|
|
267
|
+
|
|
268
|
+
JsonEvalBridge::getSchemaValueObjectAsync(handleStr,
|
|
269
|
+
[resolve, reject](const std::string& result, const std::string& error) {
|
|
270
|
+
if (error.empty()) {
|
|
271
|
+
resolve([NSString stringWithUTF8String:result.c_str()]);
|
|
272
|
+
} else {
|
|
273
|
+
reject(@"GET_SCHEMA_VALUE_OBJECT_ERROR", [NSString stringWithUTF8String:error.c_str()], nil);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
224
279
|
RCT_EXPORT_METHOD(getEvaluatedSchemaWithoutParams:(NSString *)handle
|
|
225
280
|
skipLayout:(BOOL)skipLayout
|
|
226
281
|
resolver:(RCTPromiseResolveBlock)resolve
|
|
@@ -693,6 +748,44 @@ RCT_EXPORT_METHOD(getSchemaValueSubform:(NSString *)handle
|
|
|
693
748
|
);
|
|
694
749
|
}
|
|
695
750
|
|
|
751
|
+
RCT_EXPORT_METHOD(getSchemaValueArraySubform:(NSString *)handle
|
|
752
|
+
subformPath:(NSString *)subformPath
|
|
753
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
754
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
755
|
+
{
|
|
756
|
+
std::string handleStr = [self stdStringFromNSString:handle];
|
|
757
|
+
std::string pathStr = [self stdStringFromNSString:subformPath];
|
|
758
|
+
|
|
759
|
+
JsonEvalBridge::getSchemaValueArraySubformAsync(handleStr, pathStr,
|
|
760
|
+
[resolve, reject](const std::string& result, const std::string& error) {
|
|
761
|
+
if (error.empty()) {
|
|
762
|
+
resolve([NSString stringWithUTF8String:result.c_str()]);
|
|
763
|
+
} else {
|
|
764
|
+
reject(@"GET_SCHEMA_VALUE_ARRAY_SUBFORM_ERROR", [NSString stringWithUTF8String:error.c_str()], nil);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
RCT_EXPORT_METHOD(getSchemaValueObjectSubform:(NSString *)handle
|
|
771
|
+
subformPath:(NSString *)subformPath
|
|
772
|
+
resolver:(RCTPromiseResolveBlock)resolve
|
|
773
|
+
rejecter:(RCTPromiseRejectBlock)reject)
|
|
774
|
+
{
|
|
775
|
+
std::string handleStr = [self stdStringFromNSString:handle];
|
|
776
|
+
std::string pathStr = [self stdStringFromNSString:subformPath];
|
|
777
|
+
|
|
778
|
+
JsonEvalBridge::getSchemaValueObjectSubformAsync(handleStr, pathStr,
|
|
779
|
+
[resolve, reject](const std::string& result, const std::string& error) {
|
|
780
|
+
if (error.empty()) {
|
|
781
|
+
resolve([NSString stringWithUTF8String:result.c_str()]);
|
|
782
|
+
} else {
|
|
783
|
+
reject(@"GET_SCHEMA_VALUE_OBJECT_SUBFORM_ERROR", [NSString stringWithUTF8String:error.c_str()], nil);
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
}
|
|
788
|
+
|
|
696
789
|
RCT_EXPORT_METHOD(getEvaluatedSchemaWithoutParamsSubform:(NSString *)handle
|
|
697
790
|
subformPath:(NSString *)subformPath
|
|
698
791
|
resolveLayout:(BOOL)resolveLayout
|
|
@@ -855,6 +948,12 @@ RCT_EXPORT_METHOD(setTimezoneOffset:(NSString *)handle
|
|
|
855
948
|
}
|
|
856
949
|
}
|
|
857
950
|
|
|
951
|
+
RCT_EXPORT_METHOD(cancel:(NSString *)handle)
|
|
952
|
+
{
|
|
953
|
+
std::string handleStr = [self stdStringFromNSString:handle];
|
|
954
|
+
JsonEvalBridge::cancel(handleStr);
|
|
955
|
+
}
|
|
956
|
+
|
|
858
957
|
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(dispose:(NSString *)handle)
|
|
859
958
|
{
|
|
860
959
|
std::string handleStr = [self stdStringFromNSString:handle];
|
|
@@ -8,32 +8,32 @@
|
|
|
8
8
|
<key>BinaryPath</key>
|
|
9
9
|
<string>libjson_eval_rs.a</string>
|
|
10
10
|
<key>LibraryIdentifier</key>
|
|
11
|
-
<string>ios-
|
|
11
|
+
<string>ios-arm64_x86_64-simulator</string>
|
|
12
12
|
<key>LibraryPath</key>
|
|
13
13
|
<string>libjson_eval_rs.a</string>
|
|
14
14
|
<key>SupportedArchitectures</key>
|
|
15
15
|
<array>
|
|
16
16
|
<string>arm64</string>
|
|
17
|
+
<string>x86_64</string>
|
|
17
18
|
</array>
|
|
18
19
|
<key>SupportedPlatform</key>
|
|
19
20
|
<string>ios</string>
|
|
21
|
+
<key>SupportedPlatformVariant</key>
|
|
22
|
+
<string>simulator</string>
|
|
20
23
|
</dict>
|
|
21
24
|
<dict>
|
|
22
25
|
<key>BinaryPath</key>
|
|
23
26
|
<string>libjson_eval_rs.a</string>
|
|
24
27
|
<key>LibraryIdentifier</key>
|
|
25
|
-
<string>ios-
|
|
28
|
+
<string>ios-arm64</string>
|
|
26
29
|
<key>LibraryPath</key>
|
|
27
30
|
<string>libjson_eval_rs.a</string>
|
|
28
31
|
<key>SupportedArchitectures</key>
|
|
29
32
|
<array>
|
|
30
33
|
<string>arm64</string>
|
|
31
|
-
<string>x86_64</string>
|
|
32
34
|
</array>
|
|
33
35
|
<key>SupportedPlatform</key>
|
|
34
36
|
<string>ios</string>
|
|
35
|
-
<key>SupportedPlatformVariant</key>
|
|
36
|
-
<string>simulator</string>
|
|
37
37
|
</dict>
|
|
38
38
|
</array>
|
|
39
39
|
<key>CFBundlePackageType</key>
|
|
Binary file
|