rnwind 0.0.1 → 0.0.3

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 +193 -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 +120 -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 +110 -0
  36. package/lib/cjs/core/parser/length.cjs.map +1 -0
  37. package/lib/cjs/core/parser/length.d.ts +51 -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 +188 -0
  51. package/lib/cjs/core/parser/shorthand.cjs.map +1 -0
  52. package/lib/cjs/core/parser/shorthand.d.ts +67 -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 +467 -0
  57. package/lib/cjs/core/parser/theme-vars.cjs.map +1 -0
  58. package/lib/cjs/core/parser/theme-vars.d.ts +82 -0
  59. package/lib/cjs/core/parser/tokens.cjs +486 -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 +1680 -0
  66. package/lib/cjs/core/parser/tw-parser.cjs.map +1 -0
  67. package/lib/cjs/core/parser/tw-parser.d.ts +210 -0
  68. package/lib/cjs/core/parser/types.d.ts +37 -0
  69. package/lib/cjs/core/parser/typography-dispatcher.cjs +108 -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 +444 -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 +301 -0
  93. package/lib/cjs/metro/state.cjs.map +1 -0
  94. package/lib/cjs/metro/state.d.ts +88 -0
  95. package/lib/cjs/metro/transform-ast.cjs +1472 -0
  96. package/lib/cjs/metro/transform-ast.cjs.map +1 -0
  97. package/lib/cjs/metro/transform-ast.d.ts +88 -0
  98. package/lib/cjs/metro/transformer.cjs +372 -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 +79 -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 +191 -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 +118 -0
  172. package/lib/esm/core/parser/layout-dispatcher.mjs.map +1 -0
  173. package/lib/esm/core/parser/length.d.ts +51 -0
  174. package/lib/esm/core/parser/length.mjs +104 -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 +67 -0
  189. package/lib/esm/core/parser/shorthand.mjs +180 -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 +82 -0
  195. package/lib/esm/core/parser/theme-vars.mjs +461 -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 +480 -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 +210 -0
  204. package/lib/esm/core/parser/tw-parser.mjs +1678 -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 +106 -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 +442 -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 +88 -0
  231. package/lib/esm/metro/state.mjs +291 -0
  232. package/lib/esm/metro/state.mjs.map +1 -0
  233. package/lib/esm/metro/transform-ast.d.ts +88 -0
  234. package/lib/esm/metro/transform-ast.mjs +1451 -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 +349 -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 +79 -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 +80 -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 +191 -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 +111 -0
  291. package/src/core/parser/length.ts +114 -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 +182 -0
  297. package/src/core/parser/text-truncate.ts +79 -0
  298. package/src/core/parser/theme-vars.ts +465 -0
  299. package/src/core/parser/tokens.ts +456 -0
  300. package/src/core/parser/transform.ts +195 -0
  301. package/src/core/parser/tw-parser.ts +1828 -0
  302. package/src/core/parser/types.ts +45 -0
  303. package/src/core/parser/typography-dispatcher.ts +97 -0
  304. package/src/core/parser/typography.ts +83 -0
  305. package/src/core/style-builder/build-style.ts +500 -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 +305 -0
  313. package/src/metro/transform-ast.ts +1729 -0
  314. package/src/metro/transformer.ts +372 -0
  315. package/src/metro/warn-unknown-classes.ts +79 -0
  316. package/src/metro/with-config.ts +251 -0
  317. package/src/runtime/chain-handlers.ts +47 -0
  318. package/src/runtime/components/rnwind-provider.tsx +144 -0
  319. package/src/runtime/gradient-types.ts +60 -0
  320. package/src/runtime/haptics.ts +120 -0
  321. package/src/runtime/hooks/use-css.ts +16 -0
  322. package/src/runtime/hooks/use-interact.ts +65 -0
  323. package/src/runtime/hooks/use-scheme.ts +63 -0
  324. package/src/runtime/index.ts +54 -0
  325. package/src/runtime/interactive-box.tsx +57 -0
  326. package/src/runtime/lookup-css.ts +628 -0
  327. package/src/runtime/types.ts +32 -0
  328. package/src/testing/index.ts +507 -0
  329. package/src/types/tailwindcss-node.d.ts +33 -0
  330. package/src/index.ts +0 -1
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Runtime resolver for rnwind-transformed files.
3
+ *
4
+ * Hot path is ONE WeakMap.get + cached-array return for stable atoms
5
+ * (no `active:`/`focus:`/`*-safe` variance beyond what the cache key
6
+ * captures). First call per (hoist, scheme, stateIndex) walks the
7
+ * atoms once, looks each up as
8
+ *
9
+ * `cache.atoms[scheme]?.[atom] ?? cache.atoms.common?.[atom]`
10
+ *
11
+ * and caches the result. `registerAtoms(scheme, record)` bumps a
12
+ * version counter; the next lookup notices the mismatch and rebuilds.
13
+ *
14
+ * Keyframes are inlined directly into atom values via `animationName`
15
+ * at build time — no separate registry.
16
+ */
17
+ import type { RnwindState } from './components/rnwind-provider';
18
+ /**
19
+ * One entry in the sorted-by-threshold breakpoints array. The runtime
20
+ * derives an atom's threshold by matching its `<prefix>:` against
21
+ * `name`; the array form is preferred over a Map so the hot-path
22
+ * `tierFor(width)` walk is a tight numeric loop.
23
+ */
24
+ interface BreakpointEntry {
25
+ readonly name: string;
26
+ readonly minWidth: number;
27
+ }
28
+ /** Optional window-height provider for the `screen-minus-y` marker. */
29
+ type WindowHeightProvider = () => number;
30
+ /**
31
+ * Optional scheme loader. Registered by the generated manifest module
32
+ * (`rnwind/__generated/schemes`) once at import time. SchemeProvider
33
+ * calls it synchronously on every render with the active scheme name;
34
+ * first call per scheme pulls the scheme's style module in via an
35
+ * inline `require()` — subsequent calls are a no-op through Metro's
36
+ * module cache.
37
+ */
38
+ type SchemeLoader = (scheme: string) => void;
39
+ /**
40
+ * Per-render snapshot of which interactive states (active, focus) are
41
+ * currently engaged. Forwarded from the `useInteract()` hook the
42
+ * transformer injects.
43
+ */
44
+ export interface InteractState {
45
+ active?: boolean;
46
+ focus?: boolean;
47
+ }
48
+ /**
49
+ * Safe-area insets bundle the transformer passes to `lookupCss` when a
50
+ * file uses any `*-safe` utility.
51
+ */
52
+ export interface LookupInsets {
53
+ top: number;
54
+ right: number;
55
+ bottom: number;
56
+ left: number;
57
+ }
58
+ /**
59
+ * Precomputed safe-area marker spec emitted by the build-side
60
+ * `envelopeSafeMarkers`. Tuple form: `[cssKey, sideTag, or, offset]`.
61
+ */
62
+ export type SafeMarkerSpec = readonly [string, string, number | undefined, number | undefined];
63
+ /** Type alias: the atom-list build output the transformer emits. */
64
+ export type HoistedClassName = readonly string[];
65
+ /**
66
+ * Register a window-height provider used by the `screen-minus-y`
67
+ * safe-area variant. When not wired, `h-screen-safe` resolves to `0`.
68
+ * @param provider Callback returning the current window height in px.
69
+ */
70
+ export declare function setWindowHeightProvider(provider: WindowHeightProvider | null): void;
71
+ /**
72
+ * Register the scheme-loader function exported by the generated
73
+ * manifest module. Called once at manifest-module evaluation time —
74
+ * subsequent registrations override the previous loader (useful for
75
+ * tests).
76
+ * @param loader Manifest's `ensureSchemeLoaded` function, or null to
77
+ * detach (tests).
78
+ */
79
+ export declare function registerSchemeLoader(loader: SchemeLoader | null): void;
80
+ /**
81
+ * Ensure the given scheme's style module is loaded. Safe to call in
82
+ * render — zero-cost after the first call per scheme thanks to
83
+ * Metro's module cache, and a no-op when no loader is registered
84
+ * (tests, or a bundle without rnwind-transformed sources).
85
+ * @param scheme Active scheme name.
86
+ */
87
+ export declare function loadScheme(scheme: string): void;
88
+ /**
89
+ * Register (or re-register) one scheme's atoms in the global registry.
90
+ * Pure property assignment — no iteration, no allocation. The version
91
+ * counter bump invalidates every hoist-level result cache lazily on
92
+ * next read.
93
+ * @param scheme Registry key — `'common'` for the always-loaded
94
+ * fallback, or a variant name (`'dark'`, `'light'`, `'brand'`, ...).
95
+ * @param atoms Plain record keyed by atom name.
96
+ */
97
+ export declare function registerAtoms(scheme: string, atoms: Record<string, unknown>): void;
98
+ /**
99
+ * Register the responsive-breakpoint table the manifest module emits at
100
+ * load time. Replaces the prior table — calling with `{}` clears it.
101
+ * Bumps `atomVersion` so any cached lookup invalidates on next read,
102
+ * which matters during a theme HMR cycle that adds/removes breakpoints.
103
+ * @param breakpoints Breakpoint name → minimum-width threshold (px).
104
+ */
105
+ export declare function registerBreakpoints(breakpoints: Record<string, number>): void;
106
+ /**
107
+ * Snapshot of the registered breakpoints, for callers that want to
108
+ * compute their own derivations (e.g. the provider deriving the active
109
+ * breakpoint name). Returns a fresh array — callers can iterate without
110
+ * worrying about concurrent mutation from a manifest reload.
111
+ * @returns Breakpoints sorted by ascending min-width threshold.
112
+ */
113
+ export declare function getBreakpoints(): readonly BreakpointEntry[];
114
+ /**
115
+ * Sentinel name returned by {@link activeBreakpointFor} ONLY when no
116
+ * breakpoints are registered at all (bundle without rnwind-transformed
117
+ * sources, fresh test setup). When at least one breakpoint is
118
+ * registered, the function falls back to the smallest registered name
119
+ * instead — so phone-width devices (402 dp on a stock iPhone, well
120
+ * below `sm = 640`) report `activeBreakpoint === 'sm'` rather than the
121
+ * abstract `'base'`. This matches the user expectation that the value
122
+ * is always a real Tailwind breakpoint label they can branch on.
123
+ *
124
+ * Note: this is decoupled from the className filter. `sm:*` atoms
125
+ * still only fire at `windowWidth >= 640` per Tailwind's mobile-first
126
+ * spec — `activeBreakpoint === 'sm'` at 402 means "I'm in the smallest
127
+ * tier", not "`sm:` classes are firing".
128
+ */
129
+ export declare const BASE_BREAKPOINT = "base";
130
+ /**
131
+ * Resolve the currently-active breakpoint name for a width:
132
+ * - `windowWidth >= some threshold` → the highest matching breakpoint name.
133
+ * - below every registered threshold → the smallest registered name.
134
+ * - no breakpoints registered → {@link BASE_BREAKPOINT}.
135
+ * Always returns a string so consumers can branch on it without
136
+ * null-handling.
137
+ * @param windowWidth Live window width in px.
138
+ * @returns Active breakpoint name (never null).
139
+ */
140
+ export declare function activeBreakpointFor(windowWidth: number): string;
141
+ /**
142
+ * Resolve a className input against the active rnwind context. Hot
143
+ * path:
144
+ * - Array input (build hoist): ONE WeakMap.get + ONE record-access
145
+ * + cached array return. No per-render allocation when there's no
146
+ * userStyle and the hoist has no safe atoms.
147
+ * - String input (dynamic `className={expr}`): tokenise + walk.
148
+ * @param input Hoisted atom list or raw className string.
149
+ * @param ctx Rnwind context — `{scheme, fontScale, insets}` (extra
150
+ * fields ignored). Pass the result of `useRnwind()` directly.
151
+ * @param userStyle Optional caller-supplied style appended last.
152
+ * @param interactState Live active/focus flags from `useInteract()`.
153
+ * @returns Style array for React Native's `style` prop.
154
+ */
155
+ export declare function lookupCss(input: HoistedClassName | string | null | undefined, ctx: RnwindState, userStyle?: unknown, interactState?: InteractState): readonly unknown[];
156
+ /** Test-only — clear the global registry between suites. */
157
+ export declare function __resetLookupCssState(): void;
158
+ /**
159
+ * Test-only sugar: accept a single-scheme record and register it as the
160
+ * `common` table.
161
+ * @param record Atom name → value record (registered under `common`).
162
+ */
163
+ export declare function __registerAtomsFromRecord(record: Record<string, unknown>): void;
164
+ export {};
@@ -0,0 +1,531 @@
1
+ /**
2
+ * Runtime resolver for rnwind-transformed files.
3
+ *
4
+ * Hot path is ONE WeakMap.get + cached-array return for stable atoms
5
+ * (no `active:`/`focus:`/`*-safe` variance beyond what the cache key
6
+ * captures). First call per (hoist, scheme, stateIndex) walks the
7
+ * atoms once, looks each up as
8
+ *
9
+ * `cache.atoms[scheme]?.[atom] ?? cache.atoms.common?.[atom]`
10
+ *
11
+ * and caches the result. `registerAtoms(scheme, record)` bumps a
12
+ * version counter; the next lookup notices the mismatch and rebuilds.
13
+ *
14
+ * Keyframes are inlined directly into atom values via `animationName`
15
+ * at build time — no separate registry.
16
+ */
17
+ /** Empty sentinel returned when the input is null / undefined / empty. */
18
+ const EMPTY_STYLES = [];
19
+ /** Registry key for the always-loaded fallback scheme. */
20
+ const COMMON_SCHEME = 'common';
21
+ /** Atom name prefix marking a press-state-gated atom. */
22
+ const ACTIVE_PREFIX = 'active:';
23
+ /** Atom name prefix marking a focus-state-gated atom. */
24
+ const FOCUS_PREFIX = 'focus:';
25
+ /**
26
+ * Process-global style cache. Replaced key-by-key by {@link registerAtoms}.
27
+ * Plain record-of-records: `scheme → atom → style`. Active scheme
28
+ * lookup is `cache.atoms[scheme]?.[atom]` — two property reads with
29
+ * an `?? cache.atoms.common[atom]` fallback. No loops over the
30
+ * registry, ever.
31
+ *
32
+ * `breakpoints` mirrors the build-time table the manifest module
33
+ * registers via {@link registerBreakpoints} — `name → px-threshold` for
34
+ * fast prefix-based atom filtering plus the sorted-by-threshold list
35
+ * for cheap tier-index computation in `lookupCss`.
36
+ */
37
+ const cache = {
38
+ atoms: Object.create(null),
39
+ breakpoints: Object.create(null),
40
+ breakpointList: [],
41
+ };
42
+ /**
43
+ * Bumps on every {@link registerAtoms} call. {@link HoistCache} entries
44
+ * stamp themselves with the current version; a mismatch on read
45
+ * triggers a rebuild so HMR-reloaded atoms propagate without manual
46
+ * invalidation.
47
+ */
48
+ let atomVersion = 0;
49
+ let windowHeightProvider = null;
50
+ let schemeLoader = null;
51
+ /** Module-scope flag so the missing-insets warning fires at most once. */
52
+ let WARNED_MISSING_INSETS = false;
53
+ /** Atoms we've already dev-warned about — keeps the noise to ONE line per typo per session. */
54
+ const WARNED_UNKNOWN_ATOMS = new Set();
55
+ /**
56
+ * Compute the state-array index from the live interactState. Bit-or
57
+ * encoding: 0 = idle, 1 = active, 2 = focus, 3 = both.
58
+ * @param interactState Snapshot from `useInteract()` (or undefined).
59
+ * @returns 0 / 1 / 2 / 3.
60
+ */
61
+ function stateIndexFor(interactState) {
62
+ if (!interactState)
63
+ return 0;
64
+ return ((interactState.active ? 1 : 0) | (interactState.focus ? 2 : 0));
65
+ }
66
+ /**
67
+ * Fetch the px inset for one side. Falls back to 0 when insets is undefined.
68
+ * @param side Compact side tag (`t` / `r` / `b` / `l`).
69
+ * @param insets Active insets.
70
+ * @returns Px value for that side.
71
+ */
72
+ function insetOf(side, insets) {
73
+ if (!insets)
74
+ return 0;
75
+ if (side === 't')
76
+ return insets.top;
77
+ if (side === 'r')
78
+ return insets.right;
79
+ if (side === 'b')
80
+ return insets.bottom;
81
+ if (side === 'l')
82
+ return insets.left;
83
+ return 0;
84
+ }
85
+ /**
86
+ * Collapse one safe-area marker into a concrete px number using the
87
+ * active insets.
88
+ * @param spec Marker spec tuple `[cssKey, sideTag, or, offset]`.
89
+ * @param insets Active insets (or undefined → 0).
90
+ * @returns Resolved px number.
91
+ */
92
+ function resolveMarker(spec, insets) {
93
+ const [, side, or_, offset] = spec;
94
+ if (side === 'screen-minus-y') {
95
+ const h = windowHeightProvider ? windowHeightProvider() : 0;
96
+ return Math.max(0, h - insetOf('t', insets) - insetOf('b', insets));
97
+ }
98
+ let base = insetOf(side, insets);
99
+ if (or_ !== undefined)
100
+ base = Math.max(base, or_);
101
+ if (offset !== undefined)
102
+ base += offset;
103
+ return base;
104
+ }
105
+ /**
106
+ * Emit a one-shot dev warning when a safe-area atom resolves without
107
+ * real insets in scope.
108
+ * @param insets Insets received by the resolver.
109
+ */
110
+ function warnMissingInsetsOnce(insets) {
111
+ if (WARNED_MISSING_INSETS)
112
+ return;
113
+ const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__;
114
+ if (!isDevelopment)
115
+ return;
116
+ if (insets && (insets.top !== 0 || insets.right !== 0 || insets.bottom !== 0 || insets.left !== 0))
117
+ return;
118
+ WARNED_MISSING_INSETS = true;
119
+ // eslint-disable-next-line no-console
120
+ console.warn('rnwind: a `*-safe` utility resolved with zero insets. Wire `insets` on <SchemeProvider> ' +
121
+ '(e.g. `insets={useSafeAreaInsets()}` from react-native-safe-area-context).');
122
+ }
123
+ /**
124
+ * Resolve precomputed safe-area marker specs into a fresh RN style
125
+ * object. Cannot be cached — insets vary per render with rotation /
126
+ * keyboard.
127
+ * @param specs Array of spec tuples.
128
+ * @param insets Live safe-area insets.
129
+ * @returns Fresh RN style object with concrete numbers.
130
+ */
131
+ function resolveSafe(specs, insets) {
132
+ warnMissingInsetsOnce(insets);
133
+ const out = {};
134
+ for (const spec of specs)
135
+ out[spec[0]] = resolveMarker(spec, insets);
136
+ return out;
137
+ }
138
+ /**
139
+ * Multiply `fontSize` / `lineHeight` in a resolved atom value by the
140
+ * active font scale. Early-returns the original reference for any atom
141
+ * that doesn't carry either property (most of them) — zero allocation
142
+ * on the hot path for non-text atoms.
143
+ * @param value Atom value as registered in the global table.
144
+ * @param fontScale Multiplier from `useWindowDimensions().fontScale`.
145
+ * @returns Scaled style object, or the original when no scaling applied.
146
+ */
147
+ function applyFontScale(value, fontScale) {
148
+ if (fontScale === 1)
149
+ return value;
150
+ if (typeof value !== 'object' || value === null)
151
+ return value;
152
+ const record = value;
153
+ const fs = record.fontSize;
154
+ const lh = record.lineHeight;
155
+ if (typeof fs !== 'number' && typeof lh !== 'number')
156
+ return value;
157
+ const scaled = { ...record };
158
+ if (typeof fs === 'number')
159
+ scaled.fontSize = fs * fontScale;
160
+ if (typeof lh === 'number')
161
+ scaled.lineHeight = lh * fontScale;
162
+ return scaled;
163
+ }
164
+ /**
165
+ * Read the precomputed safe-area marker spec list off an atom value.
166
+ * Build-side `envelopeSafeMarkers` wraps safe atoms in
167
+ * `{__safeStyle: [...]}`; this is a single property access.
168
+ * @param value Atom value as registered in the global table.
169
+ * @returns Spec array when the atom is safe-area, else null.
170
+ */
171
+ function readSafeSpecs(value) {
172
+ if (typeof value !== 'object' || value === null)
173
+ return null;
174
+ const safe = value.__safeStyle;
175
+ return safe ?? null;
176
+ }
177
+ /**
178
+ * Per-atom lookup. Two property reads: scheme's own table then the
179
+ * common fallback. Returns `undefined` for unknown atoms — the caller
180
+ * skips them.
181
+ * @param scheme Active scheme.
182
+ * @param atom Atom name.
183
+ * @returns Resolved value, or undefined.
184
+ */
185
+ function lookupAtom(scheme, atom) {
186
+ const schemeTable = cache.atoms[scheme];
187
+ if (schemeTable !== undefined) {
188
+ const own = schemeTable[atom];
189
+ if (own !== undefined)
190
+ return own;
191
+ }
192
+ const common = cache.atoms[COMMON_SCHEME];
193
+ return common === undefined ? undefined : common[atom];
194
+ }
195
+ /**
196
+ * Whether an atom should participate in a given interact-state index.
197
+ * - idle (0): no `active:` / `focus:` atoms.
198
+ * - active (1): base + `active:`.
199
+ * - focus (2): base + `focus:`.
200
+ * - both (3): base + `active:` + `focus:`.
201
+ * @param atom Atom name.
202
+ * @param stateIndex Encoded state (0/1/2/3).
203
+ * @returns True when the atom should be emitted for this state.
204
+ */
205
+ function atomMatchesState(atom, stateIndex) {
206
+ // Cheap prefix check — check the first code point before the full
207
+ // `startsWith` so we skip it for any atom whose first letter isn't
208
+ // `a` / `f`.
209
+ const code = atom.codePointAt(0);
210
+ if (code === 97 /* a */ && atom.startsWith(ACTIVE_PREFIX))
211
+ return (stateIndex & 1) !== 0;
212
+ if (code === 102 /* f */ && atom.startsWith(FOCUS_PREFIX))
213
+ return (stateIndex & 2) !== 0;
214
+ return true;
215
+ }
216
+ /**
217
+ * Whether an atom passes the responsive-breakpoint gate for the
218
+ * current `windowWidth`. Atoms without a registered `<prefix>:` are
219
+ * always-on (the common case — `bg-red-500`, `active:bg-blue-700`).
220
+ * Atoms whose first prefix matches a registered breakpoint name pass
221
+ * only when `windowWidth >= threshold`.
222
+ * @param atom Atom name.
223
+ * @param windowWidth Live `useWindowDimensions().width` snapshot.
224
+ * @returns True when the atom should be emitted for this width.
225
+ */
226
+ function atomMatchesBreakpoint(atom, windowWidth) {
227
+ const colon = atom.indexOf(':');
228
+ if (colon === -1)
229
+ return true;
230
+ const prefix = atom.slice(0, colon);
231
+ const threshold = cache.breakpoints[prefix];
232
+ if (threshold === undefined)
233
+ return true;
234
+ return windowWidth >= threshold;
235
+ }
236
+ /**
237
+ * Tier index — count of registered breakpoints whose threshold is
238
+ * `<= windowWidth`. Bounded by the breakpoint count, so it's a stable
239
+ * cache-key dimension instead of the unbounded raw width. Crossings
240
+ * happen ~5 times across the device-width spectrum, not per-pixel.
241
+ * @param windowWidth Live width.
242
+ * @returns Tier 0..N where N = `cache.breakpointList.length`.
243
+ */
244
+ function tierFor(windowWidth) {
245
+ let tier = 0;
246
+ for (const entry of cache.breakpointList) {
247
+ if (windowWidth >= entry.minWidth)
248
+ tier += 1;
249
+ else
250
+ break;
251
+ }
252
+ return tier;
253
+ }
254
+ /**
255
+ * Build the style array for a (hoist, scheme, state, width) tuple.
256
+ * Walks the atom list, applies the interact-state and breakpoint
257
+ * filters, resolves each atom via scheme→common fallback, and
258
+ * envelopes safe values via {@link resolveSafe}.
259
+ * @param atoms Atom name list (build-time constant).
260
+ * @param scheme Active scheme.
261
+ * @param stateIndex Encoded active/focus state.
262
+ * @param insets Live safe-area insets.
263
+ * @param fontScale Font scale multiplier.
264
+ * @param windowWidth Live window width — gates `md:*` / `lg:*` atoms.
265
+ * @returns Fresh style array.
266
+ */
267
+ function buildStyleArray(atoms, scheme, stateIndex, insets, fontScale, windowWidth) {
268
+ const out = [];
269
+ for (const atom of atoms) {
270
+ if (!atomMatchesState(atom, stateIndex))
271
+ continue;
272
+ if (!atomMatchesBreakpoint(atom, windowWidth))
273
+ continue;
274
+ const value = lookupAtom(scheme, atom);
275
+ if (value === undefined) {
276
+ warnUnknownAtomOnce(atom);
277
+ continue;
278
+ }
279
+ const safe = readSafeSpecs(value);
280
+ const resolved = safe === null ? value : resolveSafe(safe, insets);
281
+ out.push(applyFontScale(resolved, fontScale));
282
+ }
283
+ return out;
284
+ }
285
+ /**
286
+ * Emit a one-shot dev warning when an atom name doesn't resolve in the
287
+ * registry. The two real causes are a typo (`bg-red-501`) or a class
288
+ * the build-time scanner never saw because it lives in a string the
289
+ * oxide tokeniser can't see (e.g. computed at runtime). Either way, a
290
+ * silent empty style is the worst possible UX — surface it.
291
+ *
292
+ * Filters cosmetic non-issues: empty strings, build-time `__safeStyle`
293
+ * envelopes that wandered in, etc.
294
+ * @param atom Class name that didn't resolve.
295
+ */
296
+ function warnUnknownAtomOnce(atom) {
297
+ if (atom.length === 0)
298
+ return;
299
+ const isDevelopment = typeof __DEV__ === 'undefined' || __DEV__;
300
+ if (!isDevelopment)
301
+ return;
302
+ if (WARNED_UNKNOWN_ATOMS.has(atom))
303
+ return;
304
+ WARNED_UNKNOWN_ATOMS.add(atom);
305
+ // eslint-disable-next-line no-console
306
+ console.warn(`rnwind: unknown class "${atom}" — typo, or the class is built dynamically and the build-time ` +
307
+ `scanner never saw it. Static literals + ternaries are scanned automatically; runtime-built ` +
308
+ `strings need to appear somewhere as a literal so oxide can pick them up.`);
309
+ }
310
+ /**
311
+ * Per-atom-list cache keyed on the hoist reference. WeakMap so
312
+ * hoists GC with their host module on HMR.
313
+ */
314
+ const resultCache = new WeakMap();
315
+ /**
316
+ * Walk the atom list once to detect safe-area atoms — results that
317
+ * vary per render with `insets`. When any atom envelopes safe specs
318
+ * we skip the cache and rebuild every call.
319
+ * @param atoms Hoist atom list.
320
+ * @param scheme Active scheme.
321
+ * @returns Whether the hoist resolves a safe atom under this scheme.
322
+ */
323
+ function detectHasSafe(atoms, scheme) {
324
+ for (const atom of atoms) {
325
+ const value = lookupAtom(scheme, atom);
326
+ if (readSafeSpecs(value) !== null)
327
+ return true;
328
+ }
329
+ return false;
330
+ }
331
+ /**
332
+ * Cache-keyed resolution for the common static-schema case. Returns a
333
+ * stable array reference across renders until `atomVersion` bumps.
334
+ * For hoists containing safe atoms — which depend on per-render
335
+ * insets — rebuilds every call.
336
+ *
337
+ * The `tier` dimension keeps the cache bounded under responsive
338
+ * variants: instead of keying on raw `windowWidth` (which would explode
339
+ * the cache to one entry per pixel), we key on the count of registered
340
+ * breakpoints whose threshold is reached. That gives at most
341
+ * `breakpointCount + 1` cache rows per (scheme, state, fontScale).
342
+ * @param atoms Hoist atom list.
343
+ * @param scheme Active scheme.
344
+ * @param stateIndex Encoded interact state.
345
+ * @param insets Live safe-area insets.
346
+ * @param fontScale Font scale multiplier.
347
+ * @param windowWidth Live window width.
348
+ * @returns Style array.
349
+ */
350
+ function lookupCached(atoms, scheme, stateIndex, insets, fontScale, windowWidth) {
351
+ let entry = resultCache.get(atoms);
352
+ if (entry?.version !== atomVersion) {
353
+ entry = { version: atomVersion, hasSafe: detectHasSafe(atoms, scheme), byKey: Object.create(null) };
354
+ resultCache.set(atoms, entry);
355
+ }
356
+ if (entry.hasSafe)
357
+ return buildStyleArray(atoms, scheme, stateIndex, insets, fontScale, windowWidth);
358
+ const tier = tierFor(windowWidth);
359
+ const key = `${scheme}|${stateIndex}|${fontScale}|${tier}`;
360
+ const cached = entry.byKey[key];
361
+ if (cached !== undefined)
362
+ return cached;
363
+ const fresh = buildStyleArray(atoms, scheme, stateIndex, insets, fontScale, windowWidth);
364
+ entry.byKey[key] = fresh;
365
+ return fresh;
366
+ }
367
+ /**
368
+ * Register a window-height provider used by the `screen-minus-y`
369
+ * safe-area variant. When not wired, `h-screen-safe` resolves to `0`.
370
+ * @param provider Callback returning the current window height in px.
371
+ */
372
+ function setWindowHeightProvider(provider) {
373
+ windowHeightProvider = provider;
374
+ }
375
+ /**
376
+ * Register the scheme-loader function exported by the generated
377
+ * manifest module. Called once at manifest-module evaluation time —
378
+ * subsequent registrations override the previous loader (useful for
379
+ * tests).
380
+ * @param loader Manifest's `ensureSchemeLoaded` function, or null to
381
+ * detach (tests).
382
+ */
383
+ function registerSchemeLoader(loader) {
384
+ schemeLoader = loader;
385
+ }
386
+ /**
387
+ * Ensure the given scheme's style module is loaded. Safe to call in
388
+ * render — zero-cost after the first call per scheme thanks to
389
+ * Metro's module cache, and a no-op when no loader is registered
390
+ * (tests, or a bundle without rnwind-transformed sources).
391
+ * @param scheme Active scheme name.
392
+ */
393
+ function loadScheme(scheme) {
394
+ if (schemeLoader)
395
+ schemeLoader(scheme);
396
+ }
397
+ /**
398
+ * Register (or re-register) one scheme's atoms in the global registry.
399
+ * Pure property assignment — no iteration, no allocation. The version
400
+ * counter bump invalidates every hoist-level result cache lazily on
401
+ * next read.
402
+ * @param scheme Registry key — `'common'` for the always-loaded
403
+ * fallback, or a variant name (`'dark'`, `'light'`, `'brand'`, ...).
404
+ * @param atoms Plain record keyed by atom name.
405
+ */
406
+ function registerAtoms(scheme, atoms) {
407
+ cache.atoms[scheme] = atoms;
408
+ atomVersion += 1;
409
+ }
410
+ /**
411
+ * Register the responsive-breakpoint table the manifest module emits at
412
+ * load time. Replaces the prior table — calling with `{}` clears it.
413
+ * Bumps `atomVersion` so any cached lookup invalidates on next read,
414
+ * which matters during a theme HMR cycle that adds/removes breakpoints.
415
+ * @param breakpoints Breakpoint name → minimum-width threshold (px).
416
+ */
417
+ function registerBreakpoints(breakpoints) {
418
+ const fresh = Object.create(null);
419
+ const list = [];
420
+ for (const name of Object.keys(breakpoints)) {
421
+ const minWidth = breakpoints[name];
422
+ if (!Number.isFinite(minWidth) || minWidth <= 0)
423
+ continue;
424
+ fresh[name] = minWidth;
425
+ list.push({ name, minWidth });
426
+ }
427
+ list.sort((a, b) => a.minWidth - b.minWidth || a.name.localeCompare(b.name));
428
+ cache.breakpoints = fresh;
429
+ cache.breakpointList = list;
430
+ atomVersion += 1;
431
+ }
432
+ /**
433
+ * Snapshot of the registered breakpoints, for callers that want to
434
+ * compute their own derivations (e.g. the provider deriving the active
435
+ * breakpoint name). Returns a fresh array — callers can iterate without
436
+ * worrying about concurrent mutation from a manifest reload.
437
+ * @returns Breakpoints sorted by ascending min-width threshold.
438
+ */
439
+ function getBreakpoints() {
440
+ return cache.breakpointList;
441
+ }
442
+ /**
443
+ * Sentinel name returned by {@link activeBreakpointFor} ONLY when no
444
+ * breakpoints are registered at all (bundle without rnwind-transformed
445
+ * sources, fresh test setup). When at least one breakpoint is
446
+ * registered, the function falls back to the smallest registered name
447
+ * instead — so phone-width devices (402 dp on a stock iPhone, well
448
+ * below `sm = 640`) report `activeBreakpoint === 'sm'` rather than the
449
+ * abstract `'base'`. This matches the user expectation that the value
450
+ * is always a real Tailwind breakpoint label they can branch on.
451
+ *
452
+ * Note: this is decoupled from the className filter. `sm:*` atoms
453
+ * still only fire at `windowWidth >= 640` per Tailwind's mobile-first
454
+ * spec — `activeBreakpoint === 'sm'` at 402 means "I'm in the smallest
455
+ * tier", not "`sm:` classes are firing".
456
+ */
457
+ const BASE_BREAKPOINT = 'base';
458
+ /**
459
+ * Resolve the currently-active breakpoint name for a width:
460
+ * - `windowWidth >= some threshold` → the highest matching breakpoint name.
461
+ * - below every registered threshold → the smallest registered name.
462
+ * - no breakpoints registered → {@link BASE_BREAKPOINT}.
463
+ * Always returns a string so consumers can branch on it without
464
+ * null-handling.
465
+ * @param windowWidth Live window width in px.
466
+ * @returns Active breakpoint name (never null).
467
+ */
468
+ function activeBreakpointFor(windowWidth) {
469
+ const list = cache.breakpointList;
470
+ if (list.length === 0)
471
+ return BASE_BREAKPOINT;
472
+ let active = list[0].name;
473
+ for (const entry of list) {
474
+ if (windowWidth >= entry.minWidth)
475
+ active = entry.name;
476
+ else
477
+ break;
478
+ }
479
+ return active;
480
+ }
481
+ /**
482
+ * Resolve a className input against the active rnwind context. Hot
483
+ * path:
484
+ * - Array input (build hoist): ONE WeakMap.get + ONE record-access
485
+ * + cached array return. No per-render allocation when there's no
486
+ * userStyle and the hoist has no safe atoms.
487
+ * - String input (dynamic `className={expr}`): tokenise + walk.
488
+ * @param input Hoisted atom list or raw className string.
489
+ * @param ctx Rnwind context — `{scheme, fontScale, insets}` (extra
490
+ * fields ignored). Pass the result of `useRnwind()` directly.
491
+ * @param userStyle Optional caller-supplied style appended last.
492
+ * @param interactState Live active/focus flags from `useInteract()`.
493
+ * @returns Style array for React Native's `style` prop.
494
+ */
495
+ function lookupCss(input, ctx, userStyle, interactState) {
496
+ if (input === null || input === undefined) {
497
+ return userStyle === undefined || userStyle === null ? EMPTY_STYLES : [userStyle];
498
+ }
499
+ const { scheme, insets, fontScale, windowWidth } = ctx;
500
+ if (typeof input === 'string') {
501
+ const trimmed = input.trim();
502
+ if (trimmed.length === 0) {
503
+ return userStyle === undefined || userStyle === null ? EMPTY_STYLES : [userStyle];
504
+ }
505
+ const atoms = trimmed.split(/\s+/);
506
+ const out = buildStyleArray(atoms, scheme, stateIndexFor(interactState), insets, fontScale, windowWidth);
507
+ if (userStyle === undefined || userStyle === null)
508
+ return out;
509
+ return [...out, userStyle];
510
+ }
511
+ const base = lookupCached(input, scheme, stateIndexFor(interactState), insets, fontScale, windowWidth);
512
+ if (userStyle === undefined || userStyle === null)
513
+ return base;
514
+ return [...base, userStyle];
515
+ }
516
+ /** Test-only — clear the global registry between suites. */
517
+ function __resetLookupCssState() {
518
+ for (const key of Object.keys(cache.atoms))
519
+ delete cache.atoms[key];
520
+ for (const key of Object.keys(cache.breakpoints))
521
+ delete cache.breakpoints[key];
522
+ cache.breakpointList = [];
523
+ windowHeightProvider = null;
524
+ schemeLoader = null;
525
+ WARNED_MISSING_INSETS = false;
526
+ WARNED_UNKNOWN_ATOMS.clear();
527
+ atomVersion += 1;
528
+ }
529
+
530
+ export { BASE_BREAKPOINT, __resetLookupCssState, activeBreakpointFor, getBreakpoints, loadScheme, lookupCss, registerAtoms, registerBreakpoints, registerSchemeLoader, setWindowHeightProvider };
531
+ //# sourceMappingURL=lookup-css.mjs.map