react-native-css 3.0.0-nightly.8dd703d → 3.0.0-nightly.9c84741

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 (368) hide show
  1. package/dist/commonjs/compiler/compiler.js +12 -5
  2. package/dist/commonjs/compiler/compiler.js.map +1 -1
  3. package/dist/commonjs/compiler/declarations.js +89 -82
  4. package/dist/commonjs/compiler/declarations.js.map +1 -1
  5. package/dist/commonjs/compiler/inheritance.test.js +10 -10
  6. package/dist/commonjs/compiler/inheritance.test.js.map +1 -1
  7. package/dist/commonjs/compiler/pseudo-elements.js +49 -0
  8. package/dist/commonjs/compiler/pseudo-elements.js.map +1 -0
  9. package/dist/commonjs/compiler/selector-builder.js +124 -80
  10. package/dist/commonjs/compiler/selector-builder.js.map +1 -1
  11. package/dist/commonjs/compiler/stylesheet.js +18 -6
  12. package/dist/commonjs/compiler/stylesheet.js.map +1 -1
  13. package/dist/commonjs/compiler/supports.js +27 -0
  14. package/dist/commonjs/compiler/supports.js.map +1 -0
  15. package/dist/commonjs/components/ActivityIndicator.js +22 -0
  16. package/dist/commonjs/components/ActivityIndicator.js.map +1 -0
  17. package/dist/commonjs/components/Button.js +22 -0
  18. package/dist/commonjs/components/Button.js.map +1 -0
  19. package/dist/commonjs/components/FlatList.js +19 -0
  20. package/dist/commonjs/components/FlatList.js.map +1 -0
  21. package/dist/commonjs/components/Image.js +17 -0
  22. package/dist/commonjs/components/Image.js.map +1 -0
  23. package/dist/commonjs/components/Switch.js +17 -0
  24. package/dist/commonjs/components/Switch.js.map +1 -0
  25. package/dist/commonjs/components/TextInput.js +17 -0
  26. package/dist/commonjs/components/TextInput.js.map +1 -0
  27. package/dist/commonjs/components/index.js +48 -0
  28. package/dist/commonjs/components/index.js.map +1 -1
  29. package/dist/commonjs/components/react-native-safe-area-context.js +17 -0
  30. package/dist/commonjs/components/react-native-safe-area-context.js.map +1 -0
  31. package/dist/commonjs/components/react-native-safe-area-context.native.js +53 -0
  32. package/dist/commonjs/components/react-native-safe-area-context.native.js.map +1 -0
  33. package/dist/commonjs/jest/index.js +5 -5
  34. package/dist/commonjs/jest/index.js.map +1 -1
  35. package/dist/commonjs/metro/index.js +6 -3
  36. package/dist/commonjs/metro/index.js.map +1 -1
  37. package/dist/commonjs/metro/injection-code.js +5 -10
  38. package/dist/commonjs/metro/injection-code.js.map +1 -1
  39. package/dist/commonjs/metro/metro-transformer.js +18 -8
  40. package/dist/commonjs/metro/metro-transformer.js.map +1 -1
  41. package/dist/commonjs/metro/resolver.js +3 -0
  42. package/dist/commonjs/metro/resolver.js.map +1 -1
  43. package/dist/commonjs/poison.pill.js +10 -10
  44. package/dist/commonjs/runtime/native/api.js +8 -2
  45. package/dist/commonjs/runtime/native/api.js.map +1 -1
  46. package/dist/commonjs/runtime/native/conditions/index.js +4 -2
  47. package/dist/commonjs/runtime/native/conditions/index.js.map +1 -1
  48. package/dist/commonjs/runtime/native/conditions/media-query.js +14 -11
  49. package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -1
  50. package/dist/commonjs/runtime/native/react/rules.js +26 -20
  51. package/dist/commonjs/runtime/native/react/rules.js.map +1 -1
  52. package/dist/commonjs/runtime/native/reactivity.js +11 -0
  53. package/dist/commonjs/runtime/native/reactivity.js.map +1 -1
  54. package/dist/commonjs/runtime/native/styles/calculate-props.js +25 -8
  55. package/dist/commonjs/runtime/native/styles/calculate-props.js.map +1 -1
  56. package/dist/commonjs/runtime/native/styles/functions/calc.js +97 -57
  57. package/dist/commonjs/runtime/native/styles/functions/calc.js.map +1 -1
  58. package/dist/commonjs/runtime/native/styles/functions/index.js +22 -0
  59. package/dist/commonjs/runtime/native/styles/functions/index.js.map +1 -1
  60. package/dist/commonjs/runtime/native/styles/functions/numeric-functions.js +32 -0
  61. package/dist/commonjs/runtime/native/styles/functions/numeric-functions.js.map +1 -0
  62. package/dist/commonjs/runtime/native/styles/functions/string-functions.js +23 -0
  63. package/dist/commonjs/runtime/native/styles/functions/string-functions.js.map +1 -0
  64. package/dist/commonjs/runtime/native/styles/functions/transform-functions.js +91 -53
  65. package/dist/commonjs/runtime/native/styles/functions/transform-functions.js.map +1 -1
  66. package/dist/commonjs/runtime/native/styles/shorthands/animation.js +2 -2
  67. package/dist/commonjs/runtime/native/styles/shorthands/animation.js.map +1 -1
  68. package/dist/commonjs/runtime/native/styles/shorthands/box-shadow.js +14 -4
  69. package/dist/commonjs/runtime/native/styles/shorthands/box-shadow.js.map +1 -1
  70. package/dist/commonjs/runtime/native/styles/shorthands/transform.js +1 -1
  71. package/dist/commonjs/runtime/native/styles/shorthands/transform.js.map +1 -1
  72. package/dist/commonjs/runtime/native/styles/variables.js +3 -3
  73. package/dist/commonjs/runtime/native/styles/variables.js.map +1 -1
  74. package/dist/commonjs/runtime/utils/objects.js +6 -18
  75. package/dist/commonjs/runtime/utils/objects.js.map +1 -1
  76. package/dist/commonjs/runtime/web/api.js.map +1 -1
  77. package/dist/commonjs/style-collection/index.js +110 -0
  78. package/dist/commonjs/style-collection/index.js.map +1 -0
  79. package/dist/commonjs/{runtime/native → style-collection}/root.js +2 -2
  80. package/dist/commonjs/style-collection/root.js.map +1 -0
  81. package/dist/module/compiler/compiler.js +12 -5
  82. package/dist/module/compiler/compiler.js.map +1 -1
  83. package/dist/module/compiler/compiler.types.js +1 -1
  84. package/dist/module/compiler/compiler.types.js.map +1 -1
  85. package/dist/module/compiler/declarations.js +89 -82
  86. package/dist/module/compiler/declarations.js.map +1 -1
  87. package/dist/module/compiler/inheritance.test.js +10 -10
  88. package/dist/module/compiler/inheritance.test.js.map +1 -1
  89. package/dist/module/compiler/pseudo-elements.js +44 -0
  90. package/dist/module/compiler/pseudo-elements.js.map +1 -0
  91. package/dist/module/compiler/selector-builder.js +124 -80
  92. package/dist/module/compiler/selector-builder.js.map +1 -1
  93. package/dist/module/compiler/stylesheet.js +18 -6
  94. package/dist/module/compiler/stylesheet.js.map +1 -1
  95. package/dist/module/compiler/supports.js +23 -0
  96. package/dist/module/compiler/supports.js.map +1 -0
  97. package/dist/module/components/ActivityIndicator.js +17 -0
  98. package/dist/module/components/ActivityIndicator.js.map +1 -0
  99. package/dist/module/components/Button.js +17 -0
  100. package/dist/module/components/Button.js.map +1 -0
  101. package/dist/module/components/FlatList.js +14 -0
  102. package/dist/module/components/FlatList.js.map +1 -0
  103. package/dist/module/components/Image.js +12 -0
  104. package/dist/module/components/Image.js.map +1 -0
  105. package/dist/module/components/Switch.js +12 -0
  106. package/dist/module/components/Switch.js.map +1 -0
  107. package/dist/module/components/TextInput.js +12 -0
  108. package/dist/module/components/TextInput.js.map +1 -0
  109. package/dist/module/components/index.js +6 -0
  110. package/dist/module/components/index.js.map +1 -1
  111. package/dist/module/components/react-native-safe-area-context.js +4 -0
  112. package/dist/module/components/react-native-safe-area-context.js.map +1 -0
  113. package/dist/module/components/react-native-safe-area-context.native.js +36 -0
  114. package/dist/module/components/react-native-safe-area-context.native.js.map +1 -0
  115. package/dist/module/jest/index.js +2 -2
  116. package/dist/module/jest/index.js.map +1 -1
  117. package/dist/module/metro/index.js +6 -3
  118. package/dist/module/metro/index.js.map +1 -1
  119. package/dist/module/metro/injection-code.js +5 -10
  120. package/dist/module/metro/injection-code.js.map +1 -1
  121. package/dist/module/metro/metro-transformer.js +18 -8
  122. package/dist/module/metro/metro-transformer.js.map +1 -1
  123. package/dist/module/metro/resolver.js +3 -0
  124. package/dist/module/metro/resolver.js.map +1 -1
  125. package/dist/module/poison.pill.js +10 -10
  126. package/dist/module/runtime/native/api.js +2 -1
  127. package/dist/module/runtime/native/api.js.map +1 -1
  128. package/dist/module/runtime/native/conditions/index.js +4 -2
  129. package/dist/module/runtime/native/conditions/index.js.map +1 -1
  130. package/dist/module/runtime/native/conditions/media-query.js +15 -12
  131. package/dist/module/runtime/native/conditions/media-query.js.map +1 -1
  132. package/dist/module/runtime/native/react/rules.js +24 -19
  133. package/dist/module/runtime/native/react/rules.js.map +1 -1
  134. package/dist/module/runtime/native/reactivity.js +11 -0
  135. package/dist/module/runtime/native/reactivity.js.map +1 -1
  136. package/dist/module/runtime/native/styles/calculate-props.js +25 -8
  137. package/dist/module/runtime/native/styles/calculate-props.js.map +1 -1
  138. package/dist/module/runtime/native/styles/functions/calc.js +97 -56
  139. package/dist/module/runtime/native/styles/functions/calc.js.map +1 -1
  140. package/dist/module/runtime/native/styles/functions/index.js +2 -0
  141. package/dist/module/runtime/native/styles/functions/index.js.map +1 -1
  142. package/dist/module/runtime/native/styles/functions/numeric-functions.js +25 -0
  143. package/dist/module/runtime/native/styles/functions/numeric-functions.js.map +1 -0
  144. package/dist/module/runtime/native/styles/functions/string-functions.js +18 -0
  145. package/dist/module/runtime/native/styles/functions/string-functions.js.map +1 -0
  146. package/dist/module/runtime/native/styles/functions/transform-functions.js +91 -53
  147. package/dist/module/runtime/native/styles/functions/transform-functions.js.map +1 -1
  148. package/dist/module/runtime/native/styles/shorthands/animation.js +1 -1
  149. package/dist/module/runtime/native/styles/shorthands/animation.js.map +1 -1
  150. package/dist/module/runtime/native/styles/shorthands/box-shadow.js +14 -4
  151. package/dist/module/runtime/native/styles/shorthands/box-shadow.js.map +1 -1
  152. package/dist/module/runtime/native/styles/shorthands/transform.js +1 -1
  153. package/dist/module/runtime/native/styles/shorthands/transform.js.map +1 -1
  154. package/dist/module/runtime/native/styles/variables.js +1 -1
  155. package/dist/module/runtime/native/styles/variables.js.map +1 -1
  156. package/dist/module/runtime/utils/objects.js +6 -18
  157. package/dist/module/runtime/utils/objects.js.map +1 -1
  158. package/dist/module/runtime/web/api.js.map +1 -1
  159. package/dist/module/style-collection/index.js +95 -0
  160. package/dist/module/style-collection/index.js.map +1 -0
  161. package/dist/module/{runtime/native → style-collection}/root.js +2 -2
  162. package/dist/module/style-collection/root.js.map +1 -0
  163. package/dist/typescript/commonjs/src/compiler/compiler.d.ts +1 -1
  164. package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
  165. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +11 -13
  166. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -1
  167. package/dist/typescript/commonjs/src/compiler/declarations.d.ts +4 -2
  168. package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
  169. package/dist/typescript/commonjs/src/compiler/pseudo-elements.d.ts +4 -0
  170. package/dist/typescript/commonjs/src/compiler/pseudo-elements.d.ts.map +1 -0
  171. package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts +1 -0
  172. package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts.map +1 -1
  173. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +2 -2
  174. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
  175. package/dist/typescript/commonjs/src/compiler/supports.d.ts +3 -0
  176. package/dist/typescript/commonjs/src/compiler/supports.d.ts.map +1 -0
  177. package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts +13 -0
  178. package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts.map +1 -0
  179. package/dist/typescript/commonjs/src/components/Button.d.ts +13 -0
  180. package/dist/typescript/commonjs/src/components/Button.d.ts.map +1 -0
  181. package/dist/typescript/commonjs/src/components/FlatList.d.ts +10 -0
  182. package/dist/typescript/commonjs/src/components/FlatList.d.ts.map +1 -0
  183. package/dist/typescript/commonjs/src/components/Image.d.ts +8 -0
  184. package/dist/typescript/commonjs/src/components/Image.d.ts.map +1 -0
  185. package/dist/typescript/commonjs/src/components/Switch.d.ts +8 -0
  186. package/dist/typescript/commonjs/src/components/Switch.d.ts.map +1 -0
  187. package/dist/typescript/commonjs/src/components/TextInput.d.ts +8 -0
  188. package/dist/typescript/commonjs/src/components/TextInput.d.ts.map +1 -0
  189. package/dist/typescript/commonjs/src/components/index.d.ts +6 -0
  190. package/dist/typescript/commonjs/src/components/index.d.ts.map +1 -1
  191. package/dist/typescript/commonjs/src/components/react-native-safe-area-context.d.ts +2 -0
  192. package/dist/typescript/commonjs/src/components/react-native-safe-area-context.d.ts.map +1 -0
  193. package/dist/typescript/commonjs/src/components/react-native-safe-area-context.native.d.ts +4 -0
  194. package/dist/typescript/commonjs/src/components/react-native-safe-area-context.native.d.ts.map +1 -0
  195. package/dist/typescript/commonjs/src/jest/index.d.ts +3 -3
  196. package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  197. package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -1
  198. package/dist/typescript/commonjs/src/metro/injection-code.d.ts +4 -7
  199. package/dist/typescript/commonjs/src/metro/injection-code.d.ts.map +1 -1
  200. package/dist/typescript/commonjs/src/metro/metro-transformer.d.ts +4 -1
  201. package/dist/typescript/commonjs/src/metro/metro-transformer.d.ts.map +1 -1
  202. package/dist/typescript/commonjs/src/metro/resolver.d.ts.map +1 -1
  203. package/dist/typescript/commonjs/src/runtime/native/api.d.ts +3 -1
  204. package/dist/typescript/commonjs/src/runtime/native/api.d.ts.map +1 -1
  205. package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts +2 -2
  206. package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts.map +1 -1
  207. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts.map +1 -1
  208. package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts +1 -1
  209. package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts.map +1 -1
  210. package/dist/typescript/commonjs/src/runtime/native/styles/functions/calc.d.ts.map +1 -1
  211. package/dist/typescript/commonjs/src/runtime/native/styles/functions/index.d.ts +2 -0
  212. package/dist/typescript/commonjs/src/runtime/native/styles/functions/index.d.ts.map +1 -1
  213. package/dist/typescript/commonjs/src/runtime/native/styles/functions/numeric-functions.d.ts +5 -0
  214. package/dist/typescript/commonjs/src/runtime/native/styles/functions/numeric-functions.d.ts.map +1 -0
  215. package/dist/typescript/commonjs/src/runtime/native/styles/functions/string-functions.d.ts +3 -0
  216. package/dist/typescript/commonjs/src/runtime/native/styles/functions/string-functions.d.ts.map +1 -0
  217. package/dist/typescript/commonjs/src/runtime/native/styles/functions/transform-functions.d.ts.map +1 -1
  218. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/animation.d.ts.map +1 -1
  219. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/box-shadow.d.ts.map +1 -1
  220. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/transform.d.ts.map +1 -1
  221. package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts.map +1 -1
  222. package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts.map +1 -1
  223. package/dist/typescript/commonjs/src/runtime/web/api.d.ts +1 -1
  224. package/dist/typescript/commonjs/src/runtime/web/api.d.ts.map +1 -1
  225. package/dist/typescript/commonjs/src/style-collection/index.d.ts +14 -0
  226. package/dist/typescript/commonjs/src/style-collection/index.d.ts.map +1 -0
  227. package/dist/typescript/commonjs/src/{runtime/native → style-collection}/root.d.ts +1 -1
  228. package/dist/typescript/commonjs/src/style-collection/root.d.ts.map +1 -0
  229. package/dist/typescript/module/src/compiler/compiler.d.ts +1 -1
  230. package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
  231. package/dist/typescript/module/src/compiler/compiler.types.d.ts +11 -13
  232. package/dist/typescript/module/src/compiler/compiler.types.d.ts.map +1 -1
  233. package/dist/typescript/module/src/compiler/declarations.d.ts +4 -2
  234. package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
  235. package/dist/typescript/module/src/compiler/pseudo-elements.d.ts +4 -0
  236. package/dist/typescript/module/src/compiler/pseudo-elements.d.ts.map +1 -0
  237. package/dist/typescript/module/src/compiler/selector-builder.d.ts +1 -0
  238. package/dist/typescript/module/src/compiler/selector-builder.d.ts.map +1 -1
  239. package/dist/typescript/module/src/compiler/stylesheet.d.ts +2 -2
  240. package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
  241. package/dist/typescript/module/src/compiler/supports.d.ts +3 -0
  242. package/dist/typescript/module/src/compiler/supports.d.ts.map +1 -0
  243. package/dist/typescript/module/src/components/ActivityIndicator.d.ts +13 -0
  244. package/dist/typescript/module/src/components/ActivityIndicator.d.ts.map +1 -0
  245. package/dist/typescript/module/src/components/Button.d.ts +13 -0
  246. package/dist/typescript/module/src/components/Button.d.ts.map +1 -0
  247. package/dist/typescript/module/src/components/FlatList.d.ts +10 -0
  248. package/dist/typescript/module/src/components/FlatList.d.ts.map +1 -0
  249. package/dist/typescript/module/src/components/Image.d.ts +8 -0
  250. package/dist/typescript/module/src/components/Image.d.ts.map +1 -0
  251. package/dist/typescript/module/src/components/Switch.d.ts +8 -0
  252. package/dist/typescript/module/src/components/Switch.d.ts.map +1 -0
  253. package/dist/typescript/module/src/components/TextInput.d.ts +8 -0
  254. package/dist/typescript/module/src/components/TextInput.d.ts.map +1 -0
  255. package/dist/typescript/module/src/components/index.d.ts +6 -0
  256. package/dist/typescript/module/src/components/index.d.ts.map +1 -1
  257. package/dist/typescript/module/src/components/react-native-safe-area-context.d.ts +2 -0
  258. package/dist/typescript/module/src/components/react-native-safe-area-context.d.ts.map +1 -0
  259. package/dist/typescript/module/src/components/react-native-safe-area-context.native.d.ts +4 -0
  260. package/dist/typescript/module/src/components/react-native-safe-area-context.native.d.ts.map +1 -0
  261. package/dist/typescript/module/src/jest/index.d.ts +3 -3
  262. package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
  263. package/dist/typescript/module/src/metro/index.d.ts.map +1 -1
  264. package/dist/typescript/module/src/metro/injection-code.d.ts +4 -7
  265. package/dist/typescript/module/src/metro/injection-code.d.ts.map +1 -1
  266. package/dist/typescript/module/src/metro/metro-transformer.d.ts +4 -1
  267. package/dist/typescript/module/src/metro/metro-transformer.d.ts.map +1 -1
  268. package/dist/typescript/module/src/metro/resolver.d.ts.map +1 -1
  269. package/dist/typescript/module/src/runtime/native/api.d.ts +3 -1
  270. package/dist/typescript/module/src/runtime/native/api.d.ts.map +1 -1
  271. package/dist/typescript/module/src/runtime/native/react/rules.d.ts +2 -2
  272. package/dist/typescript/module/src/runtime/native/react/rules.d.ts.map +1 -1
  273. package/dist/typescript/module/src/runtime/native/reactivity.d.ts.map +1 -1
  274. package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts +1 -1
  275. package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts.map +1 -1
  276. package/dist/typescript/module/src/runtime/native/styles/functions/calc.d.ts.map +1 -1
  277. package/dist/typescript/module/src/runtime/native/styles/functions/index.d.ts +2 -0
  278. package/dist/typescript/module/src/runtime/native/styles/functions/index.d.ts.map +1 -1
  279. package/dist/typescript/module/src/runtime/native/styles/functions/numeric-functions.d.ts +5 -0
  280. package/dist/typescript/module/src/runtime/native/styles/functions/numeric-functions.d.ts.map +1 -0
  281. package/dist/typescript/module/src/runtime/native/styles/functions/string-functions.d.ts +3 -0
  282. package/dist/typescript/module/src/runtime/native/styles/functions/string-functions.d.ts.map +1 -0
  283. package/dist/typescript/module/src/runtime/native/styles/functions/transform-functions.d.ts.map +1 -1
  284. package/dist/typescript/module/src/runtime/native/styles/shorthands/animation.d.ts.map +1 -1
  285. package/dist/typescript/module/src/runtime/native/styles/shorthands/box-shadow.d.ts.map +1 -1
  286. package/dist/typescript/module/src/runtime/native/styles/shorthands/transform.d.ts.map +1 -1
  287. package/dist/typescript/module/src/runtime/native/styles/variables.d.ts.map +1 -1
  288. package/dist/typescript/module/src/runtime/utils/objects.d.ts.map +1 -1
  289. package/dist/typescript/module/src/runtime/web/api.d.ts +1 -1
  290. package/dist/typescript/module/src/runtime/web/api.d.ts.map +1 -1
  291. package/dist/typescript/module/src/style-collection/index.d.ts +14 -0
  292. package/dist/typescript/module/src/style-collection/index.d.ts.map +1 -0
  293. package/dist/typescript/module/src/{runtime/native → style-collection}/root.d.ts +1 -1
  294. package/dist/typescript/module/src/style-collection/root.d.ts.map +1 -0
  295. package/package.json +30 -14
  296. package/src/compiler/compiler.ts +11 -3
  297. package/src/compiler/compiler.types.ts +11 -14
  298. package/src/compiler/declarations.ts +157 -121
  299. package/src/compiler/inheritance.test.ts +9 -9
  300. package/src/compiler/pseudo-elements.ts +54 -0
  301. package/src/compiler/selector-builder.ts +136 -81
  302. package/src/compiler/stylesheet.ts +26 -11
  303. package/src/compiler/supports.ts +26 -0
  304. package/src/components/ActivityIndicator.tsx +27 -0
  305. package/src/components/Button.tsx +22 -0
  306. package/src/components/FlatList.tsx +21 -0
  307. package/src/components/Image.tsx +17 -0
  308. package/src/components/Switch.tsx +17 -0
  309. package/src/components/TextInput.tsx +17 -0
  310. package/src/components/index.tsx +6 -0
  311. package/src/components/react-native-safe-area-context.native.tsx +40 -0
  312. package/src/components/react-native-safe-area-context.tsx +1 -0
  313. package/src/jest/index.ts +3 -2
  314. package/src/metro/index.ts +8 -6
  315. package/src/metro/injection-code.ts +6 -10
  316. package/src/metro/metro-transformer.ts +27 -10
  317. package/src/metro/resolver.ts +8 -0
  318. package/src/poison.pill.ts +10 -10
  319. package/src/runtime/native/api.ts +3 -1
  320. package/src/runtime/native/conditions/index.ts +4 -2
  321. package/src/runtime/native/conditions/media-query.ts +16 -12
  322. package/src/runtime/native/react/rules.ts +27 -17
  323. package/src/runtime/native/reactivity.ts +12 -0
  324. package/src/runtime/native/styles/calculate-props.ts +27 -6
  325. package/src/runtime/native/styles/functions/calc.ts +94 -70
  326. package/src/runtime/native/styles/functions/index.ts +2 -0
  327. package/src/runtime/native/styles/functions/numeric-functions.ts +38 -0
  328. package/src/runtime/native/styles/functions/string-functions.ts +22 -0
  329. package/src/runtime/native/styles/functions/transform-functions.ts +68 -35
  330. package/src/runtime/native/styles/shorthands/animation.ts +2 -1
  331. package/src/runtime/native/styles/shorthands/box-shadow.ts +34 -14
  332. package/src/runtime/native/styles/shorthands/transform.ts +3 -1
  333. package/src/runtime/native/styles/variables.ts +5 -1
  334. package/src/runtime/utils/objects.ts +10 -19
  335. package/src/runtime/web/api.ts +1 -1
  336. package/src/style-collection/index.ts +142 -0
  337. package/src/{runtime/native → style-collection}/root.ts +6 -2
  338. package/dist/commonjs/compiler/attributes.test.js +0 -20
  339. package/dist/commonjs/compiler/attributes.test.js.map +0 -1
  340. package/dist/commonjs/doctor/index.js +0 -6
  341. package/dist/commonjs/doctor/index.js.map +0 -1
  342. package/dist/commonjs/runtime/native/injection.js +0 -99
  343. package/dist/commonjs/runtime/native/injection.js.map +0 -1
  344. package/dist/commonjs/runtime/native/root.js.map +0 -1
  345. package/dist/module/compiler/attributes.test.js +0 -20
  346. package/dist/module/compiler/attributes.test.js.map +0 -1
  347. package/dist/module/doctor/index.js +0 -4
  348. package/dist/module/doctor/index.js.map +0 -1
  349. package/dist/module/runtime/native/injection.js +0 -94
  350. package/dist/module/runtime/native/injection.js.map +0 -1
  351. package/dist/module/runtime/native/root.js.map +0 -1
  352. package/dist/typescript/commonjs/src/compiler/attributes.test.d.ts +0 -2
  353. package/dist/typescript/commonjs/src/compiler/attributes.test.d.ts.map +0 -1
  354. package/dist/typescript/commonjs/src/doctor/index.d.ts +0 -2
  355. package/dist/typescript/commonjs/src/doctor/index.d.ts.map +0 -1
  356. package/dist/typescript/commonjs/src/runtime/native/injection.d.ts +0 -16
  357. package/dist/typescript/commonjs/src/runtime/native/injection.d.ts.map +0 -1
  358. package/dist/typescript/commonjs/src/runtime/native/root.d.ts.map +0 -1
  359. package/dist/typescript/module/src/compiler/attributes.test.d.ts +0 -2
  360. package/dist/typescript/module/src/compiler/attributes.test.d.ts.map +0 -1
  361. package/dist/typescript/module/src/doctor/index.d.ts +0 -2
  362. package/dist/typescript/module/src/doctor/index.d.ts.map +0 -1
  363. package/dist/typescript/module/src/runtime/native/injection.d.ts +0 -16
  364. package/dist/typescript/module/src/runtime/native/injection.d.ts.map +0 -1
  365. package/dist/typescript/module/src/runtime/native/root.d.ts.map +0 -1
  366. package/src/compiler/attributes.test.ts +0 -28
  367. package/src/doctor/index.ts +0 -1
  368. package/src/runtime/native/injection.ts +0 -131
