react-native-unistyles 3.0.0-beta.5 → 3.0.0-beta.7

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 (340) hide show
  1. package/README.md +17 -2
  2. package/android/CMakeLists.txt +1 -1
  3. package/android/src/main/cxx/NativeUnistylesModule.cpp +1 -1
  4. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +5 -2
  5. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +24 -1
  6. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +6 -1
  7. package/android/src/main/java/com/unistyles/UnistylesModule.kt +5 -4
  8. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +6 -6
  9. package/components/native/Animated/package.json +5 -0
  10. package/components/native/NativeText/package.json +5 -0
  11. package/components/native/NativeView/package.json +5 -0
  12. package/cxx/core/HashGenerator.cpp +1 -1
  13. package/cxx/core/HostUnistyle.cpp +28 -4
  14. package/cxx/core/HostUnistyle.h +1 -0
  15. package/cxx/core/Unistyle.h +4 -0
  16. package/cxx/core/UnistyleWrapper.h +6 -6
  17. package/cxx/core/UnistylesRegistry.cpp +24 -3
  18. package/cxx/core/UnistylesRegistry.h +3 -0
  19. package/cxx/hybridObjects/HybridShadowRegistry.cpp +7 -0
  20. package/cxx/hybridObjects/HybridStyleSheet.cpp +27 -2
  21. package/cxx/parser/Parser.cpp +13 -7
  22. package/ios/NativePlatform+ios.swift +16 -4
  23. package/ios/UnistylesModuleOnLoad.h +4 -4
  24. package/ios/UnistylesModuleOnLoad.mm +4 -8
  25. package/lib/commonjs/components/native/Animated.js +23 -0
  26. package/lib/commonjs/components/native/Animated.js.map +1 -0
  27. package/lib/commonjs/components/native/ImageBackground.js +6 -4
  28. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  29. package/lib/commonjs/components/native/NativeText.js +13 -0
  30. package/lib/commonjs/components/native/NativeText.js.map +1 -0
  31. package/lib/commonjs/components/native/NativeText.native.js +18 -0
  32. package/lib/commonjs/components/native/NativeText.native.js.map +1 -0
  33. package/lib/commonjs/components/native/NativeView.js +9 -0
  34. package/lib/commonjs/components/native/NativeView.js.map +1 -0
  35. package/lib/commonjs/components/native/NativeView.native.js +20 -0
  36. package/lib/commonjs/components/native/NativeView.native.js.map +1 -0
  37. package/lib/commonjs/components/native/Pressable.js +1 -1
  38. package/lib/commonjs/components/native/Pressable.js.map +1 -1
  39. package/lib/commonjs/components/native/Pressable.native.js +18 -9
  40. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  41. package/lib/commonjs/core/createUnistylesElement.js +28 -24
  42. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  43. package/lib/commonjs/core/createUnistylesElement.native.js +37 -23
  44. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  45. package/lib/commonjs/core/createUnistylesImageBackground.js +34 -30
  46. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  47. package/lib/commonjs/core/getClassname.js +1 -3
  48. package/lib/commonjs/core/getClassname.js.map +1 -1
  49. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -2
  50. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  51. package/lib/commonjs/core/warn.js +1 -1
  52. package/lib/commonjs/core/withUnistyles/withUnistyles.js +2 -2
  53. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  54. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +5 -3
  55. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  56. package/lib/commonjs/hooks/useMedia.native.js +1 -1
  57. package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
  58. package/lib/commonjs/mq.js.map +1 -1
  59. package/lib/commonjs/server/getServerUnistyles.js +4 -2
  60. package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
  61. package/lib/commonjs/server/hydrateServerUnistyles.js +1 -1
  62. package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
  63. package/lib/commonjs/server/resetServerUnistyles.js +1 -1
  64. package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
  65. package/lib/commonjs/server/useServerUnistyles.js +2 -2
  66. package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
  67. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  68. package/lib/commonjs/specs/StyleSheet/index.js +1 -1
  69. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  70. package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
  71. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  72. package/lib/commonjs/specs/index.native.js +3 -3
  73. package/lib/commonjs/specs/index.native.js.map +1 -1
  74. package/lib/commonjs/utils.js +16 -1
  75. package/lib/commonjs/utils.js.map +1 -1
  76. package/lib/commonjs/web/convert/index.js +4 -4
  77. package/lib/commonjs/web/convert/index.js.map +1 -1
  78. package/lib/commonjs/web/convert/object/boxShadow.js +4 -4
  79. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
  80. package/lib/commonjs/web/convert/object/filter.js +3 -3
  81. package/lib/commonjs/web/convert/object/filter.js.map +1 -1
  82. package/lib/commonjs/web/convert/object/transform.js +1 -1
  83. package/lib/commonjs/web/convert/object/transform.js.map +1 -1
  84. package/lib/commonjs/web/convert/utils.js.map +1 -1
  85. package/lib/commonjs/web/index.js +1 -1
  86. package/lib/commonjs/web/index.js.map +1 -1
  87. package/lib/commonjs/web/registry.js +1 -1
  88. package/lib/commonjs/web/registry.js.map +1 -1
  89. package/lib/commonjs/web/runtime.js.map +1 -1
  90. package/lib/commonjs/web/shadowRegistry.js +1 -1
  91. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  92. package/lib/commonjs/web/state.js +1 -1
  93. package/lib/commonjs/web/state.js.map +1 -1
  94. package/lib/commonjs/web/utils/common.js +1 -1
  95. package/lib/commonjs/web/utils/unistyle.js +10 -6
  96. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  97. package/lib/module/components/native/Animated.js +19 -0
  98. package/lib/module/components/native/Animated.js.map +1 -0
  99. package/lib/module/components/native/ImageBackground.js +5 -3
  100. package/lib/module/components/native/ImageBackground.js.map +1 -1
  101. package/lib/module/components/native/NativeText.js +4 -0
  102. package/lib/module/components/native/NativeText.js.map +1 -0
  103. package/lib/module/components/native/NativeText.native.js +15 -0
  104. package/lib/module/components/native/NativeText.native.js.map +1 -0
  105. package/lib/module/components/native/NativeView.js +5 -0
  106. package/lib/module/components/native/NativeView.js.map +1 -0
  107. package/lib/module/components/native/NativeView.native.js +17 -0
  108. package/lib/module/components/native/NativeView.native.js.map +1 -0
  109. package/lib/module/components/native/Pressable.js +1 -1
  110. package/lib/module/components/native/Pressable.js.map +1 -1
  111. package/lib/module/components/native/Pressable.native.js +19 -10
  112. package/lib/module/components/native/Pressable.native.js.map +1 -1
  113. package/lib/module/core/createUnistylesElement.js +28 -24
  114. package/lib/module/core/createUnistylesElement.js.map +1 -1
  115. package/lib/module/core/createUnistylesElement.native.js +38 -24
  116. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  117. package/lib/module/core/createUnistylesImageBackground.js +35 -31
  118. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  119. package/lib/module/core/getClassname.js +2 -4
  120. package/lib/module/core/getClassname.js.map +1 -1
  121. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -2
  122. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  123. package/lib/module/core/warn.js +1 -1
  124. package/lib/module/core/withUnistyles/withUnistyles.js +2 -2
  125. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  126. package/lib/module/core/withUnistyles/withUnistyles.native.js +6 -4
  127. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  128. package/lib/module/hooks/useMedia.native.js +1 -1
  129. package/lib/module/hooks/useMedia.native.js.map +1 -1
  130. package/lib/module/mq.js.map +1 -1
  131. package/lib/module/server/getServerUnistyles.js +4 -2
  132. package/lib/module/server/getServerUnistyles.js.map +1 -1
  133. package/lib/module/server/hydrateServerUnistyles.js +1 -1
  134. package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
  135. package/lib/module/server/resetServerUnistyles.js +1 -1
  136. package/lib/module/server/resetServerUnistyles.js.map +1 -1
  137. package/lib/module/server/useServerUnistyles.js +2 -2
  138. package/lib/module/server/useServerUnistyles.js.map +1 -1
  139. package/lib/module/specs/StatusBar/index.js.map +1 -1
  140. package/lib/module/specs/StyleSheet/index.js +1 -1
  141. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  142. package/lib/module/specs/UnistylesRuntime/index.js +1 -1
  143. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  144. package/lib/module/specs/index.native.js +4 -4
  145. package/lib/module/specs/index.native.js.map +1 -1
  146. package/lib/module/utils.js +14 -0
  147. package/lib/module/utils.js.map +1 -1
  148. package/lib/module/web/convert/index.js +5 -5
  149. package/lib/module/web/convert/index.js.map +1 -1
  150. package/lib/module/web/convert/object/boxShadow.js +2 -2
  151. package/lib/module/web/convert/object/boxShadow.js.map +1 -1
  152. package/lib/module/web/convert/object/filter.js +3 -3
  153. package/lib/module/web/convert/object/filter.js.map +1 -1
  154. package/lib/module/web/convert/object/transform.js +1 -1
  155. package/lib/module/web/convert/object/transform.js.map +1 -1
  156. package/lib/module/web/convert/utils.js.map +1 -1
  157. package/lib/module/web/index.js +1 -1
  158. package/lib/module/web/index.js.map +1 -1
  159. package/lib/module/web/registry.js +1 -1
  160. package/lib/module/web/registry.js.map +1 -1
  161. package/lib/module/web/runtime.js.map +1 -1
  162. package/lib/module/web/shadowRegistry.js +1 -1
  163. package/lib/module/web/shadowRegistry.js.map +1 -1
  164. package/lib/module/web/state.js +1 -1
  165. package/lib/module/web/state.js.map +1 -1
  166. package/lib/module/web/utils/common.js +1 -1
  167. package/lib/module/web/utils/unistyle.js +10 -6
  168. package/lib/module/web/utils/unistyle.js.map +1 -1
  169. package/lib/typescript/src/components/native/ActivityIndicator.d.ts +1 -3
  170. package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
  171. package/lib/typescript/src/components/native/Animated.d.ts +39 -0
  172. package/lib/typescript/src/components/native/Animated.d.ts.map +1 -0
  173. package/lib/typescript/src/components/native/FlatList.d.ts +1 -3
  174. package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
  175. package/lib/typescript/src/components/native/Image.d.ts +1 -3
  176. package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
  177. package/lib/typescript/src/components/native/ImageBackground.d.ts +1 -8
  178. package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
  179. package/lib/typescript/src/components/native/ImageBackground.native.d.ts +1 -2
  180. package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
  181. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +1 -3
  182. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
  183. package/lib/typescript/src/components/native/NativeText.d.ts +2 -0
  184. package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -0
  185. package/lib/typescript/src/components/native/NativeText.native.d.ts +2 -0
  186. package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -0
  187. package/lib/typescript/src/components/native/NativeView.d.ts +3 -0
  188. package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -0
  189. package/lib/typescript/src/components/native/NativeView.native.d.ts +3 -0
  190. package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -0
  191. package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
  192. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
  193. package/lib/typescript/src/components/native/RefreshControl.d.ts +1 -3
  194. package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
  195. package/lib/typescript/src/components/native/ScrollView.d.ts +1 -3
  196. package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
  197. package/lib/typescript/src/components/native/SectionList.d.ts +1 -3
  198. package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
  199. package/lib/typescript/src/components/native/Switch.d.ts +1 -3
  200. package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
  201. package/lib/typescript/src/components/native/Text.d.ts +1 -3
  202. package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
  203. package/lib/typescript/src/components/native/TextInput.d.ts +1 -3
  204. package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
  205. package/lib/typescript/src/components/native/TouchableHighlight.d.ts +1 -3
  206. package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
  207. package/lib/typescript/src/components/native/TouchableOpacity.d.ts +1 -3
  208. package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
  209. package/lib/typescript/src/components/native/View.d.ts +1 -3
  210. package/lib/typescript/src/components/native/View.d.ts.map +1 -1
  211. package/lib/typescript/src/components/native/VirtualizedList.d.ts +1 -3
  212. package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
  213. package/lib/typescript/src/core/createUnistylesElement.d.ts +1 -7
  214. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  215. package/lib/typescript/src/core/createUnistylesElement.native.d.ts +1 -2
  216. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  217. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +2 -3
  218. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  219. package/lib/typescript/src/core/getClassname.d.ts +2 -2
  220. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  221. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +2 -1
  222. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
  223. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  224. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  225. package/lib/typescript/src/mq.d.ts +1 -1
  226. package/lib/typescript/src/mq.d.ts.map +1 -1
  227. package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
  228. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
  229. package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
  230. package/lib/typescript/src/specs/StatusBar/index.d.ts +1 -1
  231. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  232. package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -1
  233. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  234. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
  235. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  236. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +5 -5
  237. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  238. package/lib/typescript/src/specs/index.native.d.ts +4 -4
  239. package/lib/typescript/src/specs/index.native.d.ts.map +1 -1
  240. package/lib/typescript/src/types/breakpoints.d.ts +2 -2
  241. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  242. package/lib/typescript/src/types/core.d.ts +1 -1
  243. package/lib/typescript/src/types/core.d.ts.map +1 -1
  244. package/lib/typescript/src/types/stylesheet.d.ts +4 -4
  245. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  246. package/lib/typescript/src/utils.d.ts +1 -0
  247. package/lib/typescript/src/utils.d.ts.map +1 -1
  248. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
  249. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
  250. package/lib/typescript/src/web/convert/types.d.ts +1 -1
  251. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  252. package/lib/typescript/src/web/convert/utils.d.ts +2 -2
  253. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  254. package/lib/typescript/src/web/create.d.ts +1 -1
  255. package/lib/typescript/src/web/create.d.ts.map +1 -1
  256. package/lib/typescript/src/web/index.d.ts +1 -1
  257. package/lib/typescript/src/web/index.d.ts.map +1 -1
  258. package/lib/typescript/src/web/registry.d.ts +1 -1
  259. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  260. package/lib/typescript/src/web/runtime.d.ts +1 -1
  261. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  262. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  263. package/lib/typescript/src/web/state.d.ts +1 -1
  264. package/lib/typescript/src/web/state.d.ts.map +1 -1
  265. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  266. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
  267. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +23 -39
  268. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/unistylesOnLoad.kt +35 -0
  269. package/nitrogen/generated/ios/Unistyles+autolinking.rb +2 -0
  270. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +1 -1
  271. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +3 -1
  272. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +2 -3
  273. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +18 -18
  274. package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
  275. package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -1
  276. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
  277. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
  278. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
  279. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
  280. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
  281. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
  282. package/nitrogen/generated/shared/c++/Insets.hpp +1 -1
  283. package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
  284. package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +1 -1
  285. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -1
  286. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -1
  287. package/package.json +16 -12
  288. package/plugin/consts.js +63 -0
  289. package/plugin/exotic.js +54 -0
  290. package/plugin/import.js +1 -1
  291. package/plugin/index.d.ts +84 -36
  292. package/plugin/index.js +48 -65
  293. package/plugin/stylesheet.js +454 -117
  294. package/plugin/variants.js +1 -1
  295. package/src/components/native/Animated.tsx +17 -0
  296. package/src/components/native/ImageBackground.tsx +7 -4
  297. package/src/components/native/NativeText.native.tsx +12 -0
  298. package/src/components/native/NativeText.tsx +1 -0
  299. package/src/components/native/NativeView.native.tsx +13 -0
  300. package/src/components/native/NativeView.tsx +3 -0
  301. package/src/components/native/Pressable.native.tsx +26 -13
  302. package/src/components/native/Pressable.tsx +1 -1
  303. package/src/core/createUnistylesElement.native.tsx +42 -27
  304. package/src/core/createUnistylesElement.tsx +36 -31
  305. package/src/core/createUnistylesImageBackground.tsx +39 -34
  306. package/src/core/getClassname.ts +5 -4
  307. package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +3 -3
  308. package/src/core/warn.ts +1 -1
  309. package/src/core/withUnistyles/withUnistyles.native.tsx +8 -6
  310. package/src/core/withUnistyles/withUnistyles.tsx +4 -4
  311. package/src/hooks/useMedia.native.ts +1 -1
  312. package/src/mq.ts +1 -1
  313. package/src/server/getServerUnistyles.tsx +3 -2
  314. package/src/server/hydrateServerUnistyles.ts +1 -1
  315. package/src/server/resetServerUnistyles.ts +1 -1
  316. package/src/server/useServerUnistyles.tsx +2 -2
  317. package/src/specs/StatusBar/index.ts +1 -1
  318. package/src/specs/StyleSheet/index.ts +5 -4
  319. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
  320. package/src/specs/UnistylesRuntime/index.ts +5 -5
  321. package/src/specs/index.native.ts +4 -4
  322. package/src/types/breakpoints.ts +2 -2
  323. package/src/types/core.ts +1 -1
  324. package/src/types/stylesheet.ts +4 -4
  325. package/src/utils.ts +17 -0
  326. package/src/web/convert/index.ts +5 -5
  327. package/src/web/convert/object/boxShadow.ts +2 -2
  328. package/src/web/convert/object/filter.ts +3 -3
  329. package/src/web/convert/object/transform.ts +2 -2
  330. package/src/web/convert/types.ts +1 -1
  331. package/src/web/convert/utils.ts +2 -2
  332. package/src/web/create.ts +1 -1
  333. package/src/web/index.ts +3 -3
  334. package/src/web/registry.ts +2 -2
  335. package/src/web/runtime.ts +2 -2
  336. package/src/web/shadowRegistry.ts +2 -2
  337. package/src/web/state.ts +4 -4
  338. package/src/web/utils/common.ts +1 -1
  339. package/src/web/utils/unistyle.ts +13 -7
  340. package/plugin/common.js +0 -142
