react-native-unistyles 3.8.0 → 3.8.2

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 (112) hide show
  1. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +3 -10
  2. package/cxx/core/UnistylesRegistry.cpp +1 -1
  3. package/cxx/hybridObjects/HybridShadowRegistry.cpp +4 -2
  4. package/cxx/shadowTree/ShadowTreeManager.cpp +36 -0
  5. package/lib/commonjs/hooks/useMedia.js +6 -0
  6. package/lib/commonjs/hooks/useMedia.js.map +1 -1
  7. package/lib/commonjs/index.js.map +1 -1
  8. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js +13 -4
  9. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -1
  10. package/lib/commonjs/web/create.js +35 -6
  11. package/lib/commonjs/web/create.js.map +1 -1
  12. package/lib/commonjs/web/css/sheet.js +11 -1
  13. package/lib/commonjs/web/css/sheet.js.map +1 -1
  14. package/lib/commonjs/web/css/state.js +6 -0
  15. package/lib/commonjs/web/css/state.js.map +1 -1
  16. package/lib/commonjs/web/shadowRegistry.js +3 -1
  17. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  18. package/lib/commonjs/web/types.js +3 -1
  19. package/lib/commonjs/web/types.js.map +1 -1
  20. package/lib/module/hooks/useMedia.js +6 -0
  21. package/lib/module/hooks/useMedia.js.map +1 -1
  22. package/lib/module/index.js.map +1 -1
  23. package/lib/module/reanimated/variant/useUpdateVariantColor.js +15 -5
  24. package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -1
  25. package/lib/module/web/create.js +35 -6
  26. package/lib/module/web/create.js.map +1 -1
  27. package/lib/module/web/css/sheet.js +11 -1
  28. package/lib/module/web/css/sheet.js.map +1 -1
  29. package/lib/module/web/css/state.js +7 -1
  30. package/lib/module/web/css/state.js.map +1 -1
  31. package/lib/module/web/shadowRegistry.js +3 -1
  32. package/lib/module/web/shadowRegistry.js.map +1 -1
  33. package/lib/module/web/types.js +2 -0
  34. package/lib/module/web/types.js.map +1 -1
  35. package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
  36. package/lib/typescript/src/index.d.ts +1 -0
  37. package/lib/typescript/src/index.d.ts.map +1 -1
  38. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -1
  39. package/lib/typescript/src/web/create.d.ts.map +1 -1
  40. package/lib/typescript/src/web/css/sheet.d.ts.map +1 -1
  41. package/lib/typescript/src/web/css/state.d.ts.map +1 -1
  42. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  43. package/lib/typescript/src/web/types.d.ts +1 -0
  44. package/lib/typescript/src/web/types.d.ts.map +1 -1
  45. package/nitrogen/generated/android/c++/JColorScheme.hpp +1 -1
  46. package/nitrogen/generated/android/c++/JDimensions.hpp +1 -1
  47. package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +1 -1
  48. package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +1 -1
  49. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +1 -1
  50. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
  51. package/nitrogen/generated/android/c++/JInsets.hpp +1 -1
  52. package/nitrogen/generated/android/c++/JOrientation.hpp +1 -1
  53. package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +1 -1
  54. package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +1 -1
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/ColorScheme.kt +1 -1
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -1
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_UnistylesNativeMiniRuntime.kt +1 -1
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +1 -1
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +1 -1
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -1
  61. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Orientation.kt +1 -1
  62. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +1 -1
  63. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +1 -1
  64. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/unistylesOnLoad.kt +1 -1
  65. package/nitrogen/generated/android/unistyles+autolinking.cmake +1 -1
  66. package/nitrogen/generated/android/unistyles+autolinking.gradle +1 -1
  67. package/nitrogen/generated/android/unistylesOnLoad.cpp +1 -1
  68. package/nitrogen/generated/android/unistylesOnLoad.hpp +1 -1
  69. package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
  70. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +1 -1
  71. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +1 -1
  72. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +1 -1
  73. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.cpp +1 -1
  74. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +1 -1
  75. package/nitrogen/generated/ios/swift/ColorScheme.swift +1 -1
  76. package/nitrogen/generated/ios/swift/Dimensions.swift +1 -1
  77. package/nitrogen/generated/ios/swift/Func_void_UnistylesNativeMiniRuntime.swift +1 -1
  78. package/nitrogen/generated/ios/swift/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.swift +1 -1
  79. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +1 -1
  80. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +3 -3
  81. package/nitrogen/generated/ios/swift/Insets.swift +1 -1
  82. package/nitrogen/generated/ios/swift/Orientation.swift +1 -1
  83. package/nitrogen/generated/ios/swift/UnistyleDependency.swift +1 -1
  84. package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +1 -1
  85. package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
  86. package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -1
  87. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.cpp +1 -1
  88. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
  89. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.cpp +1 -1
  90. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
  91. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -1
  92. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
  93. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.cpp +1 -1
  94. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
  95. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.cpp +1 -1
  96. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
  97. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
  98. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
  99. package/nitrogen/generated/shared/c++/Insets.hpp +1 -1
  100. package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
  101. package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +1 -1
  102. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -1
  103. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -1
  104. package/package.json +3 -3
  105. package/src/hooks/useMedia.ts +6 -0
  106. package/src/index.ts +1 -0
  107. package/src/reanimated/variant/useUpdateVariantColor.ts +15 -5
  108. package/src/web/create.ts +45 -8
  109. package/src/web/css/sheet.ts +15 -1
  110. package/src/web/css/state.ts +9 -2
  111. package/src/web/shadowRegistry.ts +6 -1
  112. package/src/web/types.ts +3 -0
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Orientation.kt
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// UnistyleDependency.kt
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// UnistylesNativeMiniRuntime.kt
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// unistylesOnLoad.kt
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # unistyles+autolinking.cmake
3
3
  # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- # https://github.com/mrousavy/nitro
