react-native-unistyles 3.0.0-beta.1 → 3.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +4 -4
  2. package/Unistyles.podspec +7 -1
  3. package/android/build.gradle +6 -0
  4. package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -2
  5. package/cxx/common/Constants.h +2 -0
  6. package/cxx/core/HostStyle.cpp +12 -7
  7. package/cxx/core/HostStyle.h +5 -0
  8. package/cxx/core/UnistyleData.h +3 -3
  9. package/cxx/core/UnistyleWrapper.h +8 -8
  10. package/cxx/core/UnistylesRegistry.cpp +23 -30
  11. package/cxx/core/UnistylesRegistry.h +8 -2
  12. package/cxx/hybridObjects/HybridShadowRegistry.cpp +108 -12
  13. package/cxx/hybridObjects/HybridShadowRegistry.h +21 -2
  14. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -0
  15. package/cxx/parser/Parser.cpp +182 -26
  16. package/cxx/parser/Parser.h +3 -1
  17. package/ios/UnistylesModuleOnLoad.mm +2 -2
  18. package/lib/commonjs/components/ScopedTheme.js +36 -0
  19. package/lib/commonjs/components/ScopedTheme.js.map +1 -0
  20. package/lib/commonjs/components/Variants.js +33 -0
  21. package/lib/commonjs/components/Variants.js.map +1 -0
  22. package/lib/commonjs/components/index.js +10 -3
  23. package/lib/commonjs/components/index.js.map +1 -1
  24. package/lib/commonjs/components/native/ActivityIndicator.js +10 -0
  25. package/lib/commonjs/components/native/ActivityIndicator.js.map +1 -0
  26. package/lib/commonjs/components/native/FlatList.js +10 -0
  27. package/lib/commonjs/components/native/FlatList.js.map +1 -0
  28. package/lib/commonjs/components/native/Image.js +10 -0
  29. package/lib/commonjs/components/native/Image.js.map +1 -0
  30. package/lib/commonjs/components/native/ImageBackground.js +10 -0
  31. package/lib/commonjs/components/native/ImageBackground.js.map +1 -0
  32. package/lib/commonjs/components/native/KeyboardAvoidingView.js +10 -0
  33. package/lib/commonjs/components/native/KeyboardAvoidingView.js.map +1 -0
  34. package/lib/commonjs/components/{Pressable.web.js → native/Pressable.js} +26 -66
  35. package/lib/commonjs/components/native/Pressable.js.map +1 -0
  36. package/lib/commonjs/components/native/Pressable.native.js +48 -0
  37. package/lib/commonjs/components/native/Pressable.native.js.map +1 -0
  38. package/lib/commonjs/components/native/RefreshControl.js +10 -0
  39. package/lib/commonjs/components/native/RefreshControl.js.map +1 -0
  40. package/lib/commonjs/components/native/ScrollView.js +10 -0
  41. package/lib/commonjs/components/native/ScrollView.js.map +1 -0
  42. package/lib/commonjs/components/native/SectionList.js +10 -0
  43. package/lib/commonjs/components/native/SectionList.js.map +1 -0
  44. package/lib/commonjs/components/native/Switch.js +10 -0
  45. package/lib/commonjs/components/native/Switch.js.map +1 -0
  46. package/lib/commonjs/components/native/Text.js +10 -0
  47. package/lib/commonjs/components/native/Text.js.map +1 -0
  48. package/lib/commonjs/components/native/TextInput.js +10 -0
  49. package/lib/commonjs/components/native/TextInput.js.map +1 -0
  50. package/lib/commonjs/components/native/TouchableHighlight.js +10 -0
  51. package/lib/commonjs/components/native/TouchableHighlight.js.map +1 -0
  52. package/lib/commonjs/components/native/TouchableOpacity.js +10 -0
  53. package/lib/commonjs/components/native/TouchableOpacity.js.map +1 -0
  54. package/lib/commonjs/components/native/View.js +10 -0
  55. package/lib/commonjs/components/native/View.js.map +1 -0
  56. package/lib/commonjs/components/native/VirtualizedList.js +10 -0
  57. package/lib/commonjs/components/native/VirtualizedList.js.map +1 -0
  58. package/lib/commonjs/core/createUnistylesComponent.js +5 -68
  59. package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
  60. package/lib/commonjs/core/createUnistylesElement.js +16 -0
  61. package/lib/commonjs/core/createUnistylesElement.js.map +1 -0
  62. package/lib/commonjs/core/createUnistylesImageBackground.js +27 -0
  63. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -0
  64. package/lib/commonjs/core/index.js +20 -6
  65. package/lib/commonjs/core/index.js.map +1 -1
  66. package/lib/commonjs/core/passForwardRef.js +27 -0
  67. package/lib/commonjs/core/passForwardRef.js.map +1 -0
  68. package/lib/commonjs/core/withUnistyles/index.js +13 -0
  69. package/lib/commonjs/core/withUnistyles/index.js.map +1 -0
  70. package/lib/commonjs/core/withUnistyles/types.js +8 -0
  71. package/lib/commonjs/core/withUnistyles/types.js.map +1 -0
  72. package/lib/commonjs/core/withUnistyles/useDependencies.js +81 -0
  73. package/lib/commonjs/core/withUnistyles/useDependencies.js.map +1 -0
  74. package/lib/commonjs/core/withUnistyles/withUnistyles.js +88 -0
  75. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -0
  76. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +96 -0
  77. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -0
  78. package/lib/commonjs/hooks/useMedia.js +17 -33
  79. package/lib/commonjs/hooks/useMedia.js.map +1 -1
  80. package/lib/commonjs/hooks/useMedia.native.js +60 -0
  81. package/lib/commonjs/hooks/useMedia.native.js.map +1 -0
  82. package/lib/commonjs/index.js +33 -16
  83. package/lib/commonjs/index.js.map +1 -1
  84. package/lib/commonjs/specs/ShadowRegistry/index.js +3 -3
  85. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  86. package/lib/commonjs/specs/index.js +14 -40
  87. package/lib/commonjs/specs/index.js.map +1 -1
  88. package/lib/commonjs/specs/index.native.js +54 -0
  89. package/lib/commonjs/specs/index.native.js.map +1 -0
  90. package/lib/commonjs/web/create.js +12 -33
  91. package/lib/commonjs/web/create.js.map +1 -1
  92. package/lib/commonjs/web/index.js.map +1 -1
  93. package/lib/commonjs/web/registry.js +10 -3
  94. package/lib/commonjs/web/registry.js.map +1 -1
  95. package/lib/commonjs/web/runtime.js +3 -1
  96. package/lib/commonjs/web/runtime.js.map +1 -1
  97. package/lib/commonjs/web/shadowRegistry.js +71 -64
  98. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  99. package/lib/commonjs/web/utils/unistyle.js +3 -3
  100. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  101. package/lib/module/components/ScopedTheme.js +29 -0
  102. package/lib/module/components/ScopedTheme.js.map +1 -0
  103. package/lib/module/components/Variants.js +26 -0
  104. package/lib/module/components/Variants.js.map +1 -0
  105. package/lib/module/components/index.js +2 -1
  106. package/lib/module/components/index.js.map +1 -1
  107. package/lib/module/components/native/ActivityIndicator.js +6 -0
  108. package/lib/module/components/native/ActivityIndicator.js.map +1 -0
  109. package/lib/module/components/native/FlatList.js +6 -0
  110. package/lib/module/components/native/FlatList.js.map +1 -0
  111. package/lib/module/components/native/Image.js +6 -0
  112. package/lib/module/components/native/Image.js.map +1 -0
  113. package/lib/module/components/native/ImageBackground.js +6 -0
  114. package/lib/module/components/native/ImageBackground.js.map +1 -0
  115. package/lib/module/components/native/KeyboardAvoidingView.js +6 -0
  116. package/lib/module/components/native/KeyboardAvoidingView.js.map +1 -0
  117. package/lib/module/components/native/Pressable.js +69 -0
  118. package/lib/module/components/native/Pressable.js.map +1 -0
  119. package/lib/module/components/native/Pressable.native.js +42 -0
  120. package/lib/module/components/native/Pressable.native.js.map +1 -0
  121. package/lib/module/components/native/RefreshControl.js +6 -0
  122. package/lib/module/components/native/RefreshControl.js.map +1 -0
  123. package/lib/module/components/native/ScrollView.js +6 -0
  124. package/lib/module/components/native/ScrollView.js.map +1 -0
  125. package/lib/module/components/native/SectionList.js +6 -0
  126. package/lib/module/components/native/SectionList.js.map +1 -0
  127. package/lib/module/components/native/Switch.js +6 -0
  128. package/lib/module/components/native/Switch.js.map +1 -0
  129. package/lib/module/components/native/Text.js +6 -0
  130. package/lib/module/components/native/Text.js.map +1 -0
  131. package/lib/module/components/native/TextInput.js +6 -0
  132. package/lib/module/components/native/TextInput.js.map +1 -0
  133. package/lib/module/components/native/TouchableHighlight.js +6 -0
  134. package/lib/module/components/native/TouchableHighlight.js.map +1 -0
  135. package/lib/module/components/native/TouchableOpacity.js +6 -0
  136. package/lib/module/components/native/TouchableOpacity.js.map +1 -0
  137. package/lib/module/components/native/View.js +6 -0
  138. package/lib/module/components/native/View.js.map +1 -0
  139. package/lib/module/components/native/VirtualizedList.js +6 -0
  140. package/lib/module/components/native/VirtualizedList.js.map +1 -0
  141. package/lib/module/core/createUnistylesComponent.js +5 -66
  142. package/lib/module/core/createUnistylesComponent.js.map +1 -1
  143. package/lib/module/core/createUnistylesElement.js +10 -0
  144. package/lib/module/core/createUnistylesElement.js.map +1 -0
  145. package/lib/module/core/createUnistylesImageBackground.js +21 -0
  146. package/lib/module/core/createUnistylesImageBackground.js.map +1 -0
  147. package/lib/module/core/index.js +4 -2
  148. package/lib/module/core/index.js.map +1 -1
  149. package/lib/module/core/passForwardRef.js +22 -0
  150. package/lib/module/core/passForwardRef.js.map +1 -0
  151. package/lib/module/core/withUnistyles/index.js +4 -0
  152. package/lib/module/core/withUnistyles/index.js.map +1 -0
  153. package/lib/module/core/withUnistyles/types.js +4 -0
  154. package/lib/module/core/withUnistyles/types.js.map +1 -0
  155. package/lib/module/core/withUnistyles/useDependencies.js +75 -0
  156. package/lib/module/core/withUnistyles/useDependencies.js.map +1 -0
  157. package/lib/module/core/withUnistyles/withUnistyles.js +81 -0
  158. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -0
  159. package/lib/module/core/withUnistyles/withUnistyles.native.js +89 -0
  160. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -0
  161. package/lib/module/hooks/useMedia.js +19 -35
  162. package/lib/module/hooks/useMedia.js.map +1 -1
  163. package/lib/module/hooks/useMedia.native.js +55 -0
  164. package/lib/module/hooks/useMedia.native.js.map +1 -0
  165. package/lib/module/index.js +2 -2
  166. package/lib/module/index.js.map +1 -1
  167. package/lib/module/specs/ShadowRegistry/index.js +3 -3
  168. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  169. package/lib/module/specs/index.js +2 -8
  170. package/lib/module/specs/index.js.map +1 -1
  171. package/lib/module/specs/index.native.js +11 -0
  172. package/lib/module/specs/index.native.js.map +1 -0
  173. package/lib/module/web/create.js +13 -34
  174. package/lib/module/web/create.js.map +1 -1
  175. package/lib/module/web/index.js +1 -1
  176. package/lib/module/web/index.js.map +1 -1
  177. package/lib/module/web/registry.js +11 -4
  178. package/lib/module/web/registry.js.map +1 -1
  179. package/lib/module/web/runtime.js +3 -1
  180. package/lib/module/web/runtime.js.map +1 -1
  181. package/lib/module/web/shadowRegistry.js +70 -63
  182. package/lib/module/web/shadowRegistry.js.map +1 -1
  183. package/lib/module/web/utils/unistyle.js +1 -1
  184. package/lib/module/web/utils/unistyle.js.map +1 -1
  185. package/lib/typescript/src/components/ScopedTheme.d.ts +8 -0
  186. package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -0
  187. package/lib/typescript/src/components/Variants.d.ts +7 -0
  188. package/lib/typescript/src/components/Variants.d.ts.map +1 -0
  189. package/lib/typescript/src/components/index.d.ts +2 -1
  190. package/lib/typescript/src/components/index.d.ts.map +1 -1
  191. package/lib/typescript/src/components/native/ActivityIndicator.d.ts +2 -0
  192. package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -0
  193. package/lib/typescript/src/components/native/FlatList.d.ts +2 -0
  194. package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -0
  195. package/lib/typescript/src/components/native/Image.d.ts +2 -0
  196. package/lib/typescript/src/components/native/Image.d.ts.map +1 -0
  197. package/lib/typescript/src/components/native/ImageBackground.d.ts +3 -0
  198. package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -0
  199. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +2 -0
  200. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -0
  201. package/lib/typescript/src/components/{Pressable.web.d.ts → native/Pressable.d.ts} +3 -2
  202. package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -0
  203. package/lib/typescript/src/components/{Pressable.d.ts → native/Pressable.native.d.ts} +1 -3
  204. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -0
  205. package/lib/typescript/src/components/native/RefreshControl.d.ts +2 -0
  206. package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -0
  207. package/lib/typescript/src/components/native/ScrollView.d.ts +2 -0
  208. package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -0
  209. package/lib/typescript/src/components/native/SectionList.d.ts +2 -0
  210. package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -0
  211. package/lib/typescript/src/components/native/Switch.d.ts +2 -0
  212. package/lib/typescript/src/components/native/Switch.d.ts.map +1 -0
  213. package/lib/typescript/src/components/native/Text.d.ts +2 -0
  214. package/lib/typescript/src/components/native/Text.d.ts.map +1 -0
  215. package/lib/typescript/src/components/native/TextInput.d.ts +2 -0
  216. package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -0
  217. package/lib/typescript/src/components/native/TouchableHighlight.d.ts +2 -0
  218. package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -0
  219. package/lib/typescript/src/components/native/TouchableOpacity.d.ts +2 -0
  220. package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -0
  221. package/lib/typescript/src/components/native/View.d.ts +2 -0
  222. package/lib/typescript/src/components/native/View.d.ts.map +1 -0
  223. package/lib/typescript/src/components/native/VirtualizedList.d.ts +2 -0
  224. package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -0
  225. package/lib/typescript/src/core/createUnistylesComponent.d.ts +9 -3
  226. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
  227. package/lib/typescript/src/core/createUnistylesElement.d.ts +3 -0
  228. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -0
  229. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +4 -0
  230. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -0
  231. package/lib/typescript/src/core/index.d.ts +4 -2
  232. package/lib/typescript/src/core/index.d.ts.map +1 -1
  233. package/lib/typescript/src/core/passForwardRef.d.ts +3 -0
  234. package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -0
  235. package/lib/typescript/src/core/withUnistyles/index.d.ts +2 -0
  236. package/lib/typescript/src/core/withUnistyles/index.d.ts.map +1 -0
  237. package/lib/typescript/src/core/withUnistyles/types.d.ts +6 -0
  238. package/lib/typescript/src/core/withUnistyles/types.d.ts.map +1 -0
  239. package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts +13 -0
  240. package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts.map +1 -0
  241. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +11 -0
  242. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -0
  243. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +8 -0
  244. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -0
  245. package/lib/typescript/src/hooks/useMedia.d.ts +1 -1
  246. package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
  247. package/lib/typescript/src/hooks/useMedia.native.d.ts +6 -0
  248. package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -0
  249. package/lib/typescript/src/index.d.ts +2 -2
  250. package/lib/typescript/src/index.d.ts.map +1 -1
  251. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +7 -2
  252. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  253. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +17 -0
  254. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  255. package/lib/typescript/src/specs/index.d.ts +3 -11
  256. package/lib/typescript/src/specs/index.d.ts.map +1 -1
  257. package/lib/typescript/src/specs/index.native.d.ts +12 -0
  258. package/lib/typescript/src/specs/index.native.d.ts.map +1 -0
  259. package/lib/typescript/src/web/create.d.ts +1 -1441
  260. package/lib/typescript/src/web/create.d.ts.map +1 -1
  261. package/lib/typescript/src/web/index.d.ts +2 -1441
  262. package/lib/typescript/src/web/index.d.ts.map +1 -1
  263. package/lib/typescript/src/web/registry.d.ts +2 -3
  264. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  265. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  266. package/lib/typescript/src/web/shadowRegistry.d.ts +11 -3
  267. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  268. package/lib/typescript/src/web/utils/unistyle.d.ts +1 -2
  269. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  270. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +3 -0
  271. package/package.json +4 -4
  272. package/plugin/common.js +4 -6
  273. package/plugin/import.js +63 -26
  274. package/plugin/index.js +48 -28
  275. package/plugin/ref.js +0 -234
  276. package/plugin/style.js +4 -317
  277. package/plugin/stylesheet.js +25 -10
  278. package/plugin/variants.js +54 -1
  279. package/src/components/ScopedTheme.tsx +32 -0
  280. package/src/components/Variants.tsx +29 -0
  281. package/src/components/index.ts +2 -1
  282. package/src/components/native/ActivityIndicator.tsx +4 -0
  283. package/src/components/native/FlatList.tsx +4 -0
  284. package/src/components/native/Image.tsx +4 -0
  285. package/src/components/native/ImageBackground.tsx +4 -0
  286. package/src/components/native/KeyboardAvoidingView.tsx +4 -0
  287. package/src/components/native/Pressable.native.tsx +55 -0
  288. package/src/components/native/Pressable.tsx +98 -0
  289. package/src/components/native/RefreshControl.tsx +4 -0
  290. package/src/components/native/ScrollView.tsx +4 -0
  291. package/src/components/native/SectionList.tsx +4 -0
  292. package/src/components/native/Switch.tsx +4 -0
  293. package/src/components/native/Text.tsx +4 -0
  294. package/src/components/native/TextInput.tsx +4 -0
  295. package/src/components/native/TouchableHighlight.tsx +4 -0
  296. package/src/components/native/TouchableOpacity.tsx +4 -0
  297. package/src/components/native/View.tsx +4 -0
  298. package/src/components/native/VirtualizedList.tsx +4 -0
  299. package/src/core/createUnistylesComponent.tsx +6 -76
  300. package/src/core/createUnistylesElement.tsx +9 -0
  301. package/src/core/createUnistylesImageBackground.tsx +24 -0
  302. package/src/core/index.ts +4 -2
  303. package/src/core/passForwardRef.ts +29 -0
  304. package/src/core/withUnistyles/index.ts +1 -0
  305. package/src/core/withUnistyles/types.ts +7 -0
  306. package/src/core/withUnistyles/useDependencies.ts +93 -0
  307. package/src/core/withUnistyles/withUnistyles.native.tsx +96 -0
  308. package/src/core/withUnistyles/withUnistyles.tsx +90 -0
  309. package/src/hooks/useMedia.native.ts +65 -0
  310. package/src/hooks/useMedia.ts +19 -36
  311. package/src/index.ts +2 -2
  312. package/src/specs/ShadowRegistry/index.ts +14 -5
  313. package/src/specs/ShadowRegistry/types.ts +18 -1
  314. package/src/specs/index.native.ts +27 -0
  315. package/src/specs/index.ts +3 -27
  316. package/src/web/create.ts +14 -32
  317. package/src/web/index.ts +3 -2
  318. package/src/web/registry.ts +15 -6
  319. package/src/web/runtime.ts +3 -1
  320. package/src/web/shadowRegistry.ts +66 -52
  321. package/src/web/utils/unistyle.ts +1 -2
  322. package/lib/commonjs/components/Pressable.js +0 -74
  323. package/lib/commonjs/components/Pressable.js.map +0 -1
  324. package/lib/commonjs/components/Pressable.web.js.map +0 -1
  325. package/lib/commonjs/core/createUnistylesComponent.native.js +0 -82
  326. package/lib/commonjs/core/createUnistylesComponent.native.js.map +0 -1
  327. package/lib/commonjs/core/getBoundArgs.js +0 -18
  328. package/lib/commonjs/core/getBoundArgs.js.map +0 -1
  329. package/lib/commonjs/core/getId.js +0 -9
  330. package/lib/commonjs/core/getId.js.map +0 -1
  331. package/lib/commonjs/hooks/useMedia.web.js +0 -43
  332. package/lib/commonjs/hooks/useMedia.web.js.map +0 -1
  333. package/lib/commonjs/specs/index.web.js +0 -17
  334. package/lib/commonjs/specs/index.web.js.map +0 -1
  335. package/lib/module/components/Pressable.js +0 -68
  336. package/lib/module/components/Pressable.js.map +0 -1
  337. package/lib/module/components/Pressable.web.js +0 -109
  338. package/lib/module/components/Pressable.web.js.map +0 -1
  339. package/lib/module/core/createUnistylesComponent.native.js +0 -75
  340. package/lib/module/core/createUnistylesComponent.native.js.map +0 -1
  341. package/lib/module/core/getBoundArgs.js +0 -13
  342. package/lib/module/core/getBoundArgs.js.map +0 -1
  343. package/lib/module/core/getId.js +0 -4
  344. package/lib/module/core/getId.js.map +0 -1
  345. package/lib/module/hooks/useMedia.web.js +0 -38
  346. package/lib/module/hooks/useMedia.web.js.map +0 -1
  347. package/lib/module/specs/index.web.js +0 -4
  348. package/lib/module/specs/index.web.js.map +0 -1
  349. package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
  350. package/lib/typescript/src/components/Pressable.web.d.ts.map +0 -1
  351. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +0 -8
  352. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +0 -1
  353. package/lib/typescript/src/core/getBoundArgs.d.ts +0 -2
  354. package/lib/typescript/src/core/getBoundArgs.d.ts.map +0 -1
  355. package/lib/typescript/src/core/getId.d.ts +0 -2
  356. package/lib/typescript/src/core/getId.d.ts.map +0 -1
  357. package/lib/typescript/src/hooks/useMedia.web.d.ts +0 -6
  358. package/lib/typescript/src/hooks/useMedia.web.d.ts.map +0 -1
  359. package/lib/typescript/src/specs/index.web.d.ts +0 -2
  360. package/lib/typescript/src/specs/index.web.d.ts.map +0 -1
  361. package/src/components/Pressable.tsx +0 -89
  362. package/src/components/Pressable.web.tsx +0 -129
  363. package/src/core/createUnistylesComponent.native.tsx +0 -83
  364. package/src/core/getBoundArgs.ts +0 -15
  365. package/src/core/getId.ts +0 -1
  366. package/src/hooks/useMedia.web.ts +0 -47
  367. package/src/specs/index.web.ts +0 -1
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [<img alt="react-native-unistyles" src="assets/banner.png">](https://unistyl.es/)
1
+ [<img alt="react-native-unistyles" src="assets/banner3.png">](https://unistyl.es/)
2
2
 
3
3
  ![GitHub package.json version](https://img.shields.io/github/package-json/v/jpudysz/react-native-unistyles?style=for-the-badge)
4
4
  [![npm downloads](https://img.shields.io/npm/dm/react-native-unistyles?style=for-the-badge)](https://www.npmjs.com/package/react-native-unistyles)
@@ -59,12 +59,12 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
59
59
  <a href="https://github.com/happyfloat">
60
60
  <img src="https://avatars.githubusercontent.com/u/186333704?s=200&v=4" height="70px" width="70px" alt="happyfloat" />
61
61
  </a>
62
- <a href="https://github.com">
63
- <img src="https://avatars.githubusercontent.com/u/138339?v=4" height="70px" width="70px" alt="anonymous" />
64
- </a>
65
62
  <a href="https://github.com/hyoban">
66
63
  <img src="https://avatars.githubusercontent.com/u/38493346?v=4" height="70px" width="70px" alt="hyoban" />
67
64
  </a>
65
+ <a href="https://github.com/oscklm">
66
+ <img src="https://avatars.githubusercontent.com/u/22825865?v=4" height="70px" width="70px" alt="oscklm" />
67
+ </a>
68
68
 
69
69
  ## Past sponsors
70
70
 
package/Unistyles.podspec CHANGED
@@ -26,7 +26,13 @@ Pod::Spec.new do |s|
26
26
  "ios/Unistyles.h"
27
27
  ]
28
28
 
29
- load 'nitrogen/generated/ios/Unistyles+autolinking.rb'
29
+ if ENV["USE_FRAMEWORKS"]
30
+ s.dependency "React-Core"
31
+ add_dependency(s, "React-jsinspector", :framework_name => "jsinspector_modern")
32
+ add_dependency(s, "React-rendererconsistency", :framework_name => "React_rendererconsistency")
33
+ end
34
+
35
+ load "nitrogen/generated/ios/Unistyles+autolinking.rb"
30
36
  add_nitrogen_files(s)
31
37
 
32
38
  install_modules_dependencies(s)
@@ -12,6 +12,11 @@ buildscript {
12
12
  }
13
13
  }
14
14
 
15
+ def reactNativeArchitectures() {
16
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
17
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
18
+ }
19
+
15
20
  apply plugin: 'com.android.library'
16
21
  apply plugin: 'org.jetbrains.kotlin.android'
17
22
  apply from: '../nitrogen/generated/android/unistyles+autolinking.gradle'
@@ -41,6 +46,7 @@ android {
41
46
  externalNativeBuild {
42
47
  cmake {
43
48
  arguments "-DANDROID_STL=c++_shared"
49
+ abiFilters (*reactNativeArchitectures())
44
50
  }
45
51
  }
46
52
  }
@@ -64,8 +64,8 @@ jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindings
64
64
  HybridObjectRegistry::registerHybridObjectConstructor("UnistylesStyleSheet", [styleSheet]() -> std::shared_ptr<HybridObject>{
65
65
  return styleSheet;
66
66
  });
67
- HybridObjectRegistry::registerHybridObjectConstructor("UnistylesShadowRegistry", []() -> std::shared_ptr<HybridObject>{
68
- return std::make_shared<HybridShadowRegistry>();
67
+ HybridObjectRegistry::registerHybridObjectConstructor("UnistylesShadowRegistry", [unistylesRuntime]() -> std::shared_ptr<HybridObject>{
68
+ return std::make_shared<HybridShadowRegistry>(unistylesRuntime);
69
69
  });
70
70
  });
71
71
  }
@@ -9,5 +9,7 @@ static const std::string STYLE_VARIANTS = "uni__variants";
9
9
  static const std::string WEB_STYLE_KEY = "_web";
10
10
  static const std::string EXOTIC_STYLE_KEY = "_exotic";
11
11
  static const std::string NAME_STYLE_KEY = "__unistyles_name";
12
+ static const std::string SECRETS = "__uni__secrets";
13
+ static const std::string ARGUMENTS = "__uni__args";
12
14
 
13
15
  }
@@ -22,15 +22,21 @@ jsi::Value HostStyle::get(jsi::Runtime& rt, const jsi::PropNameID& propNameId) {
22
22
  if (propertyName == helpers::UNISTYLES_ID) {
23
23
  return jsi::Value(this->_styleSheet->tag);
24
24
  }
25
-
25
+
26
26
  if (propertyName == helpers::ADD_VARIANTS_FN) {
27
27
  return this->createAddVariantsProxyFunction(rt);
28
28
  }
29
29
 
30
30
  if (this->_styleSheet->unistyles.contains(propertyName)) {
31
- return valueFromUnistyle(rt, this->_unistylesRuntime, this->_styleSheet->unistyles[propertyName], this->_styleSheet->tag);
31
+ if (this->_styleCache.contains(propertyName)) {
32
+ return jsi::Value(rt, this->_styleCache[propertyName]);
33
+ }
34
+
35
+ this->_styleCache[propertyName] = valueFromUnistyle(rt, this->_unistylesRuntime, this->_styleSheet->unistyles[propertyName]);
36
+
37
+ return jsi::Value(rt, this->_styleCache[propertyName]);
32
38
  }
33
-
39
+
34
40
  if (propertyName == helpers::STYLE_VARIANTS) {
35
41
  return helpers::variantsToValue(rt, this->_variants);
36
42
  }
@@ -45,17 +51,16 @@ jsi::Function HostStyle::createAddVariantsProxyFunction(jsi::Runtime& rt) {
45
51
  helpers::assertThat(rt, count == 1, "Unistyles: useVariants expected to be called with one argument.");
46
52
  helpers::assertThat(rt, arguments[0].isObject(), "Unistyles: useVariants expected to be called with object.");
47
53
 
48
- auto parser = parser::Parser(this->_unistylesRuntime);
49
54
  auto pairs = helpers::variantsToPairs(rt, arguments[0].asObject(rt));
50
55
 
51
- if (pairs == this->_variants) {
56
+ if (this->hasVariantsSet && pairs == this->_variants) {
52
57
  return jsi::Value::undefined();
53
58
  }
54
59
 
60
+ // new variants or empty variants
61
+ this->hasVariantsSet = true;
55
62
  this->_variants = pairs;
56
63
 
57
- parser.rebuildUnistylesWithVariants(rt, this->_styleSheet, this->_variants);
58
-
59
64
  return jsi::Value::undefined();
60
65
  });
61
66
  }
@@ -21,9 +21,14 @@ struct JSI_EXPORT HostStyle : public jsi::HostObject {
21
21
  jsi::Function createAddVariantsProxyFunction(jsi::Runtime& rt);
22
22
 
23
23
  private:
24
+ // to additionally distinguish between empty variants
25
+ // that are set at the beginning
26
+ bool hasVariantsSet = false;
27
+
24
28
  std::shared_ptr<StyleSheet> _styleSheet;
25
29
  std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
26
30
  std::vector<std::pair<std::string, std::string>> _variants{};
31
+ std::unordered_map<std::string, jsi::Value> _styleCache{};
27
32
  };
28
33
 
29
34
  }
