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,523 @@
1
+ #include "BackgroundLayerConverter.h"
2
+
3
+ #include <algorithm>
4
+ #include <cctype>
5
+ #include <cmath>
6
+ #include <cstdlib>
7
+ #include <limits>
8
+ #include <optional>
9
+ #include <vector>
10
+
11
+ // React Native processes background size, position and repeat strings in JS
12
+ // (processBackgroundSize.js, processBackgroundPosition.js and
13
+ // processBackgroundRepeat.js). Its native props parser only reads the processed
14
+ // arrays, even with enableNativeCSSParsing, so shadow tree updates convert the
15
+ // strings here with the same output.
16
+ namespace margelo::nitro::unistyles::converters {
17
+
18
+ namespace {
19
+
20
+ bool isWhitespace(char character) {
21
+ return std::isspace(static_cast<unsigned char>(character)) != 0;
22
+ }
23
+
24
+ bool isDigit(const std::string &value, size_t index) {
25
+ return index < value.size() &&
26
+ std::isdigit(static_cast<unsigned char>(value[index])) != 0;
27
+ }
28
+
29
+ std::string toLower(std::string value) {
30
+ std::transform(value.begin(), value.end(), value.begin(),
31
+ [](unsigned char c) { return std::tolower(c); });
32
+
33
+ return value;
34
+ }
35
+
36
+ bool endsWith(const std::string &value, const std::string &suffix) {
37
+ return value.size() >= suffix.size() &&
38
+ value.compare(value.size() - suffix.size(), suffix.size(), suffix) ==
39
+ 0;
40
+ }
41
+
42
+ std::string trim(const std::string &value) {
43
+ auto start = std::find_if_not(value.begin(), value.end(), isWhitespace);
44
+ auto end = std::find_if_not(value.rbegin(), value.rend(), isWhitespace).base();
45
+
46
+ return start < end ? std::string(start, end) : std::string();
47
+ }
48
+
49
+ // value.split(',').map(s => s.trim())
50
+ std::vector<std::string> splitLayers(const std::string &value) {
51
+ std::vector<std::string> layers;
52
+ size_t start = 0;
53
+
54
+ while (true) {
55
+ auto end = value.find(',', start);
56
+
57
+ layers.push_back(trim(value.substr(start, end - start)));
58
+
59
+ if (end == std::string::npos) {
60
+ return layers;
61
+ }
62
+
63
+ start = end + 1;
64
+ }
65
+ }
66
+
67
+ // value.split(/\s+/).filter(p => p.length > 0)
68
+ std::vector<std::string> splitParts(const std::string &value) {
69
+ std::vector<std::string> parts;
70
+ std::string part;
71
+
72
+ for (auto character : value) {
73
+ if (!isWhitespace(character)) {
74
+ part.push_back(character);
75
+
76
+ continue;
77
+ }
78
+
79
+ if (!part.empty()) {
80
+ parts.push_back(part);
81
+ part.clear();
82
+ }
83
+ }
84
+
85
+ if (!part.empty()) {
86
+ parts.push_back(part);
87
+ }
88
+
89
+ return parts;
90
+ }
91
+
92
+ // JS parseFloat: the longest decimal prefix after leading whitespace, NaN
93
+ // without one
94
+ double parseFloat(const std::string &value) {
95
+ size_t index = 0;
96
+
97
+ while (index < value.size() && isWhitespace(value[index])) {
98
+ index++;
99
+ }
100
+
101
+ auto start = index;
102
+
103
+ if (index < value.size() && (value[index] == '+' || value[index] == '-')) {
104
+ index++;
105
+ }
106
+
107
+ if (value.compare(index, 8, "Infinity") == 0) {
108
+ return value[start] == '-' ? -std::numeric_limits<double>::infinity()
109
+ : std::numeric_limits<double>::infinity();
110
+ }
111
+
112
+ size_t digits = 0;
113
+
114
+ while (isDigit(value, index)) {
115
+ index++;
116
+ digits++;
117
+ }
118
+
119
+ if (index < value.size() && value[index] == '.') {
120
+ index++;
121
+
122
+ while (isDigit(value, index)) {
123
+ index++;
124
+ digits++;
125
+ }
126
+ }
127
+
128
+ if (digits == 0) {
129
+ return std::numeric_limits<double>::quiet_NaN();
130
+ }
131
+
132
+ if (index < value.size() && (value[index] == 'e' || value[index] == 'E')) {
133
+ auto exponentIndex = index + 1;
134
+
135
+ if (exponentIndex < value.size() &&
136
+ (value[exponentIndex] == '+' || value[exponentIndex] == '-')) {
137
+ exponentIndex++;
138
+ }
139
+
140
+ auto exponentStart = exponentIndex;
141
+
142
+ while (isDigit(value, exponentIndex)) {
143
+ exponentIndex++;
144
+ }
145
+
146
+ if (exponentIndex > exponentStart) {
147
+ index = exponentIndex;
148
+ }
149
+ }
150
+
151
+ return std::strtod(value.substr(start, index - start).c_str(), nullptr);
152
+ }
153
+
154
+ // [ <length-percentage [0,∞]> | auto ]
155
+ std::optional<folly::dynamic> toBackgroundSizeValue(const std::string &size) {
156
+ if (endsWith(size, "px")) {
157
+ auto number = parseFloat(size);
158
+
159
+ if (!std::isnan(number) && number >= 0) {
160
+ return folly::dynamic(number);
161
+ }
162
+ }
163
+
164
+ if (endsWith(size, "%") && parseFloat(size) >= 0) {
165
+ return folly::dynamic(size);
166
+ }
167
+
168
+ if (size == "auto") {
169
+ return folly::dynamic(size);
170
+ }
171
+
172
+ return std::nullopt;
173
+ }
174
+
175
+ // https://www.w3.org/TR/css-backgrounds-3/#typedef-bg-size
176
+ folly::dynamic parseBackgroundSize(const std::string &value) {
177
+ folly::dynamic result = folly::dynamic::array();
178
+
179
+ for (const auto &size : splitLayers(value)) {
180
+ if (size.empty()) {
181
+ return folly::dynamic::array();
182
+ }
183
+
184
+ auto parts = splitParts(size);
185
+
186
+ if (parts.size() == 2) {
187
+ auto x = toBackgroundSizeValue(toLower(parts[0]));
188
+ auto y = toBackgroundSizeValue(toLower(parts[1]));
189
+
190
+ if (!x.has_value() || !y.has_value()) {
191
+ return folly::dynamic::array();
192
+ }
193
+
194
+ result.push_back(folly::dynamic::object("x", x.value())("y", y.value()));
195
+ } else if (parts.size() == 1) {
196
+ auto x = toBackgroundSizeValue(toLower(parts[0]));
197
+
198
+ if (!x.has_value()) {
199
+ return folly::dynamic::array();
200
+ }
201
+
202
+ result.push_back(folly::dynamic::object("x", x.value())("y", "auto"));
203
+ }
204
+ }
205
+
206
+ return result;
207
+ }
208
+
209
+ bool isValidPosition(const std::string &position) {
210
+ return endsWith(position, "px") || endsWith(position, "%") ||
211
+ position == "0";
212
+ }
213
+
214
+ std::optional<folly::dynamic>
215
+ getPositionFromCSSValue(const std::string &position) {
216
+ if (endsWith(position, "px")) {
217
+ return folly::dynamic(parseFloat(position));
218
+ }
219
+
220
+ if (endsWith(position, "%")) {
221
+ return folly::dynamic(position);
222
+ }
223
+
224
+ // CSS length allows 0 as a valid value
225
+ if (position == "0") {
226
+ return folly::dynamic(0);
227
+ }
228
+
229
+ return std::nullopt;
230
+ }
231
+
232
+ // https://www.w3.org/TR/css-backgrounds-3/#typedef-bg-position
233
+ folly::dynamic parseBackgroundPosition(const std::string &value) {
234
+ folly::dynamic result = folly::dynamic::array();
235
+
236
+ for (const auto &position : splitLayers(value)) {
237
+ std::optional<folly::dynamic> top;
238
+ std::optional<folly::dynamic> left;
239
+ std::optional<folly::dynamic> right;
240
+ std::optional<folly::dynamic> bottom;
241
+ auto parts = splitParts(position);
242
+
243
+ // 1. Single value syntax [ left | center | right | top | bottom |
244
+ // <length-percentage> ]
245
+ if (parts.size() == 1) {
246
+ auto token1 = toLower(parts[0]);
247
+
248
+ if (token1 == "left") {
249
+ left = "0%";
250
+ top = "50%";
251
+ } else if (token1 == "center") {
252
+ left = "50%";
253
+ top = "50%";
254
+ } else if (token1 == "right") {
255
+ left = "100%";
256
+ top = "50%";
257
+ } else if (token1 == "top") {
258
+ left = "50%";
259
+ top = "0%";
260
+ } else if (token1 == "bottom") {
261
+ left = "50%";
262
+ top = "100%";
263
+ } else if (isValidPosition(token1)) {
264
+ auto positionValue = getPositionFromCSSValue(token1);
265
+
266
+ if (!positionValue.has_value()) {
267
+ return folly::dynamic::array();
268
+ }
269
+
270
+ left = positionValue;
271
+ top = "50%";
272
+ }
273
+ }
274
+
275
+ // 2. Two value syntax [ left | center | right | <length-percentage> ] [
276
+ // top | center | bottom | <length-percentage> ]
277
+ if (parts.size() == 2) {
278
+ auto token1 = toLower(parts[0]);
279
+
280
+ if (token1 == "left") {
281
+ left = "0%";
282
+ } else if (token1 == "center") {
283
+ left = "50%";
284
+ } else if (token1 == "right") {
285
+ left = "100%";
286
+ } else if (token1 == "top") {
287
+ top = "0%";
288
+ } else if (token1 == "bottom") {
289
+ top = "100%";
290
+ } else if (isValidPosition(token1)) {
291
+ auto positionValue = getPositionFromCSSValue(token1);
292
+
293
+ if (!positionValue.has_value()) {
294
+ return folly::dynamic::array();
295
+ }
296
+
297
+ left = positionValue;
298
+ }
299
+
300
+ auto token2 = toLower(parts[1]);
301
+
302
+ if (token2 == "top") {
303
+ top = "0%";
304
+ } else if (token2 == "center") {
305
+ top = "50%";
306
+ } else if (token2 == "bottom") {
307
+ top = "100%";
308
+ } else if (token2 == "left") {
309
+ left = "0%";
310
+ } else if (token2 == "right") {
311
+ left = "100%";
312
+ } else if (isValidPosition(token2)) {
313
+ auto positionValue = getPositionFromCSSValue(token2);
314
+
315
+ if (!positionValue.has_value()) {
316
+ return folly::dynamic::array();
317
+ }
318
+
319
+ top = positionValue;
320
+ }
321
+ }
322
+
323
+ // 3. Three value syntax [ center | [ left | right ] <length-percentage>? ]
324
+ // && [ center | [ top | bottom ] <length-percentage>? ]
325
+ if (parts.size() == 3) {
326
+ auto token1 = toLower(parts[0]);
327
+ auto token2 = toLower(parts[1]);
328
+ auto token3 = toLower(parts[2]);
329
+
330
+ if (token1 == "center") {
331
+ // e.g. center top 40%
332
+ left = "50%";
333
+ auto positionValue = getPositionFromCSSValue(token3);
334
+
335
+ if (!positionValue.has_value()) {
336
+ return folly::dynamic::array();
337
+ }
338
+
339
+ if (token2 == "top") {
340
+ top = positionValue;
341
+ } else if (token2 == "bottom") {
342
+ bottom = positionValue;
343
+ } else {
344
+ return folly::dynamic::array();
345
+ }
346
+ } else if (token3 == "center") {
347
+ // e.g. left 40% center
348
+ top = "50%";
349
+ auto positionValue = getPositionFromCSSValue(token2);
350
+
351
+ if (!positionValue.has_value()) {
352
+ return folly::dynamic::array();
353
+ }
354
+
355
+ if (token1 == "left") {
356
+ left = positionValue;
357
+ } else if (token1 == "right") {
358
+ right = positionValue;
359
+ } else {
360
+ return folly::dynamic::array();
361
+ }
362
+ } else {
363
+ // e.g. left 40% top, left top 10%
364
+ std::vector<std::string> tokens = {token1, token2, token3};
365
+
366
+ for (size_t i = 0; i < tokens.size(); i++) {
367
+ const auto &token = tokens[i];
368
+
369
+ if (isValidPosition(token)) {
370
+ auto positionValue = getPositionFromCSSValue(token);
371
+
372
+ if (!positionValue.has_value()) {
373
+ return folly::dynamic::array();
374
+ }
375
+
376
+ if (i == 0) {
377
+ continue;
378
+ }
379
+
380
+ const auto &previousToken = tokens[i - 1];
381
+
382
+ if (previousToken == "left") {
383
+ left = positionValue;
384
+ } else if (previousToken == "right") {
385
+ right = positionValue;
386
+ } else if (previousToken == "top") {
387
+ top = positionValue;
388
+ } else if (previousToken == "bottom") {
389
+ bottom = positionValue;
390
+ }
391
+ } else if (token == "left") {
392
+ left = "0%";
393
+ } else if (token == "right") {
394
+ right = "0%";
395
+ } else if (token == "top") {
396
+ top = "0%";
397
+ } else if (token == "bottom") {
398
+ bottom = "0%";
399
+ } else {
400
+ return folly::dynamic::array();
401
+ }
402
+ }
403
+ }
404
+ }
405
+
406
+ // 4. Four value syntax [ center | [ left | right ] <length-percentage>? ]
407
+ // && [ center | [ top | bottom ] <length-percentage>? ]
408
+ if (parts.size() == 4) {
409
+ auto keyword1 = toLower(parts[0]);
410
+ auto value1 = getPositionFromCSSValue(toLower(parts[1]));
411
+ auto keyword2 = toLower(parts[2]);
412
+ auto value2 = getPositionFromCSSValue(toLower(parts[3]));
413
+
414
+ if (!value1.has_value() || !value2.has_value()) {
415
+ return folly::dynamic::array();
416
+ }
417
+
418
+ if (keyword1 == "left") {
419
+ left = value1;
420
+ } else if (keyword1 == "right") {
421
+ right = value1;
422
+ }
423
+
424
+ if (keyword2 == "top") {
425
+ top = value2;
426
+ } else if (keyword2 == "bottom") {
427
+ bottom = value2;
428
+ }
429
+ }
430
+
431
+ if (top.has_value() && left.has_value()) {
432
+ result.push_back(
433
+ folly::dynamic::object("top", top.value())("left", left.value()));
434
+ } else if (bottom.has_value() && right.has_value()) {
435
+ result.push_back(folly::dynamic::object("bottom", bottom.value())(
436
+ "right", right.value()));
437
+ } else if (top.has_value() && right.has_value()) {
438
+ result.push_back(
439
+ folly::dynamic::object("top", top.value())("right", right.value()));
440
+ } else if (bottom.has_value() && left.has_value()) {
441
+ result.push_back(folly::dynamic::object("bottom", bottom.value())(
442
+ "left", left.value()));
443
+ } else {
444
+ return folly::dynamic::array();
445
+ }
446
+ }
447
+
448
+ return result;
449
+ }
450
+
451
+ bool isBackgroundRepeatKeyword(const std::string &value) {
452
+ return value == "repeat" || value == "space" || value == "round" ||
453
+ value == "no-repeat";
454
+ }
455
+
456
+ // https://www.w3.org/TR/css-backgrounds-3/#typedef-repeat-style
457
+ folly::dynamic parseBackgroundRepeat(const std::string &value) {
458
+ folly::dynamic result = folly::dynamic::array();
459
+
460
+ for (const auto &repeat : splitLayers(value)) {
461
+ if (repeat.empty()) {
462
+ return folly::dynamic::array();
463
+ }
464
+
465
+ auto parts = splitParts(repeat);
466
+
467
+ if (parts.size() == 1) {
468
+ auto token1 = toLower(parts[0]);
469
+
470
+ if (token1 == "repeat-x") {
471
+ result.push_back(folly::dynamic::object("x", "repeat")("y", "no-repeat"));
472
+ } else if (token1 == "repeat-y") {
473
+ result.push_back(folly::dynamic::object("x", "no-repeat")("y", "repeat"));
474
+ } else if (isBackgroundRepeatKeyword(token1)) {
475
+ result.push_back(folly::dynamic::object("x", token1)("y", token1));
476
+ } else {
477
+ return folly::dynamic::array();
478
+ }
479
+ } else if (parts.size() == 2) {
480
+ auto token1 = toLower(parts[0]);
481
+ auto token2 = toLower(parts[1]);
482
+
483
+ if (!isBackgroundRepeatKeyword(token1) ||
484
+ !isBackgroundRepeatKeyword(token2)) {
485
+ return folly::dynamic::array();
486
+ }
487
+
488
+ result.push_back(folly::dynamic::object("x", token1)("y", token2));
489
+ }
490
+ }
491
+
492
+ return result;
493
+ }
494
+
495
+ } // namespace
496
+
497
+ bool isBackgroundLayerPropName(const std::string &propertyName) {
498
+ return propertyName == "backgroundSize" ||
499
+ propertyName == "experimental_backgroundSize" ||
500
+ propertyName == "backgroundPosition" ||
501
+ propertyName == "experimental_backgroundPosition" ||
502
+ propertyName == "backgroundRepeat" ||
503
+ propertyName == "experimental_backgroundRepeat";
504
+ }
505
+
506
+ folly::dynamic parseBackgroundLayerString(const std::string &propertyName,
507
+ const std::string &value) {
508
+ std::string singleLineValue = value;
509
+
510
+ std::replace(singleLineValue.begin(), singleLineValue.end(), '\n', ' ');
511
+
512
+ if (endsWith(propertyName, "ackgroundSize")) {
513
+ return parseBackgroundSize(singleLineValue);
514
+ }
515
+
516
+ if (endsWith(propertyName, "ackgroundPosition")) {
517
+ return parseBackgroundPosition(singleLineValue);
518
+ }
519
+
520
+ return parseBackgroundRepeat(singleLineValue);
521
+ }
522
+
523
+ } // namespace margelo::nitro::unistyles::converters
@@ -0,0 +1,14 @@
1
+ #pragma once
2
+
3
+ #include <folly/dynamic.h>
4
+ #include <string>
5
+
6
+ namespace margelo::nitro::unistyles::converters {
7
+
8
+ // backgroundSize, backgroundPosition and backgroundRepeat (and their
9
+ // experimental_ aliases)
10
+ bool isBackgroundLayerPropName(const std::string &propertyName);
11
+ folly::dynamic parseBackgroundLayerString(const std::string &propertyName,
12
+ const std::string &value);
13
+
14
+ } // namespace margelo::nitro::unistyles::converters
@@ -0,0 +1,104 @@
1
+ #include "FontVariationSettingsConverter.h"
2
+
3
+ #include <algorithm>
4
+ #include <cmath>
5
+ #include <utility>
6
+ #include <vector>
7
+
8
+ // React Native converts the object form to a string in JS
9
+ // (processFontVariationSettings.js), and its native props only read strings,
10
+ // so shadow tree updates convert it here with the same output.
11
+ namespace margelo::nitro::unistyles::converters {
12
+
13
+ using namespace facebook;
14
+
15
+ namespace {
16
+
17
+ std::optional<std::string> quoteAxis(const std::string &axis) {
18
+ auto isPrintable = [](unsigned char character) {
19
+ return character >= 0x20 && character <= 0x7e;
20
+ };
21
+
22
+ if (axis.size() != 4 || !std::all_of(axis.begin(), axis.end(), isPrintable)) {
23
+ return std::nullopt;
24
+ }
25
+
26
+ if (axis.find('\'') == std::string::npos) {
27
+ return "'" + axis + "'";
28
+ }
29
+
30
+ if (axis.find('"') == std::string::npos) {
31
+ return "\"" + axis + "\"";
32
+ }
33
+
34
+ return std::nullopt;
35
+ }
36
+
37
+ } // namespace
38
+
39
+ bool isFontVariationSettingsPropName(const std::string &propertyName) {
40
+ return propertyName == "fontVariationSettings";
41
+ }
42
+
43
+ bool isFontVariationSettingsObject(jsi::Runtime &rt, jsi::Object &value) {
44
+ if (value.isArray(rt) || value.isFunction(rt)) {
45
+ return false;
46
+ }
47
+
48
+ auto propertyNames = value.getPropertyNames(rt);
49
+ auto length = propertyNames.size(rt);
50
+
51
+ for (size_t i = 0; i < length; i++) {
52
+ auto propertyName = propertyNames.getValueAtIndex(rt, i).asString(rt);
53
+
54
+ if (!value.getProperty(rt, jsi::PropNameID::forString(rt, propertyName))
55
+ .isNumber()) {
56
+ return false;
57
+ }
58
+ }
59
+
60
+ return true;
61
+ }
62
+
63
+ std::optional<std::string> fontVariationSettingsToString(jsi::Runtime &rt,
64
+ jsi::Object &value) {
65
+ std::vector<std::pair<std::string, double>> axes;
66
+ auto propertyNames = value.getPropertyNames(rt);
67
+ auto length = propertyNames.size(rt);
68
+
69
+ for (size_t i = 0; i < length; i++) {
70
+ auto propertyName = propertyNames.getValueAtIndex(rt, i).asString(rt);
71
+ auto axisValue =
72
+ value.getProperty(rt, jsi::PropNameID::forString(rt, propertyName));
73
+
74
+ if (!axisValue.isNumber() || !std::isfinite(axisValue.asNumber())) {
75
+ return std::nullopt;
76
+ }
77
+
78
+ axes.emplace_back(propertyName.utf8(rt), axisValue.asNumber());
79
+ }
80
+
81
+ std::sort(axes.begin(), axes.end());
82
+
83
+ std::string result;
84
+
85
+ for (const auto &[axis, axisValue] : axes) {
86
+ auto quotedAxis = quoteAxis(axis);
87
+
88
+ if (!quotedAxis.has_value()) {
89
+ return std::nullopt;
90
+ }
91
+
92
+ if (!result.empty()) {
93
+ result += ", ";
94
+ }
95
+
96
+ // String(value), so numbers are formatted like in JS
97
+ result += quotedAxis.value() + " " +
98
+ jsi::Value(axisValue).toString(rt).utf8(rt);
99
+ }
100
+
101
+ return result;
102
+ }
103
+
104
+ } // namespace margelo::nitro::unistyles::converters
@@ -0,0 +1,17 @@
1
+ #pragma once
2
+
3
+ #include <jsi/jsi.h>
4
+ #include <optional>
5
+ #include <string>
6
+
7
+ namespace margelo::nitro::unistyles::converters {
8
+
9
+ bool isFontVariationSettingsPropName(const std::string &propertyName);
10
+ // { wght: 700, slnt: -10 }, as opposed to a breakpoints object
11
+ bool isFontVariationSettingsObject(facebook::jsi::Runtime &rt,
12
+ facebook::jsi::Object &value);
13
+ std::optional<std::string>
14
+ fontVariationSettingsToString(facebook::jsi::Runtime &rt,
15
+ facebook::jsi::Object &value);
16
+
17
+ } // namespace margelo::nitro::unistyles::converters
@@ -19,6 +19,12 @@ std::vector<jsi::PropNameID> HostUnistyle::getPropertyNames(jsi::Runtime& rt) {
19
19
 
20
20
  HostUnistyle::~HostUnistyle() {
21
21
  if (this->_ownsStyleSheet) {
22
+ for (const auto& [_, unistyle] : this->_stylesheet->unistyles) {
23
+ if (unistyle->type == UnistyleType::DynamicFunction) {
24
+ std::static_pointer_cast<UnistyleDynamicFunction>(unistyle)->proxiedFunction.reset();
25
+ }
26
+ }
27
+
22
28
  this->_stylesheet->unistyles.clear();
23
29
  }
24
30
  }
@@ -44,7 +44,7 @@ inline static std::vector<std::string> getUnistylesHashKeys(jsi::Runtime& rt, js
44
44
  auto propertyName = propertyNames.getValueAtIndex(rt, i).getString(rt);
45
45
  std::string key = propertyName.utf8(rt);
46
46
 
47
- if (key.compare(0, prefix.length(), prefix) == 0) {
47
+ if (key.compare(0, prefix.length(), prefix) == 0 && object.getProperty(rt, propertyName).isObject()) {
48
48
  matchingKeys.push_back(key);
49
49
  }
50
50
  }
@@ -192,6 +192,21 @@ You likely accessed a style while the runtime was being torn down (eg. during a
192
192
  }
193
193
  }
194
194
 
195
+ if (unistyle->styleKey != helpers::EXOTIC_STYLE_KEY) {
196
+ std::vector<folly::dynamic> arguments = parsedArguments.has_value()
197
+ ? parsedArguments.value()
198
+ : std::vector<folly::dynamic>{};
199
+
200
+ auto unistyleData = std::make_shared<UnistyleData>(unistyle, variants, arguments, std::nullopt);
201
+
202
+ parser.rebuildUnistyleWithVariants(rt, unistyleData);
203
+
204
+ if (unistyleData->parsedStyle.has_value()) {
205
+ return jsi::Value(rt, unistyleData->parsedStyle.value()).asObject(rt);
206
+ }
207
+ }
208
+
209
+ // exotic (unbound) styles have no unistyle data to rebuild into
195
210
  parser.rebuildUnistyle(rt, unistyle, variants, parsedArguments);
196
211
 
197
212
  return jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);