@niibase/uniwind 1.0.0

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 (439) hide show
  1. package/LICENSE +20 -0
  2. package/dist/common/components/index.js +314 -0
  3. package/dist/common/components/native/ActivityIndicator.js +21 -0
  4. package/dist/common/components/native/Button.js +18 -0
  5. package/dist/common/components/native/FlatList.js +30 -0
  6. package/dist/common/components/native/Image.js +21 -0
  7. package/dist/common/components/native/ImageBackground.js +23 -0
  8. package/dist/common/components/native/InputAccessoryView.js +21 -0
  9. package/dist/common/components/native/KeyboardAvoidingView.js +20 -0
  10. package/dist/common/components/native/Modal.js +21 -0
  11. package/dist/common/components/native/Pressable.js +29 -0
  12. package/dist/common/components/native/RefreshControl.js +27 -0
  13. package/dist/common/components/native/SafeAreaView.js +18 -0
  14. package/dist/common/components/native/ScrollView.js +23 -0
  15. package/dist/common/components/native/SectionList.js +27 -0
  16. package/dist/common/components/native/Switch.js +32 -0
  17. package/dist/common/components/native/Text.js +36 -0
  18. package/dist/common/components/native/TextInput.js +53 -0
  19. package/dist/common/components/native/TouchableHighlight.js +35 -0
  20. package/dist/common/components/native/TouchableNativeFeedback.js +32 -0
  21. package/dist/common/components/native/TouchableOpacity.js +32 -0
  22. package/dist/common/components/native/TouchableWithoutFeedback.js +32 -0
  23. package/dist/common/components/native/View.js +18 -0
  24. package/dist/common/components/native/VirtualizedList.js +27 -0
  25. package/dist/common/components/native/useStyle.js +29 -0
  26. package/dist/common/components/utils.js +18 -0
  27. package/dist/common/components/web/ActivityIndicator.js +20 -0
  28. package/dist/common/components/web/Button.js +18 -0
  29. package/dist/common/components/web/FlatList.js +22 -0
  30. package/dist/common/components/web/Image.js +20 -0
  31. package/dist/common/components/web/ImageBackground.js +21 -0
  32. package/dist/common/components/web/KeyboardAvoidingView.js +18 -0
  33. package/dist/common/components/web/Modal.js +17 -0
  34. package/dist/common/components/web/Pressable.js +17 -0
  35. package/dist/common/components/web/RefreshControl.js +17 -0
  36. package/dist/common/components/web/SafeAreaView.js +17 -0
  37. package/dist/common/components/web/ScrollView.js +18 -0
  38. package/dist/common/components/web/SectionList.js +20 -0
  39. package/dist/common/components/web/Switch.js +26 -0
  40. package/dist/common/components/web/Text.js +17 -0
  41. package/dist/common/components/web/TextInput.js +17 -0
  42. package/dist/common/components/web/TouchableHighlight.js +20 -0
  43. package/dist/common/components/web/TouchableNativeFeedback.js +13 -0
  44. package/dist/common/components/web/TouchableOpacity.js +17 -0
  45. package/dist/common/components/web/TouchableWithoutFeedback.js +17 -0
  46. package/dist/common/components/web/View.js +17 -0
  47. package/dist/common/components/web/VirtualizedList.js +20 -0
  48. package/dist/common/components/web/index.js +187 -0
  49. package/dist/common/components/web/metro-injected.js +1 -0
  50. package/dist/common/components/web/rnw.js +42 -0
  51. package/dist/common/core/config/config.common.js +80 -0
  52. package/dist/common/core/config/config.js +51 -0
  53. package/dist/common/core/config/config.native.js +67 -0
  54. package/dist/common/core/config/index.js +16 -0
  55. package/dist/common/core/index.js +16 -0
  56. package/dist/common/core/listener.js +51 -0
  57. package/dist/common/core/logger.js +18 -0
  58. package/dist/common/core/native/index.js +27 -0
  59. package/dist/common/core/native/native-utils.js +36 -0
  60. package/dist/common/core/native/parsers/boxShadow.js +10 -0
  61. package/dist/common/core/native/parsers/fontVariant.js +8 -0
  62. package/dist/common/core/native/parsers/gradient.js +31 -0
  63. package/dist/common/core/native/parsers/index.js +60 -0
  64. package/dist/common/core/native/parsers/textShadow.js +39 -0
  65. package/dist/common/core/native/parsers/transforms.js +44 -0
  66. package/dist/common/core/native/runtime.js +34 -0
  67. package/dist/common/core/native/store.js +181 -0
  68. package/dist/common/core/types.js +1 -0
  69. package/dist/common/core/web/cssListener.js +146 -0
  70. package/dist/common/core/web/formatColor.js +15 -0
  71. package/dist/common/core/web/getWebStyles.js +51 -0
  72. package/dist/common/core/web/index.js +49 -0
  73. package/dist/common/core/web/parseCSSValue.js +15 -0
  74. package/dist/common/css/index.js +26 -0
  75. package/dist/common/css/insets.js +64 -0
  76. package/dist/common/css/processFunctions.js +54 -0
  77. package/dist/common/css/themes.js +95 -0
  78. package/dist/common/css/variants.js +16 -0
  79. package/dist/common/hoc/index.js +16 -0
  80. package/dist/common/hoc/types.js +1 -0
  81. package/dist/common/hoc/withUniwind.js +95 -0
  82. package/dist/common/hoc/withUniwind.native.js +106 -0
  83. package/dist/common/hoc/withUniwindUtils.js +16 -0
  84. package/dist/common/hooks/index.js +49 -0
  85. package/dist/common/hooks/useCSSVariable/getVariableValue.js +19 -0
  86. package/dist/common/hooks/useCSSVariable/getVariableValue.native.js +9 -0
  87. package/dist/common/hooks/useCSSVariable/index.js +16 -0
  88. package/dist/common/hooks/useCSSVariable/useCSSVariable.js +58 -0
  89. package/dist/common/hooks/useResolveClassNames.js +22 -0
  90. package/dist/common/hooks/useResolveClassNames.native.js +29 -0
  91. package/dist/common/hooks/useUniwind.js +28 -0
  92. package/dist/common/hooks/useUniwindAccent.js +13 -0
  93. package/dist/common/hooks/useUniwindAccent.native.js +12 -0
  94. package/dist/common/index.js +38 -0
  95. package/dist/common/types.js +28 -0
  96. package/dist/common/utils/buildDtsFile.js +18 -0
  97. package/dist/common/utils/stringifyThemes.js +8 -0
  98. package/dist/common/vite/index.d.ts +9 -0
  99. package/dist/common/vite/index.js +16 -0
  100. package/dist/common/vite/vite.js +72 -0
  101. package/dist/metro/index.cjs +166 -0
  102. package/dist/metro/index.d.ts +15 -0
  103. package/dist/metro/index.mjs +158 -0
  104. package/dist/metro/metro-transformer.cjs +1565 -0
  105. package/dist/metro/metro-transformer.mjs +1558 -0
  106. package/dist/module/components/index.d.ts +0 -0
  107. package/dist/module/components/index.js +312 -0
  108. package/dist/module/components/native/ActivityIndicator.d.ts +3 -0
  109. package/dist/module/components/native/ActivityIndicator.js +18 -0
  110. package/dist/module/components/native/Button.d.ts +3 -0
  111. package/dist/module/components/native/Button.js +15 -0
  112. package/dist/module/components/native/FlatList.d.ts +3 -0
  113. package/dist/module/components/native/FlatList.js +27 -0
  114. package/dist/module/components/native/Image.d.ts +3 -0
  115. package/dist/module/components/native/Image.js +18 -0
  116. package/dist/module/components/native/ImageBackground.d.ts +3 -0
  117. package/dist/module/components/native/ImageBackground.js +20 -0
  118. package/dist/module/components/native/InputAccessoryView.d.ts +3 -0
  119. package/dist/module/components/native/InputAccessoryView.js +21 -0
  120. package/dist/module/components/native/KeyboardAvoidingView.d.ts +3 -0
  121. package/dist/module/components/native/KeyboardAvoidingView.js +17 -0
  122. package/dist/module/components/native/Modal.d.ts +3 -0
  123. package/dist/module/components/native/Modal.js +18 -0
  124. package/dist/module/components/native/Pressable.d.ts +3 -0
  125. package/dist/module/components/native/Pressable.js +29 -0
  126. package/dist/module/components/native/RefreshControl.d.ts +3 -0
  127. package/dist/module/components/native/RefreshControl.js +24 -0
  128. package/dist/module/components/native/SafeAreaView.d.ts +3 -0
  129. package/dist/module/components/native/SafeAreaView.js +15 -0
  130. package/dist/module/components/native/ScrollView.d.ts +3 -0
  131. package/dist/module/components/native/ScrollView.js +20 -0
  132. package/dist/module/components/native/SectionList.d.ts +3 -0
  133. package/dist/module/components/native/SectionList.js +24 -0
  134. package/dist/module/components/native/Switch.d.ts +3 -0
  135. package/dist/module/components/native/Switch.js +26 -0
  136. package/dist/module/components/native/Text.d.ts +3 -0
  137. package/dist/module/components/native/Text.js +33 -0
  138. package/dist/module/components/native/TextInput.d.ts +3 -0
  139. package/dist/module/components/native/TextInput.js +50 -0
  140. package/dist/module/components/native/TouchableHighlight.d.ts +3 -0
  141. package/dist/module/components/native/TouchableHighlight.js +32 -0
  142. package/dist/module/components/native/TouchableNativeFeedback.d.ts +3 -0
  143. package/dist/module/components/native/TouchableNativeFeedback.js +29 -0
  144. package/dist/module/components/native/TouchableOpacity.d.ts +3 -0
  145. package/dist/module/components/native/TouchableOpacity.js +29 -0
  146. package/dist/module/components/native/TouchableWithoutFeedback.d.ts +3 -0
  147. package/dist/module/components/native/TouchableWithoutFeedback.js +29 -0
  148. package/dist/module/components/native/View.d.ts +3 -0
  149. package/dist/module/components/native/View.js +15 -0
  150. package/dist/module/components/native/VirtualizedList.d.ts +3 -0
  151. package/dist/module/components/native/VirtualizedList.js +24 -0
  152. package/dist/module/components/native/useStyle.d.ts +2 -0
  153. package/dist/module/components/native/useStyle.js +22 -0
  154. package/dist/module/components/utils.d.ts +1 -0
  155. package/dist/module/components/utils.js +11 -0
  156. package/dist/module/components/web/ActivityIndicator.d.ts +3 -0
  157. package/dist/module/components/web/ActivityIndicator.js +17 -0
  158. package/dist/module/components/web/Button.d.ts +3 -0
  159. package/dist/module/components/web/Button.js +15 -0
  160. package/dist/module/components/web/FlatList.d.ts +3 -0
  161. package/dist/module/components/web/FlatList.js +19 -0
  162. package/dist/module/components/web/Image.d.ts +3 -0
  163. package/dist/module/components/web/Image.js +17 -0
  164. package/dist/module/components/web/ImageBackground.d.ts +3 -0
  165. package/dist/module/components/web/ImageBackground.js +18 -0
  166. package/dist/module/components/web/KeyboardAvoidingView.d.ts +3 -0
  167. package/dist/module/components/web/KeyboardAvoidingView.js +15 -0
  168. package/dist/module/components/web/Modal.d.ts +3 -0
  169. package/dist/module/components/web/Modal.js +14 -0
  170. package/dist/module/components/web/Pressable.d.ts +3 -0
  171. package/dist/module/components/web/Pressable.js +14 -0
  172. package/dist/module/components/web/RefreshControl.d.ts +3 -0
  173. package/dist/module/components/web/RefreshControl.js +14 -0
  174. package/dist/module/components/web/SafeAreaView.d.ts +3 -0
  175. package/dist/module/components/web/SafeAreaView.js +14 -0
  176. package/dist/module/components/web/ScrollView.d.ts +3 -0
  177. package/dist/module/components/web/ScrollView.js +15 -0
  178. package/dist/module/components/web/SectionList.d.ts +3 -0
  179. package/dist/module/components/web/SectionList.js +17 -0
  180. package/dist/module/components/web/Switch.d.ts +3 -0
  181. package/dist/module/components/web/Switch.js +20 -0
  182. package/dist/module/components/web/Text.d.ts +3 -0
  183. package/dist/module/components/web/Text.js +14 -0
  184. package/dist/module/components/web/TextInput.d.ts +3 -0
  185. package/dist/module/components/web/TextInput.js +14 -0
  186. package/dist/module/components/web/TouchableHighlight.d.ts +3 -0
  187. package/dist/module/components/web/TouchableHighlight.js +17 -0
  188. package/dist/module/components/web/TouchableNativeFeedback.d.ts +2 -0
  189. package/dist/module/components/web/TouchableNativeFeedback.js +2 -0
  190. package/dist/module/components/web/TouchableOpacity.d.ts +3 -0
  191. package/dist/module/components/web/TouchableOpacity.js +14 -0
  192. package/dist/module/components/web/TouchableWithoutFeedback.d.ts +3 -0
  193. package/dist/module/components/web/TouchableWithoutFeedback.js +14 -0
  194. package/dist/module/components/web/View.d.ts +3 -0
  195. package/dist/module/components/web/View.js +14 -0
  196. package/dist/module/components/web/VirtualizedList.d.ts +3 -0
  197. package/dist/module/components/web/VirtualizedList.js +17 -0
  198. package/dist/module/components/web/index.d.ts +22 -0
  199. package/dist/module/components/web/index.js +22 -0
  200. package/dist/module/components/web/metro-injected.d.ts +0 -0
  201. package/dist/module/components/web/metro-injected.js +0 -0
  202. package/dist/module/components/web/rnw.d.ts +2 -0
  203. package/dist/module/components/web/rnw.js +35 -0
  204. package/dist/module/core/config/config.common.d.ts +18 -0
  205. package/dist/module/core/config/config.common.js +74 -0
  206. package/dist/module/core/config/config.d.ts +11 -0
  207. package/dist/module/core/config/config.js +48 -0
  208. package/dist/module/core/config/config.native.d.ts +12 -0
  209. package/dist/module/core/config/config.native.js +61 -0
  210. package/dist/module/core/config/index.d.ts +1 -0
  211. package/dist/module/core/config/index.js +1 -0
  212. package/dist/module/core/index.d.ts +1 -0
  213. package/dist/module/core/index.js +1 -0
  214. package/dist/module/core/listener.d.ts +12 -0
  215. package/dist/module/core/listener.js +45 -0
  216. package/dist/module/core/logger.d.ts +5 -0
  217. package/dist/module/core/logger.js +11 -0
  218. package/dist/module/core/native/index.d.ts +2 -0
  219. package/dist/module/core/native/index.js +2 -0
  220. package/dist/module/core/native/native-utils.d.ts +4 -0
  221. package/dist/module/core/native/native-utils.js +27 -0
  222. package/dist/module/core/native/parsers/boxShadow.d.ts +1 -0
  223. package/dist/module/core/native/parsers/boxShadow.js +3 -0
  224. package/dist/module/core/native/parsers/fontVariant.d.ts +1 -0
  225. package/dist/module/core/native/parsers/fontVariant.js +1 -0
  226. package/dist/module/core/native/parsers/gradient.d.ts +8 -0
  227. package/dist/module/core/native/parsers/gradient.js +26 -0
  228. package/dist/module/core/native/parsers/index.d.ts +5 -0
  229. package/dist/module/core/native/parsers/index.js +5 -0
  230. package/dist/module/core/native/parsers/textShadow.d.ts +1 -0
  231. package/dist/module/core/native/parsers/textShadow.js +32 -0
  232. package/dist/module/core/native/parsers/transforms.d.ts +1 -0
  233. package/dist/module/core/native/parsers/transforms.js +48 -0
  234. package/dist/module/core/native/runtime.d.ts +2 -0
  235. package/dist/module/core/native/runtime.js +28 -0
  236. package/dist/module/core/native/store.d.ts +19 -0
  237. package/dist/module/core/native/store.js +172 -0
  238. package/dist/module/core/types.d.ts +73 -0
  239. package/dist/module/core/types.js +0 -0
  240. package/dist/module/core/web/cssListener.d.ts +19 -0
  241. package/dist/module/core/web/cssListener.js +137 -0
  242. package/dist/module/core/web/formatColor.d.ts +1 -0
  243. package/dist/module/core/web/formatColor.js +8 -0
  244. package/dist/module/core/web/getWebStyles.d.ts +2 -0
  245. package/dist/module/core/web/getWebStyles.js +49 -0
  246. package/dist/module/core/web/index.d.ts +4 -0
  247. package/dist/module/core/web/index.js +4 -0
  248. package/dist/module/core/web/parseCSSValue.d.ts +1 -0
  249. package/dist/module/core/web/parseCSSValue.js +8 -0
  250. package/dist/module/css/index.d.ts +1 -0
  251. package/dist/module/css/index.js +25 -0
  252. package/dist/module/css/insets.d.ts +1 -0
  253. package/dist/module/css/insets.js +63 -0
  254. package/dist/module/css/processFunctions.d.ts +2 -0
  255. package/dist/module/css/processFunctions.js +36 -0
  256. package/dist/module/css/themes.d.ts +1 -0
  257. package/dist/module/css/themes.js +97 -0
  258. package/dist/module/css/variants.d.ts +1 -0
  259. package/dist/module/css/variants.js +9 -0
  260. package/dist/module/hoc/index.d.ts +1 -0
  261. package/dist/module/hoc/index.js +1 -0
  262. package/dist/module/hoc/types.d.ts +27 -0
  263. package/dist/module/hoc/types.js +0 -0
  264. package/dist/module/hoc/withUniwind.d.ts +2 -0
  265. package/dist/module/hoc/withUniwind.js +76 -0
  266. package/dist/module/hoc/withUniwind.native.d.ts +2 -0
  267. package/dist/module/hoc/withUniwind.native.js +81 -0
  268. package/dist/module/hoc/withUniwindUtils.d.ts +5 -0
  269. package/dist/module/hoc/withUniwindUtils.js +5 -0
  270. package/dist/module/hooks/index.d.ts +4 -0
  271. package/dist/module/hooks/index.js +4 -0
  272. package/dist/module/hooks/useCSSVariable/getVariableValue.d.ts +1 -0
  273. package/dist/module/hooks/useCSSVariable/getVariableValue.js +12 -0
  274. package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -0
  275. package/dist/module/hooks/useCSSVariable/getVariableValue.native.js +2 -0
  276. package/dist/module/hooks/useCSSVariable/index.d.ts +1 -0
  277. package/dist/module/hooks/useCSSVariable/index.js +1 -0
  278. package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +13 -0
  279. package/dist/module/hooks/useCSSVariable/useCSSVariable.js +56 -0
  280. package/dist/module/hooks/useResolveClassNames.d.ts +2 -0
  281. package/dist/module/hooks/useResolveClassNames.js +18 -0
  282. package/dist/module/hooks/useResolveClassNames.native.d.ts +2 -0
  283. package/dist/module/hooks/useResolveClassNames.native.js +22 -0
  284. package/dist/module/hooks/useUniwind.d.ts +5 -0
  285. package/dist/module/hooks/useUniwind.js +21 -0
  286. package/dist/module/hooks/useUniwindAccent.d.ts +1 -0
  287. package/dist/module/hooks/useUniwindAccent.js +6 -0
  288. package/dist/module/hooks/useUniwindAccent.native.d.ts +2 -0
  289. package/dist/module/hooks/useUniwindAccent.native.js +5 -0
  290. package/dist/module/index.d.ts +5 -0
  291. package/dist/module/index.js +3 -0
  292. package/dist/module/types.d.ts +21 -0
  293. package/dist/module/types.js +22 -0
  294. package/dist/module/utils/buildDtsFile.d.ts +1 -0
  295. package/dist/module/utils/buildDtsFile.js +22 -0
  296. package/dist/module/utils/stringifyThemes.d.ts +1 -0
  297. package/dist/module/utils/stringifyThemes.js +1 -0
  298. package/dist/module/vite/index.d.ts +9 -0
  299. package/dist/module/vite/index.js +1 -0
  300. package/dist/module/vite/vite.d.ts +8 -0
  301. package/dist/module/vite/vite.js +73 -0
  302. package/dist/shared/uniwind.BZIuaszw.cjs +11 -0
  303. package/dist/shared/uniwind.BgZDHdUR.cjs +81 -0
  304. package/dist/shared/uniwind.Bt3kqZo6.mjs +290 -0
  305. package/dist/shared/uniwind.CyoRUwOj.mjs +9 -0
  306. package/dist/shared/uniwind.D3fvrgEG.mjs +68 -0
  307. package/dist/shared/uniwind.D_6s2EM-.cjs +301 -0
  308. package/dist/vite/index.cjs +80 -0
  309. package/dist/vite/index.d.ts +9 -0
  310. package/dist/vite/index.mjs +74 -0
  311. package/metro/package.json +3 -0
  312. package/package.json +106 -0
  313. package/readme.md +71 -0
  314. package/src/components/index.ts +313 -0
  315. package/src/components/native/ActivityIndicator.tsx +19 -0
  316. package/src/components/native/Button.tsx +16 -0
  317. package/src/components/native/FlatList.tsx +28 -0
  318. package/src/components/native/Image.tsx +19 -0
  319. package/src/components/native/ImageBackground.tsx +21 -0
  320. package/src/components/native/InputAccessoryView.tsx +23 -0
  321. package/src/components/native/KeyboardAvoidingView.tsx +18 -0
  322. package/src/components/native/Modal.tsx +19 -0
  323. package/src/components/native/Pressable.tsx +31 -0
  324. package/src/components/native/RefreshControl.tsx +25 -0
  325. package/src/components/native/SafeAreaView.tsx +16 -0
  326. package/src/components/native/ScrollView.tsx +21 -0
  327. package/src/components/native/SectionList.tsx +25 -0
  328. package/src/components/native/Switch.tsx +28 -0
  329. package/src/components/native/Text.tsx +39 -0
  330. package/src/components/native/TextInput.tsx +52 -0
  331. package/src/components/native/TouchableHighlight.tsx +34 -0
  332. package/src/components/native/TouchableNativeFeedback.tsx +31 -0
  333. package/src/components/native/TouchableOpacity.tsx +31 -0
  334. package/src/components/native/TouchableWithoutFeedback.tsx +31 -0
  335. package/src/components/native/View.tsx +16 -0
  336. package/src/components/native/VirtualizedList.tsx +25 -0
  337. package/src/components/native/useStyle.ts +33 -0
  338. package/src/components/utils.ts +16 -0
  339. package/src/components/web/ActivityIndicator.tsx +18 -0
  340. package/src/components/web/Button.tsx +16 -0
  341. package/src/components/web/FlatList.tsx +20 -0
  342. package/src/components/web/Image.tsx +18 -0
  343. package/src/components/web/ImageBackground.tsx +19 -0
  344. package/src/components/web/KeyboardAvoidingView.tsx +15 -0
  345. package/src/components/web/Modal.tsx +14 -0
  346. package/src/components/web/Pressable.tsx +14 -0
  347. package/src/components/web/RefreshControl.tsx +14 -0
  348. package/src/components/web/SafeAreaView.tsx +14 -0
  349. package/src/components/web/ScrollView.tsx +15 -0
  350. package/src/components/web/SectionList.tsx +17 -0
  351. package/src/components/web/Switch.tsx +21 -0
  352. package/src/components/web/Text.tsx +14 -0
  353. package/src/components/web/TextInput.tsx +14 -0
  354. package/src/components/web/TouchableHighlight.tsx +18 -0
  355. package/src/components/web/TouchableNativeFeedback.tsx +2 -0
  356. package/src/components/web/TouchableOpacity.tsx +14 -0
  357. package/src/components/web/TouchableWithoutFeedback.tsx +14 -0
  358. package/src/components/web/View.tsx +14 -0
  359. package/src/components/web/VirtualizedList.tsx +17 -0
  360. package/src/components/web/index.ts +22 -0
  361. package/src/components/web/metro-injected.ts +1 -0
  362. package/src/components/web/rnw.ts +52 -0
  363. package/src/core/config/config.common.ts +98 -0
  364. package/src/core/config/config.native.ts +79 -0
  365. package/src/core/config/config.ts +64 -0
  366. package/src/core/config/index.ts +1 -0
  367. package/src/core/index.ts +1 -0
  368. package/src/core/listener.ts +59 -0
  369. package/src/core/logger.ts +15 -0
  370. package/src/core/native/index.ts +2 -0
  371. package/src/core/native/native-utils.ts +41 -0
  372. package/src/core/native/parsers/boxShadow.ts +7 -0
  373. package/src/core/native/parsers/fontVariant.ts +3 -0
  374. package/src/core/native/parsers/gradient.ts +39 -0
  375. package/src/core/native/parsers/index.ts +5 -0
  376. package/src/core/native/parsers/textShadow.ts +37 -0
  377. package/src/core/native/parsers/transforms.ts +64 -0
  378. package/src/core/native/runtime.ts +32 -0
  379. package/src/core/native/store.ts +238 -0
  380. package/src/core/types.ts +92 -0
  381. package/src/core/web/cssListener.ts +185 -0
  382. package/src/core/web/formatColor.ts +13 -0
  383. package/src/core/web/getWebStyles.ts +76 -0
  384. package/src/core/web/index.ts +4 -0
  385. package/src/core/web/parseCSSValue.ts +10 -0
  386. package/src/css/index.ts +32 -0
  387. package/src/css/insets.ts +73 -0
  388. package/src/css/processFunctions.ts +39 -0
  389. package/src/css/themes.ts +130 -0
  390. package/src/css/variants.ts +11 -0
  391. package/src/hoc/index.ts +1 -0
  392. package/src/hoc/types.ts +45 -0
  393. package/src/hoc/withUniwind.native.tsx +118 -0
  394. package/src/hoc/withUniwind.tsx +115 -0
  395. package/src/hoc/withUniwindUtils.ts +10 -0
  396. package/src/hooks/index.ts +4 -0
  397. package/src/hooks/useCSSVariable/getVariableValue.native.ts +3 -0
  398. package/src/hooks/useCSSVariable/getVariableValue.ts +19 -0
  399. package/src/hooks/useCSSVariable/index.ts +1 -0
  400. package/src/hooks/useCSSVariable/useCSSVariable.ts +89 -0
  401. package/src/hooks/useResolveClassNames.native.ts +29 -0
  402. package/src/hooks/useResolveClassNames.ts +26 -0
  403. package/src/hooks/useUniwind.ts +26 -0
  404. package/src/hooks/useUniwindAccent.native.ts +8 -0
  405. package/src/hooks/useUniwindAccent.ts +10 -0
  406. package/src/index.ts +5 -0
  407. package/src/metro/addMetaToStylesTemplate.ts +152 -0
  408. package/src/metro/compileVirtual.ts +74 -0
  409. package/src/metro/index.d.ts +15 -0
  410. package/src/metro/index.ts +1 -0
  411. package/src/metro/injectThemes.ts +23 -0
  412. package/src/metro/logger.ts +44 -0
  413. package/src/metro/metro-css-patches.ts +57 -0
  414. package/src/metro/metro-transformer.ts +99 -0
  415. package/src/metro/polyfillWeb.ts +14 -0
  416. package/src/metro/processor/color.ts +76 -0
  417. package/src/metro/processor/css.ts +541 -0
  418. package/src/metro/processor/functions.ts +199 -0
  419. package/src/metro/processor/index.ts +1 -0
  420. package/src/metro/processor/mq.ts +82 -0
  421. package/src/metro/processor/processor.ts +249 -0
  422. package/src/metro/processor/rn.ts +277 -0
  423. package/src/metro/processor/units.ts +58 -0
  424. package/src/metro/processor/var.ts +18 -0
  425. package/src/metro/resolvers.ts +101 -0
  426. package/src/metro/types.ts +74 -0
  427. package/src/metro/utils/common.ts +103 -0
  428. package/src/metro/utils/index.ts +2 -0
  429. package/src/metro/utils/serialize.ts +116 -0
  430. package/src/metro/withUniwindConfig.ts +60 -0
  431. package/src/types.ts +24 -0
  432. package/src/utils/buildDtsFile.ts +27 -0
  433. package/src/utils/stringifyThemes.ts +1 -0
  434. package/src/vite/index.d.ts +9 -0
  435. package/src/vite/index.ts +1 -0
  436. package/src/vite/vite.ts +86 -0
  437. package/types.d.ts +109 -0
  438. package/uniwind.css +262 -0
  439. package/vite/package.json +3 -0
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.colorMix = exports.cloneWithAccessors = void 0;
7
+ exports.lightDark = lightDark;
8
+ var _culori = require("culori");
9
+ const colorMix = (color, weight, mixColor) => {
10
+ const parsedWeight = typeof weight === "string" ? parseFloat(weight) / 100 : weight;
11
+ if (mixColor === "#00000000") {
12
+ const parsedColor = (0, _culori.parse)(color);
13
+ if (parsedColor === void 0) {
14
+ return color;
15
+ }
16
+ return (0, _culori.formatHex8)({
17
+ ...parsedColor,
18
+ alpha: parsedWeight * (parsedColor.alpha ?? 1)
19
+ });
20
+ }
21
+ return (0, _culori.formatHex)((0, _culori.interpolate)([mixColor, color])(parsedWeight));
22
+ };
23
+ exports.colorMix = colorMix;
24
+ function lightDark(light, dark) {
25
+ if (this.currentThemeName === "dark") {
26
+ return dark;
27
+ }
28
+ return light;
29
+ }
30
+ const cloneWithAccessors = obj => {
31
+ const proto = Object.getPrototypeOf(obj);
32
+ const clone = Object.create(proto);
33
+ Object.defineProperties(clone, Object.getOwnPropertyDescriptors(obj));
34
+ return clone;
35
+ };
36
+ exports.cloneWithAccessors = cloneWithAccessors;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseBoxShadow = void 0;
7
+ const boxShadowRegex = /(?<![#\w.-])[+-]?(?:\d*\.\d+|\d+)(?![\w-])/g;
8
+ const undefinedRegex = /undefined/g;
9
+ const parseBoxShadow = boxShadow => boxShadow.replace(boxShadowRegex, match => `${match}px`).replace(undefinedRegex, "");
10
+ exports.parseBoxShadow = parseBoxShadow;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseFontVariant = void 0;
7
+ const parseFontVariant = fontVariant => fontVariant.split(" ").filter(token => token !== "undefined");
8
+ exports.parseFontVariant = parseFontVariant;
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.resolveGradient = void 0;
7
+ const gradientDirectionTokens = /* @__PURE__ */new Set(["to", "top", "right", "bottom", "left"]);
8
+ const resolveGradient = value => {
9
+ const tokens = value.split(", ");
10
+ const directionToken = tokens.find(token => token.includes("to") || token.includes("deg"));
11
+ const filtered = tokens.filter(token => token !== directionToken);
12
+ const colorStops = filtered.map(token => {
13
+ const [color, position] = token.split(" ");
14
+ return {
15
+ color,
16
+ positions: position !== void 0 ? [position] : void 0
17
+ };
18
+ });
19
+ const direction = directionToken?.split(" ").reduce((acc, token) => {
20
+ if (gradientDirectionTokens.has(token) || token.includes("deg")) {
21
+ return `${acc} ${token.replace(",", "")}`;
22
+ }
23
+ return acc;
24
+ }, "").trim();
25
+ return [{
26
+ colorStops,
27
+ type: "linear-gradient",
28
+ direction
29
+ }];
30
+ };
31
+ exports.resolveGradient = resolveGradient;
@@ -0,0 +1,60 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _boxShadow = require("./boxShadow");
7
+ Object.keys(_boxShadow).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _boxShadow[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _boxShadow[key];
14
+ }
15
+ });
16
+ });
17
+ var _fontVariant = require("./fontVariant");
18
+ Object.keys(_fontVariant).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _fontVariant[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _fontVariant[key];
25
+ }
26
+ });
27
+ });
28
+ var _gradient = require("./gradient");
29
+ Object.keys(_gradient).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (key in exports && exports[key] === _gradient[key]) return;
32
+ Object.defineProperty(exports, key, {
33
+ enumerable: true,
34
+ get: function () {
35
+ return _gradient[key];
36
+ }
37
+ });
38
+ });
39
+ var _textShadow = require("./textShadow");
40
+ Object.keys(_textShadow).forEach(function (key) {
41
+ if (key === "default" || key === "__esModule") return;
42
+ if (key in exports && exports[key] === _textShadow[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _textShadow[key];
47
+ }
48
+ });
49
+ });
50
+ var _transforms = require("./transforms");
51
+ Object.keys(_transforms).forEach(function (key) {
52
+ if (key === "default" || key === "__esModule") return;
53
+ if (key in exports && exports[key] === _transforms[key]) return;
54
+ Object.defineProperty(exports, key, {
55
+ enumerable: true,
56
+ get: function () {
57
+ return _transforms[key];
58
+ }
59
+ });
60
+ });
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseTextShadowMutation = void 0;
7
+ const parseTextShadowMutation = styles => {
8
+ const tokens = styles.textShadow.replace(/,/g, "").split(" ");
9
+ if (tokens.length === 0) {
10
+ return;
11
+ }
12
+ const color = tokens.find(token => token.startsWith("#")) ?? "#000000";
13
+ const offsets = tokens.filter(token => token !== color);
14
+ const [offsetX, offsetY, radius] = offsets;
15
+ if (offsetX !== void 0 && offsetY !== void 0) {
16
+ Object.defineProperty(styles, "textShadowOffset", {
17
+ configurable: true,
18
+ enumerable: true,
19
+ value: {
20
+ width: Number(offsetX),
21
+ height: Number(offsetY)
22
+ }
23
+ });
24
+ delete styles.textShadow;
25
+ }
26
+ if (radius !== void 0) {
27
+ Object.defineProperty(styles, "textShadowRadius", {
28
+ configurable: true,
29
+ enumerable: true,
30
+ value: Number(radius)
31
+ });
32
+ }
33
+ Object.defineProperty(styles, "textShadowColor", {
34
+ configurable: true,
35
+ enumerable: true,
36
+ value: color
37
+ });
38
+ };
39
+ exports.parseTextShadowMutation = parseTextShadowMutation;
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseTransformsMutation = void 0;
7
+ const transforms = ["translateX", "translateY", "translateZ", "rotate", "rotateX", "rotateY", "rotateZ", "scale", "scaleX", "scaleY", "scaleZ", "skewX", "skewY", "perspective"];
8
+ const processTransform = (transform, value) => {
9
+ if (transform.startsWith("scale") && typeof value === "string") {
10
+ return parseFloat(value.replace("%", "")) / 100;
11
+ }
12
+ return value;
13
+ };
14
+ const parseTransformsMutation = styles => {
15
+ const transformTokens = typeof styles.transform === "string" ? styles.transform.split(" ").filter(token => token !== "undefined") : [];
16
+ const transformsResult = [];
17
+ for (const transform of transforms) {
18
+ if (transformTokens.length > 0) {
19
+ for (const token of transformTokens) {
20
+ if (!token.startsWith(transform)) {
21
+ continue;
22
+ }
23
+ const transformValue = token.slice(transform.length + 1, -1);
24
+ transformsResult.push({
25
+ [transform]: processTransform(transform, transformValue)
26
+ });
27
+ }
28
+ }
29
+ if (styles[transform] !== void 0) {
30
+ transformsResult.push({
31
+ [transform]: processTransform(transform, styles[transform])
32
+ });
33
+ delete styles[transform];
34
+ }
35
+ }
36
+ if (transformsResult.length > 0) {
37
+ Object.defineProperty(styles, "transform", {
38
+ configurable: true,
39
+ enumerable: true,
40
+ value: transformsResult
41
+ });
42
+ }
43
+ };
44
+ exports.parseTransformsMutation = parseTransformsMutation;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UniwindRuntime = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _types = require("../../types");
9
+ var _nativeUtils = require("./native-utils");
10
+ const window = _reactNative.Dimensions.get("window");
11
+ const initialColorScheme = _reactNative.Appearance.getColorScheme() ?? _types.ColorScheme.Light;
12
+ const UniwindRuntime = exports.UniwindRuntime = {
13
+ screen: {
14
+ width: window.width,
15
+ height: window.height
16
+ },
17
+ colorScheme: initialColorScheme,
18
+ currentThemeName: initialColorScheme,
19
+ orientation: window.width > window.height ? _types.Orientation.Landscape : _types.Orientation.Portrait,
20
+ fontScale: value => value * _reactNative.PixelRatio.getFontScale(),
21
+ hairlineWidth: _reactNative.StyleSheet.hairlineWidth,
22
+ rtl: _reactNative.I18nManager.isRTL,
23
+ insets: {
24
+ top: 0,
25
+ left: 0,
26
+ bottom: 0,
27
+ right: 0
28
+ },
29
+ colorMix: _nativeUtils.colorMix,
30
+ pixelRatio: value => value * _reactNative.PixelRatio.get(),
31
+ cubicBezier: () => "",
32
+ lightDark: () => ""
33
+ };
34
+ UniwindRuntime.lightDark = _nativeUtils.lightDark.bind(UniwindRuntime);
@@ -0,0 +1,181 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UniwindStore = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _types = require("../../types");
9
+ var _listener = require("../listener");
10
+ var _nativeUtils = require("./native-utils");
11
+ var _parsers = require("./parsers");
12
+ var _runtime = require("./runtime");
13
+ class UniwindStoreBuilder {
14
+ runtime = _runtime.UniwindRuntime;
15
+ vars = {};
16
+ runtimeThemeVariables = /* @__PURE__ */new Map();
17
+ stylesheet = {};
18
+ cache = /* @__PURE__ */new Map();
19
+ generateStyleSheetCallbackResult = null;
20
+ getStyles(className, state) {
21
+ if (className === void 0 || className === "") {
22
+ return {
23
+ styles: {},
24
+ dependencies: []
25
+ };
26
+ }
27
+ const cacheKey = `${className}${state?.isDisabled ?? false}${state?.isFocused ?? false}${state?.isPressed ?? false}`;
28
+ if (this.cache.has(cacheKey)) {
29
+ return this.cache.get(cacheKey);
30
+ }
31
+ const result = this.resolveStyles(className, state);
32
+ this.cache.set(cacheKey, result);
33
+ _listener.UniwindListener.subscribe(() => this.cache.delete(cacheKey), result.dependencies, {
34
+ once: true
35
+ });
36
+ return result;
37
+ }
38
+ reinit = generateStyleSheetCallback => {
39
+ const config = generateStyleSheetCallback?.(this.runtime) ?? this.generateStyleSheetCallbackResult;
40
+ if (!config) {
41
+ return;
42
+ }
43
+ const {
44
+ scopedVars,
45
+ stylesheet,
46
+ vars
47
+ } = config;
48
+ this.generateStyleSheetCallbackResult = config;
49
+ this.stylesheet = stylesheet;
50
+ this.vars = vars;
51
+ const themeVars = scopedVars[`__uniwind-theme-${this.runtime.currentThemeName}`];
52
+ const platformVars = scopedVars[`__uniwind-platform-${_reactNative.Platform.OS}`];
53
+ const runtimeThemeVars = this.runtimeThemeVariables.get(this.runtime.currentThemeName);
54
+ if (themeVars) {
55
+ Object.defineProperties(this.vars, Object.getOwnPropertyDescriptors(themeVars));
56
+ }
57
+ if (platformVars) {
58
+ Object.defineProperties(this.vars, Object.getOwnPropertyDescriptors(platformVars));
59
+ }
60
+ if (runtimeThemeVars) {
61
+ Object.defineProperties(this.vars, Object.getOwnPropertyDescriptors(runtimeThemeVars));
62
+ }
63
+ if (__DEV__ && generateStyleSheetCallback) {
64
+ _listener.UniwindListener.notifyAll();
65
+ }
66
+ };
67
+ resolveStyles(classNames, state) {
68
+ const result = {};
69
+ let vars = this.vars;
70
+ const dependencies = /* @__PURE__ */new Set();
71
+ const bestBreakpoints = /* @__PURE__ */new Map();
72
+ for (const className of classNames.split(" ")) {
73
+ if (!(className in this.stylesheet)) {
74
+ continue;
75
+ }
76
+ for (const style of this.stylesheet[className]) {
77
+ if (style.dependencies) {
78
+ style.dependencies.forEach(dep => dependencies.add(dep));
79
+ }
80
+ if (style.minWidth > this.runtime.screen.width || style.maxWidth < this.runtime.screen.width || style.theme !== null && this.runtime.currentThemeName !== style.theme || style.orientation !== null && this.runtime.orientation !== style.orientation || style.rtl !== null && this.runtime.rtl !== style.rtl || style.active !== null && state?.isPressed !== style.active || style.focus !== null && state?.isFocused !== style.focus || style.disabled !== null && state?.isDisabled !== style.disabled) {
81
+ continue;
82
+ }
83
+ for (const [property, valueGetter] of style.entries) {
84
+ const previousBest = bestBreakpoints.get(property);
85
+ if (previousBest && (previousBest.minWidth > style.minWidth || previousBest.complexity > style.complexity || previousBest.importantProperties.includes(property))) {
86
+ continue;
87
+ }
88
+ if (property[0] === "-") {
89
+ if (vars === this.vars) {
90
+ vars = (0, _nativeUtils.cloneWithAccessors)(this.vars);
91
+ }
92
+ Object.defineProperty(vars, property, {
93
+ configurable: true,
94
+ enumerable: true,
95
+ get: valueGetter
96
+ });
97
+ } else {
98
+ Object.defineProperty(result, property, {
99
+ configurable: true,
100
+ enumerable: true,
101
+ get: () => valueGetter.call(vars)
102
+ });
103
+ }
104
+ bestBreakpoints.set(property, style);
105
+ }
106
+ }
107
+ }
108
+ if (result.lineHeight !== void 0 && result.lineHeight < 6) {
109
+ Object.defineProperty(result, "lineHeight", {
110
+ value: result.fontSize * result.lineHeight,
111
+ configurable: true,
112
+ enumerable: true
113
+ });
114
+ }
115
+ if (result.boxShadow !== void 0) {
116
+ Object.defineProperty(result, "boxShadow", {
117
+ value: (0, _parsers.parseBoxShadow)(result.boxShadow),
118
+ configurable: true,
119
+ enumerable: true
120
+ });
121
+ }
122
+ if (result.visibility === "hidden") {
123
+ Object.defineProperty(result, "display", {
124
+ value: "none",
125
+ configurable: true,
126
+ enumerable: true
127
+ });
128
+ }
129
+ if (result.borderStyle !== void 0 && result.borderColor === void 0) {
130
+ Object.defineProperty(result, "borderColor", {
131
+ value: "#000000",
132
+ configurable: true,
133
+ enumerable: true
134
+ });
135
+ }
136
+ if (result.outlineStyle !== void 0 && result.outlineColor === void 0) {
137
+ Object.defineProperty(result, "outlineColor", {
138
+ value: "#000000",
139
+ configurable: true,
140
+ enumerable: true
141
+ });
142
+ }
143
+ if (result.fontVariant !== void 0) {
144
+ Object.defineProperty(result, "fontVariant", {
145
+ value: (0, _parsers.parseFontVariant)(result.fontVariant),
146
+ configurable: true,
147
+ enumerable: true
148
+ });
149
+ }
150
+ (0, _parsers.parseTransformsMutation)(result);
151
+ if (result.experimental_backgroundImage !== void 0) {
152
+ Object.defineProperty(result, "experimental_backgroundImage", {
153
+ value: (0, _parsers.resolveGradient)(result.experimental_backgroundImage),
154
+ configurable: true,
155
+ enumerable: true
156
+ });
157
+ }
158
+ if (result.textShadow !== void 0) {
159
+ (0, _parsers.parseTextShadowMutation)(result);
160
+ }
161
+ return {
162
+ styles: {
163
+ ...result
164
+ },
165
+ dependencies: Array.from(dependencies)
166
+ };
167
+ }
168
+ }
169
+ const UniwindStore = exports.UniwindStore = new UniwindStoreBuilder();
170
+ _reactNative.Dimensions.addEventListener("change", ({
171
+ window
172
+ }) => {
173
+ const newOrientation = window.width > window.height ? _types.Orientation.Landscape : _types.Orientation.Portrait;
174
+ const orientationChanged = UniwindStore.runtime.orientation !== newOrientation;
175
+ UniwindStore.runtime.screen = {
176
+ width: window.width,
177
+ height: window.height
178
+ };
179
+ UniwindStore.runtime.orientation = newOrientation;
180
+ _listener.UniwindListener.notify([...(orientationChanged ? [_types.StyleDependency.Orientation] : []), _types.StyleDependency.Dimensions]);
181
+ });
@@ -0,0 +1 @@
1
+ "use strict";
@@ -0,0 +1,146 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CSSListener = void 0;
7
+ var _types = require("../../types");
8
+ var _listener = require("../listener");
9
+ class CSSListenerBuilder {
10
+ classNameMediaQueryListeners = /* @__PURE__ */new Map();
11
+ listeners = /* @__PURE__ */new Map();
12
+ registeredRules = /* @__PURE__ */new Map();
13
+ processedStyleSheets = /* @__PURE__ */new WeakSet();
14
+ pendingInitialization = void 0;
15
+ constructor() {
16
+ if (typeof document === "undefined") {
17
+ return;
18
+ }
19
+ const observer = new MutationObserver(mutations => {
20
+ for (const mutation of mutations) {
21
+ if (mutation.type === "childList") {
22
+ this.scheduleInitialization();
23
+ }
24
+ }
25
+ });
26
+ this.initialize();
27
+ observer.observe(document.head, {
28
+ childList: true,
29
+ subtree: false,
30
+ attributes: true,
31
+ attributeFilter: ["disabled", "media", "title", "href", "rel"]
32
+ });
33
+ }
34
+ subscribeToClassName(classNames, listener) {
35
+ const disposables = [];
36
+ classNames.split(" ").forEach(className => {
37
+ const mediaQuery = this.classNameMediaQueryListeners.get(className);
38
+ if (!mediaQuery) {
39
+ return () => {};
40
+ }
41
+ const listeners = this.listeners.get(mediaQuery);
42
+ listeners?.add(listener);
43
+ disposables.push(() => listeners?.delete(listener));
44
+ });
45
+ const disposeThemeListener = _listener.UniwindListener.subscribe(listener, [_types.StyleDependency.Theme]);
46
+ return () => {
47
+ disposables.forEach(disposable => disposable());
48
+ disposeThemeListener();
49
+ };
50
+ }
51
+ scheduleInitialization() {
52
+ this.cancelPendingInitialization();
53
+ if (typeof requestIdleCallback !== "undefined") {
54
+ this.pendingInitialization = requestIdleCallback(() => {
55
+ this.initialize();
56
+ }, {
57
+ timeout: 50
58
+ });
59
+ return;
60
+ }
61
+ this.pendingInitialization = setTimeout(() => {
62
+ this.initialize();
63
+ }, 50);
64
+ }
65
+ cancelPendingInitialization() {
66
+ if (this.pendingInitialization !== void 0) {
67
+ if (typeof cancelIdleCallback !== "undefined") {
68
+ cancelIdleCallback(this.pendingInitialization);
69
+ } else {
70
+ clearTimeout(this.pendingInitialization);
71
+ }
72
+ this.pendingInitialization = void 0;
73
+ }
74
+ }
75
+ initialize() {
76
+ this.pendingInitialization = void 0;
77
+ for (const sheet of Array.from(document.styleSheets)) {
78
+ if (this.processedStyleSheets.has(sheet)) {
79
+ continue;
80
+ }
81
+ let rules;
82
+ try {
83
+ rules = sheet.cssRules;
84
+ } catch {
85
+ continue;
86
+ }
87
+ if (!rules) {
88
+ continue;
89
+ }
90
+ this.processedStyleSheets.add(sheet);
91
+ this.addMediaQueriesDeep(rules);
92
+ }
93
+ }
94
+ isStyleRule(rule) {
95
+ return rule.constructor.name === "CSSStyleRule";
96
+ }
97
+ isMediaRule(rule) {
98
+ return rule.constructor.name === "CSSMediaRule";
99
+ }
100
+ collectParentMediaQueries(rule, acc = []) {
101
+ const {
102
+ parentRule
103
+ } = rule;
104
+ if (!parentRule) {
105
+ return [];
106
+ }
107
+ if (this.isMediaRule(parentRule)) {
108
+ acc.push(parentRule);
109
+ }
110
+ const result = this.collectParentMediaQueries(parentRule, acc);
111
+ acc.push(...result);
112
+ return Array.from(new Set(acc));
113
+ }
114
+ addMediaQueriesDeep(rules) {
115
+ for (const rule of Array.from(rules)) {
116
+ if (this.isStyleRule(rule)) {
117
+ const mediaQueries = this.collectParentMediaQueries(rule);
118
+ if (mediaQueries.length > 0) {
119
+ this.addMediaQuery(mediaQueries, rule.selectorText);
120
+ }
121
+ continue;
122
+ }
123
+ if ("cssRules" in rule && rule.cssRules instanceof CSSRuleList) {
124
+ this.addMediaQueriesDeep(rule.cssRules);
125
+ continue;
126
+ }
127
+ }
128
+ }
129
+ addMediaQuery(mediaQueries, className) {
130
+ const rules = mediaQueries.map(mediaQuery => mediaQuery.conditionText).sort().join(" and ");
131
+ const parsedClassName = className.replace(".", "").replace("\\", "");
132
+ const cachedMediaQueryList = this.registeredRules.get(rules);
133
+ if (cachedMediaQueryList) {
134
+ this.classNameMediaQueryListeners.set(parsedClassName, cachedMediaQueryList);
135
+ return;
136
+ }
137
+ const mediaQueryList = window.matchMedia(rules);
138
+ this.registeredRules.set(rules, mediaQueryList);
139
+ this.listeners.set(mediaQueryList, /* @__PURE__ */new Set());
140
+ this.classNameMediaQueryListeners.set(parsedClassName, mediaQueryList);
141
+ mediaQueryList.addEventListener("change", () => {
142
+ this.listeners.get(mediaQueryList).forEach(listener => listener());
143
+ });
144
+ }
145
+ }
146
+ const CSSListener = exports.CSSListener = new CSSListenerBuilder();
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.formatColor = void 0;
7
+ var _culori = require("culori");
8
+ const formatColor = color => {
9
+ const parsedColor = (0, _culori.parse)(color);
10
+ if (!parsedColor) {
11
+ return color;
12
+ }
13
+ return parsedColor.alpha !== void 0 && parsedColor.alpha !== 1 ? (0, _culori.formatHex8)(parsedColor) : (0, _culori.formatHex)(parsedColor);
14
+ };
15
+ exports.formatColor = formatColor;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getWebStyles = void 0;
7
+ var _parseCSSValue = require("./parseCSSValue");
8
+ const dummy = typeof document !== "undefined" ? Object.assign(document.createElement("div"), {
9
+ style: "display: none"
10
+ }) : null;
11
+ if (dummy) {
12
+ document.body.appendChild(dummy);
13
+ }
14
+ const getComputedStyles = () => {
15
+ if (!dummy) {
16
+ return {};
17
+ }
18
+ const computedStyles = window.getComputedStyle(dummy);
19
+ const styles = {};
20
+ for (let i = 0; i < computedStyles.length; i++) {
21
+ const prop = computedStyles[i];
22
+ styles[prop] = computedStyles.getPropertyValue(prop);
23
+ }
24
+ return styles;
25
+ };
26
+ const initialStyles = typeof document !== "undefined" ? getComputedStyles() : {};
27
+ const getObjectDifference = (obj1, obj2) => {
28
+ const diff = {};
29
+ const keys = Object.keys(obj2);
30
+ keys.forEach(key => {
31
+ if (obj2[key] !== obj1[key]) {
32
+ diff[key] = obj2[key];
33
+ }
34
+ });
35
+ return diff;
36
+ };
37
+ const getWebStyles = className => {
38
+ if (className === void 0) {
39
+ return {};
40
+ }
41
+ if (!dummy) {
42
+ return {};
43
+ }
44
+ dummy.className = className;
45
+ const computedStyles = getObjectDifference(initialStyles, getComputedStyles());
46
+ return Object.fromEntries(Object.entries(computedStyles).map(([key, value]) => {
47
+ const parsedKey = key[0] === "-" ? key : key.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
48
+ return [parsedKey, (0, _parseCSSValue.parseCSSValue)(value)];
49
+ }));
50
+ };
51
+ exports.getWebStyles = getWebStyles;