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,98 @@
1
+ 'use strict';
2
+
3
+ var jsxRuntime = require('react/jsx-runtime');
4
+ var React = require('react');
5
+ var reactNative = require('react-native');
6
+ var lookupCss = require('../lookup-css.cjs');
7
+
8
+ const EMPTY_TABLES = {};
9
+ const ZERO_INSETS = { top: 0, right: 0, bottom: 0, left: 0 };
10
+ const DEFAULT_STATE = {
11
+ scheme: 'light',
12
+ tables: EMPTY_TABLES,
13
+ insets: ZERO_INSETS,
14
+ onHaptics: undefined,
15
+ fontScale: 1,
16
+ windowWidth: 0,
17
+ activeBreakpoint: lookupCss.BASE_BREAKPOINT,
18
+ };
19
+ /**
20
+ * Normalise a `Partial<Insets>` into a complete {@link Insets}, returning
21
+ * the shared {@link ZERO_INSETS} reference when nothing is supplied so
22
+ * downstream memoisation stays stable.
23
+ * @param partial Caller-supplied insets (or undefined).
24
+ * @returns Complete insets record.
25
+ */
26
+ function normaliseInsets(partial) {
27
+ if (!partial)
28
+ return ZERO_INSETS;
29
+ const top = partial.top ?? 0;
30
+ const right = partial.right ?? 0;
31
+ const bottom = partial.bottom ?? 0;
32
+ const left = partial.left ?? 0;
33
+ if (top === 0 && right === 0 && bottom === 0 && left === 0)
34
+ return ZERO_INSETS;
35
+ return { top, right, bottom, left };
36
+ }
37
+ /** Single internal context the runtime reads from. */
38
+ const RnwindContext = React.createContext(DEFAULT_STATE);
39
+ /**
40
+ * Read rnwind's full runtime state — scheme, theme tables, insets,
41
+ * fontScale, windowWidth, onHaptics — in one go. Pass the returned
42
+ * value straight to `lookupCss` / `useCss`, or destructure what you
43
+ * need.
44
+ * @returns Active rnwind state under the nearest {@link RnwindProvider}.
45
+ */
46
+ function useRnwind() {
47
+ return React.useContext(RnwindContext);
48
+ }
49
+ /**
50
+ * Internal context hook the babel transformer injects at the top of
51
+ * every rewritten component as `const _t = useR_()`. Same body as the
52
+ * public {@link useRnwind} — exposed under a `use*`-prefixed name so
53
+ * react-refresh's babel plugin (which only tracks call-sites whose
54
+ * identifier matches `^use[A-Z]`) folds it into each component's
55
+ * fast-refresh signature. Without that prefix the signature stayed
56
+ * stable across transformer changes; HMR then preserved fiber state
57
+ * while the rendered hook list shifted, surfacing as "change in the
58
+ * order of Hooks" runtime errors. Trailing underscore keeps it
59
+ * visually distinct from the user-facing `useRnwind`.
60
+ * @returns Active rnwind state.
61
+ */
62
+ function useR_() {
63
+ return React.useContext(RnwindContext);
64
+ }
65
+ /**
66
+ * Provider for rnwind's full runtime state. fontScale + windowWidth
67
+ * come from `useWindowDimensions()` so they react to OS-level
68
+ * orientation / accessibility-text-size changes automatically.
69
+ * @param props Provider props.
70
+ * @param props.scheme Active scheme name.
71
+ * @param props.tables Optional pre-resolved token tables.
72
+ * @param props.insets Optional safe-area insets.
73
+ * @param props.onHaptics Optional haptic dispatcher.
74
+ * @param props.children React subtree.
75
+ * @returns Provider element.
76
+ */
77
+ function RnwindProvider({ scheme, tables, insets, onHaptics, children }) {
78
+ const normalized = normaliseInsets(insets);
79
+ const { fontScale, width } = reactNative.useWindowDimensions();
80
+ const value = React.useMemo(() => {
81
+ lookupCss.loadScheme(scheme);
82
+ return {
83
+ scheme,
84
+ tables: tables ?? EMPTY_TABLES,
85
+ insets: normalized,
86
+ onHaptics,
87
+ fontScale,
88
+ windowWidth: width,
89
+ activeBreakpoint: lookupCss.activeBreakpointFor(width),
90
+ };
91
+ }, [scheme, tables, normalized, onHaptics, fontScale, width]);
92
+ return jsxRuntime.jsx(RnwindContext.Provider, { value: value, children: children });
93
+ }
94
+
95
+ exports.RnwindProvider = RnwindProvider;
96
+ exports.useR_ = useR_;
97
+ exports.useRnwind = useRnwind;
98
+ //# sourceMappingURL=rnwind-provider.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rnwind-provider.cjs","sources":["../../../../../src/runtime/components/rnwind-provider.tsx"],"sourcesContent":["import { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport { useWindowDimensions } from 'react-native'\nimport type { ThemeTables } from '../../core/types'\nimport type { Scheme } from '../types'\nimport type { OnHaptics } from '../../core/parser/haptics'\nimport { activeBreakpointFor, BASE_BREAKPOINT, loadScheme } from '../lookup-css'\n\n/**\n * Per-render safe-area insets snapshot. Bridge from any source\n * (`useSafeAreaInsets()`, expo-router insets, a manually computed\n * value) into the {@link RnwindProvider} — rnwind stays\n * library-agnostic.\n */\nexport type Insets = Readonly<{\n top: number\n right: number\n bottom: number\n left: number\n}>\n\n/**\n * Single value carried by the rnwind context. Every piece of runtime\n * state rnwind needs — scheme, theme tables, insets, font scale,\n * window width, active responsive breakpoint, optional haptic\n * dispatcher — lives on this one bag. Consumers read it via\n * {@link useRnwind} and either destructure or forward straight to\n * `lookupCss` / `useCss`.\n *\n * `activeBreakpoint` is the highest-threshold registered breakpoint\n * whose min-width is `<= windowWidth`, or `'base'` when below the\n * smallest one (mobile-first tier) or when no breakpoints are\n * registered yet (tests, bundles without rnwind-transformed sources).\n * Always a string — never null. Reactive: it updates with\n * `useWindowDimensions().width`, so consumers can branch on it\n * without a separate hook.\n */\nexport type RnwindState = Readonly<{\n scheme: Scheme\n tables: ThemeTables\n insets: Insets\n onHaptics: OnHaptics | undefined\n fontScale: number\n windowWidth: number\n activeBreakpoint: string\n}>\n\n/** Props accepted by {@link RnwindProvider}. */\nexport type RnwindProviderProps = Readonly<{\n scheme: Scheme\n tables?: ThemeTables\n insets?: Partial<Insets>\n onHaptics?: OnHaptics\n children?: ReactNode\n}>\n\nconst EMPTY_TABLES: ThemeTables = {}\nconst ZERO_INSETS: Insets = { top: 0, right: 0, bottom: 0, left: 0 }\nconst DEFAULT_STATE: RnwindState = {\n scheme: 'light' as Scheme,\n tables: EMPTY_TABLES,\n insets: ZERO_INSETS,\n onHaptics: undefined,\n fontScale: 1,\n windowWidth: 0,\n activeBreakpoint: BASE_BREAKPOINT,\n}\n\n/**\n * Normalise a `Partial<Insets>` into a complete {@link Insets}, returning\n * the shared {@link ZERO_INSETS} reference when nothing is supplied so\n * downstream memoisation stays stable.\n * @param partial Caller-supplied insets (or undefined).\n * @returns Complete insets record.\n */\nfunction normaliseInsets(partial: Partial<Insets> | undefined): Insets {\n if (!partial) return ZERO_INSETS\n const top = partial.top ?? 0\n const right = partial.right ?? 0\n const bottom = partial.bottom ?? 0\n const left = partial.left ?? 0\n if (top === 0 && right === 0 && bottom === 0 && left === 0) return ZERO_INSETS\n return { top, right, bottom, left }\n}\n\n/** Single internal context the runtime reads from. */\nconst RnwindContext = createContext<RnwindState>(DEFAULT_STATE)\n\n/**\n * Read rnwind's full runtime state — scheme, theme tables, insets,\n * fontScale, windowWidth, onHaptics — in one go. Pass the returned\n * value straight to `lookupCss` / `useCss`, or destructure what you\n * need.\n * @returns Active rnwind state under the nearest {@link RnwindProvider}.\n */\nexport function useRnwind(): RnwindState {\n return useContext(RnwindContext)\n}\n\n/**\n * Internal context hook the babel transformer injects at the top of\n * every rewritten component as `const _t = useR_()`. Same body as the\n * public {@link useRnwind} — exposed under a `use*`-prefixed name so\n * react-refresh's babel plugin (which only tracks call-sites whose\n * identifier matches `^use[A-Z]`) folds it into each component's\n * fast-refresh signature. Without that prefix the signature stayed\n * stable across transformer changes; HMR then preserved fiber state\n * while the rendered hook list shifted, surfacing as \"change in the\n * order of Hooks\" runtime errors. Trailing underscore keeps it\n * visually distinct from the user-facing `useRnwind`.\n * @returns Active rnwind state.\n */\nexport function useR_(): RnwindState {\n return useContext(RnwindContext)\n}\n\n/**\n * Provider for rnwind's full runtime state. fontScale + windowWidth\n * come from `useWindowDimensions()` so they react to OS-level\n * orientation / accessibility-text-size changes automatically.\n * @param props Provider props.\n * @param props.scheme Active scheme name.\n * @param props.tables Optional pre-resolved token tables.\n * @param props.insets Optional safe-area insets.\n * @param props.onHaptics Optional haptic dispatcher.\n * @param props.children React subtree.\n * @returns Provider element.\n */\nexport function RnwindProvider({ scheme, tables, insets, onHaptics, children }: RnwindProviderProps): ReactNode {\n const normalized = normaliseInsets(insets)\n const { fontScale, width } = useWindowDimensions()\n const value = useMemo<RnwindState>(() => {\n loadScheme(scheme)\n return {\n scheme,\n tables: tables ?? EMPTY_TABLES,\n insets: normalized,\n onHaptics,\n fontScale,\n windowWidth: width,\n activeBreakpoint: activeBreakpointFor(width),\n }\n }, [scheme, tables, normalized, onHaptics, fontScale, width])\n return <RnwindContext.Provider value={value}>{children}</RnwindContext.Provider>\n}\n"],"names":["BASE_BREAKPOINT","createContext","useContext","useWindowDimensions","useMemo","loadScheme","activeBreakpointFor","_jsx"],"mappings":";;;;;;;AAuDA,MAAM,YAAY,GAAgB,EAAE;AACpC,MAAM,WAAW,GAAW,EAAE,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE;AACpE,MAAM,aAAa,GAAgB;AACjC,IAAA,MAAM,EAAE,OAAiB;AACzB,IAAA,MAAM,EAAE,YAAY;AACpB,IAAA,MAAM,EAAE,WAAW;AACnB,IAAA,SAAS,EAAE,SAAS;AACpB,IAAA,SAAS,EAAE,CAAC;AACZ,IAAA,WAAW,EAAE,CAAC;AACd,IAAA,gBAAgB,EAAEA,yBAAe;CAClC;AAED;;;;;;AAMG;AACH,SAAS,eAAe,CAAC,OAAoC,EAAA;AAC3D,IAAA,IAAI,CAAC,OAAO;AAAE,QAAA,OAAO,WAAW;AAChC,IAAA,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC;AAC5B,IAAA,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,CAAC;AAChC,IAAA,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,IAAI,CAAC;AAClC,IAAA,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,IAAI,CAAC;AAC9B,IAAA,IAAI,GAAG,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC;AAAE,QAAA,OAAO,WAAW;IAC9E,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE;AACrC;AAEA;AACA,MAAM,aAAa,GAAGC,mBAAa,CAAc,aAAa,CAAC;AAE/D;;;;;;AAMG;SACa,SAAS,GAAA;AACvB,IAAA,OAAOC,gBAAU,CAAC,aAAa,CAAC;AAClC;AAEA;;;;;;;;;;;;AAYG;SACa,KAAK,GAAA;AACnB,IAAA,OAAOA,gBAAU,CAAC,aAAa,CAAC;AAClC;AAEA;;;;;;;;;;;AAWG;AACG,SAAU,cAAc,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAuB,EAAA;AACjG,IAAA,MAAM,UAAU,GAAG,eAAe,CAAC,MAAM,CAAC;IAC1C,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAGC,+BAAmB,EAAE;AAClD,IAAA,MAAM,KAAK,GAAGC,aAAO,CAAc,MAAK;QACtCC,oBAAU,CAAC,MAAM,CAAC;QAClB,OAAO;YACL,MAAM;YACN,MAAM,EAAE,MAAM,IAAI,YAAY;AAC9B,YAAA,MAAM,EAAE,UAAU;YAClB,SAAS;YACT,SAAS;AACT,YAAA,WAAW,EAAE,KAAK;AAClB,YAAA,gBAAgB,EAAEC,6BAAmB,CAAC,KAAK,CAAC;SAC7C;AACH,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAOC,cAAA,CAAC,aAAa,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAA0B;AAClF;;;;;;"}
@@ -0,0 +1,84 @@
1
+ import { type ReactNode } from 'react';
2
+ import type { ThemeTables } from '../../core/types';
3
+ import type { Scheme } from '../types';
4
+ import type { OnHaptics } from '../../core/parser/haptics';
5
+ /**
6
+ * Per-render safe-area insets snapshot. Bridge from any source
7
+ * (`useSafeAreaInsets()`, expo-router insets, a manually computed
8
+ * value) into the {@link RnwindProvider} — rnwind stays
9
+ * library-agnostic.
10
+ */
11
+ export type Insets = Readonly<{
12
+ top: number;
13
+ right: number;
14
+ bottom: number;
15
+ left: number;
16
+ }>;
17
+ /**
18
+ * Single value carried by the rnwind context. Every piece of runtime
19
+ * state rnwind needs — scheme, theme tables, insets, font scale,
20
+ * window width, active responsive breakpoint, optional haptic
21
+ * dispatcher — lives on this one bag. Consumers read it via
22
+ * {@link useRnwind} and either destructure or forward straight to
23
+ * `lookupCss` / `useCss`.
24
+ *
25
+ * `activeBreakpoint` is the highest-threshold registered breakpoint
26
+ * whose min-width is `<= windowWidth`, or `'base'` when below the
27
+ * smallest one (mobile-first tier) or when no breakpoints are
28
+ * registered yet (tests, bundles without rnwind-transformed sources).
29
+ * Always a string — never null. Reactive: it updates with
30
+ * `useWindowDimensions().width`, so consumers can branch on it
31
+ * without a separate hook.
32
+ */
33
+ export type RnwindState = Readonly<{
34
+ scheme: Scheme;
35
+ tables: ThemeTables;
36
+ insets: Insets;
37
+ onHaptics: OnHaptics | undefined;
38
+ fontScale: number;
39
+ windowWidth: number;
40
+ activeBreakpoint: string;
41
+ }>;
42
+ /** Props accepted by {@link RnwindProvider}. */
43
+ export type RnwindProviderProps = Readonly<{
44
+ scheme: Scheme;
45
+ tables?: ThemeTables;
46
+ insets?: Partial<Insets>;
47
+ onHaptics?: OnHaptics;
48
+ children?: ReactNode;
49
+ }>;
50
+ /**
51
+ * Read rnwind's full runtime state — scheme, theme tables, insets,
52
+ * fontScale, windowWidth, onHaptics — in one go. Pass the returned
53
+ * value straight to `lookupCss` / `useCss`, or destructure what you
54
+ * need.
55
+ * @returns Active rnwind state under the nearest {@link RnwindProvider}.
56
+ */
57
+ export declare function useRnwind(): RnwindState;
58
+ /**
59
+ * Internal context hook the babel transformer injects at the top of
60
+ * every rewritten component as `const _t = useR_()`. Same body as the
61
+ * public {@link useRnwind} — exposed under a `use*`-prefixed name so
62
+ * react-refresh's babel plugin (which only tracks call-sites whose
63
+ * identifier matches `^use[A-Z]`) folds it into each component's
64
+ * fast-refresh signature. Without that prefix the signature stayed
65
+ * stable across transformer changes; HMR then preserved fiber state
66
+ * while the rendered hook list shifted, surfacing as "change in the
67
+ * order of Hooks" runtime errors. Trailing underscore keeps it
68
+ * visually distinct from the user-facing `useRnwind`.
69
+ * @returns Active rnwind state.
70
+ */
71
+ export declare function useR_(): RnwindState;
72
+ /**
73
+ * Provider for rnwind's full runtime state. fontScale + windowWidth
74
+ * come from `useWindowDimensions()` so they react to OS-level
75
+ * orientation / accessibility-text-size changes automatically.
76
+ * @param props Provider props.
77
+ * @param props.scheme Active scheme name.
78
+ * @param props.tables Optional pre-resolved token tables.
79
+ * @param props.insets Optional safe-area insets.
80
+ * @param props.onHaptics Optional haptic dispatcher.
81
+ * @param props.children React subtree.
82
+ * @returns Provider element.
83
+ */
84
+ export declare function RnwindProvider({ scheme, tables, insets, onHaptics, children }: RnwindProviderProps): ReactNode;
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Typed contract for the component rnwind's transformer calls with a
3
+ * gradient-class `className`. Matches `expo-linear-gradient` verbatim
4
+ * so users can plug any gradient library that mirrors that API.
5
+ *
6
+ * A typical wiring:
7
+ *
8
+ * ```tsx
9
+ * import { LinearGradient } from 'expo-linear-gradient'
10
+ * import type { AsLinearGradientProps } from 'rnwind'
11
+ *
12
+ * // Assert at the type level — CI catches mismatches before runtime.
13
+ * const _typeCheck: AsLinearGradientProps = {} as Parameters<typeof LinearGradient>[0]
14
+ *
15
+ * // Then use it in real JSX. rnwind fills in colors / start / end.
16
+ * <LinearGradient className="bg-gradient-to-r from-red-500 to-blue-500" />
17
+ * ```
18
+ *
19
+ * The rnwind transformer emits `colors` as a frozen `readonly string[]`,
20
+ * and `start` / `end` as frozen `{x: number, y: number}` records.
21
+ * Users pass the component; rnwind fills the props. Unused props
22
+ * (`locations`, `dither`, …) are forwarded verbatim from the JSX site.
23
+ */
24
+ /** A unit-square point. Matches the `LinearGradientPoint` object form. */
25
+ export interface LinearGradientPoint {
26
+ /** Horizontal component, 0..1. */
27
+ readonly x: number;
28
+ /** Vertical component, 0..1. */
29
+ readonly y: number;
30
+ }
31
+ /**
32
+ * The exact prop shape rnwind fills onto a gradient component at
33
+ * build time. A user-supplied `<LinearGradient>` (or any other
34
+ * component) must accept these props — no wrapper, no adapter.
35
+ */
36
+ export interface AsLinearGradientProps {
37
+ /**
38
+ * Gradient colour stops in source order. rnwind emits a frozen
39
+ * `readonly string[]` with 2+ entries (at least `from` + `to`).
40
+ * Compatible with expo-linear-gradient's `colors: readonly [ColorValue, ColorValue, ...ColorValue[]]`.
41
+ */
42
+ readonly colors: readonly string[];
43
+ /**
44
+ * Start point, in the unit square (0,0)=top-left → (1,1)=bottom-right.
45
+ * rnwind emits a frozen `{x, y}` record matching the Tailwind
46
+ * direction utility (`to-r` → `{x: 0, y: 0.5}`).
47
+ */
48
+ readonly start: LinearGradientPoint;
49
+ /** End point — same unit-square coordinates as `start`. */
50
+ readonly end: LinearGradientPoint;
51
+ /**
52
+ * Optional colour-stop positions matching `colors` length. rnwind
53
+ * doesn't emit this today (Tailwind v4's stop-position atoms aren't
54
+ * wired yet); listed here so the prop surface still matches
55
+ * expo-linear-gradient when a consumer passes their own.
56
+ */
57
+ readonly locations?: readonly number[] | null;
58
+ }
@@ -0,0 +1,113 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+ var rnwindProvider = require('./components/rnwind-provider.cjs');
5
+
6
+ /**
7
+ * Runtime helpers the transformer injects for haptic utilities.
8
+ *
9
+ * Two entry points:
10
+ *
11
+ * useMountHaptic(requests) — fires each request on mount via
12
+ * `useEffect(() => { ... }, [])`. Used by the transformer for bare
13
+ * `haptic-*` atoms (no variant prefix).
14
+ *
15
+ * triggerHaptic(onHaptics, request, trigger) — thin forwarding
16
+ * helper for event-driven variants (`active:haptic-*`, `focus:...`,
17
+ * `hover:...`). The transformer emits an inline arrow that calls
18
+ * this from `onPressIn` / `onFocus` / etc.
19
+ *
20
+ * Both emit a one-shot dev-mode warning when `onHaptics` is missing —
21
+ * so developers get a clear "you forgot to wire <SchemeProvider
22
+ * onHaptics=...>" signal instead of silently dropping the haptic.
23
+ */
24
+ /**
25
+ * Module-scope set tracking haptic trigger strings we've already
26
+ * warned about. Prevents the "missing onHaptics" warning from
27
+ * spamming the console when the same class appears on many elements.
28
+ */
29
+ const WARNED_MISSING_HAPTICS = new Set();
30
+ /**
31
+ * Render a `HapticRequest` as a short descriptive tag for log lines.
32
+ * @param request Haptic request.
33
+ * @returns `impact/Light`, `notification/Success`, or `selection`.
34
+ */
35
+ function hapticTag(request) {
36
+ if (request.kind === 'impact')
37
+ return `impact/${request.style}`;
38
+ if (request.kind === 'notification')
39
+ return `notification/${request.type}`;
40
+ return 'selection';
41
+ }
42
+ /**
43
+ * Warn once per haptic trigger kind when a `haptic-*` atom tries to
44
+ * dispatch without an `onHaptics` provider. Dev-mode only — `__DEV__`
45
+ * is a Metro / Expo / RN global that compiles to `false` in release
46
+ * bundles, so no warn code ships to production.
47
+ * @param request The haptic request that had no provider.
48
+ * @param trigger The lifecycle trigger that tried to fire.
49
+ */
50
+ function warnMissingOnHaptics(request, trigger) {
51
+ // `__DEV__` is a RN / Metro global — `false` in release, strips the
52
+ // branch entirely. Guarded in case we're evaluated outside of Metro
53
+ // (tests, node scripts) where the global isn't defined.
54
+ const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__;
55
+ if (!isDevelopment)
56
+ return;
57
+ const tag = hapticTag(request);
58
+ const key = `${tag}@${trigger}`;
59
+ if (WARNED_MISSING_HAPTICS.has(key))
60
+ return;
61
+ WARNED_MISSING_HAPTICS.add(key);
62
+ // eslint-disable-next-line no-console
63
+ console.warn(`rnwind: a haptic utility fired (${tag}, trigger=${trigger}) but no onHaptics callback is wired on <SchemeProvider>. ` +
64
+ `Pass \`onHaptics\` on the provider to forward this to expo-haptics (or any library of your choice).`);
65
+ }
66
+ /**
67
+ * Invoke every request in `requests` on mount (once per component
68
+ * mount), using the `onHaptics` dispatcher from the nearest
69
+ * `<SchemeProvider>`. Missing-provider dev warnings fire via
70
+ * {@link warnMissingOnHaptics}.
71
+ *
72
+ * Uses `useEffect(..., [])` — the requests array is identity-stable
73
+ * (hoisted at module scope by the transformer), so re-firing on
74
+ * re-renders isn't a concern.
75
+ * @param requests Hoisted request list for this component.
76
+ */
77
+ function useMountHaptic(requests) {
78
+ const { onHaptics } = rnwindProvider.useRnwind();
79
+ React.useEffect(() => {
80
+ for (const request of requests) {
81
+ if (onHaptics)
82
+ onHaptics(request, 'mount');
83
+ else
84
+ warnMissingOnHaptics(request, 'mount');
85
+ }
86
+ // requests is a hoisted stable reference — depending on onHaptics
87
+ // identity keeps the effect fresh if the provider remounts with a
88
+ // different dispatcher, while the hoisted const prevents a remount
89
+ // from an inline `onHaptics={(r) => ...}`.
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps
91
+ }, [onHaptics]);
92
+ }
93
+ /**
94
+ * Fire one haptic request through the provider dispatcher. Emits the
95
+ * missing-provider dev warning when no dispatcher is wired. Designed
96
+ * for the inline arrows the transformer synthesises:
97
+ *
98
+ * onPressIn={(e) => { triggerHaptic(_h, _HR_xxx, 'pressIn'); user?.(e) }}
99
+ * @param onHaptics Provider dispatcher (may be undefined).
100
+ * @param request Pre-hoisted request object.
101
+ * @param trigger Lifecycle trigger.
102
+ */
103
+ function triggerHaptic(onHaptics, request, trigger) {
104
+ if (onHaptics) {
105
+ onHaptics(request, trigger);
106
+ return;
107
+ }
108
+ warnMissingOnHaptics(request, trigger);
109
+ }
110
+
111
+ exports.triggerHaptic = triggerHaptic;
112
+ exports.useMountHaptic = useMountHaptic;
113
+ //# sourceMappingURL=haptics.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"haptics.cjs","sources":["../../../../src/runtime/haptics.ts"],"sourcesContent":["/**\n * Runtime helpers the transformer injects for haptic utilities.\n *\n * Two entry points:\n *\n * useMountHaptic(requests) — fires each request on mount via\n * `useEffect(() => { ... }, [])`. Used by the transformer for bare\n * `haptic-*` atoms (no variant prefix).\n *\n * triggerHaptic(onHaptics, request, trigger) — thin forwarding\n * helper for event-driven variants (`active:haptic-*`, `focus:...`,\n * `hover:...`). The transformer emits an inline arrow that calls\n * this from `onPressIn` / `onFocus` / etc.\n *\n * Both emit a one-shot dev-mode warning when `onHaptics` is missing —\n * so developers get a clear \"you forgot to wire <SchemeProvider\n * onHaptics=...>\" signal instead of silently dropping the haptic.\n */\n\nimport { useEffect } from 'react'\nimport type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics'\nimport { useRnwind } from './components/rnwind-provider'\n\n/**\n * Module-scope set tracking haptic trigger strings we've already\n * warned about. Prevents the \"missing onHaptics\" warning from\n * spamming the console when the same class appears on many elements.\n */\nconst WARNED_MISSING_HAPTICS = new Set<string>()\n\n/**\n * Render a `HapticRequest` as a short descriptive tag for log lines.\n * @param request Haptic request.\n * @returns `impact/Light`, `notification/Success`, or `selection`.\n */\nfunction hapticTag(request: HapticRequest): string {\n if (request.kind === 'impact') return `impact/${request.style}`\n if (request.kind === 'notification') return `notification/${request.type}`\n return 'selection'\n}\n\n/**\n * Warn once per haptic trigger kind when a `haptic-*` atom tries to\n * dispatch without an `onHaptics` provider. Dev-mode only — `__DEV__`\n * is a Metro / Expo / RN global that compiles to `false` in release\n * bundles, so no warn code ships to production.\n * @param request The haptic request that had no provider.\n * @param trigger The lifecycle trigger that tried to fire.\n */\nfunction warnMissingOnHaptics(request: HapticRequest, trigger: HapticTrigger): void {\n // `__DEV__` is a RN / Metro global — `false` in release, strips the\n // branch entirely. Guarded in case we're evaluated outside of Metro\n // (tests, node scripts) where the global isn't defined.\n const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__\n if (!isDevelopment) return\n const tag = hapticTag(request)\n const key = `${tag}@${trigger}`\n if (WARNED_MISSING_HAPTICS.has(key)) return\n WARNED_MISSING_HAPTICS.add(key)\n // eslint-disable-next-line no-console\n console.warn(\n `rnwind: a haptic utility fired (${tag}, trigger=${trigger}) but no onHaptics callback is wired on <SchemeProvider>. ` +\n `Pass \\`onHaptics\\` on the provider to forward this to expo-haptics (or any library of your choice).`,\n )\n}\n\n/**\n * Test-only hook — clears the warned-haptics set so successive test\n * runs don't silently swallow their own warnings.\n */\nfunction __resetHapticWarnings(): void {\n WARNED_MISSING_HAPTICS.clear()\n}\n\n/**\n * Invoke every request in `requests` on mount (once per component\n * mount), using the `onHaptics` dispatcher from the nearest\n * `<SchemeProvider>`. Missing-provider dev warnings fire via\n * {@link warnMissingOnHaptics}.\n *\n * Uses `useEffect(..., [])` — the requests array is identity-stable\n * (hoisted at module scope by the transformer), so re-firing on\n * re-renders isn't a concern.\n * @param requests Hoisted request list for this component.\n */\nfunction useMountHaptic(requests: readonly HapticRequest[]): void {\n const { onHaptics } = useRnwind()\n \n useEffect(() => {\n for (const request of requests) {\n if (onHaptics) onHaptics(request, 'mount')\n else warnMissingOnHaptics(request, 'mount')\n }\n // requests is a hoisted stable reference — depending on onHaptics\n // identity keeps the effect fresh if the provider remounts with a\n // different dispatcher, while the hoisted const prevents a remount\n // from an inline `onHaptics={(r) => ...}`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [onHaptics])\n}\n\n/**\n * Fire one haptic request through the provider dispatcher. Emits the\n * missing-provider dev warning when no dispatcher is wired. Designed\n * for the inline arrows the transformer synthesises:\n *\n * onPressIn={(e) => { triggerHaptic(_h, _HR_xxx, 'pressIn'); user?.(e) }}\n * @param onHaptics Provider dispatcher (may be undefined).\n * @param request Pre-hoisted request object.\n * @param trigger Lifecycle trigger.\n */\nfunction triggerHaptic(onHaptics: OnHaptics | undefined, request: HapticRequest, trigger: HapticTrigger): void {\n if (onHaptics) {\n onHaptics(request, trigger)\n return\n }\n warnMissingOnHaptics(request, trigger)\n}\n\nexport { useMountHaptic, triggerHaptic, __resetHapticWarnings }\n"],"names":["useRnwind","useEffect"],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;;AAiBG;AAMH;;;;AAIG;AACH,MAAM,sBAAsB,GAAG,IAAI,GAAG,EAAU;AAEhD;;;;AAIG;AACH,SAAS,SAAS,CAAC,OAAsB,EAAA;AACvC,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ;AAAE,QAAA,OAAO,CAAA,OAAA,EAAU,OAAO,CAAC,KAAK,EAAE;AAC/D,IAAA,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc;AAAE,QAAA,OAAO,CAAA,aAAA,EAAgB,OAAO,CAAC,IAAI,EAAE;AAC1E,IAAA,OAAO,WAAW;AACpB;AAEA;;;;;;;AAOG;AACH,SAAS,oBAAoB,CAAC,OAAsB,EAAE,OAAsB,EAAA;;;;IAI1E,MAAM,aAAa,GAAG,OAAO,OAAO,KAAK,WAAW,IAAI,OAAO;AAC/D,IAAA,IAAI,CAAC,aAAa;QAAE;AACpB,IAAA,MAAM,GAAG,GAAG,SAAS,CAAC,OAAO,CAAC;AAC9B,IAAA,MAAM,GAAG,GAAG,CAAA,EAAG,GAAG,CAAA,CAAA,EAAI,OAAO,EAAE;AAC/B,IAAA,IAAI,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC;QAAE;AACrC,IAAA,sBAAsB,CAAC,GAAG,CAAC,GAAG,CAAC;;AAE/B,IAAA,OAAO,CAAC,IAAI,CACV,mCAAmC,GAAG,CAAA,UAAA,EAAa,OAAO,CAAA,0DAAA,CAA4D;AACpH,QAAA,CAAA,mGAAA,CAAqG,CACxG;AACH;AAUA;;;;;;;;;;AAUG;AACH,SAAS,cAAc,CAAC,QAAkC,EAAA;AACxD,IAAA,MAAM,EAAE,SAAS,EAAE,GAAGA,wBAAS,EAAE;IAEjCC,eAAS,CAAC,MAAK;AACb,QAAA,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE;AAC9B,YAAA,IAAI,SAAS;AAAE,gBAAA,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;;AACrC,gBAAA,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC;QAC7C;;;;;;AAMF,IAAA,CAAC,EAAE,CAAC,SAAS,CAAC,CAAC;AACjB;AAEA;;;;;;;;;AASG;AACH,SAAS,aAAa,CAAC,SAAgC,EAAE,OAAsB,EAAE,OAAsB,EAAA;IACrG,IAAI,SAAS,EAAE;AACb,QAAA,SAAS,CAAC,OAAO,EAAE,OAAO,CAAC;QAC3B;IACF;AACA,IAAA,oBAAoB,CAAC,OAAO,EAAE,OAAO,CAAC;AACxC;;;;;"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Runtime helpers the transformer injects for haptic utilities.
3
+ *
4
+ * Two entry points:
5
+ *
6
+ * useMountHaptic(requests) — fires each request on mount via
7
+ * `useEffect(() => { ... }, [])`. Used by the transformer for bare
8
+ * `haptic-*` atoms (no variant prefix).
9
+ *
10
+ * triggerHaptic(onHaptics, request, trigger) — thin forwarding
11
+ * helper for event-driven variants (`active:haptic-*`, `focus:...`,
12
+ * `hover:...`). The transformer emits an inline arrow that calls
13
+ * this from `onPressIn` / `onFocus` / etc.
14
+ *
15
+ * Both emit a one-shot dev-mode warning when `onHaptics` is missing —
16
+ * so developers get a clear "you forgot to wire <SchemeProvider
17
+ * onHaptics=...>" signal instead of silently dropping the haptic.
18
+ */
19
+ import type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics';
20
+ /**
21
+ * Test-only hook — clears the warned-haptics set so successive test
22
+ * runs don't silently swallow their own warnings.
23
+ */
24
+ declare function __resetHapticWarnings(): void;
25
+ /**
26
+ * Invoke every request in `requests` on mount (once per component
27
+ * mount), using the `onHaptics` dispatcher from the nearest
28
+ * `<SchemeProvider>`. Missing-provider dev warnings fire via
29
+ * {@link warnMissingOnHaptics}.
30
+ *
31
+ * Uses `useEffect(..., [])` — the requests array is identity-stable
32
+ * (hoisted at module scope by the transformer), so re-firing on
33
+ * re-renders isn't a concern.
34
+ * @param requests Hoisted request list for this component.
35
+ */
36
+ declare function useMountHaptic(requests: readonly HapticRequest[]): void;
37
+ /**
38
+ * Fire one haptic request through the provider dispatcher. Emits the
39
+ * missing-provider dev warning when no dispatcher is wired. Designed
40
+ * for the inline arrows the transformer synthesises:
41
+ *
42
+ * onPressIn={(e) => { triggerHaptic(_h, _HR_xxx, 'pressIn'); user?.(e) }}
43
+ * @param onHaptics Provider dispatcher (may be undefined).
44
+ * @param request Pre-hoisted request object.
45
+ * @param trigger Lifecycle trigger.
46
+ */
47
+ declare function triggerHaptic(onHaptics: OnHaptics | undefined, request: HapticRequest, trigger: HapticTrigger): void;
48
+ export { useMountHaptic, triggerHaptic, __resetHapticWarnings };
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ var rnwindProvider = require('../components/rnwind-provider.cjs');
4
+ var lookupCss = require('../lookup-css.cjs');
5
+
6
+ /**
7
+ * Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use
8
+ * inside any component that wants the resolved style array without
9
+ * threading the rnwind context manually. JSX-heavy components should
10
+ * still call `useRnwind()` once and pass it to `lookupCss(...)` per
11
+ * element so React only does a single context read per render.
12
+ * @param className Raw className string or transformer-hoisted atom-name array.
13
+ * @param userStyle Optional caller-supplied style appended last.
14
+ * @returns Frozen style array for React Native's `style` prop.
15
+ */
16
+ function useCss(className, userStyle) {
17
+ return lookupCss.lookupCss(className, rnwindProvider.useRnwind(), userStyle);
18
+ }
19
+
20
+ exports.useCss = useCss;
21
+ //# sourceMappingURL=use-css.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-css.cjs","sources":["../../../../../src/runtime/hooks/use-css.ts"],"sourcesContent":["import { useRnwind } from '../components/rnwind-provider'\nimport { lookupCss } from '../lookup-css'\n\n/**\n * Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use\n * inside any component that wants the resolved style array without\n * threading the rnwind context manually. JSX-heavy components should\n * still call `useRnwind()` once and pass it to `lookupCss(...)` per\n * element so React only does a single context read per render.\n * @param className Raw className string or transformer-hoisted atom-name array.\n * @param userStyle Optional caller-supplied style appended last.\n * @returns Frozen style array for React Native's `style` prop.\n */\nexport function useCss(className?: string | readonly string[] | null, userStyle?: unknown): readonly unknown[] {\n return lookupCss(className, useRnwind(), userStyle)\n}\n"],"names":["lookupCss","useRnwind"],"mappings":";;;;;AAGA;;;;;;;;;AASG;AACG,SAAU,MAAM,CAAC,SAA6C,EAAE,SAAmB,EAAA;IACvF,OAAOA,mBAAS,CAAC,SAAS,EAAEC,wBAAS,EAAE,EAAE,SAAS,CAAC;AACrD;;;;"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use
3
+ * inside any component that wants the resolved style array without
4
+ * threading the rnwind context manually. JSX-heavy components should
5
+ * still call `useRnwind()` once and pass it to `lookupCss(...)` per
6
+ * element so React only does a single context read per render.
7
+ * @param className Raw className string or transformer-hoisted atom-name array.
8
+ * @param userStyle Optional caller-supplied style appended last.
9
+ * @returns Frozen style array for React Native's `style` prop.
10
+ */
11
+ export declare function useCss(className?: string | readonly string[] | null, userStyle?: unknown): readonly unknown[];
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ var React = require('react');
4
+
5
+ /**
6
+ * Idle state reference reused across every non-interactive render —
7
+ * when neither `active` nor `focus` is true, every call site returns
8
+ * the exact same object. That's the ~99 % path for a typical list row,
9
+ * so sharing the ref is a legitimate allocation elimination.
10
+ */
11
+ const IDLE_STATE = { active: false, focus: false };
12
+ /**
13
+ * React hook driving `active:` / `focus:` variants at runtime. The
14
+ * transformer injects exactly one call per JSX element that uses an
15
+ * interactive classname, caching the hook's result into a component-
16
+ * local `_i` binding so every `lookupCss(…, _i.state)` site shares the
17
+ * same snapshot per render.
18
+ *
19
+ * React Native's `Pressable` fires `onPressIn` / `onPressOut` on touch
20
+ * down / release — the touch-device analogue of CSS `:active`. Text
21
+ * fields use `onFocus` / `onBlur`. Both pairs drive `useState` Booleans;
22
+ * unused handlers on elements that don't emit the corresponding event
23
+ * are harmless no-ops.
24
+ *
25
+ * Result stability: both `state` and the returned wrapper object stay
26
+ * reference-equal across renders unless `active` / `focus` actually
27
+ * flip. Downstream `React.memo` + `lookupCss` caches hit on equal refs.
28
+ * @returns Stable state + handler bundle.
29
+ */
30
+ function useInteract() {
31
+ const [active, setActive] = React.useState(false);
32
+ const [focus, setFocus] = React.useState(false);
33
+ const onPressIn = React.useCallback(() => setActive(true), []);
34
+ const onPressOut = React.useCallback(() => setActive(false), []);
35
+ const onFocus = React.useCallback(() => setFocus(true), []);
36
+ const onBlur = React.useCallback(() => setFocus(false), []);
37
+ const state = React.useMemo(() => {
38
+ if (!active && !focus)
39
+ return IDLE_STATE;
40
+ return { active, focus };
41
+ }, [active, focus]);
42
+ return React.useMemo(() => ({ state, onPressIn, onPressOut, onFocus, onBlur }), [state, onPressIn, onPressOut, onFocus, onBlur]);
43
+ }
44
+
45
+ exports.useInteract = useInteract;
46
+ //# sourceMappingURL=use-interact.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-interact.cjs","sources":["../../../../../src/runtime/hooks/use-interact.ts"],"sourcesContent":["import { useCallback, useMemo, useState } from 'react'\nimport type { GestureResponderEvent, NativeSyntheticEvent, TargetedEvent } from 'react-native'\nimport type { InteractState } from '../lookup-css'\n\n/**\n * Idle state reference reused across every non-interactive render —\n * when neither `active` nor `focus` is true, every call site returns\n * the exact same object. That's the ~99 % path for a typical list row,\n * so sharing the ref is a legitimate allocation elimination.\n */\nconst IDLE_STATE: InteractState = { active: false, focus: false }\n\n/**\n * Live interact-state snapshot plus the press/focus handlers the\n * transformer wires onto the JSX opening element. The state object is\n * referentially stable across renders when the underlying `active` /\n * `focus` flags don't change, which keeps `lookupCss` cache hits\n * aligned with React's render cadence (same state ref → same\n * resolved-array cache key → same reference back, no React diff\n * triggered).\n */\nexport interface UseInteractResult {\n /** Current interact flags — forwarded as the 4th arg to `lookupCss`. */\n state: InteractState\n /** Wired by the transformer onto `<Pressable onPressIn={…}>` etc. */\n onPressIn: (event: GestureResponderEvent) => void\n /** Wired by the transformer onto `<Pressable onPressOut={…}>` etc. */\n onPressOut: (event: GestureResponderEvent) => void\n /** Wired by the transformer onto `<TextInput onFocus={…}>` etc. */\n onFocus: (event: NativeSyntheticEvent<TargetedEvent>) => void\n /** Wired by the transformer onto `<TextInput onBlur={…}>` etc. */\n onBlur: (event: NativeSyntheticEvent<TargetedEvent>) => void\n}\n\n/**\n * React hook driving `active:` / `focus:` variants at runtime. The\n * transformer injects exactly one call per JSX element that uses an\n * interactive classname, caching the hook's result into a component-\n * local `_i` binding so every `lookupCss(…, _i.state)` site shares the\n * same snapshot per render.\n *\n * React Native's `Pressable` fires `onPressIn` / `onPressOut` on touch\n * down / release — the touch-device analogue of CSS `:active`. Text\n * fields use `onFocus` / `onBlur`. Both pairs drive `useState` Booleans;\n * unused handlers on elements that don't emit the corresponding event\n * are harmless no-ops.\n *\n * Result stability: both `state` and the returned wrapper object stay\n * reference-equal across renders unless `active` / `focus` actually\n * flip. Downstream `React.memo` + `lookupCss` caches hit on equal refs.\n * @returns Stable state + handler bundle.\n */\nexport function useInteract(): UseInteractResult {\n const [active, setActive] = useState(false)\n const [focus, setFocus] = useState(false)\n const onPressIn = useCallback(() => setActive(true), [])\n const onPressOut = useCallback(() => setActive(false), [])\n const onFocus = useCallback(() => setFocus(true), [])\n const onBlur = useCallback(() => setFocus(false), [])\n const state = useMemo<InteractState>(() => {\n if (!active && !focus) return IDLE_STATE\n return { active, focus }\n }, [active, focus])\n return useMemo(() => ({ state, onPressIn, onPressOut, onFocus, onBlur }), [state, onPressIn, onPressOut, onFocus, onBlur])\n}\n"],"names":["useState","useCallback","useMemo"],"mappings":";;;;AAIA;;;;;AAKG;AACH,MAAM,UAAU,GAAkB,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE;AAwBjE;;;;;;;;;;;;;;;;;AAiBG;SACa,WAAW,GAAA;IACzB,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAGA,cAAQ,CAAC,KAAK,CAAC;AACzC,IAAA,MAAM,SAAS,GAAGC,iBAAW,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AACxD,IAAA,MAAM,UAAU,GAAGA,iBAAW,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;AAC1D,IAAA,MAAM,OAAO,GAAGA,iBAAW,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AACrD,IAAA,MAAM,MAAM,GAAGA,iBAAW,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;AACrD,IAAA,MAAM,KAAK,GAAGC,aAAO,CAAgB,MAAK;AACxC,QAAA,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK;AAAE,YAAA,OAAO,UAAU;AACxC,QAAA,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE;AAC1B,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;AACnB,IAAA,OAAOA,aAAO,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;AAC5H;;;;"}
@@ -0,0 +1,42 @@
1
+ import type { GestureResponderEvent, NativeSyntheticEvent, TargetedEvent } from 'react-native';
2
+ import type { InteractState } from '../lookup-css';
3
+ /**
4
+ * Live interact-state snapshot plus the press/focus handlers the
5
+ * transformer wires onto the JSX opening element. The state object is
6
+ * referentially stable across renders when the underlying `active` /
7
+ * `focus` flags don't change, which keeps `lookupCss` cache hits
8
+ * aligned with React's render cadence (same state ref → same
9
+ * resolved-array cache key → same reference back, no React diff
10
+ * triggered).
11
+ */
12
+ export interface UseInteractResult {
13
+ /** Current interact flags — forwarded as the 4th arg to `lookupCss`. */
14
+ state: InteractState;
15
+ /** Wired by the transformer onto `<Pressable onPressIn={…}>` etc. */
16
+ onPressIn: (event: GestureResponderEvent) => void;
17
+ /** Wired by the transformer onto `<Pressable onPressOut={…}>` etc. */
18
+ onPressOut: (event: GestureResponderEvent) => void;
19
+ /** Wired by the transformer onto `<TextInput onFocus={…}>` etc. */
20
+ onFocus: (event: NativeSyntheticEvent<TargetedEvent>) => void;
21
+ /** Wired by the transformer onto `<TextInput onBlur={…}>` etc. */
22
+ onBlur: (event: NativeSyntheticEvent<TargetedEvent>) => void;
23
+ }
24
+ /**
25
+ * React hook driving `active:` / `focus:` variants at runtime. The
26
+ * transformer injects exactly one call per JSX element that uses an
27
+ * interactive classname, caching the hook's result into a component-
28
+ * local `_i` binding so every `lookupCss(…, _i.state)` site shares the
29
+ * same snapshot per render.
30
+ *
31
+ * React Native's `Pressable` fires `onPressIn` / `onPressOut` on touch
32
+ * down / release — the touch-device analogue of CSS `:active`. Text
33
+ * fields use `onFocus` / `onBlur`. Both pairs drive `useState` Booleans;
34
+ * unused handlers on elements that don't emit the corresponding event
35
+ * are harmless no-ops.
36
+ *
37
+ * Result stability: both `state` and the returned wrapper object stay
38
+ * reference-equal across renders unless `active` / `focus` actually
39
+ * flip. Downstream `React.memo` + `lookupCss` caches hit on equal refs.
40
+ * @returns Stable state + handler bundle.
41
+ */
42
+ export declare function useInteract(): UseInteractResult;
@@ -0,0 +1,68 @@
1
+ 'use strict';
2
+
3
+ var rnwindProvider = require('../components/rnwind-provider.cjs');
4
+
5
+ /**
6
+ * Synthetic scheme name applied when tokens aren't declared under any
7
+ * `@variant` block — the "no active variant" fallback every theme table
8
+ * inherits from.
9
+ */
10
+ const BASE_SCHEME = 'base';
11
+ /**
12
+ * Access the resolved theme table for the active scheme.
13
+ *
14
+ * Tokens declared outside any `@variant` block live in the `base` table and
15
+ * should apply everywhere — just like the CSS cascade treats `:root` as a
16
+ * default for every ancestor-scoped override. We merge `base` under the
17
+ * active scheme so a scheme that doesn't declare a token still sees the
18
+ * base default, while the scheme's own entries win on overlap.
19
+ * @returns Token table for the active scheme.
20
+ */
21
+ function useTheme() {
22
+ const { scheme, tables } = rnwindProvider.useRnwind();
23
+ const base = tables[BASE_SCHEME] ?? {};
24
+ const schemeTable = tables[scheme];
25
+ if (!schemeTable)
26
+ return base;
27
+ // Fast path: nothing to merge when the scheme table is empty.
28
+ if (Object.keys(schemeTable).length === 0)
29
+ return base;
30
+ return { ...base, ...schemeTable };
31
+ }
32
+ /**
33
+ * Read a raw CSS custom property's value for the active scheme. Accepts
34
+ * either `--foo` or the bare `foo` form for convenience.
35
+ * @param cssVariable CSS custom property name (with or without the leading `--`).
36
+ * @returns The resolved value, or undefined when the token is missing.
37
+ */
38
+ function useToken(cssVariable) {
39
+ const table = useTheme();
40
+ const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`;
41
+ return table[name];
42
+ }
43
+ /**
44
+ * Read a color token by shorthand name — `useColor('primary')` resolves
45
+ * `--color-primary` for the active scheme.
46
+ * @param name Token suffix after `--color-`.
47
+ * @returns Resolved color string, or undefined when the token is missing
48
+ * or its value isn't a string.
49
+ */
50
+ function useColor(name) {
51
+ const value = useToken(`--color-${name}`);
52
+ return typeof value === 'string' ? value : undefined;
53
+ }
54
+ /**
55
+ * Read a spacing token by shorthand name — `useSize('4')` resolves
56
+ * `--spacing-4` for the active scheme.
57
+ * @param name Token suffix after `--spacing-`.
58
+ * @returns Resolved spacing value, or undefined when the token is missing.
59
+ */
60
+ function useSize(name) {
61
+ return useToken(`--spacing-${name}`);
62
+ }
63
+
64
+ exports.useColor = useColor;
65
+ exports.useSize = useSize;
66
+ exports.useTheme = useTheme;
67
+ exports.useToken = useToken;
68
+ //# sourceMappingURL=use-scheme.cjs.map