rnwind 0.0.1 → 0.0.2

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 (330) hide show
  1. package/lib/cjs/core/parser/animation.cjs +427 -0
  2. package/lib/cjs/core/parser/animation.cjs.map +1 -0
  3. package/lib/cjs/core/parser/animation.d.ts +126 -0
  4. package/lib/cjs/core/parser/border-dispatcher.cjs +180 -0
  5. package/lib/cjs/core/parser/border-dispatcher.cjs.map +1 -0
  6. package/lib/cjs/core/parser/border-dispatcher.d.ts +15 -0
  7. package/lib/cjs/core/parser/case-convert.cjs +15 -0
  8. package/lib/cjs/core/parser/case-convert.cjs.map +1 -0
  9. package/lib/cjs/core/parser/case-convert.d.ts +6 -0
  10. package/lib/cjs/core/parser/color-properties-dispatcher.cjs +84 -0
  11. package/lib/cjs/core/parser/color-properties-dispatcher.cjs.map +1 -0
  12. package/lib/cjs/core/parser/color-properties-dispatcher.d.ts +19 -0
  13. package/lib/cjs/core/parser/color.cjs +164 -0
  14. package/lib/cjs/core/parser/color.cjs.map +1 -0
  15. package/lib/cjs/core/parser/color.d.ts +12 -0
  16. package/lib/cjs/core/parser/constants.cjs +21 -0
  17. package/lib/cjs/core/parser/constants.cjs.map +1 -0
  18. package/lib/cjs/core/parser/constants.d.ts +8 -0
  19. package/lib/cjs/core/parser/declaration.cjs +347 -0
  20. package/lib/cjs/core/parser/declaration.cjs.map +1 -0
  21. package/lib/cjs/core/parser/declaration.d.ts +15 -0
  22. package/lib/cjs/core/parser/gradient.cjs +132 -0
  23. package/lib/cjs/core/parser/gradient.cjs.map +1 -0
  24. package/lib/cjs/core/parser/gradient.d.ts +59 -0
  25. package/lib/cjs/core/parser/haptics.cjs +73 -0
  26. package/lib/cjs/core/parser/haptics.cjs.map +1 -0
  27. package/lib/cjs/core/parser/haptics.d.ts +47 -0
  28. package/lib/cjs/core/parser/index.d.ts +8 -0
  29. package/lib/cjs/core/parser/keyframes.cjs +95 -0
  30. package/lib/cjs/core/parser/keyframes.cjs.map +1 -0
  31. package/lib/cjs/core/parser/keyframes.d.ts +26 -0
  32. package/lib/cjs/core/parser/layout-dispatcher.cjs +100 -0
  33. package/lib/cjs/core/parser/layout-dispatcher.cjs.map +1 -0
  34. package/lib/cjs/core/parser/layout-dispatcher.d.ts +14 -0
  35. package/lib/cjs/core/parser/length.cjs +96 -0
  36. package/lib/cjs/core/parser/length.cjs.map +1 -0
  37. package/lib/cjs/core/parser/length.d.ts +48 -0
  38. package/lib/cjs/core/parser/motion-dispatcher.cjs +77 -0
  39. package/lib/cjs/core/parser/motion-dispatcher.cjs.map +1 -0
  40. package/lib/cjs/core/parser/motion-dispatcher.d.ts +11 -0
  41. package/lib/cjs/core/parser/property.cjs +22 -0
  42. package/lib/cjs/core/parser/property.cjs.map +1 -0
  43. package/lib/cjs/core/parser/property.d.ts +8 -0
  44. package/lib/cjs/core/parser/safe-area.cjs +404 -0
  45. package/lib/cjs/core/parser/safe-area.cjs.map +1 -0
  46. package/lib/cjs/core/parser/safe-area.d.ts +39 -0
  47. package/lib/cjs/core/parser/selector.cjs +22 -0
  48. package/lib/cjs/core/parser/selector.cjs.map +1 -0
  49. package/lib/cjs/core/parser/selector.d.ts +11 -0
  50. package/lib/cjs/core/parser/shorthand.cjs +156 -0
  51. package/lib/cjs/core/parser/shorthand.cjs.map +1 -0
  52. package/lib/cjs/core/parser/shorthand.d.ts +61 -0
  53. package/lib/cjs/core/parser/text-truncate.cjs +78 -0
  54. package/lib/cjs/core/parser/text-truncate.cjs.map +1 -0
  55. package/lib/cjs/core/parser/text-truncate.d.ts +44 -0
  56. package/lib/cjs/core/parser/theme-vars.cjs +414 -0
  57. package/lib/cjs/core/parser/theme-vars.cjs.map +1 -0
  58. package/lib/cjs/core/parser/theme-vars.d.ts +61 -0
  59. package/lib/cjs/core/parser/tokens.cjs +304 -0
  60. package/lib/cjs/core/parser/tokens.cjs.map +1 -0
  61. package/lib/cjs/core/parser/tokens.d.ts +45 -0
  62. package/lib/cjs/core/parser/transform.cjs +198 -0
  63. package/lib/cjs/core/parser/transform.cjs.map +1 -0
  64. package/lib/cjs/core/parser/transform.d.ts +36 -0
  65. package/lib/cjs/core/parser/tw-parser.cjs +1567 -0
  66. package/lib/cjs/core/parser/tw-parser.cjs.map +1 -0
  67. package/lib/cjs/core/parser/tw-parser.d.ts +194 -0
  68. package/lib/cjs/core/parser/types.d.ts +37 -0
  69. package/lib/cjs/core/parser/typography-dispatcher.cjs +93 -0
  70. package/lib/cjs/core/parser/typography-dispatcher.cjs.map +1 -0
  71. package/lib/cjs/core/parser/typography-dispatcher.d.ts +11 -0
  72. package/lib/cjs/core/parser/typography.cjs +97 -0
  73. package/lib/cjs/core/parser/typography.cjs.map +1 -0
  74. package/lib/cjs/core/parser/typography.d.ts +43 -0
  75. package/lib/cjs/core/style-builder/build-style.cjs +397 -0
  76. package/lib/cjs/core/style-builder/build-style.cjs.map +1 -0
  77. package/lib/cjs/core/style-builder/build-style.d.ts +54 -0
  78. package/lib/cjs/core/style-builder/index.d.ts +3 -0
  79. package/lib/cjs/core/style-builder/union-builder.cjs +326 -0
  80. package/lib/cjs/core/style-builder/union-builder.cjs.map +1 -0
  81. package/lib/cjs/core/style-builder/union-builder.d.ts +128 -0
  82. package/lib/cjs/core/types.d.ts +14 -0
  83. package/lib/cjs/metro/dts.cjs +127 -0
  84. package/lib/cjs/metro/dts.cjs.map +1 -0
  85. package/lib/cjs/metro/dts.d.ts +16 -0
  86. package/lib/cjs/metro/index.cjs +19 -0
  87. package/lib/cjs/metro/index.cjs.map +1 -0
  88. package/lib/cjs/metro/index.d.ts +9 -0
  89. package/lib/cjs/metro/resolver.cjs +47 -0
  90. package/lib/cjs/metro/resolver.cjs.map +1 -0
  91. package/lib/cjs/metro/resolver.d.ts +22 -0
  92. package/lib/cjs/metro/state.cjs +251 -0
  93. package/lib/cjs/metro/state.cjs.map +1 -0
  94. package/lib/cjs/metro/state.d.ts +72 -0
  95. package/lib/cjs/metro/transform-ast.cjs +1255 -0
  96. package/lib/cjs/metro/transform-ast.cjs.map +1 -0
  97. package/lib/cjs/metro/transform-ast.d.ts +73 -0
  98. package/lib/cjs/metro/transformer.cjs +345 -0
  99. package/lib/cjs/metro/transformer.cjs.map +1 -0
  100. package/lib/cjs/metro/transformer.d.ts +47 -0
  101. package/lib/cjs/metro/warn-unknown-classes.cjs +86 -0
  102. package/lib/cjs/metro/warn-unknown-classes.cjs.map +1 -0
  103. package/lib/cjs/metro/warn-unknown-classes.d.ts +21 -0
  104. package/lib/cjs/metro/with-config.cjs +196 -0
  105. package/lib/cjs/metro/with-config.cjs.map +1 -0
  106. package/lib/cjs/metro/with-config.d.ts +57 -0
  107. package/lib/cjs/runtime/chain-handlers.cjs +37 -0
  108. package/lib/cjs/runtime/chain-handlers.cjs.map +1 -0
  109. package/lib/cjs/runtime/chain-handlers.d.ts +33 -0
  110. package/lib/cjs/runtime/components/rnwind-provider.cjs +98 -0
  111. package/lib/cjs/runtime/components/rnwind-provider.cjs.map +1 -0
  112. package/lib/cjs/runtime/components/rnwind-provider.d.ts +84 -0
  113. package/lib/cjs/runtime/gradient-types.d.ts +58 -0
  114. package/lib/cjs/runtime/haptics.cjs +113 -0
  115. package/lib/cjs/runtime/haptics.cjs.map +1 -0
  116. package/lib/cjs/runtime/haptics.d.ts +48 -0
  117. package/lib/cjs/runtime/hooks/use-css.cjs +21 -0
  118. package/lib/cjs/runtime/hooks/use-css.cjs.map +1 -0
  119. package/lib/cjs/runtime/hooks/use-css.d.ts +11 -0
  120. package/lib/cjs/runtime/hooks/use-interact.cjs +46 -0
  121. package/lib/cjs/runtime/hooks/use-interact.cjs.map +1 -0
  122. package/lib/cjs/runtime/hooks/use-interact.d.ts +42 -0
  123. package/lib/cjs/runtime/hooks/use-scheme.cjs +68 -0
  124. package/lib/cjs/runtime/hooks/use-scheme.cjs.map +1 -0
  125. package/lib/cjs/runtime/hooks/use-scheme.d.ts +34 -0
  126. package/lib/cjs/runtime/index.cjs +45 -0
  127. package/lib/cjs/runtime/index.cjs.map +1 -0
  128. package/lib/cjs/runtime/index.d.ts +27 -0
  129. package/lib/cjs/runtime/interactive-box.cjs +35 -0
  130. package/lib/cjs/runtime/interactive-box.cjs.map +1 -0
  131. package/lib/cjs/runtime/interactive-box.d.ts +40 -0
  132. package/lib/cjs/runtime/lookup-css.cjs +542 -0
  133. package/lib/cjs/runtime/lookup-css.cjs.map +1 -0
  134. package/lib/cjs/runtime/lookup-css.d.ts +164 -0
  135. package/lib/cjs/runtime/types.d.ts +29 -0
  136. package/lib/cjs/testing/index.cjs +367 -0
  137. package/lib/cjs/testing/index.cjs.map +1 -0
  138. package/lib/cjs/testing/index.d.ts +145 -0
  139. package/lib/esm/core/parser/animation.d.ts +126 -0
  140. package/lib/esm/core/parser/animation.mjs +408 -0
  141. package/lib/esm/core/parser/animation.mjs.map +1 -0
  142. package/lib/esm/core/parser/border-dispatcher.d.ts +15 -0
  143. package/lib/esm/core/parser/border-dispatcher.mjs +178 -0
  144. package/lib/esm/core/parser/border-dispatcher.mjs.map +1 -0
  145. package/lib/esm/core/parser/case-convert.d.ts +6 -0
  146. package/lib/esm/core/parser/case-convert.mjs +13 -0
  147. package/lib/esm/core/parser/case-convert.mjs.map +1 -0
  148. package/lib/esm/core/parser/color-properties-dispatcher.d.ts +19 -0
  149. package/lib/esm/core/parser/color-properties-dispatcher.mjs +82 -0
  150. package/lib/esm/core/parser/color-properties-dispatcher.mjs.map +1 -0
  151. package/lib/esm/core/parser/color.d.ts +12 -0
  152. package/lib/esm/core/parser/color.mjs +162 -0
  153. package/lib/esm/core/parser/color.mjs.map +1 -0
  154. package/lib/esm/core/parser/constants.d.ts +8 -0
  155. package/lib/esm/core/parser/constants.mjs +13 -0
  156. package/lib/esm/core/parser/constants.mjs.map +1 -0
  157. package/lib/esm/core/parser/declaration.d.ts +15 -0
  158. package/lib/esm/core/parser/declaration.mjs +345 -0
  159. package/lib/esm/core/parser/declaration.mjs.map +1 -0
  160. package/lib/esm/core/parser/gradient.d.ts +59 -0
  161. package/lib/esm/core/parser/gradient.mjs +130 -0
  162. package/lib/esm/core/parser/gradient.mjs.map +1 -0
  163. package/lib/esm/core/parser/haptics.d.ts +47 -0
  164. package/lib/esm/core/parser/haptics.mjs +71 -0
  165. package/lib/esm/core/parser/haptics.mjs.map +1 -0
  166. package/lib/esm/core/parser/index.d.ts +8 -0
  167. package/lib/esm/core/parser/keyframes.d.ts +26 -0
  168. package/lib/esm/core/parser/keyframes.mjs +91 -0
  169. package/lib/esm/core/parser/keyframes.mjs.map +1 -0
  170. package/lib/esm/core/parser/layout-dispatcher.d.ts +14 -0
  171. package/lib/esm/core/parser/layout-dispatcher.mjs +98 -0
  172. package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -0
  173. package/lib/esm/core/parser/length.d.ts +48 -0
  174. package/lib/esm/core/parser/length.mjs +90 -0
  175. package/lib/esm/core/parser/length.mjs.map +1 -0
  176. package/lib/esm/core/parser/motion-dispatcher.d.ts +11 -0
  177. package/lib/esm/core/parser/motion-dispatcher.mjs +75 -0
  178. package/lib/esm/core/parser/motion-dispatcher.mjs.map +1 -0
  179. package/lib/esm/core/parser/property.d.ts +8 -0
  180. package/lib/esm/core/parser/property.mjs +20 -0
  181. package/lib/esm/core/parser/property.mjs.map +1 -0
  182. package/lib/esm/core/parser/safe-area.d.ts +39 -0
  183. package/lib/esm/core/parser/safe-area.mjs +402 -0
  184. package/lib/esm/core/parser/safe-area.mjs.map +1 -0
  185. package/lib/esm/core/parser/selector.d.ts +11 -0
  186. package/lib/esm/core/parser/selector.mjs +20 -0
  187. package/lib/esm/core/parser/selector.mjs.map +1 -0
  188. package/lib/esm/core/parser/shorthand.d.ts +61 -0
  189. package/lib/esm/core/parser/shorthand.mjs +148 -0
  190. package/lib/esm/core/parser/shorthand.mjs.map +1 -0
  191. package/lib/esm/core/parser/text-truncate.d.ts +44 -0
  192. package/lib/esm/core/parser/text-truncate.mjs +75 -0
  193. package/lib/esm/core/parser/text-truncate.mjs.map +1 -0
  194. package/lib/esm/core/parser/theme-vars.d.ts +61 -0
  195. package/lib/esm/core/parser/theme-vars.mjs +409 -0
  196. package/lib/esm/core/parser/theme-vars.mjs.map +1 -0
  197. package/lib/esm/core/parser/tokens.d.ts +45 -0
  198. package/lib/esm/core/parser/tokens.mjs +298 -0
  199. package/lib/esm/core/parser/tokens.mjs.map +1 -0
  200. package/lib/esm/core/parser/transform.d.ts +36 -0
  201. package/lib/esm/core/parser/transform.mjs +193 -0
  202. package/lib/esm/core/parser/transform.mjs.map +1 -0
  203. package/lib/esm/core/parser/tw-parser.d.ts +194 -0
  204. package/lib/esm/core/parser/tw-parser.mjs +1565 -0
  205. package/lib/esm/core/parser/tw-parser.mjs.map +1 -0
  206. package/lib/esm/core/parser/types.d.ts +37 -0
  207. package/lib/esm/core/parser/typography-dispatcher.d.ts +11 -0
  208. package/lib/esm/core/parser/typography-dispatcher.mjs +91 -0
  209. package/lib/esm/core/parser/typography-dispatcher.mjs.map +1 -0
  210. package/lib/esm/core/parser/typography.d.ts +43 -0
  211. package/lib/esm/core/parser/typography.mjs +91 -0
  212. package/lib/esm/core/parser/typography.mjs.map +1 -0
  213. package/lib/esm/core/style-builder/build-style.d.ts +54 -0
  214. package/lib/esm/core/style-builder/build-style.mjs +395 -0
  215. package/lib/esm/core/style-builder/build-style.mjs.map +1 -0
  216. package/lib/esm/core/style-builder/index.d.ts +3 -0
  217. package/lib/esm/core/style-builder/union-builder.d.ts +128 -0
  218. package/lib/esm/core/style-builder/union-builder.mjs +324 -0
  219. package/lib/esm/core/style-builder/union-builder.mjs.map +1 -0
  220. package/lib/esm/core/types.d.ts +14 -0
  221. package/lib/esm/metro/dts.d.ts +16 -0
  222. package/lib/esm/metro/dts.mjs +125 -0
  223. package/lib/esm/metro/dts.mjs.map +1 -0
  224. package/lib/esm/metro/index.d.ts +9 -0
  225. package/lib/esm/metro/index.mjs +6 -0
  226. package/lib/esm/metro/index.mjs.map +1 -0
  227. package/lib/esm/metro/resolver.d.ts +22 -0
  228. package/lib/esm/metro/resolver.mjs +43 -0
  229. package/lib/esm/metro/resolver.mjs.map +1 -0
  230. package/lib/esm/metro/state.d.ts +72 -0
  231. package/lib/esm/metro/state.mjs +243 -0
  232. package/lib/esm/metro/state.mjs.map +1 -0
  233. package/lib/esm/metro/transform-ast.d.ts +73 -0
  234. package/lib/esm/metro/transform-ast.mjs +1234 -0
  235. package/lib/esm/metro/transform-ast.mjs.map +1 -0
  236. package/lib/esm/metro/transformer.d.ts +47 -0
  237. package/lib/esm/metro/transformer.mjs +322 -0
  238. package/lib/esm/metro/transformer.mjs.map +1 -0
  239. package/lib/esm/metro/warn-unknown-classes.d.ts +21 -0
  240. package/lib/esm/metro/warn-unknown-classes.mjs +84 -0
  241. package/lib/esm/metro/warn-unknown-classes.mjs.map +1 -0
  242. package/lib/esm/metro/with-config.d.ts +57 -0
  243. package/lib/esm/metro/with-config.mjs +194 -0
  244. package/lib/esm/metro/with-config.mjs.map +1 -0
  245. package/lib/esm/runtime/chain-handlers.d.ts +33 -0
  246. package/lib/esm/runtime/chain-handlers.mjs +34 -0
  247. package/lib/esm/runtime/chain-handlers.mjs.map +1 -0
  248. package/lib/esm/runtime/components/rnwind-provider.d.ts +84 -0
  249. package/lib/esm/runtime/components/rnwind-provider.mjs +94 -0
  250. package/lib/esm/runtime/components/rnwind-provider.mjs.map +1 -0
  251. package/lib/esm/runtime/gradient-types.d.ts +58 -0
  252. package/lib/esm/runtime/haptics.d.ts +48 -0
  253. package/lib/esm/runtime/haptics.mjs +110 -0
  254. package/lib/esm/runtime/haptics.mjs.map +1 -0
  255. package/lib/esm/runtime/hooks/use-css.d.ts +11 -0
  256. package/lib/esm/runtime/hooks/use-css.mjs +19 -0
  257. package/lib/esm/runtime/hooks/use-css.mjs.map +1 -0
  258. package/lib/esm/runtime/hooks/use-interact.d.ts +42 -0
  259. package/lib/esm/runtime/hooks/use-interact.mjs +44 -0
  260. package/lib/esm/runtime/hooks/use-interact.mjs.map +1 -0
  261. package/lib/esm/runtime/hooks/use-scheme.d.ts +34 -0
  262. package/lib/esm/runtime/hooks/use-scheme.mjs +63 -0
  263. package/lib/esm/runtime/hooks/use-scheme.mjs.map +1 -0
  264. package/lib/esm/runtime/index.d.ts +27 -0
  265. package/lib/esm/runtime/index.mjs +18 -0
  266. package/lib/esm/runtime/index.mjs.map +1 -0
  267. package/lib/esm/runtime/interactive-box.d.ts +40 -0
  268. package/lib/esm/runtime/interactive-box.mjs +33 -0
  269. package/lib/esm/runtime/interactive-box.mjs.map +1 -0
  270. package/lib/esm/runtime/lookup-css.d.ts +164 -0
  271. package/lib/esm/runtime/lookup-css.mjs +531 -0
  272. package/lib/esm/runtime/lookup-css.mjs.map +1 -0
  273. package/lib/esm/runtime/types.d.ts +29 -0
  274. package/lib/esm/testing/index.d.ts +145 -0
  275. package/lib/esm/testing/index.mjs +344 -0
  276. package/lib/esm/testing/index.mjs.map +1 -0
  277. package/package.json +79 -13
  278. package/preset.css +1171 -0
  279. package/src/core/parser/animation.ts +404 -0
  280. package/src/core/parser/border-dispatcher.ts +176 -0
  281. package/src/core/parser/case-convert.ts +10 -0
  282. package/src/core/parser/color-properties-dispatcher.ts +78 -0
  283. package/src/core/parser/color.ts +157 -0
  284. package/src/core/parser/constants.ts +11 -0
  285. package/src/core/parser/declaration.ts +340 -0
  286. package/src/core/parser/gradient.ts +148 -0
  287. package/src/core/parser/haptics.ts +88 -0
  288. package/src/core/parser/index.ts +8 -0
  289. package/src/core/parser/keyframes.ts +84 -0
  290. package/src/core/parser/layout-dispatcher.ts +92 -0
  291. package/src/core/parser/length.ts +100 -0
  292. package/src/core/parser/motion-dispatcher.ts +89 -0
  293. package/src/core/parser/property.ts +15 -0
  294. package/src/core/parser/safe-area.ts +404 -0
  295. package/src/core/parser/selector.ts +17 -0
  296. package/src/core/parser/shorthand.ts +152 -0
  297. package/src/core/parser/text-truncate.ts +79 -0
  298. package/src/core/parser/theme-vars.ts +412 -0
  299. package/src/core/parser/tokens.ts +286 -0
  300. package/src/core/parser/transform.ts +195 -0
  301. package/src/core/parser/tw-parser.ts +1709 -0
  302. package/src/core/parser/types.ts +45 -0
  303. package/src/core/parser/typography-dispatcher.ts +83 -0
  304. package/src/core/parser/typography.ts +83 -0
  305. package/src/core/style-builder/build-style.ts +442 -0
  306. package/src/core/style-builder/index.ts +3 -0
  307. package/src/core/style-builder/union-builder.ts +328 -0
  308. package/src/core/types.ts +15 -0
  309. package/src/metro/dts.ts +128 -0
  310. package/src/metro/index.ts +9 -0
  311. package/src/metro/resolver.ts +42 -0
  312. package/src/metro/state.ts +257 -0
  313. package/src/metro/transform-ast.ts +1498 -0
  314. package/src/metro/transformer.ts +347 -0
  315. package/src/metro/warn-unknown-classes.ts +79 -0
  316. package/src/metro/with-config.ts +229 -0
  317. package/src/runtime/chain-handlers.ts +47 -0
  318. package/src/runtime/components/rnwind-provider.tsx +144 -0
  319. package/src/runtime/gradient-types.ts +60 -0
  320. package/src/runtime/haptics.ts +120 -0
  321. package/src/runtime/hooks/use-css.ts +16 -0
  322. package/src/runtime/hooks/use-interact.ts +65 -0
  323. package/src/runtime/hooks/use-scheme.ts +63 -0
  324. package/src/runtime/index.ts +54 -0
  325. package/src/runtime/interactive-box.tsx +57 -0
  326. package/src/runtime/lookup-css.ts +628 -0
  327. package/src/runtime/types.ts +32 -0
  328. package/src/testing/index.ts +507 -0
  329. package/src/types/tailwindcss-node.d.ts +33 -0
  330. package/src/index.ts +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformer.cjs","sources":["../../../../src/metro/transformer.ts"],"sourcesContent":["import type { File } from '@babel/types'\nimport * as t from '@babel/types'\nimport { parse } from '@babel/parser'\nimport generate from '@babel/generator'\nimport { createHash } from 'node:crypto'\nimport { transformAst } from './transform-ast'\nimport { getClassNamePrefixes, getRnwindCacheKey, getRnwindState, onThemeChange } from './state'\nimport { STYLE_SPECIFIERS, THEME_SIGNATURE_MODULE } from './resolver'\nimport { filterUnknownClassCandidates } from './warn-unknown-classes'\n\n/** The shape of the upstream module we delegate parsing/babel work to. */\ninterface UpstreamTransformer {\n transform: (args: BabelTransformerArgs) => Promise<BabelTransformerResult> | BabelTransformerResult\n}\n\n/** Env var that points at the upstream `babelTransformerPath` we override. */\nconst UPSTREAM_ENV = 'RNWIND_UPSTREAM_TRANSFORMER'\n\n/** Cached upstream module — required once, reused across every transform call. */\nlet cachedUpstream: UpstreamTransformer | null = null\n\nconst generateModule = (generate as unknown as { default?: typeof generate }).default ?? generate\n\n/**\n * Parse user source with the broad plugin set (Flow + JSX + TypeScript\n * + class properties). Permissive on purpose so we don't reject any\n * file the upstream could have handled. Returns `null` when parse\n * fails — caller falls back to the raw source string.\n * @param source Source text.\n * @returns Parsed AST, or null on parse failure.\n */\nfunction parseUserSource(source: string): File | null {\n try {\n return parse(source, {\n sourceType: 'unambiguous',\n allowReturnOutsideFunction: true,\n allowImportExportEverywhere: true,\n plugins: ['typescript', 'jsx'],\n }) as unknown as File\n } catch {\n try {\n return parse(source, {\n sourceType: 'unambiguous',\n allowReturnOutsideFunction: true,\n allowImportExportEverywhere: true,\n plugins: ['flow', 'jsx'],\n }) as unknown as File\n } catch {\n return null\n }\n }\n}\n\n/**\n * Print Tailwind-shaped candidates oxide picked up but the parser\n * could NOT compile — typo, missing custom utility, or class not in\n * the user's theme. Filtering by candidates that ALSO appear inside a\n * `className=\"…\"` literal eliminates false positives from imports,\n * comments, and JSX prop values.\n * @param source Original source text — searched for className literals.\n * @param candidates Every candidate oxide surfaced from the source.\n * @param atoms Successfully resolved atoms (keys are class names).\n * @param filename Source path, prefixed onto the warning.\n */\nfunction warnUnknownClasses(\n source: string,\n candidates: readonly string[],\n atoms: ReadonlyMap<string, unknown>,\n filename: string,\n): void {\n const atomNames = new Set(atoms.keys())\n const unknown = filterUnknownClassCandidates(source, candidates, atomNames)\n if (unknown.length === 0) return\n // eslint-disable-next-line no-console\n console.warn(`rnwind: unknown class${unknown.length > 1 ? 'es' : ''} in ${filename}: ${unknown.join(', ')}`)\n}\n\n/**\n * Extract the bare extension for oxide / internal switches.\n * @param filename Absolute path.\n * @returns Extension without the leading dot (`tsx` / `ts` / `js` / `jsx`).\n */\nfunction extensionOf(filename: string): string {\n const index = filename.lastIndexOf('.')\n if (index === -1) return 'tsx'\n return filename.slice(index + 1)\n}\n\n/**\n * Read the project root Metro hands us per-transform. Falls back to\n * `process.cwd()` only when the upstream harness doesn't set it (unit\n * tests, standalone). Metro's production pipeline always sets it.\n * @param args Metro transformer args.\n * @returns Absolute project root.\n */\nfunction projectRootOf(args: BabelTransformerArgs): string {\n const fromOptions = args.options?.projectRoot\n if (typeof fromOptions === 'string' && fromOptions.length > 0) return fromOptions\n return process.cwd()\n}\n\n/**\n * Whether a `.css` filename is the user's theme entry (the file\n * `withRnwindConfig` pointed us at via `RNWIND_CSS_ENTRY_FILE`).\n * Only the theme CSS should trigger a scheme rebuild — unrelated CSS\n * files in the project stay invisible to rnwind.\n * @param filename Absolute CSS path.\n * @returns Whether the file is the configured theme entry.\n */\nfunction isThemeCssEntry(filename: string): boolean {\n const cssEntry = process.env.RNWIND_CSS_ENTRY_FILE\n return typeof cssEntry === 'string' && cssEntry.length > 0 && cssEntry === filename\n}\n\n/**\n * Parse + run rnwind's JSX rewrite + regenerate source code. When\n * parsing or transformation fails, fall back to the original source —\n * we don't want a transient parse error to crash Metro for a file the\n * upstream might handle fine.\n * @param args Metro args; `src` is the original source text.\n * @returns Rewritten source text (with `className=` rewrites applied).\n */\nasync function rewriteSource(args: BabelTransformerArgs): Promise<string> {\n const ast = parseUserSource(args.src)\n if (!ast) return args.src\n\n const state = getRnwindState(projectRootOf(args))\n const extension = extensionOf(args.filename)\n const parsed = await state.parser.parseAtoms({ content: args.src, extension })\n\n warnUnknownClasses(args.src, parsed.candidates, parsed.atoms, args.filename)\n\n const classNamePrefixes = getClassNamePrefixes()\n if (parsed.atoms.size === 0) {\n state.builder.dropFile(args.filename)\n await state.builder.writeSchemes()\n transformAst(ast, {\n styleSpecifiers: [],\n gradientAtoms: parsed.gradientAtoms,\n hapticAtoms: parsed.hapticAtoms,\n classNamePrefixes,\n })\n injectThemeSignatureImport(ast)\n return generateModule(ast).code\n }\n\n const { changed } = await state.builder.recordFile(args.filename, parsed.atoms, parsed.keyframes)\n if (changed) await state.builder.writeSchemes()\n\n transformAst(ast, {\n styleSpecifiers: STYLE_SPECIFIERS as unknown as readonly string[],\n gradientAtoms: parsed.gradientAtoms,\n hapticAtoms: parsed.hapticAtoms,\n classNamePrefixes,\n })\n injectThemeSignatureImport(ast)\n return generateModule(ast).code\n}\n\n/**\n * Prepend `import 'rnwind/__generated/theme-signature'` to every\n * rnwind-transformed file. The resolver maps that specifier to the\n * user's theme CSS so Metro's dependency graph carries a real edge\n * from this JS file to the CSS. When the user edits `global.css`,\n * the CSS module's SHA1 changes, and Metro invalidates every JS file\n * holding this import — forcing them to re-transform with the new\n * theme. The `.css` branch in {@link transform} returns an empty\n * `export {}` module so the runtime cost is one extra `require()`.\n * @param ast Babel File AST to mutate in place.\n */\nfunction injectThemeSignatureImport(ast: File): void {\n const declaration = t.importDeclaration([], t.stringLiteral(THEME_SIGNATURE_MODULE))\n ast.program.body.unshift(declaration)\n}\n\n/**\n * Read the upstream transformer's `getCacheKey()` so our cache-key\n * contribution composes with — rather than replaces — whatever the\n * host framework wants to mix in.\n * @returns Upstream cache key, or `null` when no upstream exposes one.\n */\nfunction loadUpstreamCacheKey(): string | null {\n const upstream = loadUpstream() as (UpstreamTransformer & { getCacheKey?: () => string }) | null\n if (!upstream) return null\n try {\n return typeof upstream.getCacheKey === 'function' ? upstream.getCacheKey() : null\n } catch {\n return null\n }\n}\n\n/**\n * Invoke the upstream `babelTransformerPath` Metro originally had\n * configured. The path is read from `RNWIND_UPSTREAM_TRANSFORMER`,\n * which `withRnwindConfig` sets at Metro startup. When the env var is\n * unset (unit tests, standalone use), fall back to a typescript+jsx\n * parse.\n * @param args Metro's per-file args.\n * @returns Upstream transform result containing the post-babel AST.\n */\nasync function runUpstream(args: BabelTransformerArgs): Promise<BabelTransformerResult> {\n if (args.ast && !process.env[UPSTREAM_ENV]) return { ast: args.ast }\n const upstream = loadUpstream()\n if (upstream) return await Promise.resolve(upstream.transform(args))\n if (args.ast) return { ast: args.ast }\n return { ast: parseSource(args.src) }\n}\n\n/**\n * Lazily require the upstream transformer module. Cached after first\n * load so per-file overhead is one cache lookup.\n * @returns Upstream module, or null when env is unset.\n */\nfunction loadUpstream(): UpstreamTransformer | null {\n if (cachedUpstream) return cachedUpstream\n const upstreamPath = process.env[UPSTREAM_ENV]\n if (!upstreamPath || upstreamPath.length === 0) return null\n try {\n // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires\n const required = require(upstreamPath) as UpstreamTransformer | { default?: UpstreamTransformer }\n const upstream = (required as { default?: UpstreamTransformer }).default ?? (required as UpstreamTransformer)\n if (typeof upstream.transform !== 'function') return null\n cachedUpstream = upstream\n return upstream\n } catch (error) {\n // eslint-disable-next-line no-console\n if (process.env.RNWIND_DEBUG) console.error('rnwind: failed to load upstream transformer:', error)\n return null\n }\n}\n\n/**\n * Cheap guard — the file has to look JS/TS, live outside `node_modules`,\n * and mention `className=` before we spend AST cycles on it.\n * @param args Metro args.\n * @returns Whether the file might need the rnwind pass.\n */\nfunction isRewriteCandidate(args: BabelTransformerArgs): boolean {\n if (!/\\.(?:tsx|ts|jsx|js)$/i.test(args.filename)) return false\n if (args.filename.includes('/node_modules/')) return false\n return args.src.includes('className=')\n}\n\n/**\n * Fallback parse when no upstream is configured AND Metro didn't hand\n * us an AST. Used by unit tests and standalone setups.\n * @param source Source text.\n * @returns Parsed Babel File.\n */\nfunction parseSource(source: string): File {\n return parse(source, { sourceType: 'module', plugins: ['typescript', 'jsx'] }) as unknown as File\n}\n\n/** Metro's babel transformer signature. */\nexport interface BabelTransformerArgs {\n filename: string\n src: string\n options: { projectRoot?: string; [key: string]: unknown }\n ast?: File\n plugins?: readonly unknown[]\n}\n\n/** Return shape Metro expects from a babel transformer. */\nexport interface BabelTransformerResult {\n ast: File\n metadata?: unknown\n}\n\n/**\n * rnwind's Metro babel transformer. Two phases per source file:\n *\n * 1. **Pre-process the source string before handing it to the upstream\n * babel pipeline.** babel-preset-expo / React's JSX transform run\n * inside the upstream and convert `<View className=\"...\"/>` into\n * `React.createElement(View, {className})`. If we walked the AST\n * AFTER the upstream, there'd be no JSX attributes left to\n * rewrite. So we parse, run our pass, regenerate code, and feed\n * THAT to the upstream as `src`.\n * 2. **Delegate to the upstream `babelTransformerPath`** (Expo's\n * default handles Flow stripping, expo-router macros, etc.).\n *\n * Skip both phases when the file isn't a JS/TS source under user\n * code, or doesn't mention `className=` — hand straight to upstream.\n * @param args Metro's per-file args.\n * @returns Mutated AST + metadata.\n */\nexport async function transform(args: BabelTransformerArgs): Promise<BabelTransformerResult> {\n // Short-circuit `.css` inputs: the theme CSS is pulled into the dep\n // graph as a sentinel (see `THEME_SIGNATURE_MODULE` in resolver.ts)\n // so Metro watches it and invalidates importers on edit, but the\n // file's CSS syntax can't go through a JS babel transformer.\n //\n // When the CSS being transformed IS the user's theme entry, we\n // piggyback on Metro's own file-watcher: Metro calls us here on\n // every CSS save; we trigger `onThemeChange` to rebuild parser +\n // rewrite scheme files with the new values. Metro's dep graph then\n // HMRs the regenerated `common.style.js` to the running app.\n //\n // Emitting the CSS content hash in the fake JS output is what makes\n // Metro propagate invalidation to downstream importers — constant\n // `export {}` bytes would never look changed and Metro would skip\n // the chain.\n if (args.filename.endsWith('.css')) {\n if (isThemeCssEntry(args.filename)) {\n try {\n await onThemeChange(projectRootOf(args))\n } catch {\n // CSS edit happened outside a configured project (e.g. tests).\n }\n }\n const themeHash = createHash('sha256').update(args.src).digest('hex').slice(0, 16)\n const stub = `export const __rnwindThemeHash = ${JSON.stringify(themeHash)};\\n`\n return { ast: parse(stub, { sourceType: 'module' }) as unknown as File }\n }\n if (!isRewriteCandidate(args)) {\n if (/\\.(?:tsx|ts|jsx|js)$/i.test(args.filename) && !args.filename.includes('/node_modules/')) {\n try {\n getRnwindState(projectRootOf(args)).builder.dropFile(args.filename)\n } catch {\n // State not configured (e.g. test). Nothing to drop.\n }\n }\n return runUpstream(args)\n }\n\n const rewrittenSource = await rewriteSource(args)\n return runUpstream({ ...args, src: rewrittenSource, ast: undefined })\n}\n\n/**\n * Metro's babel-transformer contract: a `getCacheKey()` export is\n * sampled per-file and mixed into the transform cache key. Returning\n * a string that includes the theme CSS content hash invalidates every\n * cached transform on every CSS edit — so the bundle rebuilds with\n * the new theme automatically on the next request.\n * @returns Cache-key segment that includes rnwind's current theme hash.\n */\nexport function getCacheKey(): string {\n const upstreamKey = loadUpstreamCacheKey()\n const ownKey = getRnwindCacheKey()\n return upstreamKey ? `${upstreamKey}|${ownKey}` : ownKey\n}\n\n/** Test-only — drop the cached upstream so a new env var picks up next call. */\nexport function __resetUpstreamCache(): void {\n cachedUpstream = null\n}\n"],"names":["parse","filterUnknownClassCandidates","state","getRnwindState","getClassNamePrefixes","transformAst","STYLE_SPECIFIERS","t","THEME_SIGNATURE_MODULE","onThemeChange","createHash","getRnwindCacheKey"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAeA;AACA,MAAM,YAAY,GAAG,6BAA6B;AAElD;AACA,IAAI,cAAc,GAA+B,IAAI;AAErD,MAAM,cAAc,GAAI,QAAqD,CAAC,OAAO,IAAI,QAAQ;AAEjG;;;;;;;AAOG;AACH,SAAS,eAAe,CAAC,MAAc,EAAA;AACrC,IAAA,IAAI;QACF,OAAOA,YAAK,CAAC,MAAM,EAAE;AACnB,YAAA,UAAU,EAAE,aAAa;AACzB,YAAA,0BAA0B,EAAE,IAAI;AAChC,YAAA,2BAA2B,EAAE,IAAI;AACjC,YAAA,OAAO,EAAE,CAAC,YAAY,EAAE,KAAK,CAAC;AAC/B,SAAA,CAAoB;IACvB;AAAE,IAAA,MAAM;AACN,QAAA,IAAI;YACF,OAAOA,YAAK,CAAC,MAAM,EAAE;AACnB,g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C,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE;AAC5F,YAAA,IAAI;AACF,gBAAAG,oBAAc,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;YACrE;AAAE,YAAA,MAAM;;YAER;QACF;AACA,QAAA,OAAO,WAAW,CAAC,IAAI,CAAC;IAC1B;AAEA,IAAA,MAAM,eAAe,GAAG,MAAM,aAAa,CAAC,IAAI,CAAC;AACjD,IAAA,OAAO,WAAW,CAAC,EAAE,GAAG,IAAI,EAAE,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC;AACvE;AAEA;;;;;;;AAOG;SACa,WAAW,GAAA;AACzB,IAAA,MAAM,WAAW,GAAG,oBAAoB,EAAE;AAC1C,IAAA,MAAM,MAAM,GAAGQ,uBAAiB,EAAE;AAClC,IAAA,OAAO,WAAW,GAAG,CAAA,EAAG,WAAW,CAAA,CAAA,EAAI,MAAM,CAAA,CAAE,GAAG,MAAM;AAC1D;AAEA;SACgB,oBAAoB,GAAA;IAClC,cAAc,GAAG,IAAI;AACvB;;;;;;"}
@@ -0,0 +1,47 @@
1
+ import type { File } from '@babel/types';
2
+ /** Metro's babel transformer signature. */
3
+ export interface BabelTransformerArgs {
4
+ filename: string;
5
+ src: string;
6
+ options: {
7
+ projectRoot?: string;
8
+ [key: string]: unknown;
9
+ };
10
+ ast?: File;
11
+ plugins?: readonly unknown[];
12
+ }
13
+ /** Return shape Metro expects from a babel transformer. */
14
+ export interface BabelTransformerResult {
15
+ ast: File;
16
+ metadata?: unknown;
17
+ }
18
+ /**
19
+ * rnwind's Metro babel transformer. Two phases per source file:
20
+ *
21
+ * 1. **Pre-process the source string before handing it to the upstream
22
+ * babel pipeline.** babel-preset-expo / React's JSX transform run
23
+ * inside the upstream and convert `<View className="..."/>` into
24
+ * `React.createElement(View, {className})`. If we walked the AST
25
+ * AFTER the upstream, there'd be no JSX attributes left to
26
+ * rewrite. So we parse, run our pass, regenerate code, and feed
27
+ * THAT to the upstream as `src`.
28
+ * 2. **Delegate to the upstream `babelTransformerPath`** (Expo's
29
+ * default handles Flow stripping, expo-router macros, etc.).
30
+ *
31
+ * Skip both phases when the file isn't a JS/TS source under user
32
+ * code, or doesn't mention `className=` — hand straight to upstream.
33
+ * @param args Metro's per-file args.
34
+ * @returns Mutated AST + metadata.
35
+ */
36
+ export declare function transform(args: BabelTransformerArgs): Promise<BabelTransformerResult>;
37
+ /**
38
+ * Metro's babel-transformer contract: a `getCacheKey()` export is
39
+ * sampled per-file and mixed into the transform cache key. Returning
40
+ * a string that includes the theme CSS content hash invalidates every
41
+ * cached transform on every CSS edit — so the bundle rebuilds with
42
+ * the new theme automatically on the next request.
43
+ * @returns Cache-key segment that includes rnwind's current theme hash.
44
+ */
45
+ export declare function getCacheKey(): string;
46
+ /** Test-only — drop the cached upstream so a new env var picks up next call. */
47
+ export declare function __resetUpstreamCache(): void;
@@ -0,0 +1,86 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Yield every literal-text segment found at a `className=` site.
5
+ * @param source Raw source text.
6
+ * @yields Each literal's inner text.
7
+ */
8
+ function* iterateClassNameLiterals(source) {
9
+ // className="..." / className='...'
10
+ for (const match of source.matchAll(/className\s*=\s*"([^"]*)"/g))
11
+ yield match[1] ?? '';
12
+ for (const match of source.matchAll(/className\s*=\s*'([^']*)'/g))
13
+ yield match[1] ?? '';
14
+ // className={"..."} / className={'...'}
15
+ for (const match of source.matchAll(/className\s*=\s*\{\s*"([^"]*)"\s*\}/g))
16
+ yield match[1] ?? '';
17
+ for (const match of source.matchAll(/className\s*=\s*\{\s*'([^']*)'\s*\}/g))
18
+ yield match[1] ?? '';
19
+ // className={`...`} — yield each static quasi between `${...}` substitutions.
20
+ for (const match of source.matchAll(/className\s*=\s*\{\s*`([^`]*)`\s*\}/g)) {
21
+ const body = match[1] ?? '';
22
+ for (const part of body.split(/\$\{[^}]*\}/))
23
+ yield part;
24
+ }
25
+ }
26
+ /**
27
+ * Pull every `className="…"`, `className={'…'}`, `className={"…"}`, and
28
+ * `className={\`…\`}` literal out of the source and union their
29
+ * whitespace-separated tokens. A regex-based scan is enough — the
30
+ * warning is best-effort, not load-bearing, and a regex sidesteps
31
+ * having to re-parse the file.
32
+ *
33
+ * Skipped on purpose:
34
+ * - `className={someExpression}` with no inline literal (we can't
35
+ * introspect the runtime value at build time).
36
+ * - Template literals with substitutions (`` `text-${size}` ``) — we
37
+ * only union the static-quasi parts, which is fine because the
38
+ * warning fires only on candidates that ARE in the static parts.
39
+ * @param source Raw source text.
40
+ * @returns Set of whitespace-separated tokens drawn from every literal.
41
+ */
42
+ function collectClassNameTokens(source) {
43
+ const out = new Set();
44
+ for (const literal of iterateClassNameLiterals(source)) {
45
+ for (const token of literal.split(/\s+/)) {
46
+ if (token.length > 0)
47
+ out.add(token);
48
+ }
49
+ }
50
+ return out;
51
+ }
52
+ /**
53
+ * Filter Tailwind candidate strings down to ones that actually appear
54
+ * as a token inside a `className="…"` literal in the source. Oxide
55
+ * scans the entire file and surfaces anything Tailwind-shaped — that
56
+ * includes import specifiers (`'expo-router'`), comment markers
57
+ * (`/* @rnwind-theme=… *\/`), JSX prop values (`keyboardType="email-
58
+ * address"`), and bare suffixes Tailwind splits out from compound
59
+ * utilities (`bg-sky-500` also produces `sky-500`). None of those are
60
+ * "unknown classes" worth nagging the user about; the genuine signal
61
+ * is a typo in a real `className`, e.g. `bg-srface` for `bg-surface`.
62
+ *
63
+ * The filter walks every `className="…" / {'…'} / {`…`}` literal in the
64
+ * source, splits each on whitespace, and unions the tokens. Only
65
+ * candidates in that token set survive. Then known-good atoms are
66
+ * subtracted, leaving genuine typos.
67
+ * @param source Raw source text the transformer received from Metro.
68
+ * @param candidates Every candidate oxide picked up.
69
+ * @param atoms Set of atom names the parser successfully resolved.
70
+ * @returns Candidates that look like real "unknown classes" the user typed.
71
+ */
72
+ function filterUnknownClassCandidates(source, candidates, atoms) {
73
+ const literalTokens = collectClassNameTokens(source);
74
+ const out = [];
75
+ for (const candidate of candidates) {
76
+ if (atoms.has(candidate))
77
+ continue;
78
+ if (!literalTokens.has(candidate))
79
+ continue;
80
+ out.push(candidate);
81
+ }
82
+ return out;
83
+ }
84
+
85
+ exports.filterUnknownClassCandidates = filterUnknownClassCandidates;
86
+ //# sourceMappingURL=warn-unknown-classes.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warn-unknown-classes.cjs","sources":["../../../../src/metro/warn-unknown-classes.ts"],"sourcesContent":["/**\n * Yield every literal-text segment found at a `className=` site.\n * @param source Raw source text.\n * @yields Each literal's inner text.\n */\nfunction* iterateClassNameLiterals(source: string): Iterable<string> {\n // className=\"...\" / className='...'\n for (const match of source.matchAll(/className\\s*=\\s*\"([^\"]*)\"/g)) yield match[1] ?? ''\n for (const match of source.matchAll(/className\\s*=\\s*'([^']*)'/g)) yield match[1] ?? ''\n // className={\"...\"} / className={'...'}\n for (const match of source.matchAll(/className\\s*=\\s*\\{\\s*\"([^\"]*)\"\\s*\\}/g)) yield match[1] ?? ''\n for (const match of source.matchAll(/className\\s*=\\s*\\{\\s*'([^']*)'\\s*\\}/g)) yield match[1] ?? ''\n // className={`...`} — yield each static quasi between `${...}` substitutions.\n for (const match of source.matchAll(/className\\s*=\\s*\\{\\s*`([^`]*)`\\s*\\}/g)) {\n const body = match[1] ?? ''\n for (const part of body.split(/\\$\\{[^}]*\\}/)) yield part\n }\n}\n\n/**\n * Pull every `className=\"…\"`, `className={'…'}`, `className={\"…\"}`, and\n * `className={\\`…\\`}` literal out of the source and union their\n * whitespace-separated tokens. A regex-based scan is enough — the\n * warning is best-effort, not load-bearing, and a regex sidesteps\n * having to re-parse the file.\n *\n * Skipped on purpose:\n * - `className={someExpression}` with no inline literal (we can't\n * introspect the runtime value at build time).\n * - Template literals with substitutions (`` `text-${size}` ``) — we\n * only union the static-quasi parts, which is fine because the\n * warning fires only on candidates that ARE in the static parts.\n * @param source Raw source text.\n * @returns Set of whitespace-separated tokens drawn from every literal.\n */\nfunction collectClassNameTokens(source: string): Set<string> {\n const out = new Set<string>()\n for (const literal of iterateClassNameLiterals(source)) {\n for (const token of literal.split(/\\s+/)) {\n if (token.length > 0) out.add(token)\n }\n }\n return out\n}\n\n/**\n * Filter Tailwind candidate strings down to ones that actually appear\n * as a token inside a `className=\"…\"` literal in the source. Oxide\n * scans the entire file and surfaces anything Tailwind-shaped — that\n * includes import specifiers (`'expo-router'`), comment markers\n * (`/* @rnwind-theme=… *\\/`), JSX prop values (`keyboardType=\"email-\n * address\"`), and bare suffixes Tailwind splits out from compound\n * utilities (`bg-sky-500` also produces `sky-500`). None of those are\n * \"unknown classes\" worth nagging the user about; the genuine signal\n * is a typo in a real `className`, e.g. `bg-srface` for `bg-surface`.\n *\n * The filter walks every `className=\"…\" / {'…'} / {`…`}` literal in the\n * source, splits each on whitespace, and unions the tokens. Only\n * candidates in that token set survive. Then known-good atoms are\n * subtracted, leaving genuine typos.\n * @param source Raw source text the transformer received from Metro.\n * @param candidates Every candidate oxide picked up.\n * @param atoms Set of atom names the parser successfully resolved.\n * @returns Candidates that look like real \"unknown classes\" the user typed.\n */\nexport function filterUnknownClassCandidates(\n source: string,\n candidates: readonly string[],\n atoms: ReadonlySet<string>,\n): string[] {\n const literalTokens = collectClassNameTokens(source)\n const out: string[] = []\n for (const candidate of candidates) {\n if (atoms.has(candidate)) continue\n if (!literalTokens.has(candidate)) continue\n out.push(candidate)\n }\n return out\n}\n"],"names":[],"mappings":";;AAAA;;;;AAIG;AACH,UAAU,wBAAwB,CAAC,MAAc,EAAA;;IAE/C,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAC;AAAE,QAAA,MAAM,KAAK,CAAC,CAAC,CAAC,IAAI,EAAE;IACvF,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,QAAQ,CAAC,4BAA4B,CAAC;AAA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AA,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,SAAS,CAAC;YAAE;AACnC,QAAA,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC;IACrB;AACA,IAAA,OAAO,GAAG;AACZ;;;;"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Filter Tailwind candidate strings down to ones that actually appear
3
+ * as a token inside a `className="…"` literal in the source. Oxide
4
+ * scans the entire file and surfaces anything Tailwind-shaped — that
5
+ * includes import specifiers (`'expo-router'`), comment markers
6
+ * (`/* @rnwind-theme=… *\/`), JSX prop values (`keyboardType="email-
7
+ * address"`), and bare suffixes Tailwind splits out from compound
8
+ * utilities (`bg-sky-500` also produces `sky-500`). None of those are
9
+ * "unknown classes" worth nagging the user about; the genuine signal
10
+ * is a typo in a real `className`, e.g. `bg-srface` for `bg-surface`.
11
+ *
12
+ * The filter walks every `className="…" / {'…'} / {`…`}` literal in the
13
+ * source, splits each on whitespace, and unions the tokens. Only
14
+ * candidates in that token set survive. Then known-good atoms are
15
+ * subtracted, leaving genuine typos.
16
+ * @param source Raw source text the transformer received from Metro.
17
+ * @param candidates Every candidate oxide picked up.
18
+ * @param atoms Set of atom names the parser successfully resolved.
19
+ * @returns Candidates that look like real "unknown classes" the user typed.
20
+ */
21
+ export declare function filterUnknownClassCandidates(source: string, candidates: readonly string[], atoms: ReadonlySet<string>): string[];
@@ -0,0 +1,196 @@
1
+ 'use strict';
2
+
3
+ var node_fs = require('node:fs');
4
+ var path = require('node:path');
5
+ var dts = require('./dts.cjs');
6
+ var resolver = require('./resolver.cjs');
7
+ var state = require('./state.cjs');
8
+
9
+ /** Default cache directory at the project root. Visible for debugging. */
10
+ const DEFAULT_CACHE_DIR = '.rnwind';
11
+ /**
12
+ * Active CSS watcher — replaced (and the prior one closed) when
13
+ * `withRnwindConfig` is called again (Metro restart, repeated init).
14
+ * Only one watcher per process; no stacking.
15
+ */
16
+ let activeCssWatcher = null;
17
+ /**
18
+ * Watch the theme CSS for edits. On change, rewrite the per-scheme
19
+ * files with the fresh theme AND bump `mtime` on every source file
20
+ * rnwind has transformed so far — Metro's own watcher sees those
21
+ * mtime changes, invalidates the modules, and re-transforms them
22
+ * against the new CSS on the next request. `getCacheKey()` alone is
23
+ * NOT enough: Metro samples the cache key once per worker lifetime,
24
+ * so edits during an already-running dev server don't propagate
25
+ * without this explicit nudge.
26
+ * @param cssPath Absolute path to the theme CSS to watch.
27
+ * @param projectRoot Metro's project root (for `getRnwindState`).
28
+ */
29
+ function watchThemeCss(cssPath, projectRoot) {
30
+ if (activeCssWatcher?.cssPath === cssPath)
31
+ return;
32
+ activeCssWatcher?.close();
33
+ if (!node_fs.existsSync(cssPath))
34
+ return;
35
+ let pending = false;
36
+ const watcher = node_fs.watch(cssPath, { persistent: false }, () => {
37
+ // Debounce: editors often emit 2-3 change events per save (atomic
38
+ // rename dance, tmp files). Coalesce to ONE rebuild per microtask.
39
+ if (pending)
40
+ return;
41
+ pending = true;
42
+ queueMicrotask(async () => {
43
+ pending = false;
44
+ try {
45
+ await state.onThemeChange(projectRoot);
46
+ touchRecordedFiles(projectRoot);
47
+ }
48
+ catch {
49
+ // Invalidation is best-effort — never crash the dev server.
50
+ }
51
+ });
52
+ });
53
+ activeCssWatcher = { cssPath, close: () => watcher.close() };
54
+ }
55
+ /**
56
+ * Bump the mtime on every file the builder has transformed. Metro's
57
+ * file watcher keys on `mtime`, so this is what makes it invalidate
58
+ * those modules and re-transform them.
59
+ * @param projectRoot Metro's project root.
60
+ */
61
+ function touchRecordedFiles(projectRoot) {
62
+ const state$1 = state.getRnwindState(projectRoot);
63
+ const files = state$1.builder.recordedFiles();
64
+ const now = new Date();
65
+ for (const file of files) {
66
+ try {
67
+ if (node_fs.existsSync(file))
68
+ node_fs.utimesSync(file, now, now);
69
+ }
70
+ catch {
71
+ // One file's stat failure shouldn't stop the others.
72
+ }
73
+ }
74
+ }
75
+ /**
76
+ * Where the rnwind babel transformer lives — resolved relative to this
77
+ * module so the path works from both the `src/` tree (tests) and the
78
+ * built `lib/` output. Tries a few extensions because `require.resolve`
79
+ * doesn't auto-find `.cjs` / `.mjs` from a bare specifier.
80
+ * @returns Absolute path to the rnwind transformer module.
81
+ */
82
+ function transformerPath() {
83
+ for (const candidate of ['./transformer.cjs', './transformer.mjs', './transformer.js', './transformer.ts', './transformer']) {
84
+ try {
85
+ return require.resolve(candidate);
86
+ }
87
+ catch {
88
+ // try the next extension
89
+ }
90
+ }
91
+ throw new Error('rnwind: could not resolve the metro transformer path');
92
+ }
93
+ /**
94
+ * Resolve the effective cache directory, honoring a user override and
95
+ * falling back to `<projectRoot>/.rnwind`.
96
+ * @param projectRoot Anchor for relative paths.
97
+ * @param override User-supplied option.
98
+ * @returns Absolute cache directory.
99
+ */
100
+ function resolveCacheDir(projectRoot, override) {
101
+ if (!override || override.length === 0)
102
+ return path.resolve(projectRoot, DEFAULT_CACHE_DIR);
103
+ return path.isAbsolute(override) ? override : path.resolve(projectRoot, override);
104
+ }
105
+ /**
106
+ * Read the theme CSS and extract `@variant <name>` blocks for the .d.ts
107
+ * generator. Forces construction of `getRnwindState`, then reads
108
+ * `parser.declaredSchemes` (populated synchronously at construction).
109
+ * @param cssEntry Absolute path to theme CSS.
110
+ * @param projectRoot
111
+ * @returns Scheme names (empty when the theme has no variants; `'base'` is filtered).
112
+ */
113
+ function discoverSchemes(cssEntry, projectRoot) {
114
+ if (!node_fs.existsSync(cssEntry))
115
+ return [];
116
+ try {
117
+ const { parser } = state.getRnwindState(projectRoot);
118
+ return parser.declaredSchemes.filter((name) => name !== 'base');
119
+ }
120
+ catch {
121
+ return [];
122
+ }
123
+ }
124
+ /**
125
+ * Wrap a Metro config with rnwind's pipeline:
126
+ * - Install the rnwind babel transformer.
127
+ * - Chain a `resolveRequest` hook that serves
128
+ * `rnwind/__generated/schemes` from `<cacheDir>/schemes.js`.
129
+ * - Write the `.d.ts` so TypeScript accepts `className=` on RN components.
130
+ * - Publish the theme CSS path + cache dir via env so Metro workers
131
+ * can rebuild their local state.
132
+ * - Ensure the cache dir is a watched folder Metro's haste-map indexes.
133
+ *
134
+ * Theme-edit hot reload happens implicitly: every transformed file
135
+ * imports `rnwind/__generated/schemes`, and that module eager-imports
136
+ * `common.style.js`. When the theme changes, the per-scheme files
137
+ * regenerate with new bytes; Metro's content SHA1 dedup detects the
138
+ * change and invalidates every importer automatically.
139
+ * `getCacheKey()` on the transformer covers the per-file transform
140
+ * cache. No file watcher / source-padding hack needed — the dep graph
141
+ * carries the signal.
142
+ * @param metroConfig Config from `getDefaultConfig(__dirname)` or equivalent.
143
+ * @param options rnwind options.
144
+ * @returns The same config, mutated.
145
+ */
146
+ function withRnwindConfig(metroConfig, options) {
147
+ const projectRoot = options.projectRoot ?? metroConfig.projectRoot ?? process.cwd();
148
+ const cacheDir = resolveCacheDir(projectRoot, options.cacheDir);
149
+ const cssEntry = path.isAbsolute(options.cssEntryFile) ? options.cssEntryFile : path.resolve(projectRoot, options.cssEntryFile);
150
+ node_fs.mkdirSync(cacheDir, { recursive: true });
151
+ const watchFolders = (metroConfig.watchFolders ?? []).filter((p) => typeof p === 'string' && p.length > 0);
152
+ state.configureRnwindState(cssEntry, cacheDir, watchFolders, options.classNamePrefixes);
153
+ // Warm the state eagerly (in the Metro master process) so oxide's
154
+ // Scanner walks every project source (and every monorepo
155
+ // watch-folder) ONCE and the manifest + scheme files hold the
156
+ // complete union before Metro's resolver tries to SHA1 them on the
157
+ // first transform. Each worker lazy-repeats this scan on its first
158
+ // transform to converge on identical state.
159
+ try {
160
+ void state.getRnwindState(projectRoot).builder.ensureFilesExist();
161
+ }
162
+ catch {
163
+ // Any init error surfaces again at the first transform; don't crash Metro boot.
164
+ }
165
+ // Install transformer + resolver. Capture the existing
166
+ // babelTransformerPath BEFORE we override it — our worker chains to
167
+ // it (env-passed) so Flow / expo-router / babel-preset-expo etc. all
168
+ // continue to run.
169
+ const existingTransformerPath = metroConfig.transformer?.babelTransformerPath;
170
+ if (typeof existingTransformerPath === 'string' && existingTransformerPath.length > 0) {
171
+ process.env.RNWIND_UPSTREAM_TRANSFORMER = existingTransformerPath;
172
+ }
173
+ const upstream = metroConfig.resolver?.resolveRequest ?? null;
174
+ metroConfig.transformer = { ...metroConfig.transformer, babelTransformerPath: transformerPath() };
175
+ metroConfig.resolver = { ...metroConfig.resolver, resolveRequest: resolver.createRnwindResolver(upstream) };
176
+ // Metro's haste-map indexes `watchFolders` at startup. Adding the
177
+ // cache dir guarantees scheme style files + manifest get SHA1'd
178
+ // without a "Failed to get the SHA-1" race when the first transform
179
+ // writes them.
180
+ const existingWatch = metroConfig.watchFolders ?? [];
181
+ metroConfig.watchFolders = existingWatch.includes(cacheDir) ? existingWatch : [...existingWatch, cacheDir];
182
+ if (options.dtsFile !== false) {
183
+ const dtsPath = options.dtsFile ?? path.resolve(projectRoot, 'rnwind-types.d.ts');
184
+ const schemes = discoverSchemes(cssEntry, projectRoot);
185
+ dts.writeDtsFile(dtsPath, schemes, options.classNamePrefixes);
186
+ }
187
+ // Watch the theme CSS. On edit, we rewrite scheme files AND touch
188
+ // mtime on every transformed source file so Metro invalidates them
189
+ // and re-transforms — the only reliable way to propagate theme
190
+ // changes to an already-running dev server.
191
+ watchThemeCss(cssEntry, projectRoot);
192
+ return metroConfig;
193
+ }
194
+
195
+ exports.withRnwindConfig = withRnwindConfig;
196
+ //# sourceMappingURL=with-config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-config.cjs","sources":["../../../../src/metro/with-config.ts"],"sourcesContent":["import { existsSync, mkdirSync, utimesSync, watch as watchFile } from 'node:fs'\nimport path from 'node:path'\nimport { writeDtsFile } from './dts'\nimport { createRnwindResolver, type ResolveRequestFn } from './resolver'\nimport { configureRnwindState, getRnwindState, onThemeChange } from './state'\n\n/** Default cache directory at the project root. Visible for debugging. */\nconst DEFAULT_CACHE_DIR = '.rnwind'\n\n/**\n * Active CSS watcher — replaced (and the prior one closed) when\n * `withRnwindConfig` is called again (Metro restart, repeated init).\n * Only one watcher per process; no stacking.\n */\nlet activeCssWatcher: { cssPath: string; close: () => void } | null = null\n\n/**\n * Watch the theme CSS for edits. On change, rewrite the per-scheme\n * files with the fresh theme AND bump `mtime` on every source file\n * rnwind has transformed so far — Metro's own watcher sees those\n * mtime changes, invalidates the modules, and re-transforms them\n * against the new CSS on the next request. `getCacheKey()` alone is\n * NOT enough: Metro samples the cache key once per worker lifetime,\n * so edits during an already-running dev server don't propagate\n * without this explicit nudge.\n * @param cssPath Absolute path to the theme CSS to watch.\n * @param projectRoot Metro's project root (for `getRnwindState`).\n */\nfunction watchThemeCss(cssPath: string, projectRoot: string): void {\n if (activeCssWatcher?.cssPath === cssPath) return\n activeCssWatcher?.close()\n if (!existsSync(cssPath)) return\n let pending = false\n const watcher = watchFile(cssPath, { persistent: false }, () => {\n // Debounce: editors often emit 2-3 change events per save (atomic\n // rename dance, tmp files). Coalesce to ONE rebuild per microtask.\n if (pending) return\n pending = true\n queueMicrotask(async () => {\n pending = false\n try {\n await onThemeChange(projectRoot)\n touchRecordedFiles(projectRoot)\n } catch {\n // Invalidation is best-effort — never crash the dev server.\n }\n })\n })\n activeCssWatcher = { cssPath, close: () => watcher.close() }\n}\n\n/**\n * Bump the mtime on every file the builder has transformed. Metro's\n * file watcher keys on `mtime`, so this is what makes it invalidate\n * those modules and re-transform them.\n * @param projectRoot Metro's project root.\n */\nfunction touchRecordedFiles(projectRoot: string): void {\n const state = getRnwindState(projectRoot)\n const files = state.builder.recordedFiles()\n const now = new Date()\n for (const file of files) {\n try {\n if (existsSync(file)) utimesSync(file, now, now)\n } catch {\n // One file's stat failure shouldn't stop the others.\n }\n }\n}\n\n/**\n * Where the rnwind babel transformer lives — resolved relative to this\n * module so the path works from both the `src/` tree (tests) and the\n * built `lib/` output. Tries a few extensions because `require.resolve`\n * doesn't auto-find `.cjs` / `.mjs` from a bare specifier.\n * @returns Absolute path to the rnwind transformer module.\n */\nfunction transformerPath(): string {\n for (const candidate of ['./transformer.cjs', './transformer.mjs', './transformer.js', './transformer.ts', './transformer']) {\n try {\n return require.resolve(candidate)\n } catch {\n // try the next extension\n }\n }\n throw new Error('rnwind: could not resolve the metro transformer path')\n}\n\n/**\n * Resolve the effective cache directory, honoring a user override and\n * falling back to `<projectRoot>/.rnwind`.\n * @param projectRoot Anchor for relative paths.\n * @param override User-supplied option.\n * @returns Absolute cache directory.\n */\nfunction resolveCacheDir(projectRoot: string, override: string | undefined): string {\n if (!override || override.length === 0) return path.resolve(projectRoot, DEFAULT_CACHE_DIR)\n return path.isAbsolute(override) ? override : path.resolve(projectRoot, override)\n}\n\n/**\n * Read the theme CSS and extract `@variant <name>` blocks for the .d.ts\n * generator. Forces construction of `getRnwindState`, then reads\n * `parser.declaredSchemes` (populated synchronously at construction).\n * @param cssEntry Absolute path to theme CSS.\n * @param projectRoot\n * @returns Scheme names (empty when the theme has no variants; `'base'` is filtered).\n */\nfunction discoverSchemes(cssEntry: string, projectRoot: string): readonly string[] {\n if (!existsSync(cssEntry)) return []\n try {\n const { parser } = getRnwindState(projectRoot)\n return parser.declaredSchemes.filter((name) => name !== 'base')\n } catch {\n return []\n }\n}\n\n/** User-facing options for `withRnwindConfig`. */\nexport interface RnwindMetroOptions {\n /** Path to the theme CSS (absolute or relative to `projectRoot`). Required. */\n cssEntryFile: string\n /** Where rnwind writes the `.d.ts` file. Set `false` to disable. Defaults to `<projectRoot>/rnwind-types.d.ts`. */\n dtsFile?: string | false\n /** Optional project-root override — defaults to `metroConfig.projectRoot` then `process.cwd()`. */\n projectRoot?: string\n /** Cache directory. Absolute, or relative to `projectRoot`. Default: `.rnwind` at project root. */\n cacheDir?: string\n /**\n * Extra JSX prop-name prefixes that rnwind should rewrite. Each\n * prefix `P` turns `<Tag PClassName=\"…\">` into `<Tag\n * PStyle={lookupCss(…)}>`. The built-in `'contentContainer'` prefix\n * is always on (covers ScrollView / FlatList / SectionList); user\n * entries merge on top.\n */\n classNamePrefixes?: readonly string[]\n}\n\n/** Shape we mutate on Metro's config. Loose so we don't pin Metro's internal types. */\nexport interface MetroConfigLike {\n projectRoot?: string\n watchFolders?: string[]\n transformer?: {\n babelTransformerPath?: string\n [key: string]: unknown\n }\n resolver?: {\n resolveRequest?: ResolveRequestFn | null\n [key: string]: unknown\n }\n [key: string]: unknown\n}\n\n/**\n * Wrap a Metro config with rnwind's pipeline:\n * - Install the rnwind babel transformer.\n * - Chain a `resolveRequest` hook that serves\n * `rnwind/__generated/schemes` from `<cacheDir>/schemes.js`.\n * - Write the `.d.ts` so TypeScript accepts `className=` on RN components.\n * - Publish the theme CSS path + cache dir via env so Metro workers\n * can rebuild their local state.\n * - Ensure the cache dir is a watched folder Metro's haste-map indexes.\n *\n * Theme-edit hot reload happens implicitly: every transformed file\n * imports `rnwind/__generated/schemes`, and that module eager-imports\n * `common.style.js`. When the theme changes, the per-scheme files\n * regenerate with new bytes; Metro's content SHA1 dedup detects the\n * change and invalidates every importer automatically.\n * `getCacheKey()` on the transformer covers the per-file transform\n * cache. No file watcher / source-padding hack needed — the dep graph\n * carries the signal.\n * @param metroConfig Config from `getDefaultConfig(__dirname)` or equivalent.\n * @param options rnwind options.\n * @returns The same config, mutated.\n */\nexport function withRnwindConfig<C extends MetroConfigLike>(metroConfig: C, options: RnwindMetroOptions): C {\n const projectRoot = options.projectRoot ?? metroConfig.projectRoot ?? process.cwd()\n const cacheDir = resolveCacheDir(projectRoot, options.cacheDir)\n const cssEntry = path.isAbsolute(options.cssEntryFile) ? options.cssEntryFile : path.resolve(projectRoot, options.cssEntryFile)\n\n mkdirSync(cacheDir, { recursive: true })\n const watchFolders = (metroConfig.watchFolders ?? []).filter((p) => typeof p === 'string' && p.length > 0)\n configureRnwindState(cssEntry, cacheDir, watchFolders, options.classNamePrefixes)\n\n // Warm the state eagerly (in the Metro master process) so oxide's\n // Scanner walks every project source (and every monorepo\n // watch-folder) ONCE and the manifest + scheme files hold the\n // complete union before Metro's resolver tries to SHA1 them on the\n // first transform. Each worker lazy-repeats this scan on its first\n // transform to converge on identical state.\n try {\n void getRnwindState(projectRoot).builder.ensureFilesExist()\n } catch {\n // Any init error surfaces again at the first transform; don't crash Metro boot.\n }\n\n // Install transformer + resolver. Capture the existing\n // babelTransformerPath BEFORE we override it — our worker chains to\n // it (env-passed) so Flow / expo-router / babel-preset-expo etc. all\n // continue to run.\n const existingTransformerPath = metroConfig.transformer?.babelTransformerPath\n if (typeof existingTransformerPath === 'string' && existingTransformerPath.length > 0) {\n process.env.RNWIND_UPSTREAM_TRANSFORMER = existingTransformerPath\n }\n const upstream = metroConfig.resolver?.resolveRequest ?? null\n metroConfig.transformer = { ...metroConfig.transformer, babelTransformerPath: transformerPath() }\n metroConfig.resolver = { ...metroConfig.resolver, resolveRequest: createRnwindResolver(upstream) }\n\n // Metro's haste-map indexes `watchFolders` at startup. Adding the\n // cache dir guarantees scheme style files + manifest get SHA1'd\n // without a \"Failed to get the SHA-1\" race when the first transform\n // writes them.\n const existingWatch = metroConfig.watchFolders ?? []\n metroConfig.watchFolders = existingWatch.includes(cacheDir) ? existingWatch : [...existingWatch, cacheDir]\n\n if (options.dtsFile !== false) {\n const dtsPath = options.dtsFile ?? path.resolve(projectRoot, 'rnwind-types.d.ts')\n const schemes = discoverSchemes(cssEntry, projectRoot)\n writeDtsFile(dtsPath, schemes, options.classNamePrefixes)\n }\n\n // Watch the theme CSS. On edit, we rewrite scheme files AND touch\n // mtime on every transformed source file so Metro invalidates them\n // and re-transforms — the only reliable way to propagate theme\n // changes to an already-running dev server.\n watchThemeCss(cssEntry, projectRoot)\n\n return metroConfig\n}\n"],"names":["existsSync","watchFile","onThemeChange","state","getRnwindState","utimesSync","mkdirSync","configureRnwindState","createRnwindResolver","writeDtsFile"],"mappings":";;;;;;;;AAMA;AACA,MAAM,iBAAiB,GAAG,SAAS;AAEnC;;;;AAIG;AACH,IAAI,gBAAgB,GAAkD,IAAI;AAE1E;;;;;;;;;;;AAWG;AACH,SAAS,aAAa,CAAC,OAAe,EAAE,WAAmB,EAAA;AACzD,IAAA,IAAI,gBAAgB,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AAO,CAAC,OAAO,KAAK,KAAK,EAAE;AAC7B,QAAA,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,mBAAmB,CAAC;QACjF,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,EAAE,WAAW,CAAC;QACtDC,gBAAY,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAC3D;;;;;AAMA,IAAA,aAAa,CAAC,QAAQ,EAAE,WAAW,CAAC;AAEpC,IAAA,OAAO,WAAW;AACpB;;;;"}
@@ -0,0 +1,57 @@
1
+ import { type ResolveRequestFn } from './resolver';
2
+ /** User-facing options for `withRnwindConfig`. */
3
+ export interface RnwindMetroOptions {
4
+ /** Path to the theme CSS (absolute or relative to `projectRoot`). Required. */
5
+ cssEntryFile: string;
6
+ /** Where rnwind writes the `.d.ts` file. Set `false` to disable. Defaults to `<projectRoot>/rnwind-types.d.ts`. */
7
+ dtsFile?: string | false;
8
+ /** Optional project-root override — defaults to `metroConfig.projectRoot` then `process.cwd()`. */
9
+ projectRoot?: string;
10
+ /** Cache directory. Absolute, or relative to `projectRoot`. Default: `.rnwind` at project root. */
11
+ cacheDir?: string;
12
+ /**
13
+ * Extra JSX prop-name prefixes that rnwind should rewrite. Each
14
+ * prefix `P` turns `<Tag PClassName="…">` into `<Tag
15
+ * PStyle={lookupCss(…)}>`. The built-in `'contentContainer'` prefix
16
+ * is always on (covers ScrollView / FlatList / SectionList); user
17
+ * entries merge on top.
18
+ */
19
+ classNamePrefixes?: readonly string[];
20
+ }
21
+ /** Shape we mutate on Metro's config. Loose so we don't pin Metro's internal types. */
22
+ export interface MetroConfigLike {
23
+ projectRoot?: string;
24
+ watchFolders?: string[];
25
+ transformer?: {
26
+ babelTransformerPath?: string;
27
+ [key: string]: unknown;
28
+ };
29
+ resolver?: {
30
+ resolveRequest?: ResolveRequestFn | null;
31
+ [key: string]: unknown;
32
+ };
33
+ [key: string]: unknown;
34
+ }
35
+ /**
36
+ * Wrap a Metro config with rnwind's pipeline:
37
+ * - Install the rnwind babel transformer.
38
+ * - Chain a `resolveRequest` hook that serves
39
+ * `rnwind/__generated/schemes` from `<cacheDir>/schemes.js`.
40
+ * - Write the `.d.ts` so TypeScript accepts `className=` on RN components.
41
+ * - Publish the theme CSS path + cache dir via env so Metro workers
42
+ * can rebuild their local state.
43
+ * - Ensure the cache dir is a watched folder Metro's haste-map indexes.
44
+ *
45
+ * Theme-edit hot reload happens implicitly: every transformed file
46
+ * imports `rnwind/__generated/schemes`, and that module eager-imports
47
+ * `common.style.js`. When the theme changes, the per-scheme files
48
+ * regenerate with new bytes; Metro's content SHA1 dedup detects the
49
+ * change and invalidates every importer automatically.
50
+ * `getCacheKey()` on the transformer covers the per-file transform
51
+ * cache. No file watcher / source-padding hack needed — the dep graph
52
+ * carries the signal.
53
+ * @param metroConfig Config from `getDefaultConfig(__dirname)` or equivalent.
54
+ * @param options rnwind options.
55
+ * @returns The same config, mutated.
56
+ */
57
+ export declare function withRnwindConfig<C extends MetroConfigLike>(metroConfig: C, options: RnwindMetroOptions): C;
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Compose a user-supplied press handler with rnwind's internal one.
5
+ * User fires first (its return / side-effects happen pre-gate flip); the
6
+ * rnwind handler then updates the active flag.
7
+ * @param user User-supplied handler from the original JSX (optional).
8
+ * @param ours rnwind's internal active-toggling handler.
9
+ * @returns Combined handler, or `ours` directly when the user didn't provide one.
10
+ */
11
+ function chainPress(user, ours) {
12
+ if (user == null)
13
+ return ours;
14
+ return (event) => {
15
+ user(event);
16
+ ours(event);
17
+ };
18
+ }
19
+ /**
20
+ * Compose a user-supplied focus/blur handler with rnwind's internal one.
21
+ * Same ordering rule as {@link chainPress}: user first, rnwind second.
22
+ * @param user User-supplied handler (optional).
23
+ * @param ours rnwind's internal focus-toggling handler.
24
+ * @returns Combined handler, or `ours` directly when the user didn't provide one.
25
+ */
26
+ function chainFocus(user, ours) {
27
+ if (user == null)
28
+ return ours;
29
+ return (event) => {
30
+ user(event);
31
+ ours(event);
32
+ };
33
+ }
34
+
35
+ exports.chainFocus = chainFocus;
36
+ exports.chainPress = chainPress;
37
+ //# sourceMappingURL=chain-handlers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chain-handlers.cjs","sources":["../../../../src/runtime/chain-handlers.ts"],"sourcesContent":["/**\n * Tiny helpers that compose rnwind's press / focus handlers with any\n * user-provided ones the JSX site already has. The transformer uses\n * these when it rewrites a `<Pressable onPressIn={user}>` into\n * `<Pressable onPressIn={chainPress(user, _i.onPressIn)}>` so the user's\n * callback keeps firing.\n *\n * Both helpers bail out when the user's handler is `null` / `undefined`,\n * returning rnwind's handler directly — that gives the transformer a\n * cheap uniform rewrite (\"always chain\") without allocating a new\n * function per render when the user didn't opt in to the handler.\n */\nimport type { GestureResponderEvent, NativeSyntheticEvent, TargetedEvent } from 'react-native'\n\ntype PressHandler = (event: GestureResponderEvent) => void\ntype FocusHandler = (event: NativeSyntheticEvent<TargetedEvent>) => void\n\n/**\n * Compose a user-supplied press handler with rnwind's internal one.\n * User fires first (its return / side-effects happen pre-gate flip); the\n * rnwind handler then updates the active flag.\n * @param user User-supplied handler from the original JSX (optional).\n * @param ours rnwind's internal active-toggling handler.\n * @returns Combined handler, or `ours` directly when the user didn't provide one.\n */\nexport function chainPress(user: PressHandler | null | undefined, ours: PressHandler): PressHandler {\n if (user == null) return ours\n return (event: GestureResponderEvent): void => {\n user(event)\n ours(event)\n }\n}\n\n/**\n * Compose a user-supplied focus/blur handler with rnwind's internal one.\n * Same ordering rule as {@link chainPress}: user first, rnwind second.\n * @param user User-supplied handler (optional).\n * @param ours rnwind's internal focus-toggling handler.\n * @returns Combined handler, or `ours` directly when the user didn't provide one.\n */\nexport function chainFocus(user: FocusHandler | null | undefined, ours: FocusHandler): FocusHandler {\n if (user == null) return ours\n return (event: NativeSyntheticEvent<TargetedEvent>): void => {\n user(event)\n ours(event)\n }\n}\n"],"names":[],"mappings":";;AAiBA;;;;;;;AAOG;AACG,SAAU,UAAU,CAAC,IAAqC,EAAE,IAAkB,EAAA;IAClF,IAAI,IAAI,IAAI,IAAI;AAAE,QAAA,OAAO,IAAI;IAC7B,OAAO,CAAC,KAA4B,KAAU;QAC5C,IAAI,CAAC,KAAK,CAAC;QACX,IAAI,CAAC,KAAK,CAAC;AACb,IAAA,CAAC;AACH;AAEA;;;;;;AAMG;AACG,SAAU,UAAU,CAAC,IAAqC,EAAE,IAAkB,EAAA;IAClF,IAAI,IAAI,IAAI,IAAI;AAAE,QAAA,OAAO,IAAI;IAC7B,OAAO,CAAC,KAA0C,KAAU;QAC1D,IAAI,CAAC,KAAK,CAAC;QACX,IAAI,CAAC,KAAK,CAAC;AACb,IAAA,CAAC;AACH;;;;;"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Tiny helpers that compose rnwind's press / focus handlers with any
3
+ * user-provided ones the JSX site already has. The transformer uses
4
+ * these when it rewrites a `<Pressable onPressIn={user}>` into
5
+ * `<Pressable onPressIn={chainPress(user, _i.onPressIn)}>` so the user's
6
+ * callback keeps firing.
7
+ *
8
+ * Both helpers bail out when the user's handler is `null` / `undefined`,
9
+ * returning rnwind's handler directly — that gives the transformer a
10
+ * cheap uniform rewrite ("always chain") without allocating a new
11
+ * function per render when the user didn't opt in to the handler.
12
+ */
13
+ import type { GestureResponderEvent, NativeSyntheticEvent, TargetedEvent } from 'react-native';
14
+ type PressHandler = (event: GestureResponderEvent) => void;
15
+ type FocusHandler = (event: NativeSyntheticEvent<TargetedEvent>) => void;
16
+ /**
17
+ * Compose a user-supplied press handler with rnwind's internal one.
18
+ * User fires first (its return / side-effects happen pre-gate flip); the
19
+ * rnwind handler then updates the active flag.
20
+ * @param user User-supplied handler from the original JSX (optional).
21
+ * @param ours rnwind's internal active-toggling handler.
22
+ * @returns Combined handler, or `ours` directly when the user didn't provide one.
23
+ */
24
+ export declare function chainPress(user: PressHandler | null | undefined, ours: PressHandler): PressHandler;
25
+ /**
26
+ * Compose a user-supplied focus/blur handler with rnwind's internal one.
27
+ * Same ordering rule as {@link chainPress}: user first, rnwind second.
28
+ * @param user User-supplied handler (optional).
29
+ * @param ours rnwind's internal focus-toggling handler.
30
+ * @returns Combined handler, or `ours` directly when the user didn't provide one.
31
+ */
32
+ export declare function chainFocus(user: FocusHandler | null | undefined, ours: FocusHandler): FocusHandler;
33
+ export {};