react-native-unistyles 3.5.3 → 3.7.0

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 (401) hide show
  1. package/README.md +6 -8
  2. package/android/build.gradle +42 -0
  3. package/android/src/legacy/java/com/unistyles/NativePlatform+extraWindows.kt +16 -0
  4. package/android/src/main/cxx/NativeUnistylesModule.cpp +5 -11
  5. package/android/src/main/cxx/NativeUnistylesModule.h +0 -4
  6. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +82 -39
  7. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +73 -0
  8. package/android/src/main/java/com/unistyles/UnistylesModule.kt +2 -13
  9. package/android/src/rn86/java/com/unistyles/NativePlatform+extraWindows.kt +28 -0
  10. package/cxx/common/PerformanceTracing.h +85 -0
  11. package/cxx/converters/BackgroundImageConverter.cpp +198 -11
  12. package/cxx/converters/BackgroundImageConverter.h +1 -0
  13. package/cxx/converters/BackgroundLayerConverter.cpp +523 -0
  14. package/cxx/converters/BackgroundLayerConverter.h +14 -0
  15. package/cxx/converters/FontVariationSettingsConverter.cpp +104 -0
  16. package/cxx/converters/FontVariationSettingsConverter.h +17 -0
  17. package/cxx/core/HostUnistyle.cpp +6 -0
  18. package/cxx/core/UnistyleWrapper.h +16 -1
  19. package/cxx/hybridObjects/HybridShadowRegistry.cpp +13 -0
  20. package/cxx/hybridObjects/HybridStyleSheet.cpp +11 -0
  21. package/cxx/hybridObjects/HybridStyleSheet.h +1 -0
  22. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +10 -30
  23. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
  24. package/cxx/parser/Parser.cpp +92 -5
  25. package/cxx/shadowTree/ShadowTreeDiagnostics.cpp +74 -0
  26. package/cxx/shadowTree/ShadowTreeManager.cpp +3 -0
  27. package/ios/NativePlatform+ios.swift +22 -11
  28. package/ios/NativePlatformListener+ios.swift +9 -0
  29. package/lib/commonjs/components/NamedTheme.js +4 -4
  30. package/lib/commonjs/components/NamedTheme.js.map +1 -1
  31. package/lib/commonjs/components/ScopedThemeContext.js +3 -1
  32. package/lib/commonjs/components/ScopedThemeContext.js.map +1 -1
  33. package/lib/commonjs/components/native/deep/ActivityIndicator.js +19 -0
  34. package/lib/commonjs/components/native/deep/ActivityIndicator.js.map +1 -0
  35. package/lib/commonjs/components/native/deep/Animated.js +19 -0
  36. package/lib/commonjs/components/native/deep/Animated.js.map +1 -0
  37. package/lib/commonjs/components/native/deep/FlatList.js +19 -0
  38. package/lib/commonjs/components/native/deep/FlatList.js.map +1 -0
  39. package/lib/commonjs/components/native/deep/Image.js +19 -0
  40. package/lib/commonjs/components/native/deep/Image.js.map +1 -0
  41. package/lib/commonjs/components/native/deep/ImageBackground.js +19 -0
  42. package/lib/commonjs/components/native/deep/ImageBackground.js.map +1 -0
  43. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js +19 -0
  44. package/lib/commonjs/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  45. package/lib/commonjs/components/native/deep/Pressable.js +19 -0
  46. package/lib/commonjs/components/native/deep/Pressable.js.map +1 -0
  47. package/lib/commonjs/components/native/deep/RefreshControl.js +19 -0
  48. package/lib/commonjs/components/native/deep/RefreshControl.js.map +1 -0
  49. package/lib/commonjs/components/native/deep/SafeAreaView.js +19 -0
  50. package/lib/commonjs/components/native/deep/SafeAreaView.js.map +1 -0
  51. package/lib/commonjs/components/native/deep/ScrollView.js +19 -0
  52. package/lib/commonjs/components/native/deep/ScrollView.js.map +1 -0
  53. package/lib/commonjs/components/native/deep/SectionList.js +19 -0
  54. package/lib/commonjs/components/native/deep/SectionList.js.map +1 -0
  55. package/lib/commonjs/components/native/deep/Switch.js +19 -0
  56. package/lib/commonjs/components/native/deep/Switch.js.map +1 -0
  57. package/lib/commonjs/components/native/deep/Text.js +19 -0
  58. package/lib/commonjs/components/native/deep/Text.js.map +1 -0
  59. package/lib/commonjs/components/native/deep/TextInput.js +19 -0
  60. package/lib/commonjs/components/native/deep/TextInput.js.map +1 -0
  61. package/lib/commonjs/components/native/deep/TextNativeComponent.js +28 -0
  62. package/lib/commonjs/components/native/deep/TextNativeComponent.js.map +1 -0
  63. package/lib/commonjs/components/native/deep/TouchableHighlight.js +19 -0
  64. package/lib/commonjs/components/native/deep/TouchableHighlight.js.map +1 -0
  65. package/lib/commonjs/components/native/deep/TouchableOpacity.js +19 -0
  66. package/lib/commonjs/components/native/deep/TouchableOpacity.js.map +1 -0
  67. package/lib/commonjs/components/native/deep/View.js +19 -0
  68. package/lib/commonjs/components/native/deep/View.js.map +1 -0
  69. package/lib/commonjs/components/native/deep/ViewNativeComponent.js +26 -0
  70. package/lib/commonjs/components/native/deep/ViewNativeComponent.js.map +1 -0
  71. package/lib/commonjs/components/native/deep/VirtualizedList.js +19 -0
  72. package/lib/commonjs/components/native/deep/VirtualizedList.js.map +1 -0
  73. package/lib/commonjs/components/native/index.js +43 -0
  74. package/lib/commonjs/components/native/index.js.map +1 -0
  75. package/lib/commonjs/core/createUnistylesActivityIndicator.js +13 -3
  76. package/lib/commonjs/core/createUnistylesActivityIndicator.js.map +1 -1
  77. package/lib/commonjs/core/createUnistylesElement.native.js +6 -0
  78. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  79. package/lib/commonjs/core/createUnistylesImageBackground.js +26 -19
  80. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  81. package/lib/commonjs/core/createUnistylesTouchableHighlight.js +6 -0
  82. package/lib/commonjs/core/createUnistylesTouchableHighlight.js.map +1 -1
  83. package/lib/commonjs/core/getClassname.js +15 -0
  84. package/lib/commonjs/core/getClassname.js.map +1 -1
  85. package/lib/commonjs/core/hasUnistyles.js +26 -0
  86. package/lib/commonjs/core/hasUnistyles.js.map +1 -0
  87. package/lib/commonjs/core/withUnistyles/withUnistyles.js +10 -7
  88. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  89. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +22 -3
  90. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  91. package/lib/commonjs/mocks.js +27 -3
  92. package/lib/commonjs/mocks.js.map +1 -1
  93. package/lib/commonjs/specs/ShadowRegistry/index.js +69 -76
  94. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  95. package/lib/commonjs/specs/ShadowRegistry/styleSource.js +65 -0
  96. package/lib/commonjs/specs/ShadowRegistry/styleSource.js.map +1 -0
  97. package/lib/commonjs/specs/ShadowRegistry/tracing.js +26 -0
  98. package/lib/commonjs/specs/ShadowRegistry/tracing.js.map +1 -0
  99. package/lib/commonjs/unifiber/src/adapters/reanimated.js +157 -0
  100. package/lib/commonjs/unifiber/src/adapters/reanimated.js.map +1 -0
  101. package/lib/commonjs/unifiber/src/adapters/registry.js +67 -0
  102. package/lib/commonjs/unifiber/src/adapters/registry.js.map +1 -0
  103. package/lib/commonjs/unifiber/src/diagnostics.js +59 -0
  104. package/lib/commonjs/unifiber/src/diagnostics.js.map +1 -0
  105. package/lib/commonjs/unifiber/src/fiber.js +199 -0
  106. package/lib/commonjs/unifiber/src/fiber.js.map +1 -0
  107. package/lib/commonjs/unifiber/src/host.js +214 -0
  108. package/lib/commonjs/unifiber/src/host.js.map +1 -0
  109. package/lib/commonjs/unifiber/src/index.js +38 -0
  110. package/lib/commonjs/unifiber/src/index.js.map +1 -0
  111. package/lib/commonjs/utils.js +52 -1
  112. package/lib/commonjs/utils.js.map +1 -1
  113. package/lib/commonjs/web/convert/index.js +19 -1
  114. package/lib/commonjs/web/convert/index.js.map +1 -1
  115. package/lib/commonjs/web/convert/module.d.ts +3 -0
  116. package/lib/commonjs/web/convert/object/backgroundLayers.js +30 -0
  117. package/lib/commonjs/web/convert/object/backgroundLayers.js.map +1 -0
  118. package/lib/commonjs/web/convert/object/fontVariationSettings.js +12 -0
  119. package/lib/commonjs/web/convert/object/fontVariationSettings.js.map +1 -0
  120. package/lib/commonjs/web/convert/object/index.js +22 -0
  121. package/lib/commonjs/web/convert/object/index.js.map +1 -1
  122. package/lib/commonjs/web/convert/utils.js +7 -1
  123. package/lib/commonjs/web/convert/utils.js.map +1 -1
  124. package/lib/commonjs/web/registry.js +6 -4
  125. package/lib/commonjs/web/registry.js.map +1 -1
  126. package/lib/commonjs/web/runtime.js +9 -6
  127. package/lib/commonjs/web/runtime.js.map +1 -1
  128. package/lib/commonjs/web/utils/unistyle.js +9 -3
  129. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  130. package/lib/module/components/NamedTheme.js +4 -4
  131. package/lib/module/components/NamedTheme.js.map +1 -1
  132. package/lib/module/components/ScopedThemeContext.js +3 -1
  133. package/lib/module/components/ScopedThemeContext.js.map +1 -1
  134. package/lib/module/components/native/deep/ActivityIndicator.js +5 -0
  135. package/lib/module/components/native/deep/ActivityIndicator.js.map +1 -0
  136. package/lib/module/components/native/deep/Animated.js +5 -0
  137. package/lib/module/components/native/deep/Animated.js.map +1 -0
  138. package/lib/module/components/native/deep/FlatList.js +5 -0
  139. package/lib/module/components/native/deep/FlatList.js.map +1 -0
  140. package/lib/module/components/native/deep/Image.js +5 -0
  141. package/lib/module/components/native/deep/Image.js.map +1 -0
  142. package/lib/module/components/native/deep/ImageBackground.js +5 -0
  143. package/lib/module/components/native/deep/ImageBackground.js.map +1 -0
  144. package/lib/module/components/native/deep/KeyboardAvoidingView.js +5 -0
  145. package/lib/module/components/native/deep/KeyboardAvoidingView.js.map +1 -0
  146. package/lib/module/components/native/deep/Pressable.js +5 -0
  147. package/lib/module/components/native/deep/Pressable.js.map +1 -0
  148. package/lib/module/components/native/deep/RefreshControl.js +5 -0
  149. package/lib/module/components/native/deep/RefreshControl.js.map +1 -0
  150. package/lib/module/components/native/deep/SafeAreaView.js +5 -0
  151. package/lib/module/components/native/deep/SafeAreaView.js.map +1 -0
  152. package/lib/module/components/native/deep/ScrollView.js +5 -0
  153. package/lib/module/components/native/deep/ScrollView.js.map +1 -0
  154. package/lib/module/components/native/deep/SectionList.js +5 -0
  155. package/lib/module/components/native/deep/SectionList.js.map +1 -0
  156. package/lib/module/components/native/deep/Switch.js +5 -0
  157. package/lib/module/components/native/deep/Switch.js.map +1 -0
  158. package/lib/module/components/native/deep/Text.js +5 -0
  159. package/lib/module/components/native/deep/Text.js.map +1 -0
  160. package/lib/module/components/native/deep/TextInput.js +5 -0
  161. package/lib/module/components/native/deep/TextInput.js.map +1 -0
  162. package/lib/module/components/native/deep/TextNativeComponent.js +8 -0
  163. package/lib/module/components/native/deep/TextNativeComponent.js.map +1 -0
  164. package/lib/module/components/native/deep/TouchableHighlight.js +5 -0
  165. package/lib/module/components/native/deep/TouchableHighlight.js.map +1 -0
  166. package/lib/module/components/native/deep/TouchableOpacity.js +5 -0
  167. package/lib/module/components/native/deep/TouchableOpacity.js.map +1 -0
  168. package/lib/module/components/native/deep/View.js +5 -0
  169. package/lib/module/components/native/deep/View.js.map +1 -0
  170. package/lib/module/components/native/deep/ViewNativeComponent.js +8 -0
  171. package/lib/module/components/native/deep/ViewNativeComponent.js.map +1 -0
  172. package/lib/module/components/native/deep/VirtualizedList.js +5 -0
  173. package/lib/module/components/native/deep/VirtualizedList.js.map +1 -0
  174. package/lib/module/components/native/index.js +43 -0
  175. package/lib/module/components/native/index.js.map +1 -0
  176. package/lib/module/core/createUnistylesActivityIndicator.js +13 -3
  177. package/lib/module/core/createUnistylesActivityIndicator.js.map +1 -1
  178. package/lib/module/core/createUnistylesElement.native.js +6 -0
  179. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  180. package/lib/module/core/createUnistylesImageBackground.js +26 -19
  181. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  182. package/lib/module/core/createUnistylesTouchableHighlight.js +6 -0
  183. package/lib/module/core/createUnistylesTouchableHighlight.js.map +1 -1
  184. package/lib/module/core/getClassname.js +16 -1
  185. package/lib/module/core/getClassname.js.map +1 -1
  186. package/lib/module/core/hasUnistyles.js +21 -0
  187. package/lib/module/core/hasUnistyles.js.map +1 -0
  188. package/lib/module/core/withUnistyles/withUnistyles.js +9 -6
  189. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  190. package/lib/module/core/withUnistyles/withUnistyles.native.js +24 -5
  191. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  192. package/lib/module/mocks.js +27 -3
  193. package/lib/module/mocks.js.map +1 -1
  194. package/lib/module/specs/ShadowRegistry/index.js +69 -76
  195. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  196. package/lib/module/specs/ShadowRegistry/styleSource.js +60 -0
  197. package/lib/module/specs/ShadowRegistry/styleSource.js.map +1 -0
  198. package/lib/module/specs/ShadowRegistry/tracing.js +21 -0
  199. package/lib/module/specs/ShadowRegistry/tracing.js.map +1 -0
  200. package/lib/module/unifiber/src/adapters/reanimated.js +152 -0
  201. package/lib/module/unifiber/src/adapters/reanimated.js.map +1 -0
  202. package/lib/module/unifiber/src/adapters/registry.js +62 -0
  203. package/lib/module/unifiber/src/adapters/registry.js.map +1 -0
  204. package/lib/module/unifiber/src/diagnostics.js +52 -0
  205. package/lib/module/unifiber/src/diagnostics.js.map +1 -0
  206. package/lib/module/unifiber/src/fiber.js +183 -0
  207. package/lib/module/unifiber/src/fiber.js.map +1 -0
  208. package/lib/module/unifiber/src/host.js +191 -0
  209. package/lib/module/unifiber/src/host.js.map +1 -0
  210. package/lib/module/unifiber/src/index.js +33 -0
  211. package/lib/module/unifiber/src/index.js.map +1 -0
  212. package/lib/module/utils.js +50 -0
  213. package/lib/module/utils.js.map +1 -1
  214. package/lib/module/web/convert/index.js +22 -3
  215. package/lib/module/web/convert/index.js.map +1 -1
  216. package/lib/module/web/convert/module.d.ts +3 -0
  217. package/lib/module/web/convert/object/backgroundLayers.js +25 -0
  218. package/lib/module/web/convert/object/backgroundLayers.js.map +1 -0
  219. package/lib/module/web/convert/object/fontVariationSettings.js +7 -0
  220. package/lib/module/web/convert/object/fontVariationSettings.js.map +1 -0
  221. package/lib/module/web/convert/object/index.js +2 -0
  222. package/lib/module/web/convert/object/index.js.map +1 -1
  223. package/lib/module/web/convert/utils.js +4 -0
  224. package/lib/module/web/convert/utils.js.map +1 -1
  225. package/lib/module/web/registry.js +6 -4
  226. package/lib/module/web/registry.js.map +1 -1
  227. package/lib/module/web/runtime.js +9 -6
  228. package/lib/module/web/runtime.js.map +1 -1
  229. package/lib/module/web/utils/unistyle.js +10 -4
  230. package/lib/module/web/utils/unistyle.js.map +1 -1
  231. package/lib/typescript/src/components/ScopedThemeContext.d.ts +2 -1
  232. package/lib/typescript/src/components/ScopedThemeContext.d.ts.map +1 -1
  233. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts +2 -0
  234. package/lib/typescript/src/components/native/deep/ActivityIndicator.d.ts.map +1 -0
  235. package/lib/typescript/src/components/native/deep/Animated.d.ts +2 -0
  236. package/lib/typescript/src/components/native/deep/Animated.d.ts.map +1 -0
  237. package/lib/typescript/src/components/native/deep/FlatList.d.ts +2 -0
  238. package/lib/typescript/src/components/native/deep/FlatList.d.ts.map +1 -0
  239. package/lib/typescript/src/components/native/deep/Image.d.ts +2 -0
  240. package/lib/typescript/src/components/native/deep/Image.d.ts.map +1 -0
  241. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts +2 -0
  242. package/lib/typescript/src/components/native/deep/ImageBackground.d.ts.map +1 -0
  243. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts +2 -0
  244. package/lib/typescript/src/components/native/deep/KeyboardAvoidingView.d.ts.map +1 -0
  245. package/lib/typescript/src/components/native/deep/Pressable.d.ts +2 -0
  246. package/lib/typescript/src/components/native/deep/Pressable.d.ts.map +1 -0
  247. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts +2 -0
  248. package/lib/typescript/src/components/native/deep/RefreshControl.d.ts.map +1 -0
  249. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts +2 -0
  250. package/lib/typescript/src/components/native/deep/SafeAreaView.d.ts.map +1 -0
  251. package/lib/typescript/src/components/native/deep/ScrollView.d.ts +2 -0
  252. package/lib/typescript/src/components/native/deep/ScrollView.d.ts.map +1 -0
  253. package/lib/typescript/src/components/native/deep/SectionList.d.ts +2 -0
  254. package/lib/typescript/src/components/native/deep/SectionList.d.ts.map +1 -0
  255. package/lib/typescript/src/components/native/deep/Switch.d.ts +2 -0
  256. package/lib/typescript/src/components/native/deep/Switch.d.ts.map +1 -0
  257. package/lib/typescript/src/components/native/deep/Text.d.ts +2 -0
  258. package/lib/typescript/src/components/native/deep/Text.d.ts.map +1 -0
  259. package/lib/typescript/src/components/native/deep/TextInput.d.ts +2 -0
  260. package/lib/typescript/src/components/native/deep/TextInput.d.ts.map +1 -0
  261. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts +3 -0
  262. package/lib/typescript/src/components/native/deep/TextNativeComponent.d.ts.map +1 -0
  263. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts +2 -0
  264. package/lib/typescript/src/components/native/deep/TouchableHighlight.d.ts.map +1 -0
  265. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts +2 -0
  266. package/lib/typescript/src/components/native/deep/TouchableOpacity.d.ts.map +1 -0
  267. package/lib/typescript/src/components/native/deep/View.d.ts +2 -0
  268. package/lib/typescript/src/components/native/deep/View.d.ts.map +1 -0
  269. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts +3 -0
  270. package/lib/typescript/src/components/native/deep/ViewNativeComponent.d.ts.map +1 -0
  271. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts +2 -0
  272. package/lib/typescript/src/components/native/deep/VirtualizedList.d.ts.map +1 -0
  273. package/lib/typescript/src/components/native/index.d.ts +4 -0
  274. package/lib/typescript/src/components/native/index.d.ts.map +1 -0
  275. package/lib/typescript/src/components/scopeChildren.d.ts +1 -1
  276. package/lib/typescript/src/core/createUnistylesActivityIndicator.d.ts.map +1 -1
  277. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  278. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  279. package/lib/typescript/src/core/createUnistylesTouchableHighlight.d.ts.map +1 -1
  280. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  281. package/lib/typescript/src/core/hasUnistyles.d.ts +2 -0
  282. package/lib/typescript/src/core/hasUnistyles.d.ts.map +1 -0
  283. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +6 -3
  284. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  285. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +7 -4
  286. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  287. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  288. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts +11 -0
  289. package/lib/typescript/src/specs/ShadowRegistry/styleSource.d.ts.map +1 -0
  290. package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts +2 -0
  291. package/lib/typescript/src/specs/ShadowRegistry/tracing.d.ts.map +1 -0
  292. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -41
  293. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  294. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts +17 -0
  295. package/lib/typescript/src/unifiber/src/adapters/reanimated.d.ts.map +1 -0
  296. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts +23 -0
  297. package/lib/typescript/src/unifiber/src/adapters/registry.d.ts.map +1 -0
  298. package/lib/typescript/src/unifiber/src/diagnostics.d.ts +10 -0
  299. package/lib/typescript/src/unifiber/src/diagnostics.d.ts.map +1 -0
  300. package/lib/typescript/src/unifiber/src/fiber.d.ts +48 -0
  301. package/lib/typescript/src/unifiber/src/fiber.d.ts.map +1 -0
  302. package/lib/typescript/src/unifiber/src/host.d.ts +32 -0
  303. package/lib/typescript/src/unifiber/src/host.d.ts.map +1 -0
  304. package/lib/typescript/src/unifiber/src/index.d.ts +49 -0
  305. package/lib/typescript/src/unifiber/src/index.d.ts.map +1 -0
  306. package/lib/typescript/src/utils.d.ts +1 -0
  307. package/lib/typescript/src/utils.d.ts.map +1 -1
  308. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  309. package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts +4 -0
  310. package/lib/typescript/src/web/convert/object/backgroundLayers.d.ts.map +1 -0
  311. package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts +4 -0
  312. package/lib/typescript/src/web/convert/object/fontVariationSettings.d.ts.map +1 -0
  313. package/lib/typescript/src/web/convert/object/index.d.ts +2 -0
  314. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -1
  315. package/lib/typescript/src/web/convert/utils.d.ts +2 -0
  316. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  317. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  318. package/lib/typescript/src/web/runtime.d.ts +1 -0
  319. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  320. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  321. package/metro/babel-transformer.js +1102 -0
  322. package/metro/index.d.ts +31 -0
  323. package/metro/index.js +170 -0
  324. package/package.json +50 -32
  325. package/plugin/index.d.ts +7 -0
  326. package/plugin/index.js +115 -33
  327. package/src/components/NamedTheme.tsx +5 -5
  328. package/src/components/ScopedThemeContext.ts +6 -2
  329. package/src/components/native/deep/ActivityIndicator.ts +2 -0
  330. package/src/components/native/deep/Animated.ts +2 -0
  331. package/src/components/native/deep/FlatList.ts +2 -0
  332. package/src/components/native/deep/Image.ts +2 -0
  333. package/src/components/native/deep/ImageBackground.ts +2 -0
  334. package/src/components/native/deep/KeyboardAvoidingView.ts +2 -0
  335. package/src/components/native/deep/Pressable.ts +2 -0
  336. package/src/components/native/deep/RefreshControl.ts +2 -0
  337. package/src/components/native/deep/SafeAreaView.ts +2 -0
  338. package/src/components/native/deep/ScrollView.ts +2 -0
  339. package/src/components/native/deep/SectionList.ts +2 -0
  340. package/src/components/native/deep/Switch.ts +2 -0
  341. package/src/components/native/deep/Text.ts +2 -0
  342. package/src/components/native/deep/TextInput.ts +2 -0
  343. package/src/components/native/deep/TextNativeComponent.ts +5 -0
  344. package/src/components/native/deep/TouchableHighlight.ts +2 -0
  345. package/src/components/native/deep/TouchableOpacity.ts +2 -0
  346. package/src/components/native/deep/View.ts +2 -0
  347. package/src/components/native/deep/ViewNativeComponent.ts +5 -0
  348. package/src/components/native/deep/VirtualizedList.ts +2 -0
  349. package/src/components/native/index.ts +41 -0
  350. package/src/core/createUnistylesActivityIndicator.tsx +11 -4
  351. package/src/core/createUnistylesElement.native.tsx +5 -0
  352. package/src/core/createUnistylesImageBackground.tsx +33 -25
  353. package/src/core/createUnistylesTouchableHighlight.tsx +5 -0
  354. package/src/core/getClassname.ts +10 -1
  355. package/src/core/hasUnistyles.ts +20 -0
  356. package/src/core/withUnistyles/withUnistyles.native.tsx +28 -6
  357. package/src/core/withUnistyles/withUnistyles.tsx +6 -6
  358. package/src/mocks.ts +14 -5
  359. package/src/specs/ShadowRegistry/index.ts +62 -103
  360. package/src/specs/ShadowRegistry/styleSource.ts +78 -0
  361. package/src/specs/ShadowRegistry/tracing.ts +23 -0
  362. package/src/specs/ShadowRegistry/types.ts +3 -43
  363. package/src/unifiber/LICENSE +21 -0
  364. package/src/unifiber/README.md +92 -0
  365. package/src/unifiber/src/adapters/reanimated.ts +204 -0
  366. package/src/unifiber/src/adapters/registry.ts +102 -0
  367. package/src/unifiber/src/diagnostics.ts +55 -0
  368. package/src/unifiber/src/fiber.ts +262 -0
  369. package/src/unifiber/src/host.ts +236 -0
  370. package/src/unifiber/src/index.ts +43 -0
  371. package/src/utils.ts +51 -0
  372. package/src/web/convert/index.ts +39 -3
  373. package/src/web/convert/object/backgroundLayers.ts +33 -0
  374. package/src/web/convert/object/fontVariationSettings.ts +7 -0
  375. package/src/web/convert/object/index.ts +2 -0
  376. package/src/web/convert/utils.ts +11 -0
  377. package/src/web/registry.ts +7 -8
  378. package/src/web/runtime.ts +7 -7
  379. package/src/web/utils/unistyle.ts +11 -4
  380. package/lib/commonjs/web/convert/module.d.js +0 -2
  381. package/lib/commonjs/web/convert/module.d.js.map +0 -1
  382. package/lib/module/web/convert/module.d.js +0 -2
  383. package/lib/module/web/convert/module.d.js.map +0 -1
  384. package/lib/typescript/src/__tests__/mocks.spec.d.ts +0 -2
  385. package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +0 -1
  386. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts +0 -2
  387. package/lib/typescript/src/__tests__/passForwardRef.spec.d.ts.map +0 -1
  388. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts +0 -2
  389. package/lib/typescript/src/__tests__/scoped-theme.spec.d.ts.map +0 -1
  390. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts +0 -2
  391. package/lib/typescript/src/__tests__/shadow-registry.spec.d.ts.map +0 -1
  392. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts +0 -2
  393. package/lib/typescript/src/__tests__/web-child-selector.spec.d.ts.map +0 -1
  394. package/lib/typescript/src/__tests__/web-listener.spec.d.ts +0 -2
  395. package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +0 -1
  396. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts +0 -2
  397. package/lib/typescript/src/__tests__/web-pointer-events.spec.d.ts.map +0 -1
  398. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts +0 -2
  399. package/lib/typescript/src/__tests__/web-runtime.spec.d.ts.map +0 -1
  400. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts +0 -2
  401. package/lib/typescript/src/__tests__/withUnistyles.spec.d.ts.map +0 -1
