react-native-carrot-quest 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CarrotQuest.podspec +34 -0
- package/LICENSE +20 -0
- package/README.md +457 -0
- package/android/CMakeLists.txt +24 -0
- package/android/build.gradle +136 -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/carrotquest/CarrotQuest.kt +585 -0
- package/android/src/main/java/com/margelo/nitro/carrotquest/CarrotQuestPackage.kt +22 -0
- package/android/src/main/java/com/margelo/nitro/carrotquest/CarrotQuestSetup.kt +472 -0
- package/ios/CarrotQuest.swift +588 -0
- package/ios/CarrotQuestSetup.swift +333 -0
- package/lib/module/CarrotQuest.nitro.js +4 -0
- package/lib/module/CarrotQuest.nitro.js.map +1 -0
- package/lib/module/carrot-quest.js +136 -0
- package/lib/module/carrot-quest.js.map +1 -0
- package/lib/module/carrot-quest.native.js +155 -0
- package/lib/module/carrot-quest.native.js.map +1 -0
- package/lib/module/index.js +6 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/subscriptions.js +76 -0
- package/lib/module/subscriptions.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/CarrotQuest.nitro.d.ts +394 -0
- package/lib/typescript/src/CarrotQuest.nitro.d.ts.map +1 -0
- package/lib/typescript/src/carrot-quest.d.ts +37 -0
- package/lib/typescript/src/carrot-quest.d.ts.map +1 -0
- package/lib/typescript/src/carrot-quest.native.d.ts +37 -0
- package/lib/typescript/src/carrot-quest.native.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/lib/typescript/src/subscriptions.d.ts +32 -0
- package/lib/typescript/src/subscriptions.d.ts.map +1 -0
- package/nitro.json +23 -0
- package/nitrogen/generated/android/c++/JCarrotQuestEventValue.cpp +30 -0
- package/nitrogen/generated/android/c++/JCarrotQuestEventValue.hpp +83 -0
- package/nitrogen/generated/android/c++/JCarrotQuestLogCategory.hpp +76 -0
- package/nitrogen/generated/android/c++/JCarrotQuestLogEntry.hpp +100 -0
- package/nitrogen/generated/android/c++/JCarrotQuestLogLevel.hpp +70 -0
- package/nitrogen/generated/android/c++/JCarrotQuestProperty.hpp +74 -0
- package/nitrogen/generated/android/c++/JCarrotQuestPropertyKind.hpp +61 -0
- package/nitrogen/generated/android/c++/JCarrotQuestPropertyOperation.hpp +73 -0
- package/nitrogen/generated/android/c++/JCarrotQuestSetupOptions.hpp +94 -0
- package/nitrogen/generated/android/c++/JCarrotQuestTheme.hpp +64 -0
- package/nitrogen/generated/android/c++/JCarrotQuestUrlSource.hpp +64 -0
- package/nitrogen/generated/android/c++/JCarrotQuestUserProperties.hpp +84 -0
- package/nitrogen/generated/android/c++/JFunc_void_CarrotQuestLogEntry.hpp +84 -0
- package/nitrogen/generated/android/c++/JFunc_void_bool.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
- package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
- package/nitrogen/generated/android/c++/JHybridCarrotQuestSpec.cpp +388 -0
- package/nitrogen/generated/android/c++/JHybridCarrotQuestSpec.hpp +96 -0
- package/nitrogen/generated/android/carrotquest+autolinking.cmake +82 -0
- package/nitrogen/generated/android/carrotquest+autolinking.gradle +27 -0
- package/nitrogen/generated/android/carrotquestOnLoad.cpp +62 -0
- package/nitrogen/generated/android/carrotquestOnLoad.hpp +34 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestEventValue.kt +75 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogCategory.kt +29 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogEntry.kt +81 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestLogLevel.kt +27 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestProperty.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestPropertyKind.kt +24 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestPropertyOperation.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestSetupOptions.kt +91 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestTheme.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestUrlSource.kt +25 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/CarrotQuestUserProperties.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_CarrotQuestLogEntry.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_bool.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_double.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/Func_void_std__string.kt +80 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/HybridCarrotQuestSpec.kt +209 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/carrotquest/carrotquestOnLoad.kt +35 -0
- package/nitrogen/generated/ios/CarrotQuest+autolinking.rb +62 -0
- package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Bridge.cpp +97 -0
- package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Bridge.hpp +637 -0
- package/nitrogen/generated/ios/CarrotQuest-Swift-Cxx-Umbrella.hpp +80 -0
- package/nitrogen/generated/ios/CarrotQuestAutolinking.mm +33 -0
- package/nitrogen/generated/ios/CarrotQuestAutolinking.swift +26 -0
- package/nitrogen/generated/ios/c++/HybridCarrotQuestSpecSwift.cpp +11 -0
- package/nitrogen/generated/ios/c++/HybridCarrotQuestSpecSwift.hpp +344 -0
- package/nitrogen/generated/ios/swift/CarrotQuestEventValue.swift +32 -0
- package/nitrogen/generated/ios/swift/CarrotQuestLogCategory.swift +64 -0
- package/nitrogen/generated/ios/swift/CarrotQuestLogEntry.swift +86 -0
- package/nitrogen/generated/ios/swift/CarrotQuestLogLevel.swift +56 -0
- package/nitrogen/generated/ios/swift/CarrotQuestProperty.swift +56 -0
- package/nitrogen/generated/ios/swift/CarrotQuestPropertyKind.swift +44 -0
- package/nitrogen/generated/ios/swift/CarrotQuestPropertyOperation.swift +60 -0
- package/nitrogen/generated/ios/swift/CarrotQuestSetupOptions.swift +172 -0
- package/nitrogen/generated/ios/swift/CarrotQuestTheme.swift +48 -0
- package/nitrogen/generated/ios/swift/CarrotQuestUrlSource.swift +48 -0
- package/nitrogen/generated/ios/swift/CarrotQuestUserProperties.swift +110 -0
- package/nitrogen/generated/ios/swift/Func_void.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_CarrotQuestLogEntry.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_bool.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_double_.swift +53 -0
- package/nitrogen/generated/ios/swift/Func_void_std__optional_std__string_.swift +53 -0
- package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
- package/nitrogen/generated/ios/swift/HybridCarrotQuestSpec.swift +88 -0
- package/nitrogen/generated/ios/swift/HybridCarrotQuestSpec_cxx.swift +674 -0
- package/nitrogen/generated/shared/c++/CarrotQuestLogCategory.hpp +100 -0
- package/nitrogen/generated/shared/c++/CarrotQuestLogEntry.hpp +114 -0
- package/nitrogen/generated/shared/c++/CarrotQuestLogLevel.hpp +92 -0
- package/nitrogen/generated/shared/c++/CarrotQuestProperty.hpp +101 -0
- package/nitrogen/generated/shared/c++/CarrotQuestPropertyKind.hpp +80 -0
- package/nitrogen/generated/shared/c++/CarrotQuestPropertyOperation.hpp +96 -0
- package/nitrogen/generated/shared/c++/CarrotQuestSetupOptions.hpp +121 -0
- package/nitrogen/generated/shared/c++/CarrotQuestTheme.hpp +84 -0
- package/nitrogen/generated/shared/c++/CarrotQuestUrlSource.hpp +84 -0
- package/nitrogen/generated/shared/c++/CarrotQuestUserProperties.hpp +97 -0
- package/nitrogen/generated/shared/c++/HybridCarrotQuestSpec.cpp +55 -0
- package/nitrogen/generated/shared/c++/HybridCarrotQuestSpec.hpp +118 -0
- package/package.json +140 -0
- package/src/CarrotQuest.nitro.ts +493 -0
- package/src/carrot-quest.native.tsx +241 -0
- package/src/carrot-quest.tsx +207 -0
- package/src/index.tsx +57 -0
- package/src/subscriptions.ts +83 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CarrotQuestLogCategory.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::carrotquest {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (CarrotQuestLogCategory).
|
|
30
|
+
*/
|
|
31
|
+
enum class CarrotQuestLogCategory {
|
|
32
|
+
PUSH SWIFT_NAME(push) = 0,
|
|
33
|
+
GENERAL SWIFT_NAME(general) = 1,
|
|
34
|
+
NETWORK SWIFT_NAME(network) = 2,
|
|
35
|
+
CONNECTIVITY SWIFT_NAME(connectivity) = 3,
|
|
36
|
+
AUTH SWIFT_NAME(auth) = 4,
|
|
37
|
+
REALTIME SWIFT_NAME(realtime) = 5,
|
|
38
|
+
LIFECYCLE SWIFT_NAME(lifecycle) = 6,
|
|
39
|
+
DATABASE SWIFT_NAME(database) = 7,
|
|
40
|
+
} CLOSED_ENUM;
|
|
41
|
+
|
|
42
|
+
} // namespace margelo::nitro::carrotquest
|
|
43
|
+
|
|
44
|
+
namespace margelo::nitro {
|
|
45
|
+
|
|
46
|
+
// C++ CarrotQuestLogCategory <> JS CarrotQuestLogCategory (union)
|
|
47
|
+
template <>
|
|
48
|
+
struct JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogCategory> final {
|
|
49
|
+
static inline margelo::nitro::carrotquest::CarrotQuestLogCategory fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
50
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
51
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
52
|
+
case hashString("push"): return margelo::nitro::carrotquest::CarrotQuestLogCategory::PUSH;
|
|
53
|
+
case hashString("general"): return margelo::nitro::carrotquest::CarrotQuestLogCategory::GENERAL;
|
|
54
|
+
case hashString("network"): return margelo::nitro::carrotquest::CarrotQuestLogCategory::NETWORK;
|
|
55
|
+
case hashString("connectivity"): return margelo::nitro::carrotquest::CarrotQuestLogCategory::CONNECTIVITY;
|
|
56
|
+
case hashString("auth"): return margelo::nitro::carrotquest::CarrotQuestLogCategory::AUTH;
|
|
57
|
+
case hashString("realtime"): return margelo::nitro::carrotquest::CarrotQuestLogCategory::REALTIME;
|
|
58
|
+
case hashString("lifecycle"): return margelo::nitro::carrotquest::CarrotQuestLogCategory::LIFECYCLE;
|
|
59
|
+
case hashString("database"): return margelo::nitro::carrotquest::CarrotQuestLogCategory::DATABASE;
|
|
60
|
+
default: [[unlikely]]
|
|
61
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum CarrotQuestLogCategory - invalid value!");
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::carrotquest::CarrotQuestLogCategory arg) {
|
|
65
|
+
switch (arg) {
|
|
66
|
+
case margelo::nitro::carrotquest::CarrotQuestLogCategory::PUSH: return JSIConverter<std::string>::toJSI(runtime, "push");
|
|
67
|
+
case margelo::nitro::carrotquest::CarrotQuestLogCategory::GENERAL: return JSIConverter<std::string>::toJSI(runtime, "general");
|
|
68
|
+
case margelo::nitro::carrotquest::CarrotQuestLogCategory::NETWORK: return JSIConverter<std::string>::toJSI(runtime, "network");
|
|
69
|
+
case margelo::nitro::carrotquest::CarrotQuestLogCategory::CONNECTIVITY: return JSIConverter<std::string>::toJSI(runtime, "connectivity");
|
|
70
|
+
case margelo::nitro::carrotquest::CarrotQuestLogCategory::AUTH: return JSIConverter<std::string>::toJSI(runtime, "auth");
|
|
71
|
+
case margelo::nitro::carrotquest::CarrotQuestLogCategory::REALTIME: return JSIConverter<std::string>::toJSI(runtime, "realtime");
|
|
72
|
+
case margelo::nitro::carrotquest::CarrotQuestLogCategory::LIFECYCLE: return JSIConverter<std::string>::toJSI(runtime, "lifecycle");
|
|
73
|
+
case margelo::nitro::carrotquest::CarrotQuestLogCategory::DATABASE: return JSIConverter<std::string>::toJSI(runtime, "database");
|
|
74
|
+
default: [[unlikely]]
|
|
75
|
+
throw std::invalid_argument("Cannot convert CarrotQuestLogCategory to JS - invalid value: "
|
|
76
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
80
|
+
if (!value.isString()) {
|
|
81
|
+
return false;
|
|
82
|
+
}
|
|
83
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
84
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
85
|
+
case hashString("push"):
|
|
86
|
+
case hashString("general"):
|
|
87
|
+
case hashString("network"):
|
|
88
|
+
case hashString("connectivity"):
|
|
89
|
+
case hashString("auth"):
|
|
90
|
+
case hashString("realtime"):
|
|
91
|
+
case hashString("lifecycle"):
|
|
92
|
+
case hashString("database"):
|
|
93
|
+
return true;
|
|
94
|
+
default:
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CarrotQuestLogEntry.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 `CarrotQuestLogLevel` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestLogLevel; }
|
|
33
|
+
// Forward declaration of `CarrotQuestLogCategory` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestLogCategory; }
|
|
35
|
+
|
|
36
|
+
#include "CarrotQuestLogLevel.hpp"
|
|
37
|
+
#include "CarrotQuestLogCategory.hpp"
|
|
38
|
+
#include <string>
|
|
39
|
+
#include <unordered_map>
|
|
40
|
+
#include <optional>
|
|
41
|
+
|
|
42
|
+
namespace margelo::nitro::carrotquest {
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* A struct which can be represented as a JavaScript object (CarrotQuestLogEntry).
|
|
46
|
+
*/
|
|
47
|
+
struct CarrotQuestLogEntry final {
|
|
48
|
+
public:
|
|
49
|
+
double timestampMs SWIFT_PRIVATE;
|
|
50
|
+
CarrotQuestLogLevel level SWIFT_PRIVATE;
|
|
51
|
+
CarrotQuestLogCategory category SWIFT_PRIVATE;
|
|
52
|
+
std::string tag SWIFT_PRIVATE;
|
|
53
|
+
std::string message SWIFT_PRIVATE;
|
|
54
|
+
std::unordered_map<std::string, std::string> fields SWIFT_PRIVATE;
|
|
55
|
+
std::optional<std::string> error SWIFT_PRIVATE;
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
CarrotQuestLogEntry() = default;
|
|
59
|
+
explicit CarrotQuestLogEntry(double timestampMs, CarrotQuestLogLevel level, CarrotQuestLogCategory category, std::string tag, std::string message, std::unordered_map<std::string, std::string> fields, std::optional<std::string> error): timestampMs(timestampMs), level(level), category(category), tag(tag), message(message), fields(fields), error(error) {}
|
|
60
|
+
|
|
61
|
+
public:
|
|
62
|
+
friend bool operator==(const CarrotQuestLogEntry& lhs, const CarrotQuestLogEntry& rhs) = default;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
} // namespace margelo::nitro::carrotquest
|
|
66
|
+
|
|
67
|
+
namespace margelo::nitro {
|
|
68
|
+
|
|
69
|
+
// C++ CarrotQuestLogEntry <> JS CarrotQuestLogEntry (object)
|
|
70
|
+
template <>
|
|
71
|
+
struct JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogEntry> final {
|
|
72
|
+
static inline margelo::nitro::carrotquest::CarrotQuestLogEntry fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
73
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
74
|
+
return margelo::nitro::carrotquest::CarrotQuestLogEntry(
|
|
75
|
+
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestampMs"))),
|
|
76
|
+
JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogLevel>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "level"))),
|
|
77
|
+
JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogCategory>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "category"))),
|
|
78
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tag"))),
|
|
79
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message"))),
|
|
80
|
+
JSIConverter<std::unordered_map<std::string, std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fields"))),
|
|
81
|
+
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "error")))
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::carrotquest::CarrotQuestLogEntry& arg) {
|
|
85
|
+
jsi::Object obj(runtime);
|
|
86
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "timestampMs"), JSIConverter<double>::toJSI(runtime, arg.timestampMs));
|
|
87
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "level"), JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogLevel>::toJSI(runtime, arg.level));
|
|
88
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "category"), JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogCategory>::toJSI(runtime, arg.category));
|
|
89
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "tag"), JSIConverter<std::string>::toJSI(runtime, arg.tag));
|
|
90
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "message"), JSIConverter<std::string>::toJSI(runtime, arg.message));
|
|
91
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "fields"), JSIConverter<std::unordered_map<std::string, std::string>>::toJSI(runtime, arg.fields));
|
|
92
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "error"), JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.error));
|
|
93
|
+
return obj;
|
|
94
|
+
}
|
|
95
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
96
|
+
if (!value.isObject()) {
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
jsi::Object obj = value.getObject(runtime);
|
|
100
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
101
|
+
return false;
|
|
102
|
+
}
|
|
103
|
+
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "timestampMs")))) return false;
|
|
104
|
+
if (!JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogLevel>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "level")))) return false;
|
|
105
|
+
if (!JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogCategory>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "category")))) return false;
|
|
106
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "tag")))) return false;
|
|
107
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "message")))) return false;
|
|
108
|
+
if (!JSIConverter<std::unordered_map<std::string, std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "fields")))) return false;
|
|
109
|
+
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "error")))) return false;
|
|
110
|
+
return true;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CarrotQuestLogLevel.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::carrotquest {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (CarrotQuestLogLevel).
|
|
30
|
+
*/
|
|
31
|
+
enum class CarrotQuestLogLevel {
|
|
32
|
+
NONE SWIFT_NAME(none) = 0,
|
|
33
|
+
ERROR SWIFT_NAME(error) = 1,
|
|
34
|
+
WARN SWIFT_NAME(warn) = 2,
|
|
35
|
+
INFO SWIFT_NAME(info) = 3,
|
|
36
|
+
DEBUGGING SWIFT_NAME(debugging) = 4,
|
|
37
|
+
VERBOSE SWIFT_NAME(verbose) = 5,
|
|
38
|
+
} CLOSED_ENUM;
|
|
39
|
+
|
|
40
|
+
} // namespace margelo::nitro::carrotquest
|
|
41
|
+
|
|
42
|
+
namespace margelo::nitro {
|
|
43
|
+
|
|
44
|
+
// C++ CarrotQuestLogLevel <> JS CarrotQuestLogLevel (union)
|
|
45
|
+
template <>
|
|
46
|
+
struct JSIConverter<margelo::nitro::carrotquest::CarrotQuestLogLevel> final {
|
|
47
|
+
static inline margelo::nitro::carrotquest::CarrotQuestLogLevel fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
48
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
49
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
50
|
+
case hashString("none"): return margelo::nitro::carrotquest::CarrotQuestLogLevel::NONE;
|
|
51
|
+
case hashString("error"): return margelo::nitro::carrotquest::CarrotQuestLogLevel::ERROR;
|
|
52
|
+
case hashString("warn"): return margelo::nitro::carrotquest::CarrotQuestLogLevel::WARN;
|
|
53
|
+
case hashString("info"): return margelo::nitro::carrotquest::CarrotQuestLogLevel::INFO;
|
|
54
|
+
case hashString("debugging"): return margelo::nitro::carrotquest::CarrotQuestLogLevel::DEBUGGING;
|
|
55
|
+
case hashString("verbose"): return margelo::nitro::carrotquest::CarrotQuestLogLevel::VERBOSE;
|
|
56
|
+
default: [[unlikely]]
|
|
57
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum CarrotQuestLogLevel - invalid value!");
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::carrotquest::CarrotQuestLogLevel arg) {
|
|
61
|
+
switch (arg) {
|
|
62
|
+
case margelo::nitro::carrotquest::CarrotQuestLogLevel::NONE: return JSIConverter<std::string>::toJSI(runtime, "none");
|
|
63
|
+
case margelo::nitro::carrotquest::CarrotQuestLogLevel::ERROR: return JSIConverter<std::string>::toJSI(runtime, "error");
|
|
64
|
+
case margelo::nitro::carrotquest::CarrotQuestLogLevel::WARN: return JSIConverter<std::string>::toJSI(runtime, "warn");
|
|
65
|
+
case margelo::nitro::carrotquest::CarrotQuestLogLevel::INFO: return JSIConverter<std::string>::toJSI(runtime, "info");
|
|
66
|
+
case margelo::nitro::carrotquest::CarrotQuestLogLevel::DEBUGGING: return JSIConverter<std::string>::toJSI(runtime, "debugging");
|
|
67
|
+
case margelo::nitro::carrotquest::CarrotQuestLogLevel::VERBOSE: return JSIConverter<std::string>::toJSI(runtime, "verbose");
|
|
68
|
+
default: [[unlikely]]
|
|
69
|
+
throw std::invalid_argument("Cannot convert CarrotQuestLogLevel to JS - invalid value: "
|
|
70
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
74
|
+
if (!value.isString()) {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
78
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
79
|
+
case hashString("none"):
|
|
80
|
+
case hashString("error"):
|
|
81
|
+
case hashString("warn"):
|
|
82
|
+
case hashString("info"):
|
|
83
|
+
case hashString("debugging"):
|
|
84
|
+
case hashString("verbose"):
|
|
85
|
+
return true;
|
|
86
|
+
default:
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CarrotQuestProperty.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 `CarrotQuestPropertyOperation` to properly resolve imports.
|
|
32
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestPropertyOperation; }
|
|
33
|
+
// Forward declaration of `CarrotQuestPropertyKind` to properly resolve imports.
|
|
34
|
+
namespace margelo::nitro::carrotquest { enum class CarrotQuestPropertyKind; }
|
|
35
|
+
|
|
36
|
+
#include <string>
|
|
37
|
+
#include "CarrotQuestPropertyOperation.hpp"
|
|
38
|
+
#include <optional>
|
|
39
|
+
#include "CarrotQuestPropertyKind.hpp"
|
|
40
|
+
|
|
41
|
+
namespace margelo::nitro::carrotquest {
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* A struct which can be represented as a JavaScript object (CarrotQuestProperty).
|
|
45
|
+
*/
|
|
46
|
+
struct CarrotQuestProperty final {
|
|
47
|
+
public:
|
|
48
|
+
std::string key SWIFT_PRIVATE;
|
|
49
|
+
std::string value SWIFT_PRIVATE;
|
|
50
|
+
std::optional<CarrotQuestPropertyOperation> operation SWIFT_PRIVATE;
|
|
51
|
+
std::optional<CarrotQuestPropertyKind> kind SWIFT_PRIVATE;
|
|
52
|
+
|
|
53
|
+
public:
|
|
54
|
+
CarrotQuestProperty() = default;
|
|
55
|
+
explicit CarrotQuestProperty(std::string key, std::string value, std::optional<CarrotQuestPropertyOperation> operation, std::optional<CarrotQuestPropertyKind> kind): key(key), value(value), operation(operation), kind(kind) {}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
friend bool operator==(const CarrotQuestProperty& lhs, const CarrotQuestProperty& rhs) = default;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
} // namespace margelo::nitro::carrotquest
|
|
62
|
+
|
|
63
|
+
namespace margelo::nitro {
|
|
64
|
+
|
|
65
|
+
// C++ CarrotQuestProperty <> JS CarrotQuestProperty (object)
|
|
66
|
+
template <>
|
|
67
|
+
struct JSIConverter<margelo::nitro::carrotquest::CarrotQuestProperty> final {
|
|
68
|
+
static inline margelo::nitro::carrotquest::CarrotQuestProperty fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
69
|
+
jsi::Object obj = arg.asObject(runtime);
|
|
70
|
+
return margelo::nitro::carrotquest::CarrotQuestProperty(
|
|
71
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "key"))),
|
|
72
|
+
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value"))),
|
|
73
|
+
JSIConverter<std::optional<margelo::nitro::carrotquest::CarrotQuestPropertyOperation>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "operation"))),
|
|
74
|
+
JSIConverter<std::optional<margelo::nitro::carrotquest::CarrotQuestPropertyKind>>::fromJSI(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kind")))
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::carrotquest::CarrotQuestProperty& arg) {
|
|
78
|
+
jsi::Object obj(runtime);
|
|
79
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "key"), JSIConverter<std::string>::toJSI(runtime, arg.key));
|
|
80
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "value"), JSIConverter<std::string>::toJSI(runtime, arg.value));
|
|
81
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "operation"), JSIConverter<std::optional<margelo::nitro::carrotquest::CarrotQuestPropertyOperation>>::toJSI(runtime, arg.operation));
|
|
82
|
+
obj.setProperty(runtime, PropNameIDCache::get(runtime, "kind"), JSIConverter<std::optional<margelo::nitro::carrotquest::CarrotQuestPropertyKind>>::toJSI(runtime, arg.kind));
|
|
83
|
+
return obj;
|
|
84
|
+
}
|
|
85
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
86
|
+
if (!value.isObject()) {
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
jsi::Object obj = value.getObject(runtime);
|
|
90
|
+
if (!nitro::isPlainObject(runtime, obj)) {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "key")))) return false;
|
|
94
|
+
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "value")))) return false;
|
|
95
|
+
if (!JSIConverter<std::optional<margelo::nitro::carrotquest::CarrotQuestPropertyOperation>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "operation")))) return false;
|
|
96
|
+
if (!JSIConverter<std::optional<margelo::nitro::carrotquest::CarrotQuestPropertyKind>>::canConvert(runtime, obj.getProperty(runtime, PropNameIDCache::get(runtime, "kind")))) return false;
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CarrotQuestPropertyKind.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::carrotquest {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (CarrotQuestPropertyKind).
|
|
30
|
+
*/
|
|
31
|
+
enum class CarrotQuestPropertyKind {
|
|
32
|
+
CUSTOM SWIFT_NAME(custom) = 0,
|
|
33
|
+
SYSTEM SWIFT_NAME(system) = 1,
|
|
34
|
+
ECOMMERCE SWIFT_NAME(ecommerce) = 2,
|
|
35
|
+
} CLOSED_ENUM;
|
|
36
|
+
|
|
37
|
+
} // namespace margelo::nitro::carrotquest
|
|
38
|
+
|
|
39
|
+
namespace margelo::nitro {
|
|
40
|
+
|
|
41
|
+
// C++ CarrotQuestPropertyKind <> JS CarrotQuestPropertyKind (union)
|
|
42
|
+
template <>
|
|
43
|
+
struct JSIConverter<margelo::nitro::carrotquest::CarrotQuestPropertyKind> final {
|
|
44
|
+
static inline margelo::nitro::carrotquest::CarrotQuestPropertyKind 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("custom"): return margelo::nitro::carrotquest::CarrotQuestPropertyKind::CUSTOM;
|
|
48
|
+
case hashString("system"): return margelo::nitro::carrotquest::CarrotQuestPropertyKind::SYSTEM;
|
|
49
|
+
case hashString("ecommerce"): return margelo::nitro::carrotquest::CarrotQuestPropertyKind::ECOMMERCE;
|
|
50
|
+
default: [[unlikely]]
|
|
51
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum CarrotQuestPropertyKind - invalid value!");
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::carrotquest::CarrotQuestPropertyKind arg) {
|
|
55
|
+
switch (arg) {
|
|
56
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyKind::CUSTOM: return JSIConverter<std::string>::toJSI(runtime, "custom");
|
|
57
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyKind::SYSTEM: return JSIConverter<std::string>::toJSI(runtime, "system");
|
|
58
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyKind::ECOMMERCE: return JSIConverter<std::string>::toJSI(runtime, "ecommerce");
|
|
59
|
+
default: [[unlikely]]
|
|
60
|
+
throw std::invalid_argument("Cannot convert CarrotQuestPropertyKind 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("custom"):
|
|
71
|
+
case hashString("system"):
|
|
72
|
+
case hashString("ecommerce"):
|
|
73
|
+
return true;
|
|
74
|
+
default:
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
} // namespace margelo::nitro
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// CarrotQuestPropertyOperation.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::carrotquest {
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* An enum which can be represented as a JavaScript union (CarrotQuestPropertyOperation).
|
|
30
|
+
*/
|
|
31
|
+
enum class CarrotQuestPropertyOperation {
|
|
32
|
+
UPDATEORCREATE SWIFT_NAME(updateorcreate) = 0,
|
|
33
|
+
SETONCE SWIFT_NAME(setonce) = 1,
|
|
34
|
+
ADD SWIFT_NAME(add) = 2,
|
|
35
|
+
DELETE SWIFT_NAME(delete) = 3,
|
|
36
|
+
APPEND SWIFT_NAME(append) = 4,
|
|
37
|
+
UNION SWIFT_NAME(union) = 5,
|
|
38
|
+
EXCLUDE SWIFT_NAME(exclude) = 6,
|
|
39
|
+
} CLOSED_ENUM;
|
|
40
|
+
|
|
41
|
+
} // namespace margelo::nitro::carrotquest
|
|
42
|
+
|
|
43
|
+
namespace margelo::nitro {
|
|
44
|
+
|
|
45
|
+
// C++ CarrotQuestPropertyOperation <> JS CarrotQuestPropertyOperation (union)
|
|
46
|
+
template <>
|
|
47
|
+
struct JSIConverter<margelo::nitro::carrotquest::CarrotQuestPropertyOperation> final {
|
|
48
|
+
static inline margelo::nitro::carrotquest::CarrotQuestPropertyOperation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
|
49
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
|
50
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
51
|
+
case hashString("updateOrCreate"): return margelo::nitro::carrotquest::CarrotQuestPropertyOperation::UPDATEORCREATE;
|
|
52
|
+
case hashString("setOnce"): return margelo::nitro::carrotquest::CarrotQuestPropertyOperation::SETONCE;
|
|
53
|
+
case hashString("add"): return margelo::nitro::carrotquest::CarrotQuestPropertyOperation::ADD;
|
|
54
|
+
case hashString("delete"): return margelo::nitro::carrotquest::CarrotQuestPropertyOperation::DELETE;
|
|
55
|
+
case hashString("append"): return margelo::nitro::carrotquest::CarrotQuestPropertyOperation::APPEND;
|
|
56
|
+
case hashString("union"): return margelo::nitro::carrotquest::CarrotQuestPropertyOperation::UNION;
|
|
57
|
+
case hashString("exclude"): return margelo::nitro::carrotquest::CarrotQuestPropertyOperation::EXCLUDE;
|
|
58
|
+
default: [[unlikely]]
|
|
59
|
+
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum CarrotQuestPropertyOperation - invalid value!");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::carrotquest::CarrotQuestPropertyOperation arg) {
|
|
63
|
+
switch (arg) {
|
|
64
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyOperation::UPDATEORCREATE: return JSIConverter<std::string>::toJSI(runtime, "updateOrCreate");
|
|
65
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyOperation::SETONCE: return JSIConverter<std::string>::toJSI(runtime, "setOnce");
|
|
66
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyOperation::ADD: return JSIConverter<std::string>::toJSI(runtime, "add");
|
|
67
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyOperation::DELETE: return JSIConverter<std::string>::toJSI(runtime, "delete");
|
|
68
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyOperation::APPEND: return JSIConverter<std::string>::toJSI(runtime, "append");
|
|
69
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyOperation::UNION: return JSIConverter<std::string>::toJSI(runtime, "union");
|
|
70
|
+
case margelo::nitro::carrotquest::CarrotQuestPropertyOperation::EXCLUDE: return JSIConverter<std::string>::toJSI(runtime, "exclude");
|
|
71
|
+
default: [[unlikely]]
|
|
72
|
+
throw std::invalid_argument("Cannot convert CarrotQuestPropertyOperation to JS - invalid value: "
|
|
73
|
+
+ std::to_string(static_cast<int>(arg)) + "!");
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
static inline bool canConvert(jsi::Runtime& runtime, const jsi::Value& value) {
|
|
77
|
+
if (!value.isString()) {
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, value);
|
|
81
|
+
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
|
82
|
+
case hashString("updateOrCreate"):
|
|
83
|
+
case hashString("setOnce"):
|
|
84
|
+
case hashString("add"):
|
|
85
|
+
case hashString("delete"):
|
|
86
|
+
case hashString("append"):
|
|
87
|
+
case hashString("union"):
|
|
88
|
+
case hashString("exclude"):
|
|
89
|
+
return true;
|
|
90
|
+
default:
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
} // namespace margelo::nitro
|