@@ -8,8 +8,8 @@ namespace margelo::nitro::unistyles::core {
8
8
  using Variants = std::vector<std::pair<std::string, std::string>>;
9
9
 
10
10
  struct UnistyleData {
11
- UnistyleData(Unistyle::Shared unistyle, const Variants& variants, std::vector<folly::dynamic>& arguments, std::optional<std::string> uniquePressableId)
12
- : unistyle{unistyle}, variants(std::move(variants)), dynamicFunctionMetadata{std::move(arguments)}, pressableId{std::move(uniquePressableId)} {}
11
+ UnistyleData(Unistyle::Shared unistyle, const Variants& variants, std::vector<folly::dynamic>& arguments, std::optional<std::string> scopedTheme)
12
+ : unistyle{unistyle}, variants(std::move(variants)), dynamicFunctionMetadata{std::move(arguments)}, scopedTheme{scopedTheme} {}
13
13
 
14
14
  UnistyleData(const UnistyleData&) = delete;
15
15
  UnistyleData(UnistyleData&& other) = delete;
@@ -18,7 +18,7 @@ struct UnistyleData {
18
18
  core::Variants variants;
19
19
  std::optional<jsi::Object> parsedStyle = std::nullopt;
20
20
  std::optional<std::vector<folly::dynamic>> dynamicFunctionMetadata = std::nullopt;
21
- std::optional<std::string> pressableId = std::nullopt;
21
+ std::optional<std::string> scopedTheme = std::nullopt;
22
22
  };
23
23
 
24
24
  }
@@ -88,35 +88,35 @@ inline static std::vector<Unistyle::Shared> unistyleFromValue(jsi::Runtime& rt,
88
88
  if (value.isNull() || !value.isObject()) {
89
89
  return {};
90
90
  }
91
-
91
+
92
92
  auto maybeArray = value.asObject(rt);
93
-
93
+
94
94
  helpers::assertThat(rt, maybeArray.isArray(rt), "Unistyles: can't retrieve Unistyle state from node as it's not an array.");
95
-
95
+
96
96
  std::vector<Unistyle::Shared> unistyles;
97
97
  jsi::Array unistylesArray = maybeArray.asArray(rt);
98
-
98
+
99
99
  helpers::iterateJSIArray(rt, unistylesArray, [&rt, &unistyles](size_t index, jsi::Value& value){
100
100
  auto obj = value.getObject(rt);
101
101
 
102
102
  // possible if user used React Native styles or inline styles or did spread styles
103
103
  if (!obj.hasNativeState(rt)) {
104
104
  auto exoticUnistyles = unistylesFromNonExistentNativeState(rt, obj);
105
-
105
+
106
106
  for (auto& exoticUnistyle: exoticUnistyles) {
107
107
  unistyles.emplace_back(exoticUnistyle);
108
108
  }
109
-
109
+
110
110
  return;
111
111
  }
112
112
 
113
113
  unistyles.emplace_back(value.getObject(rt).getNativeState<UnistyleWrapper>(rt)->unistyle);
114
114
  });
115
-
115
+
116
116
  return unistyles;
117
117
  }
118
118
 
119
- inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, Unistyle::Shared unistyle, int tag) {
119
+ inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime, Unistyle::Shared unistyle) {
120
120
  auto wrappedUnistyle = std::make_shared<UnistyleWrapper>(unistyle);
121
121
 
122
122
  if (unistyle->type == UnistyleType::Object) {
@@ -71,32 +71,16 @@ void core::UnistylesRegistry::updateTheme(jsi::Runtime& rt, std::string& themeNa
71
71
  void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
72
72
  jsi::Runtime& rt,
73
73
  const ShadowNodeFamily* shadowNodeFamily,
74
- std::vector<core::Unistyle::Shared>& unistyles,
75
- Variants& variants,
76
- std::vector<std::vector<folly::dynamic>>& arguments,
77
- std::optional<std::string> uniquePressableId
74
+ std::vector<std::shared_ptr<UnistyleData>>& unistylesData
78
75
  ) {
79
- auto parser = parser::Parser(nullptr);
80
76
  shadow::ShadowLeafUpdates updates;
77
+ auto parser = parser::Parser(nullptr);
81
78
 
82
- for (size_t index = 0; index < unistyles.size(); index++) {
83
- Unistyle::Shared unistyle = unistyles[index];
84
-
85
- this->_shadowRegistry[&rt][shadowNodeFamily]
86
- .emplace_back(std::make_shared<UnistyleData>(unistyle, variants, arguments[index], uniquePressableId));
87
-
88
- // add or update node for shadow leaf updates
89
- // dynamic functions are parsed later
90
- if (unistyle->type == UnistyleType::Object) {
91
- for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
92
- for (const auto& unistyleData : unistyles) {
93
- if (unistyleData->unistyle == unistyle && family == shadowNodeFamily) {
94
- updates[family] = parser.parseStylesToShadowTreeStyles(rt, {unistyleData});
95
- }
96
- }
97
- }
98
- }
99
- }
79
+ std::for_each(unistylesData.begin(), unistylesData.end(), [this, &rt, shadowNodeFamily](std::shared_ptr<UnistyleData> unistyleData){
80
+ this->_shadowRegistry[&rt][shadowNodeFamily].emplace_back(unistyleData);
81
+ });
82
+
83
+ updates[shadowNodeFamily] = parser.parseStylesToShadowTreeStyles(rt, unistylesData);
100
84
 
101
85
  this->trafficController.setUpdates(updates);
102
86
  this->trafficController.resumeUnistylesTraffic();
@@ -160,13 +144,6 @@ void core::UnistylesRegistry::shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Uni
160
144
  for (const auto& [family, unistyles] : this->_shadowRegistry[&rt]) {
161
145
  for (const auto& unistyleData : unistyles) {
162
146
  if (unistyleData->unistyle == unistyle) {
163
- // special case for pressable
164
- if (pressableId.has_value() && unistyleData->pressableId.has_value()) {
165
- if (pressableId.value() == unistyleData->pressableId.value()) {
166
- unistyleData->parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
167
- }
168
- }
169
-
170
147
  updates[family] = parser.parseStylesToShadowTreeStyles(rt, { unistyleData });
171
148
  }
172
149
  }
@@ -220,3 +197,19 @@ std::vector<std::shared_ptr<core::StyleSheet>> core::UnistylesRegistry::getStyle
220
197
 
221
198
  return stylesheetsToRefresh;
222
199
  }
200
+
201
+ const core::Variants& core::UnistylesRegistry::getScopedVariants() {
202
+ return this->_scopedVariants;
203
+ }
204
+
205
+ const std::optional<std::string> core::UnistylesRegistry::getScopedTheme() {
206
+ return this->_scopedTheme;
207
+ }
208
+
209
+ void core::UnistylesRegistry::setScopedVariants(core::Variants&& variants) {
210
+ this->_scopedVariants = std::move(variants);
211
+ }
212
+
213
+ void core::UnistylesRegistry::setScopedTheme(std::optional<std::string> themeName) {
214
+ this->_scopedTheme = std::move(themeName);
215
+ }
@@ -37,16 +37,22 @@ struct UnistylesRegistry: public StyleSheetRegistry {
37
37
  UnistylesState& getState(jsi::Runtime& rt);
38
38
  void createState(jsi::Runtime& rt);
39
39
  std::vector<std::shared_ptr<core::StyleSheet>> getStyleSheetsToRefresh(jsi::Runtime& rt, std::vector<UnistyleDependency>& unistylesDependencies);
40
- void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, std::vector<core::Unistyle::Shared>& unistyles, Variants& variants, std::vector<std::vector<folly::dynamic>>&, std::optional<std::string> uniquePressableId);
40
+ void linkShadowNodeWithUnistyle(jsi::Runtime& rt, const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>& unistylesData);
41
41
  void unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily*);
42
42
  std::shared_ptr<core::StyleSheet> addStyleSheet(jsi::Runtime& rt, int tag, core::StyleSheetType type, jsi::Object&& rawValue);
43
43
  DependencyMap buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps);
