react-native-css 3.0.0-nightly.4723140 → 3.0.0-nightly.61014be

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 (494) hide show
  1. package/README.md +184 -1
  2. package/dist/commonjs/babel/allowedModules.js +23 -0
  3. package/dist/commonjs/babel/allowedModules.js.map +1 -0
  4. package/dist/commonjs/babel/helpers.js +18 -122
  5. package/dist/commonjs/babel/helpers.js.map +1 -1
  6. package/dist/commonjs/babel/import-plugin.js +62 -58
  7. package/dist/commonjs/babel/import-plugin.js.map +1 -1
  8. package/dist/commonjs/babel/react-native-web.js +118 -0
  9. package/dist/commonjs/babel/react-native-web.js.map +1 -0
  10. package/dist/commonjs/babel/react-native.js +118 -0
  11. package/dist/commonjs/babel/react-native.js.map +1 -0
  12. package/dist/commonjs/compiler/atRules.js +101 -0
  13. package/dist/commonjs/compiler/atRules.js.map +1 -0
  14. package/dist/commonjs/compiler/attributes.test.js +20 -0
  15. package/dist/commonjs/compiler/attributes.test.js.map +1 -0
  16. package/dist/commonjs/compiler/compiler.js +143 -344
  17. package/dist/commonjs/compiler/compiler.js.map +1 -1
  18. package/dist/commonjs/compiler/compiler.types.js.map +1 -1
  19. package/dist/commonjs/compiler/container-query.js +10 -10
  20. package/dist/commonjs/compiler/container-query.js.map +1 -1
  21. package/dist/commonjs/compiler/declarations.js +1233 -988
  22. package/dist/commonjs/compiler/declarations.js.map +1 -1
  23. package/dist/commonjs/compiler/inheritance.test.js +78 -0
  24. package/dist/commonjs/compiler/inheritance.test.js.map +1 -0
  25. package/dist/commonjs/compiler/keyframes.js +15 -24
  26. package/dist/commonjs/compiler/keyframes.js.map +1 -1
  27. package/dist/commonjs/compiler/media-query.js +22 -22
  28. package/dist/commonjs/compiler/media-query.js.map +1 -1
  29. package/dist/commonjs/compiler/selectors.js +264 -184
  30. package/dist/commonjs/compiler/selectors.js.map +1 -1
  31. package/dist/commonjs/compiler/split-by-delimiter.js +21 -0
  32. package/dist/commonjs/compiler/split-by-delimiter.js.map +1 -0
  33. package/dist/commonjs/compiler/stylesheet.js +385 -0
  34. package/dist/commonjs/compiler/stylesheet.js.map +1 -0
  35. package/dist/commonjs/components/Text.js +2 -0
  36. package/dist/commonjs/components/Text.js.map +1 -1
  37. package/dist/commonjs/components/View.js +2 -0
  38. package/dist/commonjs/components/View.js.map +1 -1
  39. package/dist/commonjs/index.js +11 -0
  40. package/dist/commonjs/index.js.map +1 -1
  41. package/dist/commonjs/jest/index.js +2 -18
  42. package/dist/commonjs/jest/index.js.map +1 -1
  43. package/dist/commonjs/metro/index.js +111 -50
  44. package/dist/commonjs/metro/index.js.map +1 -1
  45. package/dist/commonjs/metro/injection-code.js +24 -4
  46. package/dist/commonjs/metro/injection-code.js.map +1 -1
  47. package/dist/commonjs/metro/resolver.js +62 -0
  48. package/dist/commonjs/metro/resolver.js.map +1 -0
  49. package/dist/commonjs/metro/typescript.js +1 -1
  50. package/dist/commonjs/poison.pill.js +36 -0
  51. package/dist/commonjs/poison.pill.js.map +1 -0
  52. package/dist/commonjs/runtime/native/conditions/guards.js +10 -4
  53. package/dist/commonjs/runtime/native/conditions/guards.js.map +1 -1
  54. package/dist/commonjs/runtime/native/conditions/media-query.js +2 -0
  55. package/dist/commonjs/runtime/native/conditions/media-query.js.map +1 -1
  56. package/dist/commonjs/runtime/native/index.js +11 -1
  57. package/dist/commonjs/runtime/native/index.js.map +1 -1
  58. package/dist/commonjs/runtime/native/injection.js +18 -0
  59. package/dist/commonjs/runtime/native/injection.js.map +1 -1
  60. package/dist/commonjs/runtime/native/react/rules.js +23 -27
  61. package/dist/commonjs/runtime/native/react/rules.js.map +1 -1
  62. package/dist/commonjs/runtime/native/reactivity.js +1 -5
  63. package/dist/commonjs/runtime/native/reactivity.js.map +1 -1
  64. package/dist/commonjs/runtime/native/styles/animation.js +70 -72
  65. package/dist/commonjs/runtime/native/styles/animation.js.map +1 -1
  66. package/dist/commonjs/runtime/native/styles/border.js +12 -0
  67. package/dist/commonjs/runtime/native/styles/border.js.map +1 -0
  68. package/dist/commonjs/runtime/native/styles/box-shadow.js +40 -0
  69. package/dist/commonjs/runtime/native/styles/box-shadow.js.map +1 -0
  70. package/dist/commonjs/runtime/native/styles/calc.js +33 -61
  71. package/dist/commonjs/runtime/native/styles/calc.js.map +1 -1
  72. package/dist/commonjs/runtime/native/styles/calculate-props.js +123 -0
  73. package/dist/commonjs/runtime/native/styles/calculate-props.js.map +1 -0
  74. package/dist/commonjs/runtime/native/styles/constants.js +2 -1
  75. package/dist/commonjs/runtime/native/styles/constants.js.map +1 -1
  76. package/dist/commonjs/runtime/native/styles/filters.js +84 -0
  77. package/dist/commonjs/runtime/native/styles/filters.js.map +1 -0
  78. package/dist/commonjs/runtime/native/styles/index.js +2 -110
  79. package/dist/commonjs/runtime/native/styles/index.js.map +1 -1
  80. package/dist/commonjs/runtime/native/styles/platform-functions.js +46 -0
  81. package/dist/commonjs/runtime/native/styles/platform-functions.js.map +1 -0
  82. package/dist/commonjs/runtime/native/styles/resolve.js +46 -13
  83. package/dist/commonjs/runtime/native/styles/resolve.js.map +1 -1
  84. package/dist/commonjs/runtime/native/styles/shorthand.js +34 -17
  85. package/dist/commonjs/runtime/native/styles/shorthand.js.map +1 -1
  86. package/dist/commonjs/runtime/native/styles/transform.js +9 -3
  87. package/dist/commonjs/runtime/native/styles/transform.js.map +1 -1
  88. package/dist/commonjs/runtime/native/styles/units.js +7 -4
  89. package/dist/commonjs/runtime/native/styles/units.js.map +1 -1
  90. package/dist/commonjs/runtime/native/styles/variables.js +57 -36
  91. package/dist/commonjs/runtime/native/styles/variables.js.map +1 -1
  92. package/dist/commonjs/runtime/utils/objects.js +18 -5
  93. package/dist/commonjs/runtime/utils/objects.js.map +1 -1
  94. package/dist/commonjs/runtime/utils/style-value.js +7 -0
  95. package/dist/commonjs/runtime/utils/style-value.js.map +1 -1
  96. package/dist/commonjs/runtime/web/index.js +1 -0
  97. package/dist/commonjs/runtime/web/index.js.map +1 -1
  98. package/dist/commonjs/runtime/web/metro.js +6 -0
  99. package/dist/commonjs/runtime/web/metro.js.map +1 -0
  100. package/dist/module/babel/allowedModules.js +19 -0
  101. package/dist/module/babel/allowedModules.js.map +1 -0
  102. package/dist/module/babel/helpers.js +17 -116
  103. package/dist/module/babel/helpers.js.map +1 -1
  104. package/dist/module/babel/import-plugin.js +63 -59
  105. package/dist/module/babel/import-plugin.js.map +1 -1
  106. package/dist/module/babel/react-native-web.js +112 -0
  107. package/dist/module/babel/react-native-web.js.map +1 -0
  108. package/dist/module/babel/react-native.js +112 -0
  109. package/dist/module/babel/react-native.js.map +1 -0
  110. package/dist/module/compiler/atRules.js +97 -0
  111. package/dist/module/compiler/atRules.js.map +1 -0
  112. package/dist/module/compiler/attributes.test.js +20 -0
  113. package/dist/module/compiler/attributes.test.js.map +1 -0
  114. package/dist/module/compiler/compiler.js +144 -345
  115. package/dist/module/compiler/compiler.js.map +1 -1
  116. package/dist/module/compiler/compiler.types.js +0 -12
  117. package/dist/module/compiler/compiler.types.js.map +1 -1
  118. package/dist/module/compiler/container-query.js +10 -10
  119. package/dist/module/compiler/container-query.js.map +1 -1
  120. package/dist/module/compiler/declarations.js +1172 -992
  121. package/dist/module/compiler/declarations.js.map +1 -1
  122. package/dist/module/compiler/inheritance.test.js +78 -0
  123. package/dist/module/compiler/inheritance.test.js.map +1 -0
  124. package/dist/module/compiler/keyframes.js +15 -24
  125. package/dist/module/compiler/keyframes.js.map +1 -1
  126. package/dist/module/compiler/media-query.js +22 -22
  127. package/dist/module/compiler/media-query.js.map +1 -1
  128. package/dist/module/compiler/selectors.js +264 -184
  129. package/dist/module/compiler/selectors.js.map +1 -1
  130. package/dist/module/compiler/split-by-delimiter.js +17 -0
  131. package/dist/module/compiler/split-by-delimiter.js.map +1 -0
  132. package/dist/module/compiler/stylesheet.js +380 -0
  133. package/dist/module/compiler/stylesheet.js.map +1 -0
  134. package/dist/module/components/Text.js +1 -0
  135. package/dist/module/components/Text.js.map +1 -1
  136. package/dist/module/components/View.js +1 -0
  137. package/dist/module/components/View.js.map +1 -1
  138. package/dist/module/index.js +1 -0
  139. package/dist/module/index.js.map +1 -1
  140. package/dist/module/jest/index.js +3 -3
  141. package/dist/module/jest/index.js.map +1 -1
  142. package/dist/module/metro/index.js +111 -50
  143. package/dist/module/metro/index.js.map +1 -1
  144. package/dist/module/metro/injection-code.js +22 -3
  145. package/dist/module/metro/injection-code.js.map +1 -1
  146. package/dist/module/metro/resolver.js +57 -0
  147. package/dist/module/metro/resolver.js.map +1 -0
  148. package/dist/module/metro/typescript.js +1 -1
  149. package/dist/module/poison.pill.js +34 -0
  150. package/dist/module/poison.pill.js.map +1 -0
  151. package/dist/module/runtime/native/conditions/guards.js +10 -4
  152. package/dist/module/runtime/native/conditions/guards.js.map +1 -1
  153. package/dist/module/runtime/native/conditions/media-query.js +2 -0
  154. package/dist/module/runtime/native/conditions/media-query.js.map +1 -1
  155. package/dist/module/runtime/native/index.js +1 -2
  156. package/dist/module/runtime/native/index.js.map +1 -1
  157. package/dist/module/runtime/native/injection.js +18 -0
  158. package/dist/module/runtime/native/injection.js.map +1 -1
  159. package/dist/module/runtime/native/react/rules.js +22 -27
  160. package/dist/module/runtime/native/react/rules.js.map +1 -1
  161. package/dist/module/runtime/native/reactivity.js +1 -5
  162. package/dist/module/runtime/native/reactivity.js.map +1 -1
  163. package/dist/module/runtime/native/styles/animation.js +68 -71
  164. package/dist/module/runtime/native/styles/animation.js.map +1 -1
  165. package/dist/module/runtime/native/styles/border.js +8 -0
  166. package/dist/module/runtime/native/styles/border.js.map +1 -0
  167. package/dist/module/runtime/native/styles/box-shadow.js +35 -0
  168. package/dist/module/runtime/native/styles/box-shadow.js.map +1 -0
  169. package/dist/module/runtime/native/styles/calc.js +33 -62
  170. package/dist/module/runtime/native/styles/calc.js.map +1 -1
  171. package/dist/module/runtime/native/styles/calculate-props.js +118 -0
  172. package/dist/module/runtime/native/styles/calculate-props.js.map +1 -0
  173. package/dist/module/runtime/native/styles/constants.js +1 -0
  174. package/dist/module/runtime/native/styles/constants.js.map +1 -1
  175. package/dist/module/runtime/native/styles/filters.js +70 -0
  176. package/dist/module/runtime/native/styles/filters.js.map +1 -0
  177. package/dist/module/runtime/native/styles/index.js +2 -110
  178. package/dist/module/runtime/native/styles/index.js.map +1 -1
  179. package/dist/module/runtime/native/styles/platform-functions.js +36 -0
  180. package/dist/module/runtime/native/styles/platform-functions.js.map +1 -0
  181. package/dist/module/runtime/native/styles/resolve.js +47 -14
  182. package/dist/module/runtime/native/styles/resolve.js.map +1 -1
  183. package/dist/module/runtime/native/styles/shorthand.js +34 -17
  184. package/dist/module/runtime/native/styles/shorthand.js.map +1 -1
  185. package/dist/module/runtime/native/styles/transform.js +9 -3
  186. package/dist/module/runtime/native/styles/transform.js.map +1 -1
  187. package/dist/module/runtime/native/styles/units.js +7 -4
  188. package/dist/module/runtime/native/styles/units.js.map +1 -1
  189. package/dist/module/runtime/native/styles/variables.js +57 -36
  190. package/dist/module/runtime/native/styles/variables.js.map +1 -1
  191. package/dist/module/runtime/utils/objects.js +16 -4
  192. package/dist/module/runtime/utils/objects.js.map +1 -1
  193. package/dist/module/runtime/utils/style-value.js +6 -0
  194. package/dist/module/runtime/utils/style-value.js.map +1 -1
  195. package/dist/module/runtime/web/index.js +2 -0
  196. package/dist/module/runtime/web/index.js.map +1 -1
  197. package/dist/module/runtime/web/metro.js +5 -0
  198. package/dist/module/runtime/web/metro.js.map +1 -0
  199. package/dist/typescript/commonjs/example/app.config.d.ts +4 -0
  200. package/dist/typescript/commonjs/example/app.config.d.ts.map +1 -0
  201. package/dist/typescript/commonjs/example/src/App.d.ts.map +1 -1
  202. package/dist/typescript/commonjs/src/babel/allowedModules.d.ts +2 -0
  203. package/dist/typescript/commonjs/src/babel/allowedModules.d.ts.map +1 -0
  204. package/dist/typescript/commonjs/src/babel/helpers.d.ts +3 -8
  205. package/dist/typescript/commonjs/src/babel/helpers.d.ts.map +1 -1
  206. package/dist/typescript/commonjs/src/babel/import-plugin.d.ts.map +1 -1
  207. package/dist/typescript/commonjs/src/babel/react-native-web.d.ts +8 -0
  208. package/dist/typescript/commonjs/src/babel/react-native-web.d.ts.map +1 -0
  209. package/dist/typescript/commonjs/src/babel/react-native.d.ts +8 -0
  210. package/dist/typescript/commonjs/src/babel/react-native.d.ts.map +1 -0
  211. package/dist/typescript/commonjs/src/compiler/atRules.d.ts +34 -0
  212. package/dist/typescript/commonjs/src/compiler/atRules.d.ts.map +1 -0
  213. package/dist/typescript/commonjs/src/compiler/attributes.test.d.ts +2 -0
  214. package/dist/typescript/commonjs/src/compiler/attributes.test.d.ts.map +1 -0
  215. package/dist/typescript/commonjs/src/compiler/compiler.d.ts +1 -1
  216. package/dist/typescript/commonjs/src/compiler/compiler.d.ts.map +1 -1
  217. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts +27 -108
  218. package/dist/typescript/commonjs/src/compiler/compiler.types.d.ts.map +1 -1
  219. package/dist/typescript/commonjs/src/compiler/container-query.d.ts +2 -2
  220. package/dist/typescript/commonjs/src/compiler/container-query.d.ts.map +1 -1
  221. package/dist/typescript/commonjs/src/compiler/declarations.d.ts +118 -25
  222. package/dist/typescript/commonjs/src/compiler/declarations.d.ts.map +1 -1
  223. package/dist/typescript/commonjs/src/compiler/inheritance.test.d.ts +2 -0
  224. package/dist/typescript/commonjs/src/compiler/inheritance.test.d.ts.map +1 -0
  225. package/dist/typescript/commonjs/src/compiler/keyframes.d.ts +5 -4
  226. package/dist/typescript/commonjs/src/compiler/keyframes.d.ts.map +1 -1
  227. package/dist/typescript/commonjs/src/compiler/media-query.d.ts +4 -4
  228. package/dist/typescript/commonjs/src/compiler/media-query.d.ts.map +1 -1
  229. package/dist/typescript/commonjs/src/compiler/selectors.d.ts +10 -5
  230. package/dist/typescript/commonjs/src/compiler/selectors.d.ts.map +1 -1
  231. package/dist/typescript/commonjs/src/compiler/split-by-delimiter.d.ts +2 -0
  232. package/dist/typescript/commonjs/src/compiler/split-by-delimiter.d.ts.map +1 -0
  233. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts +54 -0
  234. package/dist/typescript/commonjs/src/compiler/stylesheet.d.ts.map +1 -0
  235. package/dist/typescript/commonjs/src/components/Text.d.ts +1 -1
  236. package/dist/typescript/commonjs/src/components/Text.d.ts.map +1 -1
  237. package/dist/typescript/commonjs/src/components/View.d.ts +1 -1
  238. package/dist/typescript/commonjs/src/components/View.d.ts.map +1 -1
  239. package/dist/typescript/commonjs/src/index.d.ts +1 -0
  240. package/dist/typescript/commonjs/src/index.d.ts.map +1 -1
  241. package/dist/typescript/commonjs/src/jest/index.d.ts +2 -3
  242. package/dist/typescript/commonjs/src/jest/index.d.ts.map +1 -1
  243. package/dist/typescript/commonjs/src/metro/index.d.ts +5 -4
  244. package/dist/typescript/commonjs/src/metro/index.d.ts.map +1 -1
  245. package/dist/typescript/commonjs/src/metro/injection-code.d.ts +15 -1
  246. package/dist/typescript/commonjs/src/metro/injection-code.d.ts.map +1 -1
  247. package/dist/typescript/commonjs/src/metro/resolver.d.ts +4 -0
  248. package/dist/typescript/commonjs/src/metro/resolver.d.ts.map +1 -0
  249. package/dist/typescript/commonjs/src/poison.pill.d.ts +2 -0
  250. package/dist/typescript/commonjs/src/poison.pill.d.ts.map +1 -0
  251. package/dist/typescript/commonjs/src/runtime/native/api.d.ts +1 -1
  252. package/dist/typescript/commonjs/src/runtime/native/conditions/guards.d.ts.map +1 -1
  253. package/dist/typescript/commonjs/src/runtime/native/index.d.ts +1 -1
  254. package/dist/typescript/commonjs/src/runtime/native/index.d.ts.map +1 -1
  255. package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts +2 -1
  256. package/dist/typescript/commonjs/src/runtime/native/react/rules.d.ts.map +1 -1
  257. package/dist/typescript/commonjs/src/runtime/native/react/useNativeCss.d.ts +1 -1
  258. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts +1 -1
  259. package/dist/typescript/commonjs/src/runtime/native/reactivity.d.ts.map +1 -1
  260. package/dist/typescript/commonjs/src/runtime/native/styles/animation.d.ts +3 -2
  261. package/dist/typescript/commonjs/src/runtime/native/styles/animation.d.ts.map +1 -1
  262. package/dist/typescript/commonjs/src/runtime/native/styles/border.d.ts +2 -0
  263. package/dist/typescript/commonjs/src/runtime/native/styles/border.d.ts.map +1 -0
  264. package/dist/typescript/commonjs/src/runtime/native/styles/box-shadow.d.ts +3 -0
  265. package/dist/typescript/commonjs/src/runtime/native/styles/box-shadow.d.ts.map +1 -0
  266. package/dist/typescript/commonjs/src/runtime/native/styles/calc.d.ts.map +1 -1
  267. package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts +10 -0
  268. package/dist/typescript/commonjs/src/runtime/native/styles/calculate-props.d.ts.map +1 -0
  269. package/dist/typescript/commonjs/src/runtime/native/styles/constants.d.ts +1 -0
  270. package/dist/typescript/commonjs/src/runtime/native/styles/constants.d.ts.map +1 -1
  271. package/dist/typescript/commonjs/src/runtime/native/styles/filters.d.ts +12 -0
  272. package/dist/typescript/commonjs/src/runtime/native/styles/filters.d.ts.map +1 -0
  273. package/dist/typescript/commonjs/src/runtime/native/styles/index.d.ts +3 -4
  274. package/dist/typescript/commonjs/src/runtime/native/styles/index.d.ts.map +1 -1
  275. package/dist/typescript/commonjs/src/runtime/native/styles/platform-functions.d.ts +8 -0
  276. package/dist/typescript/commonjs/src/runtime/native/styles/platform-functions.d.ts.map +1 -0
  277. package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts +6 -2
  278. package/dist/typescript/commonjs/src/runtime/native/styles/resolve.d.ts.map +1 -1
  279. package/dist/typescript/commonjs/src/runtime/native/styles/shorthand.d.ts +3 -4
  280. package/dist/typescript/commonjs/src/runtime/native/styles/shorthand.d.ts.map +1 -1
  281. package/dist/typescript/commonjs/src/runtime/native/styles/text-shadow.d.ts +1 -1
  282. package/dist/typescript/commonjs/src/runtime/native/styles/text-shadow.d.ts.map +1 -1
  283. package/dist/typescript/commonjs/src/runtime/native/styles/transform.d.ts.map +1 -1
  284. package/dist/typescript/commonjs/src/runtime/native/styles/units.d.ts.map +1 -1
  285. package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts +1 -1
  286. package/dist/typescript/commonjs/src/runtime/native/styles/variables.d.ts.map +1 -1
  287. package/dist/typescript/commonjs/src/runtime/runtime.types.d.ts +0 -15
  288. package/dist/typescript/commonjs/src/runtime/runtime.types.d.ts.map +1 -1
  289. package/dist/typescript/commonjs/src/runtime/utils/components.d.ts +1 -1
  290. package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts +2 -1
  291. package/dist/typescript/commonjs/src/runtime/utils/objects.d.ts.map +1 -1
  292. package/dist/typescript/commonjs/src/runtime/utils/style-value.d.ts +3 -2
  293. package/dist/typescript/commonjs/src/runtime/utils/style-value.d.ts.map +1 -1
  294. package/dist/typescript/commonjs/src/runtime/web/index.d.ts +1 -0
  295. package/dist/typescript/commonjs/src/runtime/web/index.d.ts.map +1 -1
  296. package/dist/typescript/commonjs/src/runtime/web/metro.d.ts +2 -0
  297. package/dist/typescript/commonjs/src/runtime/web/metro.d.ts.map +1 -0
  298. package/dist/typescript/module/example/app.config.d.ts +4 -0
  299. package/dist/typescript/module/example/app.config.d.ts.map +1 -0
  300. package/dist/typescript/module/example/src/App.d.ts.map +1 -1
  301. package/dist/typescript/module/src/babel/allowedModules.d.ts +2 -0
  302. package/dist/typescript/module/src/babel/allowedModules.d.ts.map +1 -0
  303. package/dist/typescript/module/src/babel/helpers.d.ts +3 -8
  304. package/dist/typescript/module/src/babel/helpers.d.ts.map +1 -1
  305. package/dist/typescript/module/src/babel/import-plugin.d.ts.map +1 -1
  306. package/dist/typescript/module/src/babel/react-native-web.d.ts +8 -0
  307. package/dist/typescript/module/src/babel/react-native-web.d.ts.map +1 -0
  308. package/dist/typescript/module/src/babel/react-native.d.ts +8 -0
  309. package/dist/typescript/module/src/babel/react-native.d.ts.map +1 -0
  310. package/dist/typescript/module/src/compiler/atRules.d.ts +34 -0
  311. package/dist/typescript/module/src/compiler/atRules.d.ts.map +1 -0
  312. package/dist/typescript/module/src/compiler/attributes.test.d.ts +2 -0
  313. package/dist/typescript/module/src/compiler/attributes.test.d.ts.map +1 -0
  314. package/dist/typescript/module/src/compiler/compiler.d.ts +1 -1
  315. package/dist/typescript/module/src/compiler/compiler.d.ts.map +1 -1
  316. package/dist/typescript/module/src/compiler/compiler.types.d.ts +27 -108
  317. package/dist/typescript/module/src/compiler/compiler.types.d.ts.map +1 -1
  318. package/dist/typescript/module/src/compiler/container-query.d.ts +2 -2
  319. package/dist/typescript/module/src/compiler/container-query.d.ts.map +1 -1
  320. package/dist/typescript/module/src/compiler/declarations.d.ts +118 -25
  321. package/dist/typescript/module/src/compiler/declarations.d.ts.map +1 -1
  322. package/dist/typescript/module/src/compiler/inheritance.test.d.ts +2 -0
  323. package/dist/typescript/module/src/compiler/inheritance.test.d.ts.map +1 -0
  324. package/dist/typescript/module/src/compiler/keyframes.d.ts +5 -4
  325. package/dist/typescript/module/src/compiler/keyframes.d.ts.map +1 -1
  326. package/dist/typescript/module/src/compiler/media-query.d.ts +4 -4
  327. package/dist/typescript/module/src/compiler/media-query.d.ts.map +1 -1
  328. package/dist/typescript/module/src/compiler/selectors.d.ts +10 -5
  329. package/dist/typescript/module/src/compiler/selectors.d.ts.map +1 -1
  330. package/dist/typescript/module/src/compiler/split-by-delimiter.d.ts +2 -0
  331. package/dist/typescript/module/src/compiler/split-by-delimiter.d.ts.map +1 -0
  332. package/dist/typescript/module/src/compiler/stylesheet.d.ts +54 -0
  333. package/dist/typescript/module/src/compiler/stylesheet.d.ts.map +1 -0
  334. package/dist/typescript/module/src/components/Text.d.ts +1 -1
  335. package/dist/typescript/module/src/components/Text.d.ts.map +1 -1
  336. package/dist/typescript/module/src/components/View.d.ts +1 -1
  337. package/dist/typescript/module/src/components/View.d.ts.map +1 -1
  338. package/dist/typescript/module/src/index.d.ts +1 -0
  339. package/dist/typescript/module/src/index.d.ts.map +1 -1
  340. package/dist/typescript/module/src/jest/index.d.ts +2 -3
  341. package/dist/typescript/module/src/jest/index.d.ts.map +1 -1
  342. package/dist/typescript/module/src/metro/index.d.ts +5 -4
  343. package/dist/typescript/module/src/metro/index.d.ts.map +1 -1
  344. package/dist/typescript/module/src/metro/injection-code.d.ts +15 -1
  345. package/dist/typescript/module/src/metro/injection-code.d.ts.map +1 -1
  346. package/dist/typescript/module/src/metro/resolver.d.ts +4 -0
  347. package/dist/typescript/module/src/metro/resolver.d.ts.map +1 -0
  348. package/dist/typescript/module/src/poison.pill.d.ts +2 -0
  349. package/dist/typescript/module/src/poison.pill.d.ts.map +1 -0
  350. package/dist/typescript/module/src/runtime/native/api.d.ts +1 -1
  351. package/dist/typescript/module/src/runtime/native/conditions/guards.d.ts.map +1 -1
  352. package/dist/typescript/module/src/runtime/native/index.d.ts +1 -1
  353. package/dist/typescript/module/src/runtime/native/index.d.ts.map +1 -1
  354. package/dist/typescript/module/src/runtime/native/react/rules.d.ts +2 -1
  355. package/dist/typescript/module/src/runtime/native/react/rules.d.ts.map +1 -1
  356. package/dist/typescript/module/src/runtime/native/react/useNativeCss.d.ts +1 -1
  357. package/dist/typescript/module/src/runtime/native/reactivity.d.ts +1 -1
  358. package/dist/typescript/module/src/runtime/native/reactivity.d.ts.map +1 -1
  359. package/dist/typescript/module/src/runtime/native/styles/animation.d.ts +3 -2
  360. package/dist/typescript/module/src/runtime/native/styles/animation.d.ts.map +1 -1
  361. package/dist/typescript/module/src/runtime/native/styles/border.d.ts +2 -0
  362. package/dist/typescript/module/src/runtime/native/styles/border.d.ts.map +1 -0
  363. package/dist/typescript/module/src/runtime/native/styles/box-shadow.d.ts +3 -0
  364. package/dist/typescript/module/src/runtime/native/styles/box-shadow.d.ts.map +1 -0
  365. package/dist/typescript/module/src/runtime/native/styles/calc.d.ts.map +1 -1
  366. package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts +10 -0
  367. package/dist/typescript/module/src/runtime/native/styles/calculate-props.d.ts.map +1 -0
  368. package/dist/typescript/module/src/runtime/native/styles/constants.d.ts +1 -0
  369. package/dist/typescript/module/src/runtime/native/styles/constants.d.ts.map +1 -1
  370. package/dist/typescript/module/src/runtime/native/styles/filters.d.ts +12 -0
  371. package/dist/typescript/module/src/runtime/native/styles/filters.d.ts.map +1 -0
  372. package/dist/typescript/module/src/runtime/native/styles/index.d.ts +3 -4
  373. package/dist/typescript/module/src/runtime/native/styles/index.d.ts.map +1 -1
  374. package/dist/typescript/module/src/runtime/native/styles/platform-functions.d.ts +8 -0
  375. package/dist/typescript/module/src/runtime/native/styles/platform-functions.d.ts.map +1 -0
  376. package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts +6 -2
  377. package/dist/typescript/module/src/runtime/native/styles/resolve.d.ts.map +1 -1
  378. package/dist/typescript/module/src/runtime/native/styles/shorthand.d.ts +3 -4
  379. package/dist/typescript/module/src/runtime/native/styles/shorthand.d.ts.map +1 -1
  380. package/dist/typescript/module/src/runtime/native/styles/text-shadow.d.ts +1 -1
  381. package/dist/typescript/module/src/runtime/native/styles/text-shadow.d.ts.map +1 -1
  382. package/dist/typescript/module/src/runtime/native/styles/transform.d.ts.map +1 -1
  383. package/dist/typescript/module/src/runtime/native/styles/units.d.ts.map +1 -1
  384. package/dist/typescript/module/src/runtime/native/styles/variables.d.ts +1 -1
  385. package/dist/typescript/module/src/runtime/native/styles/variables.d.ts.map +1 -1
  386. package/dist/typescript/module/src/runtime/runtime.types.d.ts +0 -15
  387. package/dist/typescript/module/src/runtime/runtime.types.d.ts.map +1 -1
  388. package/dist/typescript/module/src/runtime/utils/components.d.ts +1 -1
  389. package/dist/typescript/module/src/runtime/utils/objects.d.ts +2 -1
  390. package/dist/typescript/module/src/runtime/utils/objects.d.ts.map +1 -1
  391. package/dist/typescript/module/src/runtime/utils/style-value.d.ts +3 -2
  392. package/dist/typescript/module/src/runtime/utils/style-value.d.ts.map +1 -1
  393. package/dist/typescript/module/src/runtime/web/index.d.ts +1 -0
  394. package/dist/typescript/module/src/runtime/web/index.d.ts.map +1 -1
  395. package/dist/typescript/module/src/runtime/web/metro.d.ts +2 -0
  396. package/dist/typescript/module/src/runtime/web/metro.d.ts.map +1 -0
  397. package/package.json +67 -13
  398. package/src/babel/allowedModules.ts +24 -0
  399. package/src/babel/helpers.ts +16 -158
  400. package/src/babel/import-plugin.ts +125 -132
  401. package/src/babel/react-native-web.ts +226 -0
  402. package/src/babel/react-native.ts +226 -0
  403. package/src/compiler/atRules.ts +144 -0
  404. package/src/compiler/attributes.test.ts +28 -0
  405. package/src/compiler/compiler.ts +154 -482
  406. package/src/compiler/compiler.types.ts +30 -135
  407. package/src/compiler/container-query.ts +12 -12
  408. package/src/compiler/declarations.ts +1789 -1971
  409. package/src/compiler/inheritance.test.ts +121 -0
  410. package/src/compiler/keyframes.ts +28 -42
  411. package/src/compiler/media-query.ts +27 -26
  412. package/src/compiler/selectors.ts +289 -271
  413. package/src/compiler/split-by-delimiter.ts +19 -0
  414. package/src/compiler/stylesheet.ts +546 -0
  415. package/src/components/Text.tsx +2 -0
  416. package/src/components/View.tsx +2 -0
  417. package/src/index.ts +2 -0
  418. package/src/jest/index.ts +6 -5
  419. package/src/metro/index.ts +161 -64
  420. package/src/metro/injection-code.ts +33 -3
  421. package/src/metro/resolver.ts +89 -0
  422. package/src/metro/typescript.ts +1 -1
  423. package/src/poison.pill.ts +32 -0
  424. package/src/runtime/native/conditions/guards.ts +12 -4
  425. package/src/runtime/native/conditions/media-query.ts +2 -0
  426. package/src/runtime/native/index.ts +1 -2
  427. package/src/runtime/native/injection.ts +30 -0
  428. package/src/runtime/native/react/rules.ts +26 -33
  429. package/src/runtime/native/reactivity.ts +3 -7
  430. package/src/runtime/native/styles/animation.ts +143 -104
  431. package/src/runtime/native/styles/border.ts +10 -0
  432. package/src/runtime/native/styles/box-shadow.ts +54 -0
  433. package/src/runtime/native/styles/calc.ts +37 -60
  434. package/src/runtime/native/styles/calculate-props.ts +165 -0
  435. package/src/runtime/native/styles/constants.ts +1 -0
  436. package/src/runtime/native/styles/filters.ts +98 -0
  437. package/src/runtime/native/styles/index.ts +2 -138
  438. package/src/runtime/native/styles/platform-functions.ts +50 -0
  439. package/src/runtime/native/styles/resolve.ts +91 -17
  440. package/src/runtime/native/styles/shorthand.ts +61 -41
  441. package/src/runtime/native/styles/transform.ts +10 -4
  442. package/src/runtime/native/styles/units.ts +9 -4
  443. package/src/runtime/native/styles/variables.ts +51 -35
  444. package/src/runtime/runtime.types.ts +0 -25
  445. package/src/runtime/utils/objects.ts +20 -5
  446. package/src/runtime/utils/style-value.ts +14 -2
  447. package/src/runtime/web/index.ts +3 -0
  448. package/src/runtime/web/metro.ts +2 -0
  449. package/types.d.ts +70 -0
  450. package/dist/commonjs/compiler/add.js +0 -175
  451. package/dist/commonjs/compiler/add.js.map +0 -1
  452. package/dist/commonjs/components/ActivityIndicator.js +0 -20
  453. package/dist/commonjs/components/ActivityIndicator.js.map +0 -1
  454. package/dist/commonjs/components/SafeAreaProvider/index.js +0 -41
  455. package/dist/commonjs/components/SafeAreaProvider/index.js.map +0 -1
  456. package/dist/commonjs/components/SafeAreaProvider/index.web.js +0 -13
  457. package/dist/commonjs/components/SafeAreaProvider/index.web.js.map +0 -1
  458. package/dist/commonjs/components/TextInput.js +0 -20
  459. package/dist/commonjs/components/TextInput.js.map +0 -1
  460. package/dist/module/compiler/add.js +0 -168
  461. package/dist/module/compiler/add.js.map +0 -1
  462. package/dist/module/components/ActivityIndicator.js +0 -16
  463. package/dist/module/components/ActivityIndicator.js.map +0 -1
  464. package/dist/module/components/SafeAreaProvider/index.js +0 -36
  465. package/dist/module/components/SafeAreaProvider/index.js.map +0 -1
  466. package/dist/module/components/SafeAreaProvider/index.web.js +0 -4
  467. package/dist/module/components/SafeAreaProvider/index.web.js.map +0 -1
  468. package/dist/module/components/TextInput.js +0 -16
  469. package/dist/module/components/TextInput.js.map +0 -1
  470. package/dist/typescript/commonjs/src/compiler/add.d.ts +0 -10
  471. package/dist/typescript/commonjs/src/compiler/add.d.ts.map +0 -1
  472. package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts +0 -3
  473. package/dist/typescript/commonjs/src/components/ActivityIndicator.d.ts.map +0 -1
  474. package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.d.ts +0 -4
  475. package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.d.ts.map +0 -1
  476. package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.web.d.ts +0 -2
  477. package/dist/typescript/commonjs/src/components/SafeAreaProvider/index.web.d.ts.map +0 -1
  478. package/dist/typescript/commonjs/src/components/TextInput.d.ts +0 -13
  479. package/dist/typescript/commonjs/src/components/TextInput.d.ts.map +0 -1
  480. package/dist/typescript/module/src/compiler/add.d.ts +0 -10
  481. package/dist/typescript/module/src/compiler/add.d.ts.map +0 -1
  482. package/dist/typescript/module/src/components/ActivityIndicator.d.ts +0 -3
  483. package/dist/typescript/module/src/components/ActivityIndicator.d.ts.map +0 -1
  484. package/dist/typescript/module/src/components/SafeAreaProvider/index.d.ts +0 -4
  485. package/dist/typescript/module/src/components/SafeAreaProvider/index.d.ts.map +0 -1
  486. package/dist/typescript/module/src/components/SafeAreaProvider/index.web.d.ts +0 -2
  487. package/dist/typescript/module/src/components/SafeAreaProvider/index.web.d.ts.map +0 -1
  488. package/dist/typescript/module/src/components/TextInput.d.ts +0 -13
  489. package/dist/typescript/module/src/components/TextInput.d.ts.map +0 -1
  490. package/src/compiler/add.ts +0 -257
  491. package/src/components/ActivityIndicator.tsx +0 -19
  492. package/src/components/SafeAreaProvider/index.tsx +0 -50
  493. package/src/components/SafeAreaProvider/index.web.tsx +0 -1
  494. package/src/components/TextInput.tsx +0 -20