package/README.md CHANGED
@@ -47,6 +47,9 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
47
47
  <a href="https://galaxies.dev">
48
48
  <img src="https://avatars.githubusercontent.com/u/118431096?s=200&v=4" height="70px" width="70px" alt="galaxies-dev" />
49
49
  </a>
50
+ <a href="https://github.com/FTCHD">
51
+ <img src="https://avatars.githubusercontent.com/u/144691102?v=4" height="70px" width="70px" alt="FTCHD" />
52
+ </a>
50
53
  <a href="https://github.com/mobily">
51
54
  <img src="https://avatars.githubusercontent.com/u/1467712?v=4" height="70px" width="70px" alt="mobily" />
52
55
  </a>
@@ -62,8 +65,17 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
62
65
  <a href="https://github.com/oscklm">
63
66
  <img src="https://avatars.githubusercontent.com/u/22825865?v=4" height="70px" width="70px" alt="oscklm" />
64
67
  </a>
65
- <a href="https://github.com/giovannilondero">
66
- <img src="https://avatars.githubusercontent.com/u/10998991?v=4" height="70px" width="70px" alt="giovannilondero" />
68
+ <a href="https://github.com/guillaumehcht">
69
+ <img src="https://avatars.githubusercontent.com/u/80776475?v=4" height="70px" width="70px" alt="guillaumehcht" />
70
+ </a>
71
+ <a href="https://github.com/FilipiRafael">
72
+ <img src="https://avatars.githubusercontent.com/u/61629642?v=4" height="70px" width="70px" alt="FilipiRafael" />
73
+ </a>
74
+ <a href="https://github.com/4cc3ssX">
75
+ <img src="https://avatars.githubusercontent.com/u/57473799?v=4" height="70px" width="70px" alt="4cc3ssX" />
76
+ </a>
77
+ <a href="https://github.com/dacoto97">
78
+ <img src="https://avatars.githubusercontent.com/u/16915053?v=4" height="70px" width="70px" alt="dacoto97" />
67
79
  </a>
