react-native-unistyles 3.0.0-alpha.15 → 3.0.0-alpha.16
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.
@@ -88,8 +88,14 @@ int core::UnistylesState::parseColor(jsi::Value& maybeColor) {
|
|
88
88
|
return 0;
|
89
89
|
}
|
90
90
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
91
|
+
auto colorString = maybeColor.asString(*_rt);
|
92
|
+
|
93
|
+
if (!this->_colorCache.contains(colorString.utf8(*_rt).c_str())) {
|
94
|
+
// we must convert it to uint32_t first, otherwise color will be broken
|
95
|
+
uint32_t color = this->_processColorFn.get()->call(*_rt, colorString).asNumber();
|
96
|
+
|
97
|
+
this->_colorCache[colorString.utf8(*_rt).c_str()] = color ? color : 0;
|
98
|
+
}
|
99
|
+
|
100
|
+
return this->_colorCache[colorString.utf8(*_rt).c_str()];
|
95
101
|
}
|
@@ -43,6 +43,7 @@ private:
|
|
43
43
|
std::vector<std::string> _registeredThemeNames{};
|
44
44
|
std::optional<std::string> _currentThemeName = std::nullopt;
|
45
45
|
std::shared_ptr<jsi::Function> _processColorFn;
|
46
|
+
std::unordered_map<std::string, uint32_t> _colorCache{};
|
46
47
|
|
47
48
|
friend class UnistylesRegistry;
|
48
49
|
};
|
package/cxx/parser/Parser.cpp
CHANGED
@@ -621,6 +621,11 @@ RawProps parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const s
|
|
621
621
|
auto& state = core::UnistylesRegistry::get().getState(rt);
|
622
622
|
|
623
623
|
for (const auto& unistyleData : unistyles) {
|
624
|
+
if (!unistyleData->parsedStyle.has_value()) {
|
625
|
+
// todo this something happens with large dataset, debug it
|
626
|
+
continue;
|
627
|
+
}
|
628
|
+
|
624
629
|
helpers::enumerateJSIObject(rt, unistyleData->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
|
625
630
|
if (this->isColor(propertyName)) {
|
626
631
|
return convertedStyles.setProperty(rt, propertyName.c_str(), jsi::Value(state.parseColor(propertyValue)));
|