react-native-unistyles 3.0.0-alpha.9 → 3.0.0-beta.1

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 (596) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -41
  3. package/Unistyles.podspec +1 -1
  4. package/android/CMakeLists.txt +22 -45
  5. package/android/build.gradle +16 -5
  6. package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
  7. package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
  8. package/android/src/main/cxx/cpp-adapter.cpp +8 -86
  9. package/android/src/main/java/com/unistyles/Equatable.kt +61 -0
  10. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +294 -0
  11. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +152 -0
  12. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +59 -0
  13. package/android/src/main/java/com/unistyles/UnistylesModule.kt +51 -0
  14. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
  15. package/cxx/NativePlatform.h +11 -0
  16. package/cxx/common/Constants.h +3 -0
  17. package/cxx/common/Helpers.h +59 -6
  18. package/cxx/core/HostStyle.cpp +7 -2
  19. package/cxx/core/HostStyle.h +1 -1
  20. package/cxx/core/StyleSheet.h +0 -1
  21. package/cxx/core/Unistyle.h +8 -5
  22. package/cxx/core/UnistyleData.h +4 -3
  23. package/cxx/core/UnistyleWrapper.h +102 -7
  24. package/cxx/core/UnistylesCommitHook.cpp +14 -18
  25. package/cxx/core/UnistylesCommitHook.h +6 -11
  26. package/cxx/core/UnistylesCommitShadowNode.h +13 -0
  27. package/cxx/core/UnistylesMountHook.cpp +28 -0
  28. package/cxx/core/UnistylesMountHook.h +27 -0
  29. package/cxx/core/UnistylesRegistry.cpp +108 -48
  30. package/cxx/core/UnistylesRegistry.h +10 -10
  31. package/cxx/core/UnistylesState.cpp +29 -8
  32. package/cxx/core/UnistylesState.h +5 -2
  33. package/cxx/hybridObjects/HybridNavigationBar.cpp +0 -4
  34. package/cxx/hybridObjects/HybridNavigationBar.h +3 -4
  35. package/cxx/hybridObjects/HybridShadowRegistry.cpp +18 -13
  36. package/cxx/hybridObjects/HybridStatusBar.cpp +0 -4
  37. package/cxx/hybridObjects/HybridStatusBar.h +3 -4
  38. package/cxx/hybridObjects/HybridStyleSheet.cpp +145 -19
  39. package/cxx/hybridObjects/HybridStyleSheet.h +27 -5
  40. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +78 -11
  41. package/cxx/hybridObjects/HybridUnistylesRuntime.h +17 -3
  42. package/cxx/parser/Parser.cpp +200 -63
  43. package/cxx/parser/Parser.h +7 -5
  44. package/cxx/shadowTree/ShadowLeafUpdate.h +3 -1
  45. package/cxx/shadowTree/ShadowTrafficController.h +71 -0
  46. package/cxx/shadowTree/ShadowTreeManager.cpp +28 -19
  47. package/cxx/shadowTree/ShadowTreeManager.h +3 -2
  48. package/ios/Equatable.swift +2 -1
  49. package/ios/Extensions.swift +3 -1
  50. package/ios/NativePlatform+ios.swift +34 -9
  51. package/ios/NativePlatform+keyboard.swift +83 -0
  52. package/ios/NativePlatformListener+ios.swift +36 -24
  53. package/ios/Unistyles.h +1 -0
  54. package/ios/UnistylesModuleOnLoad.h +8 -2
  55. package/ios/UnistylesModuleOnLoad.mm +9 -1
  56. package/lib/commonjs/components/Display.js +18 -0
  57. package/lib/commonjs/components/Display.js.map +1 -0
  58. package/lib/commonjs/components/Hide.js +18 -0
  59. package/lib/commonjs/components/Hide.js.map +1 -0
  60. package/lib/commonjs/components/Pressable.js +74 -0
  61. package/lib/commonjs/components/Pressable.js.map +1 -0
  62. package/lib/commonjs/components/Pressable.web.js +115 -0
  63. package/lib/commonjs/components/Pressable.web.js.map +1 -0
  64. package/lib/commonjs/components/index.js +27 -0
  65. package/lib/commonjs/components/index.js.map +1 -0
  66. package/lib/commonjs/core/createUnistylesComponent.js +79 -0
  67. package/lib/commonjs/core/createUnistylesComponent.js.map +1 -0
  68. package/lib/commonjs/core/createUnistylesComponent.native.js +82 -0
  69. package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -0
  70. package/lib/commonjs/core/getBoundArgs.js +18 -0
  71. package/lib/commonjs/core/getBoundArgs.js.map +1 -0
  72. package/lib/commonjs/core/getId.js +9 -0
  73. package/lib/commonjs/core/getId.js.map +1 -0
  74. package/lib/commonjs/core/index.js +27 -0
  75. package/lib/commonjs/core/index.js.map +1 -0
  76. package/lib/commonjs/hooks/index.js +13 -0
  77. package/lib/commonjs/hooks/index.js.map +1 -0
  78. package/lib/commonjs/hooks/useMedia.js +59 -0
  79. package/lib/commonjs/hooks/useMedia.js.map +1 -0
  80. package/lib/commonjs/hooks/useMedia.web.js +43 -0
  81. package/lib/commonjs/hooks/useMedia.web.js.map +1 -0
  82. package/lib/commonjs/index.js +28 -11
  83. package/lib/commonjs/index.js.map +1 -1
  84. package/lib/commonjs/mq.js +31 -18
  85. package/lib/commonjs/mq.js.map +1 -1
  86. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js +1 -0
  87. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  88. package/lib/commonjs/specs/NavigtionBar/index.js +0 -15
  89. package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
  90. package/lib/commonjs/specs/ShadowRegistry/index.js +11 -8
  91. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  92. package/lib/commonjs/specs/StatusBar/index.js +0 -5
  93. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  94. package/lib/commonjs/specs/StyleSheet/index.js +1 -0
  95. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  96. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
  97. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
  98. package/lib/commonjs/specs/UnistylesRuntime/index.js +0 -2
  99. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  100. package/lib/commonjs/specs/index.js +7 -0
  101. package/lib/commonjs/specs/index.js.map +1 -1
  102. package/lib/commonjs/specs/index.web.js +0 -7
  103. package/lib/commonjs/specs/index.web.js.map +1 -1
  104. package/lib/commonjs/types/stylesheet.js.map +1 -1
  105. package/lib/commonjs/utils.js +26 -0
  106. package/lib/commonjs/utils.js.map +1 -0
  107. package/lib/commonjs/web/convert/index.js +27 -24
  108. package/lib/commonjs/web/convert/index.js.map +1 -1
  109. package/lib/commonjs/web/convert/object/boxShadow.js +59 -0
  110. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
  111. package/lib/commonjs/web/convert/object/filter.js +42 -0
  112. package/lib/commonjs/web/convert/object/filter.js.map +1 -0
  113. package/lib/commonjs/web/convert/object/index.js +39 -0
  114. package/lib/commonjs/web/convert/object/index.js.map +1 -0
  115. package/lib/commonjs/web/convert/object/objectStyle.js +56 -0
  116. package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
  117. package/lib/commonjs/web/convert/object/transform.js +27 -0
  118. package/lib/commonjs/web/convert/object/transform.js.map +1 -0
  119. package/lib/commonjs/web/convert/pseudo.js +10 -0
  120. package/lib/commonjs/web/convert/pseudo.js.map +1 -0
  121. package/lib/commonjs/web/convert/{boxShadow.js → shadow/boxShadow.js} +22 -37
  122. package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
  123. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
  124. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  125. package/lib/commonjs/web/convert/shadow/index.js +28 -0
  126. package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
  127. package/lib/commonjs/web/convert/{textShadow.js → shadow/textShadow.js} +21 -35
  128. package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
  129. package/lib/commonjs/web/convert/style.js +11 -7
  130. package/lib/commonjs/web/convert/style.js.map +1 -1
  131. package/lib/commonjs/web/convert/types.js.map +1 -1
  132. package/lib/commonjs/web/convert/utils.js +8 -4
  133. package/lib/commonjs/web/convert/utils.js.map +1 -1
  134. package/lib/commonjs/web/create.js +35 -67
  135. package/lib/commonjs/web/create.js.map +1 -1
  136. package/lib/commonjs/web/index.js +18 -7
  137. package/lib/commonjs/web/index.js.map +1 -1
  138. package/lib/commonjs/web/listener.js +61 -0
  139. package/lib/commonjs/web/listener.js.map +1 -0
  140. package/lib/commonjs/web/mock.js +2 -12
  141. package/lib/commonjs/web/mock.js.map +1 -1
  142. package/lib/commonjs/web/registry.js +154 -19
  143. package/lib/commonjs/web/registry.js.map +1 -1
  144. package/lib/commonjs/web/runtime.js +22 -13
  145. package/lib/commonjs/web/runtime.js.map +1 -1
  146. package/lib/commonjs/web/shadowRegistry.js +143 -0
  147. package/lib/commonjs/web/shadowRegistry.js.map +1 -0
  148. package/lib/commonjs/web/state.js +31 -72
  149. package/lib/commonjs/web/state.js.map +1 -1
  150. package/lib/commonjs/web/utils/common.js +39 -0
  151. package/lib/commonjs/web/utils/common.js.map +1 -0
  152. package/lib/commonjs/web/utils/index.js +28 -0
  153. package/lib/commonjs/web/utils/index.js.map +1 -0
  154. package/lib/commonjs/web/utils/unistyle.js +77 -0
  155. package/lib/commonjs/web/utils/unistyle.js.map +1 -0
  156. package/lib/commonjs/web/{variants/getVariants.js → variants.js} +2 -2
  157. package/lib/commonjs/web/variants.js.map +1 -0
  158. package/lib/module/components/Display.js +13 -0
  159. package/lib/module/components/Display.js.map +1 -0
  160. package/lib/module/components/Hide.js +13 -0
  161. package/lib/module/components/Hide.js.map +1 -0
  162. package/lib/module/components/Pressable.js +68 -0
  163. package/lib/module/components/Pressable.js.map +1 -0
  164. package/lib/module/components/Pressable.web.js +109 -0
  165. package/lib/module/components/Pressable.web.js.map +1 -0
  166. package/lib/module/components/index.js +6 -0
  167. package/lib/module/components/index.js.map +1 -0
  168. package/lib/module/core/createUnistylesComponent.js +72 -0
  169. package/lib/module/core/createUnistylesComponent.js.map +1 -0
  170. package/lib/module/core/createUnistylesComponent.native.js +75 -0
  171. package/lib/module/core/createUnistylesComponent.native.js.map +1 -0
  172. package/lib/module/core/getBoundArgs.js +13 -0
  173. package/lib/module/core/getBoundArgs.js.map +1 -0
  174. package/lib/module/core/getId.js +4 -0
  175. package/lib/module/core/getId.js.map +1 -0
  176. package/lib/module/core/index.js +6 -0
  177. package/lib/module/core/index.js.map +1 -0
  178. package/lib/module/hooks/index.js +4 -0
  179. package/lib/module/hooks/index.js.map +1 -0
  180. package/lib/module/hooks/useMedia.js +54 -0
  181. package/lib/module/hooks/useMedia.js.map +1 -0
  182. package/lib/module/hooks/useMedia.web.js +38 -0
  183. package/lib/module/hooks/useMedia.web.js.map +1 -0
  184. package/lib/module/index.js +2 -9
  185. package/lib/module/index.js.map +1 -1
  186. package/lib/module/mq.js +27 -17
  187. package/lib/module/mq.js.map +1 -1
  188. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js +1 -0
  189. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  190. package/lib/module/specs/NavigtionBar/index.js +0 -10
  191. package/lib/module/specs/NavigtionBar/index.js.map +1 -1
  192. package/lib/module/specs/ShadowRegistry/index.js +11 -8
  193. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  194. package/lib/module/specs/StatusBar/index.js +1 -6
  195. package/lib/module/specs/StatusBar/index.js.map +1 -1
  196. package/lib/module/specs/StyleSheet/index.js +1 -0
  197. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  198. package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
  199. package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
  200. package/lib/module/specs/UnistylesRuntime/index.js +0 -2
  201. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  202. package/lib/module/specs/index.js +2 -1
  203. package/lib/module/specs/index.js.map +1 -1
  204. package/lib/module/specs/index.web.js +0 -1
  205. package/lib/module/specs/index.web.js.map +1 -1
  206. package/lib/module/types/stylesheet.js.map +1 -1
  207. package/lib/module/utils.js +21 -0
  208. package/lib/module/utils.js.map +1 -0
  209. package/lib/module/web/convert/index.js +23 -20
  210. package/lib/module/web/convert/index.js.map +1 -1
  211. package/lib/module/web/convert/object/boxShadow.js +54 -0
  212. package/lib/module/web/convert/object/boxShadow.js.map +1 -0
  213. package/lib/module/web/convert/object/filter.js +37 -0
  214. package/lib/module/web/convert/object/filter.js.map +1 -0
  215. package/lib/module/web/convert/object/index.js +6 -0
  216. package/lib/module/web/convert/object/index.js.map +1 -0
  217. package/lib/module/web/convert/object/objectStyle.js +51 -0
  218. package/lib/module/web/convert/object/objectStyle.js.map +1 -0
  219. package/lib/module/web/convert/object/transform.js +22 -0
  220. package/lib/module/web/convert/object/transform.js.map +1 -0
  221. package/lib/module/web/convert/pseudo.js +5 -0
  222. package/lib/module/web/convert/pseudo.js.map +1 -0
  223. package/lib/module/web/convert/shadow/boxShadow.js +57 -0
  224. package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
  225. package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
  226. package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  227. package/lib/module/web/convert/shadow/index.js +5 -0
  228. package/lib/module/web/convert/shadow/index.js.map +1 -0
  229. package/lib/module/web/convert/shadow/textShadow.js +54 -0
  230. package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
  231. package/lib/module/web/convert/style.js +11 -7
  232. package/lib/module/web/convert/style.js.map +1 -1
  233. package/lib/module/web/convert/types.js.map +1 -1
  234. package/lib/module/web/convert/utils.js +5 -3
  235. package/lib/module/web/convert/utils.js.map +1 -1
  236. package/lib/module/web/create.js +37 -69
  237. package/lib/module/web/create.js.map +1 -1
  238. package/lib/module/web/index.js +9 -3
  239. package/lib/module/web/index.js.map +1 -1
  240. package/lib/module/web/listener.js +57 -0
  241. package/lib/module/web/listener.js.map +1 -0
  242. package/lib/module/web/mock.js +1 -11
  243. package/lib/module/web/mock.js.map +1 -1
  244. package/lib/module/web/registry.js +155 -20
  245. package/lib/module/web/registry.js.map +1 -1
  246. package/lib/module/web/runtime.js +23 -14
  247. package/lib/module/web/runtime.js.map +1 -1
  248. package/lib/module/web/shadowRegistry.js +139 -0
  249. package/lib/module/web/shadowRegistry.js.map +1 -0
  250. package/lib/module/web/state.js +32 -73
  251. package/lib/module/web/state.js.map +1 -1
  252. package/lib/module/web/utils/common.js +28 -0
  253. package/lib/module/web/utils/common.js.map +1 -0
  254. package/lib/module/web/utils/index.js +5 -0
  255. package/lib/module/web/utils/index.js.map +1 -0
  256. package/lib/module/web/utils/unistyle.js +65 -0
  257. package/lib/module/web/utils/unistyle.js.map +1 -0
  258. package/lib/module/web/{variants/getVariants.js → variants.js} +2 -2
  259. package/lib/module/web/variants.js.map +1 -0
  260. package/lib/typescript/src/components/Display.d.ts +7 -0
  261. package/lib/typescript/src/components/Display.d.ts.map +1 -0
  262. package/lib/typescript/src/components/Hide.d.ts +7 -0
  263. package/lib/typescript/src/components/Hide.d.ts.map +1 -0
  264. package/lib/typescript/src/components/Pressable.d.ts +8 -0
  265. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  266. package/lib/typescript/src/components/Pressable.web.d.ts +14 -0
  267. package/lib/typescript/src/components/Pressable.web.d.ts.map +1 -0
  268. package/lib/typescript/src/components/index.d.ts +4 -0
  269. package/lib/typescript/src/components/index.d.ts.map +1 -0
  270. package/lib/typescript/src/core/createUnistylesComponent.d.ts +8 -0
  271. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -0
  272. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +8 -0
  273. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -0
  274. package/lib/typescript/src/core/getBoundArgs.d.ts +2 -0
  275. package/lib/typescript/src/core/getBoundArgs.d.ts.map +1 -0
  276. package/lib/typescript/src/core/getId.d.ts +2 -0
  277. package/lib/typescript/src/core/getId.d.ts.map +1 -0
  278. package/lib/typescript/src/core/index.d.ts +4 -0
  279. package/lib/typescript/src/core/index.d.ts.map +1 -0
  280. package/lib/typescript/src/hooks/index.d.ts +2 -0
  281. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  282. package/lib/typescript/src/hooks/useMedia.d.ts +6 -0
  283. package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -0
  284. package/lib/typescript/src/hooks/useMedia.web.d.ts +6 -0
  285. package/lib/typescript/src/hooks/useMedia.web.d.ts.map +1 -0
  286. package/lib/typescript/src/index.d.ts +3 -0
  287. package/lib/typescript/src/index.d.ts.map +1 -1
  288. package/lib/typescript/src/mq.d.ts +8 -0
  289. package/lib/typescript/src/mq.d.ts.map +1 -1
  290. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +8 -6
  291. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
  292. package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts +0 -1
  293. package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts.map +1 -1
  294. package/lib/typescript/src/specs/NavigtionBar/index.d.ts +1 -10
  295. package/lib/typescript/src/specs/NavigtionBar/index.d.ts.map +1 -1
  296. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +4 -4
  297. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  298. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -0
  299. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  300. package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts +0 -1
  301. package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts.map +1 -1
  302. package/lib/typescript/src/specs/StatusBar/index.d.ts +2 -4
  303. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  304. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +3 -1
  305. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
  306. package/lib/typescript/src/specs/StyleSheet/index.d.ts +5 -3
  307. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  308. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
  309. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  310. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +4 -2
  311. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  312. package/lib/typescript/src/specs/index.d.ts +4 -2
  313. package/lib/typescript/src/specs/index.d.ts.map +1 -1
  314. package/lib/typescript/src/specs/index.web.d.ts +0 -2
  315. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  316. package/lib/typescript/src/types/breakpoints.d.ts +11 -11
  317. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  318. package/lib/typescript/src/types/common.d.ts +2 -0
  319. package/lib/typescript/src/types/common.d.ts.map +1 -1
  320. package/lib/typescript/src/types/index.d.ts +2 -2
  321. package/lib/typescript/src/types/index.d.ts.map +1 -1
  322. package/lib/typescript/src/types/stylesheet.d.ts +6 -4
  323. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  324. package/lib/typescript/src/types/variants.d.ts +4 -1
  325. package/lib/typescript/src/types/variants.d.ts.map +1 -1
  326. package/lib/typescript/src/utils.d.ts +2 -0
  327. package/lib/typescript/src/utils.d.ts.map +1 -0
  328. package/lib/typescript/src/web/convert/index.d.ts +1 -2
  329. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  330. package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
  331. package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
  332. package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
  333. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
  334. package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
  335. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
  336. package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
  337. package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
  338. package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
  339. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
  340. package/lib/typescript/src/web/convert/pseudo.d.ts +6 -0
  341. package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -0
  342. package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts +8 -0
  343. package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
  344. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
  345. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
  346. package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
  347. package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
  348. package/lib/typescript/src/web/convert/shadow/textShadow.d.ts +8 -0
  349. package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
  350. package/lib/typescript/src/web/convert/style.d.ts +1 -2
  351. package/lib/typescript/src/web/convert/style.d.ts.map +1 -1
  352. package/lib/typescript/src/web/convert/types.d.ts +7 -1
  353. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  354. package/lib/typescript/src/web/convert/utils.d.ts +8 -4
  355. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  356. package/lib/typescript/src/web/create.d.ts +215 -1221
  357. package/lib/typescript/src/web/create.d.ts.map +1 -1
  358. package/lib/typescript/src/web/index.d.ts +223 -1222
  359. package/lib/typescript/src/web/index.d.ts.map +1 -1
  360. package/lib/typescript/src/web/{listener/listener.d.ts → listener.d.ts} +5 -2
  361. package/lib/typescript/src/web/listener.d.ts.map +1 -0
  362. package/lib/typescript/src/web/mock.d.ts +0 -9
  363. package/lib/typescript/src/web/mock.d.ts.map +1 -1
  364. package/lib/typescript/src/web/registry.d.ts +18 -6
  365. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  366. package/lib/typescript/src/web/runtime.d.ts +6 -5
  367. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  368. package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
  369. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
  370. package/lib/typescript/src/web/state.d.ts +3 -9
  371. package/lib/typescript/src/web/state.d.ts.map +1 -1
  372. package/lib/typescript/src/web/utils/common.d.ts +8 -0
  373. package/lib/typescript/src/web/utils/common.d.ts.map +1 -0
  374. package/lib/typescript/src/web/utils/index.d.ts +3 -0
  375. package/lib/typescript/src/web/utils/index.d.ts.map +1 -0
  376. package/lib/typescript/src/web/utils/unistyle.d.ts +19 -0
  377. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -0
  378. package/lib/typescript/src/web/{variants/getVariants.d.ts → variants.d.ts} +2 -2
  379. package/lib/typescript/src/web/variants.d.ts.map +1 -0
  380. package/nitrogen/generated/android/c++/JColorScheme.hpp +2 -2
  381. package/nitrogen/generated/android/c++/JFunc_void_UnistylesNativeMiniRuntime.hpp +57 -0
  382. package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.hpp +69 -0
  383. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +35 -34
  384. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +15 -6
  385. package/nitrogen/generated/android/c++/JOrientation.hpp +2 -2
  386. package/nitrogen/generated/android/c++/JUnistyleDependency.hpp +5 -2
  387. package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +9 -7
  388. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/ColorScheme.kt +5 -1
  389. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
  390. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/{Func_void_std__vector_UnistyleDependency_.kt → Func_void_UnistylesNativeMiniRuntime.kt} +6 -5
  391. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime.kt +46 -0
  392. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +25 -13
  393. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
  394. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Orientation.kt +5 -1
  395. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistyleDependency.kt +6 -1
  396. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +3 -1
  397. package/nitrogen/generated/android/unistyles+autolinking.cmake +13 -1
  398. package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
  399. package/nitrogen/generated/android/{UnistylesOnLoad.cpp → unistylesOnLoad.cpp} +6 -4
  400. package/nitrogen/generated/android/{UnistylesOnLoad.hpp → unistylesOnLoad.hpp} +1 -1
  401. package/nitrogen/generated/ios/Unistyles+autolinking.rb +6 -4
  402. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +25 -0
  403. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +73 -38
  404. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +1 -30
  405. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +8 -8
  406. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +4 -16
  407. package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +156 -115
  408. package/nitrogen/generated/ios/swift/UnistyleDependency.swift +4 -0
  409. package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +16 -5
  410. package/nitrogen/generated/shared/c++/ColorScheme.hpp +2 -2
  411. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.cpp +2 -2
  412. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +6 -3
  413. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.cpp +0 -1
  414. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -1
  415. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.cpp +1 -0
  416. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +5 -0
  417. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
  418. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.cpp +0 -1
  419. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -1
  420. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +2 -1
  421. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +10 -4
  422. package/nitrogen/generated/shared/c++/Orientation.hpp +2 -2
  423. package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +2 -1
  424. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +10 -9
  425. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +9 -8
  426. package/package.json +24 -37
  427. package/plugin/common.js +27 -2
  428. package/plugin/import.js +29 -3
  429. package/plugin/index.js +104 -15
  430. package/plugin/ref.js +50 -16
  431. package/plugin/style.js +443 -9
  432. package/plugin/stylesheet.js +10 -3
  433. package/src/components/Display.tsx +12 -0
  434. package/src/components/Hide.tsx +12 -0
  435. package/src/components/Pressable.tsx +89 -0
  436. package/src/components/Pressable.web.tsx +129 -0
  437. package/src/components/index.ts +3 -0
  438. package/src/core/createUnistylesComponent.native.tsx +83 -0
  439. package/src/core/createUnistylesComponent.tsx +84 -0
  440. package/src/core/getBoundArgs.ts +15 -0
  441. package/src/core/getId.ts +1 -0
  442. package/src/core/index.ts +3 -0
  443. package/src/hooks/index.ts +1 -0
  444. package/src/hooks/useMedia.ts +64 -0
  445. package/src/hooks/useMedia.web.ts +47 -0
  446. package/src/index.ts +3 -12
  447. package/src/mq.ts +33 -15
  448. package/src/specs/NativePlatform/NativePlatform.nitro.ts +8 -6
  449. package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.ts +0 -1
  450. package/src/specs/NavigtionBar/index.ts +1 -25
  451. package/src/specs/ShadowRegistry/index.ts +17 -12
  452. package/src/specs/ShadowRegistry/types.ts +6 -2
  453. package/src/specs/StatusBar/UnistylesStatusBar.nitro.ts +0 -1
  454. package/src/specs/StatusBar/index.ts +2 -12
  455. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +4 -1
  456. package/src/specs/StyleSheet/index.ts +7 -3
  457. package/src/specs/TurboUnistyles/NativeTurboUnistyles.ts +1 -2
  458. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +2 -2
  459. package/src/specs/UnistylesRuntime/index.ts +4 -3
  460. package/src/specs/index.ts +6 -2
  461. package/src/specs/index.web.ts +0 -4
  462. package/src/types/breakpoints.ts +25 -13
  463. package/src/types/common.ts +2 -0
  464. package/src/types/index.ts +2 -2
  465. package/src/types/stylesheet.ts +7 -5
  466. package/src/types/variants.ts +7 -1
  467. package/src/utils.ts +22 -0
  468. package/src/web/convert/index.ts +24 -24
  469. package/src/web/convert/object/boxShadow.ts +55 -0
  470. package/src/web/convert/object/filter.ts +39 -0
  471. package/src/web/convert/object/index.ts +3 -0
  472. package/src/web/convert/object/objectStyle.ts +69 -0
  473. package/src/web/convert/object/transform.ts +24 -0
  474. package/src/web/convert/pseudo.ts +137 -0
  475. package/src/web/convert/shadow/boxShadow.ts +50 -0
  476. package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
  477. package/src/web/convert/shadow/index.ts +2 -0
  478. package/src/web/convert/shadow/textShadow.ts +48 -0
  479. package/src/web/convert/style.ts +61 -10
  480. package/src/web/convert/types.ts +8 -1
  481. package/src/web/convert/utils.ts +13 -7
  482. package/src/web/create.ts +35 -83
  483. package/src/web/index.ts +9 -4
  484. package/src/web/listener.ts +65 -0
  485. package/src/web/mock.ts +1 -12
  486. package/src/web/registry.ts +202 -28
  487. package/src/web/runtime.ts +29 -18
  488. package/src/web/shadowRegistry.ts +149 -0
  489. package/src/web/state.ts +52 -87
  490. package/src/web/utils/common.ts +45 -0
  491. package/src/web/utils/index.ts +2 -0
  492. package/src/web/utils/unistyle.ts +94 -0
  493. package/src/web/{variants/getVariants.ts → variants.ts} +2 -2
  494. package/android/src/main/cxx/helpers.cpp +0 -105
  495. package/android/src/main/cxx/helpers.h +0 -16
  496. package/android/src/main/cxx/platform.cpp +0 -170
  497. package/android/src/main/cxx/platform.h +0 -20
  498. package/lib/commonjs/web/convert/boxShadow.js.map +0 -1
  499. package/lib/commonjs/web/convert/breakpoint.js +0 -25
  500. package/lib/commonjs/web/convert/breakpoint.js.map +0 -1
  501. package/lib/commonjs/web/convert/shadow.js +0 -68
  502. package/lib/commonjs/web/convert/shadow.js.map +0 -1
  503. package/lib/commonjs/web/convert/textShadow.js.map +0 -1
  504. package/lib/commonjs/web/convert/transform.js +0 -72
  505. package/lib/commonjs/web/convert/transform.js.map +0 -1
  506. package/lib/commonjs/web/listener/index.js +0 -13
  507. package/lib/commonjs/web/listener/index.js.map +0 -1
  508. package/lib/commonjs/web/listener/listener.js +0 -36
  509. package/lib/commonjs/web/listener/listener.js.map +0 -1
  510. package/lib/commonjs/web/mq.js +0 -23
  511. package/lib/commonjs/web/mq.js.map +0 -1
  512. package/lib/commonjs/web/pseudo.js +0 -11
  513. package/lib/commonjs/web/pseudo.js.map +0 -1
  514. package/lib/commonjs/web/utils.js +0 -78
  515. package/lib/commonjs/web/utils.js.map +0 -1
  516. package/lib/commonjs/web/variants/getVariants.js.map +0 -1
  517. package/lib/commonjs/web/variants/index.js +0 -28
  518. package/lib/commonjs/web/variants/index.js.map +0 -1
  519. package/lib/commonjs/web/variants/useVariants.js +0 -75
  520. package/lib/commonjs/web/variants/useVariants.js.map +0 -1
  521. package/lib/module/web/convert/boxShadow.js +0 -72
  522. package/lib/module/web/convert/boxShadow.js.map +0 -1
  523. package/lib/module/web/convert/breakpoint.js +0 -20
  524. package/lib/module/web/convert/breakpoint.js.map +0 -1
  525. package/lib/module/web/convert/shadow.js +0 -63
  526. package/lib/module/web/convert/shadow.js.map +0 -1
  527. package/lib/module/web/convert/textShadow.js +0 -68
  528. package/lib/module/web/convert/textShadow.js.map +0 -1
  529. package/lib/module/web/convert/transform.js +0 -67
  530. package/lib/module/web/convert/transform.js.map +0 -1
  531. package/lib/module/web/listener/index.js +0 -4
  532. package/lib/module/web/listener/index.js.map +0 -1
  533. package/lib/module/web/listener/listener.js +0 -31
  534. package/lib/module/web/listener/listener.js.map +0 -1
  535. package/lib/module/web/mq.js +0 -17
  536. package/lib/module/web/mq.js.map +0 -1
  537. package/lib/module/web/pseudo.js +0 -6
  538. package/lib/module/web/pseudo.js.map +0 -1
  539. package/lib/module/web/utils.js +0 -65
  540. package/lib/module/web/utils.js.map +0 -1
  541. package/lib/module/web/variants/getVariants.js.map +0 -1
  542. package/lib/module/web/variants/index.js +0 -5
  543. package/lib/module/web/variants/index.js.map +0 -1
  544. package/lib/module/web/variants/useVariants.js +0 -70
  545. package/lib/module/web/variants/useVariants.js.map +0 -1
  546. package/lib/typescript/example/App.d.ts +0 -4
  547. package/lib/typescript/example/App.d.ts.map +0 -1
  548. package/lib/typescript/example/Typography.d.ts +0 -11
  549. package/lib/typescript/example/Typography.d.ts.map +0 -1
  550. package/lib/typescript/example/unistyles.d.ts +0 -63
  551. package/lib/typescript/example/unistyles.d.ts.map +0 -1
  552. package/lib/typescript/expo-example/App.d.ts +0 -4
  553. package/lib/typescript/expo-example/App.d.ts.map +0 -1
  554. package/lib/typescript/expo-example/unistyles.d.ts +0 -63
  555. package/lib/typescript/expo-example/unistyles.d.ts.map +0 -1
  556. package/lib/typescript/src/web/convert/boxShadow.d.ts +0 -3
  557. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +0 -1
  558. package/lib/typescript/src/web/convert/breakpoint.d.ts +0 -3
  559. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +0 -1
  560. package/lib/typescript/src/web/convert/shadow.d.ts +0 -2
  561. package/lib/typescript/src/web/convert/shadow.d.ts.map +0 -1
  562. package/lib/typescript/src/web/convert/textShadow.d.ts +0 -3
  563. package/lib/typescript/src/web/convert/textShadow.d.ts.map +0 -1
  564. package/lib/typescript/src/web/convert/transform.d.ts +0 -5
  565. package/lib/typescript/src/web/convert/transform.d.ts.map +0 -1
  566. package/lib/typescript/src/web/listener/index.d.ts +0 -2
  567. package/lib/typescript/src/web/listener/index.d.ts.map +0 -1
  568. package/lib/typescript/src/web/listener/listener.d.ts.map +0 -1
  569. package/lib/typescript/src/web/mq.d.ts +0 -4
  570. package/lib/typescript/src/web/mq.d.ts.map +0 -1
  571. package/lib/typescript/src/web/pseudo.d.ts +0 -4
  572. package/lib/typescript/src/web/pseudo.d.ts.map +0 -1
  573. package/lib/typescript/src/web/utils.d.ts +0 -20
  574. package/lib/typescript/src/web/utils.d.ts.map +0 -1
  575. package/lib/typescript/src/web/variants/getVariants.d.ts.map +0 -1
  576. package/lib/typescript/src/web/variants/index.d.ts +0 -3
  577. package/lib/typescript/src/web/variants/index.d.ts.map +0 -1
  578. package/lib/typescript/src/web/variants/useVariants.d.ts +0 -3
  579. package/lib/typescript/src/web/variants/useVariants.d.ts.map +0 -1
  580. package/nitrogen/generated/android/c++/JFunc_void_std__vector_UnistyleDependency_.hpp +0 -60
  581. package/plugin/__tests__/dependencies.spec.js +0 -438
  582. package/plugin/__tests__/ref.spec.js +0 -1170
  583. package/plugin/__tests__/stylesheet.spec.js +0 -489
  584. package/src/web/convert/boxShadow.ts +0 -72
  585. package/src/web/convert/breakpoint.ts +0 -21
  586. package/src/web/convert/shadow.ts +0 -68
  587. package/src/web/convert/textShadow.ts +0 -69
  588. package/src/web/convert/transform.ts +0 -89
  589. package/src/web/listener/index.ts +0 -1
  590. package/src/web/listener/listener.ts +0 -33
  591. package/src/web/mq.ts +0 -19
  592. package/src/web/pseudo.ts +0 -11
  593. package/src/web/utils.ts +0 -95
  594. package/src/web/variants/index.ts +0 -2
  595. package/src/web/variants/useVariants.ts +0 -79
  596. /package/nitrogen/generated/android/{UnistylesOnLoad.kt → unistylesOnLoad.kt} +0 -0