@@ -1,97 +1,121 @@
1
- /* eslint-disable */
2
- import { isStyleDescriptorArray } from "../../../utils";
3
1
  import type { StyleFunctionResolver } from "../resolve";
4
2
 
5
- const calcPrecedence: Record<string, number> = {
6
- "+": 1,
7
- "-": 1,
8
- "*": 2,
9
- "/": 2,
10
- };
3
+ interface Value {
4
+ value: number;
5
+ isPercent: boolean;
6
+ }
7
+
8
+ const precedence: Record<string, number> = { "+": 1, "-": 1, "*": 2, "/": 2 };
11
9
 
12
10
  export const calc: StyleFunctionResolver = (resolveValue, func) => {
13
- let mode: "number" | "percentage" | undefined;
14
- const values: number[] = [];
15
- const ops: string[] = [];
11
+ const tokens = resolveValue(func[2]);
16
12
 
17
- const args = resolveValue(func[2]);
13
+ if (!Array.isArray(tokens)) {
14
+ return tokens;
15
+ }
18
16
 
19
- if (!isStyleDescriptorArray(args)) return;
17
+ // --- Step 1: Convert to RPN (Shunting-Yard) ---
18
+ const output: (string | Value)[] = [];
19
+ const ops: string[] = [];
20
20
 
21
- for (let token of args) {
22
- if (typeof token === "number") {
23
- if (!mode) mode = "number";
24
- if (mode !== "number") return;
25
- values.push(token);
26
- continue;
27
- } else if (typeof token === "string") {
28
- if (token === "(") {
29
- ops.push(token);
30
- } else if (token === ")") {
31
- // Resolve all values within the brackets
32
- while (ops.length && ops[ops.length - 1] !== "(") {
33
- applyCalcOperator(ops.pop()!, values.pop(), values.pop(), values);
34
- }
35
- ops.pop();
36
- } else if (token.endsWith("%")) {
37
- if (!mode) mode = "percentage";
38
- if (mode !== "percentage") return;
39
- values.push(Number.parseFloat(token.slice(0, -1)));
40
- } else {
41
- // This means we have an operator
21
+ for (const t of tokens) {
22
+ if (typeof t === "number") {
23
+ output.push({ value: round(t), isPercent: false });
24
+ } else if (typeof t === "string") {
25
+ if (t.endsWith("%")) {
26
+ const num = parseFloat(t.slice(0, -1));
27
+ if (Number.isNaN(num)) return undefined;
28
+ output.push({ value: round(num / 100), isPercent: true });
29
+ } else if (t === "+" || t === "-" || t === "*" || t === "/") {
42
30
  while (
43
31
  ops.length &&
44
- ops[ops.length - 1] &&
45
- // @ts-ignore
46
- calcPrecedence[ops[ops.length - 1]] >= calcPrecedence[token]
32
+ (ops[ops.length - 1] === "+" ||
33
+ ops[ops.length - 1] === "-" ||
34
+ ops[ops.length - 1] === "*" ||
35
+ ops[ops.length - 1] === "/") &&
36
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
37
+ (precedence[ops[ops.length - 1]!] ?? 0) >= (precedence[t] ?? 0)
47
38
  ) {
48
- applyCalcOperator(ops.pop()!, values.pop(), values.pop(), values);
39
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
40
+ output.push(ops.pop()!);
41
+ }
42
+ ops.push(t);
43
+ } else if (t === "(") {
44
+ ops.push(t);
45
+ } else if (t === ")") {
46
+ while (ops.length && ops[ops.length - 1] !== "(") {
47
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
48
+ output.push(ops.pop()!);
49
49
  }
50
- ops.push(token);
50
+ if (ops.pop() !== "(") return undefined; // mismatched parens
51
+ } else {
52
+ return undefined; // invalid token
51
53
  }
52
54
  } else {
53
- // We got something unexpected
54
- return;
55
+ return undefined;
55
56
  }
56
57
  }
57
-
58
58
  while (ops.length) {
59
- applyCalcOperator(ops.pop()!, values.pop(), values.pop(), values);
59
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
60
+ const op = ops.pop()!;
61
+ if (op === "(" || op === ")") return undefined;
62
+ output.push(op);
60
63
  }
61
64
 
62
- if (!mode) return;
65
+ // --- Step 2: Evaluate RPN ---
66
+ const stack: Value[] = [];
67
+ for (const t of output) {
68
+ if (typeof t !== "string") {
69
+ stack.push(t);
70
+ } else {
71
+ const b = stack.pop();
72
+ const a = stack.pop();
73
+ if (!a || !b) return undefined;
63
74
 
64
- const num = values[0];
75
+ const res: Value = { value: 0, isPercent: false };
65
76
 
66
- if (typeof num !== "number") {
67
- return;
77
+ switch (t) {
78
+ case "+":
79
+ case "-": {
80
+ if (a.isPercent !== b.isPercent) return undefined; // cannot mix
81
+ res.isPercent = a.isPercent;
82
+ res.value =
83
+ t === "+" ? round(a.value + b.value) : round(a.value - b.value);
84
+ break;
85
+ }
86
+ case "*": {
87
+ if (a.isPercent && b.isPercent) return undefined; // ambiguous
88
+ res.isPercent = a.isPercent || b.isPercent;
89
+ res.value = round(a.value * b.value);
90
+ break;
91
+ }
92
+ case "/": {
93
+ if (b.value === 0) return undefined;
94
+ if (a.isPercent && b.isPercent) {
95
+ // % / % → plain number ratio
96
+ res.isPercent = false;
97
+ res.value = round(a.value / b.value);
98
+ } else {
99
+ res.isPercent = a.isPercent || b.isPercent;
100
+ res.value = round(a.value / b.value);
101
+ }
102
+ break;
103
+ }
104
+ }
105
+ stack.push(res);
106
+ }
68
107
  }
69
108
 
70
- const value = Math.round((num + Number.EPSILON) * 100) / 100;
109
+ if (stack.length !== 1) return undefined;
71
110
 
72
- if (mode === "percentage") {
73
- return `${value}%`;
111
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
112
+ const final = stack[0]!;
113
+ if (final.isPercent) {
114
+ return `${final.value * 100}%`;
74
115
  }
75
-
76
- return value;
116
+ return final.value;
77
117
  };
78
118
 
79
- function applyCalcOperator(
80
- operator: string,
81
- b = 0, // These are reversed because we pop them off the stack
82
- a = 0,
83
- values: number[],
84
- ) {
85
- switch (operator) {
86
- case "+":
87
- return values.push(a + b);
88
- case "-":
89
- return values.push(a - b);
90
- case "*":
91
- return values.push(a * b);
92
- case "/":
93
- return values.push(a / b);
94
- }
95
-
96
- return;
119
+ function round(number: number) {
120
+ return Math.round((number + Number.EPSILON) * 10000) / 10000;
97
121
  }
@@ -1,5 +1,7 @@
1
1
  export * from "./animation-timing";
2
2
  export * from "./calc";
3
3
  export * from "./filters";
4
+ export * from "./numeric-functions";
4
5
  export * from "./platform-functions";
6
+ export * from "./string-functions";
5
7
  export * from "./transform-functions";
@@ -0,0 +1,38 @@
1
+ import type { StyleFunctionResolver } from "../resolve";
2
+
3
+ export const max: StyleFunctionResolver = (resolveValue, value) => {
4
+ const args = resolveValue(value[2]);
5
+
6
+ if (!Array.isArray(args) || args.some((arg) => typeof arg !== "number")) {
7
+ return;
8
+ }
9
+
10
+ return Math.max(...(args as number[]));
11
+ };
12
+
13
+ export const min: StyleFunctionResolver = (resolveValue, value) => {
14
+ const args = resolveValue(value[2]);
15
+
16
+ if (!Array.isArray(args) || args.some((arg) => typeof arg !== "number")) {
17
+ return;
18
+ }
19
+
20
+ return Math.min(...(args as number[]));
21
+ };
22
+
23
+ export const clamp: StyleFunctionResolver = (resolveValue, value) => {
24
+ const args = resolveValue(value[2]);
25
+
26
+ const [clampValue, min, max] = args as number[];
27
+
28
+ if (
29
+ !Array.isArray(args) ||
30
+ typeof clampValue !== "number" ||
31
+ typeof min !== "number" ||
32
+ typeof max !== "number"
33
+ ) {
34
+ return;
35
+ }
36
+
37
+ return Math.min(Math.max(clampValue, min), max);
38
+ };
@@ -0,0 +1,22 @@
1
+ import type { StyleFunctionResolver } from "../resolve";
2
+
3
+ export const join: StyleFunctionResolver = (resolveValue, value) => {
4
+ const args = resolveValue(value[2]);
5
+
6
+ if (!Array.isArray(args)) {
7
+ return args;
8
+ }
9
+
10
+ const array: unknown = args[0];
11
+ const separator: unknown = args[1] ?? ",";
12
+
13
+ if (!Array.isArray(array)) {
14
+ return array;
15
+ }
16
+
17
+ if (!separator || typeof separator !== "string") {
18
+ return array.join();
19
+ }
20
+
21
+ return array.join(separator);
22
+ };
@@ -1,51 +1,84 @@
1
+ import { isStyleDescriptorArray } from "../../../utils";
1
2
  import type { StyleFunctionResolver } from "../resolve";
2
3
 
3
4
  export const scale: StyleFunctionResolver = (resolveValue, descriptor) => {
4
- const values = resolveValue(descriptor[2]);
5
-
6
- if (Array.isArray(values)) {
7
- const [x, y] = values as [string | number][];
8
-
9
- if (values.length === 2 && x === y) {
10
- return { scale: x };
11
- } else if (values.length === 2) {
12
- return [{ scaleX: x }, { scaleY: y }];
13
- } else {
14
- return { scale: x };
15
- }
16
- } else {
17
- return { scale: values };
5
+ const args = descriptor[2];
6
+
7
+ if (!isStyleDescriptorArray(args)) {
8
+ return { scale: resolveValue(args) };
9
+ }
10
+
11
+ const x = resolveValue(args[0]);
12
+ const y = resolveValue(args[1]);
13
+
14
+ const isXValid = typeof x === "string" || typeof x === "number";
15
+ const isYValid = typeof y === "string" || typeof y === "number";
16
+
17
+ if (isXValid && isYValid) {
18
+ return x === y ? { scale: x } : [{ scaleX: x }, { scaleY: y }];
19
+ } else if (isXValid) {
20
+ return { scaleX: x };
21
+ } else if (isYValid) {
22
+ return { scaleY: y };
18
23
  }
24
+
25
+ return;
19
26
  };
20
27
 
21
28
  export const rotate: StyleFunctionResolver = (resolveValue, descriptor) => {
22
- const values = resolveValue(descriptor[2]);
23
-
24
- if (Array.isArray(values)) {
25
- const [x, y, z] = values as [string | number][];
26
-
27
- if (values.length === 3 && x === y && x === z) {
28
- return { rotate: values };
29
- } else if (values.length === 3) {
30
- return [{ rotateX: x }, { rotateY: y }, { rotateZ: z }];
31
- } else if (values.length === 2) {
32
- return [{ rotateX: x }, { rotateY: y }];
33
- } else {
34
- return { rotate: values };
35
- }
36
- } else {
37
- return { rotate: values };
29
+ const args = descriptor[2];
30
+
31
+ if (!isStyleDescriptorArray(args)) {
32
+ return { rotate: resolveValue(args) };
33
+ }
34
+
35
+ const x = resolveValue(args[0]);
36
+ const y = resolveValue(args[1]);
37
+ const z = resolveValue(args[2]);
38
+
39
+ const isXValid = typeof x === "string" || typeof x === "number";
40
+ const isYValid = typeof y === "string" || typeof y === "number";
41
+ const isZValid = typeof z === "string" || typeof z === "number";
42
+
43
+ if (isXValid && isYValid && isZValid) {
44
+ return [{ rotateX: x }, { rotateY: y }, { rotateZ: z }];
45
+ } else if (isXValid && isYValid) {
46
+ return [{ rotateX: x }, { rotateY: y }];
47
+ } else if (isXValid && isZValid) {
48
+ return [{ rotateX: x }, { rotateZ: z }];
49
+ } else if (isYValid && isZValid) {
50
+ return [{ rotateY: y }, { rotateZ: z }];
51
+ } else if (isXValid) {
52
+ return { rotateX: x };
53
+ } else if (isYValid) {
54
+ return { rotateY: y };
55
+ } else if (isZValid) {
56
+ return { rotateZ: z };
38
57
  }
58
+
59
+ return;
39
60
  };
40
61
 
41
62
  export const translate: StyleFunctionResolver = (resolveValue, descriptor) => {
42
- const values = resolveValue(descriptor[2]);
63
+ const args = descriptor[2];
43
64
 
44
- if (Array.isArray(values)) {
45
- const [x, y] = values as [string | number][];
65
+ if (!isStyleDescriptorArray(args)) {
66
+ return;
67
+ }
68
+
69
+ const x = resolveValue(args[0]);
70
+ const y = resolveValue(args[1]);
46
71
 
72
+ const isXValid = typeof x === "string" || typeof x === "number";
73
+ const isYValid = typeof y === "string" || typeof y === "number";
74
+
75
+ if (isXValid && isYValid) {
47
76
  return [{ translateX: x }, { translateY: y }];
48
- } else {
49
- return { translateX: values };
77
+ } else if (isXValid) {
78
+ return { translateX: x };
79
+ } else if (isYValid) {
80
+ return { translateY: y };
50
81
  }
82
+
83
+ return;
51
84
  };
@@ -1,6 +1,7 @@
1
1
  /* eslint-disable */
2
+ import { StyleCollection } from "react-native-css/style-collection";
3
+
2
4
  import { applyShorthand } from "../../../utils";
3
- import { StyleCollection } from "../../injection";
4
5
  import type { StyleFunctionResolver } from "../resolve";
5
6
  import { shorthandHandler } from "./_handler";
6
7
 
@@ -33,22 +33,42 @@ export const boxShadow: StyleFunctionResolver = (
33
33
  if (!isStyleDescriptorArray(args)) {
34
34
  return args;
35
35
  } else {
36
- return args.flatMap((shadows) => {
37
- if (shadows === undefined) {
38
- return [];
39
- } else if (isStyleDescriptorArray(shadows)) {
40
- if (shadows.length === 0) {
36
+ return args
37
+ .flatMap((shadows) => {
38
+ if (shadows === undefined) {
41
39
  return [];
42
- } else if (Array.isArray(shadows[0])) {
43
- return shadows
44
- .map((shadow) => handler(resolveValue, shadow, get, options))
45
- .filter((v) => v !== undefined);
40
+ } else if (isStyleDescriptorArray(shadows)) {
41
+ if (shadows.length === 0) {
42
+ return [];
43
+ } else if (Array.isArray(shadows[0])) {
44
+ return shadows
45
+ .map((shadow) => {
46
+ return omitTransparentShadows(
47
+ handler(resolveValue, shadow, get, options),
48
+ );
49
+ })
50
+ .filter((v) => v !== undefined);
51
+ } else {
52
+ return omitTransparentShadows(
53
+ handler(resolveValue, shadows, get, options),
54
+ );
55
+ }
46
56
  } else {
47
- return handler(resolveValue, shadows, get, options);
57
+ return omitTransparentShadows(
58
+ handler(resolveValue, shadows, get, options),
59
+ );
48
60
  }
49
- } else {
50
- return handler(resolveValue, shadows, get, options);
51
- }
52
- });
61
+ })
62
+ .filter((v) => v !== undefined);
53
63
  }
54
64
  };
65
+
66
+ function omitTransparentShadows(style: unknown) {
67
+ if (typeof style === "object" && style && "color" in style) {
68
+ if (style.color === "#0000" || style.color === "transparent") {
69
+ return;
70
+ }
71
+ }
72
+
73
+ return style;
74
+ }
@@ -11,7 +11,9 @@ export const transform: StyleFunctionResolver = (
11
11
  const transforms = resolveValue(transformDescriptor[2]);
12
12
 
13
13
  if (Array.isArray(transforms)) {
14
- return transforms.filter((transform) => transform !== undefined) as unknown;
14
+ return transforms.filter(
15
+ (transform) => transform !== undefined && transform !== "initial",
16
+ ) as unknown;
15
17
  } else if (transforms) {
16
18
  // If it's a single transform, wrap it in an array
17
19
  return [transforms];
@@ -1,7 +1,11 @@
1
+ import {
2
+ rootVariables,
3
+ universalVariables,
4
+ } from "react-native-css/style-collection";
5
+
1
6
  import type { StyleDescriptor, StyleFunction } from "../../../compiler";
2
7
  import { isStyleDescriptorArray } from "../../utils";
3
8
  import { VAR_SYMBOL, type Getter } from "../reactivity";
4
- import { rootVariables, universalVariables } from "../root";
5
9
  import type { ResolveValueOptions, SimpleResolveValue } from "./resolve";
6
10
 
7
11
  export function varResolver(
@@ -24,7 +24,9 @@ export function getDeepPath(source: any, paths: string | string[] | false) {
24
24
 
25
25
  return target;
26
26
  } else if (transformKeys.has(paths)) {
27
- return source?.transform?.find((t: any) => t[paths] !== undefined);
27
+ return Array.isArray(source?.transform)
28
+ ? source.transform.find((t: any) => t[paths] !== undefined)
29
+ : source.transform;
28
30
  } else {
29
31
  return source?.[paths];
30
32
  }
@@ -66,25 +68,14 @@ export function applyValue(
66
68
  }
67
69
 
68
70
  const transformArray: Record<string, unknown>[] = target.transform;
69
- const transform = transformArray.find((t: any) => t[prop] !== undefined);
70
-
71
- /**
72
- * If our value is an array, this means a shorthand was split into multiple values
73
- * e.g scale -> scaleX, scaleY
74
- */
75
- if (transform) {
76
- if (Array.isArray(value)) {
77
- target.transform = transformArray.filter((t) => !(prop in t));
78
- target.transform.push(...value);
79
- } else {
80
- transform[prop] = value;
81
- }
71
+
72
+ // Remove any existing values
73
+ target.transform = transformArray.filter((t) => !(prop in t));
74
+
75
+ if (Array.isArray(value)) {
76
+ target.transform.push(...value);
82
77
  } else {
83
- if (Array.isArray(value)) {
84
- transformArray.push(...value);
85
- } else {
86
- transformArray.push(value);
87
- }
78
+ target.transform.push(value);
88
79
  }
89
80
  return;
90
81
  } else if (typeof value === "object" && value && ShortHandSymbol in value) {
@@ -66,7 +66,7 @@ export const colorScheme: ColorScheme = {
66
66
  },
67
67
  };
68
68
 
69
- export function vars(variables: Record<`--${string}`, string | number>) {
69
+ export function vars(variables: Record<string, string | number>) {
70
70
  const $variables: Record<string, string> = {};
71
71
 
72
72
  for (const [key, value] of Object.entries(variables)) {
@@ -0,0 +1,142 @@
1
+ import type {
2
+ Animation,
3
+ ReactNativeCssStyleSheet,
4
+ StyleRuleSet,
5
+ } from "react-native-css/compiler";
6
+
7
+ import { DEFAULT_CONTAINER_NAME } from "../runtime/native/conditions/container-query";
8
+ import {
9
+ family,
10
+ observable,
11
+ observableBatch,
12
+ type Observable,
13
+ } from "../runtime/native/reactivity";
14
+ import { rootVariables, universalVariables } from "./root";
15
+
16
+ export { rootVariables, universalVariables };
17
+
18
+ interface StyleCollectionType {
19
+ styles: ReturnType<typeof family<string, Observable<StyleRuleSet>>>;
20
+ keyframes: ReturnType<typeof family<string, Observable<Animation[1]>>>;
21
+ inject: (options: ReactNativeCssStyleSheet) => void;
22
+ }
23
+
24
+ declare global {
25
+ var __react_native_css_style_collection: StyleCollectionType | undefined;
26
+ }
27
+
28
+ globalThis.__react_native_css_style_collection ??= {
29
+ styles: family<string, Observable<StyleRuleSet>>(() => {
30
+ return observable([], isDeepEqual);
31
+ }),
32
+ keyframes: family<string, Observable<Animation[1]>>(() => {
33
+ return observable([], isDeepEqual);
34
+ }),
35
+ inject: function (options: ReactNativeCssStyleSheet) {
36
+ observableBatch.current = new Set();
37
+
38
+ StyleCollection.styles("will-change-variable").set([
39
+ {
40
+ s: [0],
41
+ v: [],
42
+ },
43
+ ]);
44
+
45
+ StyleCollection.styles("will-change-container").set([
46
+ {
47
+ s: [0],
48
+ c: [DEFAULT_CONTAINER_NAME],
49
+ },
50
+ ]);
51
+
52
+ StyleCollection.styles("will-change-animation").set([
53
+ {
54
+ s: [0],
55
+ a: true,
56
+ },
57
+ ]);
58
+
59
+ StyleCollection.styles("will-change-pressable").set([
60
+ {
61
+ s: [0],
62
+ p: {
63
+ h: 1,
64
+ },
65
+ },
66
+ ]);
67
+
68
+ if (options.s) {
69
+ for (const style of options.s) {
70
+ StyleCollection.styles(style[0]).set(style[1]);
71
+ }
72
+ }
73
+
74
+ if (options.k) {
75
+ for (const keyframes of options.k) {
76
+ StyleCollection.keyframes(keyframes[0]).set(keyframes[1]);
77
+ }
78
+ }
79
+
80
+ if (options.vr) {
81
+ for (const entry of options.vr) {
82
+ rootVariables(entry[0]).set(entry[1]);
83
+ }
84
+ }
85
+
86
+ if (options.vu) {
87
+ for (const entry of options.vu) {
88
+ rootVariables(entry[0]).set(entry[1]);
89
+ }
90
+ }
91
+
92
+ for (const effect of observableBatch.current) {
93
+ effect.run();
94
+ }
95
+
96
+ observableBatch.current = undefined;
97
+ },
98
+ };
99
+
100
+ export const StyleCollection = globalThis.__react_native_css_style_collection;
101
+
102
+ function isDeepEqual(a: unknown, b: unknown): boolean {
103
+ const aArray = Array.isArray(a);
104
+ const bArray = Array.isArray(b);
105
+ const requiresKeyComparison =
106
+ typeof a === "object" && typeof b === "object" && aArray === bArray;
107
+
108
+ // Only compare keys when both are an object or array
109
+ // This does not account for complex types like Date/Regex, because we don't use them
110
+ if (!requiresKeyComparison) return a === b;
111
+
112
+ // Make either are not null
113
+ if (!a || !b) {
114
+ return a === b;
115
+ }
116
+
117
+ // Shortcut for arrays
118
+ if (aArray && bArray && a.length !== b.length) {
119
+ return false;
120
+ }
121
+
122
+ // Compare a to b
123
+ for (const key in a) {
124
+ if (
125
+ !isDeepEqual(
126
+ (a as Record<string, unknown>)[key],
127
+ (b as Record<string, unknown>)[key],
128
+ )
129
+ ) {
130
+ return false;
131
+ }
132
+ }
133
+
134
+ // Compare b to a
135
+ for (const key in b) {
136
+ if (!(key in a)) {
137
+ return false;
138
+ }
139
+ }
140
+
141
+ return true;
142
+ }