4
+ # https://github.com/margelo/nitro
5
5
  # Copyright © Marc Rousavy @ Margelo
6
6
  #
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// unistyles+autolinking.gradle
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// unistylesOnLoad.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// unistylesOnLoad.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  #
2
2
  # Unistyles+autolinking.rb
3
3
  # This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- # https://github.com/mrousavy/nitro
4
+ # https://github.com/margelo/nitro
5
5
  # Copyright © Marc Rousavy @ Margelo
6
6
  #
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Unistyles-Swift-Cxx-Bridge.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Unistyles-Swift-Cxx-Bridge.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Unistyles-Swift-Cxx-Umbrella.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridNativePlatformSpecSwift.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridNativePlatformSpecSwift.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// ColorScheme.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Dimensions.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Func_void_UnistylesNativeMiniRuntime.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridNativePlatformSpec.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridNativePlatformSpec_cxx.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -27,7 +27,7 @@ open class HybridNativePlatformSpec_cxx {
27
27
  /**
28
28
  * Holds an instance of the `HybridNativePlatformSpec` Swift protocol.
29
29
  */
30
- private var __implementation: any HybridNativePlatformSpec
30
+ private let __implementation: any HybridNativePlatformSpec
31
31
 
32
32
  /**
33
33
  * Holds a weak pointer to the C++ class that wraps the Swift class.
@@ -75,7 +75,7 @@ open class HybridNativePlatformSpec_cxx {
75
75
  */
