react-native-nitro-pose-exercises 1.0.2
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/LICENSE +20 -0
- package/NitroPoseExercises.podspec +32 -0
- package/README.md +538 -0
- package/android/CMakeLists.txt +31 -0
- package/android/build.gradle +121 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/cpp/cpp-adapter.cpp +11 -0
- package/android/src/main/java/com/margelo/nitro/nitroposeexercises/NitroPoseExercises.kt +535 -0
- package/android/src/main/java/com/margelo/nitro/nitroposeexercises/NitroPoseExercisesPackage.kt +22 -0
- package/ios/NitroPoseExercises.swift +527 -0
- package/lib/module/NitroPoseExercises.nitro.js +17 -0
- package/lib/module/NitroPoseExercises.nitro.js.map +1 -0
- package/lib/module/config/pushup.js +71 -0
- package/lib/module/config/pushup.js.map +1 -0
- package/lib/module/index.js +7 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/NitroPoseExercises.nitro.d.ts +97 -0
- package/lib/typescript/src/NitroPoseExercises.nitro.d.ts.map +1 -0
- package/lib/typescript/src/config/pushup.d.ts +3 -0
- package/lib/typescript/src/config/pushup.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +6 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JAngleDefinition.hpp +69 -0
- package/nitrogen/generated/android/c++/JAngleSnapshot.hpp +61 -0
- package/nitrogen/generated/android/c++/JExerciseConfig.hpp +166 -0
- package/nitrogen/generated/android/c++/JExercisePhase.hpp +67 -0
- package/nitrogen/generated/android/c++/JExerciseType.hpp +61 -0
- package/nitrogen/generated/android/c++/JFormFeedback.hpp +67 -0
- package/nitrogen/generated/android/c++/JFormRule.hpp +79 -0
- package/nitrogen/generated/android/c++/JFormSeverity.hpp +61 -0
- package/nitrogen/generated/android/c++/JFunc_void.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_ExercisePhase.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_FormFeedback.hpp +80 -0
- package/nitrogen/generated/android/c++/JFunc_void_HoldProgress.hpp +77 -0
- package/nitrogen/generated/android/c++/JFunc_void_RepData.hpp +81 -0
- package/nitrogen/generated/android/c++/JFunc_void_SessionResult.hpp +85 -0
- package/nitrogen/generated/android/c++/JHoldProgress.hpp +65 -0
- package/nitrogen/generated/android/c++/JHybridNitroPoseExercisesSpec.cpp +311 -0
- package/nitrogen/generated/android/c++/JHybridNitroPoseExercisesSpec.hpp +87 -0
- package/nitrogen/generated/android/c++/JLandmark.hpp +69 -0
- package/nitrogen/generated/android/c++/JPhaseThreshold.hpp +71 -0
- package/nitrogen/generated/android/c++/JRepData.hpp +90 -0
- package/nitrogen/generated/android/c++/JSessionResult.hpp +120 -0
- package/nitrogen/generated/android/c++/JSessionStatus.hpp +67 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/AngleDefinition.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/AngleSnapshot.kt +56 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/ExerciseConfig.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/ExercisePhase.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/ExerciseType.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/FormFeedback.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/FormRule.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/FormSeverity.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/Func_void.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/Func_void_ExercisePhase.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/Func_void_FormFeedback.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/Func_void_HoldProgress.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/Func_void_RepData.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/Func_void_SessionResult.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/HoldProgress.kt +61 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/HybridNitroPoseExercisesSpec.kt +196 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/Landmark.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/PhaseThreshold.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/RepData.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/SessionResult.kt +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/SessionStatus.kt +26 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/nitroposeexercises/nitroposeexercisesOnLoad.kt +35 -0
- package/nitrogen/generated/android/nitroposeexercises+autolinking.cmake +81 -0
- package/nitrogen/generated/android/nitroposeexercises+autolinking.gradle +27 -0
- package/nitrogen/generated/android/nitroposeexercisesOnLoad.cpp +66 -0
- package/nitrogen/generated/android/nitroposeexercisesOnLoad.hpp +34 -0
- package/nitrogen/generated/ios/NitroPoseExercises+autolinking.rb +62 -0
- package/nitrogen/generated/ios/NitroPoseExercises-Swift-Cxx-Bridge.cpp +100 -0
- package/nitrogen/generated/ios/NitroPoseExercises-Swift-Cxx-Bridge.hpp +449 -0
- package/nitrogen/generated/ios/NitroPoseExercises-Swift-Cxx-Umbrella.hpp +95 -0
- package/nitrogen/generated/ios/NitroPoseExercisesAutolinking.mm +33 -0
- package/nitrogen/generated/ios/NitroPoseExercisesAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridNitroPoseExercisesSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridNitroPoseExercisesSpecSwift.hpp +236 -0
- package/nitrogen/generated/ios/swift/AngleDefinition.swift +44 -0
- package/nitrogen/generated/ios/swift/AngleSnapshot.swift +34 -0
- package/nitrogen/generated/ios/swift/ExerciseConfig.swift +83 -0
- package/nitrogen/generated/ios/swift/ExercisePhase.swift +52 -0
- package/nitrogen/generated/ios/swift/ExerciseType.swift +44 -0
- package/nitrogen/generated/ios/swift/FormFeedback.swift +39 -0
- package/nitrogen/generated/ios/swift/FormRule.swift +54 -0
- package/nitrogen/generated/ios/swift/FormSeverity.swift +44 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_ExercisePhase.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_FormFeedback.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_HoldProgress.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_RepData.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_SessionResult.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/HoldProgress.swift +39 -0
- package/nitrogen/generated/ios/swift/HybridNitroPoseExercisesSpec.swift +73 -0
- package/nitrogen/generated/ios/swift/HybridNitroPoseExercisesSpec_cxx.swift +483 -0
- package/nitrogen/generated/ios/swift/Landmark.swift +44 -0
- package/nitrogen/generated/ios/swift/PhaseThreshold.swift +44 -0
- package/nitrogen/generated/ios/swift/RepData.swift +50 -0
- package/nitrogen/generated/ios/swift/SessionResult.swift +66 -0
- package/nitrogen/generated/ios/swift/SessionStatus.swift +52 -0
- package/nitrogen/generated/shared/c++/AngleDefinition.hpp +95 -0
- package/nitrogen/generated/shared/c++/AngleSnapshot.hpp +87 -0
- package/nitrogen/generated/shared/c++/ExerciseConfig.hpp +122 -0
- package/nitrogen/generated/shared/c++/ExercisePhase.hpp +88 -0
- package/nitrogen/generated/shared/c++/ExerciseType.hpp +80 -0
- package/nitrogen/generated/shared/c++/FormFeedback.hpp +93 -0
- package/nitrogen/generated/shared/c++/FormRule.hpp +105 -0
- package/nitrogen/generated/shared/c++/FormSeverity.hpp +80 -0
- package/nitrogen/generated/shared/c++/HoldProgress.hpp +91 -0
- package/nitrogen/generated/shared/c++/HybridNitroPoseExercisesSpec.cpp +46 -0
- package/nitrogen/generated/shared/c++/HybridNitroPoseExercisesSpec.hpp +117 -0
- package/nitrogen/generated/shared/c++/Landmark.hpp +95 -0
- package/nitrogen/generated/shared/c++/PhaseThreshold.hpp +97 -0
- package/nitrogen/generated/shared/c++/RepData.hpp +97 -0
- package/nitrogen/generated/shared/c++/SessionResult.hpp +108 -0
- package/nitrogen/generated/shared/c++/SessionStatus.hpp +88 -0
- package/package.json +187 -0
- package/src/NitroPoseExercises.nitro.ts +155 -0
- package/src/config/pushup.ts +62 -0
- package/src/index.tsx +28 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// SessionStatus.swift
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Represents the JS union `SessionStatus`, backed by a C++ enum.
|
|
10
|
+
*/
|
|
11
|
+
public typealias SessionStatus = margelo.nitro.nitroposeexercises.SessionStatus
|
|
12
|
+
|
|
13
|
+
public extension SessionStatus {
|
|
14
|
+
/**
|
|
15
|
+
* Get a SessionStatus for the given String value, or
|
|
16
|
+
* return `nil` if the given value was invalid/unknown.
|
|
17
|
+
*/
|
|
18
|
+
init?(fromString string: String) {
|
|
19
|
+
switch string {
|
|
20
|
+
case "idle":
|
|
21
|
+
self = .idle
|
|
22
|
+
case "countdown":
|
|
23
|
+
self = .countdown
|
|
24
|
+
case "active":
|
|
25
|
+
self = .active
|
|
26
|
+
case "paused":
|
|
27
|
+
self = .paused
|
|
28
|
+
case "completed":
|
|
29
|
+
self = .completed
|
|
30
|
+
default:
|
|
31
|
+
return nil
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Get the String value this SessionStatus represents.
|
|
37
|
+
*/
|
|
38
|
+
var stringValue: String {
|
|
39
|
+
switch self {
|
|
40
|
+
case .idle:
|
|
41
|
+
return "idle"
|
|
42
|
+
case .countdown:
|
|
43
|
+
return "countdown"
|
|
44
|
+
case .active:
|
|
45
|
+
return "active"
|
|
46
|
+
case .paused:
|
|
47
|
+
return "paused"
|
|
48
|
+
case .completed:
|
|
49
|
+
return "completed"
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AngleDefinition.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::nitroposeexercises {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (AngleDefinition).
|
|
39
|
+
*/
|
|
40
|
+
struct AngleDefinition final {
|
|
41
|
+
public:
|
|
42
|
+
std::string name SWIFT_PRIVATE;
|
|
43
|
+
double landmarkA SWIFT_PRIVATE;
|
|
44
|
+
double landmarkB SWIFT_PRIVATE;
|
|
45
|
+
double landmarkC SWIFT_PRIVATE;
|
|
46
|
+
|
|
47
|
+
public:
|
|
48
|
+
AngleDefinition() = default;
|
|
49
|
+
explicit AngleDefinition(std::string name, double landmarkA, double landmarkB, double landmarkC): name(name), landmarkA(landmarkA), landmarkB(landmarkB), landmarkC(landmarkC) {}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
friend bool operator==(const AngleDefinition& lhs, const AngleDefinition& rhs) = default;
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
} // namespace margelo::nitro::nitroposeexercises
|
|
56
|
+
|
|
57
|
+
namespace margelo::nitro {
|
|
58
|
+
|
|
59
|
+
// C++ AngleDefinition <> JS AngleDefinition (object)
|
|
60
|
+
template <>
|
|
61
|
+
struct JSIConverter<margelo::nitro::nitroposeexercises::AngleDefinition> final {
|
|
62
|
+
static inline margelo::nitro::nitroposeexercises::AngleDefinition fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
63
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
64
|
+
return margelo::nitro::nitroposeexercises::AngleDefinition(
|
|
65
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
|
|
66
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "landmarkA"))),
|
|
67
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "landmarkB"))),
|
|
68
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "landmarkC")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroposeexercises::AngleDefinition& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "landmarkA"), JSIConverter<double>::toJSI(runtime, arg.landmarkA));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "landmarkB"), JSIConverter<double>::toJSI(runtime, arg.landmarkB));
|
|
76
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "landmarkC"), JSIConverter<double>::toJSI(runtime, arg.landmarkC));
|
|
77
|
+
return obj;
|
|
78
|
+
}
|
|
79
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
80
|
+
if (!value.isObject()) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
jsi::Object obj = value.getObject(runtime);
|
|
84
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
|
|
88
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "landmarkA")))) return false;
|
|
89
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "landmarkB")))) return false;
|
|
90
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "landmarkC")))) return false;
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// AngleSnapshot.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
#include <string>
|
|
34
|
+
|
|
35
|
+
namespace margelo::nitro::nitroposeexercises {
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* A struct which can be represented as a JavaScript object (AngleSnapshot).
|
|
39
|
+
*/
|
|
40
|
+
struct AngleSnapshot final {
|
|
41
|
+
public:
|
|
42
|
+
std::string name SWIFT_PRIVATE;
|
|
43
|
+
double value SWIFT_PRIVATE;
|
|
44
|
+
|
|
45
|
+
public:
|
|
46
|
+
AngleSnapshot() = default;
|
|
47
|
+
explicit AngleSnapshot(std::string name, double value): name(name), value(value) {}
|
|
48
|
+
|
|
49
|
+
public:
|
|
50
|
+
friend bool operator==(const AngleSnapshot& lhs, const AngleSnapshot& rhs) = default;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
} // namespace margelo::nitro::nitroposeexercises
|
|
54
|
+
|
|
55
|
+
namespace margelo::nitro {
|
|
56
|
+
|
|
57
|
+
// C++ AngleSnapshot <> JS AngleSnapshot (object)
|
|
58
|
+
template <>
|
|
59
|
+
struct JSIConverter<margelo::nitro::nitroposeexercises::AngleSnapshot> final {
|
|
60
|
+
static inline margelo::nitro::nitroposeexercises::AngleSnapshot fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
61
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
62
|
+
return margelo::nitro::nitroposeexercises::AngleSnapshot(
|
|
63
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
|
|
64
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroposeexercises::AngleSnapshot& arg) {
|
|
68
|
+
jsi::Object obj(runtime);
|
|
69
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
|
|
70
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<double>::toJSI(runtime, arg.value));
|
|
71
|
+
return obj;
|
|
72
|
+
}
|
|
73
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
74
|
+
if (!value.isObject()) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
jsi::Object obj = value.getObject(runtime);
|
|
78
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
|
|
82
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
|
|
83
|
+
return true;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ExerciseConfig.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `ExerciseType` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitroposeexercises { enum class ExerciseType; }
|
|
33
|
+
// Forward declaration of `AngleDefinition` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::nitroposeexercises { struct AngleDefinition; }
|
|
35
|
+
// Forward declaration of `PhaseThreshold` to properly resolve imports.
|
|
36
|
+
namespace margelo::nitro::nitroposeexercises { struct PhaseThreshold; }
|
|
37
|
+
// Forward declaration of `ExercisePhase` to properly resolve imports.
|
|
38
|
+
namespace margelo::nitro::nitroposeexercises { enum class ExercisePhase; }
|
|
39
|
+
// Forward declaration of `FormRule` to properly resolve imports.
|
|
40
|
+
namespace margelo::nitro::nitroposeexercises { struct FormRule; }
|
|
41
|
+
|
|
42
|
+
#include <string>
|
|
43
|
+
#include "ExerciseType.hpp"
|
|
44
|
+
#include "AngleDefinition.hpp"
|
|
45
|
+
#include <vector>
|
|
46
|
+
#include "PhaseThreshold.hpp"
|
|
47
|
+
#include "ExercisePhase.hpp"
|
|
48
|
+
#include "FormRule.hpp"
|
|
49
|
+
|
|
50
|
+
namespace margelo::nitro::nitroposeexercises {
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* A struct which can be represented as a JavaScript object (ExerciseConfig).
|
|
54
|
+
*/
|
|
55
|
+
struct ExerciseConfig final {
|
|
56
|
+
public:
|
|
57
|
+
std::string name SWIFT_PRIVATE;
|
|
58
|
+
ExerciseType type SWIFT_PRIVATE;
|
|
59
|
+
std::vector<AngleDefinition> angles SWIFT_PRIVATE;
|
|
60
|
+
std::vector<PhaseThreshold> phases SWIFT_PRIVATE;
|
|
61
|
+
std::vector<ExercisePhase> repSequence SWIFT_PRIVATE;
|
|
62
|
+
std::vector<FormRule> formRules SWIFT_PRIVATE;
|
|
63
|
+
double holdDurationMs SWIFT_PRIVATE;
|
|
64
|
+
|
|
65
|
+
public:
|
|
66
|
+
ExerciseConfig() = default;
|
|
67
|
+
explicit ExerciseConfig(std::string name, ExerciseType type, std::vector<AngleDefinition> angles, std::vector<PhaseThreshold> phases, std::vector<ExercisePhase> repSequence, std::vector<FormRule> formRules, double holdDurationMs): name(name), type(type), angles(angles), phases(phases), repSequence(repSequence), formRules(formRules), holdDurationMs(holdDurationMs) {}
|
|
68
|
+
|
|
69
|
+
public:
|
|
70
|
+
friend bool operator==(const ExerciseConfig& lhs, const ExerciseConfig& rhs) = default;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
} // namespace margelo::nitro::nitroposeexercises
|
|
74
|
+
|
|
75
|
+
namespace margelo::nitro {
|
|
76
|
+
|
|
77
|
+
// C++ ExerciseConfig <> JS ExerciseConfig (object)
|
|
78
|
+
template <>
|
|
79
|
+
struct JSIConverter<margelo::nitro::nitroposeexercises::ExerciseConfig> final {
|
|
80
|
+
static inline margelo::nitro::nitroposeexercises::ExerciseConfig fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
81
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
82
|
+
return margelo::nitro::nitroposeexercises::ExerciseConfig(
|
|
83
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name"))),
|
|
84
|
+
JSIConverter<margelo::nitro::nitroposeexercises::ExerciseType>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type"))),
|
|
85
|
+
JSIConverter<std::vector<margelo::nitro::nitroposeexercises::AngleDefinition>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "angles"))),
|
|
86
|
+
JSIConverter<std::vector<margelo::nitro::nitroposeexercises::PhaseThreshold>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "phases"))),
|
|
87
|
+
JSIConverter<std::vector<margelo::nitro::nitroposeexercises::ExercisePhase>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "repSequence"))),
|
|
88
|
+
JSIConverter<std::vector<margelo::nitro::nitroposeexercises::FormRule>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "formRules"))),
|
|
89
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "holdDurationMs")))
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroposeexercises::ExerciseConfig& arg) {
|
|
93
|
+
jsi::Object obj(runtime);
|
|
94
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "name"), JSIConverter<std::string>::toJSI(runtime, arg.name));
|
|
95
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "type"), JSIConverter<margelo::nitro::nitroposeexercises::ExerciseType>::toJSI(runtime, arg.type));
|
|
96
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "angles"), JSIConverter<std::vector<margelo::nitro::nitroposeexercises::AngleDefinition>>::toJSI(runtime, arg.angles));
|
|
97
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "phases"), JSIConverter<std::vector<margelo::nitro::nitroposeexercises::PhaseThreshold>>::toJSI(runtime, arg.phases));
|
|
98
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "repSequence"), JSIConverter<std::vector<margelo::nitro::nitroposeexercises::ExercisePhase>>::toJSI(runtime, arg.repSequence));
|
|
99
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "formRules"), JSIConverter<std::vector<margelo::nitro::nitroposeexercises::FormRule>>::toJSI(runtime, arg.formRules));
|
|
100
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "holdDurationMs"), JSIConverter<double>::toJSI(runtime, arg.holdDurationMs));
|
|
101
|
+
return obj;
|
|
102
|
+
}
|
|
103
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
104
|
+
if (!value.isObject()) {
|
|
105
|
+
return false;
|
|
106
|
+
}
|
|
107
|
+
jsi::Object obj = value.getObject(runtime);
|
|
108
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
109
|
+
return false;
|
|
110
|
+
}
|
|
111
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "name")))) return false;
|
|
112
|
+
if (!JSIConverter<margelo::nitro::nitroposeexercises::ExerciseType>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "type")))) return false;
|
|
113
|
+
if (!JSIConverter<std::vector<margelo::nitro::nitroposeexercises::AngleDefinition>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "angles")))) return false;
|
|
114
|
+
if (!JSIConverter<std::vector<margelo::nitro::nitroposeexercises::PhaseThreshold>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "phases")))) return false;
|
|
115
|
+
if (!JSIConverter<std::vector<margelo::nitro::nitroposeexercises::ExercisePhase>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "repSequence")))) return false;
|
|
116
|
+
if (!JSIConverter<std::vector<margelo::nitro::nitroposeexercises::FormRule>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "formRules")))) return false;
|
|
117
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "holdDurationMs")))) return false;
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ExercisePhase.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitroposeexercises {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (ExercisePhase).
|
|
30
|
+
*/
|
|
31
|
+
enum class ExercisePhase {
|
|
32
|
+
HOLD SWIFT_NAME(hold) = 0,
|
|
33
|
+
UP SWIFT_NAME(up) = 1,
|
|
34
|
+
DOWN SWIFT_NAME(down) = 2,
|
|
35
|
+
TRANSITION SWIFT_NAME(transition) = 3,
|
|
36
|
+
UNKNOWN SWIFT_NAME(unknown) = 4,
|
|
37
|
+
} CLOSED_ENUM;
|
|
38
|
+
|
|
39
|
+
} // namespace margelo::nitro::nitroposeexercises
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro {
|
|
42
|
+
|
|
43
|
+
// C++ ExercisePhase <> JS ExercisePhase (union)
|
|
44
|
+
template <>
|
|
45
|
+
struct JSIConverter<margelo::nitro::nitroposeexercises::ExercisePhase> final {
|
|
46
|
+
static inline margelo::nitro::nitroposeexercises::ExercisePhase fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
47
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
48
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
49
|
+
case hashString("hold"): return margelo::nitro::nitroposeexercises::ExercisePhase::HOLD;
|
|
50
|
+
case hashString("up"): return margelo::nitro::nitroposeexercises::ExercisePhase::UP;
|
|
51
|
+
case hashString("down"): return margelo::nitro::nitroposeexercises::ExercisePhase::DOWN;
|
|
52
|
+
case hashString("transition"): return margelo::nitro::nitroposeexercises::ExercisePhase::TRANSITION;
|
|
53
|
+
case hashString("unknown"): return margelo::nitro::nitroposeexercises::ExercisePhase::UNKNOWN;
|
|
54
|
+
default: [[unlikely]]
|
|
55
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ExercisePhase - invalid value!");
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitroposeexercises::ExercisePhase arg) {
|
|
59
|
+
switch (arg) {
|
|
60
|
+
case margelo::nitro::nitroposeexercises::ExercisePhase::HOLD: return JSIConverter<std::string>::toJSI(runtime, "hold");
|
|
61
|
+
case margelo::nitro::nitroposeexercises::ExercisePhase::UP: return JSIConverter<std::string>::toJSI(runtime, "up");
|
|
62
|
+
case margelo::nitro::nitroposeexercises::ExercisePhase::DOWN: return JSIConverter<std::string>::toJSI(runtime, "down");
|
|
63
|
+
case margelo::nitro::nitroposeexercises::ExercisePhase::TRANSITION: return JSIConverter<std::string>::toJSI(runtime, "transition");
|
|
64
|
+
case margelo::nitro::nitroposeexercises::ExercisePhase::UNKNOWN: return JSIConverter<std::string>::toJSI(runtime, "unknown");
|
|
65
|
+
default: [[unlikely]]
|
|
66
|
+
throw std::invalid_argument("Cannot convert ExercisePhase to JS - invalid value: "
|
|
67
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
71
|
+
if (!value.isString()) {
|
|
72
|
+
return false;
|
|
73
|
+
}
|
|
74
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
75
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
76
|
+
case hashString("hold"):
|
|
77
|
+
case hashString("up"):
|
|
78
|
+
case hashString("down"):
|
|
79
|
+
case hashString("transition"):
|
|
80
|
+
case hashString("unknown"):
|
|
81
|
+
return true;
|
|
82
|
+
default:
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// ExerciseType.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/NitroHash.hpp>)
|
|
11
|
+
#include <NitroModules/NitroHash.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
16
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
21
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
|
|
26
|
+
namespace margelo::nitro::nitroposeexercises {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (ExerciseType).
|
|
30
|
+
*/
|
|
31
|
+
enum class ExerciseType {
|
|
32
|
+
REP SWIFT_NAME(rep) = 0,
|
|
33
|
+
HOLD SWIFT_NAME(hold) = 1,
|
|
34
|
+
FLOW SWIFT_NAME(flow) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::nitroposeexercises
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ ExerciseType <> JS ExerciseType (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::nitroposeexercises::ExerciseType> final {
|
|
44
|
+
static inline margelo::nitro::nitroposeexercises::ExerciseType fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
45
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
46
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
47
|
+
case hashString("rep"): return margelo::nitro::nitroposeexercises::ExerciseType::REP;
|
|
48
|
+
case hashString("hold"): return margelo::nitro::nitroposeexercises::ExerciseType::HOLD;
|
|
49
|
+
case hashString("flow"): return margelo::nitro::nitroposeexercises::ExerciseType::FLOW;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ExerciseType - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::nitroposeexercises::ExerciseType arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::nitroposeexercises::ExerciseType::REP: return JSIConverter<std::string>::toJSI(runtime, "rep");
|
|
57
|
+
case margelo::nitro::nitroposeexercises::ExerciseType::HOLD: return JSIConverter<std::string>::toJSI(runtime, "hold");
|
|
58
|
+
case margelo::nitro::nitroposeexercises::ExerciseType::FLOW: return JSIConverter<std::string>::toJSI(runtime, "flow");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert ExerciseType to JS - invalid value: "
|
|
61
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
65
|
+
if (!value.isString()) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
69
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
70
|
+
case hashString("rep"):
|
|
71
|
+
case hashString("hold"):
|
|
72
|
+
case hashString("flow"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// FormFeedback.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#if __has_include(<NitroModules/JSIConverter.hpp>)
|
|
11
|
+
#include <NitroModules/JSIConverter.hpp>
|
|
12
|
+
#else
|
|
13
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
14
|
+
#endif
|
|
15
|
+
#if __has_include(<NitroModules/NitroDefines.hpp>)
|
|
16
|
+
#include <NitroModules/NitroDefines.hpp>
|
|
17
|
+
#else
|
|
18
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
19
|
+
#endif
|
|
20
|
+
#if __has_include(<NitroModules/JSIHelpers.hpp>)
|
|
21
|
+
#include <NitroModules/JSIHelpers.hpp>
|
|
22
|
+
#else
|
|
23
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
24
|
+
#endif
|
|
25
|
+
#if __has_include(<NitroModules/PropNameIDCache.hpp>)
|
|
26
|
+
#include <NitroModules/PropNameIDCache.hpp>
|
|
27
|
+
#else
|
|
28
|
+
#error NitroModules cannot be found! Are you sure you installed NitroModules properly?
|
|
29
|
+
#endif
|
|
30
|
+
|
|
31
|
+
// Forward declaration of `FormSeverity` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::nitroposeexercises { enum class FormSeverity; }
|
|
33
|
+
|
|
34
|
+
#include <string>
|
|
35
|
+
#include "FormSeverity.hpp"
|
|
36
|
+
|
|
37
|
+
namespace margelo::nitro::nitroposeexercises {
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* A struct which can be represented as a JavaScript object (FormFeedback).
|
|
41
|
+
*/
|
|
42
|
+
struct FormFeedback final {
|
|
43
|
+
public:
|
|
44
|
+
std::string ruleName SWIFT_PRIVATE;
|
|
45
|
+
std::string message SWIFT_PRIVATE;
|
|
46
|
+
FormSeverity severity SWIFT_PRIVATE;
|
|
47
|
+
|
|
48
|
+
public:
|
|
49
|
+
FormFeedback() = default;
|
|
50
|
+
explicit FormFeedback(std::string ruleName, std::string message, FormSeverity severity): ruleName(ruleName), message(message), severity(severity) {}
|
|
51
|
+
|
|
52
|
+
public:
|
|
53
|
+
friend bool operator==(const FormFeedback& lhs, const FormFeedback& rhs) = default;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
} // namespace margelo::nitro::nitroposeexercises
|
|
57
|
+
|
|
58
|
+
namespace margelo::nitro {
|
|
59
|
+
|
|
60
|
+
// C++ FormFeedback <> JS FormFeedback (object)
|
|
61
|
+
template <>
|
|
62
|
+
struct JSIConverter<margelo::nitro::nitroposeexercises::FormFeedback> final {
|
|
63
|
+
static inline margelo::nitro::nitroposeexercises::FormFeedback fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
64
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
65
|
+
return margelo::nitro::nitroposeexercises::FormFeedback(
|
|
66
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ruleName"))),
|
|
67
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message"))),
|
|
68
|
+
JSIConverter<margelo::nitro::nitroposeexercises::FormSeverity>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "severity")))
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::nitroposeexercises::FormFeedback& arg) {
|
|
72
|
+
jsi::Object obj(runtime);
|
|
73
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "ruleName"), JSIConverter<std::string>::toJSI(runtime, arg.ruleName));
|
|
74
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "message"), JSIConverter<std::string>::toJSI(runtime, arg.message));
|
|
75
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "severity"), JSIConverter<margelo::nitro::nitroposeexercises::FormSeverity>::toJSI(runtime, arg.severity));
|
|
76
|
+
return obj;
|
|
77
|
+
}
|
|
78
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
79
|
+
if (!value.isObject()) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
jsi::Object obj = value.getObject(runtime);
|
|
83
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
84
|
+
return false;
|
|
85
|
+
}
|
|
86
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "ruleName")))) return false;
|
|
87
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message")))) return false;
|
|
88
|
+
if (!JSIConverter<margelo::nitro::nitroposeexercises::FormSeverity>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "severity")))) return false;
|
|
89
|
+
return true;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
} // namespace margelo::nitro
|