react-native-unistyles 3.0.14 → 3.0.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.
Files changed (61) hide show
  1. package/README.md +2 -2
  2. package/cxx/common/Helpers.h +11 -2
  3. package/cxx/common/UnistylesConstants.h +1 -0
  4. package/cxx/hybridObjects/HybridStatusBar.cpp +1 -1
  5. package/cxx/hybridObjects/HybridStatusBar.h +1 -1
  6. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +1 -1
  7. package/cxx/hybridObjects/HybridUnistylesRuntime.h +1 -1
  8. package/cxx/parser/Parser.cpp +3 -3
  9. package/lib/commonjs/mocks.js +1 -0
  10. package/lib/commonjs/mocks.js.map +1 -1
  11. package/lib/commonjs/specs/StatusBar/index.js +1 -2
  12. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  13. package/lib/commonjs/specs/UnistylesRuntime/index.js +3 -0
  14. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  15. package/lib/commonjs/web/state.js +4 -6
  16. package/lib/commonjs/web/state.js.map +1 -1
  17. package/lib/module/mocks.js +1 -0
  18. package/lib/module/mocks.js.map +1 -1
  19. package/lib/module/specs/StatusBar/index.js +1 -2
  20. package/lib/module/specs/StatusBar/index.js.map +1 -1
  21. package/lib/module/specs/UnistylesRuntime/index.js +4 -1
  22. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  23. package/lib/module/web/state.js +4 -6
  24. package/lib/module/web/state.js.map +1 -1
  25. package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts +1 -1
  26. package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts.map +1 -1
  27. package/lib/typescript/src/specs/StatusBar/index.d.ts +1 -2
  28. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  29. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
  30. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  31. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +2 -1
  32. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  33. package/lib/typescript/src/web/state.d.ts.map +1 -1
  34. package/nitrogen/generated/android/c++/JDimensions.hpp +5 -1
  35. package/nitrogen/generated/android/c++/JInsets.hpp +5 -1
  36. package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +5 -1
  37. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +16 -9
  38. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +0 -1
  39. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +0 -1
  40. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +2 -2
  41. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +25 -18
  42. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +43 -36
  43. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +1 -1
  44. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +5 -7
  45. package/nitrogen/generated/ios/swift/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.swift +1 -5
  46. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +7 -3
  47. package/nitrogen/generated/shared/c++/Dimensions.hpp +8 -0
  48. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -1
  49. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
  50. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.cpp +1 -1
  51. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
  52. package/nitrogen/generated/shared/c++/Insets.hpp +8 -0
  53. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +8 -0
  54. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +8 -0
  55. package/package.json +3 -3
  56. package/src/mocks.ts +1 -0
  57. package/src/specs/StatusBar/UnistylesStatusBar.nitro.ts +1 -1
  58. package/src/specs/StatusBar/index.ts +3 -5
  59. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
  60. package/src/specs/UnistylesRuntime/index.ts +7 -1
  61. package/src/web/state.ts +5 -8
@@ -9,7 +9,6 @@ package com.margelo.nitro.unistyles
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
12
 
14
13
 
15
14
  /**
@@ -17,16 +16,24 @@ import com.margelo.nitro.core.*
17
16
  */
18
17
  @DoNotStrip
19
18
  @Keep
20
- data class Dimensions
19
+ data class Dimensions(
21
20
  @DoNotStrip
22
21
  @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val width: Double,
22
+ val width: Double,
23
+ @DoNotStrip
24
+ @Keep
25
+ val height: Double
26
+ ) {
27
+ private companion object {
28
+ /**
29
+ * Constructor called from C++
30
+ */
27
31
  @DoNotStrip
28
32
  @Keep
29
- val height: Double
30
- ) {
31
- /* main constructor */
33
+ @Suppress("unused")
34
+ @JvmStatic
35
+ private fun fromCpp(width: Double, height: Double): Dimensions {
36
+ return Dimensions(width, height)
37
+ }
38
+ }
32
39
  }