76
76
  public func getCxxPart() -> bridge.std__shared_ptr_HybridNativePlatformSpec_ {
77
77
  let cachedCxxPart = self.__cxxPart.lock()
78
- if Bool(fromCxx: cachedCxxPart) {
78
+ if cachedCxxPart.use_count() > 0 {
79
79
  return cachedCxxPart
80
80
  } else {
81
81
  let newCxxPart = bridge.create_std__shared_ptr_HybridNativePlatformSpec_(self.toUnsafe())
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Insets.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Orientation.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// UnistyleDependency.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// UnistylesNativeMiniRuntime.swift
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// ColorScheme.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Dimensions.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridNativePlatformSpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridNativePlatformSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesNavigationBarSpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesNavigationBarSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesRuntimeSpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesRuntimeSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesShadowRegistrySpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesShadowRegistrySpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesStatusBarSpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesStatusBarSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesStyleSheetSpec.cpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// HybridUnistylesStyleSheetSpec.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Insets.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// Orientation.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// UnistyleDependency.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// UnistylesCxxMiniRuntime.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
@@ -1,7 +1,7 @@
1
1
  ///
2
2
  /// UnistylesNativeMiniRuntime.hpp
3
3
  /// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
4
- /// https://github.com/mrousavy/nitro
4
+ /// https://github.com/margelo/nitro
5
5
  /// Copyright © Marc Rousavy @ Margelo
6
6
  ///
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.8.0",
3
+ "version": "3.8.2",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "NODE_ENV=babel-test jest ./plugin ./metro ./codemods ./src/__tests__",
@@ -219,13 +219,13 @@
219
219
  "jest": "30.5.2",
220
220
  "jscodeshift": "17.4.0",
221
221
  "jsdom": "26.1.0",
222
- "nitrogen": "0.37.1",
222
+ "nitrogen": "0.37.2",
223
223
  "oxfmt": "0.74.0",
224
224
  "oxlint": "1.89.0",
225
225
  "react": "19.3.0",
226
226
  "react-native": "0.88.0",
227
227
  "react-native-builder-bob": "0.43.2",
228
- "react-native-nitro-modules": "0.37.1",
228
+ "react-native-nitro-modules": "0.37.2",
229
229
  "react-native-reanimated": "4.7.1",
230
230
  "react-native-web": "0.21.4",
231
231
  "typescript": "6.0.3"
@@ -1,6 +1,7 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
2
 
3
3
  import { isUnistylesMq, isValidMq, parseMq } from '../utils'
4
+ import { isServer } from '../web/utils'
4
5
 
5
6
  export const useMedia = (config: { mq: symbol }) => {
6
7
  const disposeRef = useRef(() => {})
@@ -32,6 +33,11 @@ export const useMedia = (config: { mq: symbol }) => {
32
33
  .filter(Boolean)
33
34
  .join(' and ')
34
35
 
36
+ // No viewport on the server, the content is hidden until the browser renders it
37
+ if (isServer()) {
38
+ return false
39
+ }
40
+
35
41
  const media = window.matchMedia(mediaQuery)
36
42
  const handler = (event: MediaQueryListEvent) => setIsVisible(event.matches)
37
43
 
package/src/index.ts CHANGED
@@ -10,6 +10,7 @@ export { StyleSheet, UnistylesRuntime } from './specs'
10
10
  export { UnistyleDependency } from './specs'
11
11
  export type { UnistylesMiniRuntime } from './specs'
12
12
  export { ColorScheme, Orientation, StatusBarStyle } from './specs/types'
13
+ export type { AppTheme, AppThemeName, AppBreakpoint } from './specs/types'
13
14
  export { mq } from './mq'
14
15
  export type { UnistylesThemes, UnistylesBreakpoints } from './global'
15
16
  export { withUnistyles, useUnistyles, createUnistylesElement } from './core'
@@ -6,14 +6,23 @@ import type { UseUpdateVariantColorConfig } from './types'
6
6
 
7
7
  import { UnistyleDependency } from '../../specs'
8
8
  import { services } from '../../web/services'
9
- import { getClosestBreakpointValue } from '../../web/utils'
9
+ import { getClosestBreakpointValue, isServer } from '../../web/utils'
10
+
11
+ // The first render paints this color on the server and in the browser, then the layout effect sets the real one.
12
+ // Matching the server lets the effect replace its HTML: Reanimated skips writing a value that didn't change
13
+ const INITIAL_COLOR = 'rgb(0, 0, 0)'
10
14
 
11
15
  export const useUpdateVariantColor = <T extends Record<string, any>>({
12
16
  animateCallback,
13
17
  colorKey,
14
18
  style,
15
19
  }: UseUpdateVariantColorConfig<T>) => {
20
+ // Resolves CSS variables to colors, there is no document on the server
16
21
  const [dummyDiv] = useState(() => {
22
+ if (isServer()) {
23
+ return undefined
24
+ }
25
+
17
26
  const div = document.createElement('div')
18
27
 
19
28
  div.style.display = 'none'
@@ -35,7 +44,8 @@ export const useUpdateVariantColor = <T extends Record<string, any>>({
35
44
  ? currentColor
36
45
  : (getClosestBreakpointValue<string>(services.runtime, currentColor) ?? 'rgb(0, 0, 0)')
37
46
 
38
- if (currentColorVar.startsWith('var(--')) {
47
+ // Called from effects only, which don't run on the server
48
+ if (currentColorVar.startsWith('var(--') && dummyDiv) {
39
49
  dummyDiv.style.color = currentColorVar
40
50
 
41
51
  return getComputedStyle(dummyDiv).color
@@ -43,8 +53,8 @@ export const useUpdateVariantColor = <T extends Record<string, any>>({
43
53
 
44
54
  return currentColorVar
45
55
  }, [style, colorKey])
46
- const fromValue = useSharedValue<string>(getCurrentColor())
47
- const toValue = useSharedValue<string>(getCurrentColor())
56
+ const fromValue = useSharedValue<string>(INITIAL_COLOR)
57
+ const toValue = useSharedValue<string>(INITIAL_COLOR)
48
58
 
49
59
  useEffect(() => {
50
60
  const dispose = services.listener.addListeners([UnistyleDependency.Theme], () => {
@@ -72,7 +82,7 @@ export const useUpdateVariantColor = <T extends Record<string, any>>({
72
82
  return () => dispose()
73
83
  }, [style, colorKey])
74
84
 
75
- useEffect(() => () => dummyDiv.remove(), [])
85
+ useEffect(() => () => dummyDiv?.remove(), [])
76
86
 
77
87
  return {
78
88
  fromValue,
package/src/web/create.ts CHANGED
@@ -5,14 +5,7 @@ import { assignSecrets, isServer, removeInlineStyles } from './utils'
5
5
 
6
6
  type Variants = Record<string, string | boolean | undefined>
7
7
 
8
- export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => {
9
- // For SSR
10
- if (!unistyles.services.state.isInitialized && !isServer()) {
11
- const config = window?.__UNISTYLES_STATE__?.config
12
-
13
- config && unistyles.services.state.init(config)
14
- }
15
-
8
+ const createStyleSheet = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => {
16
9
  const computedStylesheet = unistyles.services.registry.getComputedStylesheet(stylesheet)
17
10
  const addSecrets = (
18
11
  value: any,
@@ -55,3 +48,47 @@ export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => {
55
48
 
56
49
  return createStyleSheetStyles()
57
50
  }
51
+
52
+ // On the server, a route can be loaded before StyleSheet.configure runs: Expo Router reads the matched route's
53
+ // metadata before rendering the document that imports the config. Such a StyleSheet is created on first use instead
54
+ const createOnFirstUse = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => {
55
+ const styles = {} as ReturnType<typeof createStyleSheet>
56
+ let isCreated = false
57
+ // The styles fill the proxy's own target, so it behaves like the object create returns (writes, freeze...)
58
+ const getStyles = () => {
59
+ if (!isCreated) {
60
+ Object.assign(styles, createStyleSheet(stylesheet))
61
+ isCreated = true
62
+ }
63
+
64
+ return styles
65
+ }
66
+ // Reflect has a method for every proxy trap
67
+ const traps = Object.getOwnPropertyNames(Reflect) as Array<keyof ProxyHandler<object>>
68
+ const handler = Object.fromEntries(
69
+ traps.map((trap) => [
70
+ trap,
71
+ (_: object, ...args: Array<any>) => (Reflect[trap] as Function)(getStyles(), ...args),
72
+ ]),
73
+ )
74
+
75
+ return new Proxy(styles, handler)
76
+ }
77
+
78
+ export const create = (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => {
79
+ if (unistyles.services.state.isInitialized) {
80
+ return createStyleSheet(stylesheet)
81
+ }
82
+
83
+ // A plain object doesn't read the config, so it can be created right away
84
+ if (isServer()) {
85
+ return typeof stylesheet === 'function' ? createOnFirstUse(stylesheet) : createStyleSheet(stylesheet)
86
+ }
87
+
88
+ // For SSR
89
+ const config = window?.__UNISTYLES_STATE__?.config
90
+
91
+ config && unistyles.services.state.init(config)
92
+
93
+ return createStyleSheet(stylesheet)
94
+ }