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,164 @@
1
+ /**
2
+ * Runtime resolver for rnwind-transformed files.
3
+ *
4
+ * Hot path is ONE WeakMap.get + cached-array return for stable atoms
5
+ * (no `active:`/`focus:`/`*-safe` variance beyond what the cache key
6
+ * captures). First call per (hoist, scheme, stateIndex) walks the
7
+ * atoms once, looks each up as
8
+ *
9
+ * `cache.atoms[scheme]?.[atom] ?? cache.atoms.common?.[atom]`
10
+ *
11
+ * and caches the result. `registerAtoms(scheme, record)` bumps a
12
+ * version counter; the next lookup notices the mismatch and rebuilds.
13
+ *
14
+ * Keyframes are inlined directly into atom values via `animationName`
15
+ * at build time — no separate registry.
16
+ */
17
+ import type { RnwindState } from './components/rnwind-provider';
18
+ /**
19
+ * One entry in the sorted-by-threshold breakpoints array. The runtime
20
+ * derives an atom's threshold by matching its `<prefix>:` against
21
+ * `name`; the array form is preferred over a Map so the hot-path
22
+ * `tierFor(width)` walk is a tight numeric loop.
23
+ */
24
+ interface BreakpointEntry {
25
+ readonly name: string;
26
+ readonly minWidth: number;
27
+ }
28
+ /** Optional window-height provider for the `screen-minus-y` marker. */
29
+ type WindowHeightProvider = () => number;
30
+ /**
31
+ * Optional scheme loader. Registered by the generated manifest module
32
+ * (`rnwind/__generated/schemes`) once at import time. SchemeProvider
33
+ * calls it synchronously on every render with the active scheme name;
34
+ * first call per scheme pulls the scheme's style module in via an
35
+ * inline `require()` — subsequent calls are a no-op through Metro's
36
+ * module cache.
37
+ */
38
+ type SchemeLoader = (scheme: string) => void;
39
+ /**
40
+ * Per-render snapshot of which interactive states (active, focus) are
41
+ * currently engaged. Forwarded from the `useInteract()` hook the
42
+ * transformer injects.
43
+ */
44
+ export interface InteractState {
45
+ active?: boolean;
46
+ focus?: boolean;
47
+ }
48
+ /**
49
+ * Safe-area insets bundle the transformer passes to `lookupCss` when a
50
+ * file uses any `*-safe` utility.
51
+ */
52
+ export interface LookupInsets {
53
+ top: number;
54
+ right: number;
55
+ bottom: number;
56
+ left: number;
57
+ }
58
+ /**
59
+ * Precomputed safe-area marker spec emitted by the build-side
60
+ * `envelopeSafeMarkers`. Tuple form: `[cssKey, sideTag, or, offset]`.
61
+ */
62
+ export type SafeMarkerSpec = readonly [string, string, number | undefined, number | undefined];
63
+ /** Type alias: the atom-list build output the transformer emits. */
64
+ export type HoistedClassName = readonly string[];
65
+ /**
66
+ * Register a window-height provider used by the `screen-minus-y`
67
+ * safe-area variant. When not wired, `h-screen-safe` resolves to `0`.
68
+ * @param provider Callback returning the current window height in px.
69
+ */
70
+ export declare function setWindowHeightProvider(provider: WindowHeightProvider | null): void;
71
+ /**
72
+ * Register the scheme-loader function exported by the generated
73
+ * manifest module. Called once at manifest-module evaluation time —
74
+ * subsequent registrations override the previous loader (useful for
75
+ * tests).
76
+ * @param loader Manifest's `ensureSchemeLoaded` function, or null to
77
+ * detach (tests).
78
+ */
79
+ export declare function registerSchemeLoader(loader: SchemeLoader | null): void;
80
+ /**
81
+ * Ensure the given scheme's style module is loaded. Safe to call in
82
+ * render — zero-cost after the first call per scheme thanks to
83
+ * Metro's module cache, and a no-op when no loader is registered
84
+ * (tests, or a bundle without rnwind-transformed sources).
85
+ * @param scheme Active scheme name.
86
+ */
87
+ export declare function loadScheme(scheme: string): void;
88
+ /**
89
+ * Register (or re-register) one scheme's atoms in the global registry.
90
+ * Pure property assignment — no iteration, no allocation. The version
91
+ * counter bump invalidates every hoist-level result cache lazily on
92
+ * next read.
93
+ * @param scheme Registry key — `'common'` for the always-loaded
94
+ * fallback, or a variant name (`'dark'`, `'light'`, `'brand'`, ...).
95
+ * @param atoms Plain record keyed by atom name.
96
+ */
97
+ export declare function registerAtoms(scheme: string, atoms: Record<string, unknown>): void;
98
+ /**
99
+ * Register the responsive-breakpoint table the manifest module emits at
100
+ * load time. Replaces the prior table — calling with `{}` clears it.
101
+ * Bumps `atomVersion` so any cached lookup invalidates on next read,
102
+ * which matters during a theme HMR cycle that adds/removes breakpoints.
103
+ * @param breakpoints Breakpoint name → minimum-width threshold (px).
104
+ */
105
+ export declare function registerBreakpoints(breakpoints: Record<string, number>): void;
106
+ /**
107
+ * Snapshot of the registered breakpoints, for callers that want to
108
+ * compute their own derivations (e.g. the provider deriving the active
109
+ * breakpoint name). Returns a fresh array — callers can iterate without
110
+ * worrying about concurrent mutation from a manifest reload.
111
+ * @returns Breakpoints sorted by ascending min-width threshold.
112
+ */
113
+ export declare function getBreakpoints(): readonly BreakpointEntry[];
114
+ /**
115
+ * Sentinel name returned by {@link activeBreakpointFor} ONLY when no
116
+ * breakpoints are registered at all (bundle without rnwind-transformed
117
+ * sources, fresh test setup). When at least one breakpoint is
118
+ * registered, the function falls back to the smallest registered name
119
+ * instead — so phone-width devices (402 dp on a stock iPhone, well
120
+ * below `sm = 640`) report `activeBreakpoint === 'sm'` rather than the
121
+ * abstract `'base'`. This matches the user expectation that the value
122
+ * is always a real Tailwind breakpoint label they can branch on.
123
+ *
124
+ * Note: this is decoupled from the className filter. `sm:*` atoms
125
+ * still only fire at `windowWidth >= 640` per Tailwind's mobile-first
126
+ * spec — `activeBreakpoint === 'sm'` at 402 means "I'm in the smallest
127
+ * tier", not "`sm:` classes are firing".
128
+ */
129
+ export declare const BASE_BREAKPOINT = "base";
130
+ /**
131
+ * Resolve the currently-active breakpoint name for a width:
132
+ * - `windowWidth >= some threshold` → the highest matching breakpoint name.
133
+ * - below every registered threshold → the smallest registered name.
134
+ * - no breakpoints registered → {@link BASE_BREAKPOINT}.
135
+ * Always returns a string so consumers can branch on it without
136
+ * null-handling.
137
+ * @param windowWidth Live window width in px.
138
+ * @returns Active breakpoint name (never null).
139
+ */
140
+ export declare function activeBreakpointFor(windowWidth: number): string;
141
+ /**
142
+ * Resolve a className input against the active rnwind context. Hot
143
+ * path:
144
+ * - Array input (build hoist): ONE WeakMap.get + ONE record-access
145
+ * + cached array return. No per-render allocation when there's no
146
+ * userStyle and the hoist has no safe atoms.
147
+ * - String input (dynamic `className={expr}`): tokenise + walk.
148
+ * @param input Hoisted atom list or raw className string.
149
+ * @param ctx Rnwind context — `{scheme, fontScale, insets}` (extra
150
+ * fields ignored). Pass the result of `useRnwind()` directly.
151
+ * @param userStyle Optional caller-supplied style appended last.
152
+ * @param interactState Live active/focus flags from `useInteract()`.
153
+ * @returns Style array for React Native's `style` prop.
154
+ */
155
+ export declare function lookupCss(input: HoistedClassName | string | null | undefined, ctx: RnwindState, userStyle?: unknown, interactState?: InteractState): readonly unknown[];
156
+ /** Test-only — clear the global registry between suites. */
157
+ export declare function __resetLookupCssState(): void;
158
+ /**
159
+ * Test-only sugar: accept a single-scheme record and register it as the
160
+ * `common` table.
161
+ * @param record Atom name → value record (registered under `common`).
162
+ */
163
+ export declare function __registerAtomsFromRecord(record: Record<string, unknown>): void;
164
+ export {};
@@ -0,0 +1,29 @@
1
+ /**
2
+ * App-level configuration projected into the type system. Apps extend this
3
+ * interface from their generated `rnwind-types.d.ts` — which rnwind writes
4
+ * alongside the CSS theme on every Metro start — to narrow `Scheme` to the
5
+ * exact scheme names declared in `global.css`.
6
+ *
7
+ * Left empty here so library code stays buildable without a generated
8
+ * augmentation; `Scheme` falls back to `string` under that default.
9
+ * @example
10
+ * ```ts
11
+ * // rnwind-types.d.ts (auto-generated)
12
+ * declare module 'rnwind' {
13
+ * export interface RnwindConfig {
14
+ * themes: readonly ['light', 'dark', 'brand']
15
+ * }
16
+ * }
17
+ * ```
18
+ */
19
+ export interface RnwindConfig {
20
+ }
21
+ /**
22
+ * Type of the `scheme` prop + the value returned by `useScheme()`. Resolves
23
+ * to the literal union declared on {@link RnwindConfig.themes} when the app
24
+ * provides one via `rnwind-types.d.ts`; falls back to `string` otherwise so
25
+ * consumers without generated types keep compiling.
26
+ */
27
+ export type Scheme = RnwindConfig extends {
28
+ themes: infer T;
29
+ } ? T extends readonly (infer S)[] ? Extract<S, string> : string : string;
@@ -0,0 +1,367 @@
1
+ 'use strict';
2
+
3
+ var parser = require('@babel/parser');
4
+ var generate$1 = require('@babel/generator');
5
+ var node_fs = require('node:fs');
6
+ var node_module = require('node:module');
7
+ var node_os = require('node:os');
8
+ var path = require('node:path');
9
+ var React = require('react');
10
+ var lookupCss = require('../runtime/lookup-css.cjs');
11
+ var rnwindProvider = require('../runtime/components/rnwind-provider.cjs');
12
+ var haptics = require('../runtime/haptics.cjs');
13
+ var state = require('../metro/state.cjs');
14
+ var metro_transformer = require('../metro/transformer.cjs');
15
+
16
+ function _interopNamespaceDefault(e) {
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ Object.keys(e).forEach(function (k) {
20
+ if (k !== 'default') {
21
+ var d = Object.getOwnPropertyDescriptor(e, k);
22
+ Object.defineProperty(n, k, d.get ? d : {
23
+ enumerable: true,
24
+ get: function () { return e[k]; }
25
+ });
26
+ }
27
+ });
28
+ }
29
+ n.default = e;
30
+ return Object.freeze(n);
31
+ }
32
+
33
+ var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
34
+
35
+ // ────────────────────────────────────────────────────────────────────────
36
+ // Private constants
37
+ // ────────────────────────────────────────────────────────────────────────
38
+ /**
39
+ * Minimal theme every `renderWithCss` call defaults to. Ships the two
40
+ * conventional schemes so atoms carrying `dark:` / `light:` prefixes
41
+ * resolve without the caller having to craft a theme CSS string.
42
+ */
43
+ const DEFAULT_THEME_CSS = `@import 'tailwindcss';
44
+ @layer theme {
45
+ :root {
46
+ @variant light { --color-bg: #ffffff; --color-fg: #0a0a0a; }
47
+ @variant dark { --color-bg: #0a0a0a; --color-fg: #ffffff; }
48
+ }
49
+ }
50
+ `;
51
+ /** `StyleSheet.create` stub the evaluated bundle calls — identity at test time. */
52
+ const BUNDLE_STYLE_SHEET = { create: (styles) => styles, hairlineWidth: 1 };
53
+ /** Stubbed interactive-state hook return matching `useInteract()`. */
54
+ const NOOP_INTERACT = {
55
+ state: undefined,
56
+ onPressIn: () => undefined,
57
+ onPressOut: () => undefined,
58
+ onFocus: () => undefined,
59
+ onBlur: () => undefined,
60
+ };
61
+ /**
62
+ * Identity chain helper matching `chainPress` / `chainFocus`. Returns a
63
+ * single callback that invokes every supplied handler in turn.
64
+ * @param handlers Handlers to chain.
65
+ * @returns Combined callback.
66
+ */
67
+ const NOOP_CHAIN = (...handlers) => (...args) => {
68
+ for (const handler of handlers) {
69
+ if (typeof handler === 'function')
70
+ handler(...args);
71
+ }
72
+ };
73
+ // Synthesize a require rooted at the consumer's cwd so optional peer
74
+ // lookups (`@testing-library/react-native`, `esbuild`) resolve from THEIR
75
+ // node_modules, not rnwind's. A workspace-local rnwind install resolves
76
+ // through a different node_modules chain than the test cwd — we want the
77
+ // test's chain.
78
+ const localRequire = node_module.createRequire(path.join(process.cwd(), 'package.json'));
79
+ const generate = generate$1.default ?? generate$1;
80
+ /**
81
+ * Pre-loaded `@testing-library/react-native`. Resolved once at module
82
+ * init (not lazily per-call) because the testing library registers
83
+ * `beforeAll`/`afterEach` cleanup hooks on import — and Bun's test
84
+ * runner refuses to register lifecycle hooks from inside a running
85
+ * test body, which is where the first `renderWithCss` call lands.
86
+ */
87
+ const TESTING_LIBRARY = (() => {
88
+ try {
89
+ return localRequire('@testing-library/react-native');
90
+ }
91
+ catch (error) {
92
+ throw new Error('rnwind/testing: cannot load `@testing-library/react-native`. Add it to your dev dependencies. Underlying error: ' +
93
+ (error instanceof Error ? error.message : String(error)));
94
+ }
95
+ })();
96
+ /**
97
+ * Default lookup for the test process's `react-native` module. Users
98
+ * who run with a mocked `react-native` (via Bun's `mock.module` or
99
+ * Jest's `jest.mock`) get the mock here automatically.
100
+ * @returns React Native namespace bindings.
101
+ */
102
+ function resolveReactNative() {
103
+ return localRequire('react-native');
104
+ }
105
+ /**
106
+ * Compile JSX + TypeScript source to plain JS. Prefers Bun's built-in
107
+ * transpiler (fast, zero-dep); falls back to `esbuild` if running under
108
+ * Node (Jest users). Throws with an install hint if neither is available.
109
+ * @param source Source text to compile.
110
+ * @returns JavaScript suitable for `new Function(...)` evaluation.
111
+ */
112
+ function compileToJs(source) {
113
+ const globalBun = globalThis.Bun;
114
+ if (globalBun?.Transpiler) {
115
+ return new globalBun.Transpiler({
116
+ loader: 'tsx',
117
+ tsconfig: JSON.stringify({ compilerOptions: { jsx: 'react', target: 'esnext' } }),
118
+ }).transformSync(source);
119
+ }
120
+ try {
121
+ const esbuild = localRequire('esbuild');
122
+ return esbuild.transformSync(source, { loader: 'tsx', jsx: 'transform', target: 'esnext' }).code;
123
+ }
124
+ catch {
125
+ throw new Error('rnwind/testing: cannot compile JSX. Run tests under Bun (which has a built-in transpiler) ' +
126
+ 'or install `esbuild` as a dev dependency for Node / Jest setups.');
127
+ }
128
+ }
129
+ /**
130
+ * Evaluate the union `style.js` the ledger wrote during the transform
131
+ * so its `registerAtoms` call lands in the process-global registry.
132
+ * Strips the `react-native` + `rnwind` imports from the source and
133
+ * forwards local bindings into the evaluated closure.
134
+ * @param cacheDir The rnwind cache dir where the ledger writes bundles.
135
+ */
136
+ function evaluateStyleBundle(cacheDir) {
137
+ const filePath = path.join(cacheDir, 'style.js');
138
+ if (!node_fs.existsSync(filePath))
139
+ return;
140
+ const body = node_fs.readFileSync(filePath, 'utf8')
141
+ .replaceAll(/import \{ StyleSheet \} from 'react-native'\s*\n/g, '')
142
+ .replaceAll(/import \{[^}]+\} from 'rnwind'\s*\n/g, '');
143
+ // Bundle body is generated by rnwind itself — not user-controlled.
144
+ // eslint-disable-next-line sonarjs/code-eval
145
+ new Function('StyleSheet', 'registerAtoms', body)(BUNDLE_STYLE_SHEET, lookupCss.registerAtoms);
146
+ }
147
+ /**
148
+ * Evaluate the transformer's rewritten source as a standalone module:
149
+ * strip synthetic imports, forward `import ... from 'rnwind'` +
150
+ * `'react-native'` to local bindings, compile JSX via the compiler, and
151
+ * capture the default export.
152
+ * @param transformedSource Post-transformer source.
153
+ * @param reactNative `react-native` namespace bindings to forward.
154
+ * @returns The default-exported component.
155
+ */
156
+ function evaluateRewrittenModule(transformedSource, reactNative) {
157
+ const prepared = transformedSource
158
+ .replaceAll(/import\s+["']rnwind\/__generated\/[^"']+["'];?\s*\n?/g, '')
159
+ .replaceAll(/import\s+\{([^}]+)\}\s+from\s+["']rnwind["'];?/g, 'const {$1} = __rnwind;')
160
+ .replaceAll(/import\s+\{([^}]+)\}\s+from\s+["']react-native["'];?/g, 'const {$1} = __reactNative;')
161
+ .replace(/export\s+default\s+/, 'module.exports.default = ');
162
+ const compiled = compileToJs(prepared);
163
+ const rnwindEnv = {
164
+ lookupCss: lookupCss.lookupCss,
165
+ useRnwind: rnwindProvider.useRnwind,
166
+ useR_: rnwindProvider.useR_,
167
+ useMountHaptic: haptics.useMountHaptic,
168
+ triggerHaptic: haptics.triggerHaptic,
169
+ useInteract: () => NOOP_INTERACT,
170
+ chainPress: NOOP_CHAIN,
171
+ chainFocus: NOOP_CHAIN,
172
+ };
173
+ const moduleObject = { exports: {} };
174
+ // Compiled source originates from rnwind's own transformer + the JSX compiler.
175
+ // eslint-disable-next-line sonarjs/code-eval
176
+ new Function('React', '__rnwind', '__reactNative', 'module', compiled)(React__namespace, rnwindEnv, reactNative, moduleObject);
177
+ if (!moduleObject.exports.default) {
178
+ throw new Error('rnwind/testing: evaluated module did not export a default component.');
179
+ }
180
+ return moduleObject.exports.default;
181
+ }
182
+ /**
183
+ * Build the root element `@testing-library/react-native`'s `render`
184
+ * receives. When a scheme is specified, wrap the component in a live
185
+ * `<RnwindProvider>` so hooks like `useScheme()` and `useCss()` return
186
+ * the requested scheme. Otherwise render bare (context falls back to the
187
+ * default `'light'`).
188
+ * @param Component Component to render.
189
+ * @param scheme Optional active scheme override.
190
+ * @param insets
191
+ * @param onHaptics
192
+ * @returns The React element to hand to `render`.
193
+ */
194
+ function buildRootElement(Component, scheme, insets, onHaptics) {
195
+ const child = React__namespace.createElement(Component);
196
+ if (scheme === undefined && !insets && !onHaptics)
197
+ return child;
198
+ const providerProps = {
199
+ scheme: (scheme ?? 'light'),
200
+ };
201
+ if (insets)
202
+ providerProps.insets = insets;
203
+ if (onHaptics)
204
+ providerProps.onHaptics = onHaptics;
205
+ return React__namespace.createElement(rnwindProvider.RnwindProvider, providerProps, child);
206
+ }
207
+ /**
208
+ * Compose the `wrapper` option `renderHook` accepts. When a scheme is
209
+ * set, wrap the hook's execution context in `<RnwindProvider>` so hooks
210
+ * that read `useScheme()` see the requested scheme. If the user also
211
+ * supplies their own wrapper, nest it inside the provider so both apply.
212
+ * @param scheme Optional active scheme override.
213
+ * @param userWrapper Optional user-supplied wrapper component.
214
+ * @returns A wrapper component suitable for `renderHook`'s `wrapper` option.
215
+ */
216
+ function composeHookWrapper(scheme, userWrapper) {
217
+ if (scheme === undefined && !userWrapper)
218
+ return undefined;
219
+ return function RnwindTestWrapper({ children }) {
220
+ const inner = userWrapper ? React__namespace.createElement(userWrapper, null, children) : children;
221
+ if (scheme === undefined)
222
+ return inner;
223
+ return React__namespace.createElement(rnwindProvider.RnwindProvider, { scheme: scheme }, inner);
224
+ };
225
+ }
226
+ /**
227
+ * Spin up an ephemeral rnwind project and register the atoms produced
228
+ * by `source` (when provided) into the runtime. Returns the project
229
+ * state and the post-transform source so callers can render the
230
+ * rewritten module or just rely on the registered atoms.
231
+ *
232
+ * Shared between `renderWithCss` (needs the rewritten component) and
233
+ * `renderHookWithCss` (only needs the atoms in the registry).
234
+ * @param options Options controlling the theme and pre-registered source.
235
+ * @param options.themeCss Theme CSS override.
236
+ * @param options.source Source whose Tailwind candidates should be registered.
237
+ * @returns Paths plus the transformed source and a `cleanup` closure.
238
+ */
239
+ async function bootstrapRnwindRuntime(options) {
240
+ const projectRoot = node_fs.mkdtempSync(path.join(node_os.tmpdir(), 'rnwind-test-'));
241
+ const cacheDir = path.join(projectRoot, '.rnwind-cache');
242
+ const cssPath = path.join(projectRoot, 'theme.css');
243
+ node_fs.writeFileSync(cssPath, options.themeCss ?? DEFAULT_THEME_CSS);
244
+ state.configureRnwindState(cssPath, cacheDir);
245
+ let transformedSource = '';
246
+ if (options.source !== undefined) {
247
+ const filename = path.join(projectRoot, 'App.tsx');
248
+ node_fs.writeFileSync(filename, options.source);
249
+ const ast = parser.parse(options.source, { sourceType: 'module', plugins: ['typescript', 'jsx'] });
250
+ const result = await metro_transformer.transform({ filename, src: options.source, options: { projectRoot }, ast });
251
+ transformedSource = generate(result.ast).code;
252
+ evaluateStyleBundle(cacheDir);
253
+ }
254
+ const cleanup = () => {
255
+ lookupCss.__resetLookupCssState();
256
+ state.resetRnwindState();
257
+ if (node_fs.existsSync(projectRoot))
258
+ node_fs.rmSync(projectRoot, { recursive: true, force: true });
259
+ };
260
+ return { projectRoot, cacheDir, transformedSource, cleanup };
261
+ }
262
+ /**
263
+ * Synthesize a throwaway source file that mentions each className in a
264
+ * JSX `className="..."` attribute so the Metro transformer's scanner
265
+ * picks them up and records their resolved styles into the union
266
+ * `style.js`. Used by `renderHookWithCss` to pre-register atoms the
267
+ * hook under test will look up.
268
+ * @param classNames Class names to include.
269
+ * @returns Source string suitable for `bootstrapRnwindRuntime`.
270
+ */
271
+ function sourceFromClassNames(classNames) {
272
+ const joined = classNames.join(' ').replaceAll('"', String.raw `\"`);
273
+ return `const V: any = () => null\nexport default () => <V className="${joined}" />\n`;
274
+ }
275
+ // ────────────────────────────────────────────────────────────────────────
276
+ // Public exports — functions
277
+ // ────────────────────────────────────────────────────────────────────────
278
+ /**
279
+ * Feed a source string through rnwind's Metro transformer, evaluate
280
+ * the generated `style.js` bundle, evaluate the rewritten module, and
281
+ * render the default-exported component with
282
+ * `@testing-library/react-native`.
283
+ *
284
+ * The rendered RN element's `style` prop is the EXACT array your
285
+ * production bundle would attach — same transformer, same runtime
286
+ * resolver, same atoms. Assert on `flatten(node.props.style)` to verify
287
+ * the resolved values.
288
+ * @example
289
+ * ```tsx
290
+ * const handle = await renderWithCss(
291
+ * `import { View } from 'react-native'
292
+ * export default () => <View className="bg-primary p-4" testID="box" />`,
293
+ * { themeCss: `@import 'tailwindcss'; @theme { --color-primary: #6366f1; }` },
294
+ * )
295
+ * const flat = flatten(handle.getByTestId('box').props.style)
296
+ * expect(flat.backgroundColor).toBe('#6366f1')
297
+ * ```
298
+ * @param source User source (one file) to transform + render.
299
+ * @param options Optional theme override, scheme, and `react-native` bindings.
300
+ * @returns Render queries + diagnostic handles.
301
+ */
302
+ async function renderWithCss(source, options = {}) {
303
+ const reactNative = options.reactNative ?? resolveReactNative();
304
+ const { projectRoot: _projectRoot, transformedSource, cleanup, } = await bootstrapRnwindRuntime({
305
+ themeCss: options.themeCss,
306
+ source,
307
+ });
308
+ const Component = evaluateRewrittenModule(transformedSource, reactNative);
309
+ const rendered = TESTING_LIBRARY.render(buildRootElement(Component, options.scheme, options.insets, options.onHaptics));
310
+ return Object.assign({}, rendered, { transformedSource, cleanup });
311
+ }
312
+ /**
313
+ * Render-side counterpart to {@link renderWithCss} for testing hooks in
314
+ * isolation. Pre-registers atoms for the supplied `classNames`, wraps
315
+ * the hook in an optional `<RnwindProvider>`, and forwards to
316
+ * `@testing-library/react-native`'s `renderHook`.
317
+ * @example
318
+ * ```ts
319
+ * const { result, cleanup } = await renderHookWithCss(
320
+ * () => useCss('bg-primary'),
321
+ * {
322
+ * themeCss: `@import 'tailwindcss'; @theme { --color-primary: #6366f1; }`,
323
+ * classNames: ['bg-primary'],
324
+ * },
325
+ * )
326
+ * expect(flatten(result.current).backgroundColor).toBe('#6366f1')
327
+ * cleanup()
328
+ * ```
329
+ * @param callback Hook body — same shape as `renderHook(callback)`.
330
+ * @param options Theme, scheme, classNames to pre-register, plus
331
+ * everything `renderHook` itself accepts (`initialProps`, `wrapper`).
332
+ * @returns `renderHook`'s return value plus a `cleanup` function.
333
+ */
334
+ async function renderHookWithCss(callback, options = {}) {
335
+ const { cleanup } = await bootstrapRnwindRuntime({
336
+ themeCss: options.themeCss,
337
+ source: options.classNames && options.classNames.length > 0 ? sourceFromClassNames(options.classNames) : undefined,
338
+ });
339
+ const wrapper = composeHookWrapper(options.scheme, options.wrapper);
340
+ const { themeCss: _themeCss, scheme: _scheme, classNames: _classNames, ...hookOptions } = options;
341
+ const rendered = TESTING_LIBRARY.renderHook(callback, {
342
+ ...hookOptions,
343
+ wrapper,
344
+ });
345
+ return Object.assign({}, rendered, { cleanup });
346
+ }
347
+ /**
348
+ * Flatten a React Native style array (or single style object) into one
349
+ * merged record. RN flattens left-to-right (later wins), so the returned
350
+ * record is what the native view manager actually applies.
351
+ * @param styles Style array, single object, or null/undefined.
352
+ * @returns Flat style record.
353
+ */
354
+ function flatten(styles) {
355
+ if (styles == null)
356
+ return {};
357
+ if (Array.isArray(styles))
358
+ return Object.assign({}, ...styles.map((entry) => flatten(entry)));
359
+ if (typeof styles === 'object')
360
+ return styles;
361
+ return {};
362
+ }
363
+
364
+ exports.flatten = flatten;
365
+ exports.renderHookWithCss = renderHookWithCss;
366
+ exports.renderWithCss = renderWithCss;
367
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../../../../src/testing/index.ts"],"sourcesContent":["/* eslint-disable sonarjs/no-unused-vars */\nimport type { File as BabelFile } from '@babel/types'\nimport { parse } from '@babel/parser'\nimport generateImport from '@babel/generator'\nimport { existsSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs'\nimport { createRequire } from 'node:module'\nimport { tmpdir } from 'node:os'\nimport path from 'node:path'\nimport * as React from 'react'\nimport type {\n render as testingLibraryRender,\n renderHook as testingLibraryRenderHook,\n RenderHookOptions,\n} from '@testing-library/react-native'\nimport { configureRnwindState, resetRnwindState, transform as metroTransform } from '../metro'\nimport { __resetLookupCssState, lookupCss, registerAtoms } from '../runtime/lookup-css'\nimport type { Insets } from '../runtime/components/rnwind-provider'\nimport { RnwindProvider, useRnwind, useR_ } from '../runtime/components/rnwind-provider'\nimport { triggerHaptic, useMountHaptic } from '../runtime/haptics'\nimport type { OnHaptics } from '../core/parser/haptics'\nimport type { Scheme } from '../runtime/types'\n\n// ────────────────────────────────────────────────────────────────────────\n// Private constants\n// ────────────────────────────────────────────────────────────────────────\n\n/**\n * Minimal theme every `renderWithCss` call defaults to. Ships the two\n * conventional schemes so atoms carrying `dark:` / `light:` prefixes\n * resolve without the caller having to craft a theme CSS string.\n */\nconst DEFAULT_THEME_CSS = `@import 'tailwindcss';\n@layer theme {\n :root {\n @variant light { --color-bg: #ffffff; --color-fg: #0a0a0a; }\n @variant dark { --color-bg: #0a0a0a; --color-fg: #ffffff; }\n }\n}\n`\n\n/** `StyleSheet.create` stub the evaluated bundle calls — identity at test time. */\nconst BUNDLE_STYLE_SHEET = { create: <T>(styles: T): T => styles, hairlineWidth: 1 }\n\n/** Stubbed interactive-state hook return matching `useInteract()`. */\nconst NOOP_INTERACT = {\n state: undefined,\n onPressIn: (): void => undefined,\n onPressOut: (): void => undefined,\n onFocus: (): void => undefined,\n onBlur: (): void => undefined,\n}\n\n/**\n * Identity chain helper matching `chainPress` / `chainFocus`. Returns a\n * single callback that invokes every supplied handler in turn.\n * @param handlers Handlers to chain.\n * @returns Combined callback.\n */\nconst NOOP_CHAIN =\n (...handlers: ReadonlyArray<((...args: unknown[]) => unknown) | undefined>) =>\n (...args: unknown[]): void => {\n for (const handler of handlers) {\n if (typeof handler === 'function') handler(...args)\n }\n }\n\n// Synthesize a require rooted at the consumer's cwd so optional peer\n// lookups (`@testing-library/react-native`, `esbuild`) resolve from THEIR\n// node_modules, not rnwind's. A workspace-local rnwind install resolves\n// through a different node_modules chain than the test cwd — we want the\n// test's chain.\nconst localRequire: NodeRequire = createRequire(path.join(process.cwd(), 'package.json'))\n\nconst generate: typeof generateImport = (generateImport as { default?: typeof generateImport }).default ?? generateImport\n\n/**\n * Pre-loaded `@testing-library/react-native`. Resolved once at module\n * init (not lazily per-call) because the testing library registers\n * `beforeAll`/`afterEach` cleanup hooks on import — and Bun's test\n * runner refuses to register lifecycle hooks from inside a running\n * test body, which is where the first `renderWithCss` call lands.\n */\nconst TESTING_LIBRARY: {\n render: typeof testingLibraryRender\n renderHook: typeof testingLibraryRenderHook\n} = (() => {\n try {\n return localRequire('@testing-library/react-native') as {\n render: typeof testingLibraryRender\n renderHook: typeof testingLibraryRenderHook\n }\n } catch (error) {\n throw new Error(\n 'rnwind/testing: cannot load `@testing-library/react-native`. Add it to your dev dependencies. Underlying error: ' +\n (error instanceof Error ? error.message : String(error)),\n )\n }\n})()\n\n// ────────────────────────────────────────────────────────────────────────\n// Private helpers\n// ────────────────────────────────────────────────────────────────────────\n\n/**\n * Scheme string typed to match what `<RnwindProvider>` accepts. Users\n * who declare their own scheme names via `rnwind-types.d.ts` get them\n * through `Scheme`; everyone else gets `'light' | 'dark' | string`.\n */\ntype SchemeName = Scheme\n\n/**\n * Default lookup for the test process's `react-native` module. Users\n * who run with a mocked `react-native` (via Bun's `mock.module` or\n * Jest's `jest.mock`) get the mock here automatically.\n * @returns React Native namespace bindings.\n */\nfunction resolveReactNative(): Record<string, unknown> {\n return localRequire('react-native') as Record<string, unknown>\n}\n\n/**\n * Compile JSX + TypeScript source to plain JS. Prefers Bun's built-in\n * transpiler (fast, zero-dep); falls back to `esbuild` if running under\n * Node (Jest users). Throws with an install hint if neither is available.\n * @param source Source text to compile.\n * @returns JavaScript suitable for `new Function(...)` evaluation.\n */\nfunction compileToJs(source: string): string {\n const globalBun = (\n globalThis as { Bun?: { Transpiler: new (options: unknown) => { transformSync: (text: string) => string } } }\n ).Bun\n if (globalBun?.Transpiler) {\n return new globalBun.Transpiler({\n loader: 'tsx',\n tsconfig: JSON.stringify({ compilerOptions: { jsx: 'react', target: 'esnext' } }),\n }).transformSync(source)\n }\n try {\n const esbuild = localRequire('esbuild') as {\n transformSync: (text: string, options: { loader: string; jsx: string; target?: string }) => { code: string }\n }\n return esbuild.transformSync(source, { loader: 'tsx', jsx: 'transform', target: 'esnext' }).code\n } catch {\n throw new Error(\n 'rnwind/testing: cannot compile JSX. Run tests under Bun (which has a built-in transpiler) ' +\n 'or install `esbuild` as a dev dependency for Node / Jest setups.',\n )\n }\n}\n\n/**\n * Evaluate the union `style.js` the ledger wrote during the transform\n * so its `registerAtoms` call lands in the process-global registry.\n * Strips the `react-native` + `rnwind` imports from the source and\n * forwards local bindings into the evaluated closure.\n * @param cacheDir The rnwind cache dir where the ledger writes bundles.\n */\nfunction evaluateStyleBundle(cacheDir: string): void {\n const filePath = path.join(cacheDir, 'style.js')\n if (!existsSync(filePath)) return\n const body = readFileSync(filePath, 'utf8')\n .replaceAll(/import \\{ StyleSheet \\} from 'react-native'\\s*\\n/g, '')\n .replaceAll(/import \\{[^}]+\\} from 'rnwind'\\s*\\n/g, '')\n // Bundle body is generated by rnwind itself — not user-controlled.\n // eslint-disable-next-line sonarjs/code-eval\n new Function('StyleSheet', 'registerAtoms', body)(BUNDLE_STYLE_SHEET, registerAtoms)\n}\n\n/**\n * Evaluate the transformer's rewritten source as a standalone module:\n * strip synthetic imports, forward `import ... from 'rnwind'` +\n * `'react-native'` to local bindings, compile JSX via the compiler, and\n * capture the default export.\n * @param transformedSource Post-transformer source.\n * @param reactNative `react-native` namespace bindings to forward.\n * @returns The default-exported component.\n */\nfunction evaluateRewrittenModule(\n transformedSource: string,\n reactNative: Record<string, unknown>,\n): React.ComponentType<Record<string, unknown>> {\n const prepared = transformedSource\n .replaceAll(/import\\s+[\"']rnwind\\/__generated\\/[^\"']+[\"'];?\\s*\\n?/g, '')\n .replaceAll(/import\\s+\\{([^}]+)\\}\\s+from\\s+[\"']rnwind[\"'];?/g, 'const {$1} = __rnwind;')\n .replaceAll(/import\\s+\\{([^}]+)\\}\\s+from\\s+[\"']react-native[\"'];?/g, 'const {$1} = __reactNative;')\n .replace(/export\\s+default\\s+/, 'module.exports.default = ')\n\n const compiled = compileToJs(prepared)\n const rnwindEnv = {\n lookupCss,\n useRnwind,\n useR_,\n useMountHaptic,\n triggerHaptic,\n useInteract: () => NOOP_INTERACT,\n chainPress: NOOP_CHAIN,\n chainFocus: NOOP_CHAIN,\n }\n const moduleObject: { exports: { default?: React.ComponentType<Record<string, unknown>> } } = { exports: {} }\n // Compiled source originates from rnwind's own transformer + the JSX compiler.\n // eslint-disable-next-line sonarjs/code-eval\n new Function('React', '__rnwind', '__reactNative', 'module', compiled)(React, rnwindEnv, reactNative, moduleObject)\n if (!moduleObject.exports.default) {\n throw new Error('rnwind/testing: evaluated module did not export a default component.')\n }\n return moduleObject.exports.default\n}\n\n/**\n * Build the root element `@testing-library/react-native`'s `render`\n * receives. When a scheme is specified, wrap the component in a live\n * `<RnwindProvider>` so hooks like `useScheme()` and `useCss()` return\n * the requested scheme. Otherwise render bare (context falls back to the\n * default `'light'`).\n * @param Component Component to render.\n * @param scheme Optional active scheme override.\n * @param insets\n * @param onHaptics\n * @returns The React element to hand to `render`.\n */\nfunction buildRootElement(\n Component: React.ComponentType<Record<string, unknown>>,\n scheme: string | undefined,\n insets: Partial<Insets> | undefined,\n onHaptics: OnHaptics | undefined,\n): React.ReactElement {\n const child = React.createElement(Component)\n if (scheme === undefined && !insets && !onHaptics) return child\n const providerProps: { scheme: SchemeName; insets?: Partial<Insets>; onHaptics?: OnHaptics } = {\n scheme: (scheme ?? 'light') as SchemeName,\n }\n if (insets) providerProps.insets = insets\n if (onHaptics) providerProps.onHaptics = onHaptics\n return React.createElement(RnwindProvider, providerProps, child)\n}\n\n/**\n * Compose the `wrapper` option `renderHook` accepts. When a scheme is\n * set, wrap the hook's execution context in `<RnwindProvider>` so hooks\n * that read `useScheme()` see the requested scheme. If the user also\n * supplies their own wrapper, nest it inside the provider so both apply.\n * @param scheme Optional active scheme override.\n * @param userWrapper Optional user-supplied wrapper component.\n * @returns A wrapper component suitable for `renderHook`'s `wrapper` option.\n */\nfunction composeHookWrapper(\n scheme: string | undefined,\n userWrapper: React.ComponentType<{ children?: React.ReactNode }> | undefined,\n): React.ComponentType<{ children?: React.ReactNode }> | undefined {\n if (scheme === undefined && !userWrapper) return undefined\n return function RnwindTestWrapper({ children }: { children?: React.ReactNode }): React.ReactElement {\n const inner = userWrapper ? React.createElement(userWrapper, null, children) : (children as React.ReactElement)\n if (scheme === undefined) return inner\n return React.createElement(RnwindProvider, { scheme: scheme as SchemeName }, inner)\n }\n}\n\n/**\n * Spin up an ephemeral rnwind project and register the atoms produced\n * by `source` (when provided) into the runtime. Returns the project\n * state and the post-transform source so callers can render the\n * rewritten module or just rely on the registered atoms.\n *\n * Shared between `renderWithCss` (needs the rewritten component) and\n * `renderHookWithCss` (only needs the atoms in the registry).\n * @param options Options controlling the theme and pre-registered source.\n * @param options.themeCss Theme CSS override.\n * @param options.source Source whose Tailwind candidates should be registered.\n * @returns Paths plus the transformed source and a `cleanup` closure.\n */\nasync function bootstrapRnwindRuntime(options: { themeCss?: string; source?: string }): Promise<{\n projectRoot: string\n cacheDir: string\n transformedSource: string\n cleanup: () => void\n}> {\n const projectRoot = mkdtempSync(path.join(tmpdir(), 'rnwind-test-'))\n const cacheDir = path.join(projectRoot, '.rnwind-cache')\n const cssPath = path.join(projectRoot, 'theme.css')\n writeFileSync(cssPath, options.themeCss ?? DEFAULT_THEME_CSS)\n configureRnwindState(cssPath, cacheDir)\n\n let transformedSource = ''\n if (options.source !== undefined) {\n const filename = path.join(projectRoot, 'App.tsx')\n writeFileSync(filename, options.source)\n const ast: BabelFile = parse(options.source, { sourceType: 'module', plugins: ['typescript', 'jsx'] })\n const result = await metroTransform({ filename, src: options.source, options: { projectRoot }, ast })\n transformedSource = generate(result.ast).code\n evaluateStyleBundle(cacheDir)\n }\n\n const cleanup = (): void => {\n __resetLookupCssState()\n resetRnwindState()\n if (existsSync(projectRoot)) rmSync(projectRoot, { recursive: true, force: true })\n }\n\n return { projectRoot, cacheDir, transformedSource, cleanup }\n}\n\n/**\n * Synthesize a throwaway source file that mentions each className in a\n * JSX `className=\"...\"` attribute so the Metro transformer's scanner\n * picks them up and records their resolved styles into the union\n * `style.js`. Used by `renderHookWithCss` to pre-register atoms the\n * hook under test will look up.\n * @param classNames Class names to include.\n * @returns Source string suitable for `bootstrapRnwindRuntime`.\n */\nfunction sourceFromClassNames(classNames: readonly string[]): string {\n const joined = classNames.join(' ').replaceAll('\"', String.raw`\\\"`)\n return `const V: any = () => null\\nexport default () => <V className=\"${joined}\" />\\n`\n}\n\n// ────────────────────────────────────────────────────────────────────────\n// Public exports — types\n// ────────────────────────────────────────────────────────────────────────\n\n/** Exact signature of `@testing-library/react-native`'s `render`. */\nexport type Render = typeof testingLibraryRender\n\n/** Exact signature of `@testing-library/react-native`'s `renderHook`. */\nexport type RenderHook = typeof testingLibraryRenderHook\n\n/**\n * Exact return type of `@testing-library/react-native`'s `render` — we\n * re-export the upstream type so tests get every query (`getByTestId`,\n * `queryByText`, `rerender`, `unmount`, `debug`, `UNSAFE_root`, …) with\n * its real signature.\n */\nexport type TestingLibraryRenderAPI = ReturnType<typeof testingLibraryRender>\n\n/** Options accepted by {@link renderWithCss}. */\nexport interface RenderWithCssOptions {\n /** Theme CSS fed to rnwind's parser. Defaults to {@link DEFAULT_THEME_CSS}. */\n themeCss?: string\n /**\n * Active scheme the runtime resolver uses. Defaults to `'light'`.\n * Flip to `'dark'` / `'brand'` / ... to exercise scheme-variant atoms.\n */\n scheme?: string\n /**\n * Safe-area insets to inject. When provided, the component tree is\n * rendered under a `<RnwindProvider insets={...}>` so `*-safe` atoms\n * resolve to real numbers instead of the `0` fallback. Partial is\n * accepted — missing sides default to zero.\n */\n insets?: Partial<Insets>\n /**\n * Haptic dispatcher forwarded onto the implicit `<RnwindProvider>`.\n * Tests pass a spy callback to assert which haptic atoms fired.\n */\n onHaptics?: OnHaptics\n /**\n * `react-native` namespace bindings forwarded into the rewritten\n * module. Defaults to importing the test process's `react-native`\n * (typically a mocked stub). Override to inject custom host elements.\n */\n reactNative?: Record<string, unknown>\n}\n\n/**\n * Result of a {@link renderWithCss} call. Every key from\n * `@testing-library/react-native`'s `render` return value is spread onto\n * this object — `getByTestId`, `queryByText`, `rerender`, `unmount`,\n * `debug`, etc. — so tests use the testing-library API directly.\n *\n * Two rnwind-specific handles are added:\n * - `transformedSource` — the exact code the rnwind Metro transformer\n * emitted for your input. Log it to confirm the rewrite.\n * - `cleanup` — tears down the ephemeral rnwind state + chunk cache dir.\n * Call from `afterEach` so successive tests don't share atoms.\n */\nexport type RenderWithCssResult = TestingLibraryRenderAPI & {\n /** The post-transformer source text. Same code Metro would ship. */\n transformedSource: string\n /** Tear down the ephemeral rnwind state + cache dir. */\n cleanup: () => void\n}\n\n/** Options accepted by {@link renderHookWithCss}. */\nexport interface RenderHookWithCssOptions<Props> extends RenderHookOptions<Props> {\n /** Theme CSS fed to rnwind's parser. Defaults to the built-in minimal theme. */\n themeCss?: string\n /**\n * Active scheme the runtime resolver uses. Defaults to `'light'`. When\n * set, the hook is wrapped in `<RnwindProvider scheme={scheme}>` so\n * `useScheme()` / `useCss()` observe the override.\n */\n scheme?: string\n /**\n * Class names to pre-register into the runtime atom registry before\n * the hook runs. rnwind synthesizes a throwaway source file mentioning\n * these classes, feeds it through the real Metro transformer, and\n * evaluates the generated `style.js` bundle — so the hook sees\n * exactly the atoms the production bundle would register.\n */\n classNames?: readonly string[]\n}\n\n/**\n * Result of a {@link renderHookWithCss} call. Mirrors\n * `@testing-library/react-native`'s `renderHook` return type — `result`,\n * `rerender`, `unmount` — and adds a `cleanup` that tears down the\n * ephemeral rnwind state.\n */\nexport type RenderHookWithCssResult<Result, Props> = ReturnType<typeof testingLibraryRenderHook<Result, Props>> & {\n /** Tear down the ephemeral rnwind state + cache dir. */\n cleanup: () => void\n}\n\n// ────────────────────────────────────────────────────────────────────────\n// Public exports — functions\n// ────────────────────────────────────────────────────────────────────────\n\n/**\n * Feed a source string through rnwind's Metro transformer, evaluate\n * the generated `style.js` bundle, evaluate the rewritten module, and\n * render the default-exported component with\n * `@testing-library/react-native`.\n *\n * The rendered RN element's `style` prop is the EXACT array your\n * production bundle would attach — same transformer, same runtime\n * resolver, same atoms. Assert on `flatten(node.props.style)` to verify\n * the resolved values.\n * @example\n * ```tsx\n * const handle = await renderWithCss(\n * `import { View } from 'react-native'\n * export default () => <View className=\"bg-primary p-4\" testID=\"box\" />`,\n * { themeCss: `@import 'tailwindcss'; @theme { --color-primary: #6366f1; }` },\n * )\n * const flat = flatten(handle.getByTestId('box').props.style)\n * expect(flat.backgroundColor).toBe('#6366f1')\n * ```\n * @param source User source (one file) to transform + render.\n * @param options Optional theme override, scheme, and `react-native` bindings.\n * @returns Render queries + diagnostic handles.\n */\nexport async function renderWithCss(source: string, options: RenderWithCssOptions = {}): Promise<RenderWithCssResult> {\n const reactNative = options.reactNative ?? resolveReactNative()\n const {\n projectRoot: _projectRoot,\n transformedSource,\n cleanup,\n } = await bootstrapRnwindRuntime({\n themeCss: options.themeCss,\n source,\n })\n const Component = evaluateRewrittenModule(transformedSource, reactNative)\n const rendered = TESTING_LIBRARY.render(buildRootElement(Component, options.scheme, options.insets, options.onHaptics))\n return Object.assign({}, rendered, { transformedSource, cleanup })\n}\n\n/**\n * Render-side counterpart to {@link renderWithCss} for testing hooks in\n * isolation. Pre-registers atoms for the supplied `classNames`, wraps\n * the hook in an optional `<RnwindProvider>`, and forwards to\n * `@testing-library/react-native`'s `renderHook`.\n * @example\n * ```ts\n * const { result, cleanup } = await renderHookWithCss(\n * () => useCss('bg-primary'),\n * {\n * themeCss: `@import 'tailwindcss'; @theme { --color-primary: #6366f1; }`,\n * classNames: ['bg-primary'],\n * },\n * )\n * expect(flatten(result.current).backgroundColor).toBe('#6366f1')\n * cleanup()\n * ```\n * @param callback Hook body — same shape as `renderHook(callback)`.\n * @param options Theme, scheme, classNames to pre-register, plus\n * everything `renderHook` itself accepts (`initialProps`, `wrapper`).\n * @returns `renderHook`'s return value plus a `cleanup` function.\n */\nexport async function renderHookWithCss<Result, Props = unknown>(\n callback: (props: Props) => Result,\n options: RenderHookWithCssOptions<Props> = {},\n): Promise<RenderHookWithCssResult<Result, Props>> {\n const { cleanup } = await bootstrapRnwindRuntime({\n themeCss: options.themeCss,\n source: options.classNames && options.classNames.length > 0 ? sourceFromClassNames(options.classNames) : undefined,\n })\n const wrapper = composeHookWrapper(options.scheme, options.wrapper as RenderHookWithCssOptions<Props>['wrapper'])\n const { themeCss: _themeCss, scheme: _scheme, classNames: _classNames, ...hookOptions } = options\n const rendered = TESTING_LIBRARY.renderHook<Result, Props>(callback, {\n ...(hookOptions as RenderHookOptions<Props>),\n wrapper,\n })\n return Object.assign({}, rendered, { cleanup })\n}\n\n/**\n * Flatten a React Native style array (or single style object) into one\n * merged record. RN flattens left-to-right (later wins), so the returned\n * record is what the native view manager actually applies.\n * @param styles Style array, single object, or null/undefined.\n * @returns Flat style record.\n */\nexport function flatten(styles: unknown): Record<string, unknown> {\n if (styles == null) return {}\n if (Array.isArray(styles)) return Object.assign({}, ...styles.map((entry) => flatten(entry)))\n if (typeof styles === 'object') return styles as Record<string, unknown>\n return {}\n}\n"],"names":["createRequire","generateImport","existsSync","readFileSync","registerAtoms","lookupCss","useRnwind","useR_","useMountHaptic","triggerHaptic","React","RnwindProvider","mkdtempSync","tmpdir","writeFileSync","configureRnwindState","parse","metroTransform","__resetLookupCssState","resetRnwindState","rmSync"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA;AACA;AACA;AAEA;;;;AAIG;AACH,MAAM,iBAAiB,GAAG,CAAA;;;;;;;CAOzB;AAED;AACA,MAAM,kBAAkB,GAAG,EAAE,MAAM,EAAE,CAAI,MAAS,KAAQ,MAAM,EAAE,aAAa,EAAE,CAAC,EAAE;AAEpF;AACA,MAAM,aAAa,GAAG;AACpB,IAAA,KAAK,EAAE,SAAS;AAChB,IAAA,SAAS,EAAE,MAAY,SAAS;AAChC,IAAA,UAAU,EAAE,MAAY,SAAS;AACjC,IAAA,OAAO,EAAE,MAAY,SAAS;AAC9B,IAAA,MAAM,EAAE,MAAY,SAAS;CAC9B;AAED;;;;;AAKG;AACH,MAAM,UAAU,GACd,CAAC,GAAG,QAAsE,KAC1E,CAAC,GAAG,IAAe,KAAU;AAC3B,IAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;QAC9B,IAAI,OAAO,OAAO,KAAK,UAAU;AAAE,YAAA,OAAO,CAAC,GAAG,IAAI,CAAC;IACrD;AACF,CAAC;AAEH;AACA;AACA;AACA;AACA;AACA,MAAM,YAAY,GAAgBA,yBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,cAAc,CAAC,CAAC;AAEzF,MAAM,QAAQ,GAA2BC,UAAsD,CAAC,OAAO,IAAIA,UAAc;AAEzH;;;;;;AAMG;AACH,MAAM,eAAe,GAGjB,CAAC,MAAK;AACR,IAAA,IAAI;AACF,QAAA,OAAO,YAAY,CAAC,+BAA+B,CAGlD;IAC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