react-native-unistyles 3.0.0-rc.3 → 3.0.0-rc.5

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 (318) hide show
  1. package/README.md +10 -8
  2. package/android/src/main/cxx/NativeUnistylesModule.cpp +3 -7
  3. package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
  4. package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -7
  5. package/cxx/core/UnistyleWrapper.h +4 -1
  6. package/cxx/core/UnistylesCommitShadowNode.h +0 -21
  7. package/cxx/core/UnistylesRegistry.cpp +45 -49
  8. package/cxx/core/UnistylesState.cpp +10 -0
  9. package/cxx/core/UnistylesState.h +3 -0
  10. package/cxx/hybridObjects/HybridShadowRegistry.cpp +6 -1
  11. package/cxx/hybridObjects/HybridShadowRegistry.h +6 -0
  12. package/cxx/hybridObjects/HybridStyleSheet.cpp +13 -16
  13. package/cxx/hybridObjects/HybridStyleSheet.h +2 -7
  14. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +8 -0
  15. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
  16. package/cxx/parser/Parser.cpp +175 -110
  17. package/cxx/parser/Parser.h +1 -0
  18. package/cxx/shadowTree/ShadowTreeManager.cpp +36 -33
  19. package/cxx/shadowTree/ShadowTreeManager.h +0 -1
  20. package/ios/UnistylesModuleOnLoad.h +1 -5
  21. package/ios/UnistylesModuleOnLoad.mm +5 -13
  22. package/lib/commonjs/components/AdaptiveTheme.js +35 -0
  23. package/lib/commonjs/components/AdaptiveTheme.js.map +1 -0
  24. package/lib/commonjs/components/ApplyScopedTheme.js +19 -0
  25. package/lib/commonjs/components/ApplyScopedTheme.js.map +1 -0
  26. package/lib/commonjs/components/NamedTheme.js +31 -0
  27. package/lib/commonjs/components/NamedTheme.js.map +1 -0
  28. package/lib/commonjs/components/ScopedTheme.js +24 -20
  29. package/lib/commonjs/components/ScopedTheme.js.map +1 -1
  30. package/lib/commonjs/components/native/Image.js +1 -2
  31. package/lib/commonjs/components/native/Image.js.map +1 -1
  32. package/lib/commonjs/components/native/ImageBackground.js +1 -2
  33. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  34. package/lib/commonjs/components/native/Pressable.js +1 -2
  35. package/lib/commonjs/components/native/Pressable.js.map +1 -1
  36. package/lib/commonjs/components/native/Pressable.native.js +1 -2
  37. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  38. package/lib/commonjs/core/createUnistylesElement.js +3 -3
  39. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  40. package/lib/commonjs/core/createUnistylesElement.native.js +18 -31
  41. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  42. package/lib/commonjs/core/createUnistylesImageBackground.js +6 -21
  43. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  44. package/lib/commonjs/core/getClassname.js +1 -2
  45. package/lib/commonjs/core/getClassname.js.map +1 -1
  46. package/lib/commonjs/core/parseBoxShadow.js +57 -0
  47. package/lib/commonjs/core/parseBoxShadow.js.map +1 -0
  48. package/lib/commonjs/core/useProxifiedUnistyles/listener.js +1 -2
  49. package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
  50. package/lib/commonjs/core/withUnistyles/withUnistyles.js +1 -2
  51. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  52. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +1 -2
  53. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  54. package/lib/commonjs/index.js +6 -0
  55. package/lib/commonjs/index.js.map +1 -1
  56. package/lib/commonjs/mocks.js +5 -2
  57. package/lib/commonjs/mocks.js.map +1 -1
  58. package/lib/commonjs/reanimated/index.js +20 -0
  59. package/lib/commonjs/reanimated/index.js.map +1 -0
  60. package/lib/commonjs/reanimated/useAnimatedTheme.js +22 -0
  61. package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -0
  62. package/lib/commonjs/reanimated/useAnimatedTheme.native.js +24 -0
  63. package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -0
  64. package/lib/commonjs/reanimated/variant/index.js +17 -0
  65. package/lib/commonjs/reanimated/variant/index.js.map +1 -0
  66. package/lib/commonjs/reanimated/variant/types.js +2 -0
  67. package/lib/commonjs/reanimated/variant/types.js.map +1 -0
  68. package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js +38 -0
  69. package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
  70. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js +66 -0
  71. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -0
  72. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +39 -0
  73. package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
  74. package/lib/commonjs/server/getServerUnistyles.js +1 -2
  75. package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
  76. package/lib/commonjs/server/hydrateServerUnistyles.js +1 -2
  77. package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
  78. package/lib/commonjs/server/resetServerUnistyles.js +1 -2
  79. package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
  80. package/lib/commonjs/specs/ShadowRegistry/index.js +6 -1
  81. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  82. package/lib/commonjs/specs/StyleSheet/index.js +3 -1
  83. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  84. package/lib/commonjs/utils.js +0 -3
  85. package/lib/commonjs/utils.js.map +1 -1
  86. package/lib/commonjs/web/create.js +2 -3
  87. package/lib/commonjs/web/create.js.map +1 -1
  88. package/lib/commonjs/web/css/core.js +6 -1
  89. package/lib/commonjs/web/css/core.js.map +1 -1
  90. package/lib/commonjs/web/css/state.js +10 -7
  91. package/lib/commonjs/web/css/state.js.map +1 -1
  92. package/lib/commonjs/web/index.js +1 -2
  93. package/lib/commonjs/web/index.js.map +1 -1
  94. package/lib/commonjs/web/listener.js +2 -0
  95. package/lib/commonjs/web/listener.js.map +1 -1
  96. package/lib/commonjs/web/runtime.js +15 -1
  97. package/lib/commonjs/web/runtime.js.map +1 -1
  98. package/lib/commonjs/web/shadowRegistry.js +12 -4
  99. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  100. package/lib/commonjs/web/state.js +1 -10
  101. package/lib/commonjs/web/state.js.map +1 -1
  102. package/lib/commonjs/web/types.js +2 -0
  103. package/lib/commonjs/web/types.js.map +1 -1
  104. package/lib/commonjs/web/utils/createUnistylesRef.js +1 -2
  105. package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
  106. package/lib/commonjs/web/utils/unistyle.js +30 -3
  107. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  108. package/lib/commonjs/web-only/getWebProps.js +19 -0
  109. package/lib/commonjs/web-only/getWebProps.js.map +1 -0
  110. package/lib/commonjs/web-only/index.js +13 -0
  111. package/lib/commonjs/web-only/index.js.map +1 -0
  112. package/lib/module/components/AdaptiveTheme.js +29 -0
  113. package/lib/module/components/AdaptiveTheme.js.map +1 -0
  114. package/lib/module/components/ApplyScopedTheme.js +14 -0
  115. package/lib/module/components/ApplyScopedTheme.js.map +1 -0
  116. package/lib/module/components/NamedTheme.js +25 -0
  117. package/lib/module/components/NamedTheme.js.map +1 -0
  118. package/lib/module/components/ScopedTheme.js +24 -19
  119. package/lib/module/components/ScopedTheme.js.map +1 -1
  120. package/lib/module/core/createUnistylesElement.js +3 -3
  121. package/lib/module/core/createUnistylesElement.js.map +1 -1
  122. package/lib/module/core/createUnistylesElement.native.js +18 -30
  123. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  124. package/lib/module/core/createUnistylesImageBackground.js +5 -19
  125. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  126. package/lib/module/core/parseBoxShadow.js +52 -0
  127. package/lib/module/core/parseBoxShadow.js.map +1 -0
  128. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  129. package/lib/module/index.js +5 -0
  130. package/lib/module/index.js.map +1 -1
  131. package/lib/module/mocks.js +5 -2
  132. package/lib/module/mocks.js.map +1 -1
  133. package/lib/module/reanimated/index.js +5 -0
  134. package/lib/module/reanimated/index.js.map +1 -0
  135. package/lib/module/reanimated/useAnimatedTheme.js +17 -0
  136. package/lib/module/reanimated/useAnimatedTheme.js.map +1 -0
  137. package/lib/module/reanimated/useAnimatedTheme.native.js +19 -0
  138. package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -0
  139. package/lib/module/reanimated/variant/index.js +4 -0
  140. package/lib/module/reanimated/variant/index.js.map +1 -0
  141. package/lib/module/reanimated/variant/types.js +2 -0
  142. package/lib/module/reanimated/variant/types.js.map +1 -0
  143. package/lib/module/reanimated/variant/useAnimatedVariantColor.js +33 -0
  144. package/lib/module/reanimated/variant/useAnimatedVariantColor.js.map +1 -0
  145. package/lib/module/reanimated/variant/useUpdateVariantColor.js +61 -0
  146. package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -0
  147. package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +34 -0
  148. package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -0
  149. package/lib/module/specs/ShadowRegistry/index.js +6 -1
  150. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  151. package/lib/module/specs/StyleSheet/index.js +3 -1
  152. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  153. package/lib/module/utils.js +0 -3
  154. package/lib/module/utils.js.map +1 -1
  155. package/lib/module/web/create.js +1 -1
  156. package/lib/module/web/create.js.map +1 -1
  157. package/lib/module/web/css/core.js +6 -1
  158. package/lib/module/web/css/core.js.map +1 -1
  159. package/lib/module/web/css/state.js +10 -7
  160. package/lib/module/web/css/state.js.map +1 -1
  161. package/lib/module/web/listener.js +2 -0
  162. package/lib/module/web/listener.js.map +1 -1
  163. package/lib/module/web/runtime.js +16 -2
  164. package/lib/module/web/runtime.js.map +1 -1
  165. package/lib/module/web/shadowRegistry.js +13 -5
  166. package/lib/module/web/shadowRegistry.js.map +1 -1
  167. package/lib/module/web/state.js +1 -10
  168. package/lib/module/web/state.js.map +1 -1
  169. package/lib/module/web/types.js +1 -1
  170. package/lib/module/web/types.js.map +1 -1
  171. package/lib/module/web/utils/unistyle.js +27 -2
  172. package/lib/module/web/utils/unistyle.js.map +1 -1
  173. package/lib/module/web-only/getWebProps.js +14 -0
  174. package/lib/module/web-only/getWebProps.js.map +1 -0
  175. package/lib/module/web-only/index.js +4 -0
  176. package/lib/module/web-only/index.js.map +1 -0
  177. package/lib/typescript/plugin/src/consts.d.ts +17 -0
  178. package/lib/typescript/plugin/src/consts.d.ts.map +1 -0
  179. package/lib/typescript/repack-plugin/src/index.d.ts +18 -0
  180. package/lib/typescript/repack-plugin/src/index.d.ts.map +1 -0
  181. package/lib/typescript/repack-plugin/src/loader.d.ts +9 -0
  182. package/lib/typescript/repack-plugin/src/loader.d.ts.map +1 -0
  183. package/lib/typescript/src/components/AdaptiveTheme.d.ts +8 -0
  184. package/lib/typescript/src/components/AdaptiveTheme.d.ts.map +1 -0
  185. package/lib/typescript/src/components/ApplyScopedTheme.d.ts +7 -0
  186. package/lib/typescript/src/components/ApplyScopedTheme.d.ts.map +1 -0
  187. package/lib/typescript/src/components/NamedTheme.d.ts +10 -0
  188. package/lib/typescript/src/components/NamedTheme.d.ts.map +1 -0
  189. package/lib/typescript/src/components/ScopedTheme.d.ts +4 -0
  190. package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
  191. package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
  192. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  193. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  194. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  195. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  196. package/lib/typescript/src/core/parseBoxShadow.d.ts +11 -0
  197. package/lib/typescript/src/core/parseBoxShadow.d.ts.map +1 -0
  198. package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -1
  199. package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -1
  200. package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
  201. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
  202. package/lib/typescript/src/core/warn.d.ts.map +1 -1
  203. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  204. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  205. package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
  206. package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -1
  207. package/lib/typescript/src/index.d.ts.map +1 -1
  208. package/lib/typescript/src/reanimated/index.d.ts +3 -0
  209. package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
  210. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts +4 -0
  211. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -0
  212. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts +4 -0
  213. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -0
  214. package/lib/typescript/src/reanimated/variant/index.d.ts +2 -0
  215. package/lib/typescript/src/reanimated/variant/index.d.ts.map +1 -0
  216. package/lib/typescript/src/reanimated/variant/types.d.ts +10 -0
  217. package/lib/typescript/src/reanimated/variant/types.d.ts.map +1 -0
  218. package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts +3 -0
  219. package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts.map +1 -0
  220. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts +6 -0
  221. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -0
  222. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts +6 -0
  223. package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -0
  224. package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
  225. package/lib/typescript/src/server/serialize.d.ts.map +1 -1
  226. package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
  227. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +1 -0
  228. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  229. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  230. package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -0
  231. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  232. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +2 -0
  233. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  234. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  235. package/lib/typescript/src/utils.d.ts.map +1 -1
  236. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  237. package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -1
  238. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
  239. package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -1
  240. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
  241. package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
  242. package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -1
  243. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -1
  244. package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -1
  245. package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
  246. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  247. package/lib/typescript/src/web/create.d.ts.map +1 -1
  248. package/lib/typescript/src/web/css/core.d.ts.map +1 -1
  249. package/lib/typescript/src/web/css/state.d.ts +2 -1
  250. package/lib/typescript/src/web/css/state.d.ts.map +1 -1
  251. package/lib/typescript/src/web/css/utils.d.ts.map +1 -1
  252. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  253. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  254. package/lib/typescript/src/web/runtime.d.ts +2 -0
  255. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  256. package/lib/typescript/src/web/shadowRegistry.d.ts +4 -2
  257. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  258. package/lib/typescript/src/web/state.d.ts.map +1 -1
  259. package/lib/typescript/src/web/types.d.ts +6 -0
  260. package/lib/typescript/src/web/types.d.ts.map +1 -1
  261. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  262. package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -1
  263. package/lib/typescript/src/web/utils/unistyle.d.ts +7 -1
  264. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  265. package/lib/typescript/src/web/variants.d.ts.map +1 -1
  266. package/lib/typescript/src/web-only/getWebProps.d.ts +7 -0
  267. package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -0
  268. package/lib/typescript/src/web-only/index.d.ts +2 -0
  269. package/lib/typescript/src/web-only/index.d.ts.map +1 -0
  270. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +1 -0
  271. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +2 -0
  272. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +2 -0
  273. package/package.json +57 -25
  274. package/plugin/index.d.ts +6 -5
  275. package/plugin/index.js +103 -99
  276. package/reanimated/package.json +6 -0
  277. package/repack-plugin/index.d.ts +19 -0
  278. package/repack-plugin/index.js +149 -0
  279. package/src/components/AdaptiveTheme.tsx +34 -0
  280. package/src/components/ApplyScopedTheme.tsx +17 -0
  281. package/src/components/NamedTheme.tsx +33 -0
  282. package/src/components/ScopedTheme.tsx +42 -22
  283. package/src/core/createUnistylesElement.native.tsx +21 -31
  284. package/src/core/createUnistylesElement.tsx +3 -3
  285. package/src/core/createUnistylesImageBackground.tsx +7 -22
  286. package/src/core/parseBoxShadow.ts +87 -0
  287. package/src/core/withUnistyles/withUnistyles.native.tsx +1 -0
  288. package/src/index.ts +8 -0
  289. package/src/mocks.ts +5 -2
  290. package/src/reanimated/index.ts +2 -0
  291. package/src/reanimated/useAnimatedTheme.native.ts +21 -0
  292. package/src/reanimated/useAnimatedTheme.ts +19 -0
  293. package/src/reanimated/variant/index.ts +1 -0
  294. package/src/reanimated/variant/types.ts +14 -0
  295. package/src/reanimated/variant/useAnimatedVariantColor.ts +38 -0
  296. package/src/reanimated/variant/useUpdateVariantColor.native.ts +38 -0
  297. package/src/reanimated/variant/useUpdateVariantColor.ts +81 -0
  298. package/src/specs/ShadowRegistry/index.ts +7 -1
  299. package/src/specs/StyleSheet/index.ts +5 -2
  300. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +2 -0
  301. package/src/utils.ts +1 -3
  302. package/src/web/create.ts +1 -1
  303. package/src/web/css/core.ts +9 -1
  304. package/src/web/css/state.ts +10 -8
  305. package/src/web/listener.ts +2 -0
  306. package/src/web/runtime.ts +23 -2
  307. package/src/web/shadowRegistry.ts +15 -6
  308. package/src/web/state.ts +7 -17
  309. package/src/web/types.ts +12 -4
  310. package/src/web/utils/unistyle.ts +38 -3
  311. package/src/web-only/getWebProps.ts +18 -0
  312. package/src/web-only/index.ts +2 -0
  313. package/web/package.json +6 -0
  314. package/cxx/core/UnistylesCommitHook.cpp +0 -52
  315. package/cxx/core/UnistylesCommitHook.h +0 -27
  316. package/cxx/core/UnistylesMountHook.cpp +0 -28
  317. package/cxx/core/UnistylesMountHook.h +0 -24
  318. package/lib/module/package.json +0 -1