@@ -1,22 +1,29 @@
1
1
  /* eslint-disable */
2
+ import { dirname, relative, sep } from "node:path";
2
3
  import { versions } from "node:process";
3
- import { sep } from "node:path";
4
4
 
5
5
  import connect from "connect";
6
+ import debug from "debug";
6
7
  import type { MetroConfig } from "metro-config";
7
8
 
9
+ import type { CompilerOptions } from "../compiler";
8
10
  import { compile } from "../compiler/compiler";
11
+ import { getNativeInjectionCode, getWebInjectionCode } from "./injection-code";
12
+ import { nativeResolver, webResolver } from "./resolver";
9
13
  import { setupTypeScript } from "./typescript";
10
- import { getInjectionCode } from "./injection-code";
11
14
 
12
- export interface WithReactNativeCSSOptions {
13
- browserslist?: string | null;
14
- browserslistEnv?: string | null;
15
- libName?: string;
15
+ export interface WithReactNativeCSSOptions extends CompilerOptions {
16
+ /* Specify the path to the TypeScript environment file. Defaults types-env.d.ts */
16
17
  typescriptEnvPath?: string;
18
+ /* Disable generation of the types-env.d.ts file. Defaults false */
17
19
  disableTypeScriptGeneration?: boolean;
20
+ /** Add className to all React Native primitives. Defaults false */
21
+ globalClassNamePolyfill?: boolean;
22
+ hexColors?: boolean;
18
23
  }
19
24
 
25
+ const defaultLogger = debug("react-native-css:metro");
26
+
20
27
  export function withReactNativeCSS<
21
28
  T extends MetroConfig | (() => Promise<MetroConfig>),
22
29
  >(config: T, options?: WithReactNativeCSSOptions): T {
@@ -26,23 +33,56 @@ export function withReactNativeCSS<
26
33
  }) as T;
