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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/README.md +17 -2
  2. package/android/CMakeLists.txt +1 -1
  3. package/android/src/main/cxx/NativeUnistylesModule.cpp +1 -1
  4. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +5 -2
  5. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +24 -1
  6. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +6 -1
  7. package/android/src/main/java/com/unistyles/UnistylesModule.kt +5 -4
  8. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +6 -6
  9. package/components/native/Animated/package.json +5 -0
  10. package/components/native/NativeText/package.json +5 -0
  11. package/components/native/NativeView/package.json +5 -0
  12. package/cxx/core/HashGenerator.cpp +1 -1
  13. package/cxx/core/HostUnistyle.cpp +28 -4
  14. package/cxx/core/HostUnistyle.h +1 -0
  15. package/cxx/core/Unistyle.h +4 -0
  16. package/cxx/core/UnistyleWrapper.h +6 -6
  17. package/cxx/core/UnistylesRegistry.cpp +24 -3
  18. package/cxx/core/UnistylesRegistry.h +3 -0
  19. package/cxx/hybridObjects/HybridShadowRegistry.cpp +7 -0
  20. package/cxx/hybridObjects/HybridStyleSheet.cpp +27 -2
  21. package/cxx/parser/Parser.cpp +13 -7
  22. package/ios/NativePlatform+ios.swift +16 -4
  23. package/ios/UnistylesModuleOnLoad.h +4 -4
  24. package/ios/UnistylesModuleOnLoad.mm +4 -8
  25. package/lib/commonjs/components/native/Animated.js +23 -0
  26. package/lib/commonjs/components/native/Animated.js.map +1 -0
  27. package/lib/commonjs/components/native/ImageBackground.js +6 -4
  28. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  29. package/lib/commonjs/components/native/NativeText.js +13 -0
  30. package/lib/commonjs/components/native/NativeText.js.map +1 -0
  31. package/lib/commonjs/components/native/NativeText.native.js +18 -0
  32. package/lib/commonjs/components/native/NativeText.native.js.map +1 -0
  33. package/lib/commonjs/components/native/NativeView.js +9 -0
  34. package/lib/commonjs/components/native/NativeView.js.map +1 -0
  35. package/lib/commonjs/components/native/NativeView.native.js +20 -0
  36. package/lib/commonjs/components/native/NativeView.native.js.map +1 -0
  37. package/lib/commonjs/components/native/Pressable.js +1 -1
  38. package/lib/commonjs/components/native/Pressable.js.map +1 -1
  39. package/lib/commonjs/components/native/Pressable.native.js +18 -9
  40. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  41. package/lib/commonjs/core/createUnistylesElement.js +28 -24
  42. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  43. package/lib/commonjs/core/createUnistylesElement.native.js +37 -23
  44. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  45. package/lib/commonjs/core/createUnistylesImageBackground.js +34 -30
  46. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  47. package/lib/commonjs/core/getClassname.js +1 -3
  48. package/lib/commonjs/core/getClassname.js.map +1 -1
  49. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -2
  50. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  51. package/lib/commonjs/core/warn.js +1 -1
  52. package/lib/commonjs/core/withUnistyles/withUnistyles.js +2 -2
  53. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  54. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +5 -3
  55. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  56. package/lib/commonjs/hooks/useMedia.native.js +1 -1
  57. package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
  58. package/lib/commonjs/mq.js.map +1 -1
  59. package/lib/commonjs/server/getServerUnistyles.js +4 -2
  60. package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
  61. package/lib/commonjs/server/hydrateServerUnistyles.js +1 -1
  62. package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
  63. package/lib/commonjs/server/resetServerUnistyles.js +1 -1
  64. package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
  65. package/lib/commonjs/server/useServerUnistyles.js +2 -2
  66. package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
  67. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  68. package/lib/commonjs/specs/StyleSheet/index.js +1 -1
  69. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  70. package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
  71. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  72. package/lib/commonjs/specs/index.native.js +3 -3
  73. package/lib/commonjs/specs/index.native.js.map +1 -1
  74. package/lib/commonjs/utils.js +16 -1
  75. package/lib/commonjs/utils.js.map +1 -1
  76. package/lib/commonjs/web/convert/index.js +4 -4
  77. package/lib/commonjs/web/convert/index.js.map +1 -1
  78. package/lib/commonjs/web/convert/object/boxShadow.js +4 -4
  79. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
  80. package/lib/commonjs/web/convert/object/filter.js +3 -3
  81. package/lib/commonjs/web/convert/object/filter.js.map +1 -1
  82. package/lib/commonjs/web/convert/object/transform.js +1 -1
  83. package/lib/commonjs/web/convert/object/transform.js.map +1 -1
  84. package/lib/commonjs/web/convert/utils.js.map +1 -1
  85. package/lib/commonjs/web/index.js +1 -1
  86. package/lib/commonjs/web/index.js.map +1 -1
  87. package/lib/commonjs/web/registry.js +1 -1
  88. package/lib/commonjs/web/registry.js.map +1 -1
  89. package/lib/commonjs/web/runtime.js.map +1 -1
  90. package/lib/commonjs/web/shadowRegistry.js +1 -1
  91. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  92. package/lib/commonjs/web/state.js +1 -1
  93. package/lib/commonjs/web/state.js.map +1 -1
  94. package/lib/commonjs/web/utils/common.js +1 -1
  95. package/lib/commonjs/web/utils/unistyle.js +10 -6
  96. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  97. package/lib/module/components/native/Animated.js +19 -0
  98. package/lib/module/components/native/Animated.js.map +1 -0
  99. package/lib/module/components/native/ImageBackground.js +5 -3
  100. package/lib/module/components/native/ImageBackground.js.map +1 -1
  101. package/lib/module/components/native/NativeText.js +4 -0
  102. package/lib/module/components/native/NativeText.js.map +1 -0
  103. package/lib/module/components/native/NativeText.native.js +15 -0
  104. package/lib/module/components/native/NativeText.native.js.map +1 -0
  105. package/lib/module/components/native/NativeView.js +5 -0
  106. package/lib/module/components/native/NativeView.js.map +1 -0
  107. package/lib/module/components/native/NativeView.native.js +17 -0
  108. package/lib/module/components/native/NativeView.native.js.map +1 -0
  109. package/lib/module/components/native/Pressable.js +1 -1
  110. package/lib/module/components/native/Pressable.js.map +1 -1
  111. package/lib/module/components/native/Pressable.native.js +19 -10
  112. package/lib/module/components/native/Pressable.native.js.map +1 -1
  113. package/lib/module/core/createUnistylesElement.js +28 -24
  114. package/lib/module/core/createUnistylesElement.js.map +1 -1
  115. package/lib/module/core/createUnistylesElement.native.js +38 -24
  116. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  117. package/lib/module/core/createUnistylesImageBackground.js +35 -31
  118. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  119. package/lib/module/core/getClassname.js +2 -4
  120. package/lib/module/core/getClassname.js.map +1 -1
  121. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -2
  122. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  123. package/lib/module/core/warn.js +1 -1
  124. package/lib/module/core/withUnistyles/withUnistyles.js +2 -2
  125. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  126. package/lib/module/core/withUnistyles/withUnistyles.native.js +6 -4
  127. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  128. package/lib/module/hooks/useMedia.native.js +1 -1
  129. package/lib/module/hooks/useMedia.native.js.map +1 -1
  130. package/lib/module/mq.js.map +1 -1
  131. package/lib/module/server/getServerUnistyles.js +4 -2
  132. package/lib/module/server/getServerUnistyles.js.map +1 -1
  133. package/lib/module/server/hydrateServerUnistyles.js +1 -1
  134. package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
  135. package/lib/module/server/resetServerUnistyles.js +1 -1
  136. package/lib/module/server/resetServerUnistyles.js.map +1 -1
  137. package/lib/module/server/useServerUnistyles.js +2 -2
  138. package/lib/module/server/useServerUnistyles.js.map +1 -1
  139. package/lib/module/specs/StatusBar/index.js.map +1 -1
  140. package/lib/module/specs/StyleSheet/index.js +1 -1
  141. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  142. package/lib/module/specs/UnistylesRuntime/index.js +1 -1
  143. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  144. package/lib/module/specs/index.native.js +4 -4
  145. package/lib/module/specs/index.native.js.map +1 -1
  146. package/lib/module/utils.js +14 -0
  147. package/lib/module/utils.js.map +1 -1
  148. package/lib/module/web/convert/index.js +5 -5
  149. package/lib/module/web/convert/index.js.map +1 -1
  150. package/lib/module/web/convert/object/boxShadow.js +2 -2
  151. package/lib/module/web/convert/object/boxShadow.js.map +1 -1
  152. package/lib/module/web/convert/object/filter.js +3 -3
  153. package/lib/module/web/convert/object/filter.js.map +1 -1
  154. package/lib/module/web/convert/object/transform.js +1 -1
  155. package/lib/module/web/convert/object/transform.js.map +1 -1
  156. package/lib/module/web/convert/utils.js.map +1 -1
  157. package/lib/module/web/index.js +1 -1
  158. package/lib/module/web/index.js.map +1 -1
  159. package/lib/module/web/registry.js +1 -1
  160. package/lib/module/web/registry.js.map +1 -1
  161. package/lib/module/web/runtime.js.map +1 -1
  162. package/lib/module/web/shadowRegistry.js +1 -1
  163. package/lib/module/web/shadowRegistry.js.map +1 -1
  164. package/lib/module/web/state.js +1 -1
  165. package/lib/module/web/state.js.map +1 -1
  166. package/lib/module/web/utils/common.js +1 -1
  167. package/lib/module/web/utils/unistyle.js +10 -6
  168. package/lib/module/web/utils/unistyle.js.map +1 -1
  169. package/lib/typescript/src/components/native/ActivityIndicator.d.ts +1 -3
  170. package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
  171. package/lib/typescript/src/components/native/Animated.d.ts +39 -0
  172. package/lib/typescript/src/components/native/Animated.d.ts.map +1 -0
  173. package/lib/typescript/src/components/native/FlatList.d.ts +1 -3
  174. package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
  175. package/lib/typescript/src/components/native/Image.d.ts +1 -3
  176. package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
  177. package/lib/typescript/src/components/native/ImageBackground.d.ts +1 -8
  178. package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
  179. package/lib/typescript/src/components/native/ImageBackground.native.d.ts +1 -2
  180. package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
  181. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +1 -3
  182. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
  183. package/lib/typescript/src/components/native/NativeText.d.ts +2 -0
  184. package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -0
  185. package/lib/typescript/src/components/native/NativeText.native.d.ts +2 -0
  186. package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -0
  187. package/lib/typescript/src/components/native/NativeView.d.ts +3 -0
  188. package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -0
  189. package/lib/typescript/src/components/native/NativeView.native.d.ts +3 -0
  190. package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -0
  191. package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
  192. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
  193. package/lib/typescript/src/components/native/RefreshControl.d.ts +1 -3
  194. package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
  195. package/lib/typescript/src/components/native/ScrollView.d.ts +1 -3
  196. package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
  197. package/lib/typescript/src/components/native/SectionList.d.ts +1 -3
  198. package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
  199. package/lib/typescript/src/components/native/Switch.d.ts +1 -3
  200. package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
  201. package/lib/typescript/src/components/native/Text.d.ts +1 -3
  202. package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
  203. package/lib/typescript/src/components/native/TextInput.d.ts +1 -3
  204. package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
  205. package/lib/typescript/src/components/native/TouchableHighlight.d.ts +1 -3
  206. package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
  207. package/lib/typescript/src/components/native/TouchableOpacity.d.ts +1 -3
  208. package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
  209. package/lib/typescript/src/components/native/View.d.ts +1 -3
  210. package/lib/typescript/src/components/native/View.d.ts.map +1 -1
  211. package/lib/typescript/src/components/native/VirtualizedList.d.ts +1 -3
  212. package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
  213. package/lib/typescript/src/core/createUnistylesElement.d.ts +1 -7
  214. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  215. package/lib/typescript/src/core/createUnistylesElement.native.d.ts +1 -2
  216. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  217. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +2 -3
  218. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  219. package/lib/typescript/src/core/getClassname.d.ts +2 -2
  220. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  221. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +2 -1
  222. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
  223. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  224. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  225. package/lib/typescript/src/mq.d.ts +1 -1
  226. package/lib/typescript/src/mq.d.ts.map +1 -1
  227. package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
  228. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
  229. package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
  230. package/lib/typescript/src/specs/StatusBar/index.d.ts +1 -1
  231. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  232. package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -1
  233. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  234. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
  235. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  236. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +5 -5
  237. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  238. package/lib/typescript/src/specs/index.native.d.ts +4 -4
  239. package/lib/typescript/src/specs/index.native.d.ts.map +1 -1
  240. package/lib/typescript/src/types/breakpoints.d.ts +2 -2
  241. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  242. package/lib/typescript/src/types/core.d.ts +1 -1
  243. package/lib/typescript/src/types/core.d.ts.map +1 -1
  244. package/lib/typescript/src/types/stylesheet.d.ts +4 -4
  245. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  246. package/lib/typescript/src/utils.d.ts +1 -0
  247. package/lib/typescript/src/utils.d.ts.map +1 -1
  248. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
  249. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
  250. package/lib/typescript/src/web/convert/types.d.ts +1 -1
  251. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  252. package/lib/typescript/src/web/convert/utils.d.ts +2 -2
  253. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  254. package/lib/typescript/src/web/create.d.ts +1 -1
  255. package/lib/typescript/src/web/create.d.ts.map +1 -1
  256. package/lib/typescript/src/web/index.d.ts +1 -1
  257. package/lib/typescript/src/web/index.d.ts.map +1 -1
  258. package/lib/typescript/src/web/registry.d.ts +1 -1
  259. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  260. package/lib/typescript/src/web/runtime.d.ts +1 -1
  261. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  262. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  263. package/lib/typescript/src/web/state.d.ts +1 -1
  264. package/lib/typescript/src/web/state.d.ts.map +1 -1
  265. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  266. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
  267. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +23 -39
  268. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/unistylesOnLoad.kt +35 -0
  269. package/nitrogen/generated/ios/Unistyles+autolinking.rb +2 -0
  270. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +1 -1
  271. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +3 -1
  272. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +2 -3
  273. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +18 -18
  274. package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
  275. package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -1
  276. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
  277. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
  278. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
  279. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
  280. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
  281. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
  282. package/nitrogen/generated/shared/c++/Insets.hpp +1 -1
  283. package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
  284. package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +1 -1
  285. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -1
  286. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -1
  287. package/package.json +16 -12
  288. package/plugin/consts.js +63 -0
  289. package/plugin/exotic.js +54 -0
  290. package/plugin/import.js +1 -1
  291. package/plugin/index.d.ts +84 -36
  292. package/plugin/index.js +48 -65
  293. package/plugin/stylesheet.js +454 -117
  294. package/plugin/variants.js +1 -1
  295. package/src/components/native/Animated.tsx +17 -0
  296. package/src/components/native/ImageBackground.tsx +7 -4
  297. package/src/components/native/NativeText.native.tsx +12 -0
  298. package/src/components/native/NativeText.tsx +1 -0
  299. package/src/components/native/NativeView.native.tsx +13 -0
  300. package/src/components/native/NativeView.tsx +3 -0
  301. package/src/components/native/Pressable.native.tsx +26 -13
  302. package/src/components/native/Pressable.tsx +1 -1
  303. package/src/core/createUnistylesElement.native.tsx +42 -27
  304. package/src/core/createUnistylesElement.tsx +36 -31
  305. package/src/core/createUnistylesImageBackground.tsx +39 -34
  306. package/src/core/getClassname.ts +5 -4
  307. package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +3 -3
  308. package/src/core/warn.ts +1 -1
  309. package/src/core/withUnistyles/withUnistyles.native.tsx +8 -6
  310. package/src/core/withUnistyles/withUnistyles.tsx +4 -4
  311. package/src/hooks/useMedia.native.ts +1 -1
  312. package/src/mq.ts +1 -1
  313. package/src/server/getServerUnistyles.tsx +3 -2
  314. package/src/server/hydrateServerUnistyles.ts +1 -1
  315. package/src/server/resetServerUnistyles.ts +1 -1
  316. package/src/server/useServerUnistyles.tsx +2 -2
  317. package/src/specs/StatusBar/index.ts +1 -1
  318. package/src/specs/StyleSheet/index.ts +5 -4
  319. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
  320. package/src/specs/UnistylesRuntime/index.ts +5 -5
  321. package/src/specs/index.native.ts +4 -4
  322. package/src/types/breakpoints.ts +2 -2
  323. package/src/types/core.ts +1 -1
  324. package/src/types/stylesheet.ts +4 -4
  325. package/src/utils.ts +17 -0
  326. package/src/web/convert/index.ts +5 -5
  327. package/src/web/convert/object/boxShadow.ts +2 -2
  328. package/src/web/convert/object/filter.ts +3 -3
  329. package/src/web/convert/object/transform.ts +2 -2
  330. package/src/web/convert/types.ts +1 -1
  331. package/src/web/convert/utils.ts +2 -2
  332. package/src/web/create.ts +1 -1
  333. package/src/web/index.ts +3 -3
  334. package/src/web/registry.ts +2 -2
  335. package/src/web/runtime.ts +2 -2
  336. package/src/web/shadowRegistry.ts +2 -2
  337. package/src/web/state.ts +4 -4
  338. package/src/web/utils/common.ts +1 -1
  339. package/src/web/utils/unistyle.ts +13 -7
  340. package/plugin/common.js +0 -142