@@ -0,0 +1,129 @@
1
+ import React, { forwardRef, useEffect, useRef } from 'react'
2
+ import { Pressable as NativePressableReactNative } from 'react-native'
3
+ import type { PressableProps as Props, View, ViewStyle } from 'react-native'
4
+ import { UnistylesShadowRegistry } from '../specs'
5
+
6
+ type WebPressableState = {
7
+ pressed: boolean,
8
+ hovered: boolean,
9
+ focused: boolean
10
+ }
11
+
12
+ type WebPressableStyle = ((state: WebPressableState) => ViewStyle) | ViewStyle
13
+
14
+ type PressableProps = Props & {
15
+ variants?: Record<string, string | boolean>
16
+ style?: WebPressableStyle,
17
+ }
18
+
19
+ const initialState: WebPressableState = {
20
+ pressed: false,
21
+ hovered: false,
22
+ focused: false
23
+ }
24
+
25
+ const events = {
26
+ 'pointerdown': { pressed: true },
27
+ 'pointerup': { pressed: false },
28
+ 'pointerenter': { hovered: true },
29
+ 'pointerleave': { hovered: false },
30
+ 'focus': { focused: true },
31
+ 'blur': { focused: false }
32
+ } satisfies Partial<Record<keyof HTMLElementEventMap, Partial<WebPressableState>>>
33
+
34
+ type UpdateStylesProps = {
35
+ ref: View | null,
36
+ style: WebPressableStyle,
37
+ variants?: Record<string, string | boolean>,
38
+ state: WebPressableState
39
+ }
40
+
41
+ const isFunctionWithBoundArgs = (fn: any): fn is Function & { getBoundArgs: Function } => {
42
+ return typeof fn === 'function' && 'getBoundArgs' in fn
43
+ }
44
+
45
+ const extractFunctionArgs = (styleResult: any) => {
46
+ return isFunctionWithBoundArgs(styleResult)
47
+ ? [styleResult.getBoundArgs()]
48
+ : Array.isArray(styleResult)
49
+ ? styleResult.map(style => isFunctionWithBoundArgs(style) ? style.getBoundArgs() : [])
50
+ : []
51
+ }
52
+
53
+ const extractStyleResult = (style: any) => {
54
+ return typeof style === 'function'
55
+ ? [style()]
56
+ : Array.isArray(style)
57
+ ? style.map(style => typeof style === 'function' ? style() : style)
58
+ : [style]
59
+ }
60
+
61
+ const updateStyles = ({ ref, style, variants, state }: UpdateStylesProps) => {
62
+ const styleResult = typeof style === 'function'
63
+ ? style(state)
64
+ : style
65
+ const fnArgs = extractFunctionArgs(styleResult)
66
+ const extractedResult = extractStyleResult(styleResult)
67
+
68
+ // @ts-expect-error - this is hidden from TS
69
+ UnistylesShadowRegistry.add(ref, extractedResult, variants, fnArgs)
70
+ }
71
+
72
+ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ...props }, passedRef) => {
73
+ const storedRef = useRef<View | null>(null)
74
+ const state = useRef<WebPressableState>(initialState)
75
+ const styleRef = useRef(style)
76
+
77
+ useEffect(() => {
78
+ styleRef.current = style
79
+ }, [style])
80
+
81
+ useEffect(() => {
82
+ const handler = (newState: Partial<WebPressableState>) => () => {
83
+ state.current = { ...state.current, ...newState }
84
+
85
+ updateStyles({
86
+ ref: storedRef.current,
87
+ style: styleRef.current as WebPressableStyle,
88
+ variants,
89
+ state: state.current
90
+ })
91
+ }
92
+
93
+ if (!storedRef.current) {
94
+ return
95
+ }
96
+
97
+ // ref on the web is dom element
98
+ const ref = storedRef.current as unknown as HTMLDivElement
99
+
100
+ Object.entries(events).forEach(([event, state]) => {
101
+ ref.addEventListener(event, handler(state))
102
+ })
103
+
104
+ return () => {
105
+ Object.entries(events).forEach(([event, state]) => {
106
+ ref.removeEventListener(event, handler(state))
107
+ })
108
+ }
109
+ }, [])
110
+
111
+ return (
112
+ <NativePressableReactNative
113
+ {...props}
114
+ ref={ref => {
115
+ storedRef.current = ref
116
+ updateStyles({
117
+ ref,
118
+ style: style as WebPressableStyle,
119
+ variants,
120
+ state: initialState
121
+ })
122
+
123
+ if (typeof passedRef === 'object' && passedRef !== null) {
124
+ passedRef.current = ref
125
+ }
126
+ }}
127
+ />
128
+ )
129
+ })
@@ -0,0 +1,3 @@
1
+ export { Hide } from './Hide'
2
+ export { Display } from './Display'
3
+ export { Pressable } from './Pressable'
@@ -0,0 +1,83 @@
1
+ import React, { type ComponentType, forwardRef, useEffect, useRef, useState } from 'react'
2
+ import type { UnistylesTheme } from '../types'
3
+ import { StyleSheet, UnistyleDependency, UnistylesRuntime, type UnistylesStyleSheet } from '../specs'
4
+ import type { PartialBy } from '../types/common'
5
+ import { deepMergeObjects } from '../utils'
6
+
7
+ const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
8
+ type SupportedStyleProps = typeof SUPPORTED_STYLE_PROPS[number]
9
+
10
+ export const createUnistylesComponent = <TProps extends Record<string, any>, TMappings extends Partial<Omit<TProps, SupportedStyleProps>>>(Component: ComponentType<TProps>, mappings?: (theme: UnistylesTheme) => TMappings) => {
11
+ return forwardRef<unknown, PartialBy<TProps, keyof TMappings | SupportedStyleProps>>((props, ref) => {
12
+ const narrowedProps = props as PartialBy<TProps, keyof TMappings | SupportedStyleProps>
13
+ const [theme, setTheme] = useState<UnistylesTheme>(UnistylesRuntime.getTheme())
14
+ const [, setRt] = useState(0)
15
+ const stylesRef = useRef<Record<string, any>>({})
16
+ const isForcedRef = useRef(false)
17
+
18
+ if (!isForcedRef.current) {
19
+ SUPPORTED_STYLE_PROPS.forEach(propName => {
20
+ if (narrowedProps?.[propName]) {
21
+ if (Array.isArray(narrowedProps[propName])) {
22
+ console.error(`🦄 Unistyles: createUnistylesComponent requires ${propName} to be an object. Please check props for component: ${Component.displayName}`)
23
+ }
24
+
25
+ // @ts-expect-error - this is hidden from TS
26
+ if (props[propName].__unistyles_name && !props[propName].__proto__?.getStyle) {
27
+ console.error(`🦄 Unistyles: createUnistylesComponent received style that is not bound. You likely used the spread operator on a Unistyle style. Please check props for component: ${Component.displayName}`)
28
+ }
29
+
30
+ stylesRef.current = {
31
+ ...stylesRef.current,
32
+ [propName]: narrowedProps[propName]
33
+ }
34
+ }
35
+ })
36
+ }
37
+
38
+ useEffect(() => {
39
+ const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
40
+ const componentDependencies = (narrowedProps.style?.__proto__.uni__dependencies || mappings?.(theme).style?.__proto__.uni__dependencies) as Array<UnistyleDependency>
41
+
42
+ if (dependencies.includes(UnistyleDependency.Theme) && (!componentDependencies ||componentDependencies.includes(UnistyleDependency.Theme))) {
43
+ setTheme(UnistylesRuntime.getTheme())
44
+
45
+ // override with Unistyles styles
46
+ SUPPORTED_STYLE_PROPS.forEach(propName => {
47
+ if (narrowedProps?.[propName]) {
48
+ stylesRef.current = {
49
+ ...stylesRef.current,
50
+ // @ts-expect-error - this is hidden from TS
51
+ [propName]: props[propName].__proto__?.getStyle?.() || props[propName]
52
+ }
53
+ }
54
+ })
55
+
56
+ isForcedRef.current = true
57
+ }
58
+
59
+ if (dependencies.some(dependency => dependency >= 2) && (!componentDependencies || componentDependencies.some(dependency => dependency >= 2))) {
60
+ setRt(prevState => prevState + 1)
61
+ }
62
+ })
63
+
64
+ return () => {
65
+ removeChangeListener()
66
+ }
67
+ }, [])
68
+
69
+ const mergedProps = mappings?.(theme) as Record<string, any> ?? {}
70
+ const finalProps = deepMergeObjects(mergedProps, props)
71
+
72
+ // override with Unistyles styles
73
+ SUPPORTED_STYLE_PROPS.forEach(propName => {
74
+ if (finalProps[propName]) {
75
+ finalProps[propName] = stylesRef.current[propName]
76
+ }
77
+ })
78
+
79
+ isForcedRef.current = false
80
+
81
+ return <Component {...finalProps as TProps} ref={ref} />
82
+ })
83
+ }
@@ -0,0 +1,84 @@
1
+ import React, { useEffect, useState, type ComponentType, forwardRef, useRef, useMemo } from 'react'
2
+ import type { UnistylesTheme } from '../types'
3
+ import { UnistylesRuntime } from '../specs'
4
+ import { UnistyleDependency } from '../specs/NativePlatform'
5
+ import type { PartialBy } from '../types/common'
6
+ import { UnistylesListener } from '../web/listener'
7
+ import { UnistylesShadowRegistry } from '../web'
8
+ import { equal } from '../web/utils'
9
+ import { deepMergeObjects } from '../utils'
10
+
11
+ const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
12
+ const ALL_DEPENDENCIES = Object.values(UnistyleDependency).filter((dependency): dependency is UnistyleDependency => typeof dependency === 'number')
13
+
14
+ type SupportedStyleProps = typeof SUPPORTED_STYLE_PROPS[number]
15
+
16
+ const useShadowRegistry = (style?: Record<string, any>) => {
17
+ const [ref] = useState(document.createElement('div'))
18
+ const oldClassNames = useRef<Array<string>>([])
19
+ const classNames = useMemo(() => {
20
+ if (!style) {
21
+ return []
22
+ }
23
+
24
+ const newClassNames = UnistylesShadowRegistry.add(ref, [style], undefined, []) ?? []
25
+
26
+ if (equal(oldClassNames.current, newClassNames)) {
27
+ return oldClassNames.current
28
+ }
29
+
30
+ oldClassNames.current = newClassNames
31
+
32
+ return newClassNames
33
+ }, [style])
34
+
35
+ useEffect(() => () => {
36
+ // Remove styles on unmount
37
+ if (style) {
38
+ UnistylesShadowRegistry.add(null, [style], undefined, [])
39
+ }
40
+ })
41
+
42
+ return classNames
43
+ }
44
+
45
+ export const createUnistylesComponent = <TProps extends Record<string, any>, TMappings extends Partial<Omit<TProps, SupportedStyleProps>>>(Component: ComponentType<TProps>, mappings?: (theme: UnistylesTheme) => TMappings) => {
46
+ return forwardRef<unknown, PartialBy<TProps, keyof TMappings | SupportedStyleProps>>((props, ref) => {
47
+ const narrowedProps = props as PartialBy<TProps, keyof TMappings | SupportedStyleProps>
48
+ const [mappingsProps, setMappingsProps] = useState(mappings?.(UnistylesRuntime.getTheme()))
49
+ const styleClassNames = useShadowRegistry(narrowedProps.style)
50
+ const contentContainerStyleClassNames = useShadowRegistry(narrowedProps.contentContainerStyle)
51
+
52
+ useEffect(() => {
53
+ const disposeMappings = UnistylesListener.addListeners(ALL_DEPENDENCIES, () => {
54
+ if (!mappings) {
55
+ disposeMappings()
56
+
57
+ return
58
+ }
59
+
60
+ return setMappingsProps(mappings(UnistylesRuntime.getTheme()))
61
+ })
62
+
63
+ return () => disposeMappings()
64
+ }, [mappingsProps, narrowedProps.style])
65
+
66
+ const combinedProps = {
67
+ ...deepMergeObjects(props, (mappingsProps ?? {}) as object),
68
+ ...narrowedProps.style ? {
69
+ style: {
70
+ $$css: true,
71
+ 'unistyles': styleClassNames.join(' ')
72
+ },
73
+ } : {},
74
+ ...narrowedProps.contentContainerStyle ? {
75
+ style: {
76
+ $$css: true,
77
+ 'unistyles': contentContainerStyleClassNames.join(' ')
78
+ },
79
+ } : {},
80
+ } as unknown as TProps
81
+
82
+ return <Component {...combinedProps} ref={ref} />
83
+ })
84
+ }
@@ -0,0 +1,15 @@
1
+ export const getBoundArgs = (fn: Function) => {
2
+ const boundArgs = [] as Array<any>
3
+
4
+ fn.bind = (thisArg, ...args) => {
5
+ boundArgs.push(...args)
6
+
7
+ const newFn = Function.prototype.bind.apply(fn, [thisArg, ...args])
8
+
9
+ newFn.getBoundArgs = () => boundArgs
10
+
11
+ return newFn
12
+ }
13
+
14
+ return fn
15
+ }
@@ -0,0 +1 @@
1
+ export const getId = () => `${Math.random().toString(36).substring(2, 9)}`
@@ -0,0 +1,3 @@
1
+ export { createUnistylesComponent } from './createUnistylesComponent'
2
+ export { getBoundArgs } from './getBoundArgs'
3
+ export { getId } from './getId'
@@ -0,0 +1 @@
1
+ export { useMedia } from './useMedia'
@@ -0,0 +1,64 @@
1
+ import { useEffect, useLayoutEffect, useState } from 'react'
2
+ import { StyleSheet, UnistyleDependency, UnistylesRuntime, type UnistylesStyleSheet } from '../specs'
3
+ import { isValidMq, parseMq, isUnistylesMq } from '../mq'
4
+
5
+ export const useMedia = (config: { mq: symbol }) => {
6
+ const computeIsVisible = (): boolean => {
7
+ const maybeMq = config.mq as unknown as string
8
+
9
+ if (!isUnistylesMq(maybeMq)) {
10
+ console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`)
11
+
12
+ return false
13
+ }
14
+
15
+ const parsedMq = parseMq(maybeMq)
16
+
17
+ if (!isValidMq(parsedMq)) {
18
+ console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`)
19
+
20
+ return false
21
+ }
22
+
23
+ const { width, height } = UnistylesRuntime.screen
24
+
25
+ if (parsedMq.minWidth !== undefined && width < parsedMq.minWidth) {
26
+ return false
27
+ }
28
+
29
+ if (parsedMq.maxWidth !== undefined && width > parsedMq.maxWidth) {
30
+ return false
31
+ }
32
+
33
+ if (parsedMq.minHeight !== undefined && height < parsedMq.minHeight) {
34
+ return false
35
+ }
36
+
37
+ if (parsedMq.maxHeight !== undefined && height > parsedMq.maxHeight) {
38
+ return false
39
+ }
40
+
41
+ return true
42
+ }
43
+ const [isVisible, setIsVisible] = useState<boolean | null>(computeIsVisible())
44
+
45
+ useEffect(() => {
46
+ setIsVisible(computeIsVisible())
47
+ }, [config.mq])
48
+
49
+ useLayoutEffect(() => {
50
+ const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
51
+ if (dependencies.includes(UnistyleDependency.Breakpoints)) {
52
+ setIsVisible(computeIsVisible())
53
+ }
54
+ })
55
+
56
+ return () => {
57
+ removeChangeListener()
58
+ }
59
+ }, [config.mq])
60
+
61
+ return {
62
+ isVisible
63
+ }
64
+ }
@@ -0,0 +1,47 @@
1
+ import { useEffect, useRef, useState } from 'react'
2
+ import { isUnistylesMq, isValidMq, parseMq } from '../mq'
3
+
4
+ export const useMedia = (config: { mq: symbol }) => {
5
+ const disposeRef = useRef(() => {})
6
+ const [isVisible, setIsVisible] = useState(() => {
7
+ const maybeMq = config.mq as unknown as string
8
+
9
+ if (!isUnistylesMq(maybeMq)) {
10
+ console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`)
11
+
12
+ return false
13
+ }
14
+
15
+ const parsedMq = parseMq(maybeMq)
16
+
17
+ if (!isValidMq(parsedMq)) {
18
+ console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`)
19
+
20
+ return false
21
+ }
22
+
23
+ const { minWidth, maxWidth, minHeight, maxHeight } = parsedMq
24
+
25
+ const mediaQuery = [
26
+ minWidth !== undefined ? `(min-width: ${minWidth}px)` : undefined,
27
+ maxWidth !== undefined ? `(max-width: ${maxWidth}px)` : undefined,
28
+ minHeight !== undefined ? `(min-height: ${minHeight}px)` : undefined,
29
+ maxHeight !== undefined ? `(max-height: ${maxHeight}px)` : undefined
30
+ ].filter(Boolean).join(' and ')
31
+
32
+ const media = window.matchMedia(mediaQuery)
33
+ const handler = (event: MediaQueryListEvent) => setIsVisible(event.matches)
34
+
35
+ media.addEventListener('change', handler)
36
+ disposeRef.current = () => media.removeEventListener('change', handler)
37
+
38
+ return media.matches
39
+ })
40
+
41
+ // Unmount
42
+ useEffect(() => () => disposeRef.current(), [])
43
+
44
+ return {
45
+ isVisible
46
+ }
47
+ }
package/src/index.ts CHANGED
@@ -1,15 +1,6 @@
1
- import React from 'react'
2
-
3
1
  export * from './specs'
