react-native-unistyles 3.0.0-alpha.36 → 3.0.0-alpha.38
Sign up to get free protection for your applications and to get access to all the features.
- package/Unistyles.podspec +1 -1
- package/android/CMakeLists.txt +3 -15
- package/android/src/main/cxx/NativeUnistylesModule.cpp +1 -1
- package/android/src/main/java/com/unistyles/Equatable.kt +61 -0
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +302 -0
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +148 -0
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +54 -0
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +5 -1
- package/cxx/core/UnistyleData.h +1 -1
- package/cxx/core/UnistyleWrapper.h +1 -2
- package/cxx/core/UnistylesCommitHook.cpp +1 -1
- package/cxx/core/UnistylesMountHook.cpp +1 -1
- package/cxx/core/UnistylesRegistry.cpp +4 -13
- package/cxx/core/UnistylesRegistry.h +1 -2
- package/cxx/core/UnistylesState.cpp +10 -7
- package/cxx/hybridObjects/HybridStyleSheet.cpp +21 -18
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +0 -4
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +0 -1
- package/cxx/parser/Parser.cpp +3 -27
- package/cxx/parser/Parser.h +2 -3
- package/cxx/shadowTree/ShadowTrafficController.h +9 -5
- package/cxx/shadowTree/ShadowTreeManager.cpp +10 -5
- package/cxx/shadowTree/ShadowTreeManager.h +1 -1
- package/lib/commonjs/core/createUnistylesComponent.native.js +1 -1
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
- package/lib/module/core/createUnistylesComponent.native.js +1 -1
- package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
- package/package.json +3 -3
- package/plugin/common.js +7 -1
- package/src/core/createUnistylesComponent.native.tsx +1 -1
- package/android/src/main/java/com/unistyles/NativePlatform.kt +0 -184
- package/android/src/main/java/com/unistyles/UnistylesModule+insets.kt +0 -8
@@ -78,10 +78,6 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
|
|
78
78
|
auto parser = parser::Parser(nullptr);
|
79
79
|
shadow::ShadowLeafUpdates updates;
|
80
80
|
|
81
|
-
if (!this->_shadowRegistry[&rt].contains(shadowNodeFamily)) {
|
82
|
-
this->_shadowRegistry[&rt][shadowNodeFamily] = {};
|
83
|
-
}
|
84
|
-
|
85
81
|
std::for_each(unistyles.begin(), unistyles.end(), [&, this](Unistyle::Shared unistyle){
|
86
82
|
this->_shadowRegistry[&rt][shadowNodeFamily].emplace_back(std::make_shared<UnistyleData>(unistyle, variants, arguments));
|
87
83
|
|
@@ -104,16 +100,11 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
|
|
104
100
|
|
105
101
|
void core::UnistylesRegistry::unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily* shadowNodeFamily) {
|
106
102
|
this->_shadowRegistry[&rt].erase(shadowNodeFamily);
|
107
|
-
|
103
|
+
this->trafficController.removeShadowNode(shadowNodeFamily);
|
108
104
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
if (targetStyleSheet == nullptr) {
|
113
|
-
return nullptr;
|
105
|
+
if (this->_shadowRegistry[&rt].empty()) {
|
106
|
+
this->_shadowRegistry.erase(&rt);
|
114
107
|
}
|
115
|
-
|
116
|
-
return targetStyleSheet.get()->unistyles[styleKey];
|
117
108
|
}
|
118
109
|
|
119
110
|
std::shared_ptr<core::StyleSheet> core::UnistylesRegistry::addStyleSheet(jsi::Runtime& rt, int unid, core::StyleSheetType type, jsi::Object&& rawValue) {
|
@@ -162,7 +153,7 @@ void core::UnistylesRegistry::shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Uni
|
|
162
153
|
for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
|
163
154
|
for (const auto& unistyleData : unistyles) {
|
164
155
|
if (unistyleData->unistyle == unistyle) {
|
165
|
-
updates[family] = parser.parseStylesToShadowTreeStyles(rt, {unistyleData});
|
156
|
+
updates[family] = parser.parseStylesToShadowTreeStyles(rt, { unistyleData });
|
166
157
|
}
|
167
158
|
}
|
168
159
|
}
|
@@ -41,7 +41,6 @@ struct UnistylesRegistry: public StyleSheetRegistry {
|
|
41
41
|
void unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily*);
|
42
42
|
std::shared_ptr<core::StyleSheet> addStyleSheet(jsi::Runtime& rt, int tag, core::StyleSheetType type, jsi::Object&& rawValue);
|
43
43
|
DependencyMap buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps);
|
44
|
-
Unistyle::Shared findUnistyleFromKey(jsi::Runtime& rt, std::string styleKey, int tag);
|
45
44
|
void shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle);
|
46
45
|
shadow::ShadowTrafficController trafficController{};
|
47
46
|
|
@@ -50,7 +49,7 @@ private:
|
|
50
49
|
|
51
50
|
std::unordered_map<jsi::Runtime*, UnistylesState> _states{};
|
52
51
|
std::unordered_map<jsi::Runtime*, std::unordered_map<int, std::shared_ptr<core::StyleSheet>>> _styleSheetRegistry{};
|
53
|
-
std::unordered_map<jsi::Runtime*, std::unordered_map<const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>>> _shadowRegistry{};
|
52
|
+
std::unordered_map<jsi::Runtime*, std::unordered_map<const ShadowNodeFamily*, std::vector<const std::shared_ptr<UnistyleData>>>> _shadowRegistry{};
|
54
53
|
};
|
55
54
|
|
56
55
|
inline UnistylesRegistry& UnistylesRegistry::get() {
|
@@ -25,7 +25,7 @@ std::optional<std::string>& core::UnistylesState::getCurrentThemeName() {
|
|
25
25
|
|
26
26
|
jsi::Object core::UnistylesState::getCurrentJSTheme() {
|
27
27
|
auto hasSomeThemes = _registeredThemeNames.size() > 0;
|
28
|
-
|
28
|
+
|
29
29
|
if (!hasSomeThemes && !this->hasUserConfig) {
|
30
30
|
helpers::assertThat(*_rt, false, "Unistyles: One of your stylesheets is trying to get the theme, but no theme has been selected yet. Did you forget to call StyleSheet.configure? If you called it, make sure you did so before any StyleSheet.create.");
|
31
31
|
}
|
@@ -99,15 +99,18 @@ int core::UnistylesState::parseColor(jsi::Value& maybeColor) {
|
|
99
99
|
if (!maybeColor.isString()) {
|
100
100
|
return 0;
|
101
101
|
}
|
102
|
-
|
102
|
+
|
103
103
|
auto colorString = maybeColor.asString(*_rt);
|
104
|
-
|
104
|
+
|
105
105
|
if (!this->_colorCache.contains(colorString.utf8(*_rt).c_str())) {
|
106
|
-
|
107
|
-
|
108
|
-
|
106
|
+
#ifdef ANDROID
|
107
|
+
int color = this->_processColorFn.get()->call(*_rt, colorString).asNumber();
|
108
|
+
#else
|
109
|
+
uint32_t color = this->_processColorFn.get()->call(*_rt, colorString).asNumber();
|
110
|
+
#endif
|
111
|
+
|
109
112
|
this->_colorCache[colorString.utf8(*_rt).c_str()] = color ? color : 0;
|
110
113
|
}
|
111
|
-
|
114
|
+
|
112
115
|
return this->_colorCache[colorString.utf8(*_rt).c_str()];
|
113
116
|
}
|
@@ -15,7 +15,7 @@ double HybridStyleSheet::getUnid() {
|
|
15
15
|
|
16
16
|
jsi::Value HybridStyleSheet::create(jsi::Runtime& rt, const jsi::Value &thisVal, const jsi::Value *arguments, size_t count) {
|
17
17
|
if (count == 1) {
|
18
|
-
helpers::assertThat(rt,
|
18
|
+
helpers::assertThat(rt, false, "Unistyles is not initialized correctly. Please add babel plugin to your babel config.");
|
19
19
|
}
|
20
20
|
|
21
21
|
// second argument is hidden, so validation is perfectly fine
|
@@ -128,7 +128,7 @@ void HybridStyleSheet::parseSettings(jsi::Runtime &rt, jsi::Object settings) {
|
|
128
128
|
void HybridStyleSheet::parseBreakpoints(jsi::Runtime &rt, jsi::Object breakpoints){
|
129
129
|
helpers::Breakpoints sortedBreakpoints = helpers::jsiBreakpointsToVecPairs(rt, std::move(breakpoints));
|
130
130
|
|
131
|
-
helpers::assertThat(rt, sortedBreakpoints.
|
131
|
+
helpers::assertThat(rt, !sortedBreakpoints.empty(), "StyleSheet.configure's breakpoints can't be empty.");
|
132
132
|
helpers::assertThat(rt, sortedBreakpoints.front().second == 0, "StyleSheet.configure's first breakpoint must start from 0.");
|
133
133
|
|
134
134
|
auto& registry = core::UnistylesRegistry::get();
|
@@ -197,7 +197,7 @@ void HybridStyleSheet::verifyAndSelectTheme(jsi::Runtime &rt) {
|
|
197
197
|
|
198
198
|
void HybridStyleSheet::setThemeFromColorScheme(jsi::Runtime& rt) {
|
199
199
|
auto& state = core::UnistylesRegistry::get().getState(rt);
|
200
|
-
|
200
|
+
auto colorScheme = static_cast<ColorScheme>(this->_unistylesRuntime->getColorScheme());
|
201
201
|
|
202
202
|
switch (colorScheme) {
|
203
203
|
case ColorScheme::LIGHT:
|
@@ -232,7 +232,7 @@ void HybridStyleSheet::loadExternalMethods(const jsi::Value& thisValue, jsi::Run
|
|
232
232
|
void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
|
233
233
|
// cleanup Shadow updates
|
234
234
|
core::UnistylesRegistry::get().trafficController.restore();
|
235
|
-
|
235
|
+
|
236
236
|
this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager);
|
237
237
|
this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager, this->_unistylesRuntime);
|
238
238
|
}
|
@@ -248,20 +248,20 @@ void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependen
|
|
248
248
|
auto dependencies = std::move(unistylesDependencies);
|
249
249
|
|
250
250
|
// re-compute new breakpoint
|
251
|
-
auto dimensionsIt = std::find(
|
251
|
+
auto dimensionsIt = std::find(unistylesDependencies.begin(), unistylesDependencies.end(), UnistyleDependency::DIMENSIONS);
|
252
252
|
|
253
|
-
if (dimensionsIt !=
|
253
|
+
if (dimensionsIt != unistylesDependencies.end()) {
|
254
254
|
registry.getState(rt).computeCurrentBreakpoint(this->_unistylesRuntime->getScreen().width);
|
255
255
|
}
|
256
256
|
|
257
257
|
// check if color scheme changed and then if Unistyles state depend on it (adaptive themes)
|
258
|
-
auto colorSchemeIt = std::find(
|
259
|
-
auto hasNewColorScheme = colorSchemeIt !=
|
258
|
+
auto colorSchemeIt = std::find(unistylesDependencies.begin(), unistylesDependencies.end(), UnistyleDependency::COLORSCHEME);
|
259
|
+
auto hasNewColorScheme = colorSchemeIt != unistylesDependencies.end();
|
260
260
|
|
261
261
|
// in a later step, we will rebuild only Unistyles with mounted StyleSheets
|
262
262
|
// however, user may have StyleSheets with components that haven't mounted yet
|
263
263
|
// we need to rebuild all dependent StyleSheets as well
|
264
|
-
auto dependentStyleSheets = registry.getStyleSheetsToRefresh(rt, hasNewColorScheme,
|
264
|
+
auto dependentStyleSheets = registry.getStyleSheetsToRefresh(rt, hasNewColorScheme, unistylesDependencies.size() > 1);
|
265
265
|
|
266
266
|
if (hasNewColorScheme) {
|
267
267
|
this->_unistylesRuntime->includeDependenciesForColorSchemeChange(dependencies);
|
@@ -269,17 +269,17 @@ void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependen
|
|
269
269
|
|
270
270
|
auto dependencyMap = registry.buildDependencyMap(rt, dependencies);
|
271
271
|
|
272
|
-
if (dependencyMap.
|
272
|
+
if (dependencyMap.empty()) {
|
273
273
|
this->notifyJSListeners(dependencies);
|
274
274
|
|
275
275
|
return;
|
276
276
|
}
|
277
277
|
|
278
278
|
parser.rebuildUnistylesInDependencyMap(rt, dependencyMap, dependentStyleSheets);
|
279
|
-
parser.rebuildShadowLeafUpdates(dependencyMap);
|
280
|
-
|
279
|
+
parser.rebuildShadowLeafUpdates(rt, dependencyMap);
|
280
|
+
|
281
281
|
this->notifyJSListeners(dependencies);
|
282
|
-
shadow::ShadowTreeManager::updateShadowTree(rt);
|
282
|
+
shadow::ShadowTreeManager::updateShadowTree(UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry());
|
283
283
|
});
|
284
284
|
}
|
285
285
|
|
@@ -298,18 +298,21 @@ void HybridStyleSheet::onImeChange() {
|
|
298
298
|
|
299
299
|
auto dependencyMap = registry.buildDependencyMap(rt, dependencies);
|
300
300
|
|
301
|
-
if (dependencyMap.
|
301
|
+
if (dependencyMap.empty()) {
|
302
302
|
return;
|
303
303
|
}
|
304
|
+
|
305
|
+
std::vector<std::shared_ptr<core::StyleSheet>> styleSheet;
|
306
|
+
|
307
|
+
parser.rebuildUnistylesInDependencyMap(rt, dependencyMap, styleSheet);
|
308
|
+
parser.rebuildShadowLeafUpdates(rt, dependencyMap);
|
304
309
|
|
305
|
-
|
306
|
-
parser.rebuildShadowLeafUpdates(dependencyMap);
|
307
|
-
shadow::ShadowTreeManager::updateShadowTree(rt);
|
310
|
+
shadow::ShadowTreeManager::updateShadowTree(UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry());
|
308
311
|
});
|
309
312
|
}
|
310
313
|
|
311
314
|
void HybridStyleSheet::notifyJSListeners(std::vector<UnistyleDependency>& dependencies) {
|
312
|
-
if (dependencies.
|
315
|
+
if (!dependencies.empty()) {
|
313
316
|
std::for_each(this->_changeListeners.begin(), this->_changeListeners.end(), [&](auto& listener){
|
314
317
|
(*listener)(dependencies);
|
315
318
|
});
|
@@ -228,10 +228,6 @@ jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt) {
|
|
228
228
|
return obj;
|
229
229
|
}
|
230
230
|
|
231
|
-
jsi::Runtime& HybridUnistylesRuntime::getRuntime() {
|
232
|
-
return *this->_rt;
|
233
|
-
}
|
234
|
-
|
235
231
|
void HybridUnistylesRuntime::registerPlatformListener(const std::function<void(std::vector<UnistyleDependency>)>& listener) {
|
236
232
|
this->_nativePlatform.registerPlatformListener(listener);
|
237
233
|
this->_onDependenciesChange = listener;
|
@@ -67,7 +67,6 @@ struct HybridUnistylesRuntime: public HybridUnistylesRuntimeSpec {
|
|
67
67
|
std::unordered_map<std::string, double> getBreakpoints() override;
|
68
68
|
|
69
69
|
jsi::Value getMiniRuntimeAsValue(jsi::Runtime& rt);
|
70
|
-
jsi::Runtime& getRuntime();
|
71
70
|
void includeDependenciesForColorSchemeChange(std::vector<UnistyleDependency>& deps);
|
72
71
|
void calculateNewThemeAndDependencies(std::vector<UnistyleDependency>& deps);
|
73
72
|
std::function<void(std::function<void(jsi::Runtime&)>&&)> runOnJSThread;
|
package/cxx/parser/Parser.cpp
CHANGED
@@ -93,13 +93,12 @@ void parser::Parser::rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_
|
|
93
93
|
continue;
|
94
94
|
}
|
95
95
|
|
96
|
-
// todo skip dynamic functions
|
97
96
|
this->rebuildUnistyle(rt, styleSheet, unistyle, variants, std::nullopt);
|
98
97
|
}
|
99
98
|
}
|
100
99
|
|
101
100
|
// rebuild all unistyles that are affected by platform event
|
102
|
-
void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet
|
101
|
+
void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet>>& styleSheets) {
|
103
102
|
std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value> parsedStyleSheets{};
|
104
103
|
std::unordered_map<std::shared_ptr<core::Unistyle>, bool> parsedUnistyles{};
|
105
104
|
|
@@ -121,7 +120,7 @@ void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, Dependenc
|
|
121
120
|
auto& unistyle = unistyleData->unistyle;
|
122
121
|
|
123
122
|
// for RN styles or inline styles, compute styles only once
|
124
|
-
if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY
|
123
|
+
if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY) {
|
125
124
|
if (!unistyleData->parsedStyle.has_value()) {
|
126
125
|
unistyleData->parsedStyle = jsi::Value(rt, unistyle->rawValue).asObject(rt);
|
127
126
|
|
@@ -206,10 +205,9 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleShee
|
|
206
205
|
}
|
207
206
|
|
208
207
|
// convert dependency map to shadow tree updates
|
209
|
-
void parser::Parser::rebuildShadowLeafUpdates(core::DependencyMap& dependencyMap) {
|
208
|
+
void parser::Parser::rebuildShadowLeafUpdates(jsi::Runtime& rt, core::DependencyMap& dependencyMap) {
|
210
209
|
shadow::ShadowLeafUpdates updates;
|
211
210
|
auto& registry = core::UnistylesRegistry::get();
|
212
|
-
auto& rt = this->_unistylesRuntime->getRuntime();
|
213
211
|
|
214
212
|
for (const auto& [shadowNode, unistyles] : dependencyMap) {
|
215
213
|
auto rawProps = this->parseStylesToShadowTreeStyles(rt, unistyles);
|
@@ -218,8 +216,6 @@ void parser::Parser::rebuildShadowLeafUpdates(core::DependencyMap& dependencyMap
|
|
218
216
|
}
|
219
217
|
|
220
218
|
registry.trafficController.setUpdates(updates);
|
221
|
-
|
222
|
-
// this is required, we need to indicate that there are new changes
|
223
219
|
registry.trafficController.resumeUnistylesTraffic();
|
224
220
|
}
|
225
221
|
|
@@ -764,26 +760,6 @@ folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, c
|
|
764
760
|
return jsi::dynamicFromValue(rt, std::move(convertedStyles));
|
765
761
|
}
|
766
762
|
|
767
|
-
folly::dynamic parser::Parser::parseUnistyleToShadowTreeStyles(jsi::Runtime& rt, const Unistyle::Shared unistyle) {
|
768
|
-
jsi::Object convertedStyles = jsi::Object(rt);
|
769
|
-
auto& state = core::UnistylesRegistry::get().getState(rt);
|
770
|
-
|
771
|
-
// can happen for exotic styles
|
772
|
-
if (!unistyle->parsedStyle.has_value()) {
|
773
|
-
return nullptr;
|
774
|
-
}
|
775
|
-
|
776
|
-
helpers::enumerateJSIObject(rt, unistyle->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
|
777
|
-
if (this->isColor(propertyName)) {
|
778
|
-
return convertedStyles.setProperty(rt, propertyName.c_str(), jsi::Value(state.parseColor(propertyValue)));
|
779
|
-
}
|
780
|
-
|
781
|
-
convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
|
782
|
-
});
|
783
|
-
|
784
|
-
return jsi::dynamicFromValue(rt, std::move(convertedStyles));
|
785
|
-
}
|
786
|
-
|
787
763
|
// check is styleKey contains color
|
788
764
|
bool parser::Parser::isColor(const std::string& propertyName) {
|
789
765
|
std::string str = propertyName;
|
package/cxx/parser/Parser.h
CHANGED
@@ -24,9 +24,8 @@ struct Parser {
|
|
24
24
|
void buildUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet);
|
25
25
|
void parseUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet);
|
26
26
|
void rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Variants& variants);
|
27
|
-
void rebuildUnistylesInDependencyMap(jsi::Runtime& rt, core::DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet
|
28
|
-
void rebuildShadowLeafUpdates(core::DependencyMap& dependencyMap);
|
29
|
-
folly::dynamic parseUnistyleToShadowTreeStyles(jsi::Runtime& rt, const Unistyle::Shared unistyle);
|
27
|
+
void rebuildUnistylesInDependencyMap(jsi::Runtime& rt, core::DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet>>& styleSheets);
|
28
|
+
void rebuildShadowLeafUpdates(jsi::Runtime& rt, core::DependencyMap& dependencyMap);
|
30
29
|
folly::dynamic parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles);
|
31
30
|
void rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants, std::optional<std::vector<folly::dynamic>>);
|
32
31
|
|
@@ -13,20 +13,16 @@ struct ShadowTrafficController {
|
|
13
13
|
}
|
14
14
|
|
15
15
|
inline void stopUnistylesTraffic() {
|
16
|
-
std::lock_guard<std::mutex> lock(_mutex);
|
17
|
-
|
18
16
|
this->_canCommit = false;
|
19
17
|
}
|
20
18
|
|
21
19
|
inline void resumeUnistylesTraffic() {
|
22
|
-
std::lock_guard<std::mutex> lock(_mutex);
|
23
|
-
|
24
20
|
this->_canCommit = true;
|
25
21
|
}
|
26
22
|
|
27
23
|
inline shadow::ShadowLeafUpdates& getUpdates() {
|
28
24
|
std::lock_guard<std::mutex> lock(_mutex);
|
29
|
-
|
25
|
+
|
30
26
|
return _unistylesUpdates;
|
31
27
|
}
|
32
28
|
|
@@ -47,6 +43,14 @@ struct ShadowTrafficController {
|
|
47
43
|
targetUpdates.emplace(pair.first, std::move(pair.second));
|
48
44
|
});
|
49
45
|
}
|
46
|
+
|
47
|
+
inline void removeShadowNode(const ShadowNodeFamily* shadowNodeFamily) {
|
48
|
+
std::lock_guard<std::mutex> lock(_mutex);
|
49
|
+
|
50
|
+
if (_unistylesUpdates.contains(shadowNodeFamily)) {
|
51
|
+
_unistylesUpdates.erase(shadowNodeFamily);
|
52
|
+
}
|
53
|
+
}
|
50
54
|
|
51
55
|
inline void restore() {
|
52
56
|
std::lock_guard<std::mutex> lock(_mutex);
|
@@ -6,13 +6,11 @@ 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(const ShadowTreeRegistry& shadowTreeRegistry) {
|
10
10
|
auto& registry = core::UnistylesRegistry::get();
|
11
|
-
auto& uiManager = UIManagerBinding::getBinding(rt)->getUIManager();
|
12
|
-
const auto &shadowTreeRegistry = uiManager.getShadowTreeRegistry();
|
13
11
|
auto updates = registry.trafficController.getUpdates();
|
14
12
|
|
15
|
-
if (updates.
|
13
|
+
if (updates.empty()) {
|
16
14
|
return;
|
17
15
|
}
|
18
16
|
|
@@ -111,9 +109,16 @@ ShadowNode::Unshared shadow::ShadowTreeManager::cloneShadowTree(const ShadowNode
|
|
111
109
|
*shadowNode.getContextContainer()
|
112
110
|
};
|
113
111
|
|
112
|
+
#ifdef ANDROID
|
113
|
+
auto safeProps = rawPropsIt->second == nullptr ? folly::dynamic::object() : rawPropsIt->second;
|
114
|
+
auto newProps = folly::dynamic::merge(shadowNode.getProps()->rawProps, safeProps);
|
115
|
+
#else
|
116
|
+
auto newProps = rawPropsIt->second;
|
117
|
+
#endif
|
118
|
+
|
114
119
|
updatedProps = shadowNode
|
115
120
|
.getComponentDescriptor()
|
116
|
-
.cloneProps(propsParserContext, shadowNode.getProps(), RawProps(
|
121
|
+
.cloneProps(propsParserContext, shadowNode.getProps(), RawProps(newProps));
|
117
122
|
}
|
118
123
|
|
119
124
|
return shadowNode.clone({
|
@@ -16,7 +16,7 @@ using namespace facebook;
|
|
16
16
|
using AffectedNodes = std::unordered_map<const ShadowNodeFamily *, std::unordered_set<int>>;
|
17
17
|
|
18
18
|
struct ShadowTreeManager {
|
19
|
-
static void updateShadowTree(
|
19
|
+
static void updateShadowTree(const ShadowTreeRegistry& shadowTreeRegistry);
|
20
20
|
static AffectedNodes findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates);
|
21
21
|
static ShadowNode::Unshared cloneShadowTree(const ShadowNode &shadowNode, ShadowLeafUpdates& updates, AffectedNodes& affectedNodes);
|
22
22
|
};
|
@@ -46,7 +46,7 @@ const createUnistylesComponent = (Component, mappings) => {
|
|
46
46
|
stylesRef.current = {
|
47
47
|
...stylesRef.current,
|
48
48
|
// @ts-expect-error - this is hidden from TS
|
49
|
-
[propName]: props[propName].__proto__?.getStyle() || props[propName]
|
49
|
+
[propName]: props[propName].__proto__?.getStyle?.() || props[propName]
|
50
50
|
};
|
51
51
|
}
|
52
52
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","mappings","props","theme","setTheme","useState","UnistylesRuntime","getTheme","setRt","stylesRef","useRef","isForcedRef","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","getStyle","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","UnistyleDependency","Theme","some","dependency","prevState","mergedProps","keys","key","assign","jsx","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAqG,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU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AAE,CAAC;UACjN;UAEAV,SAAS,CAACG,OAAO,GAAG;YAChB,GAAGH,SAAS,CAACG,OAAO;YACpB,CAACE,QAAQ,GAAGZ,KAAK,CAACY,QAAQ;UAC9B,CAAC;QACL;MACJ,CAAC,CAAC;IACN;IAEA,IAAAQ,gBAAS,EAAC,MAAM;MACZ,MAAMC,oBAAoB,GAAIC,iBAAU,CAAyBC,iBAAiB,CAACC,YAAY,IAAI;QAC/F,MAAMC,qBAAqB,GAAIzB,KAAK,CAAC0B,KAAK,EAAExC,SAAS,CAACyC,iBAAiB,IAAI5B,QAAQ,GAAGE,KAAK,CAAC,CAACyB,KAAK,EAAExC,SAAS,CAACyC,iBAA+C;QAE7J,IAAIH,YAAY,CAACI,QAAQ,CAACC,yBAAkB,CAACC,KAAK,CAAC,KAAK,CAACL,qBAAqB,IAAGA,qBAAqB,CAACG,QAAQ,CAACC,yBAAkB,CAACC,KAAK,CAAC,CAAC,EAAE;UACxI5B,QAAQ,CAACE,uBAAgB,CAACC,QAAQ,CAAC,CAAC,CAAC;;UAErC;UACAT,qBAAqB,CAACe,OAAO,CAACC,QAAQ,IAAI;YACtC,IAAIZ,KAAK,GAAGY,QAAQ,CAAC,EAAE;cACnBL,SAAS,CAACG,OAAO,GAAG;gBAChB,GAAGH,SAAS,CAACG,OAAO;gBACpB;gBACA,CAACE,QAAQ,GAAGZ,KAAK,CAACY,QAAQ,CAAC,CAAC1B,SAAS,EAAEiC,QAAQ,
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","mappings","props","theme","setTheme","useState","UnistylesRuntime","getTheme","setRt","stylesRef","useRef","isForcedRef","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","getStyle","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","UnistyleDependency","Theme","some","dependency","prevState","mergedProps","keys","key","assign","jsx","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAqG,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,C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WAAW,GAAGnC,QAAQ,GAAGE,KAAK,CAAC,IAA2B,CAAC,CAAC;IAElEb,MAAM,CAAC+C,IAAI,CAACnC,KAAK,CAAC,CAACW,OAAO,CAACyB,GAAG,IAAI;MAC9B,IAAIA,GAAG,IAAIF,WAAW,EAAE;QACpBA,WAAW,CAACE,GAAG,CAAC,GAAGhD,MAAM,CAACiD,MAAM,CAACrC,KAAK,CAACoC,GAAG,CAAuB,EAAEF,WAAW,CAACE,GAAG,CAAC,CAAC;QAEpF;MACJ;MAEAF,WAAW,CAACE,GAAG,CAAC,GAAGpC,KAAK,CAACoC,GAAG,CAAuB;IACvD,CAAC,CAAC;;IAEF;IACAxC,qBAAqB,CAACe,OAAO,CAACC,QAAQ,IAAI;MACtC,IAAIsB,WAAW,CAACtB,QAAQ,CAAC,EAAE;QACvBsB,WAAW,CAACtB,QAAQ,CAAC,GAAGL,SAAS,CAACG,OAAO,CAACE,QAAQ,CAAC;MACvD;IACJ,CAAC,CAAC;IAEFH,WAAW,CAACC,OAAO,GAAG,KAAK;IAE3B,oBAAO,IAAAnC,WAAA,CAAA+D,GAAA,EAACxC,SAAS;MAAA,GAAKoC;IAAW,CAAa,CAAC;EACnD,CAAC;AACL,CAAC;AAAAK,OAAA,CAAA1C,wBAAA,GAAAA,wBAAA","ignoreList":[]}
|
@@ -40,7 +40,7 @@ export const createUnistylesComponent = (Component, mappings) => {
|
|
40
40
|
stylesRef.current = {
|
41
41
|
...stylesRef.current,
|
42
42
|
// @ts-expect-error - this is hidden from TS
|
43
|
-
[propName]: props[propName].__proto__?.getStyle() || props[propName]
|
43
|
+
[propName]: props[propName].__proto__?.getStyle?.() || props[propName]
|
44
44
|
};
|
45
45
|
}
|
46
46
|
});
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["React","useEffect","useRef","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","jsx","_jsx","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","mappings","props","theme","setTheme","getTheme","setRt","stylesRef","isForcedRef","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","__proto__","getStyle","removeChangeListener","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","Theme","some","dependency","prevState","mergedProps","Object","keys","key","assign"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAwBC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAE9E,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAkC,UAAU;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGrG,MAAMC,qBAAqB,GAAG,CAAC,OAAO,EAAE,uBAAuB,CAAU;AAGzE,OAAO,MAAMC,wBAAwB,GAAEA,CAAmGC,SAAgC,EAAEC,QAA+C,KAAK;EAC5N,OAAQC,KAA+D,IAAK;IACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGZ,QAAQ,CAAiBG,gBAAgB,CAACU,QAAQ,CAAC,CAAC,CAAC;IAC/E,MAAM,GAAGC,KAAK,CAAC,GAAGd,QAAQ,CAAC,CAAC,CAAC;IAC7B,MAAMe,SAAS,GAAGhB,MAAM,CAAsB,CAAC,CAAC,CAAC;IACjD,MAAMiB,WAAW,GAAGjB,MAAM,CAAC,KAAK,CAAC;IAEjC,IAAI,CAACiB,WAAW,CAACC,OAAO,EAAE;MACtBX,qBAAqB,CAACY,OAAO,CAACC,QAAQ,IAAI;QACtC,IAAIT,KAAK,GAAGS,QAAQ,CAAC,EAAE;UACnB,IAAIC,KAAK,CAACC,OAAO,CAACX,KAAK,CAACS,QAAQ,CAAC,CAAC,EAAE;YAChCG,OAAO,CAACC,KAAK,CAAC,mDAAmDJ,QAAQ,uDAAuDX,SAAS,CAACgB,WAAW,EAAE,CAAC;UAC5J;;UAEA;UACA,IAAId,KAAK,CAACS,QAAQ,CAAC,CAACM,gBAAgB,IAAI,CAACf,KAAK,CAACS,QAAQ,CAAC,CAACO,SAAS,EAAEC,QAAQ,EAAE;YAC1EL,OAAO,CAACC,KAAK,CAAC,uKAAuKf,SAAS,CAACgB,WAAW,EAAE,CAAC;UACjN;UAEAT,SAAS,CAACE,OAAO,GAAG;YAChB,GAAGF,SAAS,CAACE,OAAO;YACpB,CAACE,QAAQ,GAAGT,KAAK,CAACS,QAAQ;UAC9B,CAAC;QACL;MACJ,CAAC,CAAC;IACN;IAEArB,SAAS,CAAC,MAAM;MACZ,MAAM8B,oBAAoB,GAAI3B,UAAU,CAAyB4B,iBAAiB,CAACC,YAAY,IAAI;QAC/F,MAAMC,qBAAqB,GAAIrB,KAAK,CAACsB,KAAK,EAAEN,SAAS,CAACO,iBAAiB,IAAIxB,QAAQ,GAAGE,KAAK,CAAC,CAACqB,KAAK,EAAEN,SAAS,CAACO,iBAA+C;QAE7J,IAAIH,YAAY,CAACI,QAAQ,CAAChC,kBAAkB,CAACiC,KAAK,CAAC,KAAK,CAACJ,qBAAqB,IAAGA,qBAAqB,CAACG,QAAQ,CAAChC,kBAAkB,CAACiC,KAAK,CAAC,CAAC,EAAE;UACxIvB,QAAQ,CAACT,gBAAgB,CAACU,QAAQ,CAAC,CAAC,CAAC;;UAErC;UACAP,qBAAqB,CAACY,OAAO,CAACC,QAAQ,IAAI;YACtC,IAAIT,KAAK,GAAGS,QAAQ,CAAC,EAAE;cACnBJ,SAAS,CAACE,OAAO,GAAG;gBAChB,GAAGF,SAAS,CAACE,OAAO;gBACpB;gBACA,CAACE,QAAQ,GAAGT,KAAK,CAACS,QAAQ,CAAC,CAACO,SAAS,EAAEC,QAAQ,
|
1
|
+
{"version":3,"names":["React","useEffect","useRef","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","jsx","_jsx","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","mappings","props","theme","setTheme","getTheme","setRt","stylesRef","isForcedRef","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","__proto__","getStyle","removeChangeListener","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","Theme","some","dependency","prevState","mergedProps","Object","keys","key","assign"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAwBC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAE9E,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAkC,UAAU;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAGrG,MAAMC,qBAAqB,GAAG,CAAC,OAAO,EAAE,uBAAuB,CAAU;AAGzE,OAAO,MAAMC,wBAAwB,GAAEA,CAAmGC,SAAgC,EAAEC,QAA+C,KAAK;EAC5N,OAAQC,KAA+D,IAAK;IACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGZ,QAAQ,CAAiBG,gBAAgB,CAACU,QAAQ,CAAC,CAAC,CAAC;IAC/E,MAAM,GAAGC,KAAK,CAAC,GAAGd,QAAQ,CAAC,CAAC,CAAC;IAC7B,MAAMe,SAAS,GAAGhB,MAAM,CAAsB,CAAC,CAAC,CAAC;IACjD,MAAMiB,WAAW,GAAGjB,MAAM,CAAC,KAAK,CAAC;IAEjC,IAAI,CAACiB,WAAW,CAACC,OAAO,EAAE;MACtBX,qBAAqB,CAACY,OAAO,CAACC,QAAQ,IAAI;QACtC,IAAIT,KAAK,GAAGS,QAAQ,CAAC,EAAE;UACnB,IAAIC,KAAK,CAACC,OAAO,CAACX,KAAK,CAACS,QAAQ,CAAC,CAAC,EAAE;YAChCG,OAAO,CAACC,KAAK,CAAC,mDAAmDJ,QAAQ,uDAAuDX,SAAS,CAACgB,WAAW,EAAE,CAAC;UAC5J;;UAEA;UACA,IAAId,KAAK,CAACS,QAAQ,CAAC,CAACM,gBAAgB,IAAI,CAACf,KAAK,CAACS,QAAQ,CAAC,CAACO,SAAS,EAAEC,QAAQ,EAAE;YAC1EL,OAAO,CAACC,KAAK,CAAC,uKAAuKf,SAAS,CAACgB,WAAW,EAAE,CA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,CAAC,CAAC;QACrC;MACJ,CAAC,CAAC;MAEF,OAAO,MAAM;QACTV,oBAAoB,CAAC,CAAC;MAC1B,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;IAEN,MAAMW,WAAW,GAAG9B,QAAQ,GAAGE,KAAK,CAAC,IAA2B,CAAC,CAAC;IAElE6B,MAAM,CAACC,IAAI,CAAC/B,KAAK,CAAC,CAACQ,OAAO,CAACwB,GAAG,IAAI;MAC9B,IAAIA,GAAG,IAAIH,WAAW,EAAE;QACpBA,WAAW,CAACG,GAAG,CAAC,GAAGF,MAAM,CAACG,MAAM,CAACjC,KAAK,CAACgC,GAAG,CAAuB,EAAEH,WAAW,CAACG,GAAG,CAAC,CAAC;QAEpF;MACJ;MAEAH,WAAW,CAACG,GAAG,CAAC,GAAGhC,KAAK,CAACgC,GAAG,CAAuB;IACvD,CAAC,CAAC;;IAEF;IACApC,qBAAqB,CAACY,OAAO,CAACC,QAAQ,IAAI;MACtC,IAAIoB,WAAW,CAACpB,QAAQ,CAAC,EAAE;QACvBoB,WAAW,CAACpB,QAAQ,CAAC,GAAGJ,SAAS,CAACE,OAAO,CAACE,QAAQ,CAAC;MACvD;IACJ,CAAC,CAAC;IAEFH,WAAW,CAACC,OAAO,GAAG,KAAK;IAE3B,oBAAOZ,IAAA,CAACG,SAAS;MAAA,GAAK+B;IAAW,CAAa,CAAC;EACnD,CAAC;AACL,CAAC","ignoreList":[]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-alpha.
|
3
|
+
"version": "3.0.0-alpha.38",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -74,11 +74,11 @@
|
|
74
74
|
"husky": "9.1.6",
|
75
75
|
"jest": "29.7.0",
|
76
76
|
"metro-react-native-babel-preset": "0.77.0",
|
77
|
-
"nitro-codegen": "0.
|
77
|
+
"nitro-codegen": "0.16.2",
|
78
78
|
"react": "18.3.1",
|
79
79
|
"react-native": "0.76.0",
|
80
80
|
"react-native-builder-bob": "0.30.2",
|
81
|
-
"react-native-nitro-modules": "0.
|
81
|
+
"react-native-nitro-modules": "0.16.2",
|
82
82
|
"react-test-renderer": "18.3.1",
|
83
83
|
"release-it": "17.10.0",
|
84
84
|
"typescript": "5.6.3"
|
package/plugin/common.js
CHANGED
@@ -1,5 +1,9 @@
|
|
1
1
|
function getIdentifierNameFromExpression(t, memberExpression) {
|
2
2
|
if (t.isMemberExpression(memberExpression)) {
|
3
|
+
if (memberExpression.computed) {
|
4
|
+
return getIdentifierNameFromExpression(t, memberExpression.property).flat()
|
5
|
+
}
|
6
|
+
|
3
7
|
const object = memberExpression.object
|
4
8
|
|
5
9
|
// If the object is an Identifier, return its name
|
@@ -96,7 +100,9 @@ function getSecondPropertyName(t, memberExpression) {
|
|
96
100
|
return []
|
97
101
|
}
|
98
102
|
|
99
|
-
let current = memberExpression
|
103
|
+
let current = memberExpression.computed
|
104
|
+
? memberExpression.property
|
105
|
+
: memberExpression
|
100
106
|
let propertyName = null
|
101
107
|
|
102
108
|
while (t.isMemberExpression(current)) {
|
@@ -46,7 +46,7 @@ export const createUnistylesComponent =<TProps extends Record<string, any>, TMap
|
|
46
46
|
stylesRef.current = {
|
47
47
|
...stylesRef.current,
|
48
48
|
// @ts-expect-error - this is hidden from TS
|
49
|
-
[propName]: props[propName].__proto__?.getStyle() || props[propName]
|
49
|
+
[propName]: props[propName].__proto__?.getStyle?.() || props[propName]
|
50
50
|
}
|
51
51
|
}
|
52
52
|
})
|