package/README.md CHANGED
@@ -21,15 +21,14 @@ yarn add react-native-unistyles@next
21
21
  Install dependencies:
22
22
 
23
23
  ```shell
24
- yarn add react-native-edge-to-edge react-native-nitro-modules@0.25.2
24
+ yarn add react-native-edge-to-edge react-native-nitro-modules@0.26.2
25
25
  ```
26
26
 
27
27
  > To avoid unexpected behavior, always use a fixed version of `react-native-nitro-modules`
28
28
 
29
29
  | react-native-unistyles | react-native-nitro-modules |
30
30
  |------------------------|----------------------------|
31
- | 3.0.0-nightly-20250505 | 0.25.2 |
32
- | 3.0.0-rc.2 | 0.25.2 |
31
+ | 3.0.0-rc.5 | 0.26.2 |
33
32
 
34
33
  Then follow [installation guides](https://unistyl.es/v3/start/getting-started) for your platform.
35
34
 
@@ -60,9 +59,6 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
60
59
  <a href="https://galaxies.dev">
61
60
  <img src="https://avatars.githubusercontent.com/u/118431096?s=200&v=4" height="70px" width="70px" alt="galaxies-dev" />
62
61
  </a>
63
- <a href="https://github.com/FTCHD">
64
- <img src="https://avatars.githubusercontent.com/u/144691102?v=4" height="70px" width="70px" alt="FTCHD" />
65
- </a>
66
62
  <a href="https://github.com/mobily">
67
63
  <img src="https://avatars.githubusercontent.com/u/1467712?v=4" height="70px" width="70px" alt="mobily" />
68
64
  </a>
@@ -81,8 +77,8 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
81
77
  <a href="https://github.com/ryanlanciaux">
82
78
  <img src="https://avatars.githubusercontent.com/u/85041?v=4" height="70px" width="70px" alt="ryanlanciaux" />
83
79
  </a>
84
- <a href="https://github.com/loopsware">
85
- <img src="https://avatars.githubusercontent.com/u/161434039?s=200&v=4" height="70px" width="70px" alt="loopsware" />
80
+ <a href="https://github.com/avega99">
81
+ <img src="https://avatars.githubusercontent.com/u/177598670?v=4" height="70px" width="70px" alt="avega99" />
86
82
  </a>
87
83
 
88
84
  ## Past sponsors
@@ -126,6 +122,12 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
126
122
  <a href="https://github.com/guillaumehcht">
127
123
  <img src="https://avatars.githubusercontent.com/u/80776475?v=4" height="60px" width="60px" alt="guillaumehcht" />
128
124
  </a>
125
+ <a href="https://github.com/loopsware">
126
+ <img src="https://avatars.githubusercontent.com/u/161434039?s=200&v=4" height="60px" width="60px" alt="loopsware" />
127
+ </a>
128
+ <a href="https://github.com/FTCHD">
129
+ <img src="https://avatars.githubusercontent.com/u/144691102?v=4" height="60px" width="60px" alt="FTCHD" />
130
+ </a>
129
131
 
130
132
  ## Sponsor my work
131
133
 
@@ -10,19 +10,16 @@ using namespace facebook::react;
10
10
  UnistylesModule::UnistylesModule(
11
11
  jni::alias_ref<UnistylesModule::jhybridobject> jThis,
12
12
  jni::alias_ref<react::JRuntimeExecutor::javaobject> runtimeExecutorHolder,
13
- jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
14
13
  jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
15
14
  ): _runtimeExecutor(runtimeExecutorHolder->cthis()->get()),
16
- _uiManager(fabricUIManager->getBinding()->getScheduler()->getUIManager()),
17
15
  _nativePlatform(nativePlatform->cthis()) {}
18
16
 
19
17
  jni::local_ref<UnistylesModule::jhybriddata> UnistylesModule::initHybrid(
20
18
  jni::alias_ref<UnistylesModule::jhybridobject> jThis,
21
19
  jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
22
- jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
23
20
  jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
24
21
  ) {
25
- return makeCxxInstance(jThis, runtimeExecutorHolder, fabricUIManager, nativePlatform);
22
+ return makeCxxInstance(jThis, runtimeExecutorHolder, nativePlatform);
26
23
  }
27
24
 
28
25
  void UnistylesModule::registerNatives() {
@@ -34,10 +31,9 @@ void UnistylesModule::registerNatives() {
34
31
 
35
32
  jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindingsInstaller(jni::alias_ref<UnistylesModule::javaobject> jobj) {
36
33
  auto& runtimeExecutor = jobj->cthis()->_runtimeExecutor;
37
- auto& uiManager = jobj->cthis()->_uiManager;
38
34
  auto& nativePlatform = jobj->cthis()->_nativePlatform;
39
35
 
40
- return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, &uiManager, &nativePlatform](jsi::Runtime& rt) {
36
+ return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, &nativePlatform](jsi::Runtime& rt) {
41
37
  // function is called on: first init and every live reload
42
38
  // check if this is live reload, if so let's replace UnistylesRuntime with new runtime
43
39
  auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
@@ -56,7 +52,7 @@ jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindings
56
52
 
57
53
  // init hybrids
58
54
  auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, rt, runOnJSThread);
59
- auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime, uiManager);
55
+ auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime);
60
56
 
61
57
  HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
62
58
  return unistylesRuntime;
@@ -1,7 +1,6 @@
1
1
  #pragma once
2
2
 
3
3
  #include <ReactCommon/BindingsInstallerHolder.h>
4
- #include <react/fabric/JFabricUIManager.h>
5
4
  #include <react/jni/JRuntimeExecutor.h>
6
5
  #include <react/renderer/scheduler/Scheduler.h>
7
6
  #include <fbjni/fbjni.h>
@@ -19,7 +18,6 @@ struct UnistylesModule : public jni::HybridClass<UnistylesModule> {
19
18
  explicit UnistylesModule(
20
19
  jni::alias_ref<jhybridobject> jThis,
21
20
  jni::alias_ref<react::JRuntimeExecutor::javaobject> runtimeExecutorHolder,
22
- jni::alias_ref<JFabricUIManager::javaobject> fabricUIManager,
23
21
  jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
24
22
  );
25
23
 
@@ -27,14 +25,12 @@ struct UnistylesModule : public jni::HybridClass<UnistylesModule> {
27
25
  static jni::local_ref<jhybriddata> initHybrid(
28
26
  jni::alias_ref<jhybridobject> jThis,
29
27
  jni::alias_ref<JRuntimeExecutor::javaobject> runtimeExecutorHolder,
30
- jni::alias_ref<JFabricUIManager::javaobject>,
31
28
  jni::alias_ref<JHybridNativePlatformSpec::javaobject> nativePlatform
32
29
  );
33
30
 
34
31
  static jni::local_ref<BindingsInstallerHolder::javaobject> getBindingsInstaller(jni::alias_ref<UnistylesModule::javaobject> jThis);
35
32
 
36
33
  private:
37
- std::shared_ptr<UIManager> _uiManager;
38
34
  RuntimeExecutor _runtimeExecutor;
39
35
  std::shared_ptr<HybridNativePlatformSpec> _nativePlatform;
40
36
  };
@@ -5,11 +5,8 @@ import com.facebook.jni.HybridData
5
5
  import com.facebook.proguard.annotations.DoNotStrip
6
6
  import com.facebook.react.bridge.ReactApplicationContext
7
7
  import com.facebook.react.bridge.RuntimeExecutor
8
- import com.facebook.react.fabric.FabricUIManager
9
8
  import com.facebook.react.turbomodule.core.interfaces.BindingsInstallerHolder
10
9
  import com.facebook.react.turbomodule.core.interfaces.TurboModuleWithJSIBindings
11
- import com.facebook.react.uimanager.UIManagerHelper
12
- import com.facebook.react.uimanager.common.UIManagerType
13
10
  import com.margelo.nitro.unistyles.HybridNativePlatformSpec
14
11
  import com.margelo.nitro.unistyles.unistylesOnLoad.Companion.initializeNative
15
12
 
@@ -34,10 +31,8 @@ class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistyl
34
31
  private fun initializeHybridData(reactContext: ReactApplicationContext): HybridData {
35
32
  val runtimeExecutor = reactContext.catalystInstance?.runtimeExecutor
36
33
  ?: throw IllegalStateException("Unistyles: React Native runtime executor is not available. Please follow installation guides.")
37
- val fabricUIManager = UIManagerHelper.getUIManager(reactContext, UIManagerType.FABRIC) as? FabricUIManager
38
- ?: throw IllegalStateException("Unistyles: Fabric UI Manager is not available. Please follow installation guides.")
39
34
 
40
- return initHybrid(runtimeExecutor, fabricUIManager, _nativePlatform)
35
+ return initHybrid(runtimeExecutor, _nativePlatform)
41
36
  }
42
37
 
43
38
  @DoNotStrip
@@ -46,7 +41,6 @@ class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistyl
46
41
  @DoNotStrip
47
42
  private external fun initHybrid(
48
43
  runtimeExecutor: RuntimeExecutor,
49
- fabricUIManager: FabricUIManager,
50
44
  nativePlatform: HybridNativePlatformSpec
51
45
  ): HybridData
52
46
  }
@@ -154,8 +154,11 @@ inline static jsi::Value objectFromUnistyle(jsi::Runtime& rt, std::shared_ptr<Hy
154
154
  rt,
155
155
  jsi::PropNameID::forUtf8(rt, helpers::GET_STYLES.c_str()),
156
156
  0,
157
- [unistyle, unistylesRuntime, variants, parsedArguments](jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count
157
+ [unistyleID = unistyle->unid, unistylesRuntime, variants, parsedArguments](jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count
158
158
  ) {
159
+ auto& registry = UnistylesRegistry::get();
160
+ auto unistyle = registry.getUnistyleById(rt, unistyleID);
161
+
159
162
  parser::Parser(unistylesRuntime).rebuildUnistyle(rt, unistyle, variants, parsedArguments);
160
163
 
161
164
  return jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
@@ -8,32 +8,11 @@ namespace margelo::nitro::unistyles::core {
8
8
  // React Native uses 0-10
9
9
  // Reanimated uses 27-28
10
10
  constexpr shadow::ShadowNodeTraits::Trait UnistylesCommitTrait{1 << 30};
11
- constexpr shadow::ShadowNodeTraits::Trait UnistylesMountTrait{1 << 31};
12
11
 
13
12
  struct UnistylesCommitShadowNode: public shadow::ShadowNode {
14
13
  inline void addUnistylesCommitTrait() {
15
14
  traits_.set(UnistylesCommitTrait);
16
15
  }
17
-
18
- inline void removeUnistylesCommitTrait() {
19
- traits_.unset(UnistylesCommitTrait);
20
- }
21
-
22
- inline bool hasUnistylesCommitTrait() {
23
- return traits_.check(UnistylesCommitTrait);
24
- }
25
-
26
- inline void addUnistylesMountTrait() {
27
- traits_.set(UnistylesMountTrait);
28
- }
29
-
30
- inline void removeUnistylesMountTrait() {
31
- traits_.unset(UnistylesMountTrait);
32
- }
33
-
34
- inline bool hasUnistylesMountTrait() {
35
- return traits_.check(UnistylesMountTrait);
36
- }
37
16
  };
38
17
 
39
18
  }
@@ -42,12 +42,6 @@ core::UnistylesState& core::UnistylesRegistry::getState(jsi::Runtime& rt) {
42
42
  void core::UnistylesRegistry::createState(jsi::Runtime& rt) {
43
43
  auto it = this->_states.find(&rt);
44
44
 
45
- // remove old state, so we can swap it with new config
46
- // during live reload
47
- if (it != this->_states.end()) {
48
- this->_states.extract(&rt);
49
- }
50
-
51
45
  this->_states.emplace(
52
46
  std::piecewise_construct,
53
47
  std::forward_as_tuple(&rt),
@@ -82,7 +76,7 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
82
76
  });
83
77
 
84
78
  updates[shadowNodeFamily] = parser.parseStylesToShadowTreeStyles(rt, unistylesData);
85
-
79
+
86
80
  this->trafficController.setUpdates(updates);
87
81
  this->trafficController.resumeUnistylesTraffic();
88
82
  });
@@ -127,31 +121,36 @@ std::shared_ptr<core::StyleSheet> core::UnistylesRegistry::addStyleSheet(jsi::Ru
127
121
  }
128
122
 
129
123
  core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps) {
130
- DependencyMap dependencyMap;
131
- std::set<UnistyleDependency> uniqueDependencies(deps.begin(), deps.end());
124
+ core::DependencyMap dependencyMap;
125
+
126
+ std::unordered_set<UnistyleDependency> uniqueDependencies(deps.begin(), deps.end());
132
127
 
133
128
  for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
129
+ bool hasAnyOfDependencies = false;
130
+
131
+ // Check if any dependency matches
134
132
  for (const auto& unistyleData : unistyles) {
135
- bool hasAnyOfDependencies = std::any_of(
136
- unistyleData->unistyle->dependencies.begin(),
137
- unistyleData->unistyle->dependencies.end(),
138
- [&uniqueDependencies](UnistyleDependency dep) {
139
- return std::find(uniqueDependencies.begin(), uniqueDependencies.end(), dep) != uniqueDependencies.end();
133
+ for (const auto& dep : unistyleData->unistyle->dependencies) {
134
+ if (uniqueDependencies.count(dep)) {
135
+ hasAnyOfDependencies = true;
136
+ break;
140
137
  }
141
- );
142
-
143
- if (!hasAnyOfDependencies) {
144
- continue;
145
138
  }
146
139
 
147
- // we need to take in count all unistyles from the shadowNode
148
- // as user might be using spreads and not all of them may have dependencies
149
- for (const auto& unistyleData : unistyles) {
150
- dependencyMap[family].emplace_back(unistyleData);
151
- }
140
+ if (hasAnyOfDependencies) {
141
+ break;
142
+ };
143
+ }
152
144
 
153
- break;
145
+ if (!hasAnyOfDependencies) {
146
+ continue;
154
147
  }
148
+
149
+ dependencyMap[family].insert(
150
+ dependencyMap[family].end(),
151
+ unistyles.begin(),
152
+ unistyles.end()
153
+ );
155
154
  }
156
155
 
157
156
  return dependencyMap;
@@ -179,48 +178,45 @@ void core::UnistylesRegistry::shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Uni
179
178
  });
180
179
  }
181
180
 
182
- std::vector<std::shared_ptr<core::StyleSheet>> core::UnistylesRegistry::getStyleSheetsToRefresh(jsi::Runtime& rt, std::vector<UnistyleDependency>& unistylesDependencies) {
183
- std::vector<std::shared_ptr<core::StyleSheet>> stylesheetsToRefresh{};
184
- auto themeDidChangeIt = std::find(unistylesDependencies.begin(),
185
- unistylesDependencies.end(),
186
- UnistyleDependency::THEME);
187
- auto themeDidChange = themeDidChangeIt != unistylesDependencies.end();
188
- auto runtimeDidChange = (themeDidChange && unistylesDependencies.size() > 1) || unistylesDependencies.size() > 0;
181
+ std::vector<std::shared_ptr<core::StyleSheet>>core::UnistylesRegistry::getStyleSheetsToRefresh(jsi::Runtime& rt, std::vector<UnistyleDependency>& unistylesDependencies) {
182
+ std::vector<std::shared_ptr<core::StyleSheet>> stylesheetsToRefresh;
183
+ std::unordered_set<UnistyleDependency> depSet(
184
+ unistylesDependencies.begin(),
185
+ unistylesDependencies.end()
186
+ );
187
+
188
+ bool themeDidChange = depSet.count(UnistyleDependency::THEME) > 0;
189
+ bool runtimeDidChange = (themeDidChange && depSet.size() > 1) || !depSet.empty();
189
190
 
190
- // if nothing changed, skip further lookup
191
191
  if (!themeDidChange && !runtimeDidChange) {
192
192
  return stylesheetsToRefresh;
193
193
  }
194
194
 
195
195
  auto& styleSheets = this->_styleSheetRegistry[&rt];
196
196
 
197
- std::for_each(styleSheets.begin(), styleSheets.end(), [&](std::pair<int, std::shared_ptr<core::StyleSheet>> pair){
198
- auto& [_, styleSheet] = pair;
199
-
197
+ for (const auto& [_, styleSheet] : styleSheets) {
200
198
  if (styleSheet->type == StyleSheetType::ThemableWithMiniRuntime) {
201
- for (const auto& unistylePair: styleSheet->unistyles) {
202
- auto& [_, unistyle] = unistylePair;
203
-
204
- bool hasAnyOfDependencies = std::any_of(
205
- unistyle->dependencies.begin(),
206
- unistyle->dependencies.end(),
207
- [&unistylesDependencies](UnistyleDependency dep) {
208
- return std::find(unistylesDependencies.begin(), unistylesDependencies.end(), dep) != unistylesDependencies.end();
199
+ auto hasMatchingDependency = [&depSet](const auto& unistyles) {
200
+ for (const auto& [_, unistyle] : unistyles) {
201
+ for (const auto& dep : unistyle->dependencies) {
202
+ if (depSet.count(dep)) {
203
+ return true;
204
+ }
209
205
  }
210
- );
206
+ }
211
207
 
212
- if (hasAnyOfDependencies) {
213
- stylesheetsToRefresh.emplace_back(styleSheet);
208
+ return false;
209
+ };
214
210
 
215
- return;
216
- }
211
+ if (hasMatchingDependency(styleSheet->unistyles)) {
212
+ stylesheetsToRefresh.emplace_back(styleSheet);
217
213
  }
218
214
  }
219
215
 
220
216
  if (styleSheet->type == StyleSheetType::Themable && themeDidChange) {
221
217
  stylesheetsToRefresh.emplace_back(styleSheet);
222
218
  }
223
- });
219
+ }
224
220
 
225
221
  return stylesheetsToRefresh;
226
222
  }
@@ -95,6 +95,10 @@ void core::UnistylesState::registerProcessColorFunction(jsi::Function&& fn) {
95
95
  this->_processColorFn = std::make_shared<jsi::Function>(std::move(fn));
96
96
  }
97
97
 
98
+ void core::UnistylesState::registerParseBoxShadowString(jsi::Function&& fn) {
99
+ this->_parseBoxShadowStringFn = std::make_shared<jsi::Function>(std::move(fn));
100
+ }
101
+
98
102
  int core::UnistylesState::parseColor(jsi::Value& maybeColor) {
99
103
  if (!maybeColor.isString()) {
100
104
  return 0;
@@ -114,3 +118,9 @@ int core::UnistylesState::parseColor(jsi::Value& maybeColor) {
114
118
 
115
119
  return this->_colorCache[colorString.utf8(*_rt).c_str()];
116
120
  }
121
+
122
+ jsi::Array core::UnistylesState::parseBoxShadowString(std::string&& boxShadowString) {
123
+ jsi::Value result = this->_parseBoxShadowStringFn.get()->call(*_rt, boxShadowString);
124
+
125
+ return result.asObject(*_rt).asArray(*_rt);
126
+ }
@@ -32,8 +32,10 @@ struct UnistylesState {
32
32
  jsi::Object getCurrentJSTheme();
33
33
  jsi::Object getJSThemeByName(std::string& themeName);
34
34
  int parseColor(jsi::Value& color);
35
+ jsi::Array parseBoxShadowString(std::string&& boxShadowString);
35
36
  void computeCurrentBreakpoint(int screenWidth);
36
37
  void registerProcessColorFunction(jsi::Function&& fn);
38
+ void registerParseBoxShadowString(jsi::Function&& fn);
37
39
 
38
40
  private:
39
41
  jsi::Runtime* _rt;
@@ -45,6 +47,7 @@ private:
45
47
  std::vector<std::string> _registeredThemeNames{};
46
48
  std::optional<std::string> _currentThemeName = std::nullopt;
47
49
  std::shared_ptr<jsi::Function> _processColorFn;
50
+ std::shared_ptr<jsi::Function> _parseBoxShadowStringFn;
48
51
  std::unordered_map<std::string, uint32_t> _colorCache{};
49
52
 
50
53
  friend class UnistylesRegistry;
@@ -107,13 +107,18 @@ jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &this
107
107
  return jsi::Value::undefined();
108
108
  }
109
109
 
110
+ jsi::Value HybridShadowRegistry::flush(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
111
+ shadow::ShadowTreeManager::updateShadowTree(UIManagerBinding::getBinding(rt)->getUIManager().getShadowTreeRegistry());
112
+
113
+ return jsi::Value::undefined();
114
+ }
115
+
110
116
  jsi::Value HybridShadowRegistry::setScopedTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
111
117
  helpers::assertThat(rt, count == 1, "Unistyles: setScopedTheme expected 1 argument.");
112
118
 
113
119
  auto& registry = core::UnistylesRegistry::get();
114
120
 
115
121
  if (args[0].isUndefined()) {
116
-
117
122
  registry.setScopedTheme(std::nullopt);
118
123
  }
119
124
 
@@ -5,6 +5,7 @@
5
5
  #include "UnistyleWrapper.h"
6
6
  #include "UnistylesState.h"
7
7
  #include "UnistylesRegistry.h"
8
+ #include "ShadowTreeManager.h"
8
9
 
9
10
  namespace margelo::nitro::unistyles {
10
11
 
@@ -20,6 +21,10 @@ struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
20
21
  const jsi::Value& thisValue,
21
22
  const jsi::Value* args,
22
23
  size_t count);
24
+ jsi::Value flush(jsi::Runtime& rt,
25
+ const jsi::Value& thisValue,
26
+ const jsi::Value* args,
27
+ size_t count);
23
28
  jsi::Value setScopedTheme(jsi::Runtime& rt,
24
29
  const jsi::Value& thisValue,
25
30
  const jsi::Value* args,
@@ -35,6 +40,7 @@ struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
35
40
  registerHybrids(this, [](Prototype& prototype) {
36
41
  prototype.registerRawHybridMethod("link", 2, &HybridShadowRegistry::link);
37
42
  prototype.registerRawHybridMethod("unlink", 1, &HybridShadowRegistry::unlink);
43
+ prototype.registerRawHybridMethod("flush", 0, &HybridShadowRegistry::flush);
38
44
  prototype.registerRawHybridMethod("setScopedTheme", 1, &HybridShadowRegistry::setScopedTheme);
39
45
  prototype.registerRawHybridMethod("getScopedTheme", 0, &HybridShadowRegistry::getScopedTheme);
40
46
  });
@@ -3,10 +3,14 @@
3
3
  using namespace facebook::react;
4
4
 
5
5
  double HybridStyleSheet::getHairlineWidth() {
6
- auto pixelRatio = this->_unistylesRuntime->getPixelRatio();
7
- auto nearestPixel = static_cast<int>(std::trunc(pixelRatio * 0.4));
6
+ double pixelRatio = this->_unistylesRuntime->getPixelRatio();
7
+ double hairlineWidth = std::round(pixelRatio * 0.4) / pixelRatio;
8
8
 
9
- return nearestPixel / pixelRatio;
9
+ if (hairlineWidth == 0.0) {
10
+ hairlineWidth = 1.0 / pixelRatio;
11
+ }
12
+
13
+ return hairlineWidth;
10
14
  }
11
15
 
12
16
  double HybridStyleSheet::getUnid() {
@@ -87,7 +91,6 @@ jsi::Value HybridStyleSheet::init(jsi::Runtime &rt, const jsi::Value &thisVal, c
87
91
  registry.createState(rt);
88
92
 
89
93
  loadExternalMethods(thisVal, rt);
90
- registerHooks(rt);
91
94
 
92
95
  this->isInitialized = true;
93
96
 
@@ -248,24 +251,18 @@ void HybridStyleSheet::loadExternalMethods(const jsi::Value& thisValue, jsi::Run
248
251
  auto maybeProcessColorFn = jsMethods.asObject(rt).getProperty(rt, "processColor");
249
252
 
250
253
  helpers::assertThat(rt, maybeProcessColorFn.isObject(), "Unistyles: Can't load processColor function from JS.");
254
+
255
+ auto maybeParseBoxShadowStringFn = jsMethods.asObject(rt).getProperty(rt, "parseBoxShadowString");
256
+
257
+ helpers::assertThat(rt, maybeParseBoxShadowStringFn.isObject(), "Unistyles: Can't load parseBoxShadowString function from JS.");
251
258
 
252
259
  auto processColorFn = maybeProcessColorFn.asObject(rt).asFunction(rt);
260
+ auto parseBoxShadowStringFn = maybeParseBoxShadowStringFn.asObject(rt).asFunction(rt);
253
261
  auto& registry = core::UnistylesRegistry::get();
254
262
  auto& state = registry.getState(rt);
255
263
 
256
264
  state.registerProcessColorFunction(std::move(processColorFn));
257
- }
258
-
259
- void HybridStyleSheet::registerHooks(jsi::Runtime& rt) {
260
- // cleanup Shadow updates
261
- auto& registry = core::UnistylesRegistry::get();
262
-
263
- registry.trafficController.withLock([&registry](){
264
- registry.trafficController.restore();
265
- });
266
-
267
- this->_unistylesCommitHook = std::make_shared<core::UnistylesCommitHook>(this->_uiManager);
268
- this->_unistylesMountHook = std::make_shared<core::UnistylesMountHook>(this->_uiManager);
265
+ state.registerParseBoxShadowString(std::move(parseBoxShadowStringFn));
269
266
  }
270
267
 
271
268
  void HybridStyleSheet::onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies) {
@@ -9,15 +9,13 @@
9
9
  #include "UnistylesConstants.h"
10
10
  #include "Breakpoints.h"
11
11
  #include "Parser.h"
12
- #include "UnistylesCommitHook.h"
13
- #include "UnistylesMountHook.h"
12
+ #include "ShadowTreeManager.h"
14
13
 
15
14
  using namespace margelo::nitro::unistyles;
16
15
  using namespace facebook::react;
17
16
 
18
17
  struct HybridStyleSheet: public HybridUnistylesStyleSheetSpec {
19
- HybridStyleSheet(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, std::shared_ptr<UIManager> uiManager)
20
- : HybridObject(TAG), _unistylesRuntime{unistylesRuntime}, _uiManager{uiManager} {
18
+ HybridStyleSheet(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime): HybridObject(TAG), _unistylesRuntime{unistylesRuntime} {
21
19
  this->_unistylesRuntime->registerPlatformListener(
22
20
  std::bind(&HybridStyleSheet::onPlatformDependenciesChange, this, std::placeholders::_1)
23
21
  );
@@ -67,7 +65,6 @@ private:
67
65
  void verifyAndSelectTheme(jsi::Runtime &rt);
68
66
  void setThemeFromColorScheme(jsi::Runtime& rt);
69
67
  void loadExternalMethods(const jsi::Value& thisValue, jsi::Runtime& rt);
70
- void registerHooks(jsi::Runtime& rt);
71
68
  void onPlatformDependenciesChange(std::vector<UnistyleDependency> dependencies);
72
69
  void onPlatformNativeDependenciesChange(std::vector<UnistyleDependency> dependencies, UnistylesNativeMiniRuntime miniRuntime);
73
70
  void onImeChange(UnistylesNativeMiniRuntime miniRuntime);
@@ -77,8 +74,6 @@ private:
77
74
  double __unid = -1;
78
75
  std::vector<std::unique_ptr<const std::function<void(std::vector<UnistyleDependency>&)>>> _changeListeners{};
79
76
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
80
- std::shared_ptr<core::UnistylesCommitHook> _unistylesCommitHook;
81
- std::shared_ptr<core::UnistylesMountHook> _unistylesMountHook;
82
77
  std::shared_ptr<UIManager> _uiManager;
83
78
  };
84
79
 
@@ -49,6 +49,14 @@ Orientation HybridUnistylesRuntime::getOrientation() {
49
49
  return static_cast<Orientation>(orientation);
50
50
  };
51
51
 
52
+ bool HybridUnistylesRuntime::getIsLandscape() {
53
+ return this->getOrientation() == Orientation::LANDSCAPE;
54
+ }
55
+
56
+ bool HybridUnistylesRuntime::getIsPortrait() {
57
+ return this->getOrientation() == Orientation::PORTRAIT;
58
+ }
59
+
52
60
  double HybridUnistylesRuntime::getPixelRatio() {
53
61
  return this->_nativePlatform->getPixelRatio();
54
62
  };
@@ -47,6 +47,8 @@ struct HybridUnistylesRuntime: public HybridUnistylesRuntimeSpec {
47
47
  ColorScheme getColorScheme() override;
48
48
  bool getHasAdaptiveThemes() override;
49
49
  bool getRtl() override;
50
+ bool getIsLandscape() override;
51
+ bool getIsPortrait() override;
50
52
  Dimensions getScreen() override;
51
53
  std::optional<std::string> getThemeName() override;
52
54
  std::string getContentSizeCategory() override;