4
2
  export { mq } from './mq'
5
3
  export type { UnistylesThemes, UnistylesBreakpoints } from './global'
6
-
7
- // todo verify true min version
8
- const minReactVersionRequiredByUnistyles = '18.3.1'
9
-
10
- if (React.version < minReactVersionRequiredByUnistyles) {
11
- throw new Error(`
12
- You are using an outdated version of React (${React.version}).
13
- Unistyles requires at least React ${minReactVersionRequiredByUnistyles}.
14
- `)
15
- }
4
+ export { createUnistylesComponent, getBoundArgs } from './core'
5
+ export type { UnistylesVariants } from './types'
6
+ export * from './components'
package/src/mq.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  import type { Nullable } from './types'
2
2
  import type { UnistylesBreakpoints } from './global'
3
+ import { UnistylesRuntime } from './specs'
4
+
5
+ const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
6
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
7
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/
3
8
 
4
9
  type MQValue = keyof UnistylesBreakpoints | number
5
10
 
@@ -29,16 +34,8 @@ const getMQValue = (value: Nullable<MQValue>) => {
29
34
  return 0
30
35
  }
31
36
 
32
- // todo take it from js
33
- const breakpoints = {
34
- xs: 0,
35
- sm: 300,
36
- md: 500,
37
- lg: 800,
38
- xl: 1200
39
- }
37
+ const breakpoints = UnistylesRuntime.breakpoints
40
38
 