44
44
  void shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Value& maybePressableId);
45
45
  shadow::ShadowTrafficController trafficController{};
46
+ const core::Variants& getScopedVariants();
47
+ const std::optional<std::string> getScopedTheme();
48
+ void setScopedVariants(core::Variants&& variants);
49
+ void setScopedTheme(std::optional<std::string> themeName);
46
50
 
47
51
  private:
48
52
  UnistylesRegistry() = default;
49
-
53
+
54
+ core::Variants _scopedVariants{};
55
+ std::optional<std::string> _scopedTheme{};
50
56
  std::unordered_map<jsi::Runtime*, UnistylesState> _states{};
51
57
  std::unordered_map<jsi::Runtime*, std::unordered_map<int, std::shared_ptr<core::StyleSheet>>> _styleSheetRegistry{};
52
58
  std::unordered_map<jsi::Runtime*, std::unordered_map<const ShadowNodeFamily*, std::vector<const std::shared_ptr<UnistyleData>>>> _shadowRegistry{};
@@ -4,29 +4,83 @@ using namespace margelo::nitro::unistyles;
4
4
  using namespace facebook::react;
5
5
 
6
6
  jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
7
- helpers::assertThat(rt, count == 5, "Unistyles: Invalid babel transform 'ShadowRegistry link' expected 5 arguments.");
7
+ helpers::assertThat(rt, count == 2, "Unistyles: Invalid babel transform 'ShadowRegistry link' expected 2 arguments.");
8
8
 
