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":"dts.cjs","sources":["../../../../src/metro/dts.ts"],"sourcesContent":["import { mkdirSync, writeFileSync } from 'node:fs'\nimport path from 'node:path'\n\n/**\n * React Native component-props interfaces rnwind augments. Adding an\n * optional `className?: string` to each lets TypeScript accept\n * `<View className=\"…\" />` without the user touching types by hand.\n * The generic ones are written with a placeholder so the output type\n * stays parameterised.\n */\nconst INTERFACES: ReadonlyArray<string | { name: string; generic: string }> = [\n 'ViewProps',\n 'TextProps',\n 'ImageProps',\n 'ImageBackgroundProps',\n 'ScrollViewProps',\n 'PressableProps',\n 'ModalProps',\n 'TextInputProps',\n 'TouchableOpacityProps',\n 'TouchableHighlightProps',\n 'TouchableNativeFeedbackProps',\n 'TouchableWithoutFeedbackProps',\n 'SafeAreaViewProps',\n 'KeyboardAvoidingViewProps',\n 'RefreshControlProps',\n 'StatusBarProps',\n 'SwitchProps',\n 'ActivityIndicatorProps',\n 'SectionListProps',\n { name: 'FlatListProps', generic: 'ItemT' },\n { name: 'VirtualizedListProps', generic: 'ItemT' },\n]\n\n/**\n * Built-in prefix wired into every install. Restricted to the interfaces\n * that natively expose `contentContainerStyle` so TypeScript doesn't\n * start accepting `<View contentContainerClassName=\"…\" />` — RN would\n * silently ignore it at runtime and a typed lint is more useful than a\n * permissive one. User prefixes don't come with this restriction; rnwind\n * can't know which component props they target.\n */\nconst BUILTIN_PREFIX = 'contentContainer'\n\n/**\n * Interfaces that expose `contentContainerStyle` in React Native's own\n * types — the set the built-in prefix's `.d.ts` augmentation targets.\n * Everything else stays `className`-only by default.\n */\nconst CONTENT_CONTAINER_INTERFACES: ReadonlySet<string> = new Set([\n 'ScrollViewProps',\n 'FlatListProps',\n 'SectionListProps',\n 'VirtualizedListProps',\n])\n\n/**\n * Build the body of one interface augmentation: `className?: string`\n * plus `<prefix>ClassName?: string` for every prefix that applies to\n * THIS interface. Emits a single-line body so the file stays easy to\n * scan and diff.\n * @param interfaceName Bare interface name (generic parameters stripped).\n * @param userPrefixes Extra prefixes from the Metro config — applied to\n * every interface the same way `className` is.\n * @returns Space-separated property declarations.\n */\nfunction buildInterfaceBody(interfaceName: string, userPrefixes: readonly string[]): string {\n const props = ['className?: string']\n if (CONTENT_CONTAINER_INTERFACES.has(interfaceName)) props.push(`${BUILTIN_PREFIX}ClassName?: string`)\n for (const prefix of userPrefixes) {\n if (prefix === BUILTIN_PREFIX) continue\n props.push(`${prefix}ClassName?: string`)\n }\n return props.join('; ')\n}\n\n/**\n * Write the rnwind TypeScript declaration file. The generated `.d.ts`\n * declares a `rnwind` module augmentation for `react-native`'s\n * component props — every interface gets an optional `className?:\n * string` plus `<prefix>ClassName?: string` for each active prefix.\n * Runtime-rendered schemes (`@variant` blocks) are reflected in the\n * `Scheme` union so `useScheme()` returns the actual names.\n *\n * Called once at Metro-config time — overwrite-on-rewrite so the file\n * stays in sync with the user's current theme CSS + prefix config.\n * @param targetPath Absolute path to write (typically `rnwind-types.d.ts` at project root).\n * @param schemes Scheme names from the user's `@variant` blocks (empty when none declared).\n * @param classNamePrefixes Extra prefixes from the Metro config — merged\n * on top of the built-in `'contentContainer'`. Defaults to empty.\n */\nexport function writeDtsFile(\n targetPath: string,\n schemes: readonly string[],\n classNamePrefixes: readonly string[] = [],\n): void {\n const lines: string[] = [\n '// Auto-generated by rnwind — do not edit by hand.',\n '// Overwritten on Metro start / theme CSS change.',\n '',\n `declare module 'react-native' {`,\n ]\n for (const entry of INTERFACES) {\n const name = typeof entry === 'string' ? entry : entry.name\n const body = buildInterfaceBody(name, classNamePrefixes)\n if (typeof entry === 'string') {\n lines.push(` interface ${entry} { ${body} }`)\n continue\n }\n lines.push(` interface ${entry.name}<${entry.generic}> { ${body} }`)\n }\n lines.push('}', '')\n if (schemes.length > 0) {\n lines.push(`declare module 'rnwind' {`, ` export interface RnwindConfig {`)\n const schemeLiterals = schemes.map((s) => `'${s}'`).join(', ')\n lines.push(` themes: readonly [${schemeLiterals}]`, ` }`, '}', '')\n }\n // The `export {}` is mandatory — without at least one top-level\n // import/export, TypeScript treats this file as a SCRIPT and the\n // `declare module 'react-native'` block above becomes a complete\n // *replacement* declaration (hiding the real RN exports like\n // `Pressable`, `useColorScheme`, etc.). With `export {}` the file\n // becomes a module and the `declare module` blocks are interpreted as\n // *augmentations* — which is what we want.\n lines.push('export {}', '')\n mkdirSync(path.dirname(targetPath), { recursive: true })\n writeFileSync(targetPath, lines.join('\\n'), 'utf8')\n}\n"],"names":["mkdirSync","writeFileSync"],"mappings":";;;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EAAE,IAAI,EAAE,CAAC;AACxD,IAAAC,qBAAa,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;AACrD;;;;"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Write the rnwind TypeScript declaration file. The generated `.d.ts`
3
+ * declares a `rnwind` module augmentation for `react-native`'s
4
+ * component props — every interface gets an optional `className?:
5
+ * string` plus `<prefix>ClassName?: string` for each active prefix.
6
+ * Runtime-rendered schemes (`@variant` blocks) are reflected in the
7
+ * `Scheme` union so `useScheme()` returns the actual names.
8
+ *
9
+ * Called once at Metro-config time — overwrite-on-rewrite so the file
10
+ * stays in sync with the user's current theme CSS + prefix config.
11
+ * @param targetPath Absolute path to write (typically `rnwind-types.d.ts` at project root).
12
+ * @param schemes Scheme names from the user's `@variant` blocks (empty when none declared).
13
+ * @param classNamePrefixes Extra prefixes from the Metro config — merged
14
+ * on top of the built-in `'contentContainer'`. Defaults to empty.
15
+ */
16
+ export declare function writeDtsFile(targetPath: string, schemes: readonly string[], classNamePrefixes?: readonly string[]): void;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var withConfig = require('./with-config.cjs');
4
+ var resolver = require('./resolver.cjs');
5
+ var dts = require('./dts.cjs');
6
+ var metro_transformer = require('./transformer.cjs');
7
+ var state = require('./state.cjs');
8
+
9
+
10
+
11
+ exports.withRnwindConfig = withConfig.withRnwindConfig;
12
+ exports.createRnwindResolver = resolver.createRnwindResolver;
13
+ exports.writeDtsFile = dts.writeDtsFile;
14
+ exports.transform = metro_transformer.transform;
15
+ exports.configureRnwindState = state.configureRnwindState;
16
+ exports.getRnwindState = state.getRnwindState;
17
+ exports.manifestPathFor = state.manifestPathFor;
18
+ exports.resetRnwindState = state.resetRnwindState;
19
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,9 @@
1
+ export { withRnwindConfig } from './with-config';
2
+ export type { RnwindMetroOptions, MetroConfigLike } from './with-config';
3
+ export { createRnwindResolver } from './resolver';
4
+ export type { ResolveRequestFn } from './resolver';
5
+ export { writeDtsFile } from './dts';
6
+ export { transform } from './transformer';
7
+ export type { BabelTransformerArgs, BabelTransformerResult } from './transformer';
8
+ export { getRnwindState, configureRnwindState, resetRnwindState, manifestPathFor } from './state';
9
+ export type { RnwindState } from './state';
@@ -0,0 +1,47 @@
1
+ 'use strict';
2
+
3
+ var state = require('./state.cjs');
4
+
5
+ /** Specifier the transformer prepends — resolves to the scheme manifest. */
6
+ const SCHEMES_MODULE = 'rnwind/__generated/schemes';
7
+ /**
8
+ * Sentinel module specifier the transformer prepends to every rewritten
9
+ * file. The resolver maps it to the user's theme CSS so Metro watches
10
+ * that file as a real node in the dependency graph — when the user
11
+ * edits `global.css`, the CSS file's SHA1 changes, and Metro
12
+ * invalidates every JS file that imports the sentinel. The transformer
13
+ * recognises `.css` filenames and returns an empty `export {}` AST so
14
+ * Metro can still bundle it.
15
+ */
16
+ const THEME_SIGNATURE_MODULE = 'rnwind/__generated/theme-signature';
17
+ /**
18
+ * Build a Metro `resolveRequest` hook that maps the scheme manifest
19
+ * specifier (and the theme-signature sentinel) to its on-disk path.
20
+ * Delegates every other request to the upstream resolver.
21
+ * @param upstream Previously-registered `resolveRequest` (kept in the chain).
22
+ * @returns Metro-compatible resolver.
23
+ */
24
+ function createRnwindResolver(upstream) {
25
+ return (context, moduleName, platform) => {
26
+ if (moduleName === SCHEMES_MODULE)
27
+ return { type: 'sourceFile', filePath: state.manifestPathFor() };
28
+ if (moduleName === THEME_SIGNATURE_MODULE) {
29
+ const cssPath = process.env.RNWIND_CSS_ENTRY_FILE;
30
+ if (cssPath)
31
+ return { type: 'sourceFile', filePath: cssPath };
32
+ }
33
+ if (upstream)
34
+ return upstream(context, moduleName, platform);
35
+ const { resolveRequest } = context;
36
+ if (resolveRequest)
37
+ return resolveRequest(context, moduleName, platform);
38
+ return null;
39
+ };
40
+ }
41
+ /** Side-effect import specifier(s) the transformer injects on every rewritten file. */
42
+ const STYLE_SPECIFIERS = [SCHEMES_MODULE];
43
+
44
+ exports.STYLE_SPECIFIERS = STYLE_SPECIFIERS;
45
+ exports.THEME_SIGNATURE_MODULE = THEME_SIGNATURE_MODULE;
46
+ exports.createRnwindResolver = createRnwindResolver;
47
+ //# sourceMappingURL=resolver.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.cjs","sources":["../../../../src/metro/resolver.ts"],"sourcesContent":["import { manifestPathFor } from './state'\n\n/** Specifier the transformer prepends — resolves to the scheme manifest. */\nconst SCHEMES_MODULE = 'rnwind/__generated/schemes'\n\n/** Metro `resolveRequest` callable shape. Loose so we don't bind to Metro's internal types. */\nexport type ResolveRequestFn = (context: unknown, moduleName: string, platform: string | null) => unknown\n\n/**\n * Sentinel module specifier the transformer prepends to every rewritten\n * file. The resolver maps it to the user's theme CSS so Metro watches\n * that file as a real node in the dependency graph — when the user\n * edits `global.css`, the CSS file's SHA1 changes, and Metro\n * invalidates every JS file that imports the sentinel. The transformer\n * recognises `.css` filenames and returns an empty `export {}` AST so\n * Metro can still bundle it.\n */\nexport const THEME_SIGNATURE_MODULE = 'rnwind/__generated/theme-signature'\n\n/**\n * Build a Metro `resolveRequest` hook that maps the scheme manifest\n * specifier (and the theme-signature sentinel) to its on-disk path.\n * Delegates every other request to the upstream resolver.\n * @param upstream Previously-registered `resolveRequest` (kept in the chain).\n * @returns Metro-compatible resolver.\n */\nexport function createRnwindResolver(upstream: ResolveRequestFn | null | undefined): ResolveRequestFn {\n return (context, moduleName, platform) => {\n if (moduleName === SCHEMES_MODULE) return { type: 'sourceFile', filePath: manifestPathFor() }\n if (moduleName === THEME_SIGNATURE_MODULE) {\n const cssPath = process.env.RNWIND_CSS_ENTRY_FILE\n if (cssPath) return { type: 'sourceFile', filePath: cssPath }\n }\n if (upstream) return upstream(context, moduleName, platform)\n const { resolveRequest } = context as { resolveRequest?: ResolveRequestFn }\n if (resolveRequest) return resolveRequest(context, moduleName, platform)\n return null as unknown\n }\n}\n\n/** Side-effect import specifier(s) the transformer injects on every rewritten file. */\nexport const STYLE_SPECIFIERS = [SCHEMES_MODULE] as const\n"],"names":["manifestPathFor"],"mappings":";;;;AAEA;AACA,MAAM,cAAc,GAAG,4BAA4B;AAKnD;;;;;;;;AAQG;AACI,MAAM,sBAAsB,GAAG;AAEtC;;;;;;AAMG;AACG,SAAU,oBAAoB,CAAC,QAA6C,EAAA;AAChF,IAAA,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,KAAI;QACvC,IAAI,UAAU,KAAK,cAAc;YAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAEA,qBAAe,EAAE,EAAE;AAC7F,QAAA,IAAI,UAAU,KAAK,sBAAsB,EAAE;AACzC,YAAA,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB;AACjD,YAAA,IAAI,OAAO;gBAAE,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,QAAQ,EAAE,OAAO,EAAE;QAC/D;AACA,QAAA,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;AAC5D,QAAA,MAAM,EAAE,cAAc,EAAE,GAAG,OAAgD;AAC3E,QAAA,IAAI,cAAc;YAAE,OAAO,cAAc,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC;AACxE,QAAA,OAAO,IAAe;AACxB,IAAA,CAAC;AACH;AAEA;AACO,MAAM,gBAAgB,GAAG,CAAC,cAAc;;;;;;"}
@@ -0,0 +1,22 @@
1
+ /** Metro `resolveRequest` callable shape. Loose so we don't bind to Metro's internal types. */
2
+ export type ResolveRequestFn = (context: unknown, moduleName: string, platform: string | null) => unknown;
3
+ /**
4
+ * Sentinel module specifier the transformer prepends to every rewritten
5
+ * file. The resolver maps it to the user's theme CSS so Metro watches
6
+ * that file as a real node in the dependency graph — when the user
7
+ * edits `global.css`, the CSS file's SHA1 changes, and Metro
8
+ * invalidates every JS file that imports the sentinel. The transformer
9
+ * recognises `.css` filenames and returns an empty `export {}` AST so
10
+ * Metro can still bundle it.
11
+ */
12
+ export declare const THEME_SIGNATURE_MODULE = "rnwind/__generated/theme-signature";
13
+ /**
14
+ * Build a Metro `resolveRequest` hook that maps the scheme manifest
15
+ * specifier (and the theme-signature sentinel) to its on-disk path.
16
+ * Delegates every other request to the upstream resolver.
17
+ * @param upstream Previously-registered `resolveRequest` (kept in the chain).
18
+ * @returns Metro-compatible resolver.
19
+ */
20
+ export declare function createRnwindResolver(upstream: ResolveRequestFn | null | undefined): ResolveRequestFn;
21
+ /** Side-effect import specifier(s) the transformer injects on every rewritten file. */
22
+ export declare const STYLE_SPECIFIERS: readonly ["rnwind/__generated/schemes"];
@@ -0,0 +1,251 @@
1
+ 'use strict';
2
+
3
+ var node_fs = require('node:fs');
4
+ var path = require('node:path');
5
+ var node_crypto = require('node:crypto');
6
+ var unionBuilder = require('../core/style-builder/union-builder.cjs');
7
+ var twParser = require('../core/parser/tw-parser.cjs');
8
+
9
+ /**
10
+ * Default oxide Scanner globs — walk every JS/TS source under the
11
+ * project root AND every monorepo watch folder, excluding
12
+ * `node_modules` and rnwind's own cache dir so we don't rescan
13
+ * generated scheme files.
14
+ *
15
+ * Monorepo layouts (Yarn workspaces, pnpm workspaces, Nx) surface
16
+ * sibling package roots as `metroConfig.watchFolders`. Every folder
17
+ * Metro watches must also be scanned so atoms declared in shared UI
18
+ * packages make it into the union — without this, only the app's
19
+ * own files would be scanned and every UI-package atom would resolve
20
+ * to `undefined` at runtime.
21
+ * @param projectRoot Absolute project root.
22
+ * @param cacheDir Absolute rnwind cache dir (to exclude).
23
+ * @param watchFolders Extra monorepo roots Metro is watching.
24
+ * @returns Scanner sources suitable for `parser.parseProject()`.
25
+ */
26
+ function defaultSources(projectRoot, cacheDir, watchFolders) {
27
+ const cacheBaseName = path.basename(cacheDir);
28
+ const roots = new Set([projectRoot, ...watchFolders]);
29
+ const sources = [];
30
+ for (const root of roots) {
31
+ sources.push({ base: root, pattern: '**/*.{ts,tsx,js,jsx}', negated: false }, { base: root, pattern: '**/node_modules/**', negated: true }, { base: root, pattern: `**/${cacheBaseName}/**`, negated: true });
32
+ }
33
+ return sources;
34
+ }
35
+ /**
36
+ * Read monorepo watch-folder paths out of the worker environment.
37
+ * Empty array when the host isn't a monorepo.
38
+ * @returns Absolute paths Metro also watches (sibling packages).
39
+ */
40
+ function readWatchFolders() {
41
+ const raw = process.env[WATCH_FOLDERS_ENV];
42
+ if (!raw || raw.length === 0)
43
+ return [];
44
+ return raw.split('\0').filter((entry) => entry.length > 0);
45
+ }
46
+ /** Env var Metro workers read to locate the theme CSS on disk. */
47
+ const CSS_ENTRY_ENV = 'RNWIND_CSS_ENTRY_FILE';
48
+ /** Env var Metro workers read to locate the cache directory (`.rnwind`). */
49
+ const CACHE_DIR_ENV = 'RNWIND_CACHE_DIR';
50
+ /** Env var carrying `watchFolders` from Metro config (NUL-separated). */
51
+ const WATCH_FOLDERS_ENV = 'RNWIND_WATCH_FOLDERS';
52
+ /** Env var carrying extra className prefixes the Metro config supplied. */
53
+ const CLASSNAME_PREFIXES_ENV = 'RNWIND_CLASSNAME_PREFIXES';
54
+ /** Memoised library fingerprint — read once per worker process. */
55
+ let libraryFingerprint;
56
+ /** Live state shared across one Metro transform worker. */
57
+ let cached = null;
58
+ /**
59
+ * Cheap content-hash readout. SHA-256 prefix of the CSS bytes plus the
60
+ * file's mtime nanoseconds (so identical content with different mtime
61
+ * — atomic rewrites — still picks up the change). Returns `'missing'`
62
+ * when the file can't be read so the cache key is still deterministic.
63
+ * @param cssPath Absolute CSS path.
64
+ * @returns 16-char hex content hash.
65
+ */
66
+ function readThemeHashFor(cssPath) {
67
+ if (!node_fs.existsSync(cssPath))
68
+ return 'missing';
69
+ try {
70
+ const bytes = node_fs.readFileSync(cssPath);
71
+ const mtime = node_fs.statSync(cssPath).mtimeMs.toString();
72
+ return node_crypto.createHash('sha256').update(bytes).update(mtime).digest('hex').slice(0, 16);
73
+ }
74
+ catch {
75
+ return 'missing';
76
+ }
77
+ }
78
+ /**
79
+ * Hash a small set of rnwind library files whose changes affect the
80
+ * generated transform output. When the library is rebuilt (workspace
81
+ * dev OR npm install of a new version) the file bytes change, the
82
+ * fingerprint rotates, and Metro's transform cache invalidates.
83
+ *
84
+ * Includes the JSX rewriter (`transform-ast`) alongside the parser /
85
+ * style-builder so a change to the transformer — e.g. renaming the
86
+ * injected context hook — invalidates every stale per-file cache entry
87
+ * on the next dev run. Without this, a user upgrading rnwind in-place
88
+ * would keep loading the old transformed bytes; React-refresh would
89
+ * then preserve fiber state across the version bump and the rendered
90
+ * hook list could shift, surfacing as "change in the order of Hooks"
91
+ * runtime errors.
92
+ * Memoised — read once per worker process.
93
+ * @returns 16-char hex fingerprint.
94
+ */
95
+ function getLibraryFingerprint() {
96
+ if (libraryFingerprint !== undefined)
97
+ return libraryFingerprint;
98
+ const here = path.dirname(__filename);
99
+ const candidates = [
100
+ path.resolve(here, '..', 'core', 'style-builder', 'build-style.mjs'),
101
+ path.resolve(here, '..', 'core', 'style-builder', 'build-style.cjs'),
102
+ path.resolve(here, '..', 'core', 'parser', 'tw-parser.mjs'),
103
+ path.resolve(here, '..', 'core', 'parser', 'tw-parser.cjs'),
104
+ path.resolve(here, 'transform-ast.mjs'),
105
+ path.resolve(here, 'transform-ast.cjs'),
106
+ path.resolve(here, 'transformer.mjs'),
107
+ path.resolve(here, 'transformer.cjs'),
108
+ // Source-tree fallback for tests + workspace dev (no built lib yet).
109
+ path.resolve(here, '..', '..', 'src', 'core', 'style-builder', 'build-style.ts'),
110
+ path.resolve(here, '..', '..', 'src', 'core', 'parser', 'tw-parser.ts'),
111
+ path.resolve(here, '..', '..', 'src', 'metro', 'transform-ast.ts'),
112
+ path.resolve(here, '..', '..', 'src', 'metro', 'transformer.ts'),
113
+ ];
114
+ const hash = node_crypto.createHash('sha256');
115
+ let included = 0;
116
+ for (const file of candidates) {
117
+ if (!node_fs.existsSync(file))
118
+ continue;
119
+ try {
120
+ hash.update(node_fs.readFileSync(file));
121
+ included += 1;
122
+ }
123
+ catch {
124
+ // Unreadable file — skip; fingerprint still derives from whatever WE could read.
125
+ }
126
+ }
127
+ libraryFingerprint = included > 0 ? hash.digest('hex').slice(0, 16) : '0'.repeat(16);
128
+ return libraryFingerprint;
129
+ }
130
+ /**
131
+ * Publish the theme CSS path + cache dir to the environment so worker
132
+ * subprocesses (spawned by Metro once `babelTransformerPath` is set)
133
+ * can rebuild the same state without re-reading the Metro config.
134
+ * @param cssEntryFile Absolute path to the user's theme CSS.
135
+ * @param cacheDir Absolute path to the cache dir (`.rnwind`).
136
+ * @param watchFolders
137
+ * @param classNamePrefixes Extra JSX prop-name prefixes to rewrite.
138
+ */
139
+ function configureRnwindState(cssEntryFile, cacheDir, watchFolders = [], classNamePrefixes) {
140
+ process.env[CSS_ENTRY_ENV] = cssEntryFile;
141
+ process.env[CACHE_DIR_ENV] = cacheDir;
142
+ if (watchFolders.length === 0) {
143
+ delete process.env[WATCH_FOLDERS_ENV];
144
+ }
145
+ else {
146
+ process.env[WATCH_FOLDERS_ENV] = watchFolders.join('\0');
147
+ }
148
+ if (!classNamePrefixes || classNamePrefixes.length === 0) {
149
+ delete process.env[CLASSNAME_PREFIXES_ENV];
150
+ }
151
+ else {
152
+ process.env[CLASSNAME_PREFIXES_ENV] = classNamePrefixes.join(',');
153
+ }
154
+ cached = null;
155
+ }
156
+ /**
157
+ * Read the caller-configured extra className prefixes out of the
158
+ * worker environment. Returns an empty array when unset — the
159
+ * transformer applies the built-in `contentContainer` default on top
160
+ * either way.
161
+ * @returns User-supplied extra prefixes.
162
+ */
163
+ function getClassNamePrefixes() {
164
+ const raw = process.env[CLASSNAME_PREFIXES_ENV];
165
+ if (!raw || raw.length === 0)
166
+ return [];
167
+ return raw.split(',').filter((entry) => entry.length > 0);
168
+ }
169
+ /**
170
+ * Fetch (or build) the worker-local rnwind state. Re-reads the theme
171
+ * CSS hash on every call: if the user edited `global.css` while Metro
172
+ * is running, the cached state is dropped and a fresh parser + ledger
173
+ * is built. Combined with the `getCacheKey()` export on the
174
+ * transformer (which folds the same hash into Metro's per-file cache
175
+ * key) every CSS edit produces a full, correct re-bundle.
176
+ * @param projectRoot
177
+ * @returns The live rnwind state.
178
+ */
179
+ function getRnwindState(projectRoot) {
180
+ const cssEntry = process.env[CSS_ENTRY_ENV];
181
+ const cacheDir = process.env[CACHE_DIR_ENV];
182
+ if (!cssEntry)
183
+ throw new Error('rnwind: RNWIND_CSS_ENTRY_FILE is not set — did `withRnwindConfig` run?');
184
+ if (!cacheDir)
185
+ throw new Error('rnwind: RNWIND_CACHE_DIR is not set — did `withRnwindConfig` run?');
186
+ const currentHash = readThemeHashFor(cssEntry);
187
+ if (cached?.themeHash === currentHash && cached.projectRoot === projectRoot)
188
+ return cached;
189
+ const themeCss = node_fs.readFileSync(cssEntry, 'utf8');
190
+ const parser = new twParser.TailwindParser({
191
+ themeCss,
192
+ sources: defaultSources(projectRoot, cacheDir, readWatchFolders()),
193
+ });
194
+ const builder = new unionBuilder.UnionBuilder(cacheDir, parser);
195
+ cached = { parser, builder, themeCss, themeHash: currentHash, projectRoot };
196
+ return cached;
197
+ }
198
+ /**
199
+ * Compute the rnwind cache-key suffix Metro mixes into every per-file
200
+ * transform cache entry via the transformer's `getCacheKey()` export.
201
+ * Includes the CSS path + its current content hash + the rnwind
202
+ * library fingerprint, so any edit to `global.css` OR a library
203
+ * upgrade flips the cache key and forces Metro to re-run the
204
+ * transformer.
205
+ * @returns Deterministic string suitable for appending to Metro's cache key.
206
+ */
207
+ function getRnwindCacheKey() {
208
+ const cssEntry = process.env[CSS_ENTRY_ENV] ?? '';
209
+ const prefixes = process.env[CLASSNAME_PREFIXES_ENV] ?? '';
210
+ return `rnwind:${cssEntry}:${readThemeHashFor(cssEntry)}|lib:${getLibraryFingerprint()}|pfx:${prefixes}`;
211
+ }
212
+ /** Drop the cached state — call after editing the theme CSS. */
213
+ function resetRnwindState() {
214
+ cached = null;
215
+ }
216
+ /**
217
+ * Drop cached state, rebuild parser/builder with the fresh CSS, rescan
218
+ * the project, and rewrite every scheme file on disk. This is what
219
+ * `withRnwindConfig`'s CSS file-watcher invokes so `global.css` edits
220
+ * propagate to the app via Metro's HMR — without this, the CSS-as-JS
221
+ * module would re-emit `export {}` whose bytes never change, so Metro
222
+ * would never invalidate downstream modules.
223
+ * @param projectRoot Absolute project root (from `metroConfig.projectRoot`).
224
+ */
225
+ async function onThemeChange(projectRoot) {
226
+ resetRnwindState();
227
+ const state = getRnwindState(projectRoot);
228
+ await state.builder.writeSchemes();
229
+ }
230
+ /**
231
+ * Resolve the on-disk path of the scheme manifest module for the
232
+ * resolver. The manifest eager-imports `common.style.js` and
233
+ * lazy-requires each variant scheme; SchemeProvider calls its
234
+ * `ensureSchemeLoaded` export to trigger per-scheme requires.
235
+ * @returns Absolute path to `<cacheDir>/schemes.js`.
236
+ */
237
+ function manifestPathFor() {
238
+ const cacheDir = process.env[CACHE_DIR_ENV];
239
+ if (!cacheDir)
240
+ throw new Error('rnwind: RNWIND_CACHE_DIR is not set');
241
+ return path.join(cacheDir, 'schemes.js');
242
+ }
243
+
244
+ exports.configureRnwindState = configureRnwindState;
245
+ exports.getClassNamePrefixes = getClassNamePrefixes;
246
+ exports.getRnwindCacheKey = getRnwindCacheKey;
247
+ exports.getRnwindState = getRnwindState;
248
+ exports.manifestPathFor = manifestPathFor;
249
+ exports.onThemeChange = onThemeChange;
250
+ exports.resetRnwindState = resetRnwindState;
251
+ //# sourceMappingURL=state.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.cjs","sources":["../../../../src/metro/state.ts"],"sourcesContent":["import { existsSync, readFileSync, statSync } from 'node:fs'\nimport path from 'node:path'\nimport { createHash } from 'node:crypto'\nimport { UnionBuilder } from '../core/style-builder'\nimport { TailwindParser, type SourceEntry } from '../core/parser'\n\n/**\n * Default oxide Scanner globs — walk every JS/TS source under the\n * project root AND every monorepo watch folder, excluding\n * `node_modules` and rnwind's own cache dir so we don't rescan\n * generated scheme files.\n *\n * Monorepo layouts (Yarn workspaces, pnpm workspaces, Nx) surface\n * sibling package roots as `metroConfig.watchFolders`. Every folder\n * Metro watches must also be scanned so atoms declared in shared UI\n * packages make it into the union — without this, only the app's\n * own files would be scanned and every UI-package atom would resolve\n * to `undefined` at runtime.\n * @param projectRoot Absolute project root.\n * @param cacheDir Absolute rnwind cache dir (to exclude).\n * @param watchFolders Extra monorepo roots Metro is watching.\n * @returns Scanner sources suitable for `parser.parseProject()`.\n */\nfunction defaultSources(projectRoot: string, cacheDir: string, watchFolders: readonly string[]): readonly SourceEntry[] {\n const cacheBaseName = path.basename(cacheDir)\n const roots = new Set<string>([projectRoot, ...watchFolders])\n const sources: SourceEntry[] = []\n for (const root of roots) {\n sources.push({ base: root, pattern: '**/*.{ts,tsx,js,jsx}', negated: false }, { base: root, pattern: '**/node_modules/**', negated: true }, { base: root, pattern: `**/${cacheBaseName}/**`, negated: true })\n }\n return sources\n}\n\n/**\n * Read monorepo watch-folder paths out of the worker environment.\n * Empty array when the host isn't a monorepo.\n * @returns Absolute paths Metro also watches (sibling packages).\n */\nfunction readWatchFolders(): readonly string[] {\n const raw = process.env[WATCH_FOLDERS_ENV]\n if (!raw || raw.length === 0) return []\n return raw.split('\\0').filter((entry) => entry.length > 0)\n}\n\n/** Env var Metro workers read to locate the theme CSS on disk. */\nconst CSS_ENTRY_ENV = 'RNWIND_CSS_ENTRY_FILE'\n/** Env var Metro workers read to locate the cache directory (`.rnwind`). */\nconst CACHE_DIR_ENV = 'RNWIND_CACHE_DIR'\n/** Env var carrying `watchFolders` from Metro config (NUL-separated). */\nconst WATCH_FOLDERS_ENV = 'RNWIND_WATCH_FOLDERS'\n/** Env var carrying extra className prefixes the Metro config supplied. */\nconst CLASSNAME_PREFIXES_ENV = 'RNWIND_CLASSNAME_PREFIXES'\n\n/** Memoised library fingerprint — read once per worker process. */\nlet libraryFingerprint: string | undefined\n\n/** Live state shared across one Metro transform worker. */\nlet cached: RnwindState | null = null\n\n/**\n * Cheap content-hash readout. SHA-256 prefix of the CSS bytes plus the\n * file's mtime nanoseconds (so identical content with different mtime\n * — atomic rewrites — still picks up the change). Returns `'missing'`\n * when the file can't be read so the cache key is still deterministic.\n * @param cssPath Absolute CSS path.\n * @returns 16-char hex content hash.\n */\nfunction readThemeHashFor(cssPath: string): string {\n if (!existsSync(cssPath)) return 'missing'\n try {\n const bytes = readFileSync(cssPath)\n const mtime = statSync(cssPath).mtimeMs.toString()\n return createHash('sha256').update(bytes).update(mtime).digest('hex').slice(0, 16)\n } catch {\n return 'missing'\n }\n}\n\n/**\n * Hash a small set of rnwind library files whose changes affect the\n * generated transform output. When the library is rebuilt (workspace\n * dev OR npm install of a new version) the file bytes change, the\n * fingerprint rotates, and Metro's transform cache invalidates.\n *\n * Includes the JSX rewriter (`transform-ast`) alongside the parser /\n * style-builder so a change to the transformer — e.g. renaming the\n * injected context hook — invalidates every stale per-file cache entry\n * on the next dev run. Without this, a user upgrading rnwind in-place\n * would keep loading the old transformed bytes; React-refresh would\n * then preserve fiber state across the version bump and the rendered\n * hook list could shift, surfacing as \"change in the order of Hooks\"\n * runtime errors.\n * Memoised — read once per worker process.\n * @returns 16-char hex fingerprint.\n */\nfunction getLibraryFingerprint(): string {\n if (libraryFingerprint !== undefined) return libraryFingerprint\n const here = path.dirname(__filename)\n const candidates = [\n path.resolve(here, '..', 'core', 'style-builder', 'build-style.mjs'),\n path.resolve(here, '..', 'core', 'style-builder', 'build-style.cjs'),\n path.resolve(here, '..', 'core', 'parser', 'tw-parser.mjs'),\n path.resolve(here, '..', 'core', 'parser', 'tw-parser.cjs'),\n path.resolve(here, 'transform-ast.mjs'),\n path.resolve(here, 'transform-ast.cjs'),\n path.resolve(here, 'transformer.mjs'),\n path.resolve(here, 'transformer.cjs'),\n // Source-tree fallback for tests + workspace dev (no built lib yet).\n path.resolve(here, '..', '..', 'src', 'core', 'style-builder', 'build-style.ts'),\n path.resolve(here, '..', '..', 'src', 'core', 'parser', 'tw-parser.ts'),\n path.resolve(here, '..', '..', 'src', 'metro', 'transform-ast.ts'),\n path.resolve(here, '..', '..', 'src', 'metro', 'transformer.ts'),\n ]\n const hash = createHash('sha256')\n let included = 0\n for (const file of candidates) {\n if (!existsSync(file)) continue\n try {\n hash.update(readFileSync(file))\n included += 1\n } catch {\n // Unreadable file — skip; fingerprint still derives from whatever WE could read.\n }\n }\n libraryFingerprint = included > 0 ? hash.digest('hex').slice(0, 16) : '0'.repeat(16)\n return libraryFingerprint\n}\n\n/**\n * Worker-local state. Lazy-initialised on first access so files that\n * bypass the transform don't pay for construction.\n */\nexport interface RnwindState {\n parser: TailwindParser\n builder: UnionBuilder\n themeCss: string\n themeHash: string\n projectRoot: string\n}\n\n/**\n * Publish the theme CSS path + cache dir to the environment so worker\n * subprocesses (spawned by Metro once `babelTransformerPath` is set)\n * can rebuild the same state without re-reading the Metro config.\n * @param cssEntryFile Absolute path to the user's theme CSS.\n * @param cacheDir Absolute path to the cache dir (`.rnwind`).\n * @param watchFolders\n * @param classNamePrefixes Extra JSX prop-name prefixes to rewrite.\n */\nexport function configureRnwindState(\n cssEntryFile: string,\n cacheDir: string,\n watchFolders: readonly string[] = [],\n classNamePrefixes?: readonly string[],\n): void {\n process.env[CSS_ENTRY_ENV] = cssEntryFile\n process.env[CACHE_DIR_ENV] = cacheDir\n if (watchFolders.length === 0) {\n delete process.env[WATCH_FOLDERS_ENV]\n } else {\n process.env[WATCH_FOLDERS_ENV] = watchFolders.join('\\0')\n }\n if (!classNamePrefixes || classNamePrefixes.length === 0) {\n delete process.env[CLASSNAME_PREFIXES_ENV]\n } else {\n process.env[CLASSNAME_PREFIXES_ENV] = classNamePrefixes.join(',')\n }\n cached = null\n}\n\n/**\n * Read the caller-configured extra className prefixes out of the\n * worker environment. Returns an empty array when unset — the\n * transformer applies the built-in `contentContainer` default on top\n * either way.\n * @returns User-supplied extra prefixes.\n */\nexport function getClassNamePrefixes(): readonly string[] {\n const raw = process.env[CLASSNAME_PREFIXES_ENV]\n if (!raw || raw.length === 0) return []\n return raw.split(',').filter((entry) => entry.length > 0)\n}\n\n/**\n * Fetch (or build) the worker-local rnwind state. Re-reads the theme\n * CSS hash on every call: if the user edited `global.css` while Metro\n * is running, the cached state is dropped and a fresh parser + ledger\n * is built. Combined with the `getCacheKey()` export on the\n * transformer (which folds the same hash into Metro's per-file cache\n * key) every CSS edit produces a full, correct re-bundle.\n * @param projectRoot\n * @returns The live rnwind state.\n */\nexport function getRnwindState(projectRoot: string): RnwindState {\n const cssEntry = process.env[CSS_ENTRY_ENV]\n const cacheDir = process.env[CACHE_DIR_ENV]\n if (!cssEntry) throw new Error('rnwind: RNWIND_CSS_ENTRY_FILE is not set — did `withRnwindConfig` run?')\n if (!cacheDir) throw new Error('rnwind: RNWIND_CACHE_DIR is not set — did `withRnwindConfig` run?')\n const currentHash = readThemeHashFor(cssEntry)\n if (cached?.themeHash === currentHash && cached.projectRoot === projectRoot) return cached\n const themeCss = readFileSync(cssEntry, 'utf8')\n const parser = new TailwindParser({\n themeCss,\n sources: defaultSources(projectRoot, cacheDir, readWatchFolders()),\n })\n const builder = new UnionBuilder(cacheDir, parser)\n cached = { parser, builder, themeCss, themeHash: currentHash, projectRoot }\n return cached\n}\n\n/**\n * Compute the rnwind cache-key suffix Metro mixes into every per-file\n * transform cache entry via the transformer's `getCacheKey()` export.\n * Includes the CSS path + its current content hash + the rnwind\n * library fingerprint, so any edit to `global.css` OR a library\n * upgrade flips the cache key and forces Metro to re-run the\n * transformer.\n * @returns Deterministic string suitable for appending to Metro's cache key.\n */\nexport function getRnwindCacheKey(): string {\n const cssEntry = process.env[CSS_ENTRY_ENV] ?? ''\n const prefixes = process.env[CLASSNAME_PREFIXES_ENV] ?? ''\n return `rnwind:${cssEntry}:${readThemeHashFor(cssEntry)}|lib:${getLibraryFingerprint()}|pfx:${prefixes}`\n}\n\n/** Drop the cached state — call after editing the theme CSS. */\nexport function resetRnwindState(): void {\n cached = null\n}\n\n/**\n * Drop cached state, rebuild parser/builder with the fresh CSS, rescan\n * the project, and rewrite every scheme file on disk. This is what\n * `withRnwindConfig`'s CSS file-watcher invokes so `global.css` edits\n * propagate to the app via Metro's HMR — without this, the CSS-as-JS\n * module would re-emit `export {}` whose bytes never change, so Metro\n * would never invalidate downstream modules.\n * @param projectRoot Absolute project root (from `metroConfig.projectRoot`).\n */\nexport async function onThemeChange(projectRoot: string): Promise<void> {\n resetRnwindState()\n const state = getRnwindState(projectRoot)\n await state.builder.writeSchemes()\n}\n\n/**\n * Resolve the on-disk path of the scheme manifest module for the\n * resolver. The manifest eager-imports `common.style.js` and\n * lazy-requires each variant scheme; SchemeProvider calls its\n * `ensureSchemeLoaded` export to trigger per-scheme requires.\n * @returns Absolute path to `<cacheDir>/schemes.js`.\n */\nexport function manifestPathFor(): string {\n const cacheDir = process.env[CACHE_DIR_ENV]\n if (!cacheDir) throw new Error('rnwind: RNWIND_CACHE_DIR is not set')\n return path.join(cacheDir, 'schemes.js')\n}\n"],"names":["existsSync","readFileSync","statSync","createHash","TailwindParser","UnionBuilder"],"mappings":";;;;;;;;AAMA;;;;;;;;;;;;;;;;AAgBG;AACH,SAAS,cAAc,CAAC,WAAmB,EAAE,QAAgB,EAAE,YAA+B,EAAA;IAC5F,MAAM,aAAa,GAAG,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC;AAC7C,IAAA,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS,CAAC,WAAW,EAAE,GAAG,YAAY,CAAC,CAAC;IAC7D,MAAM,OAAO,GAAkB,EAAE;AACjC,IAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,sBAAsB,EAAE,OAAO,EAAE,KAAK,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;AACnE,KAAA,CAAC;IACF,MAAM,OAAO,GAAG,IAAIC,yBAAY,CAAC,QAAQ,EAAE,MAAM,CAAC;AAClD,IAAA,MAAM,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE;AAC3E,IAAA,OAAO,MAAM;AACf;AAEA;;;;;;;;AAQG;SACa,iBAAiB,GAAA;IAC/B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,EAAE;IACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC,IAAI,EAAE;AAC1D,IAAA,OAAO,CAAA,OAAA,EAAU,QAAQ,CAAA,CAAA,EAAI,gBAAgB,CAAC,QAAQ,CAAC,CAAA,KAAA,EAAQ,qBAAqB,EAAE,CAAA,KAAA,EAAQ,QAAQ,EAAE;AAC1G;AAEA;SACgB,gBAAgB,GAAA;IAC9B,MAAM,GAAG,IAAI;AACf;AAEA;;;;;;;;AAQG;AACI,eAAe,aAAa,CAAC,WAAmB,EAAA;AACrD,IAAA,gBAAgB,EAAE;AAClB,IAAA,MAAM,KAAK,GAAG,cAAc,CAAC,WAAW,CAAC;AACzC,IAAA,MAAM,KAAK,CAAC,OAAO,CAAC,YAAY,EAAE;AACpC;AAEA;;;;;;AAMG;SACa,eAAe,GAAA;IAC7B,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;AAC3C,IAAA,IAAI,CAAC,QAAQ;AAAE,QAAA,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC;IACrE,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,YAAY,CAAC;AAC1C;;;;;;;;;;"}
@@ -0,0 +1,72 @@
1
+ import { UnionBuilder } from '../core/style-builder';
2
+ import { TailwindParser } from '../core/parser';
3
+ /**
4
+ * Worker-local state. Lazy-initialised on first access so files that
5
+ * bypass the transform don't pay for construction.
6
+ */
7
+ export interface RnwindState {
8
+ parser: TailwindParser;
9
+ builder: UnionBuilder;
10
+ themeCss: string;
11
+ themeHash: string;
12
+ projectRoot: string;
13
+ }
14
+ /**
15
+ * Publish the theme CSS path + cache dir to the environment so worker
16
+ * subprocesses (spawned by Metro once `babelTransformerPath` is set)
17
+ * can rebuild the same state without re-reading the Metro config.
18
+ * @param cssEntryFile Absolute path to the user's theme CSS.
19
+ * @param cacheDir Absolute path to the cache dir (`.rnwind`).
20
+ * @param watchFolders
21
+ * @param classNamePrefixes Extra JSX prop-name prefixes to rewrite.
22
+ */
23
+ export declare function configureRnwindState(cssEntryFile: string, cacheDir: string, watchFolders?: readonly string[], classNamePrefixes?: readonly string[]): void;
24
+ /**
25
+ * Read the caller-configured extra className prefixes out of the
26
+ * worker environment. Returns an empty array when unset — the
27
+ * transformer applies the built-in `contentContainer` default on top
28
+ * either way.
29
+ * @returns User-supplied extra prefixes.
30
+ */
31
+ export declare function getClassNamePrefixes(): readonly string[];
32
+ /**
33
+ * Fetch (or build) the worker-local rnwind state. Re-reads the theme
34
+ * CSS hash on every call: if the user edited `global.css` while Metro
35
+ * is running, the cached state is dropped and a fresh parser + ledger
36
+ * is built. Combined with the `getCacheKey()` export on the
37
+ * transformer (which folds the same hash into Metro's per-file cache
38
+ * key) every CSS edit produces a full, correct re-bundle.
39
+ * @param projectRoot
40
+ * @returns The live rnwind state.
41
+ */
42
+ export declare function getRnwindState(projectRoot: string): RnwindState;
43
+ /**
44
+ * Compute the rnwind cache-key suffix Metro mixes into every per-file
45
+ * transform cache entry via the transformer's `getCacheKey()` export.
46
+ * Includes the CSS path + its current content hash + the rnwind
47
+ * library fingerprint, so any edit to `global.css` OR a library
48
+ * upgrade flips the cache key and forces Metro to re-run the
49
+ * transformer.
50
+ * @returns Deterministic string suitable for appending to Metro's cache key.
51
+ */
52
+ export declare function getRnwindCacheKey(): string;
53
+ /** Drop the cached state — call after editing the theme CSS. */
54
+ export declare function resetRnwindState(): void;
55
+ /**
56
+ * Drop cached state, rebuild parser/builder with the fresh CSS, rescan
57
+ * the project, and rewrite every scheme file on disk. This is what
58
+ * `withRnwindConfig`'s CSS file-watcher invokes so `global.css` edits
59
+ * propagate to the app via Metro's HMR — without this, the CSS-as-JS
60
+ * module would re-emit `export {}` whose bytes never change, so Metro
61
+ * would never invalidate downstream modules.
62
+ * @param projectRoot Absolute project root (from `metroConfig.projectRoot`).
63
+ */
64
+ export declare function onThemeChange(projectRoot: string): Promise<void>;
65
+ /**
66
+ * Resolve the on-disk path of the scheme manifest module for the
67
+ * resolver. The manifest eager-imports `common.style.js` and
68
+ * lazy-requires each variant scheme; SchemeProvider calls its
69
+ * `ensureSchemeLoaded` export to trigger per-scheme requires.
70
+ * @returns Absolute path to `<cacheDir>/schemes.js`.
71
+ */
72
+ export declare function manifestPathFor(): string;