react-native-unistyles 3.0.22 → 3.0.24
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 +11 -5
- package/android/src/main/java/com/unistyles/Equatable.kt +1 -2
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +34 -7
- package/cxx/parser/Parser.cpp +166 -13
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +15 -2
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +16 -3
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/nitrogen/generated/ios/swift/Dimensions.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_UnistylesNativeMiniRuntime.swift +0 -1
- package/nitrogen/generated/ios/swift/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +0 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +0 -1
- package/nitrogen/generated/ios/swift/Insets.swift +0 -1
- package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +0 -1
- package/package.json +3 -3
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +20 -5
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.33.
|
|
24
|
+
yarn add react-native-edge-to-edge react-native-nitro-modules@0.33.8
|
|
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.33.
|
|
31
|
+
| 3.0.0 | 0.33.8 |
|
|
32
32
|
|
|
33
33
|
Then follow [installation guides](https://unistyl.es/v3/start/getting-started) for your platform.
|
|
34
34
|
|
|
@@ -59,9 +59,6 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
|
|
|
59
59
|
<a href="https://galaxies.dev">
|
|
60
60
|
<img src="https://avatars.githubusercontent.com/u/118431096?s=200&v=4" height="70px" width="70px" alt="galaxies-dev" />
|
|
61
61
|
</a>
|
|
62
|
-
<a href="https://github.com/biw">
|
|
63
|
-
<img src="https://avatars.githubusercontent.com/u/6139501?v=4" height="70px" width="70px" alt="biw" />
|
|
64
|
-
</a>
|
|
65
62
|
<a href="https://github.com/ryanlanciaux">
|
|
66
63
|
<img src="https://avatars.githubusercontent.com/u/85041?v=4" height="70px" width="70px" alt="ryanlanciaux" />
|
|
67
64
|
</a>
|
|
@@ -74,6 +71,12 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
|
|
|
74
71
|
<a href="https://github.com/andkindness">
|
|
75
72
|
<img src="https://avatars.githubusercontent.com/u/143941782?v=4" height="70px" width="70px" alt="andkindness" />
|
|
76
73
|
</a>
|
|
74
|
+
<a href="https://github.com/AdiRishi">
|
|
75
|
+
<img src="https://avatars.githubusercontent.com/u/8351234?v=4" height="70px" width="70px" alt="AdiRishi" />
|
|
76
|
+
</a>
|
|
77
|
+
<a href="https://github.com/cybercarrot">
|
|
78
|
+
<img src="https://avatars.githubusercontent.com/u/6837094?v=4" height="70px" width="70px" alt="cybercarrot" />
|
|
79
|
+
</a>
|
|
77
80
|
|
|
78
81
|
|
|
79
82
|
## Past sponsors
|
|
@@ -147,6 +150,9 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
|
|
|
147
150
|
<a href="https://github.com/oliverloops">
|
|
148
151
|
<img src="https://avatars.githubusercontent.com/u/33361399?v=4" height="60px" width="60px" alt="oliverloops" />
|
|
149
152
|
</a>
|
|
153
|
+
<a href="https://github.com/biw">
|
|
154
|
+
<img src="https://avatars.githubusercontent.com/u/6139501?v=4" height="60px" width="60px" alt="biw" />
|
|
155
|
+
</a>
|
|
150
156
|
|
|
151
157
|
## Sponsor my work
|
|
152
158
|
|
|
@@ -11,8 +11,7 @@ fun Dimensions.isEqualTo(other: Dimensions): Boolean {
|
|
|
11
11
|
|
|
12
12
|
fun Insets.isEqualTo(other: Insets): Boolean {
|
|
13
13
|
return this.top == other.top && this.bottom == other.bottom &&
|
|
14
|
-
this.left == other.left && this.right == other.right
|
|
15
|
-
this.ime == other.ime
|
|
14
|
+
this.left == other.left && this.right == other.right
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
fun NativePlatformAndroid.diffMiniRuntimes(lhs: UnistylesNativeMiniRuntime, rhs: UnistylesNativeMiniRuntime): Array<UnistyleDependency> {
|
|
@@ -67,6 +67,8 @@ class NativePlatformInsets(
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
fun setInsets(insetsCompat: WindowInsetsCompat, window: Window, animatedBottomInsets: Double?, skipUpdate: Boolean = false) {
|
|
70
|
+
val previousInsets = this._insets
|
|
71
|
+
|
|
70
72
|
// below Android 11, we need to use window flags to detect status bar visibility
|
|
71
73
|
val isStatusBarVisible = when(Build.VERSION.SDK_INT) {
|
|
72
74
|
in 30..Int.MAX_VALUE -> {
|
|
@@ -91,36 +93,59 @@ class NativePlatformInsets(
|
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
val insets = insetsCompat.getInsets(WindowInsetsCompat.Type.systemBars() or WindowInsetsCompat.Type.displayCutout())
|
|
96
|
+
val imeInsetValue = insetsCompat.getInsets(WindowInsetsCompat.Type.ime()).bottom
|
|
97
|
+
|
|
98
|
+
// When a keyboard management library (e.g. react-native-keyboard-controller) is active,
|
|
99
|
+
// systemBars().bottom can get polluted with the IME height on certain interactions
|
|
100
|
+
// (like double-tapping to select text). Detect this by checking if systemBars bottom
|
|
101
|
+
// is >= IME bottom (normally systemBars bottom is just the nav bar, much smaller than IME).
|
|
102
|
+
// Fall back to getInsetsIgnoringVisibility which returns stable nav bar values.
|
|
103
|
+
val bottomInset = if (imeInsetValue > 0 && insets.bottom >= imeInsetValue) {
|
|
104
|
+
insetsCompat.getInsetsIgnoringVisibility(
|
|
105
|
+
WindowInsetsCompat.Type.navigationBars() or WindowInsetsCompat.Type.displayCutout()
|
|
106
|
+
).bottom
|
|
107
|
+
} else {
|
|
108
|
+
insets.bottom
|
|
109
|
+
}
|
|
94
110
|
|
|
95
111
|
// Android 10 and below - set bottom insets to 0 while keyboard is visible and use default bottom insets otherwise
|
|
96
112
|
// Android 11 and above - animate bottom insets while keyboard is appearing and disappearing
|
|
97
113
|
val imeInsets = when {
|
|
98
114
|
animatedBottomInsets != null && Build.VERSION.SDK_INT >= 30 -> animatedBottomInsets
|
|
99
115
|
Build.VERSION.SDK_INT < 30 -> {
|
|
100
|
-
val nextBottomInset =
|
|
116
|
+
val nextBottomInset = imeInsetValue - bottomInset
|
|
101
117
|
maxOf(nextBottomInset, 0).toDouble()
|
|
102
118
|
}
|
|
103
119
|
else -> 0.0
|
|
104
120
|
}
|
|
105
121
|
|
|
106
|
-
val shouldEmitImeEvent = Build.VERSION.SDK_INT < 30 && imeInsets != this._insets.ime || animatedBottomInsets != null && Build.VERSION.SDK_INT >= 30
|
|
107
|
-
|
|
108
122
|
this._insets = Insets(
|
|
109
123
|
statusBarTopInset.toDouble(),
|
|
110
|
-
|
|
124
|
+
bottomInset.toDouble(),
|
|
111
125
|
insets.left.toDouble(),
|
|
112
126
|
insets.right.toDouble(),
|
|
113
127
|
imeInsets
|
|
114
128
|
)
|
|
129
|
+
val didInsetsChange = !previousInsets.isEqualTo(this._insets)
|
|
130
|
+
val didImeChange = previousInsets.ime != this._insets.ime
|
|
131
|
+
val shouldEmitImeEvent =
|
|
132
|
+
didImeChange && (
|
|
133
|
+
Build.VERSION.SDK_INT < 30 ||
|
|
134
|
+
animatedBottomInsets != null && Build.VERSION.SDK_INT >= 30
|
|
135
|
+
)
|
|
115
136
|
|
|
116
137
|
if (skipUpdate) {
|
|
117
138
|
return
|
|
118
139
|
}
|
|
119
140
|
|
|
120
|
-
|
|
141
|
+
if (didInsetsChange) {
|
|
142
|
+
this@NativePlatformInsets.onConfigChange()
|
|
143
|
+
}
|
|
121
144
|
|
|
122
145
|
if (shouldEmitImeEvent) {
|
|
123
|
-
this@NativePlatformInsets.emitImeEvent(
|
|
146
|
+
this@NativePlatformInsets.emitImeEvent(
|
|
147
|
+
this.getMiniRuntime().copy(insets = this.getInsets())
|
|
148
|
+
)
|
|
124
149
|
}
|
|
125
150
|
}
|
|
126
151
|
|
|
@@ -148,7 +173,9 @@ class NativePlatformInsets(
|
|
|
148
173
|
return insets
|
|
149
174
|
}
|
|
150
175
|
|
|
151
|
-
runningAnimations.firstOrNull
|
|
176
|
+
runningAnimations.firstOrNull { animation ->
|
|
177
|
+
animation.typeMask and WindowInsetsCompat.Type.ime() != 0
|
|
178
|
+
}?.let {
|
|
152
179
|
val bottomInset = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom.toDouble() - this@NativePlatformInsets._insets.bottom
|
|
153
180
|
val nextBottomInset = if (bottomInset < 0) {
|
|
154
181
|
0.0
|
package/cxx/parser/Parser.cpp
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
#include "Parser.h"
|
|
2
2
|
#include "UnistyleWrapper.h"
|
|
3
|
+
#include <iomanip>
|
|
4
|
+
#include <sstream>
|
|
5
|
+
#include <react/renderer/css/CSSFilter.h>
|
|
6
|
+
#include <react/renderer/css/CSSValueParser.h>
|
|
3
7
|
|
|
4
8
|
using namespace margelo::nitro::unistyles;
|
|
5
9
|
using namespace facebook;
|
|
@@ -7,6 +11,59 @@ using namespace facebook::react;
|
|
|
7
11
|
|
|
8
12
|
using Variants = std::vector<std::pair<std::string, std::string>>;
|
|
9
13
|
|
|
14
|
+
namespace {
|
|
15
|
+
|
|
16
|
+
bool isSupportedLength(const CSSLength& length) {
|
|
17
|
+
return length.unit == CSSLengthUnit::Px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
std::string cssColorToRgbaString(const CSSColor& color) {
|
|
21
|
+
std::ostringstream stream;
|
|
22
|
+
|
|
23
|
+
stream << "rgba("
|
|
24
|
+
<< static_cast<int>(color.r) << ", "
|
|
25
|
+
<< static_cast<int>(color.g) << ", "
|
|
26
|
+
<< static_cast<int>(color.b) << ", "
|
|
27
|
+
<< std::fixed << std::setprecision(3)
|
|
28
|
+
<< (static_cast<float>(color.a) / 255.0f)
|
|
29
|
+
<< ")";
|
|
30
|
+
|
|
31
|
+
return stream.str();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
std::optional<jsi::Object> parseDropShadowString(jsi::Runtime& rt, const std::string& dropShadowString) {
|
|
35
|
+
auto maybeParsedDropShadow = parseCSSProperty<CSSDropShadowFilter>(std::string("drop-shadow(") + dropShadowString + ")");
|
|
36
|
+
|
|
37
|
+
if (!std::holds_alternative<CSSDropShadowFilter>(maybeParsedDropShadow)) {
|
|
38
|
+
return std::nullopt;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
auto parsedDropShadow = std::get<CSSDropShadowFilter>(maybeParsedDropShadow);
|
|
42
|
+
|
|
43
|
+
if (
|
|
44
|
+
!isSupportedLength(parsedDropShadow.offsetX) ||
|
|
45
|
+
!isSupportedLength(parsedDropShadow.offsetY) ||
|
|
46
|
+
!isSupportedLength(parsedDropShadow.standardDeviation)
|
|
47
|
+
) {
|
|
48
|
+
return std::nullopt;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
jsi::Object shadowObject(rt);
|
|
52
|
+
|
|
53
|
+
shadowObject.setProperty(rt, "offsetX", parsedDropShadow.offsetX.value);
|
|
54
|
+
shadowObject.setProperty(rt, "offsetY", parsedDropShadow.offsetY.value);
|
|
55
|
+
shadowObject.setProperty(rt, "standardDeviation", parsedDropShadow.standardDeviation.value);
|
|
56
|
+
shadowObject.setProperty(
|
|
57
|
+
rt,
|
|
58
|
+
"color",
|
|
59
|
+
jsi::String::createFromUtf8(rt, cssColorToRgbaString(parsedDropShadow.color))
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
return shadowObject;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
10
67
|
// called only once while processing StyleSheet.create
|
|
11
68
|
void parser::Parser::buildUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet) {
|
|
12
69
|
jsi::Object unwrappedStyleSheet = this->unwrapStyleSheet(rt, styleSheet, std::nullopt);
|
|
@@ -651,8 +708,42 @@ jsi::Value parser::Parser::parseFilters(jsi::Runtime &rt, Unistyle::Shared unist
|
|
|
651
708
|
|
|
652
709
|
auto parsedResult = this->parseSecondLevel(rt, unistyle, value);
|
|
653
710
|
|
|
711
|
+
if (!parsedResult.isObject()) {
|
|
712
|
+
return;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
auto parsedResultObject = parsedResult.asObject(rt);
|
|
716
|
+
auto filterPropertyNames = parsedResultObject.getPropertyNames(rt);
|
|
717
|
+
auto filterPropertyCount = filterPropertyNames.size(rt);
|
|
718
|
+
|
|
719
|
+
for (size_t index = 0; index < filterPropertyCount; index++) {
|
|
720
|
+
auto filterName = filterPropertyNames.getValueAtIndex(rt, index).asString(rt).utf8(rt);
|
|
721
|
+
|
|
722
|
+
if (filterName != "dropShadow") {
|
|
723
|
+
continue;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
auto filterValue = parsedResultObject.getProperty(rt, filterName.c_str());
|
|
727
|
+
|
|
728
|
+
if (filterValue.isString()) {
|
|
729
|
+
auto maybeParsedDropShadow = parseDropShadowString(rt, filterValue.asString(rt).utf8(rt));
|
|
730
|
+
|
|
731
|
+
if (!maybeParsedDropShadow.has_value()) {
|
|
732
|
+
return;
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
auto dropShadowObject = std::move(maybeParsedDropShadow.value());
|
|
736
|
+
parsedResultObject.setProperty(rt, filterName.c_str(), std::move(dropShadowObject));
|
|
737
|
+
continue;
|
|
738
|
+
}
|
|
739
|
+
|
|
740
|
+
if (!filterValue.isObject()) {
|
|
741
|
+
return;
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
|
|
654
745
|
// take only one filter per object
|
|
655
|
-
jsi::Array propertyNames =
|
|
746
|
+
jsi::Array propertyNames = parsedResultObject.getPropertyNames(rt);
|
|
656
747
|
size_t length = propertyNames.size(rt);
|
|
657
748
|
|
|
658
749
|
// ignore no filters
|
|
@@ -660,7 +751,7 @@ jsi::Value parser::Parser::parseFilters(jsi::Runtime &rt, Unistyle::Shared unist
|
|
|
660
751
|
return;
|
|
661
752
|
}
|
|
662
753
|
|
|
663
|
-
parsedFilters.emplace_back(std::move(
|
|
754
|
+
parsedFilters.emplace_back(std::move(parsedResultObject));
|
|
664
755
|
});
|
|
665
756
|
|
|
666
757
|
// create jsi::Array result with correct filters
|
|
@@ -973,11 +1064,19 @@ folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, c
|
|
|
973
1064
|
unistyleData->parsedStyle.value(),
|
|
974
1065
|
[this, &rt, &state, &convertedStyles](const std::string& propertyName, jsi::Value& propertyValue) {
|
|
975
1066
|
if (this->isColor(propertyName)) {
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
1067
|
+
if (propertyValue.isString()) {
|
|
1068
|
+
convertedStyles.setProperty(
|
|
1069
|
+
rt,
|
|
1070
|
+
propertyName.c_str(),
|
|
1071
|
+
jsi::Value(state.parseColor(propertyValue))
|
|
1072
|
+
);
|
|
1073
|
+
} else {
|
|
1074
|
+
convertedStyles.setProperty(
|
|
1075
|
+
rt,
|
|
1076
|
+
propertyName.c_str(),
|
|
1077
|
+
propertyValue
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
981
1080
|
|
|
982
1081
|
return;
|
|
983
1082
|
}
|
|
@@ -1021,10 +1120,60 @@ folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, c
|
|
|
1021
1120
|
nestedValue.asObject(rt),
|
|
1022
1121
|
[this, &rt, &state, &obj](const std::string& nestedPropName, jsi::Value& nestedPropValue) {
|
|
1023
1122
|
if (this->isColor(nestedPropName)) {
|
|
1123
|
+
if (nestedPropValue.isString()) {
|
|
1124
|
+
obj.setProperty(
|
|
1125
|
+
rt,
|
|
1126
|
+
nestedPropName.c_str(),
|
|
1127
|
+
state.parseColor(nestedPropValue)
|
|
1128
|
+
);
|
|
1129
|
+
} else {
|
|
1130
|
+
obj.setProperty(
|
|
1131
|
+
rt,
|
|
1132
|
+
nestedPropName.c_str(),
|
|
1133
|
+
nestedPropValue
|
|
1134
|
+
);
|
|
1135
|
+
}
|
|
1136
|
+
} else if (nestedPropValue.isObject()) {
|
|
1137
|
+
auto nestedObj = nestedPropValue.asObject(rt);
|
|
1138
|
+
|
|
1139
|
+
if (nestedObj.isArray(rt) || nestedObj.isFunction(rt)) {
|
|
1140
|
+
obj.setProperty(
|
|
1141
|
+
rt,
|
|
1142
|
+
nestedPropName.c_str(),
|
|
1143
|
+
nestedPropValue
|
|
1144
|
+
);
|
|
1145
|
+
|
|
1146
|
+
return;
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
jsi::Object parsedNestedObj(rt);
|
|
1150
|
+
|
|
1151
|
+
helpers::enumerateJSIObject(
|
|
1152
|
+
rt,
|
|
1153
|
+
nestedObj,
|
|
1154
|
+
[this, &rt, &state, &parsedNestedObj](const std::string& secondLevelPropName, jsi::Value& secondLevelPropValue) {
|
|
1155
|
+
if (this->isColor(secondLevelPropName) && secondLevelPropValue.isString()) {
|
|
1156
|
+
parsedNestedObj.setProperty(
|
|
1157
|
+
rt,
|
|
1158
|
+
secondLevelPropName.c_str(),
|
|
1159
|
+
state.parseColor(secondLevelPropValue)
|
|
1160
|
+
);
|
|
1161
|
+
|
|
1162
|
+
return;
|
|
1163
|
+
}
|
|
1164
|
+
|
|
1165
|
+
parsedNestedObj.setProperty(
|
|
1166
|
+
rt,
|
|
1167
|
+
secondLevelPropName.c_str(),
|
|
1168
|
+
secondLevelPropValue
|
|
1169
|
+
);
|
|
1170
|
+
}
|
|
1171
|
+
);
|
|
1172
|
+
|
|
1024
1173
|
obj.setProperty(
|
|
1025
1174
|
rt,
|
|
1026
1175
|
nestedPropName.c_str(),
|
|
1027
|
-
|
|
1176
|
+
parsedNestedObj
|
|
1028
1177
|
);
|
|
1029
1178
|
} else {
|
|
1030
1179
|
obj.setProperty(
|
|
@@ -1042,11 +1191,15 @@ folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, c
|
|
|
1042
1191
|
}
|
|
1043
1192
|
|
|
1044
1193
|
if (this->isColor(propertyName)) {
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1194
|
+
if (nestedValue.isString()) {
|
|
1195
|
+
parsedArray.setValueAtIndex(
|
|
1196
|
+
rt,
|
|
1197
|
+
i,
|
|
1198
|
+
jsi::Value(state.parseColor(nestedValue))
|
|
1199
|
+
);
|
|
1200
|
+
} else {
|
|
1201
|
+
parsedArray.setValueAtIndex(rt, i, nestedValue);
|
|
1202
|
+
}
|
|
1050
1203
|
} else {
|
|
1051
1204
|
parsedArray.setValueAtIndex(rt, i, nestedValue);
|
|
1052
1205
|
}
|
|
@@ -36,6 +36,8 @@ const useProxifiedUnistyles = forcedTheme => {
|
|
|
36
36
|
const [theme, setTheme] = (0, _react.useState)(_specs.UnistylesRuntime.getTheme(scopedTheme));
|
|
37
37
|
const [_, runtimeChanged] = (0, _react.useReducer)(() => ({}), {});
|
|
38
38
|
const disposeRef = (0, _react.useRef)(undefined);
|
|
39
|
+
const syncedDependenciesSizeRef = (0, _react.useRef)(-1);
|
|
40
|
+
const syncedScopedThemeRef = (0, _react.useRef)(undefined);
|
|
39
41
|
const reinitListener = () => {
|
|
40
42
|
disposeRef.current?.();
|
|
41
43
|
disposeRef.current = (0, _listener.listener)({
|
|
@@ -55,9 +57,8 @@ const useProxifiedUnistyles = forcedTheme => {
|
|
|
55
57
|
});
|
|
56
58
|
};
|
|
57
59
|
(0, _react.useEffect)(() => {
|
|
58
|
-
reinitListener();
|
|
59
60
|
return () => disposeRef.current?.();
|
|
60
|
-
}, [
|
|
61
|
+
}, [disposeRef]);
|
|
61
62
|
const maybeNewScopedTheme = _specs.UnistylesShadowRegistry.getScopedTheme();
|
|
62
63
|
if (scopedTheme && maybeNewScopedTheme && scopedTheme !== maybeNewScopedTheme) {
|
|
63
64
|
setScopedTheme(maybeNewScopedTheme);
|
|
@@ -91,6 +92,16 @@ const useProxifiedUnistyles = forcedTheme => {
|
|
|
91
92
|
return target[prop];
|
|
92
93
|
}
|
|
93
94
|
});
|
|
95
|
+
(0, _react.useLayoutEffect)(() => {
|
|
96
|
+
const sameDeps = syncedDependenciesSizeRef.current === dependencies.size;
|
|
97
|
+
const sameScopedTheme = syncedScopedThemeRef.current === scopedTheme;
|
|
98
|
+
if (sameDeps && sameScopedTheme) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
syncedDependenciesSizeRef.current = dependencies.size;
|
|
102
|
+
syncedScopedThemeRef.current = scopedTheme;
|
|
103
|
+
reinitListener();
|
|
104
|
+
}, [proxifiedTheme, proxifiedRuntime, scopedTheme]);
|
|
94
105
|
return {
|
|
95
106
|
proxifiedTheme,
|
|
96
107
|
proxifiedRuntime,
|
|
@@ -102,6 +113,8 @@ const useProxifiedUnistyles = forcedTheme => {
|
|
|
102
113
|
if (dependenciesSize === dependencies.size) {
|
|
103
114
|
return;
|
|
104
115
|
}
|
|
116
|
+
syncedDependenciesSizeRef.current = dependencies.size;
|
|
117
|
+
syncedScopedThemeRef.current = scopedTheme;
|
|
105
118
|
reinitListener();
|
|
106
119
|
}
|
|
107
120
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","require","_specs","_NativePlatform","_listener","getMiniRuntime","UnistylesRuntime","miniRuntime","RTDependencyMap","breakpoint","UnistyleDependency","Breakpoints","colorScheme","ColorScheme","contentSizeCategory","ContentSizeCategory","hasAdaptiveThemes","AdaptiveThemes","insets","Insets","fontScale","FontScale","isLandscape","Orientation","isPortrait","navigationBar","NavigationBar","screen","Dimensions","statusBar","StatusBar","pixelRatio","PixelRatio","themeName","ThemeName","rtl","Rtl","useProxifiedUnistyles","forcedTheme","scopedTheme","setScopedTheme","useState","UnistylesShadowRegistry","getScopedTheme","dependencies","Set","theme","setTheme","getTheme","_","runtimeChanged","useReducer","disposeRef","useRef","undefined","reinitListener","current","listener","Array","from","updateTheme","updateRuntime","hasThemeNameChange","useEffect","
|
|
1
|
+
{"version":3,"names":["_react","require","_specs","_NativePlatform","_listener","getMiniRuntime","UnistylesRuntime","miniRuntime","RTDependencyMap","breakpoint","UnistyleDependency","Breakpoints","colorScheme","ColorScheme","contentSizeCategory","ContentSizeCategory","hasAdaptiveThemes","AdaptiveThemes","insets","Insets","fontScale","FontScale","isLandscape","Orientation","isPortrait","navigationBar","NavigationBar","screen","Dimensions","statusBar","StatusBar","pixelRatio","PixelRatio","themeName","ThemeName","rtl","Rtl","useProxifiedUnistyles","forcedTheme","scopedTheme","setScopedTheme","useState","UnistylesShadowRegistry","getScopedTheme","dependencies","Set","theme","setTheme","getTheme","_","runtimeChanged","useReducer","disposeRef","useRef","undefined","syncedDependenciesSizeRef","syncedScopedThemeRef","reinitListener","current","listener","Array","from","updateTheme","updateRuntime","hasThemeNameChange","useEffect","maybeNewScopedTheme","proxifiedTheme","Proxy","get","target","prop","add","Theme","proxifiedRuntime","Ime","useLayoutEffect","sameDeps","size","sameScopedTheme","addDependencies","newDependencies","dependenciesSize","forEach","dependency","exports"],"sourceRoot":"../../../../src","sources":["core/useProxifiedUnistyles/useProxifiedUnistyles.ts"],"mappings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tB,oBAAoB,CAACE,OAAO,GAAGnB,WAAW;IAE1CkB,cAAc,CAAC,CAAC;EACpB,CAAC,EAAE,CAACU,cAAc,EAAEO,gBAAgB,EAAEnC,WAAW,CAAC,CAAC;EAEnD,OAAO;IACH4B,cAAc;IACdO,gBAAgB;IAChBM,eAAe,EAAGC,eAA0C,IAAK;MAC7D,MAAMC,gBAAgB,GAAGtC,YAAY,CAACkC,IAAI;MAE1CG,eAAe,CAACE,OAAO,CAACC,UAAU,IAAI;QAClCxC,YAAY,CAAC4B,GAAG,CAACY,UAAU,CAAC;MAChC,CAAC,CAAC;MAEF,IAAIF,gBAAgB,KAAKtC,YAAY,CAACkC,IAAI,EAAE;QACxC;MACJ;MAEAvB,yBAAyB,CAACG,OAAO,GAAGd,YAAY,CAACkC,IAAI;MACrDtB,oBAAoB,CAACE,OAAO,GAAGnB,WAAW;MAC1CkB,cAAc,CAAC,CAAC;IACpB;EACJ,CAAC;AACL,CAAC;AAAA4B,OAAA,CAAAhD,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useReducer, useRef, useState } from 'react';
|
|
3
|
+
import { useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react';
|
|
4
4
|
import { UnistylesRuntime, UnistylesShadowRegistry } from '../../specs';
|
|
5
5
|
// It's imported that way because of circular dependency
|
|
6
6
|
import { UnistyleDependency } from '../../specs/NativePlatform';
|
|
@@ -31,6 +31,8 @@ export const useProxifiedUnistyles = forcedTheme => {
|
|
|
31
31
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme));
|
|
32
32
|
const [_, runtimeChanged] = useReducer(() => ({}), {});
|
|
33
33
|
const disposeRef = useRef(undefined);
|
|
34
|
+
const syncedDependenciesSizeRef = useRef(-1);
|
|
35
|
+
const syncedScopedThemeRef = useRef(undefined);
|
|
34
36
|
const reinitListener = () => {
|
|
35
37
|
disposeRef.current?.();
|
|
36
38
|
disposeRef.current = listener({
|
|
@@ -50,9 +52,8 @@ export const useProxifiedUnistyles = forcedTheme => {
|
|
|
50
52
|
});
|
|
51
53
|
};
|
|
52
54
|
useEffect(() => {
|
|
53
|
-
reinitListener();
|
|
54
55
|
return () => disposeRef.current?.();
|
|
55
|
-
}, [
|
|
56
|
+
}, [disposeRef]);
|
|
56
57
|
const maybeNewScopedTheme = UnistylesShadowRegistry.getScopedTheme();
|
|
57
58
|
if (scopedTheme && maybeNewScopedTheme && scopedTheme !== maybeNewScopedTheme) {
|
|
58
59
|
setScopedTheme(maybeNewScopedTheme);
|
|
@@ -86,6 +87,16 @@ export const useProxifiedUnistyles = forcedTheme => {
|
|
|
86
87
|
return target[prop];
|
|
87
88
|
}
|
|
88
89
|
});
|
|
90
|
+
useLayoutEffect(() => {
|
|
91
|
+
const sameDeps = syncedDependenciesSizeRef.current === dependencies.size;
|
|
92
|
+
const sameScopedTheme = syncedScopedThemeRef.current === scopedTheme;
|
|
93
|
+
if (sameDeps && sameScopedTheme) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
syncedDependenciesSizeRef.current = dependencies.size;
|
|
97
|
+
syncedScopedThemeRef.current = scopedTheme;
|
|
98
|
+
reinitListener();
|
|
99
|
+
}, [proxifiedTheme, proxifiedRuntime, scopedTheme]);
|
|
89
100
|
return {
|
|
90
101
|
proxifiedTheme,
|
|
91
102
|
proxifiedRuntime,
|
|
@@ -97,6 +108,8 @@ export const useProxifiedUnistyles = forcedTheme => {
|
|
|
97
108
|
if (dependenciesSize === dependencies.size) {
|
|
98
109
|
return;
|
|
99
110
|
}
|
|
111
|
+
syncedDependenciesSizeRef.current = dependencies.size;
|
|
112
|
+
syncedScopedThemeRef.current = scopedTheme;
|
|
100
113
|
reinitListener();
|
|
101
114
|
}
|
|
102
115
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useEffect","useReducer","useRef","useState","UnistylesRuntime","UnistylesShadowRegistry","UnistyleDependency","listener","getMiniRuntime","miniRuntime","RTDependencyMap","breakpoint","Breakpoints","colorScheme","ColorScheme","contentSizeCategory","ContentSizeCategory","hasAdaptiveThemes","AdaptiveThemes","insets","Insets","fontScale","FontScale","isLandscape","Orientation","isPortrait","navigationBar","NavigationBar","screen","Dimensions","statusBar","StatusBar","pixelRatio","PixelRatio","themeName","ThemeName","rtl","Rtl","useProxifiedUnistyles","forcedTheme","scopedTheme","setScopedTheme","getScopedTheme","dependencies","Set","theme","setTheme","getTheme","_","runtimeChanged","disposeRef","undefined","reinitListener","current","Array","from","updateTheme","updateRuntime","hasThemeNameChange","
|
|
1
|
+
{"version":3,"names":["useEffect","useLayoutEffect","useReducer","useRef","useState","UnistylesRuntime","UnistylesShadowRegistry","UnistyleDependency","listener","getMiniRuntime","miniRuntime","RTDependencyMap","breakpoint","Breakpoints","colorScheme","ColorScheme","contentSizeCategory","ContentSizeCategory","hasAdaptiveThemes","AdaptiveThemes","insets","Insets","fontScale","FontScale","isLandscape","Orientation","isPortrait","navigationBar","NavigationBar","screen","Dimensions","statusBar","StatusBar","pixelRatio","PixelRatio","themeName","ThemeName","rtl","Rtl","useProxifiedUnistyles","forcedTheme","scopedTheme","setScopedTheme","getScopedTheme","dependencies","Set","theme","setTheme","getTheme","_","runtimeChanged","disposeRef","undefined","syncedDependenciesSizeRef","syncedScopedThemeRef","reinitListener","current","Array","from","updateTheme","updateRuntime","hasThemeNameChange","maybeNewScopedTheme","proxifiedTheme","Proxy","get","target","prop","add","Theme","proxifiedRuntime","Ime","sameDeps","size","sameScopedTheme","addDependencies","newDependencies","dependenciesSize","forEach","dependency"],"sourceRoot":"../../../../src","sources":["core/useProxifiedUnistyles/useProxifiedUnistyles.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,UAAU,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAChF,SAAoCC,gBAAgB,EAAEC,uBAAuB,QAAQ,aAAa;AACl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,gBAAgB,EAAE7B,WAAW,CAAC,CAAC;EAEnD,OAAO;IACHsB,cAAc;IACdO,gBAAgB;IAChBK,eAAe,EAAGC,eAA0C,IAAK;MAC7D,MAAMC,gBAAgB,GAAGjC,YAAY,CAAC6B,IAAI;MAE1CG,eAAe,CAACE,OAAO,CAACC,UAAU,IAAI;QAClCnC,YAAY,CAACwB,GAAG,CAACW,UAAU,CAAC;MAChC,CAAC,CAAC;MAEF,IAAIF,gBAAgB,KAAKjC,YAAY,CAAC6B,IAAI,EAAE;QACxC;MACJ;MAEApB,yBAAyB,CAACG,OAAO,GAAGZ,YAAY,CAAC6B,IAAI;MACrDnB,oBAAoB,CAACE,OAAO,GAAGf,WAAW;MAC1Cc,cAAc,CAAC,CAAC;IACpB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useProxifiedUnistyles.d.ts","sourceRoot":"","sources":["../../../../../src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAA6C,MAAM,aAAa,CAAA;AAElG,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAyBjD,eAAO,MAAM,qBAAqB,GAAI,cAAc,cAAc;;;
|
|
1
|
+
{"version":3,"file":"useProxifiedUnistyles.d.ts","sourceRoot":"","sources":["../../../../../src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,oBAAoB,EAA6C,MAAM,aAAa,CAAA;AAElG,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AAC/D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAyBjD,eAAO,MAAM,qBAAqB,GAAI,cAAc,cAAc;;;uCA8FvB,KAAK,CAAC,kBAAkB,CAAC;CAgBnE,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-unistyles",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.24",
|
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "NODE_ENV=babel-test jest ./plugin",
|
|
@@ -146,11 +146,11 @@
|
|
|
146
146
|
"husky": "9.1.7",
|
|
147
147
|
"jest": "29.7.0",
|
|
148
148
|
"metro-react-native-babel-preset": "0.77.0",
|
|
149
|
-
"nitrogen": "0.33.
|
|
149
|
+
"nitrogen": "0.33.8",
|
|
150
150
|
"react": "19.1.0",
|
|
151
151
|
"react-native": "0.79.2",
|
|
152
152
|
"react-native-builder-bob": "0.40.10",
|
|
153
|
-
"react-native-nitro-modules": "0.33.
|
|
153
|
+
"react-native-nitro-modules": "0.33.8",
|
|
154
154
|
"react-native-reanimated": "3.17.5",
|
|
155
155
|
"react-native-web": "0.20.0",
|
|
156
156
|
"react-test-renderer": "19.1.0",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useReducer, useRef, useState } from 'react'
|
|
1
|
+
import { useEffect, useLayoutEffect, useReducer, useRef, useState } from 'react'
|
|
2
2
|
import { type UnistylesMiniRuntime, UnistylesRuntime, UnistylesShadowRegistry } from '../../specs'
|
|
3
3
|
// It's imported that way because of circular dependency
|
|
4
4
|
import { UnistyleDependency } from '../../specs/NativePlatform'
|
|
@@ -33,6 +33,8 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
33
33
|
const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme))
|
|
34
34
|
const [_, runtimeChanged] = useReducer(() => ({}), {})
|
|
35
35
|
const disposeRef = useRef<VoidFunction>(undefined)
|
|
36
|
+
const syncedDependenciesSizeRef = useRef(-1)
|
|
37
|
+
const syncedScopedThemeRef = useRef<UnistylesTheme | undefined>(undefined)
|
|
36
38
|
|
|
37
39
|
const reinitListener = () => {
|
|
38
40
|
disposeRef.current?.()
|
|
@@ -56,11 +58,8 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
useEffect(() => {
|
|
59
|
-
reinitListener()
|
|
60
|
-
|
|
61
61
|
return () => disposeRef.current?.()
|
|
62
|
-
}, [
|
|
63
|
-
|
|
62
|
+
}, [disposeRef])
|
|
64
63
|
|
|
65
64
|
const maybeNewScopedTheme = UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
|
|
66
65
|
|
|
@@ -105,6 +104,20 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
105
104
|
}
|
|
106
105
|
})
|
|
107
106
|
|
|
107
|
+
useLayoutEffect(() => {
|
|
108
|
+
const sameDeps = syncedDependenciesSizeRef.current === dependencies.size
|
|
109
|
+
const sameScopedTheme = syncedScopedThemeRef.current === scopedTheme
|
|
110
|
+
|
|
111
|
+
if (sameDeps && sameScopedTheme) {
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
syncedDependenciesSizeRef.current = dependencies.size
|
|
116
|
+
syncedScopedThemeRef.current = scopedTheme
|
|
117
|
+
|
|
118
|
+
reinitListener()
|
|
119
|
+
}, [proxifiedTheme, proxifiedRuntime, scopedTheme])
|
|
120
|
+
|
|
108
121
|
return {
|
|
109
122
|
proxifiedTheme,
|
|
110
123
|
proxifiedRuntime,
|
|
@@ -119,6 +132,8 @@ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
|
|
|
119
132
|
return
|
|
120
133
|
}
|
|
121
134
|
|
|
135
|
+
syncedDependenciesSizeRef.current = dependencies.size
|
|
136
|
+
syncedScopedThemeRef.current = scopedTheme
|
|
122
137
|
reinitListener()
|
|
123
138
|
}
|
|
124
139
|
}
|