@@ -0,0 +1,236 @@
1
+ // A Host is the view's creation fiber behind an opaque type: no allocation, and stable identity (=== / WeakMap keys).
2
+ import type { FiberNode, RawFiber, ShadowNode } from './fiber'
3
+ import * as fiber from './fiber'
4
+
5
+ // Bound once: Metro's inline requires would turn each imported name used in a function into a require per call
6
+ const {
7
+ committedOf,
8
+ fiberOfInstance,
9
+ firstHostBelow,
10
+ hostAncestor,
11
+ patchRenderedProps: patchFiberProps,
12
+ raw,
13
+ resolveHostFiber,
14
+ shadowNodesOf,
15
+ } = fiber
16
+ const { HostComponent: HOST_COMPONENT, Offscreen: OFFSCREEN, Suspense: SUSPENSE, Activity: ACTIVITY } = fiber.Tag
17
+
18
+ declare const brand: unique symbol
19
+ export type Host = { readonly [brand]: 'Host' }
20
+
21
+ export const fiberOf = (host: Host): RawFiber => host as unknown as RawFiber
22
+
23
+ export const toHost = (fiber: RawFiber | FiberNode | null | undefined): Host | undefined =>
24
+ ((fiber as RawFiber | null | undefined)?.stateNode?.canonical?.internalInstanceHandle ?? undefined) as Host | undefined
25
+
26
+ const resolveRefSlowly = (ref: unknown): RawFiber | undefined =>
27
+ raw(resolveHostFiber(ref)) ?? (toHost(firstHostBelow(fiberOfInstance(ref))) as unknown as RawFiber | undefined)
28
+
29
+ // The fast path is inlined: legacy Hermes doesn't inline calls
30
+ export const getHostFor = (ref: unknown): Host | undefined => {
31
+ const fiber = (ref as { __internalInstanceHandle?: RawFiber } | null | undefined)?.__internalInstanceHandle
32
+
33
+ if (fiber !== undefined) {
34
+ return fiber as unknown as Host
35
+ }
36
+
37
+ return resolveRefSlowly(ref) as unknown as Host | undefined
38
+ }
39
+
40
+ export const getShadowNodeFor = (ref: unknown): ShadowNode | undefined => {
41
+ const fiber = (ref as { __internalInstanceHandle?: RawFiber } | null | undefined)?.__internalInstanceHandle
42
+
43
+ if (fiber !== undefined) {
44
+ return fiber.stateNode?.node
45
+ }
46
+
47
+ return resolveRefSlowly(ref)?.stateNode?.node
48
+ }
49
+
50
+ export const getHostForInstanceHandle = (handle: unknown): Host | undefined => toHost(handle as RawFiber | null | undefined)
51
+
52
+ // Not the first host below the scroll view: on iOS a refreshControl comes first
53
+ export const getContentContainerFor = (ref: any): Host | undefined => {
54
+ const scroll = ref?.getInnerViewRef ? ref : (ref?.getNativeScrollRef?.() ?? ref?.getScrollResponder?.())
55
+
56
+ return getHostFor(scroll?.getInnerViewRef?.())
57
+ }
58
+
59
+ export const getShadowNode = (host: Host): ShadowNode | undefined => fiberOf(host).stateNode?.node
60
+
61
+ // Two nodes only while a render is in flight; after a commit both halves share one
62
+ export const getShadowNodes = (host: Host, out: Array<ShadowNode> = []): Array<ShadowNode> => {
63
+ shadowNodesOf(host as unknown as FiberNode, out)
64
+
65
+ return out
66
+ }
67
+
68
+ export const getNativeTag = (host: Host): number | undefined => fiberOf(host).stateNode?.canonical?.nativeTag
69
+
70
+ export const getParentHost = (host: Host): Host | undefined => toHost(hostAncestor(host as unknown as FiberNode))
71
+
72
+ export const patchRenderedProps = (host: Host, patch: (props: Record<string, any>) => Record<string, any> | undefined): boolean =>
73
+ patchFiberProps(host as unknown as FiberNode, patch)
74
+
75
+ export const HiddenBy = {
76
+ None: 0,
77
+ Suspense: 1,
78
+ Freeze: 2,
79
+ Activity: 4,
80
+ } as const
81
+
82
+ // `return` can point into either half of a pair; ask which half is committed only when they disagree
83
+ export const committedHalf = (fiber: RawFiber, differs: (a: RawFiber, b: RawFiber) => boolean): RawFiber | null => {
84
+ const alternate = fiber.alternate
85
+
86
+ if (!alternate || !differs(fiber, alternate)) {
87
+ return fiber
88
+ }
89
+
90
+ return raw(committedOf(fiber as unknown as FiberNode)) ?? null
91
+ }
92
+
93
+ const hiddenStateDiffers = (a: RawFiber, b: RawFiber) => (a.memoizedState === null) !== (b.memoizedState === null)
94
+
95
+ // React's own visibility bit on the Offscreen instance: shared by both halves and flipped in the commit before refs
96
+ // detach, so it also holds inside a ref cleanup, where the committed half is still the old tree
97
+ const OFFSCREEN_VISIBLE = 1
98
+ const isOffscreenHidden = (offscreen: RawFiber): boolean => {
99
+ const visibility = offscreen.stateNode?._visibility
100
+
101
+ if (typeof visibility === 'number') {
102
+ return (visibility & OFFSCREEN_VISIBLE) === 0
103
+ }
104
+
105
+ return committedHalf(offscreen, hiddenStateDiffers)?.memoizedState != null
106
+ }
107
+ const freezeDiffers = (a: RawFiber, b: RawFiber) => a.memoizedProps?.freeze !== b.memoizedProps?.freeze
108
+
109
+ // react-freeze: Freeze > Suspense > Suspender. The Suspender keeps stale props because it throws, so read Freeze's.
110
+ const isFrozenBoundary = (suspense: RawFiber) =>
111
+ committedHalf(suspense.return as RawFiber, freezeDiffers)?.memoizedProps?.freeze === true
112
+
113
+ // Every hidden subtree sits under an Offscreen fiber with memoizedState set
114
+ export const getHiddenReasons = (host: Host): number => {
115
+ let reasons = 0
116
+
117
+ for (let current = fiberOf(host).return; current; current = current.return) {
118
+ if (current.tag !== OFFSCREEN || !isOffscreenHidden(current)) {
119
+ continue
120
+ }
121
+
122
+ const boundary = current.return
123
+
124
+ if (boundary?.tag === ACTIVITY) {
125
+ reasons |= HiddenBy.Activity
126
+ } else if (boundary?.tag === SUSPENSE) {
127
+ reasons |= isFrozenBoundary(boundary) ? HiddenBy.Freeze : HiddenBy.Suspense
128
+ }
129
+ }
130
+
131
+ return reasons
132
+ }
133
+
134
+ // Any hidden Offscreen, as in collectVisibleAncestors. Stops at the first: the reason isn't needed
135
+ export const isHidden = (host: Host): boolean => {
136
+ for (let current = fiberOf(host).return; current; current = current.return) {
137
+ if (current.tag === OFFSCREEN && isOffscreenHidden(current)) {
138
+ return true
139
+ }
140
+ }
141
+
142
+ return false
143
+ }
144
+ export const isSuspended = (host: Host) => (getHiddenReasons(host) & HiddenBy.Suspense) !== 0
145
+ export const isFrozen = (host: Host) => (getHiddenReasons(host) & HiddenBy.Freeze) !== 0
146
+ export const isInHiddenActivity = (host: Host) => (getHiddenReasons(host) & HiddenBy.Activity) !== 0
147
+
148
+ const isHiddenOffscreen = (offscreen: RawFiber, boundaries: Map<RawFiber, boolean>): boolean => {
149
+ let hidden = boundaries.get(offscreen)
150
+
151
+ if (hidden === undefined) {
152
+ hidden = isOffscreenHidden(offscreen)
153
+ boundaries.set(offscreen, hidden)
154
+
155
+ if (offscreen.alternate) {
156
+ boundaries.set(offscreen.alternate, hidden)
157
+ }
158
+ }
159
+
160
+ return hidden
161
+ }
162
+
163
+ // Hot loops below: indexed loops and writes, explicit null checks, no helper calls (legacy Hermes)
164
+ export const collectVisibleAncestors = (hosts: ReadonlyArray<Host | null | undefined>, visit: (host: Host) => void) => {
165
+ const visibleByTag = new Map<number, boolean>()
166
+ const boundaries = new Map<RawFiber, boolean>()
167
+ const pending: Array<RawFiber> = []
168
+
169
+ for (let h = 0; h < hosts.length; h++) {
170
+ let visible = true
171
+ let count = 0
172
+
173
+ for (let current = hosts[h] as unknown as RawFiber | null | undefined; current != null; current = current.return) {
174
+ if (current.tag === HOST_COMPONENT) {
175
+ const stateNode = current.stateNode
176
+
177
+ if (stateNode == null || stateNode.canonical == null) {
178
+ break
179
+ }
180
+
181
+ const answer = visibleByTag.get(stateNode.canonical.nativeTag)
182
+
183
+ if (answer !== undefined) {
184
+ visible = answer
185
+ break
186
+ }
187
+
188
+ pending[count++] = current
189
+ } else if (current.tag === OFFSCREEN && isHiddenOffscreen(current, boundaries)) {
190
+ visible = false
191
+ break
192
+ }
193
+ }
194
+
195
+ for (let i = 0; i < count; i++) {
196
+ const canonical = pending[i]!.stateNode.canonical
197
+
198
+ visibleByTag.set(canonical.nativeTag, visible)
199
+
200
+ if (visible && canonical.internalInstanceHandle != null) {
201
+ visit(canonical.internalInstanceHandle as Host)
202
+ }
203
+ }
204
+ }
205
+ }
206
+
207
+ // Hidden hosts included
208
+ export const collectAncestors = (hosts: ReadonlyArray<Host | null | undefined>, visit: (host: Host) => void) => {
209
+ const visitedByTag = new Set<number>()
210
+
211
+ for (let h = 0; h < hosts.length; h++) {
212
+ for (let current = hosts[h] as unknown as RawFiber | null | undefined; current != null; current = current.return) {
213
+ if (current.tag !== HOST_COMPONENT) {
214
+ continue
215
+ }
216
+
217
+ const stateNode = current.stateNode
218
+
219
+ if (stateNode == null || stateNode.canonical == null) {
220
+ break
221
+ }
222
+
223
+ const canonical = stateNode.canonical
224
+
225
+ if (visitedByTag.has(canonical.nativeTag)) {
226
+ break
227
+ }
228
+
229
+ visitedByTag.add(canonical.nativeTag)
230
+
231
+ if (canonical.internalInstanceHandle != null) {
232
+ visit(canonical.internalInstanceHandle as Host)
233
+ }
234
+ }
235
+ }
236
+ }
@@ -0,0 +1,43 @@
1
+ import { createOwnerRegistry } from './adapters/registry'
2
+ import { animatedComponentOf, reanimatedCSSAdapter } from './adapters/reanimated'
3
+ import { getCreationStack, getOwners, verify } from './diagnostics'
4
+ import * as HostApi from './host'
5
+
6
+ export type { Host } from './host'
7
+ export type { Drift } from './diagnostics'
8
+ export type { ShadowNode } from './fiber'
9
+ export type { OwnerAdapter, OwnerRegistry, StyleSource } from './adapters/registry'
10
+
11
+ // Object literals, not classes: static methods on a Babel-transpiled class are slower on Hermes
12
+ export const Fiber = {
13
+ getHostFor: HostApi.getHostFor,
14
+ getShadowNodeFor: HostApi.getShadowNodeFor,
15
+ getHostForInstanceHandle: HostApi.getHostForInstanceHandle,
16
+ getContentContainerFor: HostApi.getContentContainerFor,
17
+
18
+ getShadowNode: HostApi.getShadowNode,
19
+ getShadowNodes: HostApi.getShadowNodes,
20
+ getNativeTag: HostApi.getNativeTag,
21
+ getParentHost: HostApi.getParentHost,
22
+
23
+ isHidden: HostApi.isHidden,
24
+ isSuspended: HostApi.isSuspended,
25
+ isFrozen: HostApi.isFrozen,
26
+ isInHiddenActivity: HostApi.isInHiddenActivity,
27
+
28
+ collectVisibleAncestors: HostApi.collectVisibleAncestors,
29
+ collectAncestors: HostApi.collectAncestors,
30
+
31
+ patchRenderedProps: HostApi.patchRenderedProps,
32
+
33
+ verify,
34
+ getOwners,
35
+ getCreationStack,
36
+
37
+ createOwnerRegistry,
38
+ }
39
+
40
+ export const Reanimated = {
41
+ animatedComponentOf,
42
+ cssAdapter: reanimatedCSSAdapter,
43
+ }
package/src/utils.ts CHANGED
@@ -1,5 +1,10 @@
1
1
  export const isDefined = <T>(value: T): value is NonNullable<T> => value !== undefined && value !== null