9
9
  ShadowNode::Shared shadowNodeWrapper = shadowNodeFromValue(rt, args[0]);
10
10
  std::vector<core::Unistyle::Shared> unistyleWrappers = core::unistyleFromValue(rt, args[1]);
11
- core::Variants variants = helpers::variantsToPairs(rt, args[2].asObject(rt));
12
- jsi::Array rawArguments = args[3].asObject(rt).asArray(rt);
13
- std::optional<std::string> uniquePressableId = args[4].isUndefined()
14
- ? std::nullopt
15
- : std::make_optional<std::string>(args[4].asString(rt).utf8(rt));
16
11
  std::vector<std::vector<folly::dynamic>> arguments;
17
12
  auto& registry = core::UnistylesRegistry::get();
13
+
14
+ for (size_t i = 0; i < unistyleWrappers.size(); i++) {
15
+ if (unistyleWrappers[i]->type == core::UnistyleType::DynamicFunction) {
16
+ auto rawStyle = args[1].asObject(rt).asArray(rt).getValueAtIndex(rt, i);
17
+
18
+ helpers::assertThat(rt, rawStyle.isObject(), "Unistyles: Dynamic function is not bound!");
19
+
20
+ auto maybeSecrets = rawStyle.getObject(rt).getProperty(rt, helpers::SECRETS.c_str());
21
+
22
+ helpers::assertThat(rt, maybeSecrets.isObject(), "Unistyles: Dynamic function is not bound!");
23
+
24
+ auto secrets = maybeSecrets.asObject(rt).getProperty(rt, helpers::ARGUMENTS.c_str());
25
+
26
+ arguments.push_back(helpers::parseDynamicFunctionArguments(rt, secrets.asObject(rt).asArray(rt)));
27
+
28
+ continue;
29
+ }
30
+
31
+ arguments.push_back({});
32
+ }
18
33
 
