react-native-unistyles 3.0.8 → 3.0.10
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/README.md +2 -2
- package/android/CMakeLists.txt +6 -2
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +11 -3
- package/cxx/hybridObjects/HybridShadowRegistry.h +3 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +3 -3
- package/cxx/shadowTree/ShadowTreeManager.cpp +58 -37
- package/cxx/shadowTree/ShadowTreeManager.h +4 -2
- package/nitrogen/generated/android/c++/JColorScheme.hpp +1 -1
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JOrientation.hpp +1 -1
- package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/ColorScheme.kt +4 -8
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +10 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Orientation.kt +3 -7
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +17 -21
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +22 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +3 -3
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +8 -8
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +5 -5
- package/nitrogen/generated/shared/c++/ColorScheme.hpp +9 -11
- package/nitrogen/generated/shared/c++/Dimensions.hpp +4 -6
- package/nitrogen/generated/shared/c++/Insets.hpp +4 -6
- package/nitrogen/generated/shared/c++/Orientation.hpp +7 -9
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +4 -6
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +19 -21
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +19 -21
- package/package.json +3 -3
package/README.md
CHANGED
@@ -21,14 +21,14 @@ yarn add react-native-unistyles
|
|
21
21
|
Install dependencies:
|
22
22
|
|
23
23
|
```shell
|
24
|
-
yarn add react-native-edge-to-edge react-native-nitro-modules@0.
|
24
|
+
yarn add react-native-edge-to-edge react-native-nitro-modules@0.28.0
|
25
25
|
```
|
26
26
|
|
27
27
|
> To avoid unexpected behavior, always use a fixed version of `react-native-nitro-modules`
|
28
28
|
|
29
29
|
| react-native-unistyles | react-native-nitro-modules |
|
30
30
|
|------------------------|----------------------------|
|
31
|
-
| 3.0.0 | 0.
|
31
|
+
| 3.0.0 | 0.28.0 |
|
32
32
|
|
33
33
|
Then follow [installation guides](https://unistyl.es/v3/start/getting-started) for your platform.
|
34
34
|
|
package/android/CMakeLists.txt
CHANGED
@@ -5,6 +5,10 @@ project(unistyles)
|
|
5
5
|
file(GLOB_RECURSE CORE_SRC RELATIVE ${CMAKE_SOURCE_DIR} "../cxx/**/*.cpp")
|
6
6
|
file(GLOB_RECURSE PLATFORM_SRC RELATIVE ${CMAKE_SOURCE_DIR} "./src/main/cxx/*.cpp")
|
7
7
|
|
8
|
+
if(ReactAndroid_VERSION_MINOR GREATER_EQUAL 80)
|
9
|
+
target_compile_reactnative_options(unistyles PRIVATE)
|
10
|
+
endif()
|
11
|
+
|
8
12
|
add_library(unistyles
|
9
13
|
SHARED
|
10
14
|
${CORE_SRC}
|
@@ -35,6 +39,6 @@ set_target_properties(unistyles PROPERTIES
|
|
35
39
|
|
36
40
|
# For React Native 0.76 and above, we don't need to link anything
|
37
41
|
# as NitroModules will automatically add ReactAndroid::reactnative prefab
|
38
|
-
if (ReactAndroid_VERSION_MINOR LESS
|
39
|
-
message(FATAL_ERROR "Unistyles 3.0 requires min. React Native version to be 0.
|
42
|
+
if (ReactAndroid_VERSION_MINOR LESS 78)
|
43
|
+
message(FATAL_ERROR "Unistyles 3.0 requires min. React Native version to be 0.78")
|
40
44
|
endif ()
|
@@ -6,7 +6,7 @@ using namespace facebook::react;
|
|
6
6
|
jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
7
7
|
helpers::assertThat(rt, count == 2, "Unistyles: Invalid babel transform 'ShadowRegistry link' expected 2 arguments.");
|
8
8
|
|
9
|
-
|
9
|
+
auto shadowNodeWrapper = getShadowNodeFromRef(rt, args[0]);
|
10
10
|
|
11
11
|
std::vector<core::Unistyle::Shared> unistyleWrappers = core::unistyleFromValue(rt, args[1]);
|
12
12
|
std::vector<std::vector<folly::dynamic>> arguments;
|
@@ -98,7 +98,7 @@ jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisVa
|
|
98
98
|
jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
99
99
|
helpers::assertThat(rt, count == 1, "Unistyles: Invalid babel transform 'ShadowRegistry unlink' expected 1 argument.");
|
100
100
|
|
101
|
-
|
101
|
+
auto shadowNodeWrapper = getShadowNodeFromRef(rt, args[0]);
|
102
102
|
|
103
103
|
auto& registry = core::UnistylesRegistry::get();
|
104
104
|
|
@@ -108,7 +108,7 @@ jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &this
|
|
108
108
|
}
|
109
109
|
|
110
110
|
jsi::Value HybridShadowRegistry::flush(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
|
111
|
-
shadow::ShadowTreeManager::updateShadowTree(
|
111
|
+
shadow::ShadowTreeManager::updateShadowTree(rt);
|
112
112
|
|
113
113
|
return jsi::Value::undefined();
|
114
114
|
}
|
@@ -137,3 +137,11 @@ jsi::Value HybridShadowRegistry::getScopedTheme(jsi::Runtime &rt, const jsi::Val
|
|
137
137
|
? jsi::String::createFromUtf8(rt, maybeScopedTheme.value())
|
138
138
|
: jsi::Value::undefined();
|
139
139
|
}
|
140
|
+
|
141
|
+
std::shared_ptr<const core::ShadowNode> HybridShadowRegistry::getShadowNodeFromRef(jsi::Runtime& rt, const jsi::Value& maybeRef) {
|
142
|
+
#if REACT_NATIVE_VERSION_MINOR >= 81
|
143
|
+
return Bridging<std::shared_ptr<const ShadowNode>>::fromJs(rt, maybeRef);
|
144
|
+
#else
|
145
|
+
return shadowNodeFromValue(rt, maybeRef);
|
146
|
+
#endif
|
147
|
+
}
|
@@ -6,6 +6,7 @@
|
|
6
6
|
#include "UnistylesState.h"
|
7
7
|
#include "UnistylesRegistry.h"
|
8
8
|
#include "ShadowTreeManager.h"
|
9
|
+
#include <cxxreact/ReactNativeVersion.h>
|
9
10
|
|
10
11
|
namespace margelo::nitro::unistyles {
|
11
12
|
|
@@ -45,6 +46,8 @@ struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
|
|
45
46
|
prototype.registerRawHybridMethod("getScopedTheme", 0, &HybridShadowRegistry::getScopedTheme);
|
46
47
|
});
|
47
48
|
};
|
49
|
+
|
50
|
+
std::shared_ptr<const core::ShadowNode> getShadowNodeFromRef(jsi::Runtime& rt, const jsi::Value& maybeRef);
|
48
51
|
|
49
52
|
private:
|
50
53
|
std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
|
@@ -296,7 +296,7 @@ void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependen
|
|
296
296
|
parser.rebuildShadowLeafUpdates(rt, dependencyMap);
|
297
297
|
|
298
298
|
this->notifyJSListeners(dependencies);
|
299
|
-
shadow::ShadowTreeManager::updateShadowTree(
|
299
|
+
shadow::ShadowTreeManager::updateShadowTree(rt);
|
300
300
|
}
|
301
301
|
|
302
302
|
void HybridStyleSheet::onPlatformNativeDependenciesChange(std::vector<UnistyleDependency> dependencies, UnistylesNativeMiniRuntime miniRuntime) {
|
@@ -352,7 +352,7 @@ void HybridStyleSheet::onPlatformNativeDependenciesChange(std::vector<UnistyleDe
|
|
352
352
|
parser.rebuildShadowLeafUpdates(rt, dependencyMap);
|
353
353
|
|
354
354
|
this->notifyJSListeners(unistyleDependencies);
|
355
|
-
shadow::ShadowTreeManager::updateShadowTree(
|
355
|
+
shadow::ShadowTreeManager::updateShadowTree(rt);
|
356
356
|
});
|
357
357
|
}
|
358
358
|
|
@@ -381,7 +381,7 @@ void HybridStyleSheet::onImeChange(UnistylesNativeMiniRuntime miniRuntime) {
|
|
381
381
|
parser.rebuildShadowLeafUpdates(rt, dependencyMap);
|
382
382
|
|
383
383
|
this->notifyJSListeners(dependencies);
|
384
|
-
shadow::ShadowTreeManager::updateShadowTree(
|
384
|
+
shadow::ShadowTreeManager::updateShadowTree(rt);
|
385
385
|
});
|
386
386
|
}
|
387
387
|
|
@@ -6,7 +6,7 @@ using namespace facebook;
|
|
6
6
|
|
7
7
|
using AffectedNodes = std::unordered_map<const ShadowNodeFamily*, std::unordered_set<int>>;
|
8
8
|
|
9
|
-
void shadow::ShadowTreeManager::updateShadowTree(
|
9
|
+
void shadow::ShadowTreeManager::updateShadowTree(jsi::Runtime& rt) {
|
10
10
|
auto& registry = core::UnistylesRegistry::get();
|
11
11
|
|
12
12
|
registry.trafficController.withLock([&](){
|
@@ -16,6 +16,21 @@ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shado
|
|
16
16
|
return;
|
17
17
|
}
|
18
18
|
|
19
|
+
#if REACT_NATIVE_VERSION_MINOR >= 81
|
20
|
+
std::unordered_map<Tag, folly::dynamic> tagToProps;
|
21
|
+
|
22
|
+
for (const auto& [family, props] : updates) {
|
23
|
+
tagToProps.insert({family->getTag(), props});
|
24
|
+
|
25
|
+
// Store in native props system to preserve during Reanimated cloning
|
26
|
+
const_cast<ShadowNodeFamily*>(family)->nativeProps_DEPRECATED =
|
27
|
+
std::make_unique<folly::dynamic>(props);
|
28
|
+
}
|
29
|
+
|
30
|
+
UIManagerBinding::getBinding(rt)->getUIManager().updateShadowTree(tagToProps);
|
31
|
+
#else
|
32
|
+
const auto& shadowTreeRegistry = UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry();
|
33
|
+
|
19
34
|
shadowTreeRegistry.enumerate([&updates](const ShadowTree& shadowTree, bool& stop){
|
20
35
|
// we could iterate via updates and create multiple commits
|
21
36
|
// but it can cause performance issues for hundreds of nodes
|
@@ -23,6 +38,12 @@ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shado
|
|
23
38
|
auto transaction = [&updates](const RootShadowNode& oldRootShadowNode) {
|
24
39
|
auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(oldRootShadowNode, updates);
|
25
40
|
|
41
|
+
for (const auto& [family, props] : updates) {
|
42
|
+
// Merge props to fix glitches caused by REA updates
|
43
|
+
const_cast<ShadowNodeFamily*>(family)->nativeProps_DEPRECATED =
|
44
|
+
std::make_unique<folly::dynamic>(props);
|
45
|
+
}
|
46
|
+
|
26
47
|
return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
|
27
48
|
oldRootShadowNode,
|
28
49
|
updates,
|
@@ -36,12 +57,12 @@ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shado
|
|
36
57
|
// mountSynchronously: must be true as this is update from C++ not React
|
37
58
|
shadowTree.commit(transaction, {false, true});
|
38
59
|
|
39
|
-
|
40
60
|
// for now we're assuming single surface, can be improved in the future
|
41
61
|
// stop = true means stop enumerating next shadow tree
|
42
62
|
// so in other words first shadow tree is our desired tree
|
43
63
|
stop = true;
|
44
64
|
});
|
65
|
+
#endif
|
45
66
|
});
|
46
67
|
}
|
47
68
|
|
@@ -80,15 +101,41 @@ AffectedNodes shadow::ShadowTreeManager::findAffectedNodes(const RootShadowNode&
|
|
80
101
|
return affectedNodes;
|
81
102
|
}
|
82
103
|
|
104
|
+
Props::Shared shadow::ShadowTreeManager::computeUpdatedProps(const ShadowNode &shadowNode, ShadowLeafUpdates& updates) {
|
105
|
+
const auto family = &shadowNode.getFamily();
|
106
|
+
const auto rawPropsIt = updates.find(family);
|
107
|
+
|
108
|
+
if (rawPropsIt == updates.end()) {
|
109
|
+
return ShadowNodeFragment::propsPlaceholder();
|
110
|
+
}
|
111
|
+
|
112
|
+
const auto& componentDescriptor = shadowNode.getComponentDescriptor();
|
113
|
+
const auto& props = shadowNode.getProps();
|
114
|
+
|
115
|
+
PropsParserContext propsParserContext{
|
116
|
+
shadowNode.getSurfaceId(),
|
117
|
+
*shadowNode.getContextContainer()
|
118
|
+
};
|
119
|
+
|
120
|
+
folly::dynamic newProps = rawPropsIt->second == nullptr
|
121
|
+
? folly::dynamic::object()
|
122
|
+
: rawPropsIt->second;
|
123
|
+
|
124
|
+
return componentDescriptor.cloneProps(
|
125
|
+
propsParserContext,
|
126
|
+
props,
|
127
|
+
RawProps(newProps)
|
128
|
+
);
|
129
|
+
}
|
130
|
+
|
83
131
|
// based on Reanimated algorithm
|
84
132
|
// clone affected nodes recursively, inject props and commit tree
|
85
|
-
ShadowNode
|
133
|
+
std::shared_ptr<ShadowNode> shadow::ShadowTreeManager::cloneShadowTree(const ShadowNode &shadowNode, ShadowLeafUpdates& updates, AffectedNodes& affectedNodes) {
|
86
134
|
const auto family = &shadowNode.getFamily();
|
87
|
-
const auto rawPropsIt = updates.find(family);
|
88
135
|
const auto childrenIt = affectedNodes.find(family);
|
89
136
|
|
90
137
|
// Only copy children if we need to update them
|
91
|
-
std::shared_ptr<
|
138
|
+
std::shared_ptr<std::vector<std::shared_ptr<const ShadowNode>>> childrenPtr;
|
92
139
|
const auto& originalChildren = shadowNode.getChildren();
|
93
140
|
|
94
141
|
if (childrenIt != affectedNodes.end()) {
|
@@ -98,42 +145,16 @@ ShadowNode::Unshared shadow::ShadowTreeManager::cloneShadowTree(const ShadowNode
|
|
98
145
|
children[index] = cloneShadowTree(*children[index], updates, affectedNodes);
|
99
146
|
}
|
100
147
|
|
101
|
-
childrenPtr = std::make_shared<ShadowNode
|
148
|
+
childrenPtr = std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(std::move(children));
|
102
149
|
} else {
|
103
|
-
childrenPtr = std::make_shared<ShadowNode
|
150
|
+
childrenPtr = std::make_shared<std::vector<std::shared_ptr<const ShadowNode>>>(originalChildren);
|
104
151
|
}
|
105
152
|
|
106
|
-
Props::Shared updatedProps =
|
107
|
-
|
108
|
-
if (rawPropsIt != updates.end()) {
|
109
|
-
const auto& componentDescriptor = shadowNode.getComponentDescriptor();
|
110
|
-
const auto& props = shadowNode.getProps();
|
111
|
-
|
112
|
-
PropsParserContext propsParserContext{
|
113
|
-
shadowNode.getSurfaceId(),
|
114
|
-
*shadowNode.getContextContainer()
|
115
|
-
};
|
116
|
-
|
117
|
-
folly::dynamic newProps;
|
118
|
-
#ifdef ANDROID
|
119
|
-
auto safeProps = rawPropsIt->second == nullptr
|
120
|
-
? folly::dynamic::object()
|
121
|
-
: rawPropsIt->second;
|
122
|
-
newProps = folly::dynamic::merge(props->rawProps, safeProps);
|
123
|
-
#else
|
124
|
-
newProps = rawPropsIt->second;
|
125
|
-
#endif
|
126
|
-
|
127
|
-
updatedProps = componentDescriptor.cloneProps(
|
128
|
-
propsParserContext,
|
129
|
-
props,
|
130
|
-
RawProps(newProps)
|
131
|
-
);
|
132
|
-
}
|
153
|
+
Props::Shared updatedProps = computeUpdatedProps(shadowNode, updates);
|
133
154
|
|
134
155
|
return shadowNode.clone({
|
135
|
-
|
136
|
-
childrenPtr,
|
137
|
-
shadowNode.getState()
|
156
|
+
.props = updatedProps,
|
157
|
+
.children = childrenPtr,
|
158
|
+
.state = shadowNode.getState()
|
138
159
|
});
|
139
160
|
}
|
@@ -6,6 +6,7 @@
|
|
6
6
|
#include <ranges>
|
7
7
|
#include "ShadowLeafUpdate.h"
|
8
8
|
#include "UnistylesRegistry.h"
|
9
|
+
#include <cxxreact/ReactNativeVersion.h>
|
9
10
|
|
10
11
|
namespace margelo::nitro::unistyles::shadow {
|
11
12
|
|
@@ -15,9 +16,10 @@ using namespace facebook;
|
|
15
16
|
using AffectedNodes = std::unordered_map<const ShadowNodeFamily *, std::unordered_set<int>>;
|
16
17
|
|
17
18
|
struct ShadowTreeManager {
|
18
|
-
static void updateShadowTree(
|
19
|
+
static void updateShadowTree(jsi::Runtime& rt);
|
19
20
|
static AffectedNodes findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates);
|
20
|
-
static ShadowNode
|
21
|
+
static std::shared_ptr<ShadowNode> cloneShadowTree(const ShadowNode& shadowNode, ShadowLeafUpdates& updates, AffectedNodes& affectedNodes);
|
22
|
+
static Props::Shared computeUpdatedProps(const ShadowNode &shadowNode, ShadowLeafUpdates& updates);
|
21
23
|
};
|
22
24
|
|
23
25
|
}
|
@@ -29,7 +29,7 @@ namespace margelo::nitro::unistyles {
|
|
29
29
|
[[nodiscard]]
|
30
30
|
ColorScheme toCpp() const {
|
31
31
|
static const auto clazz = javaClassStatic();
|
32
|
-
static const auto fieldOrdinal = clazz->getField<int>("
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
33
33
|
int ordinal = this->getFieldValue(fieldOrdinal);
|
34
34
|
return static_cast<ColorScheme>(ordinal);
|
35
35
|
}
|
@@ -29,6 +29,7 @@ namespace margelo::nitro::unistyles {
|
|
29
29
|
// C++ constructor (called from Java via `initHybrid()`)
|
30
30
|
explicit JHybridNativePlatformSpec(jni::alias_ref<jhybridobject> jThis) :
|
31
31
|
HybridObject(HybridNativePlatformSpec::TAG),
|
32
|
+
HybridBase(jThis),
|
32
33
|
_javaPart(jni::make_global(jThis)) {}
|
33
34
|
|
34
35
|
public:
|
@@ -29,7 +29,7 @@ namespace margelo::nitro::unistyles {
|
|
29
29
|
[[nodiscard]]
|
30
30
|
Orientation toCpp() const {
|
31
31
|
static const auto clazz = javaClassStatic();
|
32
|
-
static const auto fieldOrdinal = clazz->getField<int>("
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
33
33
|
int ordinal = this->getFieldValue(fieldOrdinal);
|
34
34
|
return static_cast<Orientation>(ordinal);
|
35
35
|
}
|
@@ -29,7 +29,7 @@ namespace margelo::nitro::unistyles {
|
|
29
29
|
[[nodiscard]]
|
30
30
|
UnistyleDependency toCpp() const {
|
31
31
|
static const auto clazz = javaClassStatic();
|
32
|
-
static const auto fieldOrdinal = clazz->getField<int>("
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
33
33
|
int ordinal = this->getFieldValue(fieldOrdinal);
|
34
34
|
return static_cast<UnistyleDependency>(ordinal);
|
35
35
|
}
|
@@ -15,12 +15,8 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
15
15
|
*/
|
16
16
|
@DoNotStrip
|
17
17
|
@Keep
|
18
|
-
enum class ColorScheme {
|
19
|
-
DARK,
|
20
|
-
LIGHT,
|
21
|
-
UNSPECIFIED;
|
22
|
-
|
23
|
-
@DoNotStrip
|
24
|
-
@Keep
|
25
|
-
private val _ordinal = ordinal
|
18
|
+
enum class ColorScheme(@DoNotStrip @Keep val value: Int) {
|
19
|
+
DARK(0),
|
20
|
+
LIGHT(1),
|
21
|
+
UNSPECIFIED(2);
|
26
22
|
}
|
@@ -21,10 +21,20 @@ data class Insets
|
|
21
21
|
@DoNotStrip
|
22
22
|
@Keep
|
23
23
|
constructor(
|
24
|
+
@DoNotStrip
|
25
|
+
@Keep
|
24
26
|
val top: Double,
|
27
|
+
@DoNotStrip
|
28
|
+
@Keep
|
25
29
|
val bottom: Double,
|
30
|
+
@DoNotStrip
|
31
|
+
@Keep
|
26
32
|
val left: Double,
|
33
|
+
@DoNotStrip
|
34
|
+
@Keep
|
27
35
|
val right: Double,
|
36
|
+
@DoNotStrip
|
37
|
+
@Keep
|
28
38
|
val ime: Double
|
29
39
|
) {
|
30
40
|
/* main constructor */
|
@@ -15,11 +15,7 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
15
15
|
*/
|
16
16
|
@DoNotStrip
|
17
17
|
@Keep
|
18
|
-
enum class Orientation {
|
19
|
-
PORTRAIT,
|
20
|
-
LANDSCAPE;
|
21
|
-
|
22
|
-
@DoNotStrip
|
23
|
-
@Keep
|
24
|
-
private val _ordinal = ordinal
|
18
|
+
enum class Orientation(@DoNotStrip @Keep val value: Int) {
|
19
|
+
PORTRAIT(0),
|
20
|
+
LANDSCAPE(1);
|
25
21
|
}
|
@@ -15,25 +15,21 @@ import com.facebook.proguard.annotations.DoNotStrip
|
|
15
15
|
*/
|
16
16
|
@DoNotStrip
|
17
17
|
@Keep
|
18
|
-
enum class UnistyleDependency {
|
19
|
-
THEME,
|
20
|
-
THEMENAME,
|
21
|
-
ADAPTIVETHEMES,
|
22
|
-
BREAKPOINTS,
|
23
|
-
VARIANTS,
|
24
|
-
COLORSCHEME,
|
25
|
-
DIMENSIONS,
|
26
|
-
ORIENTATION,
|
27
|
-
CONTENTSIZECATEGORY,
|
28
|
-
INSETS,
|
29
|
-
PIXELRATIO,
|
30
|
-
FONTSCALE,
|
31
|
-
STATUSBAR,
|
32
|
-
NAVIGATIONBAR,
|
33
|
-
IME,
|
34
|
-
RTL;
|
35
|
-
|
36
|
-
@DoNotStrip
|
37
|
-
@Keep
|
38
|
-
private val _ordinal = ordinal
|
18
|
+
enum class UnistyleDependency(@DoNotStrip @Keep val value: Int) {
|
19
|
+
THEME(0),
|
20
|
+
THEMENAME(1),
|
21
|
+
ADAPTIVETHEMES(2),
|
22
|
+
BREAKPOINTS(3),
|
23
|
+
VARIANTS(4),
|
24
|
+
COLORSCHEME(5),
|
25
|
+
DIMENSIONS(6),
|
26
|
+
ORIENTATION(7),
|
27
|
+
CONTENTSIZECATEGORY(8),
|
28
|
+
INSETS(9),
|
29
|
+
PIXELRATIO(10),
|
30
|
+
FONTSCALE(11),
|
31
|
+
STATUSBAR(12),
|
32
|
+
NAVIGATIONBAR(13),
|
33
|
+
IME(14),
|
34
|
+
RTL(15);
|
39
35
|
}
|
package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt
CHANGED
@@ -21,16 +21,38 @@ data class UnistylesNativeMiniRuntime
|
|
21
21
|
@DoNotStrip
|
22
22
|
@Keep
|
23
23
|
constructor(
|
24
|
+
@DoNotStrip
|
25
|
+
@Keep
|
24
26
|
val colorScheme: ColorScheme,
|
27
|
+
@DoNotStrip
|
28
|
+
@Keep
|
25
29
|
val screen: Dimensions,
|
30
|
+
@DoNotStrip
|
31
|
+
@Keep
|
26
32
|
val contentSizeCategory: String,
|
33
|
+
@DoNotStrip
|
34
|
+
@Keep
|
27
35
|
val insets: Insets,
|
36
|
+
@DoNotStrip
|
37
|
+
@Keep
|
28
38
|
val pixelRatio: Double,
|
39
|
+
@DoNotStrip
|
40
|
+
@Keep
|
29
41
|
val fontScale: Double,
|
42
|
+
@DoNotStrip
|
43
|
+
@Keep
|
30
44
|
val rtl: Boolean,
|
45
|
+
@DoNotStrip
|
46
|
+
@Keep
|
31
47
|
val statusBar: Dimensions,
|
48
|
+
@DoNotStrip
|
49
|
+
@Keep
|
32
50
|
val navigationBar: Dimensions,
|
51
|
+
@DoNotStrip
|
52
|
+
@Keep
|
33
53
|
val isPortrait: Boolean,
|
54
|
+
@DoNotStrip
|
55
|
+
@Keep
|
34
56
|
val isLandscape: Boolean
|
35
57
|
) {
|
36
58
|
/* main constructor */
|
@@ -29,12 +29,12 @@ namespace margelo::nitro::unistyles::bridge::swift {
|
|
29
29
|
};
|
30
30
|
}
|
31
31
|
|
32
|
-
// pragma MARK: std::shared_ptr<
|
33
|
-
std::shared_ptr<
|
32
|
+
// pragma MARK: std::shared_ptr<HybridNativePlatformSpec>
|
33
|
+
std::shared_ptr<HybridNativePlatformSpec> create_std__shared_ptr_HybridNativePlatformSpec_(void* _Nonnull swiftUnsafePointer) {
|
34
34
|
Unistyles::HybridNativePlatformSpec_cxx swiftPart = Unistyles::HybridNativePlatformSpec_cxx::fromUnsafe(swiftUnsafePointer);
|
35
35
|
return std::make_shared<margelo::nitro::unistyles::HybridNativePlatformSpecSwift>(swiftPart);
|
36
36
|
}
|
37
|
-
void* _Nonnull
|
37
|
+
void* _Nonnull get_std__shared_ptr_HybridNativePlatformSpec_(std__shared_ptr_HybridNativePlatformSpec_ cppType) {
|
38
38
|
std::shared_ptr<margelo::nitro::unistyles::HybridNativePlatformSpecSwift> swiftWrapper = std::dynamic_pointer_cast<margelo::nitro::unistyles::HybridNativePlatformSpecSwift>(cppType);
|
39
39
|
#ifdef NITRO_DEBUG
|
40
40
|
if (swiftWrapper == nullptr) [[unlikely]] {
|
@@ -103,17 +103,17 @@ namespace margelo::nitro::unistyles::bridge::swift {
|
|
103
103
|
return Func_void_UnistylesNativeMiniRuntime_Wrapper(std::move(value));
|
104
104
|
}
|
105
105
|
|
106
|
-
// pragma MARK: std::shared_ptr<
|
106
|
+
// pragma MARK: std::shared_ptr<HybridNativePlatformSpec>
|
107
107
|
/**
|
108
|
-
* Specialized version of `std::shared_ptr<
|
108
|
+
* Specialized version of `std::shared_ptr<HybridNativePlatformSpec>`.
|
109
109
|
*/
|
110
|
-
using
|
111
|
-
std::shared_ptr<
|
112
|
-
void* _Nonnull
|
110
|
+
using std__shared_ptr_HybridNativePlatformSpec_ = std::shared_ptr<HybridNativePlatformSpec>;
|
111
|
+
std::shared_ptr<HybridNativePlatformSpec> create_std__shared_ptr_HybridNativePlatformSpec_(void* _Nonnull swiftUnsafePointer);
|
112
|
+
void* _Nonnull get_std__shared_ptr_HybridNativePlatformSpec_(std__shared_ptr_HybridNativePlatformSpec_ cppType);
|
113
113
|
|
114
|
-
// pragma MARK: std::weak_ptr<
|
115
|
-
using
|
116
|
-
inline
|
114
|
+
// pragma MARK: std::weak_ptr<HybridNativePlatformSpec>
|
115
|
+
using std__weak_ptr_HybridNativePlatformSpec_ = std::weak_ptr<HybridNativePlatformSpec>;
|
116
|
+
inline std__weak_ptr_HybridNativePlatformSpec_ weakify_std__shared_ptr_HybridNativePlatformSpec_(const std::shared_ptr<HybridNativePlatformSpec>& strong) { return strong; }
|
117
117
|
|
118
118
|
// pragma MARK: Result<Insets>
|
119
119
|
using Result_Insets_ = Result<Insets>;
|
@@ -33,7 +33,7 @@ open class HybridNativePlatformSpec_cxx {
|
|
33
33
|
/**
|
34
34
|
* Holds a weak pointer to the C++ class that wraps the Swift class.
|
35
35
|
*/
|
36
|
-
private var __cxxPart: bridge.
|
36
|
+
private var __cxxPart: bridge.std__weak_ptr_HybridNativePlatformSpec_
|
37
37
|
|
38
38
|
/**
|
39
39
|
* Create a new `HybridNativePlatformSpec_cxx` that wraps the given `HybridNativePlatformSpec`.
|
@@ -72,15 +72,15 @@ open class HybridNativePlatformSpec_cxx {
|
|
72
72
|
|
73
73
|
/**
|
74
74
|
* Gets (or creates) the C++ part of this Hybrid Object.
|
75
|
-
* The C++ part is a `std::shared_ptr<
|
75
|
+
* The C++ part is a `std::shared_ptr<HybridNativePlatformSpec>`.
|
76
76
|
*/
|
77
|
-
public func getCxxPart() -> bridge.
|
77
|
+
public func getCxxPart() -> bridge.std__shared_ptr_HybridNativePlatformSpec_ {
|
78
78
|
let cachedCxxPart = self.__cxxPart.lock()
|
79
79
|
if cachedCxxPart.__convertToBool() {
|
80
80
|
return cachedCxxPart
|
81
81
|
} else {
|
82
|
-
let newCxxPart = bridge.
|
83
|
-
__cxxPart = bridge.
|
82
|
+
let newCxxPart = bridge.create_std__shared_ptr_HybridNativePlatformSpec_(self.toUnsafe())
|
83
|
+
__cxxPart = bridge.weakify_std__shared_ptr_HybridNativePlatformSpec_(newCxxPart)
|
84
84
|
return newCxxPart
|
85
85
|
}
|
86
86
|
}
|
@@ -38,26 +38,24 @@ namespace margelo::nitro::unistyles {
|
|
38
38
|
|
39
39
|
namespace margelo::nitro {
|
40
40
|
|
41
|
-
using namespace margelo::nitro::unistyles;
|
42
|
-
|
43
41
|
// C++ ColorScheme <> JS ColorScheme (union)
|
44
42
|
template <>
|
45
|
-
struct JSIConverter<ColorScheme> final {
|
46
|
-
static inline ColorScheme fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
43
|
+
struct JSIConverter<margelo::nitro::unistyles::ColorScheme> final {
|
44
|
+
static inline margelo::nitro::unistyles::ColorScheme fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
47
45
|
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
48
46
|
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
49
|
-
case hashString("dark"): return ColorScheme::DARK;
|
50
|
-
case hashString("light"): return ColorScheme::LIGHT;
|
51
|
-
case hashString("unspecified"): return ColorScheme::UNSPECIFIED;
|
47
|
+
case hashString("dark"): return margelo::nitro::unistyles::ColorScheme::DARK;
|
48
|
+
case hashString("light"): return margelo::nitro::unistyles::ColorScheme::LIGHT;
|
49
|
+
case hashString("unspecified"): return margelo::nitro::unistyles::ColorScheme::UNSPECIFIED;
|
52
50
|
default: [[unlikely]]
|
53
51
|
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum ColorScheme - invalid value!");
|
54
52
|
}
|
55
53
|
}
|
56
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, ColorScheme arg) {
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::unistyles::ColorScheme arg) {
|
57
55
|
switch (arg) {
|
58
|
-
case ColorScheme::DARK: return JSIConverter<std::string>::toJSI(runtime, "dark");
|
59
|
-
case ColorScheme::LIGHT: return JSIConverter<std::string>::toJSI(runtime, "light");
|
60
|
-
case ColorScheme::UNSPECIFIED: return JSIConverter<std::string>::toJSI(runtime, "unspecified");
|
56
|
+
case margelo::nitro::unistyles::ColorScheme::DARK: return JSIConverter<std::string>::toJSI(runtime, "dark");
|
57
|
+
case margelo::nitro::unistyles::ColorScheme::LIGHT: return JSIConverter<std::string>::toJSI(runtime, "light");
|
58
|
+
case margelo::nitro::unistyles::ColorScheme::UNSPECIFIED: return JSIConverter<std::string>::toJSI(runtime, "unspecified");
|
61
59
|
default: [[unlikely]]
|
62
60
|
throw std::invalid_argument("Cannot convert ColorScheme to JS - invalid value: "
|
63
61
|
+ std::to_string(static_cast<int>(arg)) + "!");
|
@@ -41,19 +41,17 @@ namespace margelo::nitro::unistyles {
|
|
41
41
|
|
42
42
|
namespace margelo::nitro {
|
43
43
|
|
44
|
-
using namespace margelo::nitro::unistyles;
|
45
|
-
|
46
44
|
// C++ Dimensions <> JS Dimensions (object)
|
47
45
|
template <>
|
48
|
-
struct JSIConverter<Dimensions> final {
|
49
|
-
static inline Dimensions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
46
|
+
struct JSIConverter<margelo::nitro::unistyles::Dimensions> final {
|
47
|
+
static inline margelo::nitro::unistyles::Dimensions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
50
48
|
jsi::Object obj = arg.asObject(runtime);
|
51
|
-
return Dimensions(
|
49
|
+
return margelo::nitro::unistyles::Dimensions(
|
52
50
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "width")),
|
53
51
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "height"))
|
54
52
|
);
|
55
53
|
}
|
56
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const Dimensions& arg) {
|
54
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::unistyles::Dimensions& arg) {
|
57
55
|
jsi::Object obj(runtime);
|
58
56
|
obj.setProperty(runtime, "width", JSIConverter<double>::toJSI(runtime, arg.width));
|
59
57
|
obj.setProperty(runtime, "height", JSIConverter<double>::toJSI(runtime, arg.height));
|
@@ -44,14 +44,12 @@ namespace margelo::nitro::unistyles {
|
|
44
44
|
|
45
45
|
namespace margelo::nitro {
|
46
46
|
|
47
|
-
using namespace margelo::nitro::unistyles;
|
48
|
-
|
49
47
|
// C++ Insets <> JS Insets (object)
|
50
48
|
template <>
|
51
|
-
struct JSIConverter<Insets> final {
|
52
|
-
static inline Insets fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
49
|
+
struct JSIConverter<margelo::nitro::unistyles::Insets> final {
|
50
|
+
static inline margelo::nitro::unistyles::Insets fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
53
51
|
jsi::Object obj = arg.asObject(runtime);
|
54
|
-
return Insets(
|
52
|
+
return margelo::nitro::unistyles::Insets(
|
55
53
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "top")),
|
56
54
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "bottom")),
|
57
55
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "left")),
|
@@ -59,7 +57,7 @@ namespace margelo::nitro {
|
|
59
57
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "ime"))
|
60
58
|
);
|
61
59
|
}
|
62
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const Insets& arg) {
|
60
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::unistyles::Insets& arg) {
|
63
61
|
jsi::Object obj(runtime);
|
64
62
|
obj.setProperty(runtime, "top", JSIConverter<double>::toJSI(runtime, arg.top));
|
65
63
|
obj.setProperty(runtime, "bottom", JSIConverter<double>::toJSI(runtime, arg.bottom));
|
@@ -37,24 +37,22 @@ namespace margelo::nitro::unistyles {
|
|
37
37
|
|
38
38
|
namespace margelo::nitro {
|
39
39
|
|
40
|
-
using namespace margelo::nitro::unistyles;
|
41
|
-
|
42
40
|
// C++ Orientation <> JS Orientation (union)
|
43
41
|
template <>
|
44
|
-
struct JSIConverter<Orientation> final {
|
45
|
-
static inline Orientation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
42
|
+
struct JSIConverter<margelo::nitro::unistyles::Orientation> final {
|
43
|
+
static inline margelo::nitro::unistyles::Orientation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
46
44
|
std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
|
47
45
|
switch (hashString(unionValue.c_str(), unionValue.size())) {
|
48
|
-
case hashString("portrait"): return Orientation::PORTRAIT;
|
49
|
-
case hashString("landscape"): return Orientation::LANDSCAPE;
|
46
|
+
case hashString("portrait"): return margelo::nitro::unistyles::Orientation::PORTRAIT;
|
47
|
+
case hashString("landscape"): return margelo::nitro::unistyles::Orientation::LANDSCAPE;
|
50
48
|
default: [[unlikely]]
|
51
49
|
throw std::invalid_argument("Cannot convert \"" + unionValue + "\" to enum Orientation - invalid value!");
|
52
50
|
}
|
53
51
|
}
|
54
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, Orientation arg) {
|
52
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::unistyles::Orientation arg) {
|
55
53
|
switch (arg) {
|
56
|
-
case Orientation::PORTRAIT: return JSIConverter<std::string>::toJSI(runtime, "portrait");
|
57
|
-
case Orientation::LANDSCAPE: return JSIConverter<std::string>::toJSI(runtime, "landscape");
|
54
|
+
case margelo::nitro::unistyles::Orientation::PORTRAIT: return JSIConverter<std::string>::toJSI(runtime, "portrait");
|
55
|
+
case margelo::nitro::unistyles::Orientation::LANDSCAPE: return JSIConverter<std::string>::toJSI(runtime, "landscape");
|
58
56
|
default: [[unlikely]]
|
59
57
|
throw std::invalid_argument("Cannot convert Orientation to JS - invalid value: "
|
60
58
|
+ std::to_string(static_cast<int>(arg)) + "!");
|
@@ -46,16 +46,14 @@ namespace margelo::nitro::unistyles {
|
|
46
46
|
|
47
47
|
namespace margelo::nitro {
|
48
48
|
|
49
|
-
using namespace margelo::nitro::unistyles;
|
50
|
-
|
51
49
|
// C++ UnistyleDependency <> JS UnistyleDependency (enum)
|
52
50
|
template <>
|
53
|
-
struct JSIConverter<UnistyleDependency> final {
|
54
|
-
static inline UnistyleDependency fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
51
|
+
struct JSIConverter<margelo::nitro::unistyles::UnistyleDependency> final {
|
52
|
+
static inline margelo::nitro::unistyles::UnistyleDependency fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
55
53
|
int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
|
56
|
-
return static_cast<UnistyleDependency>(enumValue);
|
54
|
+
return static_cast<margelo::nitro::unistyles::UnistyleDependency>(enumValue);
|
57
55
|
}
|
58
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, UnistyleDependency arg) {
|
56
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, margelo::nitro::unistyles::UnistyleDependency arg) {
|
59
57
|
int enumValue = static_cast<int>(arg);
|
60
58
|
return JSIConverter<int>::toJSI(runtime, enumValue);
|
61
59
|
}
|
@@ -62,44 +62,42 @@ namespace margelo::nitro::unistyles {
|
|
62
62
|
|
63
63
|
namespace margelo::nitro {
|
64
64
|
|
65
|
-
using namespace margelo::nitro::unistyles;
|
66
|
-
|
67
65
|
// C++ UnistylesCxxMiniRuntime <> JS UnistylesCxxMiniRuntime (object)
|
68
66
|
template <>
|
69
|
-
struct JSIConverter<UnistylesCxxMiniRuntime> final {
|
70
|
-
static inline UnistylesCxxMiniRuntime fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
67
|
+
struct JSIConverter<margelo::nitro::unistyles::UnistylesCxxMiniRuntime> final {
|
68
|
+
static inline margelo::nitro::unistyles::UnistylesCxxMiniRuntime fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
71
69
|
jsi::Object obj = arg.asObject(runtime);
|
72
|
-
return UnistylesCxxMiniRuntime(
|
70
|
+
return margelo::nitro::unistyles::UnistylesCxxMiniRuntime(
|
73
71
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "themeName")),
|
74
72
|
JSIConverter<std::optional<std::string>>::fromJSI(runtime, obj.getProperty(runtime, "breakpoint")),
|
75
73
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "hasAdaptiveThemes")),
|
76
|
-
JSIConverter<ColorScheme>::fromJSI(runtime, obj.getProperty(runtime, "colorScheme")),
|
77
|
-
JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "screen")),
|
74
|
+
JSIConverter<margelo::nitro::unistyles::ColorScheme>::fromJSI(runtime, obj.getProperty(runtime, "colorScheme")),
|
75
|
+
JSIConverter<margelo::nitro::unistyles::Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "screen")),
|
78
76
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "contentSizeCategory")),
|
79
|
-
JSIConverter<Insets>::fromJSI(runtime, obj.getProperty(runtime, "insets")),
|
77
|
+
JSIConverter<margelo::nitro::unistyles::Insets>::fromJSI(runtime, obj.getProperty(runtime, "insets")),
|
80
78
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pixelRatio")),
|
81
79
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "fontScale")),
|
82
80
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "rtl")),
|
83
|
-
JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "statusBar")),
|
84
|
-
JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "navigationBar")),
|
81
|
+
JSIConverter<margelo::nitro::unistyles::Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "statusBar")),
|
82
|
+
JSIConverter<margelo::nitro::unistyles::Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "navigationBar")),
|
85
83
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isPortrait")),
|
86
84
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isLandscape"))
|
87
85
|
);
|
88
86
|
}
|
89
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const UnistylesCxxMiniRuntime& arg) {
|
87
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::unistyles::UnistylesCxxMiniRuntime& arg) {
|
90
88
|
jsi::Object obj(runtime);
|
91
89
|
obj.setProperty(runtime, "themeName", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.themeName));
|
92
90
|
obj.setProperty(runtime, "breakpoint", JSIConverter<std::optional<std::string>>::toJSI(runtime, arg.breakpoint));
|
93
91
|
obj.setProperty(runtime, "hasAdaptiveThemes", JSIConverter<bool>::toJSI(runtime, arg.hasAdaptiveThemes));
|
94
|
-
obj.setProperty(runtime, "colorScheme", JSIConverter<ColorScheme>::toJSI(runtime, arg.colorScheme));
|
95
|
-
obj.setProperty(runtime, "screen", JSIConverter<Dimensions>::toJSI(runtime, arg.screen));
|
92
|
+
obj.setProperty(runtime, "colorScheme", JSIConverter<margelo::nitro::unistyles::ColorScheme>::toJSI(runtime, arg.colorScheme));
|
93
|
+
obj.setProperty(runtime, "screen", JSIConverter<margelo::nitro::unistyles::Dimensions>::toJSI(runtime, arg.screen));
|
96
94
|
obj.setProperty(runtime, "contentSizeCategory", JSIConverter<std::string>::toJSI(runtime, arg.contentSizeCategory));
|
97
|
-
obj.setProperty(runtime, "insets", JSIConverter<Insets>::toJSI(runtime, arg.insets));
|
95
|
+
obj.setProperty(runtime, "insets", JSIConverter<margelo::nitro::unistyles::Insets>::toJSI(runtime, arg.insets));
|
98
96
|
obj.setProperty(runtime, "pixelRatio", JSIConverter<double>::toJSI(runtime, arg.pixelRatio));
|
99
97
|
obj.setProperty(runtime, "fontScale", JSIConverter<double>::toJSI(runtime, arg.fontScale));
|
100
98
|
obj.setProperty(runtime, "rtl", JSIConverter<bool>::toJSI(runtime, arg.rtl));
|
101
|
-
obj.setProperty(runtime, "statusBar", JSIConverter<Dimensions>::toJSI(runtime, arg.statusBar));
|
102
|
-
obj.setProperty(runtime, "navigationBar", JSIConverter<Dimensions>::toJSI(runtime, arg.navigationBar));
|
99
|
+
obj.setProperty(runtime, "statusBar", JSIConverter<margelo::nitro::unistyles::Dimensions>::toJSI(runtime, arg.statusBar));
|
100
|
+
obj.setProperty(runtime, "navigationBar", JSIConverter<margelo::nitro::unistyles::Dimensions>::toJSI(runtime, arg.navigationBar));
|
103
101
|
obj.setProperty(runtime, "isPortrait", JSIConverter<bool>::toJSI(runtime, arg.isPortrait));
|
104
102
|
obj.setProperty(runtime, "isLandscape", JSIConverter<bool>::toJSI(runtime, arg.isLandscape));
|
105
103
|
return obj;
|
@@ -112,15 +110,15 @@ namespace margelo::nitro {
|
|
112
110
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "themeName"))) return false;
|
113
111
|
if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "breakpoint"))) return false;
|
114
112
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "hasAdaptiveThemes"))) return false;
|
115
|
-
if (!JSIConverter<ColorScheme>::canConvert(runtime, obj.getProperty(runtime, "colorScheme"))) return false;
|
116
|
-
if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "screen"))) return false;
|
113
|
+
if (!JSIConverter<margelo::nitro::unistyles::ColorScheme>::canConvert(runtime, obj.getProperty(runtime, "colorScheme"))) return false;
|
114
|
+
if (!JSIConverter<margelo::nitro::unistyles::Dimensions>::canConvert(runtime, obj.getProperty(runtime, "screen"))) return false;
|
117
115
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "contentSizeCategory"))) return false;
|
118
|
-
if (!JSIConverter<Insets>::canConvert(runtime, obj.getProperty(runtime, "insets"))) return false;
|
116
|
+
if (!JSIConverter<margelo::nitro::unistyles::Insets>::canConvert(runtime, obj.getProperty(runtime, "insets"))) return false;
|
119
117
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pixelRatio"))) return false;
|
120
118
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "fontScale"))) return false;
|
121
119
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "rtl"))) return false;
|
122
|
-
if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "statusBar"))) return false;
|
123
|
-
if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "navigationBar"))) return false;
|
120
|
+
if (!JSIConverter<margelo::nitro::unistyles::Dimensions>::canConvert(runtime, obj.getProperty(runtime, "statusBar"))) return false;
|
121
|
+
if (!JSIConverter<margelo::nitro::unistyles::Dimensions>::canConvert(runtime, obj.getProperty(runtime, "navigationBar"))) return false;
|
124
122
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isPortrait"))) return false;
|
125
123
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isLandscape"))) return false;
|
126
124
|
return true;
|
@@ -58,38 +58,36 @@ namespace margelo::nitro::unistyles {
|
|
58
58
|
|
59
59
|
namespace margelo::nitro {
|
60
60
|
|
61
|
-
using namespace margelo::nitro::unistyles;
|
62
|
-
|
63
61
|
// C++ UnistylesNativeMiniRuntime <> JS UnistylesNativeMiniRuntime (object)
|
64
62
|
template <>
|
65
|
-
struct JSIConverter<UnistylesNativeMiniRuntime> final {
|
66
|
-
static inline UnistylesNativeMiniRuntime fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
63
|
+
struct JSIConverter<margelo::nitro::unistyles::UnistylesNativeMiniRuntime> final {
|
64
|
+
static inline margelo::nitro::unistyles::UnistylesNativeMiniRuntime fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
|
67
65
|
jsi::Object obj = arg.asObject(runtime);
|
68
|
-
return UnistylesNativeMiniRuntime(
|
69
|
-
JSIConverter<ColorScheme>::fromJSI(runtime, obj.getProperty(runtime, "colorScheme")),
|
70
|
-
JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "screen")),
|
66
|
+
return margelo::nitro::unistyles::UnistylesNativeMiniRuntime(
|
67
|
+
JSIConverter<margelo::nitro::unistyles::ColorScheme>::fromJSI(runtime, obj.getProperty(runtime, "colorScheme")),
|
68
|
+
JSIConverter<margelo::nitro::unistyles::Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "screen")),
|
71
69
|
JSIConverter<std::string>::fromJSI(runtime, obj.getProperty(runtime, "contentSizeCategory")),
|
72
|
-
JSIConverter<Insets>::fromJSI(runtime, obj.getProperty(runtime, "insets")),
|
70
|
+
JSIConverter<margelo::nitro::unistyles::Insets>::fromJSI(runtime, obj.getProperty(runtime, "insets")),
|
73
71
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "pixelRatio")),
|
74
72
|
JSIConverter<double>::fromJSI(runtime, obj.getProperty(runtime, "fontScale")),
|
75
73
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "rtl")),
|
76
|
-
JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "statusBar")),
|
77
|
-
JSIConverter<Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "navigationBar")),
|
74
|
+
JSIConverter<margelo::nitro::unistyles::Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "statusBar")),
|
75
|
+
JSIConverter<margelo::nitro::unistyles::Dimensions>::fromJSI(runtime, obj.getProperty(runtime, "navigationBar")),
|
78
76
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isPortrait")),
|
79
77
|
JSIConverter<bool>::fromJSI(runtime, obj.getProperty(runtime, "isLandscape"))
|
80
78
|
);
|
81
79
|
}
|
82
|
-
static inline jsi::Value toJSI(jsi::Runtime& runtime, const UnistylesNativeMiniRuntime& arg) {
|
80
|
+
static inline jsi::Value toJSI(jsi::Runtime& runtime, const margelo::nitro::unistyles::UnistylesNativeMiniRuntime& arg) {
|
83
81
|
jsi::Object obj(runtime);
|
84
|
-
obj.setProperty(runtime, "colorScheme", JSIConverter<ColorScheme>::toJSI(runtime, arg.colorScheme));
|
85
|
-
obj.setProperty(runtime, "screen", JSIConverter<Dimensions>::toJSI(runtime, arg.screen));
|
82
|
+
obj.setProperty(runtime, "colorScheme", JSIConverter<margelo::nitro::unistyles::ColorScheme>::toJSI(runtime, arg.colorScheme));
|
83
|
+
obj.setProperty(runtime, "screen", JSIConverter<margelo::nitro::unistyles::Dimensions>::toJSI(runtime, arg.screen));
|
86
84
|
obj.setProperty(runtime, "contentSizeCategory", JSIConverter<std::string>::toJSI(runtime, arg.contentSizeCategory));
|
87
|
-
obj.setProperty(runtime, "insets", JSIConverter<Insets>::toJSI(runtime, arg.insets));
|
85
|
+
obj.setProperty(runtime, "insets", JSIConverter<margelo::nitro::unistyles::Insets>::toJSI(runtime, arg.insets));
|
88
86
|
obj.setProperty(runtime, "pixelRatio", JSIConverter<double>::toJSI(runtime, arg.pixelRatio));
|
89
87
|
obj.setProperty(runtime, "fontScale", JSIConverter<double>::toJSI(runtime, arg.fontScale));
|
90
88
|
obj.setProperty(runtime, "rtl", JSIConverter<bool>::toJSI(runtime, arg.rtl));
|
91
|
-
obj.setProperty(runtime, "statusBar", JSIConverter<Dimensions>::toJSI(runtime, arg.statusBar));
|
92
|
-
obj.setProperty(runtime, "navigationBar", JSIConverter<Dimensions>::toJSI(runtime, arg.navigationBar));
|
89
|
+
obj.setProperty(runtime, "statusBar", JSIConverter<margelo::nitro::unistyles::Dimensions>::toJSI(runtime, arg.statusBar));
|
90
|
+
obj.setProperty(runtime, "navigationBar", JSIConverter<margelo::nitro::unistyles::Dimensions>::toJSI(runtime, arg.navigationBar));
|
93
91
|
obj.setProperty(runtime, "isPortrait", JSIConverter<bool>::toJSI(runtime, arg.isPortrait));
|
94
92
|
obj.setProperty(runtime, "isLandscape", JSIConverter<bool>::toJSI(runtime, arg.isLandscape));
|
95
93
|
return obj;
|
@@ -99,15 +97,15 @@ namespace margelo::nitro {
|
|
99
97
|
return false;
|
100
98
|
}
|
101
99
|
jsi::Object obj = value.getObject(runtime);
|
102
|
-
if (!JSIConverter<ColorScheme>::canConvert(runtime, obj.getProperty(runtime, "colorScheme"))) return false;
|
103
|
-
if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "screen"))) return false;
|
100
|
+
if (!JSIConverter<margelo::nitro::unistyles::ColorScheme>::canConvert(runtime, obj.getProperty(runtime, "colorScheme"))) return false;
|
101
|
+
if (!JSIConverter<margelo::nitro::unistyles::Dimensions>::canConvert(runtime, obj.getProperty(runtime, "screen"))) return false;
|
104
102
|
if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "contentSizeCategory"))) return false;
|
105
|
-
if (!JSIConverter<Insets>::canConvert(runtime, obj.getProperty(runtime, "insets"))) return false;
|
103
|
+
if (!JSIConverter<margelo::nitro::unistyles::Insets>::canConvert(runtime, obj.getProperty(runtime, "insets"))) return false;
|
106
104
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "pixelRatio"))) return false;
|
107
105
|
if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "fontScale"))) return false;
|
108
106
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "rtl"))) return false;
|
109
|
-
if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "statusBar"))) return false;
|
110
|
-
if (!JSIConverter<Dimensions>::canConvert(runtime, obj.getProperty(runtime, "navigationBar"))) return false;
|
107
|
+
if (!JSIConverter<margelo::nitro::unistyles::Dimensions>::canConvert(runtime, obj.getProperty(runtime, "statusBar"))) return false;
|
108
|
+
if (!JSIConverter<margelo::nitro::unistyles::Dimensions>::canConvert(runtime, obj.getProperty(runtime, "navigationBar"))) return false;
|
111
109
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isPortrait"))) return false;
|
112
110
|
if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "isLandscape"))) return false;
|
113
111
|
return true;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.10",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "NODE_ENV=babel-test jest ./plugin",
|
@@ -148,11 +148,11 @@
|
|
148
148
|
"husky": "9.1.7",
|
149
149
|
"jest": "29.7.0",
|
150
150
|
"metro-react-native-babel-preset": "0.77.0",
|
151
|
-
"nitro-codegen": "0.
|
151
|
+
"nitro-codegen": "0.28.0",
|
152
152
|
"react": "19.1.0",
|
153
153
|
"react-native": "0.79.2",
|
154
154
|
"react-native-builder-bob": "0.40.10",
|
155
|
-
"react-native-nitro-modules": "0.
|
155
|
+
"react-native-nitro-modules": "0.28.0",
|
156
156
|
"react-native-reanimated": "3.17.5",
|
157
157
|
"react-native-web": "0.20.0",
|
158
158
|
"react-test-renderer": "19.1.0",
|