41
- // @ts-ignore
42
39
  return breakpoints[value] ?? 0
43
40
  }
44
41
 
@@ -48,19 +45,40 @@ const getMQValue = (value: Nullable<MQValue>) => {
48
45
  */
49
46
  export const mq: MQHandler = {
50
47
  only: {
51
- width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) => (`:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]` as unknown as symbol),
52
- height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Infinity) => (`:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]` as unknown as symbol)
48
+ width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Number.POSITIVE_INFINITY) => (`:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]` as unknown as symbol),
49
+ height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Number.POSITIVE_INFINITY) => (`:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]` as unknown as symbol)
53
50
  },
54
- width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) => ({
51
+ width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Number.POSITIVE_INFINITY) => ({
55
52
  and: {
56
- height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Infinity) =>
53
+ height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Number.POSITIVE_INFINITY) =>
57
54
  (`:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]` as unknown as symbol)
58
55
  }
59
56
  }),
60
- height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Infinity) => ({
57
+ height: (hMin: Nullable<MQValue> = 0, hMax: MQValue = Number.POSITIVE_INFINITY) => ({
61
58
  and: {
62
- width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) =>
59
+ width: (wMin: Nullable<MQValue> = 0, wMax: MQValue = Number.POSITIVE_INFINITY) =>
63
60
  (`:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]` as unknown as symbol)
64
61
  }
65
62
  })
66
63
  }
