react-native-unistyles 3.0.0-nightly-20250216 → 3.0.0-nightly-20250219

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.
@@ -24,6 +24,7 @@ class NativePlatformInsets(
24
24
  private val getMiniRuntime: () -> UnistylesNativeMiniRuntime,
25
25
  private val diffMiniRuntime: () -> Array<UnistyleDependency>
26
26
  ) {
27
+ private var _shouldListenToImeEvents = false
27
28
  private val _imeListeners: MutableList<CxxImeListener> = mutableListOf()
28
29
  private var _insets: Insets = Insets(0.0, 0.0, 0.0, 0.0, 0.0)
29
30
 
@@ -113,6 +114,8 @@ class NativePlatformInsets(
113
114
  }
114
115
 
115
116
  fun startInsetsListener() {
117
+ _shouldListenToImeEvents = true
118
+
116
119
  reactContext.currentActivity?.let { activity ->
117
120
  activity.findViewById<View>(android.R.id.content)?.let { mainView ->
118
121
  ViewCompat.setOnApplyWindowInsetsListener(mainView) { _, insets ->
@@ -130,6 +133,10 @@ class NativePlatformInsets(
130
133
  insets: WindowInsetsCompat,
131
134
  runningAnimations: List<WindowInsetsAnimationCompat>
132
135
  ): WindowInsetsCompat {
136
+ if (!_shouldListenToImeEvents) {
137
+ return insets
138
+ }
139
+
133
140
  runningAnimations.firstOrNull()?.let {
134
141
  val bottomInset = insets.getInsets(WindowInsetsCompat.Type.ime()).bottom.toDouble() - this@NativePlatformInsets._insets.bottom
135
142
  val nextBottomInset = if (bottomInset < 0) {
@@ -160,9 +167,10 @@ class NativePlatformInsets(
160
167
  reactContext.currentActivity?.let { activity ->
161
168
  activity.window?.decorView?.let { view ->
162
169
  ViewCompat.setOnApplyWindowInsetsListener(view, null)
163
- ViewCompat.setWindowInsetsAnimationCallback(view, null)
164
170
  }
165
171
  }
172
+
173
+ _shouldListenToImeEvents = false
166
174
  }
167
175
 
168
176
  fun addImeListener(listener: CxxImeListener) {
@@ -225,4 +225,89 @@ inline static jsi::Array dependenciesToJSIArray(jsi::Runtime& rt, const std::vec
225
225
  return result;
226
226
  }
227
227
 
228
+ inline void debugPrintJSIObject(jsi::Runtime& rt, std::string& name, jsi::Object& obj) {
229
+ auto console = rt.global().getPropertyAsObject(rt, "console");
230
+ auto log = console.getPropertyAsFunction(rt, "log");
231
+ auto parser = [&](const std::string& key, jsi::Value& value){
232
+ if (value.isBool()) {
233
+ std::string output = key + ": " + (value.getBool() ? "true" : "false");
234
+ log.call(rt, output);
235
+
236
+ return;
237
+ }
238
+
239
+ if (value.isNumber()) {
240
+ std::string output = key + ": " + std::to_string(value.getNumber());
241
+ log.call(rt, output);
242
+
243
+ return;
244
+ }
245
+
246
+ if (value.isString()) {
247
+ std::string output = key + ": " + value.getString(rt).utf8(rt);
248
+ log.call(rt, output);
249
+
250
+ return;
251
+ }
252
+
253
+ if (value.isUndefined()) {
254
+ std::string output = key + ": undefined";
255
+ log.call(rt, output);
256
+
257
+ return;
258
+ }
259
+
260
+ if (value.isNull()) {
261
+ std::string output = key + ": null";
262
+ log.call(rt, output);
263
+
264
+ return;
265
+ }
266
+ };
267
+
268
+ log.call(rt, "===" + name + "===");
269
+
270
+ enumerateJSIObject(rt, obj, [&](const std::string& key, jsi::Value& value){
271
+ if (value.isObject()) {
272
+ if (value.asObject(rt).isArray(rt)) {
273
+ iterateJSIArray(rt, value.asObject(rt).asArray(rt), [&](size_t i, jsi::Value& nestedValue){
274
+ std::string printableKey = key + ": Array[" + std::to_string(i) + "]";
275
+
276
+ log.call(rt, printableKey);
277
+
278
+ if (nestedValue.isObject()) {
279
+ enumerateJSIObject(rt, nestedValue.asObject(rt), [&](const std::string& nestedKey, jsi::Value& nestedValue){
280
+ parser(nestedKey, nestedValue);
281
+ });
282
+ } else {
283
+ parser(printableKey, nestedValue);
284
+ }
285
+
286
+ std::string endKey = key + ": Array[end]";
287
+
288
+ log.call(rt, endKey);
289
+ });
290
+ }
291
+
292
+ if (value.asObject(rt).isFunction(rt)) {
293
+ std::string output = key + ": [Function]";
294
+
295
+ log.call(rt, output);
296
+
297
+ return;
298
+ }
299
+
300
+ enumerateJSIObject(rt, value.asObject(rt), [&](const std::string& nestedKey, jsi::Value& nestedValue){
301
+ parser(nestedKey, nestedValue);
302
+ });
303
+
304
+ return;
305
+ }
306
+
307
+ parser(key, value);
308
+ });
309
+
310
+ log.call(rt, "===/" + name + "===");
311
+ }
312
+
228
313
  }
@@ -83,11 +83,6 @@ jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisVa
83
83
  parser.rebuildUnistyleWithScopedTheme(rt, parsedStyleSheet, unistyleData);
84
84
  }
85
85
 
86
- // for exotic unistyles, do nothing
87
- if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY) {
88
- unistyleData->parsedStyle = std::make_optional<jsi::Object>(jsi::Value(rt, unistyle->rawValue).asObject(rt));
89
- }
90
-
91
86
  unistylesData.emplace_back(unistyleData);
92
87
  }
93
88
 
@@ -908,7 +908,7 @@ folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, c
908
908
  for (const auto& unistyleData : unistyles) {
909
909
  // this can happen for exotic stylesheets
910
910
  if (!unistyleData->parsedStyle.has_value()) {
911
- return nullptr;
911
+ continue;
912
912
  }
913
913
 
914
914
  helpers::enumerateJSIObject(rt, unistyleData->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
@@ -916,7 +916,49 @@ folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, c
916
916
  return convertedStyles.setProperty(rt, propertyName.c_str(), jsi::Value(state.parseColor(propertyValue)));
917
917
  }
918
918
 
919
- convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
919
+ if (!propertyValue.isObject()) {
920
+ return convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
921
+ }
922
+
923
+ auto objValue = propertyValue.asObject(rt);
924
+
925
+ if (!objValue.isArray(rt)) {
926
+ return convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
927
+ }
928
+
929
+ // parse nested arrays like boxShadow
930
+ auto arrValue = objValue.asArray(rt);
931
+ auto parsedArray = jsi::Array(rt, arrValue.length(rt));
932
+
933
+ helpers::iterateJSIArray(rt, arrValue, [&](size_t i, jsi::Value& nestedValue){
934
+ if (nestedValue.isObject()) {
935
+ jsi::Object obj = jsi::Object(rt);
936
+
937
+ helpers::enumerateJSIObject(rt, nestedValue.asObject(rt), [&](const std::string& propertyName, jsi::Value& propertyValue){
938
+ if (this->isColor(propertyName)) {
939
+ obj.setProperty(rt, propertyName.c_str(), state.parseColor(propertyValue));
940
+
941
+ return;
942
+ }
943
+
944
+ obj.setProperty(rt, propertyName.c_str(), propertyValue);
945
+ });
946
+
947
+ parsedArray.setValueAtIndex(rt, i, std::move(obj));
948
+
949
+ return;
950
+ }
951
+
952
+ if (this->isColor(propertyName)) {
953
+ parsedArray.setValueAtIndex(rt, i, jsi::Value(state.parseColor(nestedValue)));
954
+
955
+ return;
956
+ }
957
+
958
+ parsedArray.setValueAtIndex(rt, i, nestedValue);
959
+ });
960
+
961
+ return convertedStyles.setProperty(rt, propertyName.c_str(), parsedArray);
920
962
  });
921
963
  }
922
964
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-nightly-20250216",
3
+ "version": "3.0.0-nightly-20250219",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",