19
- helpers::iterateJSIArray(rt, rawArguments, [&rt, &arguments](size_t index, jsi::Value& value){
20
- arguments.push_back(helpers::parseDynamicFunctionArguments(rt, value.asObject(rt).asArray(rt)));
21
- });
22
-
23
- registry.linkShadowNodeWithUnistyle(rt, &shadowNodeWrapper->getFamily(), unistyleWrappers, variants, arguments, uniquePressableId);
34
+ auto scopedTheme = registry.getScopedTheme();
35
+
36
+ // check if scope theme exists
37
+ if (scopedTheme.has_value()) {
38
+ auto themeName = scopedTheme.value();
39
+
40
+ helpers::assertThat(rt, registry.getState(rt).hasTheme(themeName), "Unistyles: You're trying to use scoped theme '" + themeName + "' but it wasn't registered.");
41
+ }
42
+
43
+ auto parser = parser::Parser(this->_unistylesRuntime);
44
+ auto parsedStyleSheet = jsi::Value::undefined();
45
+ std::vector<std::shared_ptr<core::UnistyleData>> unistylesData{};
46
+
47
+ // create unistyleData based on wrappers
48
+ for (size_t i = 0; i < unistyleWrappers.size(); i++) {
49
+ core::Unistyle::Shared& unistyle = unistyleWrappers[i];
50
+ std::shared_ptr<core::UnistyleData> unistyleData = std::make_shared<core::UnistyleData>(
51
+ unistyle,
52
+ registry.getScopedVariants(),
53
+ arguments[i],
54
+ scopedTheme
55
+ );
56
+
57
+ // before linking we need to check if given unistyle is affected by scoped theme
58
+ if (scopedTheme.has_value()) {
59
+ if (parsedStyleSheet.isUndefined()) {
60
+ parsedStyleSheet = parser.getParsedStyleSheetForScopedTheme(rt, unistyle, scopedTheme.value());
61
+ }
62
+
63
+ // if so we need to force update
64
+ parser.rebuildUnistyleWithScopedTheme(rt, parsedStyleSheet, unistyleData);
65
+ } else {
66
+ // for other styles, not scoped to theme we need to compute variants value
67
+ parser.rebuildUnistyleWithVariants(rt, unistyleData);
68
+ }
69
+
70
+ unistylesData.emplace_back(unistyleData);
71
+ }
72
+
73
+ registry.linkShadowNodeWithUnistyle(
74
+ rt,
75
+ &shadowNodeWrapper->getFamily(),
76
+ unistylesData
77
+ );
24
78
 