64
+
65
+ export const parseMq = (mq: string) => {
66
+ const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || []
67
+ const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || []
68
+
69
+ return {
70
+ minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
71
+ maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
72
+ minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
73
+ maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH),
74
+ }
75
+ }
76
+
77
+ export const isUnistylesMq = (mq: string) => IS_UNISTYLES_REGEX.test(mq)
78
+
79
+ export const isValidMq = (parsedMQ: ReturnType<typeof parseMq>) => {
80
+ const isWidthValid = parsedMQ.minWidth === undefined || parsedMQ.maxWidth === undefined || parsedMQ.minWidth <= parsedMQ.maxWidth
81
+ const isHeightValid = parsedMQ.minHeight === undefined || parsedMQ.maxHeight === undefined || parsedMQ.minHeight <= parsedMQ.maxHeight
82
+
83
+ return isWidthValid && isHeightValid
84
+ }
@@ -1,5 +1,5 @@
1
1
  import type { HybridObject } from 'react-native-nitro-modules'
2
- import { type Dimensions, type Insets } from '../types'
2
+ import type { Dimensions, Insets } from '../types'
3
3
 
4
4
  type ColorScheme = 'dark' | 'light' | 'unspecified'
5
5
  type Orientation = 'portrait' | 'landscape'
