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,94 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { createContext, useMemo, useContext } from 'react';
3
+ import { useWindowDimensions } from 'react-native';
4
+ import { BASE_BREAKPOINT, loadScheme, activeBreakpointFor } from '../lookup-css.mjs';
5
+
6
+ const EMPTY_TABLES = {};
7
+ const ZERO_INSETS = { top: 0, right: 0, bottom: 0, left: 0 };
8
+ const DEFAULT_STATE = {
9
+ scheme: 'light',
10
+ tables: EMPTY_TABLES,
11
+ insets: ZERO_INSETS,
12
+ onHaptics: undefined,
13
+ fontScale: 1,
14
+ windowWidth: 0,
15
+ activeBreakpoint: BASE_BREAKPOINT,
16
+ };
17
+ /**
18
+ * Normalise a `Partial<Insets>` into a complete {@link Insets}, returning
19
+ * the shared {@link ZERO_INSETS} reference when nothing is supplied so
20
+ * downstream memoisation stays stable.
21
+ * @param partial Caller-supplied insets (or undefined).
22
+ * @returns Complete insets record.
23
+ */
24
+ function normaliseInsets(partial) {
25
+ if (!partial)
26
+ return ZERO_INSETS;
27
+ const top = partial.top ?? 0;
28
+ const right = partial.right ?? 0;
29
+ const bottom = partial.bottom ?? 0;
30
+ const left = partial.left ?? 0;
31
+ if (top === 0 && right === 0 && bottom === 0 && left === 0)
32
+ return ZERO_INSETS;
33
+ return { top, right, bottom, left };
34
+ }
35
+ /** Single internal context the runtime reads from. */
36
+ const RnwindContext = createContext(DEFAULT_STATE);
37
+ /**
38
+ * Read rnwind's full runtime state — scheme, theme tables, insets,
39
+ * fontScale, windowWidth, onHaptics — in one go. Pass the returned
40
+ * value straight to `lookupCss` / `useCss`, or destructure what you
41
+ * need.
42
+ * @returns Active rnwind state under the nearest {@link RnwindProvider}.
43
+ */
44
+ function useRnwind() {
45
+ return useContext(RnwindContext);
46
+ }
47
+ /**
48
+ * Internal context hook the babel transformer injects at the top of
49
+ * every rewritten component as `const _t = useR_()`. Same body as the
50
+ * public {@link useRnwind} — exposed under a `use*`-prefixed name so
51
+ * react-refresh's babel plugin (which only tracks call-sites whose
52
+ * identifier matches `^use[A-Z]`) folds it into each component's
53
+ * fast-refresh signature. Without that prefix the signature stayed
54
+ * stable across transformer changes; HMR then preserved fiber state
55
+ * while the rendered hook list shifted, surfacing as "change in the
56
+ * order of Hooks" runtime errors. Trailing underscore keeps it
57
+ * visually distinct from the user-facing `useRnwind`.
58
+ * @returns Active rnwind state.
59
+ */
60
+ function useR_() {
61
+ return useContext(RnwindContext);
62
+ }
63
+ /**
64
+ * Provider for rnwind's full runtime state. fontScale + windowWidth
65
+ * come from `useWindowDimensions()` so they react to OS-level
66
+ * orientation / accessibility-text-size changes automatically.
67
+ * @param props Provider props.
68
+ * @param props.scheme Active scheme name.
69
+ * @param props.tables Optional pre-resolved token tables.
70
+ * @param props.insets Optional safe-area insets.
71
+ * @param props.onHaptics Optional haptic dispatcher.
72
+ * @param props.children React subtree.
73
+ * @returns Provider element.
74
+ */
75
+ function RnwindProvider({ scheme, tables, insets, onHaptics, children }) {
76
+ const normalized = normaliseInsets(insets);
77
+ const { fontScale, width } = useWindowDimensions();
78
+ const value = useMemo(() => {
79
+ loadScheme(scheme);
80
+ return {
81
+ scheme,
82
+ tables: tables ?? EMPTY_TABLES,
83
+ insets: normalized,
84
+ onHaptics,
85
+ fontScale,
86
+ windowWidth: width,
87
+ activeBreakpoint: activeBreakpointFor(width),
88
+ };
89
+ }, [scheme, tables, normalized, onHaptics, fontScale, width]);
90
+ return jsx(RnwindContext.Provider, { value: value, children: children });
91
+ }
92
+
93
+ export { RnwindProvider, useR_, useRnwind };
94
+ //# sourceMappingURL=rnwind-provider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rnwind-provider.mjs","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":["_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,EAAE,eAAe;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,GAAG,aAAa,CAAc,aAAa,CAAC;AAE/D;;;;;;AAMG;SACa,SAAS,GAAA;AACvB,IAAA,OAAO,UAAU,CAAC,aAAa,CAAC;AAClC;AAEA;;;;;;;;;;;;AAYG;SACa,KAAK,GAAA;AACnB,IAAA,OAAO,UAAU,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,GAAG,mBAAmB,EAAE;AAClD,IAAA,MAAM,KAAK,GAAG,OAAO,CAAc,MAAK;QACtC,UAAU,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,EAAE,mBAAmB,CAAC,KAAK,CAAC;SAC7C;AACH,IAAA,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;IAC7D,OAAOA,GAAA,CAAC,aAAa,CAAC,QAAQ,EAAA,EAAC,KAAK,EAAE,KAAK,EAAA,QAAA,EAAG,QAAQ,EAAA,CAA0B;AAClF;;;;"}
@@ -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,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,110 @@
1
+ import { useEffect } from 'react';
2
+ import { useRnwind } from './components/rnwind-provider.mjs';
3
+
4
+ /**
5
+ * Runtime helpers the transformer injects for haptic utilities.
6
+ *
7
+ * Two entry points:
8
+ *
9
+ * useMountHaptic(requests) — fires each request on mount via
10
+ * `useEffect(() => { ... }, [])`. Used by the transformer for bare
11
+ * `haptic-*` atoms (no variant prefix).
12
+ *
13
+ * triggerHaptic(onHaptics, request, trigger) — thin forwarding
14
+ * helper for event-driven variants (`active:haptic-*`, `focus:...`,
15
+ * `hover:...`). The transformer emits an inline arrow that calls
16
+ * this from `onPressIn` / `onFocus` / etc.
17
+ *
18
+ * Both emit a one-shot dev-mode warning when `onHaptics` is missing —
19
+ * so developers get a clear "you forgot to wire <SchemeProvider
20
+ * onHaptics=...>" signal instead of silently dropping the haptic.
21
+ */
22
+ /**
23
+ * Module-scope set tracking haptic trigger strings we've already
24
+ * warned about. Prevents the "missing onHaptics" warning from
25
+ * spamming the console when the same class appears on many elements.
26
+ */
27
+ const WARNED_MISSING_HAPTICS = new Set();
28
+ /**
29
+ * Render a `HapticRequest` as a short descriptive tag for log lines.
30
+ * @param request Haptic request.
31
+ * @returns `impact/Light`, `notification/Success`, or `selection`.
32
+ */
33
+ function hapticTag(request) {
34
+ if (request.kind === 'impact')
35
+ return `impact/${request.style}`;
36
+ if (request.kind === 'notification')
37
+ return `notification/${request.type}`;
38
+ return 'selection';
39
+ }
40
+ /**
41
+ * Warn once per haptic trigger kind when a `haptic-*` atom tries to
42
+ * dispatch without an `onHaptics` provider. Dev-mode only — `__DEV__`
43
+ * is a Metro / Expo / RN global that compiles to `false` in release
44
+ * bundles, so no warn code ships to production.
45
+ * @param request The haptic request that had no provider.
46
+ * @param trigger The lifecycle trigger that tried to fire.
47
+ */
48
+ function warnMissingOnHaptics(request, trigger) {
49
+ // `__DEV__` is a RN / Metro global — `false` in release, strips the
50
+ // branch entirely. Guarded in case we're evaluated outside of Metro
51
+ // (tests, node scripts) where the global isn't defined.
52
+ const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__;
53
+ if (!isDevelopment)
54
+ return;
55
+ const tag = hapticTag(request);
56
+ const key = `${tag}@${trigger}`;
57
+ if (WARNED_MISSING_HAPTICS.has(key))
58
+ return;
59
+ WARNED_MISSING_HAPTICS.add(key);
60
+ // eslint-disable-next-line no-console
61
+ console.warn(`rnwind: a haptic utility fired (${tag}, trigger=${trigger}) but no onHaptics callback is wired on <SchemeProvider>. ` +
62
+ `Pass \`onHaptics\` on the provider to forward this to expo-haptics (or any library of your choice).`);
63
+ }
64
+ /**
65
+ * Invoke every request in `requests` on mount (once per component
66
+ * mount), using the `onHaptics` dispatcher from the nearest
67
+ * `<SchemeProvider>`. Missing-provider dev warnings fire via
68
+ * {@link warnMissingOnHaptics}.
69
+ *
70
+ * Uses `useEffect(..., [])` — the requests array is identity-stable
71
+ * (hoisted at module scope by the transformer), so re-firing on
72
+ * re-renders isn't a concern.
73
+ * @param requests Hoisted request list for this component.
74
+ */
75
+ function useMountHaptic(requests) {
76
+ const { onHaptics } = useRnwind();
77
+ useEffect(() => {
78
+ for (const request of requests) {
79
+ if (onHaptics)
80
+ onHaptics(request, 'mount');
81
+ else
82
+ warnMissingOnHaptics(request, 'mount');
83
+ }
84
+ // requests is a hoisted stable reference — depending on onHaptics
85
+ // identity keeps the effect fresh if the provider remounts with a
86
+ // different dispatcher, while the hoisted const prevents a remount
87
+ // from an inline `onHaptics={(r) => ...}`.
88
+ // eslint-disable-next-line react-hooks/exhaustive-deps
89
+ }, [onHaptics]);
90
+ }
91
+ /**
92
+ * Fire one haptic request through the provider dispatcher. Emits the
93
+ * missing-provider dev warning when no dispatcher is wired. Designed
94
+ * for the inline arrows the transformer synthesises:
95
+ *
96
+ * onPressIn={(e) => { triggerHaptic(_h, _HR_xxx, 'pressIn'); user?.(e) }}
97
+ * @param onHaptics Provider dispatcher (may be undefined).
98
+ * @param request Pre-hoisted request object.
99
+ * @param trigger Lifecycle trigger.
100
+ */
101
+ function triggerHaptic(onHaptics, request, trigger) {
102
+ if (onHaptics) {
103
+ onHaptics(request, trigger);
104
+ return;
105
+ }
106
+ warnMissingOnHaptics(request, trigger);
107
+ }
108
+
109
+ export { triggerHaptic, useMountHaptic };
110
+ //# sourceMappingURL=haptics.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"haptics.mjs","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":[],"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,GAAG,SAAS,EAAE;IAEjC,SAAS,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,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,19 @@
1
+ import { useRnwind } from '../components/rnwind-provider.mjs';
2
+ import { lookupCss } from '../lookup-css.mjs';
3
+
4
+ /**
5
+ * Convenience hook: `useRnwind()` + `lookupCss()` rolled into one. Use
6
+ * inside any component that wants the resolved style array without
7
+ * threading the rnwind context manually. JSX-heavy components should
8
+ * still call `useRnwind()` once and pass it to `lookupCss(...)` per
9
+ * element so React only does a single context read per render.
10
+ * @param className Raw className string or transformer-hoisted atom-name array.
11
+ * @param userStyle Optional caller-supplied style appended last.
12
+ * @returns Frozen style array for React Native's `style` prop.
13
+ */
14
+ function useCss(className, userStyle) {
15
+ return lookupCss(className, useRnwind(), userStyle);
16
+ }
17
+
18
+ export { useCss };
19
+ //# sourceMappingURL=use-css.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-css.mjs","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":[],"mappings":";;;AAGA;;;;;;;;;AASG;AACG,SAAU,MAAM,CAAC,SAA6C,EAAE,SAAmB,EAAA;IACvF,OAAO,SAAS,CAAC,SAAS,EAAE,SAAS,EAAE,EAAE,SAAS,CAAC;AACrD;;;;"}
@@ -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,44 @@
1
+ import { useState, useCallback, useMemo } from 'react';
2
+
3
+ /**
4
+ * Idle state reference reused across every non-interactive render —
5
+ * when neither `active` nor `focus` is true, every call site returns
6
+ * the exact same object. That's the ~99 % path for a typical list row,
7
+ * so sharing the ref is a legitimate allocation elimination.
8
+ */
9
+ const IDLE_STATE = { active: false, focus: false };
10
+ /**
11
+ * React hook driving `active:` / `focus:` variants at runtime. The
12
+ * transformer injects exactly one call per JSX element that uses an
13
+ * interactive classname, caching the hook's result into a component-
14
+ * local `_i` binding so every `lookupCss(…, _i.state)` site shares the
15
+ * same snapshot per render.
16
+ *
17
+ * React Native's `Pressable` fires `onPressIn` / `onPressOut` on touch
18
+ * down / release — the touch-device analogue of CSS `:active`. Text
19
+ * fields use `onFocus` / `onBlur`. Both pairs drive `useState` Booleans;
20
+ * unused handlers on elements that don't emit the corresponding event
21
+ * are harmless no-ops.
22
+ *
23
+ * Result stability: both `state` and the returned wrapper object stay
24
+ * reference-equal across renders unless `active` / `focus` actually
25
+ * flip. Downstream `React.memo` + `lookupCss` caches hit on equal refs.
26
+ * @returns Stable state + handler bundle.
27
+ */
28
+ function useInteract() {
29
+ const [active, setActive] = useState(false);
30
+ const [focus, setFocus] = useState(false);
31
+ const onPressIn = useCallback(() => setActive(true), []);
32
+ const onPressOut = useCallback(() => setActive(false), []);
33
+ const onFocus = useCallback(() => setFocus(true), []);
34
+ const onBlur = useCallback(() => setFocus(false), []);
35
+ const state = useMemo(() => {
36
+ if (!active && !focus)
37
+ return IDLE_STATE;
38
+ return { active, focus };
39
+ }, [active, focus]);
40
+ return useMemo(() => ({ state, onPressIn, onPressOut, onFocus, onBlur }), [state, onPressIn, onPressOut, onFocus, onBlur]);
41
+ }
42
+
43
+ export { useInteract };
44
+ //# sourceMappingURL=use-interact.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-interact.mjs","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":[],"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,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC3C,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC;AACzC,IAAA,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,SAAS,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AACxD,IAAA,MAAM,UAAU,GAAG,WAAW,CAAC,MAAM,SAAS,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;AAC1D,IAAA,MAAM,OAAO,GAAG,WAAW,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;AACrD,IAAA,MAAM,MAAM,GAAG,WAAW,CAAC,MAAM,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC;AACrD,IAAA,MAAM,KAAK,GAAG,OAAO,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,OAAO,OAAO,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,34 @@
1
+ import type { ThemeTable } from '../../core/types';
2
+ /**
3
+ * Access the resolved theme table for the active scheme.
4
+ *
5
+ * Tokens declared outside any `@variant` block live in the `base` table and
6
+ * should apply everywhere — just like the CSS cascade treats `:root` as a
7
+ * default for every ancestor-scoped override. We merge `base` under the
8
+ * active scheme so a scheme that doesn't declare a token still sees the
9
+ * base default, while the scheme's own entries win on overlap.
10
+ * @returns Token table for the active scheme.
11
+ */
12
+ export declare function useTheme(): ThemeTable;
13
+ /**
14
+ * Read a raw CSS custom property's value for the active scheme. Accepts
15
+ * either `--foo` or the bare `foo` form for convenience.
16
+ * @param cssVariable CSS custom property name (with or without the leading `--`).
17
+ * @returns The resolved value, or undefined when the token is missing.
18
+ */
19
+ export declare function useToken(cssVariable: string): string | number | undefined;
20
+ /**
21
+ * Read a color token by shorthand name — `useColor('primary')` resolves
22
+ * `--color-primary` for the active scheme.
23
+ * @param name Token suffix after `--color-`.
24
+ * @returns Resolved color string, or undefined when the token is missing
25
+ * or its value isn't a string.
26
+ */
27
+ export declare function useColor(name: string): string | undefined;
28
+ /**
29
+ * Read a spacing token by shorthand name — `useSize('4')` resolves
30
+ * `--spacing-4` for the active scheme.
31
+ * @param name Token suffix after `--spacing-`.
32
+ * @returns Resolved spacing value, or undefined when the token is missing.
33
+ */
34
+ export declare function useSize(name: string): number | string | undefined;
@@ -0,0 +1,63 @@
1
+ import { useRnwind } from '../components/rnwind-provider.mjs';
2
+
3
+ /**
4
+ * Synthetic scheme name applied when tokens aren't declared under any
5
+ * `@variant` block — the "no active variant" fallback every theme table
6
+ * inherits from.
7
+ */
8
+ const BASE_SCHEME = 'base';
9
+ /**
10
+ * Access the resolved theme table for the active scheme.
11
+ *
12
+ * Tokens declared outside any `@variant` block live in the `base` table and
13
+ * should apply everywhere — just like the CSS cascade treats `:root` as a
14
+ * default for every ancestor-scoped override. We merge `base` under the
15
+ * active scheme so a scheme that doesn't declare a token still sees the
16
+ * base default, while the scheme's own entries win on overlap.
17
+ * @returns Token table for the active scheme.
18
+ */
19
+ function useTheme() {
20
+ const { scheme, tables } = useRnwind();
21
+ const base = tables[BASE_SCHEME] ?? {};
22
+ const schemeTable = tables[scheme];
23
+ if (!schemeTable)
24
+ return base;
25
+ // Fast path: nothing to merge when the scheme table is empty.
26
+ if (Object.keys(schemeTable).length === 0)
27
+ return base;
28
+ return { ...base, ...schemeTable };
29
+ }
30
+ /**
31
+ * Read a raw CSS custom property's value for the active scheme. Accepts
32
+ * either `--foo` or the bare `foo` form for convenience.
33
+ * @param cssVariable CSS custom property name (with or without the leading `--`).
34
+ * @returns The resolved value, or undefined when the token is missing.
35
+ */
36
+ function useToken(cssVariable) {
37
+ const table = useTheme();
38
+ const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`;
39
+ return table[name];
40
+ }
41
+ /**
42
+ * Read a color token by shorthand name — `useColor('primary')` resolves
43
+ * `--color-primary` for the active scheme.
44
+ * @param name Token suffix after `--color-`.
45
+ * @returns Resolved color string, or undefined when the token is missing
46
+ * or its value isn't a string.
47
+ */
48
+ function useColor(name) {
49
+ const value = useToken(`--color-${name}`);
50
+ return typeof value === 'string' ? value : undefined;
51
+ }
52
+ /**
53
+ * Read a spacing token by shorthand name — `useSize('4')` resolves
54
+ * `--spacing-4` for the active scheme.
55
+ * @param name Token suffix after `--spacing-`.
56
+ * @returns Resolved spacing value, or undefined when the token is missing.
57
+ */
58
+ function useSize(name) {
59
+ return useToken(`--spacing-${name}`);
60
+ }
61
+
62
+ export { useColor, useSize, useTheme, useToken };
63
+ //# sourceMappingURL=use-scheme.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-scheme.mjs","sources":["../../../../../src/runtime/hooks/use-scheme.ts"],"sourcesContent":["import type { ThemeTable } from '../../core/types'\nimport { useRnwind } from '../components/rnwind-provider'\n\n/**\n * Synthetic scheme name applied when tokens aren't declared under any\n * `@variant` block — the \"no active variant\" fallback every theme table\n * inherits from.\n */\nconst BASE_SCHEME = 'base'\n\n/**\n * Access the resolved theme table for the active scheme.\n *\n * Tokens declared outside any `@variant` block live in the `base` table and\n * should apply everywhere — just like the CSS cascade treats `:root` as a\n * default for every ancestor-scoped override. We merge `base` under the\n * active scheme so a scheme that doesn't declare a token still sees the\n * base default, while the scheme's own entries win on overlap.\n * @returns Token table for the active scheme.\n */\nexport function useTheme(): ThemeTable {\n const { scheme, tables } = useRnwind()\n const base = tables[BASE_SCHEME] ?? {}\n const schemeTable = tables[scheme]\n if (!schemeTable) return base\n // Fast path: nothing to merge when the scheme table is empty.\n if (Object.keys(schemeTable).length === 0) return base\n return { ...base, ...schemeTable }\n}\n\n/**\n * Read a raw CSS custom property's value for the active scheme. Accepts\n * either `--foo` or the bare `foo` form for convenience.\n * @param cssVariable CSS custom property name (with or without the leading `--`).\n * @returns The resolved value, or undefined when the token is missing.\n */\nexport function useToken(cssVariable: string): string | number | undefined {\n const table = useTheme()\n const name = cssVariable.startsWith('--') ? cssVariable : `--${cssVariable}`\n return table[name]\n}\n\n/**\n * Read a color token by shorthand name — `useColor('primary')` resolves\n * `--color-primary` for the active scheme.\n * @param name Token suffix after `--color-`.\n * @returns Resolved color string, or undefined when the token is missing\n * or its value isn't a string.\n */\nexport function useColor(name: string): string | undefined {\n const value = useToken(`--color-${name}`)\n return typeof value === 'string' ? value : undefined\n}\n\n/**\n * Read a spacing token by shorthand name — `useSize('4')` resolves\n * `--spacing-4` for the active scheme.\n * @param name Token suffix after `--spacing-`.\n * @returns Resolved spacing value, or undefined when the token is missing.\n */\nexport function useSize(name: string): number | string | undefined {\n return useToken(`--spacing-${name}`)\n}\n"],"names":[],"mappings":";;AAGA;;;;AAIG;AACH,MAAM,WAAW,GAAG,MAAM;AAE1B;;;;;;;;;AASG;SACa,QAAQ,GAAA;IACtB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE;IACtC,MAAM,IAAI,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,EAAE;AACtC,IAAA,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC;AAClC,IAAA,IAAI,CAAC,WAAW;AAAE,QAAA,OAAO,IAAI;;IAE7B,IAAI,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,MAAM,KAAK,CAAC;AAAE,QAAA,OAAO,IAAI;AACtD,IAAA,OAAO,EAAE,GAAG,IAAI,EAAE,GAAG,WAAW,EAAE;AACpC;AAEA;;;;;AAKG;AACG,SAAU,QAAQ,CAAC,WAAmB,EAAA;AAC1C,IAAA,MAAM,KAAK,GAAG,QAAQ,EAAE;AACxB,IAAA,MAAM,IAAI,GAAG,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,WAAW,GAAG,CAAA,EAAA,EAAK,WAAW,EAAE;AAC5E,IAAA,OAAO,KAAK,CAAC,IAAI,CAAC;AACpB;AAEA;;;;;;AAMG;AACG,SAAU,QAAQ,CAAC,IAAY,EAAA;IACnC,MAAM,KAAK,GAAG,QAAQ,CAAC,WAAW,IAAI,CAAA,CAAE,CAAC;AACzC,IAAA,OAAO,OAAO,KAAK,KAAK,QAAQ,GAAG,KAAK,GAAG,SAAS;AACtD;AAEA;;;;;AAKG;AACG,SAAU,OAAO,CAAC,IAAY,EAAA;AAClC,IAAA,OAAO,QAAQ,CAAC,CAAA,UAAA,EAAa,IAAI,CAAA,CAAE,CAAC;AACtC;;;;"}
@@ -0,0 +1,27 @@
1
+ export { lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider, getBreakpoints, activeBreakpointFor, lookupCss as _l, } from './lookup-css';
2
+ export { useR_ } from './components/rnwind-provider';
3
+ export type { HoistedClassName, InteractState, LookupInsets, SafeMarkerSpec } from './lookup-css';
4
+ export { useCss } from './hooks/use-css';
5
+ export { useInteract } from './hooks/use-interact';
6
+ export type { UseInteractResult } from './hooks/use-interact';
7
+ export { chainPress, chainFocus } from './chain-handlers';
8
+ export { InteractiveBox, InteractiveBox as _ib } from './interactive-box';
9
+ export type { InteractiveBoxProps, InteractiveSpec } from './interactive-box';
10
+ export { RnwindProvider, useRnwind } from './components/rnwind-provider';
11
+ export type { RnwindProviderProps, RnwindState, Insets } from './components/rnwind-provider';
12
+ export { useMountHaptic, triggerHaptic, triggerHaptic as _ht, useMountHaptic as _hm } from './haptics';
13
+ /** @internal */
14
+ /** @internal */
15
+ /** @internal */
16
+ /** @internal */
17
+ export type { HapticRequest, HapticTrigger, OnHaptics } from '../core/parser/haptics';
18
+ export type { AsLinearGradientProps, LinearGradientPoint } from './gradient-types';
19
+ export type { ThemeTable, ThemeTables } from '../core/types';
20
+ export { useTheme, useToken, useColor, useSize } from './hooks/use-scheme';
21
+ export type { Scheme, RnwindConfig } from './types';
22
+ /**
23
+ * Installed rnwind version, inlined at publish time. Compare against a pinned
24
+ * string when integrating with build tooling that may see multiple rnwind
25
+ * copies (e.g. workspace overrides).
26
+ */
27
+ export declare const VERSION: "0.0.1";
@@ -0,0 +1,18 @@
1
+ export { lookupCss as _l, activeBreakpointFor, getBreakpoints, lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider } from './lookup-css.mjs';
2
+ export { RnwindProvider, useR_, useRnwind } from './components/rnwind-provider.mjs';
3
+ export { useCss } from './hooks/use-css.mjs';
4
+ export { useInteract } from './hooks/use-interact.mjs';
5
+ export { chainFocus, chainPress } from './chain-handlers.mjs';
6
+ export { InteractiveBox, InteractiveBox as _ib } from './interactive-box.mjs';
7
+ export { useMountHaptic as _hm, triggerHaptic as _ht, triggerHaptic, useMountHaptic } from './haptics.mjs';
8
+ export { useColor, useSize, useTheme, useToken } from './hooks/use-scheme.mjs';
9
+
10
+ /**
11
+ * Installed rnwind version, inlined at publish time. Compare against a pinned
12
+ * string when integrating with build tooling that may see multiple rnwind
13
+ * copies (e.g. workspace overrides).
14
+ */
15
+ const VERSION = '0.0.1';
16
+
17
+ export { VERSION };
18
+ //# sourceMappingURL=index.mjs.map