@@ -10,7 +10,6 @@ package com.margelo.nitro.unistyles
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
14
13
  import dalvik.annotation.optimization.FastNative
15
14
 
16
15
 
@@ -10,7 +10,6 @@ package com.margelo.nitro.unistyles
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
14
13
  import dalvik.annotation.optimization.FastNative
15
14
 
16
15
 
@@ -10,7 +10,7 @@ package com.margelo.nitro.unistyles
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
- import com.margelo.nitro.core.*
13
+ import com.margelo.nitro.core.HybridObject
14
14
 
15
15
  /**
16
16
  * A Kotlin class representing the NativePlatform HybridObject.
@@ -125,6 +125,6 @@ abstract class HybridNativePlatformSpec: HybridObject() {
125
125
  private external fun initHybrid(): HybridData
126
126
 
127
127
  companion object {
128
- private const val TAG = "HybridNativePlatformSpec"
128
+ protected const val TAG = "HybridNativePlatformSpec"
129
129
  }
130
130
  }
@@ -9,7 +9,6 @@ package com.margelo.nitro.unistyles
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
12
 
14
13
 
15
14
  /**
@@ -17,25 +16,33 @@ import com.margelo.nitro.core.*
17
16
  */
18
17
  @DoNotStrip
19
18
  @Keep
20
- data class Insets
19
+ data class Insets(
21
20
  @DoNotStrip
22
21
  @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val top: Double,
27
- @DoNotStrip
28
- @Keep
29
- val bottom: Double,
30
- @DoNotStrip
31
- @Keep
32
- val left: Double,
33
- @DoNotStrip
34
- @Keep
35
- val right: Double,
22
+ val top: Double,
23
+ @DoNotStrip
24
+ @Keep
25
+ val bottom: Double,
26
+ @DoNotStrip
27
+ @Keep
28
+ val left: Double,
29
+ @DoNotStrip
30
+ @Keep
31
+ val right: Double,
32
+ @DoNotStrip
33
+ @Keep
34
+ val ime: Double
35
+ ) {
36
+ private companion object {
37
+ /**
38
+ * Constructor called from C++
39
+ */
36
40
  @DoNotStrip
37
41
  @Keep
38
- val ime: Double
39
- ) {
40
- /* main constructor */
42
+ @Suppress("unused")
43
+ @JvmStatic
44
+ private fun fromCpp(top: Double, bottom: Double, left: Double, right: Double, ime: Double): Insets {
45
+ return Insets(top, bottom, left, right, ime)
46
+ }
47
+ }
41
48
  }
@@ -9,7 +9,6 @@ package com.margelo.nitro.unistyles
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
- import com.margelo.nitro.core.*
13
12
 
14
13
 
15
14
  /**
@@ -17,43 +16,51 @@ import com.margelo.nitro.core.*
17
16
  */
18
17
  @DoNotStrip
19
18
  @Keep