68
80
 
69
81
  ## Past sponsors
@@ -89,6 +101,9 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
89
101
  <a href="https://github.com/hyoban">
90
102
  <img src="https://avatars.githubusercontent.com/u/38493346?v=4" height="70px" width="70px" alt="hyoban" />
91
103
  </a>
104
+ <a href="https://github.com/giovannilondero">
105
+ <img src="https://avatars.githubusercontent.com/u/10998991?v=4" height="70px" width="70px" alt="giovannilondero" />
106
+ </a>
92
107
 
93
108
  ## Sponsor my work
94
109
 
@@ -23,7 +23,7 @@ include_directories(
23
23
  ../cxx/shadowTree
24
24
  )
25
25
 
26
- string(APPEND CMAKE_CXX_FLAGS "-DFOLLY_NO_CONFIG=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_MOBILE=1")
26
+ string(APPEND CMAKE_CXX_FLAGS " -DFOLLY_NO_CONFIG=1 -DFOLLY_CFG_NO_COROUTINES=1 -DFOLLY_MOBILE=1")
27
27
 
28
28
  set_target_properties(unistyles PROPERTIES
29
29
  CXX_STANDARD 20
@@ -37,7 +37,7 @@ jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindings
37
37
  auto& uiManager = jobj->cthis()->_uiManager;
38
38
  auto& nativePlatform = jobj->cthis()->_nativePlatform;
39
39
 
40
- return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, uiManager, nativePlatform](jsi::Runtime& rt) {
40
+ return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, &uiManager, &nativePlatform](jsi::Runtime& rt) {
41
41
  // function is called on: first init and every live reload
42
42
  // check if this is live reload, if so let's replace UnistylesRuntime with new runtime
43
43
  auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
@@ -6,11 +6,13 @@ import android.os.Build
6
6
  import android.util.DisplayMetrics
7
7
  import android.view.View
8
8
  import android.view.WindowManager
9
+ import androidx.annotation.Keep
9
10
  import androidx.core.text.TextUtilsCompat
10
11
  import androidx.core.view.ViewCompat
11
12
  import androidx.core.view.WindowCompat
12
13
  import androidx.core.view.WindowInsetsCompat
13
14
  import androidx.core.view.WindowInsetsControllerCompat
15
+ import com.facebook.proguard.annotations.DoNotStrip
14
16
  import com.facebook.react.bridge.LifecycleEventListener
15
17
  import com.facebook.react.bridge.ReactApplicationContext
16
18
  import com.margelo.nitro.unistyles.ColorScheme
@@ -22,6 +24,8 @@ import com.margelo.nitro.unistyles.UnistyleDependency
22
24
  import com.margelo.nitro.unistyles.UnistylesNativeMiniRuntime
23
25
  import java.util.Locale
24
26
 
27
+ @Keep
28
+ @DoNotStrip
25
29
  class NativePlatformAndroid(private val reactContext: ReactApplicationContext): HybridNativePlatformSpec(), LifecycleEventListener {
26
30
  private val _insets = NativePlatformInsets(reactContext, this::getMiniRuntime) { this.diffMiniRuntime() }
27
31
  private var _miniRuntime: UnistylesNativeMiniRuntime = buildMiniRuntime()
@@ -32,9 +36,8 @@ class NativePlatformAndroid(private val reactContext: ReactApplicationContext):
32
36
  reactContext.addLifecycleEventListener(this)
33
37
  }
34
38
 
35
- fun invalidate() {
39
+ fun onDestroy() {
36
40
  reactContext.removeLifecycleEventListener(this)
37
- _listener.invalidate()
38
41
  }
39
42
 
40
43
  override fun onHostResume() {
@@ -5,9 +5,11 @@ import android.os.Build
5
5
  import android.view.View
6
6
  import android.view.Window
7
7
  import android.view.WindowManager
8
+ import androidx.annotation.Keep
8
9
  import androidx.core.view.ViewCompat
9
10
  import androidx.core.view.WindowInsetsAnimationCompat
10
11
  import androidx.core.view.WindowInsetsCompat
12
+ import com.facebook.proguard.annotations.DoNotStrip
11
13
  import com.facebook.react.bridge.ReactApplicationContext
12
14
  import com.margelo.nitro.unistyles.Insets
13
15
  import com.margelo.nitro.unistyles.UnistyleDependency
@@ -15,6 +17,8 @@ import com.margelo.nitro.unistyles.UnistylesNativeMiniRuntime
15
17
 
16
18
  typealias CxxImeListener = (miniRuntime: UnistylesNativeMiniRuntime) -> Unit
17
19
 
20
+ @Keep
21
+ @DoNotStrip
18
22
  class NativePlatformInsets(
19
23
  private val reactContext: ReactApplicationContext,
20
24
  private val getMiniRuntime: () -> UnistylesNativeMiniRuntime,
@@ -23,6 +27,21 @@ class NativePlatformInsets(
23
27
  private val _imeListeners: MutableList<CxxImeListener> = mutableListOf()
24
28
  private var _insets: Insets = Insets(0.0, 0.0, 0.0, 0.0, 0.0)
25
29
 
30
+ init {
31
+ // get initial insets
32
+ reactContext.currentActivity?.let { activity ->
33
+ val insets = ViewCompat.getRootWindowInsets(activity.window.decorView)
34
+
35
+ insets?.let { windowInsets ->
36
+ setInsets(windowInsets, activity.window, null, true)
37
+ }
38
+ }
39
+ }
40
+
41
+ fun onDestroy() {
42
+ this.removeImeListeners()
43
+ }
44
+
26
45
  fun getInsets(): Insets {
27
46
  val density = reactContext.resources.displayMetrics.density
28
47
 
@@ -35,7 +54,7 @@ class NativePlatformInsets(
35
54
  )
36
55
  }
37
56
 
38
- fun setInsets(insetsCompat: WindowInsetsCompat, window: Window, animatedBottomInsets: Double?) {
57
+ fun setInsets(insetsCompat: WindowInsetsCompat, window: Window, animatedBottomInsets: Double?, skipUpdate: Boolean = false) {
39
58
  // below Android 11, we need to use window flags to detect status bar visibility
40
59
  val isStatusBarVisible = when(Build.VERSION.SDK_INT) {
41
60
  in 30..Int.MAX_VALUE -> {
@@ -82,6 +101,10 @@ class NativePlatformInsets(
82
101
  imeInsets
83
102
  )
84
103
 
104
+ if (skipUpdate) {
105
+ return
106
+ }
107
+
85
108
  diffMiniRuntime()
86
109
 
87
110
  if (shouldEmitImeEvent) {
@@ -6,12 +6,16 @@ import android.content.Intent
6
6
  import android.content.IntentFilter
7
7
  import android.os.Handler
8
8
  import android.os.Looper
9
+ import androidx.annotation.Keep
10
+ import com.facebook.proguard.annotations.DoNotStrip
9
11
  import com.facebook.react.bridge.ReactApplicationContext
10
12
  import com.margelo.nitro.unistyles.UnistyleDependency
11
13
  import com.margelo.nitro.unistyles.UnistylesNativeMiniRuntime
12
14
 
13
15
  typealias CxxDependencyListener = (dependencies: Array<UnistyleDependency>, miniRuntime: UnistylesNativeMiniRuntime) -> Unit
14
16
 
17
+ @Keep
18
+ @DoNotStrip
15
19
  class NativePlatformListener(
16
20
  private val reactContext: ReactApplicationContext,
17
21
  private val getMiniRuntime: () -> UnistylesNativeMiniRuntime,
@@ -31,7 +35,8 @@ class NativePlatformListener(
31
35
  reactContext.registerReceiver(configurationChangeReceiver, IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED))
32
36
  }
33
37
 
34
- fun invalidate() {
38
+ fun onDestroy() {
39
+ this.removePlatformListeners()
35
40
  reactContext.unregisterReceiver(configurationChangeReceiver)
36
41
  }
37
42
 
@@ -11,6 +11,7 @@ import com.facebook.react.turbomodule.core.interfaces.TurboModuleWithJSIBindings
11
11
  import com.facebook.react.uimanager.UIManagerHelper
12
12
  import com.facebook.react.uimanager.common.UIManagerType
13
13
  import com.margelo.nitro.unistyles.HybridNativePlatformSpec
14
+ import com.margelo.nitro.unistyles.unistylesOnLoad.Companion.initializeNative
14
15
 
15
16
  @Suppress("KotlinJniMissingFunction")
16
17
  class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistylesSpec(reactContext), TurboModuleWithJSIBindings {
@@ -20,16 +21,16 @@ class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistyl
20
21
 
21
22
  companion object {
22
23
  const val NAME = NativeTurboUnistylesSpec.NAME
24
+
25
+ init {
26
+ initializeNative()
27
+ }
23
28
  }
24
29
 
25
30
  init {
26
31
  mHybridData = initializeHybridData(reactContext)
27
32
  }
28
33
 
29
- override fun invalidate() {
30
- _nativePlatform.invalidate()
31
- }
32
-
33
34
  private fun initializeHybridData(reactContext: ReactApplicationContext): HybridData {
34
35
  val runtimeExecutor = reactContext.catalystInstance?.runtimeExecutor
35
36
  ?: throw IllegalStateException("Unistyles: React Native runtime executor is not available. Please follow installation guides.")
@@ -1,12 +1,12 @@
1
1
  package com.unistyles
2
2
 
3
- import com.facebook.react.TurboReactPackage
3
+ import com.facebook.react.BaseReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.module.model.ReactModuleInfo
7
7
  import com.facebook.react.module.model.ReactModuleInfoProvider
8
8
 
9
- class UnistylesPackage: TurboReactPackage() {
9
+ class UnistylesPackage: BaseReactPackage() {
10
10
  override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
11
11
  return if (name == UnistylesModule.NAME) {
12
12
  UnistylesModule(reactContext)
@@ -20,10 +20,10 @@ class UnistylesPackage: TurboReactPackage() {
20
20
  mapOf(UnistylesModule.NAME to ReactModuleInfo(
21
21
  UnistylesModule.NAME,
22
22
  UnistylesModule.NAME,
23
- _canOverrideExistingModule = true,
24
- _needsEagerInit = true,
25
- isCxxModule = true,
26
- isTurboModule = true
23
+ true,
24
+ true,
25
+ true,
26
+ true
27
27
  ))
28
28
  }
29
29
  }
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../../lib/commonjs/components/native/Animated.js",
3
+ "module": "../../../lib/module/components/native/Animated.js",
4
+ "react-native": "../../../src/components/native/Animated.tsx"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../../lib/commonjs/components/native/NativeText.js",
3
+ "module": "../../../lib/module/components/native/NativeText.js",
4
+ "react-native": "../../../src/components/native/NativeText.native.tsx"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../../lib/commonjs/components/native/NativeView.js",
3
+ "module": "../../../lib/module/components/native/NativeView.js",
4
+ "react-native": "../../../src/components/native/NativeView.native.tsx"
5
+ }
@@ -17,7 +17,7 @@ std::string HashGenerator::generateHash(const std::string& input) {
17
17
  std::stringstream ss;
18
18
  ss << std::hex << std::setfill('0') << std::setw(8) << (combinedHash & 0xFFFFFFFF);
19
19
 
20
- return "unistyles-" + ss.str();
20
+ return "unistyles_" + ss.str();
21
21
  }
22
22
 
23
23
  }
@@ -39,14 +39,40 @@ jsi::Value HostUnistyle::get(jsi::Runtime& rt, const jsi::PropNameID& propNameId
39
39
  auto& unistyle = this->_stylesheet->unistyles[propertyName];
40
40
 
41
41
  // check if Unistyles recomputed new style in the background
42
- // ()when no node was mounted), if so we need to simply rebuild unistyle to get fresh data
42
+ // (when no node was mounted), if so we need to simply rebuild unistyle to get fresh data
43
43
  if (unistyle->isDirty) {
44
+ this->_cache.erase(propertyName);
45
+
44
46
  auto parser = parser::Parser(this->_unistylesRuntime);
45
47
 
46
48
  parser.rebuildUnistyle(rt, unistyle, this->_variants, std::nullopt);
47
49
  }
48
50
 
49
- return valueFromUnistyle(rt, this->_unistylesRuntime, this->_stylesheet->unistyles[propertyName], this->_variants);
51
+ if (unistyle->type == UnistyleType::DynamicFunction) {
52
+ // for dynamic functions we will also bind "this"
53
+ auto styleFn = valueFromUnistyle(rt, this->_unistylesRuntime, unistyle, this->_variants);
54
+
55
+ // construct newThis
56
+ jsi::Object newThis = jsi::Object(rt);
57
+ newThis.setProperty(rt, helpers::STYLESHEET_VARIANTS.c_str(), helpers::variantsToValue(rt, this->_variants));
58
+
59
+ auto functionPrototype = rt.global()
60
+ .getPropertyAsObject(rt, "Function")
61
+ .getPropertyAsObject(rt, "prototype")
62
+ .getPropertyAsFunction(rt, "bind");
63
+
64
+ return functionPrototype.callWithThis(rt, styleFn.asObject(rt), newThis);
65
+ }
66
+
67
+ if (this->_cache.contains(propertyName)) {
68
+ return jsi::Value(rt, this->_cache[propertyName]);
69
+ }
70
+
71
+ auto style = valueFromUnistyle(rt, this->_unistylesRuntime, unistyle, this->_variants);
72
+
73
+ this->_cache.emplace(propertyName, jsi::Value(rt, style));
74
+
75
+ return style;
50
76
  }
51
77
 
52
78
  void HostUnistyle::set(jsi::Runtime& rt, const jsi::PropNameID& propNameId, const jsi::Value& value) {}
@@ -73,8 +99,6 @@ jsi::Function HostUnistyle::createAddVariantsProxyFunction(jsi::Runtime& rt) {
73
99
  }
74
100
  });
75
101
 
76
- this->_variants = variants;
77
-
78
102
  auto style = std::make_shared<core::HostUnistyle>(this->_stylesheet, this->_unistylesRuntime, variants);
79
103
  auto styleHostObject = jsi::Object::createFromHostObject(rt, style);
80
104
 
@@ -22,6 +22,7 @@ private:
22
22
  Variants _variants;
23
23
  std::shared_ptr<StyleSheet> _stylesheet;
24
24
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
25
+ std::unordered_map<std::string, jsi::Value> _cache;
25
26
  };
26
27
 
27
28
  }
@@ -54,6 +54,10 @@ struct Unistyle {
54
54
  inline bool dependsOn(UnistyleDependency dependency) {
55
55
  return std::find(this->dependencies.begin(), this->dependencies.end(), dependency) != this->dependencies.end();
56
56
  }
57
+
58
+ inline bool isSealed() {
59
+ return this->_isSealed;
60
+ }
57
61
 
58
62
  inline void seal() {
59
63
  this->_isSealed = true;
@@ -35,7 +35,7 @@ inline static Unistyle::Shared unistyleFromStaticStyleSheet(jsi::Runtime& rt, js
35
35
 
36
36
  inline static std::vector<std::string> getUnistylesHashKeys(jsi::Runtime& rt, jsi::Object& object) {
37
37
  std::vector<std::string> matchingKeys{};
38
- const std::string prefix = "unistyles-";
38
+ const std::string prefix = "unistyles_";
39
39
 
40
40
  auto propertyNames = object.getPropertyNames(rt);
41
41
  size_t length = propertyNames.length(rt);
@@ -82,13 +82,13 @@ inline static std::vector<Unistyle::Shared> unistylesFromNonExistentNativeState(
82
82
 
83
83
  You likely altered unistyle hash key and we're not able to recover C++ state attached to this node.)");
84
84
  }
85
-
85
+
86
86
  // someone merged unistyles, and will be warned in JS
87
87
  // the best we can do is to return first unistyle
88
88
  if (unistyles.size() > 1) {
89
89
  return {unistyles.at(0)};
90
90
  }
91
-
91
+
92
92
  return unistyles;
93
93
  }
94
94
 
@@ -137,7 +137,7 @@ inline static jsi::Value objectFromUnistyle(jsi::Runtime& rt, std::shared_ptr<Hy
137
137
  auto parsedArguments = arguments.has_value()
138
138
  ? helpers::parseDynamicFunctionArguments(rt, arguments.value())
139
139
  : std::optional<std::vector<folly::dynamic>>{};
140
-
140
+
141
141
  if (arguments.has_value()) {
142
142
  // this is required for HybridShadowRegistry::link
143
143
  helpers::defineHiddenProperty(rt, secrets, helpers::ARGUMENTS.c_str(), arguments.value());
@@ -148,7 +148,7 @@ inline static jsi::Value objectFromUnistyle(jsi::Runtime& rt, std::shared_ptr<Hy
148
148
 
149
149
  // this is required for withUnistyles
150
150
  helpers::defineHiddenProperty(rt, secrets, helpers::STYLE_DEPENDENCIES.c_str(), helpers::dependenciesToJSIArray(rt, unistyle->dependencies));
151
-
151
+
152
152
  // this is required for withUnistyles
153
153
  auto hostFn = jsi::Function::createFromHostFunction(
154
154
  rt,
@@ -160,7 +160,7 @@ inline static jsi::Value objectFromUnistyle(jsi::Runtime& rt, std::shared_ptr<Hy
160
160
 
161
161
  return jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
162
162
  });
163
-
163
+
164
164
  helpers::defineHiddenProperty(rt, secrets, helpers::GET_STYLES.c_str(), std::move(hostFn));
165
165
 
166
166
  obj.setProperty(rt, unistyleID, secrets);
@@ -86,6 +86,27 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
86
86
  this->trafficController.resumeUnistylesTraffic();
87
87
  }
88
88
 
89
+ void core::UnistylesRegistry::removeDuplicatedUnistyles(jsi::Runtime& rt, const ShadowNodeFamily *shadowNodeFamily, std::vector<core::Unistyle::Shared>& unistyles) {
90
+ auto targetFamilyUnistyles = this->_shadowRegistry[&rt][shadowNodeFamily];
91
+
92
+ unistyles.erase(
93
+ std::remove_if(
94
+ unistyles.begin(),
95
+ unistyles.end(),
96
+ [&targetFamilyUnistyles](const core::Unistyle::Shared& unistyle) {
97
+ return std::any_of(
98
+ targetFamilyUnistyles.begin(),
99
+ targetFamilyUnistyles.end(),
100
+ [&unistyle](const std::shared_ptr<core::UnistyleData>& data) {
101
+ return data->unistyle == unistyle;
102
+ }
103
+ );
104
+ }
105
+ ),
106
+ unistyles.end()
107
+ );
108
+ }
109
+
89
110
  void core::UnistylesRegistry::unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily* shadowNodeFamily) {
90
111
  this->_shadowRegistry[&rt].erase(shadowNodeFamily);
91
112
  this->trafficController.removeShadowNode(shadowNodeFamily);
@@ -201,16 +222,16 @@ std::vector<std::shared_ptr<core::StyleSheet>> core::UnistylesRegistry::getStyle
201
222
  core::Unistyle::Shared core::UnistylesRegistry::getUnistyleById(jsi::Runtime& rt, std::string unistyleID) {
202
223
  for (auto& pair: this->_styleSheetRegistry[&rt]) {
203
224
  auto [_, stylesheet] = pair;
204
-
225
+
205
226
  for (auto unistylePair: stylesheet->unistyles) {
206
227
  auto [_, unistyle] = unistylePair;
207
-
228
+
208
229
  if (unistyle->unid == unistyleID) {
209
230
  return unistyle;
210
231
  }
211
232
  }
212
233
  }
213
-
234
+
214
235
  return nullptr;
215
236
  }
216
237
 
@@ -27,6 +27,8 @@ struct UnistylesRegistry: public StyleSheetRegistry {
27
27
 
28
28
  UnistylesRegistry(const UnistylesRegistry&) = delete;
29
29
  UnistylesRegistry(const UnistylesRegistry&&) = delete;
30
+
31
+ bool shouldUsePointsForBreakpoints = false;
30
32
 
31
33
  void registerTheme(jsi::Runtime& rt, std::string name, jsi::Value& theme);
32
34
  void registerBreakpoints(jsi::Runtime& rt, std::vector<std::pair<std::string, double>>& sortedBreakpoints);
@@ -44,6 +46,7 @@ struct UnistylesRegistry: public StyleSheetRegistry {
44
46
  void shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Value& maybePressableId);
45
47
  shadow::ShadowTrafficController trafficController{};
46
48
  const std::optional<std::string> getScopedTheme();
49
+ void removeDuplicatedUnistyles(jsi::Runtime& rt, const ShadowNodeFamily* shadowNodeFamily, std::vector<core::Unistyle::Shared>& unistyles);
47
50
  void setScopedTheme(std::optional<std::string> themeName);
48
51
  core::Unistyle::Shared getUnistyleById(jsi::Runtime& rt, std::string unistyleID);
49
52
 
@@ -12,6 +12,13 @@ jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisVa
12
12
  std::vector<std::vector<folly::dynamic>> arguments;
13
13
  auto& registry = core::UnistylesRegistry::get();
14
14
 
15
+ // this is special case for Animated, and prevents appending same unistyles to node
16
+ registry.removeDuplicatedUnistyles(rt, &shadowNodeWrapper->getFamily(), unistyleWrappers);
17
+
18
+ if (unistyleWrappers.empty()) {
19
+ return jsi::Value::undefined();
20
+ }
21
+
15
22
  for (size_t i = 0; i < unistyleWrappers.size(); i++) {
16
23
  if (unistyleWrappers[i]->type == core::UnistyleType::DynamicFunction) {
17
24
  try {
@@ -127,6 +127,20 @@ void HybridStyleSheet::parseSettings(jsi::Runtime &rt, jsi::Object settings) {
127
127
  if (propertyName == "CSSVars") {
128
128
  return;
129
129
  }
130
+
131
+ if (propertyName == "nativeBreakpointsMode") {
132
+ helpers::assertThat(rt, propertyValue.isString(), "StyleSheet.configure's nativeBreakpointsMode must be a string");
133
+
134
+ auto mode = propertyValue.asString(rt).utf8(rt);
135
+
136
+ helpers::assertThat(rt, mode == "pixels" || mode == "points", "StyleSheet.configure's nativeBreakpointsMode must be one of: pixels or points");
137
+
138
+ if (mode == "points") {
139
+ registry.shouldUsePointsForBreakpoints = true;
140
+ }
141
+
142
+ return;
143
+ }
130
144
 
131
145
  helpers::assertThat(rt, false, "StyleSheet.configure's settings received unexpected key: '" + std::string(propertyName) + "'");
132
146
  });
@@ -142,7 +156,13 @@ void HybridStyleSheet::parseBreakpoints(jsi::Runtime &rt, jsi::Object breakpoint
142
156
  auto& state = registry.getState(rt);
143
157
 
144
158
  registry.registerBreakpoints(rt, sortedBreakpoints);
145
- state.computeCurrentBreakpoint(this->_unistylesRuntime->getScreen().width);
159
+
160
+ auto rawWidth = this->_unistylesRuntime->getScreen().width;
161
+ auto width = registry.shouldUsePointsForBreakpoints
162
+ ? rawWidth / this->_unistylesRuntime->getPixelRatio()
163
+ : rawWidth;
164
+
165
+ state.computeCurrentBreakpoint(width);
146
166
  }
147
167
 
148
168
  void HybridStyleSheet::parseThemes(jsi::Runtime &rt, jsi::Object themes) {
@@ -293,7 +313,12 @@ void HybridStyleSheet::onPlatformNativeDependenciesChange(std::vector<UnistyleDe
293
313
  auto dimensionsIt = std::find(dependencies.begin(), dependencies.end(), UnistyleDependency::DIMENSIONS);
294
314
 
295
315
  if (dimensionsIt != dependencies.end()) {
296
- registry.getState(rt).computeCurrentBreakpoint(this->_unistylesRuntime->getScreen().width);
316
+ auto rawWidth = this->_unistylesRuntime->getScreen().width;
317
+ auto width = registry.shouldUsePointsForBreakpoints
318
+ ? rawWidth / this->_unistylesRuntime->getPixelRatio()
319
+ : rawWidth;
320
+
321
+ registry.getState(rt).computeCurrentBreakpoint(width);
297
322
  }
298
323
 
299
324
  // check if color scheme changed and then if Unistyles state depend on it (adaptive themes)
@@ -18,7 +18,7 @@ void parser::Parser::buildUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet
18
18
 
19
19
  if (styleValue.isFunction(rt)) {
20
20
  styleSheet->unistyles[styleKey] = std::make_shared<UnistyleDynamicFunction>(
21
- helpers::HashGenerator::generateHash(styleKey),
21
+ helpers::HashGenerator::generateHash(styleKey + std::to_string(styleSheet->tag)),
22
22
  UnistyleType::DynamicFunction,
23
23
  styleKey,
24
24
  styleValue,
@@ -29,7 +29,7 @@ void parser::Parser::buildUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet
29
29
  }
30
30
 
31
31
  styleSheet->unistyles[styleKey] = std::make_shared<Unistyle>(
32
- helpers::HashGenerator::generateHash(styleKey),
32
+ helpers::HashGenerator::generateHash(styleKey + std::to_string(styleSheet->tag)),
33
33
  UnistyleType::Object,
34
34
  styleKey,
35
35
  styleValue,
@@ -361,7 +361,7 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle
361
361
  unistyleFn->unprocessedValue = std::move(functionResult);
362
362
  unistyleFn->parsedStyle = this->parseFirstLevel(rt, unistyleFn, variants);
363
363
  }
364
-
364
+
365
365
  if (unistyle->isDirty) {
366
366
  unistyle->isDirty = false;
367
367
  }
@@ -399,8 +399,10 @@ jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared u
399
399
 
400
400
  helpers::enumerateJSIObject(rt, style, [&](const std::string& propertyName, jsi::Value& propertyValue){
401
401
  // parse dependencies only once
402
- if (propertyName == helpers::STYLE_DEPENDENCIES && unistyle->dependencies.empty()) {
403
- unistyle->dependencies = this->parseDependencies(rt, propertyValue.asObject(rt));
402
+ if (propertyName == helpers::STYLE_DEPENDENCIES && !unistyle->isSealed()) {
403
+ auto newDeps = this->parseDependencies(rt, propertyValue.asObject(rt));
404
+
405
+ unistyle->dependencies.insert(unistyle->dependencies.end(), newDeps.begin(), newDeps.end());
404
406
 
405
407
  return;
406
408
  }
@@ -524,7 +526,7 @@ jsi::Function parser::Parser::createDynamicFunctionProxy(jsi::Runtime& rt, Unist
524
526
 
525
527
  Variants variants = helpers::variantsToPairs(rt, rawVariants.asObject(rt));
526
528
 
527
- unistyleFn->parsedStyle = this->parseFirstLevel(rt, unistyleFn, variants);
529
+ unistyleFn->parsedStyle = parser.parseFirstLevel(rt, unistyleFn, variants);
528
530
  unistyleFn->seal();
529
531
 
530
532
  // for compatibility purpose save last arguments to style instance. It will work ok, if user sees warning about multiple unistyles
@@ -651,7 +653,11 @@ jsi::Value parser::Parser::getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::S
651
653
  auto sortedBreakpoints = state.getSortedBreakpointPairs();
652
654
  auto hasBreakpoints = !sortedBreakpoints.empty();
653
655
  auto currentBreakpoint = state.getCurrentBreakpointName();
654
- auto dimensions = this->_unistylesRuntime->getScreen();
656
+ auto rawDimensions = this->_unistylesRuntime->getScreen();
657
+ auto pixelRatio = this->_unistylesRuntime->getPixelRatio();
658
+ auto dimensions = registry.shouldUsePointsForBreakpoints
659
+ ? Dimensions(rawDimensions.width / pixelRatio, rawDimensions.height / pixelRatio)
660
+ : rawDimensions;
655
661
  auto currentOrientation = dimensions.width > dimensions.height
656
662
  ? "landscape"
657
663
  : "portrait";
@@ -114,6 +114,12 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
114
114
  func getScreenDimensionsFn() -> Dimensions {
115
115
  guard let presentedViewController = RCTPresentedViewController(),
116
116
  let windowFrame = presentedViewController.view.window?.frame else {
117
+
118
+ // when user goes to background RCTPresentedViewController is not available, try to get last known value
119
+ if let cachedRuntime = self.miniRuntime, UIApplication.shared.applicationState == .background {
120
+ return cachedRuntime.screen;
121
+ }
122
+
117
123
  // this should never happen, but it's better to return zeros
118
124
  return Dimensions(width: 0, height: 0)
119
125
  }
@@ -137,10 +143,10 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
137
143
  let screenDimensions = getScreenDimensions()
138
144
 
139
145
  if (screenDimensions.width > screenDimensions.height) {
140
- return Orientation.landscape;
146
+ return Orientation.landscape
141
147
  }
142
148
 
143
- return Orientation.portrait;
149
+ return Orientation.portrait
144
150
  }
145
151
 
146
152
  func getContentSizeCategory() -> String {
@@ -268,8 +274,14 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
268
274
  func getPixelRatioFn() -> Double {
269
275
  guard let presentedViewController = RCTPresentedViewController(),
270
276
  let window = presentedViewController.view.window else {
277
+
278
+ // when user goes to background RCTPresentedViewController is not available, try to get last known value
279
+ if let cachedRuntime = self.miniRuntime, UIApplication.shared.applicationState == .background {
280
+ return cachedRuntime.pixelRatio;
281
+ }
282
+
271
283
  // this should never happen, but it's better to return default
272
- return 1;
284
+ return 1
273
285
  }
274
286
 
275
287
  return window.screen.scale
@@ -297,7 +309,7 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
297
309
  }
298
310
 
299
311
  func getNavigationBarDimensions() -> Dimensions {
300
- return Dimensions(width: 0, height: 0);
312
+ return Dimensions(width: 0, height: 0)
301
313
  }
302
314
 
303
315
  func setStatusBarHidden(isHidden: Bool) throws {