react-native-css 3.0.0-nightly.61014be → 3.0.0-nightly.8dd703d

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 (416) hide show
  1. package/dist/commonjs/compiler/atRules.js +16 -3
  2. package/dist/commonjs/compiler/atRules.js.map +1 -1
  3. package/dist/commonjs/compiler/attributes.test.js +1 -1
  4. package/dist/commonjs/compiler/attributes.test.js.map +1 -1
  5. package/dist/commonjs/compiler/compiler.js +26 -17
  6. package/dist/commonjs/compiler/compiler.js.map +1 -1
  7. package/dist/commonjs/compiler/declarations.js +195 -94
  8. package/dist/commonjs/compiler/declarations.js.map +1 -1
  9. package/dist/commonjs/compiler/inheritance.test.js +7 -7
  10. package/dist/commonjs/compiler/inheritance.test.js.map +1 -1
  11. package/dist/commonjs/compiler/keyframes.js +1 -1
  12. package/dist/commonjs/compiler/keyframes.js.map +1 -1
  13. package/dist/commonjs/compiler/selector-builder.js +457 -0
  14. package/dist/commonjs/compiler/selector-builder.js.map +1 -0
  15. package/dist/commonjs/compiler/selectors.js +10 -6
  16. package/dist/commonjs/compiler/selectors.js.map +1 -1
  17. package/dist/commonjs/compiler/stylesheet.js +122 -43
  18. package/dist/commonjs/compiler/stylesheet.js.map +1 -1
  19. package/dist/commonjs/jest/index.js +33 -10
  20. package/dist/commonjs/jest/index.js.map +1 -1
  21. package/dist/commonjs/metro/index.js +1 -1
  22. package/dist/commonjs/metro/index.js.map +1 -1
  23. package/dist/commonjs/poison.pill.js +4 -1
  24. package/dist/commonjs/poison.pill.js.map +1 -1
  25. package/dist/commonjs/runtime/native/conditions/attributes.js +42 -0
  26. package/dist/commonjs/runtime/native/conditions/attributes.js.map +1 -0
  27. package/dist/commonjs/runtime/native/conditions/container-query.js +28 -21
  28. package/dist/commonjs/runtime/native/conditions/container-query.js.map +1 -1
  29. package/dist/commonjs/runtime/native/conditions/guards.js.map +1 -1
  30. package/dist/commonjs/runtime/native/conditions/index.js +10 -46
  31. package/dist/commonjs/runtime/native/conditions/index.js.map +1 -1
  32. package/dist/commonjs/runtime/native/conditions/media-query.js +19 -17
  33. package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -1
  34. package/dist/commonjs/runtime/native/injection.js +3 -2
  35. package/dist/commonjs/runtime/native/injection.js.map +1 -1
  36. package/dist/commonjs/runtime/native/react/interaction.js +10 -10
  37. package/dist/commonjs/runtime/native/react/interaction.js.map +1 -1
  38. package/dist/commonjs/runtime/native/react/rules.js +9 -9
  39. package/dist/commonjs/runtime/native/react/rules.js.map +1 -1
  40. package/dist/commonjs/runtime/native/react/useNativeCss.js +3 -2
  41. package/dist/commonjs/runtime/native/react/useNativeCss.js.map +1 -1
  42. package/dist/commonjs/runtime/native/reactivity.js +1 -12
  43. package/dist/commonjs/runtime/native/reactivity.js.map +1 -1
  44. package/dist/commonjs/runtime/native/reanimated.js +17 -0
  45. package/dist/commonjs/runtime/native/reanimated.js.map +1 -0
  46. package/dist/commonjs/runtime/native/root.js +28 -0
  47. package/dist/commonjs/runtime/native/root.js.map +1 -0
  48. package/dist/commonjs/runtime/native/styles/calculate-props.js +56 -48
  49. package/dist/commonjs/runtime/native/styles/calculate-props.js.map +1 -1
  50. package/dist/commonjs/runtime/native/styles/defaults.js +1 -1
  51. package/dist/commonjs/runtime/native/styles/defaults.js.map +1 -1
  52. package/dist/commonjs/runtime/native/styles/functions/animation-timing.js +34 -0
  53. package/dist/commonjs/runtime/native/styles/functions/animation-timing.js.map +1 -0
  54. package/dist/commonjs/runtime/native/styles/{calc.js → functions/calc.js} +1 -1
  55. package/dist/commonjs/runtime/native/styles/functions/calc.js.map +1 -0
  56. package/dist/commonjs/runtime/native/styles/{filters.js → functions/filters.js} +3 -3
  57. package/dist/commonjs/runtime/native/styles/functions/filters.js.map +1 -0
  58. package/dist/commonjs/runtime/native/styles/functions/index.js +61 -0
  59. package/dist/commonjs/runtime/native/styles/functions/index.js.map +1 -0
  60. package/dist/commonjs/runtime/native/styles/{platform-functions.js → functions/platform-functions.js} +3 -3
  61. package/dist/commonjs/runtime/native/styles/functions/platform-functions.js.map +1 -0
  62. package/dist/commonjs/runtime/native/styles/functions/transform-functions.js +83 -0
  63. package/dist/commonjs/runtime/native/styles/functions/transform-functions.js.map +1 -0
  64. package/dist/commonjs/runtime/native/styles/index.js +12 -12
  65. package/dist/commonjs/runtime/native/styles/index.js.map +1 -1
  66. package/dist/commonjs/runtime/native/styles/resolve.js +21 -44
  67. package/dist/commonjs/runtime/native/styles/resolve.js.map +1 -1
  68. package/dist/commonjs/runtime/native/styles/{shorthand.js → shorthands/_handler.js} +5 -5
  69. package/dist/commonjs/runtime/native/styles/shorthands/_handler.js.map +1 -0
  70. package/dist/commonjs/runtime/native/styles/{animation.js → shorthands/animation.js} +5 -36
  71. package/dist/commonjs/runtime/native/styles/shorthands/animation.js.map +1 -0
  72. package/dist/commonjs/runtime/native/styles/{border.js → shorthands/border.js} +2 -2
  73. package/dist/commonjs/runtime/native/styles/shorthands/border.js.map +1 -0
  74. package/dist/commonjs/runtime/native/styles/{box-shadow.js → shorthands/box-shadow.js} +3 -3
  75. package/dist/commonjs/runtime/native/styles/shorthands/box-shadow.js.map +1 -0
  76. package/dist/commonjs/runtime/native/styles/shorthands/index.js +61 -0
  77. package/dist/commonjs/runtime/native/styles/shorthands/index.js.map +1 -0
  78. package/dist/commonjs/runtime/native/styles/{text-shadow.js → shorthands/text-shadow.js} +2 -2
  79. package/dist/commonjs/runtime/native/styles/shorthands/text-shadow.js.map +1 -0
  80. package/dist/commonjs/runtime/native/styles/shorthands/transform.js.map +1 -0
  81. package/dist/commonjs/runtime/native/styles/units.js +7 -4
  82. package/dist/commonjs/runtime/native/styles/units.js.map +1 -1
  83. package/dist/commonjs/runtime/native/styles/variables.js +3 -2
  84. package/dist/commonjs/runtime/native/styles/variables.js.map +1 -1
  85. package/dist/commonjs/runtime/utils/objects.js +25 -5
  86. package/dist/commonjs/runtime/utils/objects.js.map +1 -1
  87. package/dist/commonjs/runtime/utils/specificity.js +2 -1
  88. package/dist/commonjs/runtime/utils/specificity.js.map +1 -1
  89. package/dist/module/compiler/atRules.js +16 -3
  90. package/dist/module/compiler/atRules.js.map +1 -1
  91. package/dist/module/compiler/attributes.test.js +1 -1
  92. package/dist/module/compiler/attributes.test.js.map +1 -1
  93. package/dist/module/compiler/compiler.js +26 -17
  94. package/dist/module/compiler/compiler.js.map +1 -1
  95. package/dist/module/compiler/compiler.types.js.map +1 -1
  96. package/dist/module/compiler/declarations.js +190 -90
  97. package/dist/module/compiler/declarations.js.map +1 -1
  98. package/dist/module/compiler/inheritance.test.js +7 -7
  99. package/dist/module/compiler/inheritance.test.js.map +1 -1
  100. package/dist/module/compiler/keyframes.js +1 -1
  101. package/dist/module/compiler/keyframes.js.map +1 -1
  102. package/dist/module/compiler/selector-builder.js +452 -0
  103. package/dist/module/compiler/selector-builder.js.map +1 -0
  104. package/dist/module/compiler/selectors.js +10 -6
  105. package/dist/module/compiler/selectors.js.map +1 -1
  106. package/dist/module/compiler/stylesheet.js +121 -42
  107. package/dist/module/compiler/stylesheet.js.map +1 -1
  108. package/dist/module/jest/index.js +32 -10
  109. package/dist/module/jest/index.js.map +1 -1
  110. package/dist/module/metro/index.js +1 -1
  111. package/dist/module/metro/index.js.map +1 -1
  112. package/dist/module/poison.pill.js +4 -1
  113. package/dist/module/poison.pill.js.map +1 -1
  114. package/dist/module/runtime/native/conditions/attributes.js +38 -0
  115. package/dist/module/runtime/native/conditions/attributes.js.map +1 -0
  116. package/dist/module/runtime/native/conditions/container-query.js +28 -21
  117. package/dist/module/runtime/native/conditions/container-query.js.map +1 -1
  118. package/dist/module/runtime/native/conditions/guards.js.map +1 -1
  119. package/dist/module/runtime/native/conditions/index.js +10 -46
  120. package/dist/module/runtime/native/conditions/index.js.map +1 -1
  121. package/dist/module/runtime/native/conditions/media-query.js +19 -17
  122. package/dist/module/runtime/native/conditions/media-query.js.map +1 -1
  123. package/dist/module/runtime/native/injection.js +2 -1
  124. package/dist/module/runtime/native/injection.js.map +1 -1
  125. package/dist/module/runtime/native/react/interaction.js +10 -10
  126. package/dist/module/runtime/native/react/interaction.js.map +1 -1
  127. package/dist/module/runtime/native/react/rules.js +9 -9
  128. package/dist/module/runtime/native/react/rules.js.map +1 -1
  129. package/dist/module/runtime/native/react/useNativeCss.js +2 -1
  130. package/dist/module/runtime/native/react/useNativeCss.js.map +1 -1
  131. package/dist/module/runtime/native/reactivity.js +0 -11
  132. package/dist/module/runtime/native/reactivity.js.map +1 -1
  133. package/dist/module/runtime/native/reanimated.js +13 -0
  134. package/dist/module/runtime/native/reanimated.js.map +1 -0
  135. package/dist/module/runtime/native/root.js +24 -0
  136. package/dist/module/runtime/native/root.js.map +1 -0
  137. package/dist/module/runtime/native/styles/calculate-props.js +57 -49
  138. package/dist/module/runtime/native/styles/calculate-props.js.map +1 -1
  139. package/dist/module/runtime/native/styles/defaults.js +1 -1
  140. package/dist/module/runtime/native/styles/defaults.js.map +1 -1
  141. package/dist/module/runtime/native/styles/functions/animation-timing.js +30 -0
  142. package/dist/module/runtime/native/styles/functions/animation-timing.js.map +1 -0
  143. package/dist/module/runtime/native/styles/{calc.js → functions/calc.js} +1 -1
  144. package/dist/module/runtime/native/styles/functions/calc.js.map +1 -0
  145. package/dist/module/runtime/native/styles/{filters.js → functions/filters.js} +2 -2
  146. package/dist/module/runtime/native/styles/functions/filters.js.map +1 -0
  147. package/dist/module/runtime/native/styles/functions/index.js +8 -0
  148. package/dist/module/runtime/native/styles/functions/index.js.map +1 -0
  149. package/dist/module/runtime/native/styles/{platform-functions.js → functions/platform-functions.js} +1 -1
  150. package/dist/module/runtime/native/styles/functions/platform-functions.js.map +1 -0
  151. package/dist/module/runtime/native/styles/functions/transform-functions.js +76 -0
  152. package/dist/module/runtime/native/styles/functions/transform-functions.js.map +1 -0
  153. package/dist/module/runtime/native/styles/index.js +12 -12
  154. package/dist/module/runtime/native/styles/index.js.map +1 -1
  155. package/dist/module/runtime/native/styles/resolve.js +20 -44
  156. package/dist/module/runtime/native/styles/resolve.js.map +1 -1
  157. package/dist/module/runtime/native/styles/{shorthand.js → shorthands/_handler.js} +5 -5
  158. package/dist/module/runtime/native/styles/shorthands/_handler.js.map +1 -0
  159. package/dist/module/runtime/native/styles/{animation.js → shorthands/animation.js} +3 -34
  160. package/dist/module/runtime/native/styles/shorthands/animation.js.map +1 -0
  161. package/dist/module/runtime/native/styles/{border.js → shorthands/border.js} +1 -1
  162. package/dist/module/runtime/native/styles/shorthands/border.js.map +1 -0
  163. package/dist/module/runtime/native/styles/{box-shadow.js → shorthands/box-shadow.js} +2 -2
  164. package/dist/module/runtime/native/styles/shorthands/box-shadow.js.map +1 -0
  165. package/dist/module/runtime/native/styles/shorthands/index.js +8 -0
  166. package/dist/module/runtime/native/styles/shorthands/index.js.map +1 -0
  167. package/dist/module/runtime/native/styles/{text-shadow.js → shorthands/text-shadow.js} +1 -1
  168. package/dist/module/runtime/native/styles/shorthands/text-shadow.js.map +1 -0
  169. package/dist/module/runtime/native/styles/shorthands/transform.js.map +1 -0
  170. package/dist/module/runtime/native/styles/units.js +7 -4
  171. package/dist/module/runtime/native/styles/units.js.map +1 -1
  172. package/dist/module/runtime/native/styles/variables.js +2 -1
  173. package/dist/module/runtime/native/styles/variables.js.map +1 -1
  174. package/dist/module/runtime/utils/objects.js +25 -5
  175. package/dist/module/runtime/utils/objects.js.map +1 -1
  176. package/dist/module/runtime/utils/specificity.js +2 -1
  177. package/dist/module/runtime/utils/specificity.js.map +1 -1
  178. package/dist/typescript/commonjs/src/compiler/atRules.d.ts.map +1 -1
  179. package/dist/typescript/commonjs/src/compiler/compiler.d.ts +9 -2
  180. package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
  181. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +5 -4
  182. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -1
  183. package/dist/typescript/commonjs/src/compiler/declarations.d.ts +16 -19
  184. package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
  185. package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts +23 -0
  186. package/dist/typescript/commonjs/src/compiler/selector-builder.d.ts.map +1 -0
  187. package/dist/typescript/commonjs/src/compiler/selectors.d.ts +3 -2
  188. package/dist/typescript/commonjs/src/compiler/selectors.d.ts.map +1 -1
  189. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +21 -7
  190. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -1
  191. package/dist/typescript/commonjs/src/jest/index.d.ts +20 -3
  192. package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  193. package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -1
  194. package/dist/typescript/commonjs/src/poison.pill.d.ts.map +1 -1
  195. package/dist/typescript/commonjs/src/runtime/native/conditions/attributes.d.ts +5 -0
  196. package/dist/typescript/commonjs/src/runtime/native/conditions/attributes.d.ts.map +1 -0
  197. package/dist/typescript/commonjs/src/runtime/native/conditions/container-query.d.ts +3 -3
  198. package/dist/typescript/commonjs/src/runtime/native/conditions/container-query.d.ts.map +1 -1
  199. package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts +2 -2
  200. package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts.map +1 -1
  201. package/dist/typescript/commonjs/src/runtime/native/conditions/index.d.ts +2 -2
  202. package/dist/typescript/commonjs/src/runtime/native/conditions/index.d.ts.map +1 -1
  203. package/dist/typescript/commonjs/src/runtime/native/conditions/media-query.d.ts +2 -2
  204. package/dist/typescript/commonjs/src/runtime/native/conditions/media-query.d.ts.map +1 -1
  205. package/dist/typescript/commonjs/src/runtime/native/injection.d.ts.map +1 -1
  206. package/dist/typescript/commonjs/src/runtime/native/react/interaction.d.ts +2 -2
  207. package/dist/typescript/commonjs/src/runtime/native/react/interaction.d.ts.map +1 -1
  208. package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts +2 -1
  209. package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts.map +1 -1
  210. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts +2 -10
  211. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts.map +1 -1
  212. package/dist/typescript/commonjs/src/runtime/native/reanimated.d.ts +5 -0
  213. package/dist/typescript/commonjs/src/runtime/native/reanimated.d.ts.map +1 -0
  214. package/dist/typescript/commonjs/src/runtime/native/root.d.ts +11 -0
  215. package/dist/typescript/commonjs/src/runtime/native/root.d.ts.map +1 -0
  216. package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts.map +1 -1
  217. package/dist/typescript/commonjs/src/runtime/native/styles/defaults.d.ts.map +1 -1
  218. package/dist/typescript/commonjs/src/runtime/native/styles/functions/animation-timing.d.ts +4 -0
  219. package/dist/typescript/commonjs/src/runtime/native/styles/functions/animation-timing.d.ts.map +1 -0
  220. package/dist/typescript/commonjs/src/runtime/native/styles/functions/calc.d.ts +3 -0
  221. package/dist/typescript/commonjs/src/runtime/native/styles/functions/calc.d.ts.map +1 -0
  222. package/dist/typescript/commonjs/src/runtime/native/styles/{filters.d.ts → functions/filters.d.ts} +1 -1
  223. package/dist/typescript/commonjs/src/runtime/native/styles/functions/filters.d.ts.map +1 -0
  224. package/dist/typescript/commonjs/src/runtime/native/styles/functions/index.d.ts +6 -0
  225. package/dist/typescript/commonjs/src/runtime/native/styles/functions/index.d.ts.map +1 -0
  226. package/dist/typescript/commonjs/src/runtime/native/styles/{platform-functions.d.ts → functions/platform-functions.d.ts} +2 -2
  227. package/dist/typescript/commonjs/src/runtime/native/styles/functions/platform-functions.d.ts.map +1 -0
  228. package/dist/typescript/commonjs/src/runtime/native/styles/functions/transform-functions.d.ts +5 -0
  229. package/dist/typescript/commonjs/src/runtime/native/styles/functions/transform-functions.d.ts.map +1 -0
  230. package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts.map +1 -1
  231. package/dist/typescript/commonjs/src/runtime/native/styles/{shorthand.d.ts → shorthands/_handler.d.ts} +2 -2
  232. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/_handler.d.ts.map +1 -0
  233. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/animation.d.ts +4 -0
  234. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/animation.d.ts.map +1 -0
  235. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/border.d.ts +2 -0
  236. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/border.d.ts.map +1 -0
  237. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/box-shadow.d.ts +3 -0
  238. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/box-shadow.d.ts.map +1 -0
  239. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/index.d.ts +6 -0
  240. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/index.d.ts.map +1 -0
  241. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/text-shadow.d.ts +2 -0
  242. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/text-shadow.d.ts.map +1 -0
  243. package/dist/typescript/commonjs/src/runtime/native/styles/{transform.d.ts → shorthands/transform.d.ts} +1 -1
  244. package/dist/typescript/commonjs/src/runtime/native/styles/shorthands/transform.d.ts.map +1 -0
  245. package/dist/typescript/commonjs/src/runtime/native/styles/units.d.ts.map +1 -1
  246. package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts.map +1 -1
  247. package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts.map +1 -1
  248. package/dist/typescript/commonjs/src/runtime/utils/specificity.d.ts +1 -0
  249. package/dist/typescript/commonjs/src/runtime/utils/specificity.d.ts.map +1 -1
  250. package/dist/typescript/module/src/compiler/atRules.d.ts.map +1 -1
  251. package/dist/typescript/module/src/compiler/compiler.d.ts +9 -2
  252. package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
  253. package/dist/typescript/module/src/compiler/compiler.types.d.ts +5 -4
  254. package/dist/typescript/module/src/compiler/compiler.types.d.ts.map +1 -1
  255. package/dist/typescript/module/src/compiler/declarations.d.ts +16 -19
  256. package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
  257. package/dist/typescript/module/src/compiler/selector-builder.d.ts +23 -0
  258. package/dist/typescript/module/src/compiler/selector-builder.d.ts.map +1 -0
  259. package/dist/typescript/module/src/compiler/selectors.d.ts +3 -2
  260. package/dist/typescript/module/src/compiler/selectors.d.ts.map +1 -1
  261. package/dist/typescript/module/src/compiler/stylesheet.d.ts +21 -7
  262. package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -1
  263. package/dist/typescript/module/src/jest/index.d.ts +20 -3
  264. package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
  265. package/dist/typescript/module/src/metro/index.d.ts.map +1 -1
  266. package/dist/typescript/module/src/poison.pill.d.ts.map +1 -1
  267. package/dist/typescript/module/src/runtime/native/conditions/attributes.d.ts +5 -0
  268. package/dist/typescript/module/src/runtime/native/conditions/attributes.d.ts.map +1 -0
  269. package/dist/typescript/module/src/runtime/native/conditions/container-query.d.ts +3 -3
  270. package/dist/typescript/module/src/runtime/native/conditions/container-query.d.ts.map +1 -1
  271. package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts +2 -2
  272. package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts.map +1 -1
  273. package/dist/typescript/module/src/runtime/native/conditions/index.d.ts +2 -2
  274. package/dist/typescript/module/src/runtime/native/conditions/index.d.ts.map +1 -1
  275. package/dist/typescript/module/src/runtime/native/conditions/media-query.d.ts +2 -2
  276. package/dist/typescript/module/src/runtime/native/conditions/media-query.d.ts.map +1 -1
  277. package/dist/typescript/module/src/runtime/native/injection.d.ts.map +1 -1
  278. package/dist/typescript/module/src/runtime/native/react/interaction.d.ts +2 -2
  279. package/dist/typescript/module/src/runtime/native/react/interaction.d.ts.map +1 -1
  280. package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts +2 -1
  281. package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts.map +1 -1
  282. package/dist/typescript/module/src/runtime/native/reactivity.d.ts +2 -10
  283. package/dist/typescript/module/src/runtime/native/reactivity.d.ts.map +1 -1
  284. package/dist/typescript/module/src/runtime/native/reanimated.d.ts +5 -0
  285. package/dist/typescript/module/src/runtime/native/reanimated.d.ts.map +1 -0
  286. package/dist/typescript/module/src/runtime/native/root.d.ts +11 -0
  287. package/dist/typescript/module/src/runtime/native/root.d.ts.map +1 -0
  288. package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts.map +1 -1
  289. package/dist/typescript/module/src/runtime/native/styles/defaults.d.ts.map +1 -1
  290. package/dist/typescript/module/src/runtime/native/styles/functions/animation-timing.d.ts +4 -0
  291. package/dist/typescript/module/src/runtime/native/styles/functions/animation-timing.d.ts.map +1 -0
  292. package/dist/typescript/module/src/runtime/native/styles/functions/calc.d.ts +3 -0
  293. package/dist/typescript/module/src/runtime/native/styles/functions/calc.d.ts.map +1 -0
  294. package/dist/typescript/module/src/runtime/native/styles/{filters.d.ts → functions/filters.d.ts} +1 -1
  295. package/dist/typescript/module/src/runtime/native/styles/functions/filters.d.ts.map +1 -0
  296. package/dist/typescript/module/src/runtime/native/styles/functions/index.d.ts +6 -0
  297. package/dist/typescript/module/src/runtime/native/styles/functions/index.d.ts.map +1 -0
  298. package/dist/typescript/module/src/runtime/native/styles/{platform-functions.d.ts → functions/platform-functions.d.ts} +2 -2
  299. package/dist/typescript/module/src/runtime/native/styles/functions/platform-functions.d.ts.map +1 -0
  300. package/dist/typescript/module/src/runtime/native/styles/functions/transform-functions.d.ts +5 -0
  301. package/dist/typescript/module/src/runtime/native/styles/functions/transform-functions.d.ts.map +1 -0
  302. package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts.map +1 -1
  303. package/dist/typescript/module/src/runtime/native/styles/{shorthand.d.ts → shorthands/_handler.d.ts} +2 -2
  304. package/dist/typescript/module/src/runtime/native/styles/shorthands/_handler.d.ts.map +1 -0
  305. package/dist/typescript/module/src/runtime/native/styles/shorthands/animation.d.ts +4 -0
  306. package/dist/typescript/module/src/runtime/native/styles/shorthands/animation.d.ts.map +1 -0
  307. package/dist/typescript/module/src/runtime/native/styles/shorthands/border.d.ts +2 -0
  308. package/dist/typescript/module/src/runtime/native/styles/shorthands/border.d.ts.map +1 -0
  309. package/dist/typescript/module/src/runtime/native/styles/shorthands/box-shadow.d.ts +3 -0
  310. package/dist/typescript/module/src/runtime/native/styles/shorthands/box-shadow.d.ts.map +1 -0
  311. package/dist/typescript/module/src/runtime/native/styles/shorthands/index.d.ts +6 -0
  312. package/dist/typescript/module/src/runtime/native/styles/shorthands/index.d.ts.map +1 -0
  313. package/dist/typescript/module/src/runtime/native/styles/shorthands/text-shadow.d.ts +2 -0
  314. package/dist/typescript/module/src/runtime/native/styles/shorthands/text-shadow.d.ts.map +1 -0
  315. package/dist/typescript/module/src/runtime/native/styles/{transform.d.ts → shorthands/transform.d.ts} +1 -1
  316. package/dist/typescript/module/src/runtime/native/styles/shorthands/transform.d.ts.map +1 -0
  317. package/dist/typescript/module/src/runtime/native/styles/units.d.ts.map +1 -1
  318. package/dist/typescript/module/src/runtime/native/styles/variables.d.ts.map +1 -1
  319. package/dist/typescript/module/src/runtime/utils/objects.d.ts.map +1 -1
  320. package/dist/typescript/module/src/runtime/utils/specificity.d.ts +1 -0
  321. package/dist/typescript/module/src/runtime/utils/specificity.d.ts.map +1 -1
  322. package/package.json +4 -3
  323. package/src/compiler/atRules.ts +17 -3
  324. package/src/compiler/attributes.test.ts +1 -1
  325. package/src/compiler/compiler.ts +30 -31
  326. package/src/compiler/compiler.types.ts +7 -5
  327. package/src/compiler/declarations.ts +351 -114
  328. package/src/compiler/inheritance.test.ts +6 -6
  329. package/src/compiler/keyframes.ts +1 -1
  330. package/src/compiler/selector-builder.ts +531 -0
  331. package/src/compiler/selectors.ts +20 -6
  332. package/src/compiler/stylesheet.ts +168 -48
  333. package/src/jest/index.ts +41 -8
  334. package/src/metro/index.ts +6 -3
  335. package/src/poison.pill.ts +5 -1
  336. package/src/runtime/native/conditions/attributes.ts +52 -0
  337. package/src/runtime/native/conditions/container-query.ts +27 -22
  338. package/src/runtime/native/conditions/guards.ts +1 -2
  339. package/src/runtime/native/conditions/index.ts +12 -66
  340. package/src/runtime/native/conditions/media-query.ts +20 -20
  341. package/src/runtime/native/injection.ts +1 -1
  342. package/src/runtime/native/react/interaction.ts +12 -12
  343. package/src/runtime/native/react/rules.ts +9 -9
  344. package/src/runtime/native/react/useNativeCss.ts +4 -1
  345. package/src/runtime/native/reactivity.ts +2 -21
  346. package/src/runtime/native/reanimated.ts +22 -0
  347. package/src/runtime/native/root.ts +31 -0
  348. package/src/runtime/native/styles/calculate-props.ts +61 -50
  349. package/src/runtime/native/styles/defaults.ts +1 -0
  350. package/src/runtime/native/styles/functions/animation-timing.ts +44 -0
  351. package/src/runtime/native/styles/{calc.ts → functions/calc.ts} +2 -2
  352. package/src/runtime/native/styles/{filters.ts → functions/filters.ts} +3 -3
  353. package/src/runtime/native/styles/functions/index.ts +5 -0
  354. package/src/runtime/native/styles/{platform-functions.ts → functions/platform-functions.ts} +2 -2
  355. package/src/runtime/native/styles/functions/transform-functions.ts +51 -0
  356. package/src/runtime/native/styles/index.ts +12 -12
  357. package/src/runtime/native/styles/resolve.ts +20 -63
  358. package/src/runtime/native/styles/{shorthand.ts → shorthands/_handler.ts} +5 -5
  359. package/src/runtime/native/styles/{animation.ts → shorthands/animation.ts} +4 -63
  360. package/src/runtime/native/styles/{border.ts → shorthands/border.ts} +1 -1
  361. package/src/runtime/native/styles/{box-shadow.ts → shorthands/box-shadow.ts} +3 -3
  362. package/src/runtime/native/styles/shorthands/index.ts +5 -0
  363. package/src/runtime/native/styles/{text-shadow.ts → shorthands/text-shadow.ts} +1 -1
  364. package/src/runtime/native/styles/{transform.ts → shorthands/transform.ts} +1 -1
  365. package/src/runtime/native/styles/units.ts +8 -4
  366. package/src/runtime/native/styles/variables.ts +2 -6
  367. package/src/runtime/utils/objects.ts +24 -3
  368. package/src/runtime/utils/specificity.ts +1 -0
  369. package/dist/commonjs/runtime/native/styles/animation.js.map +0 -1
  370. package/dist/commonjs/runtime/native/styles/border.js.map +0 -1
  371. package/dist/commonjs/runtime/native/styles/box-shadow.js.map +0 -1
  372. package/dist/commonjs/runtime/native/styles/calc.js.map +0 -1
  373. package/dist/commonjs/runtime/native/styles/filters.js.map +0 -1
  374. package/dist/commonjs/runtime/native/styles/platform-functions.js.map +0 -1
  375. package/dist/commonjs/runtime/native/styles/shorthand.js.map +0 -1
  376. package/dist/commonjs/runtime/native/styles/text-shadow.js.map +0 -1
  377. package/dist/commonjs/runtime/native/styles/transform.js.map +0 -1
  378. package/dist/module/runtime/native/styles/animation.js.map +0 -1
  379. package/dist/module/runtime/native/styles/border.js.map +0 -1
  380. package/dist/module/runtime/native/styles/box-shadow.js.map +0 -1
  381. package/dist/module/runtime/native/styles/calc.js.map +0 -1
  382. package/dist/module/runtime/native/styles/filters.js.map +0 -1
  383. package/dist/module/runtime/native/styles/platform-functions.js.map +0 -1
  384. package/dist/module/runtime/native/styles/shorthand.js.map +0 -1
  385. package/dist/module/runtime/native/styles/text-shadow.js.map +0 -1
  386. package/dist/module/runtime/native/styles/transform.js.map +0 -1
  387. package/dist/typescript/commonjs/src/runtime/native/styles/animation.d.ts +0 -9
  388. package/dist/typescript/commonjs/src/runtime/native/styles/animation.d.ts.map +0 -1
  389. package/dist/typescript/commonjs/src/runtime/native/styles/border.d.ts +0 -2
  390. package/dist/typescript/commonjs/src/runtime/native/styles/border.d.ts.map +0 -1
  391. package/dist/typescript/commonjs/src/runtime/native/styles/box-shadow.d.ts +0 -3
  392. package/dist/typescript/commonjs/src/runtime/native/styles/box-shadow.d.ts.map +0 -1
  393. package/dist/typescript/commonjs/src/runtime/native/styles/calc.d.ts +0 -3
  394. package/dist/typescript/commonjs/src/runtime/native/styles/calc.d.ts.map +0 -1
  395. package/dist/typescript/commonjs/src/runtime/native/styles/filters.d.ts.map +0 -1
  396. package/dist/typescript/commonjs/src/runtime/native/styles/platform-functions.d.ts.map +0 -1
  397. package/dist/typescript/commonjs/src/runtime/native/styles/shorthand.d.ts.map +0 -1
  398. package/dist/typescript/commonjs/src/runtime/native/styles/text-shadow.d.ts +0 -2
  399. package/dist/typescript/commonjs/src/runtime/native/styles/text-shadow.d.ts.map +0 -1
  400. package/dist/typescript/commonjs/src/runtime/native/styles/transform.d.ts.map +0 -1
  401. package/dist/typescript/module/src/runtime/native/styles/animation.d.ts +0 -9
  402. package/dist/typescript/module/src/runtime/native/styles/animation.d.ts.map +0 -1
  403. package/dist/typescript/module/src/runtime/native/styles/border.d.ts +0 -2
  404. package/dist/typescript/module/src/runtime/native/styles/border.d.ts.map +0 -1
  405. package/dist/typescript/module/src/runtime/native/styles/box-shadow.d.ts +0 -3
  406. package/dist/typescript/module/src/runtime/native/styles/box-shadow.d.ts.map +0 -1
  407. package/dist/typescript/module/src/runtime/native/styles/calc.d.ts +0 -3
  408. package/dist/typescript/module/src/runtime/native/styles/calc.d.ts.map +0 -1
  409. package/dist/typescript/module/src/runtime/native/styles/filters.d.ts.map +0 -1
  410. package/dist/typescript/module/src/runtime/native/styles/platform-functions.d.ts.map +0 -1
  411. package/dist/typescript/module/src/runtime/native/styles/shorthand.d.ts.map +0 -1
  412. package/dist/typescript/module/src/runtime/native/styles/text-shadow.d.ts +0 -2
  413. package/dist/typescript/module/src/runtime/native/styles/text-shadow.d.ts.map +0 -1
  414. package/dist/typescript/module/src/runtime/native/styles/transform.d.ts.map +0 -1
  415. /package/dist/commonjs/runtime/native/styles/{transform.js → shorthands/transform.js} +0 -0
  416. /package/dist/module/runtime/native/styles/{transform.js → shorthands/transform.js} +0 -0
