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
@@ -213,113 +213,115 @@ void parser::Parser::rebuildUnistyleWithVariants(jsi::Runtime& rt, std::shared_p
213
213
  }
214
214
 
215
215
  // rebuild all unistyles that are affected by platform event
216
- void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet>>& styleSheets, std::optional<UnistylesNativeMiniRuntime> maybeMiniRuntime) {
217
- std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value> parsedStyleSheetsWithDefaultTheme{};
218
- std::unordered_map<std::string, std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value>> parsedStyleSheetsWithScopedTheme{};
219
- std::unordered_map<std::shared_ptr<core::Unistyle>, bool> parsedUnistyles{};
220
-
221
- // parse all stylesheets that depends on changes
222
- for (auto styleSheet : styleSheets) {
223
- parsedStyleSheetsWithDefaultTheme.emplace(styleSheet, this->unwrapStyleSheet(rt, styleSheet, maybeMiniRuntime));
216
+ void parser::Parser::rebuildUnistylesInDependencyMap(
217
+ jsi::Runtime& rt,
218
+ DependencyMap& dependencyMap,
219
+ std::vector<std::shared_ptr<core::StyleSheet>>& styleSheets,
220
+ std::optional<UnistylesNativeMiniRuntime> maybeMiniRuntime
221
+ ) {
222
+ std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value> parsedStyleSheetsWithDefaultTheme;
223
+ std::unordered_map<std::string, std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value>> parsedStyleSheetsWithScopedTheme;
224
+ std::unordered_set<std::shared_ptr<core::Unistyle>> parsedUnistyles;
225
+
226
+ // Parse all stylesheets that depend on changes
227
+ for (const auto& styleSheet : styleSheets) {
228
+ parsedStyleSheetsWithDefaultTheme.emplace(
229
+ styleSheet,
230
+ this->unwrapStyleSheet(rt, styleSheet, maybeMiniRuntime)
231
+ );
224
232
  }
225
233
 
226
- // then parse all visible Unistyles managed by Unistyle
234
+ // Parse all visible Unistyles managed by Unistyle
227
235
  for (auto& [shadowNode, unistyles] : dependencyMap) {
228
- auto styleSheet = unistyles.begin()->get()->unistyle->parent;
236
+ auto styleSheet = unistyles.front()->unistyle->parent;
229
237
 
230
- // stylesheet may be optional for exotic unistyles
231
- if (styleSheet != nullptr && !parsedStyleSheetsWithDefaultTheme.contains(styleSheet)) {
232
- parsedStyleSheetsWithDefaultTheme.emplace(styleSheet, this->unwrapStyleSheet(rt, styleSheet, maybeMiniRuntime));
238
+ // Stylesheet may be optional for exotic unistyles
239
+ if (styleSheet && parsedStyleSheetsWithDefaultTheme.find(styleSheet) == parsedStyleSheetsWithDefaultTheme.end()) {
240
+ parsedStyleSheetsWithDefaultTheme.emplace(
241
+ styleSheet,
242
+ this->unwrapStyleSheet(rt, styleSheet, maybeMiniRuntime)
243
+ );
233
244
  }
234
245
 
235
246
  for (auto& unistyleData : unistyles) {
236
247
  auto& unistyle = unistyleData->unistyle;
237
248
 
238
- // for RN styles or inline styles, compute styles only once
249
+ // For RN styles or inline styles, compute styles only once
239
250
  if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY) {
240
251
  if (!unistyleData->parsedStyle.has_value()) {
241
252
  unistyleData->parsedStyle = jsi::Value(rt, unistyle->rawValue).asObject(rt);
242
-
243
- if (!parsedUnistyles.contains(unistyle)) {
244
- parsedUnistyles.emplace(unistyle, true);
245
- }
253
+ parsedUnistyles.insert(unistyle);
246
254
  }
247
255
 
248
256
  continue;
249
257
  }
250
258
 
251
- // reference Unistyles StyleSheet as we may mix them for one style
259
+ // Reference Unistyles StyleSheet as we may mix them for one style
252
260
  auto unistyleStyleSheet = unistyle->parent;
253
261
 
254
- // we may hit now other StyleSheets that are referenced from affected nodes
255
- if (unistyleStyleSheet != nullptr && !parsedStyleSheetsWithDefaultTheme.contains(unistyleStyleSheet)) {
256
- parsedStyleSheetsWithDefaultTheme.emplace(unistyleStyleSheet, this->unwrapStyleSheet(rt, unistyleStyleSheet, maybeMiniRuntime));
262
+ // We may hit now other StyleSheets that are referenced from affected nodes
263
+ if (unistyleStyleSheet && parsedStyleSheetsWithDefaultTheme.find(unistyleStyleSheet) == parsedStyleSheetsWithDefaultTheme.end()) {
264
+ parsedStyleSheetsWithDefaultTheme.emplace(
265
+ unistyleStyleSheet,
266
+ this->unwrapStyleSheet(rt, unistyleStyleSheet, maybeMiniRuntime)
267
+ );
257
268
  }
258
269
 
259
270
  // StyleSheet might have styles that are not affected
260
- if (!parsedStyleSheetsWithDefaultTheme[unistyleStyleSheet].asObject(rt).hasProperty(rt, unistyle->styleKey.c_str())) {
271
+ auto& parsedSheetValue = parsedStyleSheetsWithDefaultTheme[unistyleStyleSheet];
272
+ auto parsedSheetObj = parsedSheetValue.asObject(rt);
273
+
274
+ if (!parsedSheetObj.hasProperty(rt, unistyle->styleKey.c_str())) {
261
275
  continue;
262
276
  }
263
277
 
264
- // for scoped themes we need to parse unistyle exclusively
278
+ // For scoped themes we need to parse unistyle exclusively
265
279
  if (unistyleData->scopedTheme.has_value()) {
266
- std::vector<folly::dynamic> arguments = {};
267
-
268
- if (unistyleData->dynamicFunctionMetadata.has_value()) {
269
- arguments = unistyleData->dynamicFunctionMetadata.value();
270
- }
280
+ auto& scopedThemeName = unistyleData->scopedTheme.value();
281
+ auto& scopedThemeMap = parsedStyleSheetsWithScopedTheme[scopedThemeName];
271
282
 
272
- auto parsedStyleSheet = jsi::Value::undefined();
273
- auto scopedThemeName = unistyleData->scopedTheme.value();
283
+ jsi::Value parsedStyleSheet = jsi::Value::undefined();
284
+ auto it = scopedThemeMap.find(unistyle->parent);
274
285
 
275
- // check if we have theme in cache
276
- if (parsedStyleSheetsWithScopedTheme.contains(scopedThemeName)) {
277
- if (parsedStyleSheetsWithScopedTheme[scopedThemeName].contains(unistyle->parent)) {
278
- parsedStyleSheet = jsi::Value(rt, parsedStyleSheetsWithScopedTheme[scopedThemeName][unistyle->parent]);
279
- }
286
+ if (it != scopedThemeMap.end()) {
287
+ parsedStyleSheet = jsi::Value(rt, it->second);
280
288
  }
281
289
 
282
- // if not, let's build it
283
290
  if (parsedStyleSheet.isUndefined()) {
284
- parsedStyleSheet = this->getParsedStyleSheetForScopedTheme(rt, unistyle, unistyleData->scopedTheme.value());
285
-
286
- if (!parsedStyleSheetsWithScopedTheme.contains(scopedThemeName)) {
287
- parsedStyleSheetsWithScopedTheme.emplace(
288
- scopedThemeName,
289
- std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value>{}
290
- );
291
- }
292
-
293
- parsedStyleSheetsWithScopedTheme[scopedThemeName].emplace(
291
+ parsedStyleSheet = this->getParsedStyleSheetForScopedTheme(rt, unistyle, scopedThemeName);
292
+ scopedThemeMap.emplace(
294
293
  unistyle->parent,
295
294
  jsi::Value(rt, parsedStyleSheet)
296
295
  );
297
296
  }
298
297
 
299
- this->rebuildUnistyleWithScopedTheme(
300
- rt,
301
- parsedStyleSheet,
302
- unistyleData
303
- );
298
+ this->rebuildUnistyleWithScopedTheme(rt, parsedStyleSheet, unistyleData);
304
299
  } else {
305
- unistyle->rawValue = parsedStyleSheetsWithDefaultTheme[unistyleStyleSheet].asObject(rt).getProperty(rt, unistyle->styleKey.c_str()).asObject(rt);
306
- this->rebuildUnistyle(rt, unistyle, unistyleData->variants, unistyleData->dynamicFunctionMetadata);
300
+ unistyle->rawValue = parsedSheetObj
301
+ .getProperty(rt, unistyle->styleKey.c_str())
302
+ .asObject(rt);
303
+ this->rebuildUnistyle(
304
+ rt, unistyle, unistyleData->variants,
305
+ unistyleData->dynamicFunctionMetadata
306
+ );
307
307
  unistyleData->parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
308
308
  unistyle->isDirty = true;
309
309
  }
310
310
 
311
- if (!parsedUnistyles.contains(unistyle)) {
312
- parsedUnistyles.emplace(unistyle, true);
313
- }
311
+ parsedUnistyles.insert(unistyle);
314
312
  }
315
313
  }
316
314
 
317
- // parse whatever left in StyleSheets to be later accessible
318
- // for createUnistylesComponent
319
- for (auto styleSheet : styleSheets) {
315
+ // Parse whatever left in StyleSheets to be later accessible
316
+ for (const auto& styleSheet : styleSheets) {
317
+ auto& parsedSheetValue = parsedStyleSheetsWithDefaultTheme[styleSheet];
318
+ auto parsedSheetObj = parsedSheetValue.asObject(rt);
319
+
320
320
  for (auto& [_, unistyle] : styleSheet->unistyles) {
321
321
  if (!parsedUnistyles.contains(unistyle)) {
322
- unistyle->rawValue = parsedStyleSheetsWithDefaultTheme[styleSheet].asObject(rt).getProperty(rt, unistyle->styleKey.c_str()).asObject(rt);
322
+ unistyle->rawValue = parsedSheetObj
323
+ .getProperty(rt, unistyle->styleKey.c_str())
324
+ .asObject(rt);
323
325
  unistyle->isDirty = true;
324
326
  }
325
327
  }
@@ -372,11 +374,12 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle
372
374
  void parser::Parser::rebuildShadowLeafUpdates(jsi::Runtime& rt, core::DependencyMap& dependencyMap) {
373
375
  auto& registry = core::UnistylesRegistry::get();
374
376
 
375
- registry.trafficController.withLock([this, &rt, &dependencyMap, &registry](){
377
+ registry.trafficController.withLock([this, &rt, &dependencyMap, &registry]() {
376
378
  shadow::ShadowLeafUpdates updates;
377
-
379
+ updates.reserve(dependencyMap.size());
380
+
378
381
  for (const auto& [shadowNode, unistyles] : dependencyMap) {
379
- // this step is required to parse string colors eg. #000000 to int representation
382
+ // Parse string colors (e.g., "#000000") to int representation
380
383
  auto rawProps = this->parseStylesToShadowTreeStyles(rt, unistyles);
381
384
 
382
385
  updates.emplace(shadowNode, std::move(rawProps));
@@ -387,6 +390,7 @@ void parser::Parser::rebuildShadowLeafUpdates(jsi::Runtime& rt, core::Dependency
387
390
  });
388
391
  }
389
392
 
393
+
390
394
  // first level of StyleSheet, we can expect here different properties than on second level
391
395
  // eg. variants, compoundVariants, mq, breakpoints etc.
392
396
  jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, std::optional<Variants> variants) {
@@ -420,6 +424,13 @@ jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared u
420
424
  return;
421
425
  }
422
426
 
427
+ // special case as we need to convert it to jsi::Array<jsi::Object>
428
+ if (propertyName == "boxShadow" && propertyValue.isString()) {
429
+ parsedStyle.setProperty(rt, jsi::PropNameID::forUtf8(rt, propertyName), parseBoxShadowString(rt, propertyValue.asString(rt).utf8(rt)));
430
+
431
+ return;
432
+ }
433
+
423
434
  // primitives
424
435
  if (propertyValue.isNumber() || propertyValue.isString() || propertyValue.isUndefined() || propertyValue.isNull()) {
425
436
  parsedStyle.setProperty(rt, jsi::PropNameID::forUtf8(rt, propertyName), propertyValue);
@@ -592,7 +603,7 @@ jsi::Value parser::Parser::parseTransforms(jsi::Runtime& rt, Unistyle::Shared un
592
603
  jsi::Value parser::Parser::parseBoxShadow(jsi::Runtime &rt, Unistyle::Shared unistyle, jsi::Object &obj) {
593
604
  std::vector<jsi::Value> parsedBoxShadows{};
594
605
 
595
- parsedBoxShadows.reserve(2);
606
+ parsedBoxShadows.reserve(1);
596
607
 
597
608
  helpers::iterateJSIArray(rt, obj.asArray(rt), [&](size_t i, jsi::Value& value){
598
609
  if (!value.isObject()) {
@@ -614,6 +625,13 @@ jsi::Value parser::Parser::parseBoxShadow(jsi::Runtime &rt, Unistyle::Shared uni
614
625
  return result;
615
626
  }
616
627
 
628
+ jsi::Array parser::Parser::parseBoxShadowString(jsi::Runtime& rt, std::string&& boxShadowString) {
629
+ auto& registry = core::UnistylesRegistry::get();
630
+ auto& state = registry.getState(rt);
631
+
632
+ return state.parseBoxShadowString(std::move(boxShadowString));
633
+ }
634
+
617
635
  // eg. [{ brightness: 0.5 }, { opacity: 0.25 }]
618
636
  jsi::Value parser::Parser::parseFilters(jsi::Runtime &rt, Unistyle::Shared unistyle, jsi::Object &obj) {
619
637
  std::vector<jsi::Value> parsedFilters{};
@@ -863,8 +881,16 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
863
881
  jsi::Object parsedStyle = jsi::Object(rt);
864
882
 
865
883
  helpers::enumerateJSIObject(rt, nestedObjectStyle, [&](const std::string& propertyName, jsi::Value& propertyValue){
866
- // primitives
867
- if (propertyValue.isString() || propertyValue.isNumber() || propertyValue.isUndefined() || propertyValue.isNull()) {
884
+ // special case as we need to convert it to jsi::Array<jsi::Object>
885
+ // possible with variants and compoundVariants
886
+ if (propertyName == "boxShadow" && propertyValue.isString()) {
887
+ parsedStyle.setProperty(rt, jsi::PropNameID::forUtf8(rt, propertyName), parseBoxShadowString(rt, propertyValue.asString(rt).utf8(rt)));
888
+
889
+ return;
890
+ }
891
+
892
+ // primitives, bool is possible for boxShadow inset
893
+ if (propertyValue.isString() || propertyValue.isNumber() || propertyValue.isUndefined() || propertyValue.isNull() || propertyValue.isBool()) {
868
894
  parsedStyle.setProperty(rt, propertyName.c_str(), propertyValue);
869
895
 
870
896
  return;
@@ -884,13 +910,13 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
884
910
 
885
911
  return;
886
912
  }
887
-
913
+
888
914
  auto isArray = nestedObjectStyle.isArray(rt);
889
-
915
+
890
916
  if (!isArray) {
891
917
  parsedStyle.setProperty(rt, propertyName.c_str(), this->getValueFromBreakpoints(rt, unistyle, nestedObjectStyle));
892
918
  }
893
-
919
+
894
920
  // possible with variants and compoundVariants
895
921
  if (propertyName == "transform") {
896
922
  parsedStyle.setProperty(rt, propertyName.c_str(), parseTransforms(rt, unistyle, nestedObjectStyle));
@@ -928,69 +954,108 @@ jsi::Value parser::Parser::parseSecondLevel(jsi::Runtime &rt, Unistyle::Shared u
928
954
 
929
955
  // convert unistyles to folly with int colors
930
956
  folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles) {
931
- jsi::Object convertedStyles = jsi::Object(rt);
957
+ jsi::Object convertedStyles(rt);
932
958
  auto& state = core::UnistylesRegistry::get().getState(rt);
933
959
 
934
960
  for (const auto& unistyleData : unistyles) {
935
- // this can happen for exotic stylesheets
936
961
  if (!unistyleData->parsedStyle.has_value()) {
937
962
  continue;
938
963
  }
939
964
 
940
- helpers::enumerateJSIObject(rt, unistyleData->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
941
- if (this->isColor(propertyName)) {
942
- return convertedStyles.setProperty(rt, propertyName.c_str(), jsi::Value(state.parseColor(propertyValue)));
943
- }
944
-
945
- if (!propertyValue.isObject()) {
946
- return convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
947
- }
948
-
949
- auto objValue = propertyValue.asObject(rt);
950
-
951
- if (!objValue.isArray(rt)) {
952
- return convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
953
- }
954
-
955
- // parse nested arrays like boxShadow
956
- auto arrValue = objValue.asArray(rt);
957
- auto parsedArray = jsi::Array(rt, arrValue.length(rt));
965
+ helpers::enumerateJSIObject(
966
+ rt,
967
+ unistyleData->parsedStyle.value(),
968
+ [this, &rt, &state, &convertedStyles](const std::string& propertyName, jsi::Value& propertyValue) {
969
+ if (this->isColor(propertyName)) {
970
+ convertedStyles.setProperty(
971
+ rt,
972
+ propertyName.c_str(),
973
+ jsi::Value(state.parseColor(propertyValue))
974
+ );
958
975
 
959
- helpers::iterateJSIArray(rt, arrValue, [&](size_t i, jsi::Value& nestedValue){
960
- if (nestedValue.isObject()) {
961
- jsi::Object obj = jsi::Object(rt);
976
+ return;
977
+ }
962
978
 
963
- helpers::enumerateJSIObject(rt, nestedValue.asObject(rt), [&](const std::string& propertyName, jsi::Value& propertyValue){
964
- if (this->isColor(propertyName)) {
965
- obj.setProperty(rt, propertyName.c_str(), state.parseColor(propertyValue));
979
+ if (!propertyValue.isObject()) {
980
+ convertedStyles.setProperty(
981
+ rt,
982
+ propertyName.c_str(),
983
+ propertyValue
984
+ );
966
985
 
967
- return;
968
- }
986
+ return;
987
+ }
969
988
 
970
- obj.setProperty(rt, propertyName.c_str(), propertyValue);
971
- });
989
+ jsi::Object objValue = propertyValue.asObject(rt);
972
990
 
973
- parsedArray.setValueAtIndex(rt, i, std::move(obj));
991
+ if (!objValue.isArray(rt)) {
992
+ convertedStyles.setProperty(
993
+ rt,
994
+ propertyName.c_str(),
995
+ propertyValue
996
+ );
974
997
 
975
998
  return;
976
999
  }
977
1000
 
978
- if (this->isColor(propertyName)) {
979
- parsedArray.setValueAtIndex(rt, i, jsi::Value(state.parseColor(nestedValue)));
1001
+ // parse nested arrays like boxShadow
1002
+ jsi::Array arrValue = objValue.asArray(rt);
1003
+ size_t arrLen = arrValue.length(rt);
1004
+ jsi::Array parsedArray(rt, arrLen);
980
1005
 
981
- return;
982
- }
1006
+ helpers::iterateJSIArray(
1007
+ rt,
1008
+ arrValue,
1009
+ [this, &rt, &state, &propertyName, &parsedArray](size_t i, jsi::Value& nestedValue) {
1010
+ if (nestedValue.isObject()) {
1011
+ jsi::Object obj(rt);
1012
+
1013
+ helpers::enumerateJSIObject(
1014
+ rt,
1015
+ nestedValue.asObject(rt),
1016
+ [this, &rt, &state, &obj](const std::string& nestedPropName, jsi::Value& nestedPropValue) {
1017
+ if (this->isColor(nestedPropName)) {
1018
+ obj.setProperty(
1019
+ rt,
1020
+ nestedPropName.c_str(),
1021
+ state.parseColor(nestedPropValue)
1022
+ );
1023
+ } else {
1024
+ obj.setProperty(
1025
+ rt,
1026
+ nestedPropName.c_str(),
1027
+ nestedPropValue
1028
+ );
1029
+ }
1030
+ }
1031
+ );
1032
+
1033
+ parsedArray.setValueAtIndex(rt, i, obj);
1034
+
1035
+ return;
1036
+ }
983
1037
 
984
- parsedArray.setValueAtIndex(rt, i, nestedValue);
985
- });
1038
+ if (this->isColor(propertyName)) {
1039
+ parsedArray.setValueAtIndex(
1040
+ rt,
1041
+ i,
1042
+ jsi::Value(state.parseColor(nestedValue))
1043
+ );
1044
+ } else {
1045
+ parsedArray.setValueAtIndex(rt, i, nestedValue);
1046
+ }
1047
+ }
1048
+ );
986
1049
 
987
- return convertedStyles.setProperty(rt, propertyName.c_str(), parsedArray);
988
- });
1050
+ convertedStyles.setProperty(rt, propertyName.c_str(), parsedArray);
1051
+ }
1052
+ );
989
1053
  }
990
1054
 
991
- return jsi::dynamicFromValue(rt, std::move(convertedStyles));
1055
+ return jsi::dynamicFromValue(rt, jsi::Value(rt, convertedStyles));
992
1056
  }
993
1057
 
1058
+
994
1059
  // check is styleKey contains color
995
1060
  bool parser::Parser::isColor(const std::string& propertyName) {
996
1061
  std::string str = propertyName;
@@ -40,6 +40,7 @@ private:
40
40
  std::vector<UnistyleDependency> parseDependencies(jsi::Runtime &rt, jsi::Object&& dependencies);
41
41
  jsi::Value parseTransforms(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
42
42
  jsi::Value parseBoxShadow(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
43
+ jsi::Array parseBoxShadowString(jsi::Runtime& rt, std::string&& boxShadowString);
43
44
  jsi::Value parseFilters(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
44
45
  jsi::Value getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
45
46
  jsi::Object parseVariants(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj, Variants& variants);
@@ -8,7 +8,7 @@ using AffectedNodes = std::unordered_map<const ShadowNodeFamily*, std::unordered
8
8
 
9
9
  void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shadowTreeRegistry) {
10
10
  auto& registry = core::UnistylesRegistry::get();
11
-
11
+
12
12
  registry.trafficController.withLock([&](){
13
13
  auto updates = registry.trafficController.getUpdates();
14
14
 
@@ -20,20 +20,14 @@ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shado
20
20
  // we could iterate via updates and create multiple commits
21
21
  // but it can cause performance issues for hundreds of nodes
22
22
  // so let's mutate Shadow Tree in single transaction
23
- auto transaction = [&](const RootShadowNode& oldRootShadowNode) {
23
+ auto transaction = [&updates](const RootShadowNode& oldRootShadowNode) {
24
24
  auto affectedNodes = shadow::ShadowTreeManager::findAffectedNodes(oldRootShadowNode, updates);
25
- auto newRootNode = std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
25
+
26
+ return std::static_pointer_cast<RootShadowNode>(shadow::ShadowTreeManager::cloneShadowTree(
26
27
  oldRootShadowNode,
27
28
  updates,
28
29
  affectedNodes
29
30
  ));
30
-
31
- // set unistyles trait
32
- auto unistylesRootNode = std::reinterpret_pointer_cast<core::UnistylesCommitShadowNode>(newRootNode);
33
-
34
- unistylesRootNode->addUnistylesCommitTrait();
35
-
36
- return newRootNode;
37
31
  };
38
32
 
39
33
  // commit once!
@@ -71,18 +65,17 @@ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shado
71
65
  AffectedNodes shadow::ShadowTreeManager::findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates) {
72
66
  AffectedNodes affectedNodes;
73
67
 
74
- // compute affected nodes (sub tree)
75
- std::for_each(updates.begin(), updates.end(), [&](const auto& pair) {
76
- const auto& [family, _] = pair;
77
- const auto familyAncestors = family->getAncestors(rootNode);
68
+ for (const auto& [family, _] : updates) {
69
+ auto familyAncestors = family->getAncestors(rootNode);
78
70
 
79
- for (const auto& [parentNode, index] : std::ranges::reverse_view(familyAncestors)) {
71
+ for (auto it = familyAncestors.rbegin(); it != familyAncestors.rend(); ++it) {
72
+ const auto& [parentNode, index] = *it;
80
73
  const auto parentFamily = &parentNode.get().getFamily();
81
- std::unordered_set<int>& affectedNode = affectedNodes[parentFamily];
74
+ auto [setIt, inserted] = affectedNodes.try_emplace(parentFamily, std::unordered_set<int>{});
82
75
 
83
- affectedNode.insert(index);
76
+ setIt->second.insert(index);
84
77
  }
85
- });
78
+ }
86
79
 
87
80
  return affectedNodes;
88
81
  }
@@ -93,44 +86,54 @@ ShadowNode::Unshared shadow::ShadowTreeManager::cloneShadowTree(const ShadowNode
93
86
  const auto family = &shadowNode.getFamily();
94
87
  const auto rawPropsIt = updates.find(family);
95
88
  const auto childrenIt = affectedNodes.find(family);
96
- auto children = shadowNode.getChildren();
97
89
 
98
- // for each affected node
90
+ // Only copy children if we need to update them
91
+ std::shared_ptr<ShadowNode::ListOfShared> childrenPtr;
92
+ const auto& originalChildren = shadowNode.getChildren();
93
+
99
94
  if (childrenIt != affectedNodes.end()) {
100
- // get all indexes of children and clone it recursively
95
+ auto children = originalChildren;
96
+
101
97
  for (const auto index : childrenIt->second) {
102
98
  children[index] = cloneShadowTree(*children[index], updates, affectedNodes);
103
99
  }
100
+
101
+ childrenPtr = std::make_shared<ShadowNode::ListOfShared>(std::move(children));
102
+ } else {
103
+ childrenPtr = std::make_shared<ShadowNode::ListOfShared>(originalChildren);
104
104
  }
105
105
 
106
106
  Props::Shared updatedProps = nullptr;
107
107
 
108
- // clone props for our target shadow node and place fresh RawProps
109
108
  if (rawPropsIt != updates.end()) {
109
+ const auto& componentDescriptor = shadowNode.getComponentDescriptor();
110
+ const auto& props = shadowNode.getProps();
111
+
110
112
  PropsParserContext propsParserContext{
111
113
  shadowNode.getSurfaceId(),
112
114
  *shadowNode.getContextContainer()
113
115
  };
114
116
 
115
- // this is important and critical
116
- // first of all Android doesn't like nullish props (they work perfectly fine on iOS)
117
- // second of all Android props MUST be constructed from previous props, otherwise RawProps::~RawProps error occurs
118
- // Meta wants to remove shadowNode.getProps()->rawProps, but for now it's the only viable solution
117
+ folly::dynamic newProps;
119
118
  #ifdef ANDROID
120
- auto safeProps = rawPropsIt->second == nullptr ? folly::dynamic::object() : rawPropsIt->second;
121
- auto newProps = folly::dynamic::merge(shadowNode.getProps()->rawProps, safeProps);
119
+ auto safeProps = rawPropsIt->second == nullptr
120
+ ? folly::dynamic::object()
121
+ : rawPropsIt->second;
122
+ newProps = folly::dynamic::merge(props->rawProps, safeProps);
122
123
  #else
123
- auto newProps = rawPropsIt->second;
124
+ newProps = rawPropsIt->second;
124
125
  #endif
125
126
 
126
- updatedProps = shadowNode
127
- .getComponentDescriptor()
128
- .cloneProps(propsParserContext, shadowNode.getProps(), RawProps(newProps));
127
+ updatedProps = componentDescriptor.cloneProps(
128
+ propsParserContext,
129
+ props,
130
+ RawProps(newProps)
131
+ );
129
132
  }
130
133
 
131
134
  return shadowNode.clone({
132
135
  updatedProps ? updatedProps : ShadowNodeFragment::propsPlaceholder(),
133
- std::make_shared<ShadowNode::ListOfShared>(children),
136
+ childrenPtr,
134
137
  shadowNode.getState()
135
138
  });
136
139
  }
@@ -5,7 +5,6 @@
5
5
  #include <react/renderer/uimanager/UIManager.h>
6
6
  #include <ranges>
7
7
  #include "ShadowLeafUpdate.h"
8
- #include "UnistylesCommitShadowNode.h"
9
8
  #include "UnistylesRegistry.h"
10
9
 
11
10
  namespace margelo::nitro::unistyles::shadow {
@@ -6,13 +6,9 @@
6
6
 
7
7
  #import <React/RCTEventEmitter.h>
8
8
  #import "TurboUnistyles/TurboUnistyles.h"
9
- #import <React/RCTSurfacePresenter.h>
10
- #import <React/RCTScheduler.h>
11
- #import <React/RCTCallInvoker.h>
12
- #import <React/RCTCallInvokerModule.h>
13
9
  #import <ReactCommon/RCTTurboModuleWithJSIBindings.h>
14
10
 
15
- @interface UnistylesModule: RCTEventEmitter<NativeTurboUnistylesSpec, RCTCallInvokerModule>
11
+ @interface UnistylesModule: RCTEventEmitter<NativeTurboUnistylesSpec>
16
12
  @end
17
13
 
18
14
  @interface UnistylesModule()<RCTTurboModuleWithJSIBindings>
@@ -10,18 +10,11 @@ using namespace margelo::nitro;
10
10
 
11
11
  RCT_EXPORT_MODULE(Unistyles)
12
12
 
13
- __weak RCTSurfacePresenter* _surfacePresenter;
14
- @synthesize callInvoker = _callInvoker;
15
-
16
13
  + (BOOL)requiresMainQueueSetup {
17
14
  return YES;
18
15
  }
19
16
 
20
- - (void)setSurfacePresenter:(id<RCTSurfacePresenterStub>)surfacePresenter {
21
- _surfacePresenter = surfacePresenter;
22
- }
23
-
24
- - (void)installJSIBindingsWithRuntime:(jsi::Runtime&)rt {
17
+ - (void)installJSIBindingsWithRuntime:(jsi::Runtime&)rt callInvoker:(const std::shared_ptr<facebook::react::CallInvoker> &)callInvoker {
25
18
  // function is called on: first init and every live reload
26
19
  // check if this is live reload, if so let's replace UnistylesRuntime with new runtime
27
20
  auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
@@ -32,18 +25,17 @@ __weak RCTSurfacePresenter* _surfacePresenter;
32
25
  HybridObjectRegistry::unregisterHybridObjectConstructor("UnistylesShadowRegistry");
33
26
  }
34
27
 
35
- [self createHybrids:rt];
28
+ [self createHybrids:rt callInvoker:callInvoker];
36
29
  }
37
30
 
38
- - (void)createHybrids:(jsi::Runtime&)rt {
39
- auto runOnJSThread = [callInvoker = _callInvoker.callInvoker](std::function<void(jsi::Runtime& rt)> &&callback){
31
+ - (void)createHybrids:(jsi::Runtime&)rt callInvoker:(const std::shared_ptr<facebook::react::CallInvoker> &)callInvoker {
32
+ auto runOnJSThread = [callInvoker](std::function<void(jsi::Runtime& rt)> &&callback){
40
33
  callInvoker->invokeAsync(std::move(callback));
41
34
  };
42
35
 
43
36
  auto nativePlatform = Unistyles::NativePlatform::create().getCxxPart();
44
37
  auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, rt, runOnJSThread);
45
- auto uiManager = [_surfacePresenter scheduler].uiManager;
46
- auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime, uiManager);
38
+ auto styleSheet = std::make_shared<HybridStyleSheet>(unistylesRuntime);
47
39
 
48
40
  HybridObjectRegistry::registerHybridObjectConstructor("UnistylesRuntime", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
49
41
  return unistylesRuntime;