20
- data class UnistylesNativeMiniRuntime
19
+ data class UnistylesNativeMiniRuntime(
21
20
  @DoNotStrip
22
21
  @Keep
23
- constructor(
24
- @DoNotStrip
25
- @Keep
26
- val colorScheme: ColorScheme,
27
- @DoNotStrip
28
- @Keep
29
- val screen: Dimensions,
30
- @DoNotStrip
31
- @Keep
32
- val contentSizeCategory: String,
33
- @DoNotStrip
34
- @Keep
35
- val insets: Insets,
36
- @DoNotStrip
37
- @Keep
38
- val pixelRatio: Double,
39
- @DoNotStrip
40
- @Keep
41
- val fontScale: Double,
42
- @DoNotStrip
43
- @Keep
44
- val rtl: Boolean,
45
- @DoNotStrip
46
- @Keep
47
- val statusBar: Dimensions,
48
- @DoNotStrip
49
- @Keep
50
- val navigationBar: Dimensions,
51
- @DoNotStrip
52
- @Keep
53
- val isPortrait: Boolean,
22
+ val colorScheme: ColorScheme,
23
+ @DoNotStrip
24
+ @Keep
25
+ val screen: Dimensions,
26
+ @DoNotStrip
27
+ @Keep
28
+ val contentSizeCategory: String,
29
+ @DoNotStrip
30
+ @Keep
31
+ val insets: Insets,
32
+ @DoNotStrip
33
+ @Keep
34
+ val pixelRatio: Double,
35
+ @DoNotStrip
36
+ @Keep
37
+ val fontScale: Double,
38
+ @DoNotStrip
39
+ @Keep
40
+ val rtl: Boolean,
41
+ @DoNotStrip
42
+ @Keep
43
+ val statusBar: Dimensions,
44
+ @DoNotStrip
45
+ @Keep
46
+ val navigationBar: Dimensions,
47
+ @DoNotStrip
48
+ @Keep
49
+ val isPortrait: Boolean,
50
+ @DoNotStrip
51
+ @Keep
52
+ val isLandscape: Boolean
53
+ ) {
54
+ private companion object {
55
+ /**
56
+ * Constructor called from C++
57
+ */
54
58
  @DoNotStrip
55
59
  @Keep
56
- val isLandscape: Boolean
57
- ) {
58
- /* main constructor */
60
+ @Suppress("unused")
61
+ @JvmStatic
62
+ private fun fromCpp(colorScheme: ColorScheme, screen: Dimensions, contentSizeCategory: String, insets: Insets, pixelRatio: Double, fontScale: Double, rtl: Boolean, statusBar: Dimensions, navigationBar: Dimensions, isPortrait: Boolean, isLandscape: Boolean): UnistylesNativeMiniRuntime {
63
+ return UnistylesNativeMiniRuntime(colorScheme, screen, contentSizeCategory, insets, pixelRatio, fontScale, rtl, statusBar, navigationBar, isPortrait, isLandscape)
64
+ }
65
+ }
59
66
  }
@@ -34,7 +34,7 @@ namespace margelo::nitro::unistyles::bridge::swift {
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* NON_NULL get_std__shared_ptr_HybridNativePlatformSpec_(std__shared_ptr_HybridNativePlatformSpec_ cppType) noexcept {
37
+ void* NON_NULL 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]] {
@@ -35,7 +35,6 @@ namespace Unistyles { class HybridNativePlatformSpec_cxx; }
35
35
  #include "Orientation.hpp"
36
36
  #include "UnistyleDependency.hpp"
37
37
  #include "UnistylesNativeMiniRuntime.hpp"
38
- #include <NitroModules/FastVectorCopy.hpp>
39
38
  #include <NitroModules/Result.hpp>
40
39
  #include <exception>
41
40
  #include <functional>
@@ -54,11 +53,10 @@ namespace margelo::nitro::unistyles::bridge::swift {
54
53
  * Specialized version of `std::vector<UnistyleDependency>`.
55
54
  */
56
55
  using std__vector_UnistyleDependency_ = std::vector<UnistyleDependency>;
57
- inline std::vector<UnistyleDependency> copy_std__vector_UnistyleDependency_(const UnistyleDependency* CONTIGUOUS_MEMORY NON_NULL data, size_t size) noexcept {
58
- return margelo::nitro::FastVectorCopy<UnistyleDependency>(data, size);
59
- }
60
- inline const UnistyleDependency* CONTIGUOUS_MEMORY NON_NULL get_data_std__vector_UnistyleDependency_(const std::vector<UnistyleDependency>& vector) noexcept {
61
- return vector.data();
56
+ inline std::vector<UnistyleDependency> create_std__vector_UnistyleDependency_(size_t size) noexcept {
57
+ std::vector<UnistyleDependency> vector;
58
+ vector.reserve(size);
59
+ return vector;
62
60
  }
63
61
 
64
62
  // pragma MARK: std::function<void(const std::vector<UnistyleDependency>& /* dependencies */, const UnistylesNativeMiniRuntime& /* miniRuntime */)>
@@ -111,7 +109,7 @@ namespace margelo::nitro::unistyles::bridge::swift {
111
109
  */
112
110
  using std__shared_ptr_HybridNativePlatformSpec_ = std::shared_ptr<HybridNativePlatformSpec>;
113
111
  std::shared_ptr<HybridNativePlatformSpec> create_std__shared_ptr_HybridNativePlatformSpec_(void* NON_NULL swiftUnsafePointer) noexcept;
114
- void* NON_NULL get_std__shared_ptr_HybridNativePlatformSpec_(std__shared_ptr_HybridNativePlatformSpec_ cppType) noexcept;
112
+ void* NON_NULL get_std__shared_ptr_HybridNativePlatformSpec_(std__shared_ptr_HybridNativePlatformSpec_ cppType);
115
113
 
116
114
  // pragma MARK: std::weak_ptr<HybridNativePlatformSpec>
117
115
  using std__weak_ptr_HybridNativePlatformSpec_ = std::weak_ptr<HybridNativePlatformSpec>;
@@ -23,11 +23,7 @@ public final class Func_void_std__vector_UnistyleDependency__UnistylesNativeMini
23
23
 
24
24
  @inline(__always)
25
25
  public func call(dependencies: bridge.std__vector_UnistyleDependency_, miniRuntime: UnistylesNativeMiniRuntime) -> Void {
26
- self.closure({ () -> [UnistyleDependency] in
27
- let __data = bridge.get_data_std__vector_UnistyleDependency_(dependencies)
28
- let __size = dependencies.size()
29
- return Array(UnsafeBufferPointer(start: __data, count: __size))
30
- }(), miniRuntime)
26
+ self.closure(dependencies.map({ __item in __item }), miniRuntime)
31
27
  }
32
28
 
33
29
  /**
@@ -291,9 +291,13 @@ open class HybridNativePlatformSpec_cxx {
291
291
  try self.__implementation.registerPlatformListener(callback: { () -> ([UnistyleDependency], UnistylesNativeMiniRuntime) -> Void in
292
292
  let __wrappedFunction = bridge.wrap_Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime(callback)
293
293
  return { (__dependencies: [UnistyleDependency], __miniRuntime: UnistylesNativeMiniRuntime) -> Void in
294
- __wrappedFunction.call(__dependencies.withUnsafeBufferPointer { __pointer -> bridge.std__vector_UnistyleDependency_ in
295
- return bridge.copy_std__vector_UnistyleDependency_(__pointer.baseAddress!, __dependencies.count)
296
- }, __miniRuntime)
294
+ __wrappedFunction.call({ () -> bridge.std__vector_UnistyleDependency_ in
295
+ var __vector = bridge.create_std__vector_UnistyleDependency_(__dependencies.count)
296
+ for __item in __dependencies {
297
+ __vector.push_back(__item)
298
+ }
299
+ return __vector
300
+ }(), __miniRuntime)
297
301
  }
298
302
  }())
299
303
  return bridge.create_Result_void_()
@@ -17,6 +17,11 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
20
25
 
21
26
 
22
27
 
@@ -62,6 +67,9 @@ namespace margelo::nitro {
62
67
  return false;
63
68
  }
64
69
  jsi::Object obj = value.getObject(runtime);
70
+ if (!nitro::isPlainObject(runtime, obj)) {
71
+ return false;
72
+ }
65
73
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "width"))) return false;
66
74
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "height"))) return false;
67
75
  return true;
@@ -31,7 +31,7 @@ namespace margelo::nitro::unistyles {
31
31
  prototype.registerHybridGetter("miniRuntime", &HybridUnistylesRuntimeSpec::getMiniRuntime);
32
32
  prototype.registerHybridMethod("setTheme", &HybridUnistylesRuntimeSpec::setTheme);
33
33
  prototype.registerHybridMethod("setAdaptiveThemes", &HybridUnistylesRuntimeSpec::setAdaptiveThemes);
34
- prototype.registerHybridMethod("setImmersiveMode", &HybridUnistylesRuntimeSpec::setImmersiveMode);
34
+ prototype.registerHybridMethod("setImmersiveModeNative", &HybridUnistylesRuntimeSpec::setImmersiveModeNative);
35
35
  prototype.registerHybridMethod("nativeSetRootViewBackgroundColor", &HybridUnistylesRuntimeSpec::nativeSetRootViewBackgroundColor);
36
36
  });
37
37
  }
@@ -80,7 +80,7 @@ namespace margelo::nitro::unistyles {
80
80
  // Methods
81
81
  virtual void setTheme(const std::string& themeName) = 0;
82
82
  virtual void setAdaptiveThemes(bool isEnabled) = 0;
83
- virtual void setImmersiveMode(bool isEnabled) = 0;
83
+ virtual void setImmersiveModeNative(bool isEnabled) = 0;
84
84
  virtual void nativeSetRootViewBackgroundColor(double color) = 0;
85
85
 
86
86
  protected:
@@ -16,7 +16,7 @@ namespace margelo::nitro::unistyles {
16
16
  registerHybrids(this, [](Prototype& prototype) {
17
17
  prototype.registerHybridGetter("width", &HybridUnistylesStatusBarSpec::getWidth);
18
18
  prototype.registerHybridGetter("height", &HybridUnistylesStatusBarSpec::getHeight);
19
- prototype.registerHybridMethod("setHidden", &HybridUnistylesStatusBarSpec::setHidden);
19
+ prototype.registerHybridMethod("setHiddenNative", &HybridUnistylesStatusBarSpec::setHiddenNative);
20
20
  });
21
21
  }
22
22
 
@@ -49,7 +49,7 @@ namespace margelo::nitro::unistyles {
49
49
 
50
50
  public:
51
51
  // Methods
52
- virtual void setHidden(bool isHidden) = 0;
52
+ virtual void setHiddenNative(bool isHidden) = 0;
53
53
 
54
54
  protected:
55
55
  // Hybrid Setup
@@ -17,6 +17,11 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
20
25
 
21
26
 
22
27
 
@@ -71,6 +76,9 @@ namespace margelo::nitro {
71
76
  return false;
72
77
  }
73
78
  jsi::Object obj = value.getObject(runtime);
79
+ if (!nitro::isPlainObject(runtime, obj)) {
80
+ return false;
81
+ }
74
82
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "top"))) return false;
75
83
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "bottom"))) return false;
76
84
  if (!JSIConverter<double>::canConvert(runtime, obj.getProperty(runtime, "left"))) return false;
@@ -17,6 +17,11 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
20
25
 
21
26
  // Forward declaration of `ColorScheme` to properly resolve imports.
22
27
  namespace margelo::nitro::unistyles { enum class ColorScheme; }
@@ -107,6 +112,9 @@ namespace margelo::nitro {
107
112
  return false;
108
113
  }
109
114
  jsi::Object obj = value.getObject(runtime);
115
+ if (!nitro::isPlainObject(runtime, obj)) {
116
+ return false;
117
+ }
110
118
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "themeName"))) return false;
111
119
  if (!JSIConverter<std::optional<std::string>>::canConvert(runtime, obj.getProperty(runtime, "breakpoint"))) return false;
112
120
  if (!JSIConverter<bool>::canConvert(runtime, obj.getProperty(runtime, "hasAdaptiveThemes"))) return false;
@@ -17,6 +17,11 @@
17
17
  #else
18
18
  #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
19
19
  #endif
20
+ #if __has_include(<NitroModules/JSIHelpers.hpp>)
21
+ #include <NitroModules/JSIHelpers.hpp>
22
+ #else
23
+ #error NitroModules cannot be found! Are you sure you installed NitroModules properly?
24
+ #endif
20
25
 
21
26
  // Forward declaration of `ColorScheme` to properly resolve imports.
22
27
  namespace margelo::nitro::unistyles { enum class ColorScheme; }
@@ -97,6 +102,9 @@ namespace margelo::nitro {
97
102
  return false;
98
103
  }
99
104
  jsi::Object obj = value.getObject(runtime);
105
+ if (!nitro::isPlainObject(runtime, obj)) {
106
+ return false;
107
+ }
100
108
  if (!JSIConverter<margelo::nitro::unistyles::ColorScheme>::canConvert(runtime, obj.getProperty(runtime, "colorScheme"))) return false;
101
109
  if (!JSIConverter<margelo::nitro::unistyles::Dimensions>::canConvert(runtime, obj.getProperty(runtime, "screen"))) return false;
102
110
  if (!JSIConverter<std::string>::canConvert(runtime, obj.getProperty(runtime, "contentSizeCategory"))) return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.14",
3
+ "version": "3.0.16",
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
- "nitrogen": "0.29.8",
151
+ "nitrogen": "0.31.2",
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.29.8",
155
+ "react-native-nitro-modules": "0.31.2",
156
156
  "react-native-reanimated": "3.17.5",
157
157
  "react-native-web": "0.20.0",
158
158
  "react-test-renderer": "19.1.0",
package/src/mocks.ts CHANGED
@@ -107,6 +107,7 @@ jest.mock('react-native-unistyles', () => {
107
107
  },
108
108
  setAdaptiveThemes: () => {},
109
109
  setImmersiveMode: () => {},
110
+ setImmersiveModeNative: () => {},
110
111
  insets: {
111
112
  top: 0,
112
113
  left: 0,
@@ -5,5 +5,5 @@ export interface UnistylesStatusBar extends HybridObject<{ ios: 'c++', android:
5
5
  readonly width: number,
6
6
  readonly height: number,
7
7
 
8
- setHidden(isHidden: boolean): void,
8
+ setHiddenNative(isHidden: boolean): void,
9
9
  }
@@ -6,8 +6,7 @@ export type StatusBarHiddenAnimation = 'none' | 'fade' | 'slide'
6
6
 
7
7
  interface PrivateUnistylesStatusBar extends Omit<UnistylesStatusBarSpec, 'setBackgroundColor' | 'setHidden'> {
8
8
  setStyle(style: StatusBarStyle, animated?: boolean): void,
9
- setHidden(isHidden: boolean, animation?: StatusBarHiddenAnimation): void,
10
- _setHidden(isHidden: boolean, animation?: StatusBarHiddenAnimation): void,
9
+ setHidden(isHidden: boolean, animation?: StatusBarHiddenAnimation): void
11
10
  }
12
11
 
13
12
  export const attachStatusBarJSMethods = (hybridObject: UnistylesStatusBar) => {
@@ -24,15 +23,14 @@ export const attachStatusBarJSMethods = (hybridObject: UnistylesStatusBar) => {
24
23
 
25
24
  const privateHybrid = hybridObject as PrivateUnistylesStatusBar
26
25
 
27
- privateHybrid._setHidden = hybridObject.setHidden
28
26
  hybridObject.setHidden = (isHidden: boolean, animation?: StatusBarHiddenAnimation) => {
29
27
  NativeStatusBar.setHidden(isHidden, animation)
30
- privateHybrid._setHidden(isHidden)
28
+ privateHybrid.setHiddenNative(isHidden)
31
29
  }
32
30
  }
33
31
 
34
32
  type PrivateMethods =
35
- | '_setHidden'
36
33
  | 'dispose'
34
+ | 'setHiddenNative'
37
35
 
38
36
  export type UnistylesStatusBar = Omit<PrivateUnistylesStatusBar, PrivateMethods>
@@ -41,7 +41,7 @@ export interface UnistylesRuntime extends HybridObject<{ ios: 'c++', android: 'c
41
41
 
42
42
  setTheme(themeName: string): void,
43
43
  setAdaptiveThemes(isEnabled: boolean): void,
44
- setImmersiveMode(isEnabled: boolean): void,
44
+ setImmersiveModeNative(isEnabled: boolean): void,
45
45
  nativeSetRootViewBackgroundColor(color: number): void
46
46
 
47
47
  // private
@@ -1,6 +1,6 @@
1
1
  import { processColor } from 'react-native'
2
2
  import { NitroModules } from 'react-native-nitro-modules'
3
- import { isIOS } from '../../common'
3
+ import { isAndroid, isIOS } from '../../common'
4
4
  import type { UnistylesThemes } from '../../global'
5
5
  import type { AndroidContentSizeCategory, IOSContentSizeCategory, UnistylesTheme } from '../../types'
6
6
  import type { UnistylesNavigationBar } from '../NavigtionBar'
@@ -24,6 +24,7 @@ export interface UnistylesRuntimePrivate extends Omit<UnistylesRuntimeSpec, 'set
24
24
  updateTheme(themeName: AppThemeName, updater: (currentTheme: AppTheme) => AppTheme): void,
25
25
  setRootViewBackgroundColor(color?: string): void,
26
26
  nativeSetRootViewBackgroundColor(color?: Color): void
27
+ setImmersiveMode(isEnabled: boolean): void
27
28
 
28
29
  // constructors
29
30
  createHybridStatusBar(): UnistylesStatusBar,
@@ -36,6 +37,7 @@ type PrivateMethods =
36
37
  | 'dispose'
37
38
  | 'miniRuntime'
38
39
  | 'nativeSetRootViewBackgroundColor'
40
+ | 'setImmersiveModeNative'
39
41
 
40
42
  type UnistylesRuntime = Omit<UnistylesRuntimePrivate, PrivateMethods>
41
43
 
@@ -55,6 +57,10 @@ if (isIOS) {
55
57
  HybridUnistylesRuntime.setImmersiveMode = (isEnabled: boolean) => HybridUnistylesRuntime.statusBar.setHidden(isEnabled, 'fade')
56
58
  }
57
59
 
60
+ if (isAndroid) {
61
+ HybridUnistylesRuntime.setImmersiveMode = HybridUnistylesRuntime.setImmersiveModeNative
62
+ }
63
+
58
64
  attachStatusBarJSMethods(HybridUnistylesRuntime.statusBar)
59
65
 
60
66
  export const Runtime = HybridUnistylesRuntime as UnistylesRuntime
package/src/web/state.ts CHANGED
@@ -43,10 +43,7 @@ export class UnistylesState {
43
43
  this.isInitialized = true
44
44
  this.initThemes(config.themes, config.settings?.CSSVars)
45
45
  this.initBreakpoints(config.breakpoints)
46
-
47
- if (config.settings) {
48
- this.initSettings(config.settings as UnistylesSettings)
49
- }
46
+ this.initSettings(config.settings as UnistylesSettings | undefined)
50
47
 
51
48
  if (isServer()) {
52
49
  return
@@ -83,15 +80,15 @@ export class UnistylesState {
83
80
  })
84
81
  }
85
82
 
86
- private initSettings = (settings: UnistylesSettings) => {
83
+ private initSettings = (settings?: UnistylesSettings) => {
87
84
  this.hasAdaptiveThemes = settings?.adaptiveThemes ?? false
88
85
 
89
- if (settings.initialTheme && settings.adaptiveThemes) {
86
+ if (settings?.initialTheme && settings.adaptiveThemes) {
90
87
  throw error('You\'re trying to set initial theme and enable adaptiveThemes, but these options are mutually exclusive.')
91
88
  }
92
89
 
93
90
  // Adaptive themes
94
- if (settings.adaptiveThemes) {
91
+ if (settings?.adaptiveThemes) {
95
92
  if (!this.themes.get('light') || !this.themes.get('dark')) {
96
93
  throw error(`You're trying to enable adaptiveThemes, but you didn't register both 'light' and 'dark' themes.`)
97
94
  }
@@ -101,7 +98,7 @@ export class UnistylesState {
101
98
  return
102
99
  }
103
100
 
104
- if (settings.initialTheme) {
101
+ if (settings?.initialTheme) {
105
102
  const initialTheme = typeof settings.initialTheme === 'function'
106
103
  ? settings.initialTheme()
107
104
  : settings.initialTheme