27
34
  }
28
35
 
29
- if (Number(versions.node.split(".")[0]) < 18) {
30
- throw new Error("react-native-css only supports NodeJS >18");
36
+ if (Number(versions.node.split(".")[0]) < 20) {
37
+ throw new Error("react-native-css only supports NodeJS >20");
31
38
  }
32
39
 
33
- if (options?.disableTypeScriptGeneration !== true) {
34
- setupTypeScript(options?.typescriptEnvPath, options?.libName);
40
+ const {
41
+ disableTypeScriptGeneration,
42
+ typescriptEnvPath,
43
+ globalClassNamePolyfill = false,
44
+ logger = defaultLogger,
45
+ } = options || {};
46
+
47
+ const loggerEnabled = "enabled" in logger ? logger.enabled : true;
48
+
49
+ if (disableTypeScriptGeneration !== true) {
50
+ setupTypeScript(typescriptEnvPath);
35
51
  }
36
52
 
37
53
  const originalMiddleware = config.server?.enhanceMiddleware;
54
+ const originalResolver = config.resolver?.resolveRequest;
55
+
56
+ const poisonPillPath = "./poison.pill";
38
57
 
39
58
  return {
40
59
  ...config,
41
60
  transformerPath: require.resolve("./metro-transformer"),
42
- transformer: {
43
- ...config.transformer,
44
- browserslist: options?.browserslist,
45
- browserslistEnv: options?.browserslistEnv,
61
+ resolver: {
62
+ ...config.resolver,
63
+ sourceExts: [...(config?.resolver?.sourceExts || []), "css"],
64
+ resolveRequest: (context, moduleName, platform) => {
65
+ if (moduleName === poisonPillPath) {
66
+ return { type: "empty" };
67
+ }
68
+
69
+ // Don't hijack the resolution of react-native imports
70
+ if (!globalClassNamePolyfill) {
71
+ const parentResolver = originalResolver ?? context.resolveRequest;
72
+ return parentResolver(context, moduleName, platform);
73
+ }
74
+
75
+ const parentResolver = originalResolver ?? context.resolveRequest;
76
+ const resolver = platform === "web" ? webResolver : nativeResolver;
77
+ const resolved = resolver(
78
+ parentResolver,
79
+ context,
80
+ moduleName,
81
+ platform,
82
+ );
83
+
84
+ return resolved;
85
+ },
46
86
  },
47
87
  server: {
48
88
  ...config.server,
@@ -53,16 +93,34 @@ export function withReactNativeCSS<
53
93
  if (!bundler.__react_native_css__patched) {
54
94
  bundler.__react_native_css__patched = true;
55
95
 
56
- const cssFiles = new Map();
96
+ const nativeCSSFiles = new Map();
97
+ const webCSSFiles = new Set<string>();
98
+
99
+ const nativeInjectionPath = require.resolve(
100
+ "../runtime/native/metro",
101
+ );
102
+ const nativeInjectionFilepaths = [
103
+ // CommonJS
104
+ nativeInjectionPath,
105
+ // ES Module
106
+ nativeInjectionPath.replace(
107
+ `dist${sep}commonjs`,
108
+ `dist${sep}module`,
109
+ ),
110
+ // TypeScript
111
+ nativeInjectionPath
112
+ .replace(`dist${sep}commonjs`, `src`)
113
+ .replace(".js", ".ts"),
114
+ ];
57
115
 
58
- const injectionCommonJS = require.resolve("../runtime/native/metro");
59
- const injectionFilePaths = [
116
+ const webInjectionPath = require.resolve("../runtime/web/metro");
117
+ const webInjectionFilepaths = [
60
118
  // CommonJS
61
- injectionCommonJS,
119
+ webInjectionPath,
62
120
  // ES Module
63
- injectionCommonJS.replace(`dist${sep}commonjs`, `dist${sep}module`),
121
+ webInjectionPath.replace(`dist${sep}commonjs`, `dist${sep}module`),
64
122
  // TypeScript
65
- injectionCommonJS
123
+ webInjectionPath
66
124
  .replace(`dist${sep}commonjs`, `src`)
67
125
  .replace(".js", ".ts"),
68
126
  ];
@@ -70,6 +128,8 @@ export function withReactNativeCSS<
70
128
  // Keep the original
71
129
  const transformFile = bundler.transformFile.bind(bundler);
72
130
 
131
+ const watcher = bundler.getWatcher();
132
+
73
133
  // Patch with our functionality
74
134
  bundler.transformFile = async function (
75
135
  filePath: string,
@@ -78,53 +138,90 @@ export function withReactNativeCSS<
78
138
  ) {
79
139
  const isCss = /\.(s?css|sass)$/.test(filePath);
80
140
 
81
- // Handle CSS files on native platforms
82
- if (isCss && transformOptions.platform !== "web") {
83
- const real = await transformFile(
84
- filePath,
85
- {
86
- ...transformOptions,
87
- // Force the platform to web for CSS files
88
- platform: "web",
89
- // Let the transformer know that we will handle compilation
90
- customTransformOptions: {
91
- ...transformOptions.customTransformOptions,
92
- reactNativeCSSCompile: false,
93
- },
94
- },
95
- fileBuffer,
96
- );
97
-
98
- const lastTransform = cssFiles.get(filePath);
99
- const last = lastTransform?.[0];
100
- const next = real.output[0].data.css.code.toString();
101
-
102
- // The CSS file has changed, we need to recompile the injection file
103
- if (next !== last) {
104
- cssFiles.set(filePath, [next, compile(next, {})]);
105
-
106
- bundler.getWatcher().emit("change", {
107
- eventsQueue: injectionFilePaths.map((filePath) => ({
108
- filePath,
109
- metadata: {
110
- modifiedTime: Date.now(),
111
- size: 1, // Can be anything
112
- type: "virtual", // Can be anything
141
+ if (transformOptions.platform === "web") {
142
+ if (isCss) {
143
+ webCSSFiles.add(filePath);
144
+ } else if (webInjectionFilepaths.includes(filePath)) {
145
+ fileBuffer = getWebInjectionCode(Array.from(webCSSFiles));
146
+ }
147
+
148
+ return transformFile(filePath, transformOptions, fileBuffer);
149
+ } else {
150
+ // Handle CSS files on native platforms
151
+ if (isCss) {
152
+ const webTransform = await transformFile(
153
+ filePath,
154
+ {
155
+ ...transformOptions,
156
+ // Force the platform to web for CSS files
157
+ platform: "web",
158
+ // Let the transformer know that we will handle compilation
159
+ customTransformOptions: {
160
+ ...transformOptions.customTransformOptions,
161
+ reactNativeCSSCompile: false,
113
162
  },
114
- type: "change",
115
- })),
116
- });
163
+ },
164
+ fileBuffer,
165
+ );
166
+
167
+ const lastTransform = nativeCSSFiles.get(filePath);
168
+ const last = lastTransform?.[0];
169
+ const next = webTransform.output[0].data.css.code.toString();
170
+
171
+ // The CSS file has changed, we need to recompile the injection file
172
+ if (next !== last) {
173
+ nativeCSSFiles.set(filePath, [
174
+ next,
175
+ compile(next, {
176
+ hexColors: options?.hexColors,
177
+ }),
178
+ ]);
179
+
180
+ watcher.emit("change", {
181
+ eventsQueue: nativeInjectionFilepaths.map((filePath) => ({
182
+ filePath,
183
+ metadata: {
184
+ modifiedTime: Date.now(),
185
+ size: 1, // Can be anything
186
+ type: "virtual", // Can be anything
187
+ },
188
+ type: "change",
189
+ })),
190
+ });
191
+ }
192
+
193
+ const nativeTransform = await transformFile(
194
+ filePath,
195
+ transformOptions,
196
+ fileBuffer,
197
+ );
198
+
199
+ // Tell Expo to skip caching this file
200
+ nativeTransform.output[0].data.css = {
201
+ skipCache: true,
202
+ // Expo requires a `code` property
203
+ code: "",
204
+ };
205
+
206
+ return nativeTransform;
207
+ } else if (nativeInjectionFilepaths.includes(filePath)) {
208
+ // If this is the injection file, we to swap its content with the
209
+ // compiled CSS files
210
+ fileBuffer = getNativeInjectionCode(
211
+ Array.from(nativeCSSFiles.keys()).map((key) =>
212
+ relative(dirname(filePath), key),
213
+ ),
214
+ Array.from(nativeCSSFiles.values()).map(([, value]) => value),
215
+ );
216
+
217
+ if (loggerEnabled && fileBuffer) {
218
+ logger(`Transformed ${filePath}`);
219
+ logger(fileBuffer?.toString());
220
+ }
117
221
  }
118
- } else if (injectionFilePaths.includes(filePath)) {
119
- // If this is the injection file, we to swap its content with the
120
- // compiled CSS files
121
- fileBuffer = getInjectionCode(
122
- "./api",
123
- Array.from(cssFiles.values()).map(([, value]) => value),
124
- );
125
- }
126
222
 
127
- return transformFile(filePath, transformOptions, fileBuffer);
223
+ return transformFile(filePath, transformOptions, fileBuffer);
224
+ }
128
225
  };
129
226
  }
130
227
 
@@ -1,8 +1,38 @@
1
- export function getInjectionCode(filePath: string, values: unknown[]) {
2
- const importPath = `import { StyleCollection } from "${filePath}";`;
1
+ /**
2
+ * This is a hack around Expo's handling of CSS files.
3
+ * When a component is inside a lazy() barrier, it is inside a different JS bundle.
4
+ * So when it updates, it only updates its local bundle, not the global one which contains the CSS files.
5
+ *
6
+ * To fix this, we force our code to always import the CSS files.
7
+ * Now the CSS files are in every bundle.
8
+ *
9
+ * We achieve this by collecting all CSS files and injecting them into a special file
10
+ * which is included inside react-native-css's runtime.
11
+ *
12
+ * This is why both of these function add imports for the CSS files.
13
+ */
14
+
15
+ export function getWebInjectionCode(filePaths: string[]) {
16
+ const importStatements = filePaths
17
+ .map((filePath) => `import "${filePath}";`)
18
+ .join("\n");
19
+
20
+ return Buffer.from(importStatements);
21
+ }
22
+
23
+ export function getNativeInjectionCode(
24
+ cssFilePaths: string[],
25
+ values: unknown[],
26
+ ) {
27
+ const importStatements = cssFilePaths
28
+ .map((filePath) => `import "${filePath}";`)
29
+ .join("\n");
30
+ const importPath = `import { StyleCollection } from "./api";`;
3
31
  const contents = values
4
32
  .map((value) => `StyleCollection.inject(${JSON.stringify(value)});`)
5
33
  .join("\n");
6
34
 
7
- return Buffer.from(`${importPath}\n${contents}`);
35
+ return Buffer.from(
36
+ `${importStatements}\n${importPath}\n${contents};export {};`,
37
+ );
8
38
  }
@@ -0,0 +1,89 @@
1
+ import { basename, resolve, sep } from "node:path";
2
+
3
+ import type {
4
+ CustomResolutionContext,
5
+ CustomResolver,
6
+ Resolution,
7
+ } from "metro-resolver";
8
+
9
+ import { allowedModules } from "../babel/allowedModules";
10
+
11
+ const thisModuleDist = resolve(__dirname, "../../../dist");
12
+ const thisModuleSrc = resolve(__dirname, "../../../src");
13
+
14
+ function isFromThisModule(filename: string): boolean {
15
+ return (
16
+ filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc)
17
+ );
18
+ }
19
+
20
+ export function nativeResolver(
21
+ resolver: CustomResolver,
22
+ context: CustomResolutionContext,
23
+ moduleName: string,
24
+ platform: string | null,
25
+ ): Resolution {
26
+ const resolution = resolver(context, moduleName, platform);
27
+
28
+ if (
29
+ // Don't include our internal files
30
+ isFromThisModule(context.originModulePath) ||
31
+ // Only operate on source files
32
+ resolution.type !== "sourceFile" ||
33
+ // Skip the React Native barrel file to prevent infinite recursion
34
+ context.originModulePath.endsWith("react-native/index.js") ||
35
+ // Skip anything that isn't importing a React Native component
36
+ !(
37
+ moduleName.startsWith("react-native") ||
38
+ moduleName.startsWith("react-native/")
39
+ )
40
+ ) {
41
+ return resolution;
42
+ }
43
+
44
+ if (moduleName === "react-native") {
45
+ return resolver(context, `react-native-css/components`, platform);
46
+ }
47
+
48
+ // We only care about `react-native/Library/Components/<module>.js` components
49
+ const segments = resolution.filePath.split(sep);
50
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
51
+ const module = basename(segments.at(-1)!).split(".")[0];
52
+
53
+ if (!module || !allowedModules.has(module)) {
54
+ return resolution;
55
+ }
56
+
57
+ return resolver(context, `react-native-css/components/${module}`, platform);
58
+ }
59
+
60
+ export function webResolver(
61
+ resolver: CustomResolver,
62
+ context: CustomResolutionContext,
63
+ moduleName: string,
64
+ platform: string | null,
65
+ ): Resolution {
66
+ const resolution = resolver(context, moduleName, platform);
67
+
68
+ if (
69
+ // Don't include our internal files
70
+ isFromThisModule(context.originModulePath) ||
71
+ // Only operate on source files
72
+ resolution.type !== "sourceFile" ||
73
+ // Skip anything that isn't importing from `react-native-web`
74
+ !resolution.filePath.includes(`${sep}react-native-web${sep}`)
75
+ ) {
76
+ return resolution;
77
+ }
78
+
79
+ // We only care about `react-native-web/<segment>/<segment>/<module>/index.js` components
80
+ const segments = resolution.filePath.split(sep);
81
+ const isIndex = segments.at(-1)?.startsWith("index.");
82
+ const module = segments.at(-2);
83
+
84
+ if (!isIndex || !module || !allowedModules.has(module)) {
85
+ return resolution;
86
+ }
87
+
88
+ return resolver(context, `react-native-css/components/${module}`, platform);
89
+ }
@@ -41,7 +41,7 @@ export function setupTypeScript(
41
41
  if (!existsSync(envPath)) {
42
42
  writeFileSync(
43
43
  envPath,
44
- `/// <reference types="react-native-css/react-env" />
44
+ `/// <reference types="react-native-css/types" />
45
45
 
46
46
  // NOTE: This file should not be edited and should be committed with your source code. It is generated by ${name}. If you need to move or disable this file, please see the documentation.`,
47
47
  );
@@ -0,0 +1,32 @@
1
+ throw new Error(`react-native-css has encountered a setup error.
2
+
3
+ ┌─────-─┐
4
+ | Metro |
5
+ └─────-─┘
6
+
7
+ Either your metro.config.js is missing the 'withReactNativeCSS' wrapper OR
8
+ the resolver.resolveRequest function of your config is being overridden, and not calling the parent resolver.
9
+
10
+ When using 3rd party libraries, please use withReactNativeCSS as the innermost function when composing Metro configs.
11
+
12
+ \`\`\`ts
13
+ const config = getDefaultConfig(__dirname);
14
+ module.exports = with3rdPartyPlugin(
15
+ withReactNativeCSS(config)
16
+ )
17
+ \`\`\`
18
+
19
+ ┌─────------─┐
20
+ | NativeWind |
21
+ └─────------─┘
22
+
23
+ If you are using NativeWind with the 'withNativeWind' function, follow the Metro instructions above, but use 'withNativeWind' instead of 'withReactNativeCSS'.
24
+
25
+ ┌─────----------─┐
26
+ | Other bundlers |
27
+ └─────----------─┘
28
+
29
+ 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
+ `);
31
+
32
+ export {};
@@ -19,19 +19,27 @@ export function testGuards(
19
19
  inheritedContainers: ContainerContextValue,
20
20
  ) {
21
21
  return state.guards?.some((guard) => {
22
+ let result = false;
23
+
22
24
  switch (guard[0]) {
23
25
  case "a":
24
26
  // Attribute
25
- return currentProps?.[guard[1]] !== guard[2];
27
+ result = currentProps?.[guard[1]] !== guard[2];
28
+ break;
26
29
  case "d":
27
30
  // DataSet
28
- return currentProps?.dataSet?.[guard[1]] !== guard[2];
31
+ result = currentProps?.dataSet?.[guard[1]] !== guard[2];
32
+ break;
29
33
  case "v":
30
34
  // Variables
31
- return inheritedVariables[guard[1]] !== guard[2];
35
+ result = inheritedVariables[guard[1]] !== guard[2];
36
+ break;
32
37
  case "c":
33
38
  // Containers
34
- return inheritedContainers[guard[1]] !== guard[2];
39
+ result = inheritedContainers[guard[1]] !== guard[2];
40
+ break;
35
41
  }
42
+
43
+ return result;
36
44
  });
37
45
  }
@@ -38,6 +38,8 @@ function testComparison(mediaQuery: MediaCondition, effect: Effect): Boolean {
38
38
  const right = mediaQuery[2];
39
39
 
40
40
  switch (mediaQuery[1]) {
41
+ case "platform":
42
+ return right === Platform.OS;
41
43
  case "prefers-color-scheme": {
42
44
  return right === colorScheme.get(effect);
43
45
  }
@@ -1,5 +1,4 @@
1
- // Import this file for Metro to override
2
- import "./metro";
1
+ export * from "./metro";
3
2
 
4
3
  export * from "./api";
5
4
  export type * from "../runtime.types";
@@ -99,3 +99,33 @@ function isDeepEqual(a: unknown, b: unknown): boolean {
99
99
 
100
100
  return true;
101
101
  }
102
+
103
+ StyleCollection.styles("will-change-variable").set([
104
+ {
105
+ s: [0],
106
+ v: [],
107
+ },
108
+ ]);
109
+
110
+ StyleCollection.styles("will-change-container").set([
111
+ {
112
+ s: [0],
113
+ c: [],
114
+ },
115
+ ]);
116
+
117
+ StyleCollection.styles("will-change-animation").set([
118
+ {
119
+ s: [0],
120
+ a: true,
121
+ },
122
+ ]);
123
+
124
+ StyleCollection.styles("will-change-pressable").set([
125
+ {
126
+ s: [0],
127
+ p: {
128
+ h: 1,
129
+ },
130
+ },
131
+ ]);
@@ -166,31 +166,20 @@ export function updateRules(
166
166
  let pressable = activeFamily.has(state.ruleEffect);
167
167
 
168
168
  if (Boolean(variables) !== Boolean(state.variables)) {
169
- throw new Error(
170
- `ReactNativeCss: Cannot dynamic add a variable context. '${source}' was added after the initial render.
171
- Use modifier ('hover:my-var', 'active:my-var', 'not(true):my-var', etc) to ensure it present in the initial render`,
169
+ console.log(
170
+ `ReactNativeCss: className '${source}' added or removed a variable after the initial render. This causes the components state to be reset and all children be re-mounted. Use the className 'will-change-variable' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.`,
172
171
  );
173
- }
174
-
175
- if (Boolean(containers) !== Boolean(state.containers)) {
176
- throw new Error(
177
- `ReactNativeCss: Cannot dynamic add a container context. '${source}' was added after the initial render.
178
- Use modifier ('hover:container', 'active:container', 'not(true):container', etc) to ensure it present in the initial render`,
172
+ } else if (Boolean(containers) !== Boolean(state.containers)) {
173
+ console.log(
174
+ `ReactNativeCss: className '${source}' added or removed a container after the initial render. This causes the components state to be reset and all children be re-mounted. This will cause unexpected behavior. Use the className 'will-change-container' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.`,
179
175
  );
180
- }
181
-
182
- if (animated !== state.animated) {
183
- throw new Error(
184
- `ReactNativeCss: Cannot dynamically change to an animated component. '${source}' was added after the initial render.
185
- Use 'animation-none' or a modifier ('hover:animation', 'active:animation', 'not(true):animation', etc) to ensure it present in the initial render`,
176
+ } else if (animated !== state.animated) {
177
+ console.log(
178
+ `ReactNativeCss: className '${source}' added or removed an animation after the initial render. This causes the components state to be reset and all children be re-mounted. This will cause unexpected behavior. Use the className 'will-change-animation' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.`,
186
179
  );
187
- }
188
-
189
- if (pressable !== state.pressable) {
190
- throw new Error(
191
- `ReactNativeCss: Cannot dynamically change to a Pressable. '${source}' was added after the initial render.
192
- The 'hover', 'active', and 'focus' modifiers on a View will convert it to a Pressable.
193
- Use a modifier ('not(true):hover:my-class') to ensure it present in the initial render`,
180
+ } else if (pressable !== state.pressable) {
181
+ console.log(
182
+ `ReactNativeCss: className '${source}' added or removed a pressable state after the initial render. This causes the components state to be reset and all children be re-mounted. This will cause unexpected behavior. Use the className 'will-change-pressable' to avoid this warning. If this was caused by sibling components being added/removed, use a 'key' prop so React can track the component correctly.`,
194
183
  );
195
184
  }
196
185
  }
@@ -232,7 +221,7 @@ Use a modifier ('not(true):hover:my-class') to ensure it present in the initial
232
221
  }
233
222
 
234
223
  // Generate a StyleObservable for this unique set of rules / variables
235
- const stylesObs = stylesFamily(generateHash(state, rules), rules);
224
+ const stylesObs = stylesFamily(generateStateHash(state, rules), rules);
236
225
 
237
226
  // Get the guards without subscribing to the observable
238
227
  // We will subscribe within the render using the StyleEffect
@@ -288,21 +277,12 @@ function pushInlineRule(
288
277
  let hashKeyCount = 0;
289
278
  const hashKeyFamily = weakFamily(() => hashKeyCount++);
290
279
 
291
- /**
292
- * Quickly generate a unique hash for a set of numbers.
293
- * This is not a cryptographic hash, but it is fast and has a low chance of collision.
294
- */
295
- const MOD = 9007199254740871; // Largest prime within safe integer range 2^53
296
- const PRIME = 31; // A smaller prime for mixing
297
- export function generateHash(
280
+ export function generateStateHash(
298
281
  state: ComponentState,
299
282
  iterableKeys?: Iterable<WeakKey>,
300
283
  variables?: WeakKey,
301
284
  inlineVars?: Set<WeakKey>,
302
285
  ): string {
303
- let hash = 0;
304
- let product = 1; // Used for mixing to enhance uniqueness
305
-
306
286
  if (!iterableKeys) {
307
287
  return "";
308
288
  }
@@ -317,6 +297,19 @@ export function generateHash(
317
297
  keys.push(...inlineVars);
318
298
  }
319
299
 
300
+ return generateHash(keys);
301
+ }
302
+
303
+ /**
304
+ * Quickly generate a unique hash for a set of numbers.
305
+ * This is not a cryptographic hash, but it is fast and has a low chance of collision.
306
+ */
307
+ const MOD = 9007199254740871; // Largest prime within safe integer range 2^53
308
+ const PRIME = 31; // A smaller prime for mixing
309
+ export function generateHash(keys: WeakKey[]): string {
310
+ let hash = 0;
311
+ let product = 1; // Used for mixing to enhance uniqueness
312
+
320
313
  for (const key of keys) {
321
314
  if (!key) continue; // Skip if key is undefined
322
315
 
@@ -29,7 +29,7 @@ export const observableBatch: {
29
29
 
30
30
  export function observable<Value, Arg = Value>(
31
31
  init: Value | Read<Value, Arg>,
32
- equality = Object.is,
32
+ equality: (value1: Value, value2: Value) => boolean = Object.is,
33
33
  ) {
34
34
  let value: Value;
35
35
  let isStatic = typeof init !== "function";
@@ -72,7 +72,7 @@ export function observable<Value, Arg = Value>(
72
72
 
73
73
  function set(arg: Arg) {
74
74
  if (isStatic) {
75
- if (equality(value, arg)) {
75
+ if (equality(value, arg as unknown as Value)) {
76
76
  return;
77
77
  }
78
78
  value = arg as unknown as Value;
@@ -233,11 +233,7 @@ export const vh = observable<number>(
233
233
  export const colorScheme = observable<ColorSchemeName>(
234
234
  Appearance.getColorScheme(),
235
235
  );
236
- colorScheme.set(Appearance.getColorScheme());
237
- colorScheme.get({
238
- observers: new Set(),
239
- run: () => Appearance.setColorScheme(colorScheme.get()),
240
- });
236
+ Appearance.addChangeListener((event) => colorScheme.set(event.colorScheme));
241
237
 
242
238
  /** Containers ****************************************************************/
243
239