@@ -1,5 +1,3 @@
1
- const { getIdentifierNameFromExpression, getSecondPropertyName } = require('./common')
2
-
3
1
  const UnistyleDependency = {
4
2
  Theme: 0,
5
3
  ThemeName: 1,
@@ -19,7 +17,7 @@ const UnistyleDependency = {
19
17
  }
20
18
 
21
19
  function stringToUniqueId(str) {
22
- let hash = 0;
20
+ let hash = 0
23
21
 
24
22
  for (let i = 0; i < str.length; i++) {
25
23
  hash = (hash << 5) - hash + str.charCodeAt(i)
@@ -43,7 +41,7 @@ function isUnistylesStyleSheet(t, path, state) {
43
41
  }
44
42
 
45
43
  function isKindOfStyleSheet(t, path, state) {
46
- if (!state.file.forceProcessing) {
44
+ if (!state.file.forceProcessing && !state.file.hasUnistylesImport) {
47
45
  return false
48
46
  }
49
47
 
@@ -63,166 +61,505 @@ function addStyleSheetTag(t, path, state) {
63
61
  callee.container.arguments.push(t.numericLiteral(uniqueId))
64
62
  }
65
63
 
66
- /** @param {import('./index').UnistylesPluginPass} state */
67
- function analyzeDependencies(t, state, name, unistyleObj, themeName, rtName) {
68
- const debugMessage = deps => {
69
- if (state.opts.debug) {
70
- const mappedDeps = deps
71
- .map(dep => Object.keys(UnistyleDependency).find(key => UnistyleDependency[key] === dep))
72
- .join(', ')
64
+ const getProperty = (t, property) => {
65
+ if (!property) {
66
+ return undefined
67
+ }
73
68
 
74
- console.log(`${state.filename.replace(`${state.file.opts.root}/`, '')}: styles.${name}: [${mappedDeps}]`)
69
+ if (t.isIdentifier(property)) {
70
+ return {
71
+ properties: [property.name]
75
72
  }
76
73
  }
77
- const unistyle = unistyleObj.properties
78
- const dependencies = []
79
74
 
80
- Object.values(unistyle).forEach(uni => {
81
- const identifier = getIdentifierNameFromExpression(t, uni.value)
75
+ if (t.isObjectPattern(property)) {
76
+ const matchingProperties = property.properties.flatMap(p => getProperty(t, p))
82
77
 
83
- if (identifier.includes(themeName)) {
84
- dependencies.push(UnistyleDependency.Theme)
78
+ return {
79
+ properties: matchingProperties.flatMap(properties => properties.properties)
85
80
  }
81
+ }
86
82
 
87
- if (identifier.includes(rtName)) {
88
- const propertyNames = getSecondPropertyName(t, uni.value)
83
+ if (t.isObjectProperty(property) && t.isIdentifier(property.value)) {
84
+ return {
85
+ properties: [property.key.name]
86
+ }
87
+ }
89
88
 
90
- propertyNames
91
- .filter(Boolean)
92
- .forEach(propertyName => {
93
- switch (propertyName) {
94
- case 'themeName': {
95
- dependencies.push(UnistyleDependency.ThemeName)
89
+ if (t.isObjectProperty(property) && t.isObjectPattern(property.value)) {
90
+ const matchingProperties = property.value.properties.flatMap(p => getProperty(t, p))
96
91
 
97
- return
98
- }
99
- case 'adaptiveThemes': {
100
- dependencies.push(UnistyleDependency.AdaptiveThemes)
92
+ return {
93
+ parent: property.key.name,
94
+ properties: matchingProperties.flatMap(properties => properties.properties)
95
+ }
96
+ }
101
97
 
102
- return
103
- }
104
- case 'breakpoint': {
105
- dependencies.push(UnistyleDependency.Breakpoints)
98
+ return undefined
99
+ }
106
100
 
107
- return
108
- }
109
- case 'colorScheme': {
110
- dependencies.push(UnistyleDependency.ColorScheme)
101
+ function getStylesDependenciesFromObject(t, path) {
102
+ const detectedStylesWithVariants = new Set()
103
+ const stylesheet = path.node.arguments[0]
111
104
 
112
- return
113
- }
114
- case 'screen': {
115
- dependencies.push(UnistyleDependency.Dimensions)
105
+ stylesheet.properties.forEach(property => {
106
+ if (!t.isIdentifier(property.key)) {
107
+ return
108
+ }
116
109
 
117
- return
118
- }
119
- case 'isPortrait':
120
- case 'isLandscape': {
121
- dependencies.push(UnistyleDependency.Orientation)
110
+ if (t.isObjectProperty(property)) {
111
+ if(t.isObjectExpression(property.value)) {
112
+ property.value.properties.forEach(innerProp => {
113
+ if (t.isIdentifier(innerProp.key) && innerProp.key.name === 'variants') {
114
+ detectedStylesWithVariants.add({
115
+ label: 'variants',
116
+ key: property.key.name
117
+ })
118
+ }
119
+ })
122
120
 
123
- return
124
- }
125
- case 'contentSizeCategory': {
126
- dependencies.push(UnistyleDependency.ContentSizeCategory)
121
+ }
122
+ }
127
123
 
128
- return
129
- }
130
- case 'ime': {
131
- dependencies.push(UnistyleDependency.Ime)
124
+ if (t.isArrowFunctionExpression(property.value)) {
125
+ if(t.isObjectExpression(property.value.body)) {
126
+ property.value.body.properties.forEach(innerProp => {
127
+ if (t.isIdentifier(innerProp.key) && innerProp.key.name === 'variants') {
128
+ detectedStylesWithVariants.add({
129
+ label: 'variants',
130
+ key: property.key.name
131
+ })
132
+ }
133
+ })
132
134
 
133
- return
134
- }
135
- case 'insets': {
136
- dependencies.push(UnistyleDependency.Insets)
135
+ }
136
+ }
137
+ })
137
138
 
138
- return
139
- }
140
- case 'pixelRatio': {
141
- dependencies.push(UnistyleDependency.PixelRatio)
139
+ const variants = Array.from(detectedStylesWithVariants)
140
+
141
+ return variants.reduce((acc, { key, label }) => {
142
+ if (acc[key]) {
143
+ return {
144
+ ...acc,
145
+ [key]: [
146
+ ...acc[key],
147
+ label
148
+ ]
149
+ }
150
+ }
142
151
 
143
- return
144
- }
145
- case 'fontScale': {
146
- dependencies.push(UnistyleDependency.FontScale)
152
+ return {
153
+ ...acc,
154
+ [key]: [label]
155
+ }
156
+ }, {})
157
+ }
147
158
 
148
- return
149
- }
150
- case 'statusBar': {
151
- dependencies.push(UnistyleDependency.StatusBar)
159
+ function getStylesDependenciesFromFunction(t, path) {
160
+ const funcPath = path.get('arguments.0')
161
+
162
+ if (!funcPath) {
163
+ return
164
+ }
165
+
166
+ const params = funcPath.node.params
167
+ const [themeParam, rtParam] = params
168
+
169
+ let themeNames = []
170
+
171
+ // destructured theme object
172
+ if (themeParam && themeParam.type === 'ObjectPattern') {
173
+ // If destructured, collect all property names
174
+ for (const prop of themeParam.properties) {
175
+ themeNames.push(getProperty(t, prop))
176
+ }
177
+ }
178
+
179
+ // user used 'theme' without destructuring
180
+ if (themeParam && themeParam.type === 'Identifier') {
181
+ themeNames.push({
182
+ properties: [themeParam.name]
183
+ })
184
+ }
185
+
186
+ let rtNames = []
187
+
188
+ // destructured rt object
189
+ if (rtParam && rtParam.type === 'ObjectPattern') {
190
+ // If destructured, collect all property names
191
+ for (const prop of rtParam.properties) {
192
+ rtNames.push(getProperty(t, prop))
193
+ }
194
+ }
195
+
196
+ // user used 'rt' without destructuring
197
+ if (rtParam && rtParam.type === 'Identifier') {
198
+ rtNames.push({
199
+ properties: [rtParam.name]
200
+ })
201
+ }
202
+
203
+ // get returned object or return statement from StyleSheet.create function
204
+ let returnedObjectPath = null
205
+
206
+ if (funcPath.get('body').isObjectExpression()) {
207
+ returnedObjectPath = funcPath.get('body')
208
+ } else {
209
+ funcPath.traverse({
210
+ ReturnStatement(retPath) {
211
+ if (!returnedObjectPath && retPath.get('argument').isObjectExpression()) {
212
+ returnedObjectPath = retPath.get('argument')
213
+ }
214
+ }
215
+ })
216
+ }
217
+
218
+ if (!returnedObjectPath) {
219
+ // there is no returned object
220
+ // abort
221
+
222
+ return
223
+ }
224
+
225
+ const detectedStylesWithVariants = new Set()
226
+
227
+ // detect variants via Scope
228
+ returnedObjectPath.get('properties').forEach(propPath => {
229
+ // get style name
230
+ const stylePath = propPath.get('key')
231
+
232
+ if (!stylePath.isIdentifier()) {
233
+ return
234
+ }
235
+
236
+ const styleKey = stylePath.node.name
237
+
238
+ const valuePath = propPath.get('value')
239
+
240
+ if (valuePath.isObjectExpression()) {
241
+ const hasVariants = valuePath.get('properties').some(innerProp => {
242
+ const innerKey = innerProp.get('key')
243
+
244
+ return innerKey.isIdentifier() && innerKey.node.name === 'variants'
245
+ })
246
+
247
+ if (hasVariants) {
248
+ detectedStylesWithVariants.add({
249
+ label: 'variants',
250
+ key: styleKey
251
+ })
252
+ }
253
+ }
254
+
255
+ if (valuePath.isArrowFunctionExpression()) {
256
+ if(t.isObjectExpression(valuePath.node.body)) {
257
+ const hasVariants = valuePath.node.body.properties.some(innerProp => {
258
+
259
+ return t.isIdentifier(innerProp.key) && innerProp.key.name === 'variants'
260
+ })
261
+
262
+ if (hasVariants) {
263
+ detectedStylesWithVariants.add({
264
+ label: 'variants',
265
+ key: styleKey
266
+ })
267
+ }
268
+ }
269
+ }
270
+ })
271
+
272
+ const detectedStylesWithTheme = new Set()
273
+
274
+ // detect theme dependencies via Scope
275
+ themeNames.forEach(({ properties }) => {
276
+ properties.forEach(property => {
277
+ const binding = funcPath.scope.getBinding(property)
278
+
279
+ if (!binding) {
280
+ return
281
+ }
282
+
283
+ binding.referencePaths.forEach(refPath => {
284
+ // find key of the style that we are referring to
285
+ const containerProp = refPath
286
+ .findParent(parent => parent.isObjectProperty() && parent.parentPath === returnedObjectPath)
152
287
 
153
- return
288
+ if (!containerProp) {
289
+ return
290
+ }
291
+
292
+ const keyNode = containerProp.get('key')
293
+ const styleKey = keyNode.isIdentifier()
294
+ ? keyNode.node.name
295
+ : keyNode.isLiteral()
296
+ ? keyNode.node.value
297
+ : null
298
+
299
+ if (styleKey) {
300
+ detectedStylesWithTheme.add({
301
+ label: 'theme',
302
+ key: styleKey
303
+ })
304
+ }
305
+ })
306
+ })
307
+ })
308
+
309
+ const detectedStylesWithRt = new Set()
310
+ const localRtName = t.isIdentifier(rtParam)
311
+ ? rtParam.name
312
+ : undefined
313
+
314
+ // detect rt dependencies via Scope
315
+ rtNames.forEach(({ properties, parent }) => {
316
+ properties.forEach(property => {
317
+ const rtBinding = funcPath.scope.getBinding(property)
318
+
319
+ if (!rtBinding) {
320
+ return
321
+ }
322
+
323
+ const isValidDependency = Boolean(toUnistylesDependency(property))
324
+
325
+ let validRtName = property
326
+
327
+ // user used nested destructing, find out parent key
328
+ if (!isValidDependency && (!localRtName || (localRtName && localRtName !== property))) {
329
+ if (!parent) {
330
+ return
331
+ }
332
+
333
+ if (!Boolean(toUnistylesDependency(parent))) {
334
+ return
335
+ }
336
+
337
+ validRtName = parent
338
+ }
339
+
340
+ rtBinding.referencePaths.forEach(refPath => {
341
+ // to detect rt dependencies we need to get parameter not rt itself
342
+ // eg. rt.screen.width -> screen
343
+ // rt.insets.top -> insets
344
+ // special case: rt.insets.ime -> ime
345
+
346
+ let usedLabel = validRtName
347
+
348
+ if (refPath.parentPath.isMemberExpression() && refPath.parentPath.get('object') === refPath) {
349
+ const memberExpr = refPath.parentPath
350
+ const propPath = memberExpr.get('property')
351
+
352
+ if (propPath.isIdentifier()) {
353
+ if (localRtName) {
354
+ usedLabel = propPath.node.name
154
355
  }
155
- case 'navigationBar': {
156
- dependencies.push(UnistyleDependency.NavigationBar)
157
356
 
158
- return
357
+ if (
358
+ usedLabel === 'insets' &&
359
+ memberExpr.parentPath.isMemberExpression() &&
360
+ memberExpr.parentPath.get('object') === memberExpr
361
+ ) {
362
+ const secondPropPath = memberExpr.parentPath.get('property')
363
+
364
+ if (secondPropPath.isIdentifier() && secondPropPath.node.name === 'ime') {
365
+ usedLabel = 'ime'
366
+ }
159
367
  }
160
368
  }
161
- })
162
- }
369
+ }
370
+
371
+ // find key of the style that we are referring to
372
+ const containerProp = refPath
373
+ .findParent(parent => parent.isObjectProperty() && parent.parentPath === returnedObjectPath)
374
+
375
+ if (!containerProp) {
376
+ return
377
+ }
378
+
379
+ const keyNode = containerProp.get('key')
380
+ const styleKey = keyNode.isIdentifier()
381
+ ? keyNode.node.name
382
+ : keyNode.isLiteral()
383
+ ? keyNode.node.value
384
+ : null
385
+
386
+ if (styleKey) {
387
+ detectedStylesWithRt.add({
388
+ label: usedLabel,
389
+ key: styleKey
390
+ })
391
+ }
392
+ })
393
+ })
394
+ })
395
+
396
+ const variants = Array.from(detectedStylesWithVariants)
397
+ const theme = Array.from(detectedStylesWithTheme)
398
+ const rt = Array.from(detectedStylesWithRt)
399
+
400
+ return theme
401
+ .concat(rt)
402
+ .concat(variants)
403
+ .reduce((acc, { key, label }) => {
404
+ if (acc[key]) {
405
+ return {
406
+ ...acc,
407
+ [key]: [
408
+ ...acc[key],
409
+ label
410
+ ]
411
+ }
412
+ }
413
+
414
+ return {
415
+ ...acc,
416
+ [key]: [label]
417
+ }
418
+ }, {})
419
+ }
163
420
 
164
- if (uni.key && uni.key.name === 'variants') {
165
- dependencies.push(UnistyleDependency.Variants)
421
+ function toUnistylesDependency(dependency) {
422
+ switch (dependency) {
423
+ case 'theme': {
424
+ return UnistyleDependency.Theme
425
+ }
426
+ case 'themeName': {
427
+ return UnistyleDependency.ThemeName
428
+ }
429
+ case 'adaptiveThemes': {
430
+ return UnistyleDependency.AdaptiveThemes
431
+ }
432
+ case 'breakpoint': {
433
+ return UnistyleDependency.Breakpoints
434
+ }
435
+ case 'colorScheme': {
436
+ return UnistyleDependency.ColorScheme
437
+ }
438
+ case 'screen': {
439
+ return UnistyleDependency.Dimensions
440
+ }
441
+ case 'isPortrait':
442
+ case 'isLandscape': {
443
+ return UnistyleDependency.Orientation
444
+ }
445
+ case 'contentSizeCategory': {
446
+ return UnistyleDependency.ContentSizeCategory
447
+ }
448
+ case 'ime': {
449
+ return UnistyleDependency.Ime
450
+ }
451
+ case 'insets': {
452
+ return UnistyleDependency.Insets
453
+ }
454
+ case 'pixelRatio': {
455
+ return UnistyleDependency.PixelRatio
456
+ }
457
+ case 'fontScale': {
458
+ return UnistyleDependency.FontScale
459
+ }
460
+ case 'statusBar': {
461
+ return UnistyleDependency.StatusBar
462
+ }
463
+ case 'navigationBar': {
464
+ return UnistyleDependency.NavigationBar
465
+ }
466
+ case 'variants': {
467
+ return UnistyleDependency.Variants
166
468
  }
167
469
 
168
470
  // breakpoints are too complex and are handled by C++
169
- })
471
+ }
472
+ }
170
473
 
171
- // add dependencies to the unistyle object if any found
172
- if (dependencies.length > 0) {
173
- const uniqueDependencies = Array.from(new Set(dependencies))
474
+ function getReturnStatementsFromBody(t, node, results = []) {
475
+ if (t.isReturnStatement(node)) {
476
+ results.push(node)
477
+ }
174
478
 
175
- debugMessage(uniqueDependencies)
479
+ if (t.isBlockStatement(node)) {
480
+ node.body.forEach(child => getReturnStatementsFromBody(t, child, results))
481
+ }
176
482
 
177
- unistyleObj.properties.push(
178
- t.objectProperty(
179
- t.identifier('uni__dependencies'),
180
- t.arrayExpression(uniqueDependencies.map(dep => t.numericLiteral(dep)))
181
- )
182
- )
483
+ if (t.isIfStatement(node)) {
484
+ getReturnStatementsFromBody(t, node.consequent, results)
485
+
486
+ if (node.alternate) {
487
+ getReturnStatementsFromBody(t, node.alternate, results)
488
+ }
183
489
  }
490
+
491
+ return results
184
492
  }
185
493
 
186
- function getUnistyles(t, property) {
187
- const propertyValue = t.isArrowFunctionExpression(property.value)
188
- ? property.value.body
189
- : property.value
494
+ function addDependencies(t, state, styleName, unistyle, detectedDependencies) {
495
+ const debugMessage = deps => {
496
+ if (state.opts.debug) {
497
+ const mappedDeps = deps
498
+ .map(dep => Object.keys(UnistyleDependency).find(key => UnistyleDependency[key] === dep))
499
+ .join(', ')
190
500
 
191
- if (t.isObjectExpression(propertyValue)) {
192
- return [propertyValue]
501
+ console.log(`${state.filename.replace(`${state.file.opts.root}/`, '')}: styles.${styleName}: [${mappedDeps}]`)
502
+ }
193
503
  }
194
504
 
195
- if (t.isBlockStatement(propertyValue)) {
196
- // here we might have single return statement
197
- // or if-else statements with return statements
198
- return propertyValue.body
199
- .flatMap(value => {
200
- if (t.isReturnStatement(value)) {
201
- return [value]
202
- }
505
+ const styleDependencies = detectedDependencies.map(toUnistylesDependency)
203
506
 
204
- if (!t.isIfStatement(value)) {
205
- return []
206
- }
507
+ // add metadata about dependencies
508
+ if (styleDependencies.length > 0) {
509
+ const uniqueDependencies = Array.from(new Set(styleDependencies))
510
+
511
+ debugMessage(uniqueDependencies)
512
+
513
+ let targets = []
514
+
515
+ if (t.isArrowFunctionExpression(unistyle.value) || t.isFunctionExpression(unistyle.value)) {
516
+ if (t.isObjectExpression(unistyle.value.body)) {
517
+ targets.push(unistyle.value.body)
518
+ }
207
519
 
208
- return [value.consequent, value.alternate]
209
- .filter(Boolean)
210
- .flatMap(value => {
211
- if (t.isBlockStatement(value)) {
212
- return value.body.filter(t.isReturnStatement)
520
+ if (t.isBlockStatement(unistyle.value.body)) {
521
+ targets = getReturnStatementsFromBody(t, unistyle.value.body)
522
+ .map(node => {
523
+ if (t.isIdentifier(node.argument)) {
524
+ node.argument = t.objectExpression([
525
+ t.spreadElement(node.argument)
526
+ ])
213
527
  }
528
+
529
+ return node.argument
214
530
  })
531
+ }
532
+ }
533
+
534
+ if (t.isObjectExpression(unistyle.value)) {
535
+ targets.push(unistyle.value)
536
+ }
537
+
538
+ if (t.isMemberExpression(unistyle.value)) {
539
+ // convert to object
540
+ unistyle.value = t.objectExpression([t.spreadElement(unistyle.value)])
541
+
542
+ targets.push(unistyle.value)
543
+ }
544
+
545
+ if (targets.length > 0) {
546
+ targets.forEach(target => {
547
+ target.properties.push(
548
+ t.objectProperty(
549
+ t.identifier('uni__dependencies'),
550
+ t.arrayExpression(uniqueDependencies.map(dep => t.numericLiteral(dep)))
551
+ )
552
+ )
215
553
  })
216
- .map(value => value.argument)
554
+ }
217
555
  }
218
-
219
- return []
220
556
  }
221
557
 
222
558
  module.exports = {
223
559
  isUnistylesStyleSheet,
224
- analyzeDependencies,
560
+ addDependencies,
225
561
  addStyleSheetTag,
226
- getUnistyles,
562
+ getStylesDependenciesFromObject,
563
+ getStylesDependenciesFromFunction,
227
564
  isKindOfStyleSheet
228
565
  }
@@ -15,7 +15,7 @@ function extractVariants(t, path, state) {
15
15
  return (
16
16
  t.isIdentifier(variant.expression.callee.object, { name: calleeName }) &&
17
17
  t.isIdentifier(variant.expression.callee.property, { name: 'useVariants' }) &&
18
- t.isObjectExpression(variant.expression.arguments[0])
18
+ variant.expression.arguments.length === 1
19
19
  )
20
20
  })
21
21
 
@@ -0,0 +1,17 @@
1
+ import { Animated as RNAnimated } from 'react-native'
2
+ import { FlatList } from './FlatList'
3
+ import { Image } from './Image'
4
+ import { ScrollView } from './ScrollView'
5
+ import { SectionList } from './SectionList'
6
+ import { Text } from './Text'
7
+ import { View } from './View'
8
+
9
+ export const Animated = {
10
+ ...RNAnimated,
11
+ View: RNAnimated.createAnimatedComponent(View),
12
+ Text: RNAnimated.createAnimatedComponent(Text),
13
+ FlatList: RNAnimated.createAnimatedComponent(FlatList),
14
+ Image: RNAnimated.createAnimatedComponent(Image),
15
+ ScrollView: RNAnimated.createAnimatedComponent(ScrollView),
16
+ SectionList: RNAnimated.createAnimatedComponent(SectionList)
17
+ }