25
79
  return jsi::Value::undefined();
26
80
  }
27
81
 
28
82
  jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
29
- helpers::assertThat(rt, count == 1, "Unistyles: Invalid babel transform 'ShadowRegistry unlink' expected 1 arguments.");
83
+ helpers::assertThat(rt, count == 1, "Unistyles: Invalid babel transform 'ShadowRegistry unlink' expected 1 argument.");
30
84
 
31
85
  ShadowNode::Shared shadowNodeWrapper = shadowNodeFromValue(rt, args[0]);
32
86
 
@@ -36,3 +90,45 @@ jsi::Value HybridShadowRegistry::unlink(jsi::Runtime &rt, const jsi::Value &this
36
90
 
37
91
  return jsi::Value::undefined();
38
92
  }
93
+
94
+ jsi::Value HybridShadowRegistry::selectVariants(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
95
+ helpers::assertThat(rt, count == 1, "Unistyles: Invalid babel transform 'ShadowRegistry selectVariants' expected 1 arguments.");
96
+
97
+ auto& registry = core::UnistylesRegistry::get();
98
+
99
+ if (args[0].isUndefined()) {
100
+ registry.setScopedVariants({});
101
+ }
102
+
103
+ if (args[0].isObject()) {
104
+ registry.setScopedVariants(helpers::variantsToPairs(rt, args[0].asObject(rt)));
105
+ }
106
+
107
+ return jsi::Value::undefined();
108
+ }
109
+
110
+ jsi::Value HybridShadowRegistry::setScopedTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
111
+ helpers::assertThat(rt, count == 1, "Unistyles: setScopedTheme expected 1 argument.");
112
+
113
+ auto& registry = core::UnistylesRegistry::get();
114
+
115
+ if (args[0].isUndefined()) {
116
+
117
+ registry.setScopedTheme(std::nullopt);
118
+ }
119
+
120
+ if (args[0].isString()) {
121
+ registry.setScopedTheme(args[0].asString(rt).utf8(rt));
122
+ }
123
+
124
+ return jsi::Value::undefined();
125
+ }
126
+
127
+ jsi::Value HybridShadowRegistry::getScopedTheme(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
128
+ auto& registry = core::UnistylesRegistry::get();
129
+ auto maybeScopedTheme = registry.getScopedTheme();
130
+
131
+ return maybeScopedTheme.has_value()
132
+ ? jsi::String::createFromUtf8(rt, maybeScopedTheme.value())
133
+ : jsi::Value::undefined();
134
+ }
@@ -9,8 +9,9 @@
9
9
  namespace margelo::nitro::unistyles {
10
10
 
11
11
  struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
12
- HybridShadowRegistry(): HybridObject(TAG) {}
13
-
12
+ HybridShadowRegistry(std::shared_ptr<HybridUnistylesRuntime> unistylesRuntime)
13
+ : HybridObject(TAG), _unistylesRuntime{unistylesRuntime} {}
14
+
14
15
  jsi::Value link(jsi::Runtime& rt,
15
16
  const jsi::Value& thisValue,
16
17
  const jsi::Value* args,
@@ -19,6 +20,18 @@ struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
19
20
  const jsi::Value& thisValue,
20
21
  const jsi::Value* args,
21
22
  size_t count);
23
+ jsi::Value selectVariants(jsi::Runtime& rt,
24
+ const jsi::Value& thisValue,
25
+ const jsi::Value* args,
26
+ size_t count);
27
+ jsi::Value setScopedTheme(jsi::Runtime& rt,
28
+ const jsi::Value& thisValue,
29
+ const jsi::Value* args,
30
+ size_t count);
31
+ jsi::Value getScopedTheme(jsi::Runtime& rt,
32
+ const jsi::Value& thisValue,
33
+ const jsi::Value* args,
34
+ size_t count);
22
35
 
23
36
  void loadHybridMethods() override {
24
37
  HybridUnistylesShadowRegistrySpec::loadHybridMethods();
@@ -26,8 +39,14 @@ struct HybridShadowRegistry: public HybridUnistylesShadowRegistrySpec {
26
39
  registerHybrids(this, [](Prototype& prototype) {
27
40
  prototype.registerRawHybridMethod("link", 2, &HybridShadowRegistry::link);
28
41
  prototype.registerRawHybridMethod("unlink", 2, &HybridShadowRegistry::unlink);
42
+ prototype.registerRawHybridMethod("selectVariants", 2, &HybridShadowRegistry::selectVariants);
43
+ prototype.registerRawHybridMethod("setScopedTheme", 2, &HybridShadowRegistry::setScopedTheme);
44
+ prototype.registerRawHybridMethod("getScopedTheme", 2, &HybridShadowRegistry::getScopedTheme);
29
45
  });
30
46
  };
47
+
48
+ private:
49
+ std::shared_ptr<HybridUnistylesRuntime> _unistylesRuntime;
31
50
  };
32
51
 
33
52
  }
@@ -130,6 +130,10 @@ jsi::Value HybridUnistylesRuntime::getTheme(jsi::Runtime &rt, const jsi::Value &
130
130
  auto& state = core::UnistylesRegistry::get().getState(*_rt);
131
131
 
132
132
  if (count == 1) {
133
+ if (args[0].isUndefined()) {
134
+ return state.getCurrentJSTheme();
135
+ }
136
+
133
137
  helpers::assertThat(rt, args[0].isString(), "UnistylesRuntime.getTheme expected to be called with string.");
134
138
 
135
139
  auto themeName = args[0].asString(rt).utf8(rt);