2
2
 
3
+ // Reanimated useAnimatedStyle handle, it's a plain object, not an Animated.Node
4
+ // styleUpdaterContainer was added in Reanimated 4.1, so check only the keys every version has
5
+ export const isAnimatedStyleHandle = (value: unknown): boolean =>
6
+ typeof value === 'object' && value !== null && 'viewDescriptors' in value && 'initial' in value
7
+
3
8
  export const deepMergeObjects = <T extends Record<PropertyKey, any>>(...sources: Array<T>) => {
4
9
  const target = {} as T
5
10
 
@@ -23,7 +28,53 @@ export const deepMergeObjects = <T extends Record<PropertyKey, any>>(...sources:
23
28
  return target
24
29
  }
25
30
 
31
+ // React tells a class component from a function component by these keys
32
+ const CLASS_PROTOTYPE_KEYS = ['isReactComponent', 'render']
33
+ const CLASS_STATIC_KEYS = ['contextType', 'contextTypes', 'childContextTypes', 'getDerivedStateFromProps']
34
+
35
+ // owner doesn't have the key, objects that inherit from owner read it from source
36
+ const hideFromOwner = (owner: object, source: object, key: string) => {
37
+ Object.defineProperty(owner, key, {
38
+ configurable: true,
39
+ get() {
40
+ return this === owner ? undefined : Reflect.get(source, key, this)
41
+ },
42
+ set(value) {
43
+ Object.defineProperty(this, key, { value, writable: true, enumerable: true, configurable: true })
44
+ },
45
+ })
46
+ }
47
+
48
+ const inheritNativeClass = (Component: any, UnistylesComponent: (props: unknown) => unknown) => {
49
+ function UnistylesClassComponent(this: unknown, ...args: Array<unknown>) {
50
+ if (this instanceof UnistylesClassComponent) {
51
+ return Reflect.construct(Component, args, new.target ?? this.constructor)
52
+ }
53
+
54
+ return UnistylesComponent(args[0])
55
+ }
56
+
57
+ Object.setPrototypeOf(UnistylesClassComponent, Component)
58
+ UnistylesClassComponent.prototype = Object.create(Component.prototype, {
59
+ constructor: { value: UnistylesClassComponent, writable: true, configurable: true },
60
+ })
61
+ // only the keys of the class, eg. React warns about a subclass with a `contextType` key that isn't a context
62
+ CLASS_PROTOTYPE_KEYS.filter((key) => key in Component.prototype).forEach((key) =>
63
+ hideFromOwner(UnistylesClassComponent.prototype, Component.prototype, key),
64
+ )
65
+ CLASS_STATIC_KEYS.filter((key) => key in Component).forEach((key) =>
66
+ hideFromOwner(UnistylesClassComponent, Component, key),
67
+ )
68
+
69
+ return UnistylesClassComponent
70
+ }
71
+
26
72
  export const copyComponentProperties = (Component: any, UnistylesComponent: any) => {
73
+ // static properties (eg. displayName) are inherited from the class
74
+ if (Component?.prototype?.isReactComponent && typeof UnistylesComponent === 'function') {
75
+ return inheritNativeClass(Component, UnistylesComponent)
76
+ }
77
+
27
78
  Object.entries(Component).forEach(([key, value]) => {
28
79
  // Filter out the keys we don't want to copy
29
80
  if (['$$typeof', 'render', 'contextType'].includes(key)) {
@@ -2,11 +2,38 @@ import type { UnistylesValues } from '../../types'
2
2
  import type { UnistylesRuntime } from '../runtime'
3
3
 
4
4
  import { deepMergeObjects } from '../../utils'
5
- import { getBoxShadow, getFilterStyle, getTransformStyle } from './object'
5
+ import {
6
+ getBackgroundLayers,
7
+ getBoxShadow,
8
+ getFilterStyle,
9
+ getFontVariationSettings,
10
+ getTransformStyle,
11
+ } from './object'
6
12
  import { isPseudo } from './pseudo'
7
13
  import { getBoxShadowStyle, getTextShadowStyle } from './shadow'
8
14
  import { getStyle } from './style'
9
- import { isBoxShadow, isFilter, isShadow, isTextShadow, isTransform } from './utils'
15
+ import {
16
+ isBackgroundLayer,
17
+ isBoxShadow,
18
+ isFilter,
19
+ isFontVariationSettings,
20
+ isShadow,
21
+ isTextShadow,
22
+ isTransform,
23
+ } from './utils'
24
+
25
+ // a breakpoint can hold React Native's array or object syntax too
26
+ const getBreakpointStyle = (key: string, value: any) => {
27
+ if (isBackgroundLayer(key, value)) {
28
+ return getBackgroundLayers(key, value)
29
+ }
30
+
31
+ if (isFontVariationSettings(key, value)) {
32
+ return getFontVariationSettings(value)
33
+ }
34
+
35
+ return getStyle(key, value)
36
+ }
10
37
 
11
38
  export const convertUnistyles = (value: UnistylesValues, runtime: UnistylesRuntime) => {
12
39
  // Flag to mark if textShadow is already created
@@ -65,10 +92,19 @@ export const convertUnistyles = (value: UnistylesValues, runtime: UnistylesRunti
65
92
  return getTransformStyle(unistylesValue)
66
93
  }
67
94
 
95
+ // React Native's array and object syntaxes, not breakpoints
96
+ if (isBackgroundLayer(unistylesKey, unistylesValue)) {
97
+ return getBackgroundLayers(unistylesKey, unistylesValue)
98
+ }
99
+
100
+ if (isFontVariationSettings(unistylesKey, unistylesValue)) {
101
+ return getFontVariationSettings(unistylesValue)
102
+ }
103
+
68
104
  // Breakpoints
69
105
  if (typeof unistylesValue === 'object' && unistylesValue !== null) {
70
106
  return Object.entries(unistylesValue).map(([breakpointKey, breakpointValue]) => {
71
- return { [breakpointKey]: getStyle(unistylesKey, breakpointValue) }
107
+ return { [breakpointKey]: getBreakpointStyle(unistylesKey, breakpointValue) }
72
108
  })
73
109
  }
74
110
 
@@ -0,0 +1,33 @@
1
+ import { normalizeNumericValue } from '../utils'
2
+
3
+ type BackgroundLayerKey = 'backgroundSize' | 'backgroundPosition' | 'backgroundRepeat'
4
+ type BackgroundSize = string | { x: string | number; y: string | number }
5
+ type BackgroundPosition = Partial<Record<'top' | 'left' | 'right' | 'bottom', string | number>>
6
+ type BackgroundRepeat = { x: string; y: string }
7
+
8
+ const createBackgroundSizeValue = (size: BackgroundSize) => {
9
+ if (typeof size === 'string') {
10
+ return size
11
+ }
12
+
13
+ return `${normalizeNumericValue(size.x)} ${normalizeNumericValue(size.y)}`
14
+ }
15
+
16
+ const createBackgroundPositionValue = (position: BackgroundPosition) => {
17
+ const edges = (['left', 'right', 'top', 'bottom'] as const).filter((edge) => position[edge] !== undefined)
18
+
19
+ return edges.map((edge) => `${edge} ${normalizeNumericValue(position[edge]!)}`).join(' ')
20
+ }
21
+
22
+ const createBackgroundRepeatValue = (repeat: BackgroundRepeat) => `${repeat.x} ${repeat.y}`
23
+
24
+ const createBackgroundLayerValue = {
25
+ backgroundSize: createBackgroundSizeValue,
26
+ backgroundPosition: createBackgroundPositionValue,
27
+ backgroundRepeat: createBackgroundRepeatValue,
28
+ } as Record<BackgroundLayerKey, (layer: any) => string>
29
+
30
+ // React Native's processed syntax, one object per background layer
31
+ export const getBackgroundLayers = (key: string, layers: Array<unknown>) => ({
32
+ [key]: layers.map(createBackgroundLayerValue[key as BackgroundLayerKey]).join(', '),
33
+ })
@@ -0,0 +1,7 @@
1
+ // Same output as React Native's processFontVariationSettings, eg. { wght: 700 } -> 'wght' 700
2
+ export const getFontVariationSettings = (fontVariationSettings: Record<string, number>) => ({
3
+ fontVariationSettings: Object.keys(fontVariationSettings)
4
+ .sort()
5
+ .map((axis) => `${axis.includes("'") ? `"${axis}"` : `'${axis}'`} ${fontVariationSettings[axis]}`)
6
+ .join(', '),
7
+ })
@@ -1,3 +1,5 @@
1
1
  export * from './transform'
2
2
  export * from './boxShadow'
3
3
  export * from './filter'
4
+ export * from './backgroundLayers'
5
+ export * from './fontVariationSettings'
@@ -21,6 +21,17 @@ export const isFilter = (key: string, value: any): value is Array<Filters> => ke
21
21
  export const isBoxShadow = (key: string, value: any): value is Array<BoxShadowValue> =>
22
22
  key === 'boxShadow' && Array.isArray(value)
23
23
 
24
+ export const isBackgroundLayer = (key: string, value: any): value is Array<unknown> =>
25
+ ['backgroundSize', 'backgroundPosition', 'backgroundRepeat'].includes(key) && Array.isArray(value)
26
+
27
+ // { wght: 700 } is the object syntax, a breakpoints object holds strings or objects
28
+ export const isFontVariationSettings = (key: string, value: any): value is Record<string, number> =>
29
+ key === 'fontVariationSettings' &&
30
+ typeof value === 'object' &&
31
+ value !== null &&
32
+ !Array.isArray(value) &&
33
+ Object.values(value).every((axisValue) => typeof axisValue === 'number')
34
+
24
35
  export const normalizeNumericValue = (value: number | string) =>
25
36
  value && typeof value === 'number' ? `${value}px` : value
26
37
 
@@ -32,7 +32,7 @@ export class UnistylesRegistry {
32
32
  )
33
33
  }
34
34
 
35
- return stylesheet(scopedTheme, this.services.runtime.miniRuntime)
35
+ return stylesheet(scopedTheme, this.services.runtime.getMiniRuntime(scopedThemeName))
36
36
  }
37
37
 
38
38
  const computedStylesheet = this.stylesheets.get(stylesheet)
@@ -41,11 +41,9 @@ export class UnistylesRegistry {
41
41
  return computedStylesheet
42
42
  }
43
43
 
44
- const currentTheme = this.services.runtime.getTheme(
45
- this.services.runtime.themeName,
46
- this.services.state.CSSVars,
47
- )
48
- const createdStylesheet = stylesheet(currentTheme, this.services.runtime.miniRuntime)
44
+ const themeName = this.services.runtime.themeName
45
+ const currentTheme = this.services.runtime.getTheme(themeName, this.services.state.CSSVars)
46
+ const createdStylesheet = stylesheet(currentTheme, this.services.runtime.getMiniRuntime(themeName))
49
47
  const dependencies = Object.values(createdStylesheet).flatMap((value) => extractUnistyleDependencies(value))
50
48
 
51
49
  this.addDependenciesToStylesheet(stylesheet, dependencies)
@@ -65,9 +63,10 @@ export class UnistylesRegistry {
65
63
  dependencies.forEach((dependency) => dependenciesMap.add(dependency))
66
64
 
67
65
  const dispose = this.services.listener.addStylesheetListeners(Array.from(dependenciesMap), () => {
66
+ const themeName = this.services.runtime.themeName
68
67
  const newComputedStylesheet = stylesheet(
69
- this.services.runtime.getTheme(this.services.runtime.themeName, this.services.state.CSSVars),
70
- this.services.runtime.miniRuntime,
68
+ this.services.runtime.getTheme(themeName, this.services.state.CSSVars),
69
+ this.services.runtime.getMiniRuntime(themeName),
71
70
  )
72
71
 
73
72
  this.stylesheets.set(stylesheet, newComputedStylesheet)
@@ -49,13 +49,8 @@ export class UnistylesRuntime {
49
49
  }
50
50
  }
51
51
 
52
+ // App theme, like on native. ScopedTheme is read from React Context (useUnistyles) (#1295)
52
53
  get themeName() {
53
- const scopedTheme = this.services.shadowRegistry.getScopedTheme()
54
-
55
- if (scopedTheme) {
56
- return scopedTheme
57
- }
58
-
59
54
  if (this.services.state.hasAdaptiveThemes) {
60
55
  return schemeToTheme(this.colorScheme) as AppThemeName
61
56
  }
@@ -150,9 +145,14 @@ export class UnistylesRuntime {
150
145
  }
151
146
 
152
147
  get miniRuntime(): UnistylesMiniRuntime {
148
+ return this.getMiniRuntime(this.themeName)
149
+ }
150
+
151
+ // StyleSheets get the name of the theme they are called with
152
+ getMiniRuntime = (themeName?: AppThemeName): UnistylesMiniRuntime => {
153
153
  return {
154
154
  colorScheme: this.colorScheme,
155
- themeName: this.themeName,
155
+ themeName,
156
156
  contentSizeCategory: this.contentSizeCategory,
157
157
  breakpoint: this.breakpoint,
158
158
  isLandscape: this.orientation === Orientation.Landscape,
@@ -6,7 +6,7 @@ import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../
6
6
  import type { UnistylesRuntime } from '../runtime'
7
7
 
8
8
  import { ColorScheme, Orientation } from '../../specs/types'
9
- import { isDefined, isUnistylesMq, parseMq } from '../../utils'
9
+ import { isAnimatedStyleHandle, isDefined, isUnistylesMq, parseMq } from '../../utils'
10
10
  import * as unistyles from '../services'
11
11
  import { UNI_GENERATED_KEYS, type UniGeneratedKey, type UniGeneratedStyle } from '../types'
12
12
  import { hyphenate, keyInObject, reduceObject } from './common'
@@ -98,9 +98,13 @@ export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
98
98
  .map((b) => unistyles.services.runtime.breakpoints[b] as number)
99
99
  .sort((a, b) => a - b)
100
100
  .find((b) => b > breakpointValue)
101
+ // Viewport widths are fractional CSS px under browser zoom / OS scaling, so an integer
102
+ // `max-width: next - 1` leaves a dead band (e.g. 767 < width < 768) that matches neither
103
+ // this breakpoint nor the next one. 0.02px below the next breakpoint (the Bootstrap
104
+ // convention) closes it without overlapping `(min-width: next)`.
101
105
  const queries = [
102
106
  `(min-width: ${breakpointValue}px)`,
103
- nextBreakpoint ? `(max-width: ${nextBreakpoint - 1}px)` : undefined,
107
+ nextBreakpoint ? `(max-width: ${nextBreakpoint - 0.02}px)` : undefined,
104
108
  ]
105
109
  .filter(Boolean)
106
110
  .join(' and ')
@@ -138,12 +142,15 @@ export const checkForAnimated = (value: any): boolean => {
138
142
  }
139
143
 
140
144
  if (typeof value === 'object' && value !== null) {
145
+ if (isAnimatedStyleHandle(value)) {
146
+ return true
147
+ }
148
+
141
149
  const objectValues = Object.values(value)
142
150
  const secrets = extractSecrets(value)
143
151
 
144
- // @ts-expect-error React Native Web exports Animated.AnimatedNode as Animated.Node
145
152
  // prettier-ignore
146
- return value instanceof Animated.Node || objectValues.length > 0 && objectValues.some(checkForAnimated) || secrets && Object.keys(secrets).length === 0
153
+ return value instanceof Animated.Node || objectValues.length > 0 && objectValues.some(checkForAnimated) || !!secrets && Object.keys(secrets).length === 0
147
154
  }
148
155
 
149
156
  return false
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=module.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/convert/module.d.ts"],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- "use strict";
2
- //# sourceMappingURL=module.d.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["web/convert/module.d.ts"],"mappings":"","ignoreList":[]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=mocks.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mocks.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/mocks.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=passForwardRef.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"passForwardRef.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/passForwardRef.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=scoped-theme.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"scoped-theme.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/scoped-theme.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=shadow-registry.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"shadow-registry.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/shadow-registry.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=web-child-selector.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-child-selector.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-child-selector.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=web-listener.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-listener.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-listener.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=web-pointer-events.spec.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"web-pointer-events.spec.d.ts","sourceRoot":"","sources":["../../../../src/__tests__/web-pointer-events.spec.ts"],"names":[],"mappings":""}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=web-runtime.spec.d.ts.map