@@ -1,3 +1,5 @@
1
+ import type { SelectorList } from "lightningcss";
2
+
1
3
  import {
2
4
  isStyleDescriptorArray,
3
5
  Specificity,
@@ -17,8 +19,9 @@ import type {
17
19
  StyleRuleMapping,
18
20
  StyleRuleSet,
19
21
  VariableRecord,
22
+ VariableValue,
20
23
  } from "./compiler.types";
21
- import { toRNProperty, type NormalizeSelector } from "./selectors";
24
+ import { getClassNameSelectors, toRNProperty } from "./selector-builder";
22
25
 
23
26
  type BuilderMode = "style" | "media" | "container" | "keyframes";
24
27
 
@@ -29,6 +32,8 @@ const staticDeclarations = new WeakMap<
29
32
 
30
33
  const extraRules = new WeakMap<StyleRule, Partial<StyleRule>[]>();
31
34
 
35
+ const keywords = new Set(["unset"]);
36
+
32
37
  export class StylesheetBuilder {
33
38
  animationFrames?: AnimationKeyframes_V2[];
34
39
  animationDeclarations: StyleDeclaration[] = [];
@@ -47,6 +52,7 @@ export class StylesheetBuilder {
47
52
  private ruleTemplate: StyleRule = {
48
53
  s: [],
49
54
  },
55
+ // Any default mapping should be included in the @prop parsing
50
56
  private mapping: StyleRuleMapping = {},
51
57
  public descriptorProperty?: string,
52
58
  private shared: {
@@ -56,15 +62,37 @@ export class StylesheetBuilder {
56
62
  animations?: AnimationRecord;
57
63
  rem: number;
58
64
  ruleOrder: number;
59
- } = { ruleSets: {}, rem: 14, ruleOrder: 0 },
60
- private selectors?: NormalizeSelector[],
65
+ warningProperty?: string;
66
+ warningProperties: string[];
67
+ warningValues: Record<string, unknown[]>;
68
+ warningFunctions: string[];
69
+ } = {
70
+ ruleSets: {},
71
+ rem: 14,
72
+ ruleOrder: 0,
73
+ warningProperties: [],
74
+ warningValues: {},
75
+ warningFunctions: [],
76
+ },
77
+ private selectors: SelectorList = [],
61
78
  ) {}
62
79
 
63
- fork(
64
- mode = this.mode,
65
- selectors: NormalizeSelector[] | undefined = this.selectors,
66
- ): StylesheetBuilder {
80
+ fork(mode = this.mode, selectors: SelectorList = []): StylesheetBuilder {
67
81
  this.shared.ruleOrder++;
82
+
83
+ /**
84
+ * If we already have selectors and we are added more
85
+ * Then these must be nested selectors.
86
+ *
87
+ * We need to extrapolate out the selectors to their full values
88
+ */
89
+ selectors =
90
+ this.selectors.length && selectors.length
91
+ ? this.selectors.flatMap((selectorA) => {
92
+ return selectors.map((selectorB) => [...selectorA, ...selectorB]);
93
+ })
94
+ : [...this.selectors, ...selectors];
95
+
68
96
  return new StylesheetBuilder(
69
97
  this.options,
70
98
  mode,
@@ -76,7 +104,7 @@ export class StylesheetBuilder {
76
104
  );
77
105
  }
78
106
 
79
- cloneRule({ ...rule } = this.rule): StyleRule {
107
+ cloneRule({ ...rule } = this.ruleTemplate): StyleRule {
80
108
  rule.s = [...rule.s];
81
109
  rule.aq &&= [...rule.aq];
82
110
  rule.c &&= [...rule.c];
@@ -128,11 +156,17 @@ export class StylesheetBuilder {
128
156
  }
129
157
 
130
158
  if (this.shared.rootVariables) {
131
- stylesheetOptions.vr = Object.entries(this.shared.rootVariables);
159
+ stylesheetOptions.vr = Object.entries(this.shared.rootVariables).map(
160
+ // Reverse these so the most specific variables are first
161
+ ([key, value]) => [key, value.reverse()] as const,
162
+ );
132
163
  }
133
164
 
134
165
  if (this.shared.universalVariables) {
135
- stylesheetOptions.vu = Object.entries(this.shared.universalVariables);
166
+ stylesheetOptions.vu = Object.entries(this.shared.universalVariables).map(
167
+ // Reverse these so the most specific variables are first
168
+ ([key, value]) => [key, value.reverse()] as const,
169
+ );
136
170
  }
137
171
 
138
172
  if (this.shared.animations) {
@@ -155,11 +189,64 @@ export class StylesheetBuilder {
155
189
  );
156
190
  }
157
191
 
192
+ setWarningProperty(property: string) {
193
+ this.shared.warningProperty = property;
194
+ }
195
+
196
+ addWarning(type: "property" | "value", property: string): void;
197
+ addWarning(type: "style", property: string, value: unknown): void;
158
198
  addWarning(
159
- _type: "property" | "value" | "function",
160
- _property: string | number,
199
+ type: "property" | "style" | "value",
200
+ property: string,
201
+ value?: unknown,
161
202
  ): void {
162
- // TODO
203
+ switch (type) {
204
+ case "property":
205
+ this.shared.warningProperties.push(property);
206
+ break;
207
+ case "value": {
208
+ value = property;
209
+ property = this.shared.warningProperty ?? "";
210
+
211
+ if (!property) {
212
+ return;
213
+ }
214
+
215
+ this.shared.warningValues[property] ??= [];
216
+ this.shared.warningValues[property]?.push(value);
217
+ break;
218
+ }
219
+ case "style":
220
+ this.shared.warningValues[property] ??= [];
221
+ this.shared.warningValues[property]?.push(value);
222
+ break;
223
+ }
224
+ }
225
+
226
+ getWarnings() {
227
+ const result: {
228
+ properties?: string[];
229
+ values?: Record<string, unknown[]>;
230
+ functions?: string[];
231
+ } = {};
232
+
233
+ if (this.shared.warningProperties.length) {
234
+ result.properties = this.shared.warningProperties;
235
+ }
236
+
237
+ if (Object.keys(this.shared.warningValues).length) {
238
+ result.values = this.shared.warningValues;
239
+ }
240
+
241
+ if (this.shared.warningFunctions.length) {
242
+ result.functions = this.shared.warningFunctions;
243
+ }
244
+
245
+ return result;
246
+ }
247
+
248
+ addMapping(mapping: StyleRuleMapping) {
249
+ this.mapping = { ...this.mapping, ...mapping };
163
250
  }
164
251
 
165
252
  newRule(mapping = this.mapping, { important = false } = {}) {
@@ -171,14 +258,12 @@ export class StylesheetBuilder {
171
258
  }
172
259
  }
173
260
 
174
- newRuleFork({ important = false } = {}) {
175
- this.rule = this.cloneRule(this.rule);
176
- this.rule.s[Specificity.Order] = this.shared.ruleOrder;
177
- if (important) {
178
- this.rule.s[Specificity.Important] = 1;
179
- }
261
+ /** Used by nested declarations (for example @media inside a RuleSet) */
262
+ newNestedRule({ important = false } = {}) {
263
+ this.newRule(this.mapping, { important });
180
264
  }
181
265
 
266
+ /** Hack for light-dark, which requires adding a new rule without changing the current rule */
182
267
  addExtraRule(rule: Partial<StyleRule>) {
183
268
  let extraRuleArray = extraRules.get(this.rule);
184
269
  if (!extraRuleArray) {
@@ -197,8 +282,8 @@ export class StylesheetBuilder {
197
282
  }
198
283
 
199
284
  addMediaQuery(condition: MediaCondition) {
200
- this.rule.m ??= [];
201
- this.rule.m.push(condition);
285
+ this.ruleTemplate.m ??= [];
286
+ this.ruleTemplate.m.push(condition);
202
287
  }
203
288
 
204
289
  addContainer(value: string[] | false) {
@@ -257,7 +342,10 @@ export class StylesheetBuilder {
257
342
  const [delayed, usesVariables] = postProcessStyleFunction(value);
258
343
 
259
344
  rule.d ??= [];
260
- if (value[1] === "@animation") {
345
+ if (
346
+ value[1].startsWith("animation") ||
347
+ value[1].startsWith("transition")
348
+ ) {
261
349
  rule.a ??= true;
262
350
  }
263
351
 
@@ -297,30 +385,29 @@ export class StylesheetBuilder {
297
385
  }
298
386
 
299
387
  private pushDescriptor(
300
- property: string,
388
+ rawProperty: string,
301
389
  value: StyleDescriptor,
302
390
  declarations: StyleDeclaration[],
303
391
  forceTuple = false,
304
392
  delayed = false,
305
393
  ) {
306
- property = toRNProperty(property);
394
+ const property = toRNProperty(rawProperty);
307
395
 
308
- let propPath: string | string[] =
309
- this.mapping[property] ?? this.mapping["*"] ?? property;
396
+ let propPath: string | string[] | undefined =
397
+ this.mapping[rawProperty] ?? this.mapping[property] ?? this.mapping["*"];
310
398
 
311
399
  if (Array.isArray(propPath)) {
312
- const first = propPath[0];
400
+ const [first, second] = propPath;
313
401
 
314
- if (!first) {
315
- // This should not happen, but if it does, we skip the property
316
- return;
317
- }
318
-
319
- if (propPath.length === 1) {
320
- propPath = first;
402
+ if (propPath.length === 2 && first === "*" && second) {
403
+ propPath = second;
321
404
  } else {
322
405
  forceTuple = true;
323
406
  }
407
+ } else if (propPath) {
408
+ forceTuple = true;
409
+ } else {
410
+ propPath = property;
324
411
  }
325
412
 
326
413
  if (isStyleFunction(value)) {
@@ -330,9 +417,14 @@ export class StylesheetBuilder {
330
417
  declarations.push([value, propPath]);
331
418
  }
332
419
  } else if (forceTuple || Array.isArray(propPath)) {
333
- declarations.push([value, propPath]);
420
+ declarations.push([
421
+ value,
422
+ Array.isArray(propPath) ? propPath : [propPath],
423
+ ]);
334
424
  } else if (Array.isArray(value) && value.some(isStyleFunction)) {
335
425
  declarations.push([value, propPath]);
426
+ } else if (typeof value === "string" && keywords.has(value)) {
427
+ declarations.push([value, propPath]);
336
428
  } else {
337
429
  let staticDeclarationRecord = staticDeclarations.get(declarations);
338
430
  if (!staticDeclarationRecord) {
@@ -345,17 +437,23 @@ export class StylesheetBuilder {
345
437
  }
346
438
 
347
439
  applyRuleToSelectors(selectorList = this.selectors): void {
348
- if (!selectorList?.length) {
440
+ if (!selectorList.length) {
349
441
  // If there are no selectors, we cannot apply the rule
350
442
  return;
351
443
  }
352
444
 
353
- if (!this.rule.d && !this.rule.v) {
445
+ if (!this.rule.d && !this.rule.v && !this.rule.c) {
354
446
  return;
355
447
  }
356
448
 
357
- for (const selector of selectorList) {
358
- const rule = this.cloneRule();
449
+ const normalizedSelectors = getClassNameSelectors(
450
+ selectorList,
451
+ this.options,
452
+ );
453
+
454
+ for (const selector of normalizedSelectors) {
455
+ // We are going to be apply the current rule to n selectors, so we clone the rule
456
+ const rule = this.cloneRule(this.rule);
359
457
 
360
458
  if (selector.type === "className") {
361
459
  const {
@@ -367,6 +465,10 @@ export class StylesheetBuilder {
367
465
  attributeQuery,
368
466
  } = selector;
369
467
 
468
+ if (!className) {
469
+ continue; // No className, nothing to do
470
+ }
471
+
370
472
  // Combine the specificity of the selector with the rule's specificity
371
473
  for (let i = 0; i < specificity.length; i++) {
372
474
  const spec = specificity[i];
@@ -390,14 +492,29 @@ export class StylesheetBuilder {
390
492
  continue;
391
493
  }
392
494
 
495
+ const [first, ...rest] = name.split(".");
496
+
497
+ if (typeof first !== "string") {
498
+ continue;
499
+ }
500
+
393
501
  const containerRule: StyleRule = {
394
502
  // These are not "real" rules, so they use the lowest specificity
395
503
  s: [0],
396
504
  c: [name],
397
505
  };
398
506
 
507
+ if (rest.length) {
508
+ containerRule.aq = rest.map((attr) => [
509
+ "a",
510
+ "className",
511
+ "*=",
512
+ attr,
513
+ ]);
514
+ }
515
+
399
516
  // Create rules for the parent classes
400
- this.addRuleToRuleSet(name, containerRule);
517
+ this.addRuleToRuleSet(first, containerRule);
401
518
  }
402
519
  }
403
520
 
@@ -426,21 +543,24 @@ export class StylesheetBuilder {
426
543
  if (!this.rule.v) {
427
544
  continue;
428
545
  }
429
-
430
- const { type, subtype } = selector;
431
-
546
+ const { type } = selector;
432
547
  for (const [name, value] of this.rule.v) {
433
548
  this.shared[type] ??= {};
434
- this.shared[type][name] ??= [undefined];
435
- this.shared[type][name][subtype === "light" ? 0 : 1] = value;
549
+ this.shared[type][name] ??= [];
550
+ const mediaQueries = this.rule.m;
551
+ const variableValue: VariableValue = mediaQueries
552
+ ? [value, [...mediaQueries]]
553
+ : [value];
554
+ // Append extra media queries if they exist
555
+ this.shared[type][name].push(variableValue);
436
556
  }
437
557
  }
438
558
  }
439
559
  }
440
560
 
441
561
  addContainerQuery(query: ContainerQuery) {
442
- this.rule.cq ??= [];
443
- this.rule.cq.push(query);
562
+ this.ruleTemplate.cq ??= [];
563
+ this.ruleTemplate.cq.push(query);
444
564
  }
445
565
 
446
566
  newAnimationFrames(name: string) {
@@ -502,7 +622,7 @@ function postProcessStyleFunction(value: StyleDescriptor): [
502
622
  let [shouldDelay, usesVariables] = postProcessStyleFunction(value[2]);
503
623
 
504
624
  usesVariables ||= value[1] === "var";
505
- shouldDelay ||= value[3] === 1;
625
+ shouldDelay ||= value[3] === 1 || usesVariables;
506
626
 
507
627
  if (shouldDelay) {
508
628
  return [true, usesVariables];
package/src/jest/index.ts CHANGED
@@ -1,5 +1,7 @@
1
1
  import { Appearance, Dimensions } from "react-native";
2
2
 
3
+ import { inspect } from "node:util";
4
+
3
5
  import { compile, type CompilerOptions } from "../compiler";
4
6
  import { StyleCollection } from "../runtime/native/injection";
5
7
  import { colorScheme, dimensions, rem } from "../runtime/native/reactivity";
@@ -23,19 +25,50 @@ beforeEach(() => {
23
25
  colorScheme.set(null);
24
26
  });
25
27
 
28
+ const debugDefault = Boolean(
29
+ process.env.REACT_NATIVE_CSS_TEST_DEBUG &&
30
+ process.env.NODE_OPTIONS?.includes("--inspect"),
31
+ );
32
+
26
33
  export function registerCSS(
27
34
  css: string,
28
- {
29
- debugCompiled = process.env.NODE_OPTIONS?.includes("--inspect"),
30
- ...options
31
- }: CompilerOptions & { debugCompiled?: boolean } = {},
35
+ options: CompilerOptions & { debug?: boolean } = {},
32
36
  ) {
33
- const compiled = compile(css, options);
34
- if (debugCompiled) {
35
- console.log(`Compiled styles:\n\n${JSON.stringify({ compiled }, null, 2)}`);
37
+ const { debug = debugDefault } = options;
38
+ const compiled = compileWithAutoDebug(css, options);
39
+
40
+ if (debug) {
41
+ console.log(
42
+ `Compiled:\n---\n${inspect(
43
+ {
44
+ stylesheet: compiled.stylesheet(),
45
+ warnings: compiled.warnings(),
46
+ },
47
+ { depth: null, colors: true, compact: false },
48
+ )}`,
49
+ );
36
50
  }
37
51
 
38
- StyleCollection.inject(compiled);
52
+ StyleCollection.inject(compiled.stylesheet());
39
53
 
40
54
  return compiled;
41
55
  }
56
+
57
+ export function compileWithAutoDebug(
58
+ css: string,
59
+ {
60
+ debug = debugDefault,
61
+ ...options
62
+ }: CompilerOptions & { debug?: boolean } = {},
63
+ ) {
64
+ const logger = debug
65
+ ? (text: string) => {
66
+ // Just log the rules
67
+ if (text.startsWith("[")) {
68
+ console.log(`Rules:\n---\n${text}`);
69
+ }
70
+ }
71
+ : undefined;
72
+
73
+ return compile(css, { ...options, logger });
74
+ }
@@ -6,7 +6,7 @@ import connect from "connect";
6
6
  import debug from "debug";
7
7
  import type { MetroConfig } from "metro-config";
8
8
 
9
- import type { CompilerOptions } from "../compiler";
9
+ import type { CompilerOptions, ReactNativeCssStyleSheet_V2 } from "../compiler";
10
10
  import { compile } from "../compiler/compiler";
11
11
  import { getNativeInjectionCode, getWebInjectionCode } from "./injection-code";
12
12
  import { nativeResolver, webResolver } from "./resolver";
@@ -93,7 +93,10 @@ export function withReactNativeCSS<
93
93
  if (!bundler.__react_native_css__patched) {
94
94
  bundler.__react_native_css__patched = true;
95
95
 
96
- const nativeCSSFiles = new Map();
96
+ const nativeCSSFiles = new Map<
97
+ string,
98
+ [string, ReactNativeCssStyleSheet_V2]
99
+ >();
97
100
  const webCSSFiles = new Set<string>();
98
101
 
99
102
  const nativeInjectionPath = require.resolve(
@@ -174,7 +177,7 @@ export function withReactNativeCSS<
174
177
  next,
175
178
  compile(next, {
176
179
  hexColors: options?.hexColors,
177
- }),
180
+ }).stylesheet(),
178
181
  ]);
179
182
 
180
183
  watcher.emit("change", {
@@ -1,4 +1,7 @@
1
- throw new Error(`react-native-css has encountered a setup error.
1
+ const canWarn = process.env.NODE_ENV !== "test";
2
+
3
+ if (canWarn) {
4
+ throw new Error(`react-native-css has encountered a setup error.
2
5
 
3
6
  ┌─────-─┐
4
7
  | Metro |
@@ -28,5 +31,6 @@ If you are using NativeWind with the 'withNativeWind' function, follow the Metro
28
31
 
29
32
  If you are using another bundler (Vite, Webpack, etc), or non-Metro framework (Next.js, Remix, etc), please ensure you have included 'react-native-css/babel' as a babel preset.
30
33
  `);
34
+ }
31
35
 
32
36
  export {};
@@ -0,0 +1,52 @@
1
+ import type { AttributeQuery } from "../../../compiler";
2
+ import type { Props } from "../../runtime.types";
3
+ import type { RenderGuard } from "./guards";
4
+
5
+ export function testAttributes(
6
+ queries: AttributeQuery[],
7
+ props: Props,
8
+ guards: RenderGuard[],
9
+ ) {
10
+ return queries.every((query) => testAttribute(query, props, guards));
11
+ }
12
+
13
+ function testAttribute(
14
+ [type, prop, operator, testValue]: AttributeQuery,
15
+ props: Props,
16
+ guards: RenderGuard[],
17
+ ) {
18
+ let value: unknown;
19
+
20
+ if (type === "a") {
21
+ value = props?.[prop];
22
+ } else {
23
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
24
+ value = props?.dataSet?.[prop];
25
+ }
26
+
27
+ guards.push([type, prop, value]);
28
+
29
+ if (!operator) {
30
+ return value !== undefined && value !== null && value !== false;
31
+ }
32
+
33
+ switch (operator) {
34
+ case "!":
35
+ return !value;
36
+ case "=":
37
+ return value == testValue;
38
+ case "~=":
39
+ return testValue && value?.toString().split(" ").includes(testValue);
40
+ case "|=":
41
+ return testValue && value?.toString().startsWith(testValue + "-");
42
+ case "^=":
43
+ return testValue && value?.toString().startsWith(testValue);
44
+ case "$=":
45
+ return testValue && value?.toString().endsWith(testValue);
46
+ case "*=":
47
+ return testValue && value?.toString().includes(testValue);
48
+ default:
49
+ operator satisfies never;
50
+ return false;
51
+ }
52
+ }
@@ -14,8 +14,9 @@ import {
14
14
  focusFamily,
15
15
  hoverFamily,
16
16
  type ContainerContextValue,
17
- type Effect,
17
+ type Getter,
18
18
  } from "../reactivity";
19
+ // import { testAttributes } from "./attributes";
19
20
  import type { RenderGuard } from "./guards";
20
21
 
21
22
  export const DEFAULT_CONTAINER_NAME = "c:___default___";
@@ -24,10 +25,10 @@ export function testContainerQueries(
24
25
  queries: ContainerQuery[],
25
26
  inheritedContainers: ContainerContextValue,
26
27
  guards: RenderGuard[],
27
- effect: Effect,
28
+ get: Getter,
28
29
  ) {
29
30
  return queries.every((query) => {
30
- return testContainerQuery(query, inheritedContainers, guards, effect);
31
+ return testContainerQuery(query, inheritedContainers, guards, get);
31
32
  });
32
33
  }
33
34
 
@@ -35,7 +36,7 @@ export function testContainerQuery(
35
36
  query: ContainerQuery,
36
37
  inheritedContainers: ContainerContextValue,
37
38
  guards: RenderGuard[],
38
- effect?: Effect,
39
+ get: Getter,
39
40
  ): boolean {
40
41
  const name = query.n ?? DEFAULT_CONTAINER_NAME;
41
42
  const container = inheritedContainers[name]!;
@@ -46,11 +47,15 @@ export function testContainerQuery(
46
47
  return false;
47
48
  }
48
49
 
49
- if (query.m && !testContainerMediaCondition(query.m, container, effect)) {
50
+ // if (query.a && !testAttributes(query.a, container.props, guards)) {
51
+ // return false;
52
+ // }
53
+
54
+ if (query.m && !testContainerMediaCondition(query.m, container, get)) {
50
55
  return false;
51
56
  }
52
57
 
53
- if (query.p && !testContainerPseudoCondition(query.p, container, effect)) {
58
+ if (query.p && !testContainerPseudoCondition(query.p, container, get)) {
54
59
  return false;
55
60
  }
56
61
 
@@ -60,15 +65,15 @@ export function testContainerQuery(
60
65
  function testContainerPseudoCondition(
61
66
  query: PseudoClassesQuery,
62
67
  containerKey: WeakKey,
63
- effect?: Effect,
68
+ get: Getter,
64
69
  ): boolean {
65
- if (query.h && !hoverFamily(containerKey).get(effect)) {
70
+ if (query.h && !get(hoverFamily(containerKey))) {
66
71
  return false;
67
72
  }
68
- if (query.a && !activeFamily(containerKey).get(effect)) {
73
+ if (query.a && !get(activeFamily(containerKey))) {
69
74
  return false;
70
75
  }
71
- if (query.f && !focusFamily(containerKey).get(effect)) {
76
+ if (query.f && !get(focusFamily(containerKey))) {
72
77
  return false;
73
78
  }
74
79
  return true;
@@ -77,18 +82,18 @@ function testContainerPseudoCondition(
77
82
  function testContainerMediaCondition(
78
83
  condition: MediaCondition,
79
84
  containerKey: WeakKey,
80
- effect?: Effect,
85
+ get: Getter,
81
86
  ): boolean {
82
87
  switch (condition[0]) {
83
88
  case "!":
84
- return !testContainerMediaCondition(condition[1], containerKey, effect);
89
+ return !testContainerMediaCondition(condition[1], containerKey, get);
85
90
  case "&":
86
91
  return condition[1].every((query) => {
87
- return testContainerMediaCondition(query, containerKey, effect);
92
+ return testContainerMediaCondition(query, containerKey, get);
88
93
  });
89
94
  case "|":
90
95
  return condition[1].some((query) => {
91
- return testContainerMediaCondition(query, containerKey, effect);
96
+ return testContainerMediaCondition(query, containerKey, get);
92
97
  });
93
98
  case "!!":
94
99
  return false;
@@ -99,7 +104,7 @@ function testContainerMediaCondition(
99
104
  case "<":
100
105
  case "<=":
101
106
  case "=": {
102
- const left = getContainerFeatureValue(condition[1], containerKey, effect);
107
+ const left = getContainerFeatureValue(condition[1], containerKey, get);
103
108
  const right = condition[2];
104
109
 
105
110
  if (condition[0] === "=") {
@@ -133,21 +138,21 @@ function testContainerMediaCondition(
133
138
  function getContainerFeatureValue(
134
139
  name: MediaFeatureNameFor_ContainerSizeFeatureId,
135
140
  containerKey: WeakKey,
136
- effect?: Effect,
141
+ get: Getter,
137
142
  ): StyleDescriptor {
138
143
  switch (name) {
139
144
  case "width":
140
- return containerWidthFamily(containerKey).get(effect);
145
+ return get(containerWidthFamily(containerKey));
141
146
  case "height":
142
- return containerHeightFamily(containerKey).get(effect);
147
+ return get(containerHeightFamily(containerKey));
143
148
  case "aspect-ratio": {
144
- const width = containerWidthFamily(containerKey).get(effect);
145
- const height = containerWidthFamily(containerKey).get(effect);
149
+ const width = get(containerWidthFamily(containerKey));
150
+ const height = get(containerHeightFamily(containerKey));
146
151
  return width / height;
147
152
  }
148
153
  case "orientation":
149
- const width = containerWidthFamily(containerKey).get(effect);
150
- const height = containerWidthFamily(containerKey).get(effect);
154
+ const width = get(containerWidthFamily(containerKey));
155
+ const height = get(containerHeightFamily(containerKey));
151
156
  return width > height ? "landscape" : "portrait";
152
157
  case "inline-size":
153
158
  case "block-size":
@@ -2,7 +2,6 @@
2
2
  import type { ComponentState } from "../react/useNativeCss";
3
3
  import type {
4
4
  ContainerContextValue,
5
- Effect,
6
5
  VariableContextValue,
7
6
  } from "../reactivity";
8
7
 
@@ -10,7 +9,7 @@ export type RenderGuard =
10
9
  | ["a", string, any]
11
10
  | ["d", string, any]
12
11
  | ["v", string, any]
13
- | ["c", string, Effect];
12
+ | ["c", string, WeakKey];
14
13
 
15
14
  export function testGuards(
16
15
  state: ComponentState,