@@ -18,7 +18,8 @@ export enum UnistyleDependency {
18
18
  PixelRatio = 10,
19
19
  FontScale = 11,
20
20
  StatusBar = 12,
21
- NavigationBar = 13
21
+ NavigationBar = 13,
22
+ Ime = 14
22
23
  }
23
24
 
24
25
  export interface UnistylesNativeMiniRuntime {
@@ -31,7 +32,8 @@ export interface UnistylesNativeMiniRuntime {
31
32
  readonly rtl: boolean
32
33
  readonly statusBar: Dimensions,
33
34
  readonly navigationBar: Dimensions
34
- readonly orientation: Orientation
35
+ readonly isPortrait: boolean,
36
+ readonly isLandscape: boolean
35
37
  }
36
38
 
37
39
  // represents any native API that can communicate with Unistyles
@@ -49,13 +51,13 @@ export interface NativePlatform extends HybridObject<{ ios: 'swift', android: 'k
49
51
  getPrefersRtlDirection(): boolean,
50
52
 
51
53
  setRootViewBackgroundColor(color: number): void,
52
- setNavigationBarBackgroundColor?(color: number): void,
53
54
  setNavigationBarHidden?(isHidden: boolean): void,
54
55
  setStatusBarHidden(isHidden: boolean): void,
55
- setStatusBarBackgroundColor?(color: number): void,
56
56
  setImmersiveMode(isEnabled: boolean): void,
57
57
 
58
58
  // private
59
59
  getMiniRuntime(): UnistylesNativeMiniRuntime,
60
- registerPlatformListener(callback: (dependencies: Array<UnistyleDependency>) => void): void
60
+ registerPlatformListener(callback: (dependencies: Array<UnistyleDependency>, miniRuntime: UnistylesNativeMiniRuntime) => void): void,
61
+ registerImeListener(callback: (miniRuntime: UnistylesNativeMiniRuntime) => void): void,
62
+ unregisterPlatformListeners(): void
61
63
  }
@@ -5,6 +5,5 @@ export interface UnistylesNavigationBar extends HybridObject<{ ios: 'c++', andro
5
5
  readonly width: number,
6
6
  readonly height: number,
7
7
 
8
- setBackgroundColor(color: number): void,
9
8
  setHidden(isHidden: boolean): void
10
9
  }
@@ -1,25 +1 @@
1
- import { processColor } from 'react-native'
2
- import type { UnistylesNavigationBar as UnistylesNavigationBarSpec } from './UnistylesNavigationBar.nitro'
3
- import type { Color } from '../types'
4
-
5
- interface PrivateUnistylesNavigationBar extends Omit<UnistylesNavigationBarSpec, 'setBackgroundColor'> {
6
- setBackgroundColor(color?: string): void,
7
- _setBackgroundColor(color?: Color): void
8
- }
9
-
10
- export const attachNavigationBarJSMethods = (hybridObject: UnistylesNavigationBar) => {
11
- const privateHybrid = hybridObject as PrivateUnistylesNavigationBar
12
-
13
- privateHybrid._setBackgroundColor = hybridObject.setBackgroundColor
14
- hybridObject.setBackgroundColor = (color?: string) => {
15
- const parsedColor = processColor(color) ?? 0
16
-
17
- privateHybrid._setBackgroundColor(parsedColor as number)
18
- }
19
- }
20
-
21
- type PrivateMethods =
22
- | '_setBackgroundColor'
23
- | 'dispose'
24
-
25
- export type UnistylesNavigationBar = Omit<PrivateUnistylesNavigationBar, PrivateMethods>
1
+ export type { UnistylesNavigationBar } from './UnistylesNavigationBar.nitro'
@@ -4,11 +4,11 @@ import type { ShadowNode, Unistyle, ViewHandle } from './types'
4
4
 
5
5
  interface ShadowRegistry extends UnistylesShadowRegistrySpec {
6
6
  // Babel API
7
- add(handle?: ViewHandle, style?: Unistyle, variants?: Record<string, string | boolean>, args?: Array<any>): void,
8
- remove(handle?: ViewHandle, style?: Unistyle): void,
7
+ add(handle?: ViewHandle, styles?: Array<Unistyle>, variants?: Record<string, string | boolean>, args?: Array<Array<any>>, id?: string): void,
8
+ remove(handle?: ViewHandle): void,
9
9
  // JSI
10
- link(node: ShadowNode, style: Unistyle, variants?: Record<string, string | boolean>, args?: Array<any>): void,
11
- unlink(node: ShadowNode, style: Unistyle): void
10
+ link(node: ShadowNode, styles?: Array<Unistyle>, variants?: Record<string, string | boolean>, args?: Array<Array<any>>, id?: string): void,
11
+ unlink(node: ShadowNode): void
12
12
  }
13
13
 
14
14
  const HybridShadowRegistry = NitroModules.createHybridObject<ShadowRegistry>('UnistylesShadowRegistry')
@@ -19,27 +19,32 @@ const findShadowNodeForHandle = (handle: ViewHandle) => {
19
19
  ?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node
20
20
 
21
21
  if (!node) {
22
- // todo extend log with file name / component name
23
- throw new Error('Could not find shadow node for one of your components')
22
+ throw new Error(`Unistyles: Could not find shadow node for one of your components of type ${handle?.__internalInstanceHandle?.elementType ?? 'unknown'}`)
24
23
  }
25
24
 
26
25
  return node
27
26
  }
28
27
 
29
- HybridShadowRegistry.add = (handle, style, variants, args) => {
30
- if (!handle || !style?.__unid) {
28
+ HybridShadowRegistry.add = (handle, styles, variants, args, id) => {
29
+ // virtualized nodes can be null
30
+ if (!handle || !styles || !Array.isArray(styles)) {
31
31
  return
32
32
  }
33
33
 
34
- HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? [])
34
+ // filter Reanimated styles and styles that are undefined
35
+ const filteredStyles = styles
36
+ .filter(style => !style?.initial?.updater)
37
+ .filter(Boolean)
38
+
39
+ HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles, variants ?? {}, args ?? [], id)
35
40
  }
36
41
 
37
- HybridShadowRegistry.remove = (handle, style) => {
38
- if (!handle || !style?.__unid) {
42
+ HybridShadowRegistry.remove = handle => {
43
+ if (!handle) {
39
44
  return
40
45
  }
41
46
 
42
- HybridShadowRegistry.unlink(findShadowNodeForHandle(handle), style)
47
+ HybridShadowRegistry.unlink(findShadowNodeForHandle(handle))
43
48
  }
44
49
 
45
50
  type PrivateMethods =