react-native-unistyles 1.1.6 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (394) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +30 -38
  3. package/android/CMakeLists.txt +27 -0
  4. package/android/build.gradle +75 -0
  5. package/android/src/main/cxx/cpp-adapter.cpp +132 -0
  6. package/android/src/main/java/com/unistyles/UnistylesModule.kt +189 -0
  7. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
  8. package/cxx/UnistylesRuntime.cpp +318 -0
  9. package/cxx/UnistylesRuntime.h +74 -0
  10. package/ios/UnistylesHelpers.h +3 -0
  11. package/ios/UnistylesHelpers.mm +5 -0
  12. package/ios/UnistylesModule.h +16 -0
  13. package/ios/UnistylesModule.mm +138 -0
  14. package/ios/platform/Platform_iOS.h +21 -0
  15. package/ios/platform/Platform_iOS.mm +132 -0
  16. package/ios/platform/Platform_macOS.h +20 -0
  17. package/ios/platform/Platform_macOS.mm +83 -0
  18. package/lib/commonjs/common.js +60 -0
  19. package/lib/commonjs/common.js.map +1 -0
  20. package/lib/commonjs/core/UnistyleRegistry.js +94 -0
  21. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
  22. package/lib/commonjs/core/Unistyles.js +32 -0
  23. package/lib/commonjs/core/Unistyles.js.map +1 -0
  24. package/lib/commonjs/core/UnistylesModule.js +197 -0
  25. package/lib/commonjs/core/UnistylesModule.js.map +1 -0
  26. package/lib/commonjs/core/UnistylesModule.native.js +9 -0
  27. package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
  28. package/lib/commonjs/core/UnistylesRuntime.js +140 -0
  29. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
  30. package/lib/commonjs/core/index.js +13 -0
  31. package/lib/commonjs/core/index.js.map +1 -0
  32. package/lib/commonjs/createStyleSheet.js +14 -0
  33. package/lib/commonjs/createStyleSheet.js.map +1 -0
  34. package/lib/commonjs/global.js +2 -0
  35. package/lib/commonjs/global.js.map +1 -0
  36. package/lib/commonjs/hooks/index.js +24 -3
  37. package/lib/commonjs/hooks/index.js.map +1 -1
  38. package/lib/commonjs/hooks/useCSS.js +44 -0
  39. package/lib/commonjs/hooks/useCSS.js.map +1 -0
  40. package/lib/commonjs/hooks/useCSS.native.js +9 -0
  41. package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
  42. package/lib/commonjs/hooks/useInitialTheme.js +17 -0
  43. package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
  44. package/lib/commonjs/hooks/useUnistyles.js +64 -0
  45. package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
  46. package/lib/commonjs/hooks/useVariants.js +14 -0
  47. package/lib/commonjs/hooks/useVariants.js.map +1 -0
  48. package/lib/commonjs/index.js +63 -6
  49. package/lib/commonjs/index.js.map +1 -1
  50. package/lib/commonjs/normalizer/index.js +32 -0
  51. package/lib/commonjs/normalizer/index.js.map +1 -0
  52. package/lib/commonjs/normalizer/module.d.js.map +1 -0
  53. package/lib/commonjs/{utils/normalizeStyles.web.js → normalizer/normalizeStyle.js} +5 -5
  54. package/lib/commonjs/normalizer/normalizeStyle.js.map +1 -0
  55. package/lib/commonjs/{utils → normalizer}/normalizer.js +2 -3
  56. package/lib/commonjs/normalizer/normalizer.js.map +1 -0
  57. package/lib/commonjs/normalizer/normalizer.macos.js +3 -0
  58. package/lib/commonjs/normalizer/normalizer.macos.js.map +1 -0
  59. package/lib/commonjs/plugins/cssMediaQueriesPlugin.js +14 -0
  60. package/lib/commonjs/plugins/cssMediaQueriesPlugin.js.map +1 -0
  61. package/lib/commonjs/plugins/index.js +20 -0
  62. package/lib/commonjs/plugins/index.js.map +1 -0
  63. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
  64. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
  65. package/lib/commonjs/types/common.js +2 -0
  66. package/lib/{module/utils/module.d.js.map → commonjs/types/common.js.map} +1 -1
  67. package/lib/commonjs/types/index.js +11 -0
  68. package/lib/commonjs/types/index.js.map +1 -1
  69. package/lib/commonjs/types/plugin.js +6 -0
  70. package/lib/commonjs/{utils/module.d.js.map → types/plugin.js.map} +1 -1
  71. package/lib/commonjs/types/stylesheet.js +6 -0
  72. package/lib/commonjs/types/{mediaQueries.js.map → stylesheet.js.map} +1 -1
  73. package/lib/commonjs/types/unistyles.js +6 -0
  74. package/lib/{module/types/mediaQueries.js.map → commonjs/types/unistyles.js.map} +1 -1
  75. package/lib/commonjs/types/variants.js +2 -0
  76. package/lib/commonjs/types/variants.js.map +1 -0
  77. package/lib/commonjs/useStyles.js +47 -0
  78. package/lib/commonjs/useStyles.js.map +1 -0
  79. package/lib/commonjs/utils/breakpoints.js +20 -122
  80. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  81. package/lib/commonjs/utils/cssMediaQuery.js +244 -0
  82. package/lib/commonjs/utils/cssMediaQuery.js.map +1 -0
  83. package/lib/commonjs/utils/generateId.js +15 -0
  84. package/lib/commonjs/utils/generateId.js.map +1 -0
  85. package/lib/commonjs/utils/hash32.js +43 -0
  86. package/lib/commonjs/utils/hash32.js.map +1 -0
  87. package/lib/commonjs/utils/index.js +22 -54
  88. package/lib/commonjs/utils/index.js.map +1 -1
  89. package/lib/commonjs/utils/mq.js +38 -0
  90. package/lib/commonjs/utils/mq.js.map +1 -0
  91. package/lib/commonjs/utils/mqParser.js +89 -0
  92. package/lib/commonjs/utils/mqParser.js.map +1 -0
  93. package/lib/commonjs/utils/styles.js +52 -72
  94. package/lib/commonjs/utils/styles.js.map +1 -1
  95. package/lib/commonjs/utils/withPlugins.js +15 -0
  96. package/lib/commonjs/utils/withPlugins.js.map +1 -0
  97. package/lib/module/common.js +53 -0
  98. package/lib/module/common.js.map +1 -0
  99. package/lib/module/core/UnistyleRegistry.js +87 -0
  100. package/lib/module/core/UnistyleRegistry.js.map +1 -0
  101. package/lib/module/core/Unistyles.js +26 -0
  102. package/lib/module/core/Unistyles.js.map +1 -0
  103. package/lib/module/core/UnistylesModule.js +190 -0
  104. package/lib/module/core/UnistylesModule.js.map +1 -0
  105. package/lib/module/core/UnistylesModule.native.js +3 -0
  106. package/lib/module/core/UnistylesModule.native.js.map +1 -0
  107. package/lib/module/core/UnistylesRuntime.js +133 -0
  108. package/lib/module/core/UnistylesRuntime.js.map +1 -0
  109. package/lib/module/core/index.js +2 -0
  110. package/lib/module/core/index.js.map +1 -0
  111. package/lib/module/createStyleSheet.js +7 -0
  112. package/lib/module/createStyleSheet.js.map +1 -0
  113. package/lib/module/global.js +2 -0
  114. package/lib/module/global.js.map +1 -0
  115. package/lib/module/hooks/index.js +4 -1
  116. package/lib/module/hooks/index.js.map +1 -1
  117. package/lib/module/hooks/useCSS.js +37 -0
  118. package/lib/module/hooks/useCSS.js.map +1 -0
  119. package/lib/module/hooks/useCSS.native.js +2 -0
  120. package/lib/module/hooks/useCSS.native.js.map +1 -0
  121. package/lib/module/hooks/useInitialTheme.js +10 -0
  122. package/lib/module/hooks/useInitialTheme.js.map +1 -0
  123. package/lib/module/hooks/useUnistyles.js +57 -0
  124. package/lib/module/hooks/useUnistyles.js.map +1 -0
  125. package/lib/module/hooks/useVariants.js +7 -0
  126. package/lib/module/hooks/useVariants.js.map +1 -0
  127. package/lib/module/index.js +30 -2
  128. package/lib/module/index.js.map +1 -1
  129. package/lib/module/normalizer/index.js +3 -0
  130. package/lib/module/normalizer/index.js.map +1 -0
  131. package/lib/module/normalizer/module.d.js.map +1 -0
  132. package/lib/module/{utils/normalizeStyles.web.js → normalizer/normalizeStyle.js} +3 -3
  133. package/lib/module/normalizer/normalizeStyle.js.map +1 -0
  134. package/lib/module/{utils → normalizer}/normalizer.js +2 -3
  135. package/lib/module/normalizer/normalizer.js.map +1 -0
  136. package/lib/module/normalizer/normalizer.macos.js +2 -0
  137. package/lib/module/normalizer/normalizer.macos.js.map +1 -0
  138. package/lib/module/plugins/cssMediaQueriesPlugin.js +7 -0
  139. package/lib/module/plugins/cssMediaQueriesPlugin.js.map +1 -0
  140. package/lib/module/plugins/index.js +3 -0
  141. package/lib/module/plugins/index.js.map +1 -0
  142. package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
  143. package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
  144. package/lib/module/types/common.js +2 -0
  145. package/lib/module/types/common.js.map +1 -0
  146. package/lib/module/types/index.js +1 -0
  147. package/lib/module/types/index.js.map +1 -1
  148. package/lib/module/types/plugin.js +2 -0
  149. package/lib/module/types/plugin.js.map +1 -0
  150. package/lib/module/types/stylesheet.js +2 -0
  151. package/lib/module/types/stylesheet.js.map +1 -0
  152. package/lib/module/types/unistyles.js +2 -0
  153. package/lib/module/types/unistyles.js.map +1 -0
  154. package/lib/module/types/variants.js +2 -0
  155. package/lib/module/types/variants.js.map +1 -0
  156. package/lib/module/useStyles.js +40 -0
  157. package/lib/module/useStyles.js.map +1 -0
  158. package/lib/module/utils/breakpoints.js +19 -120
  159. package/lib/module/utils/breakpoints.js.map +1 -1
  160. package/lib/module/utils/cssMediaQuery.js +237 -0
  161. package/lib/module/utils/cssMediaQuery.js.map +1 -0
  162. package/lib/module/utils/generateId.js +7 -0
  163. package/lib/module/utils/generateId.js.map +1 -0
  164. package/lib/module/utils/hash32.js +36 -0
  165. package/lib/module/utils/hash32.js.map +1 -0
  166. package/lib/module/utils/index.js +6 -6
  167. package/lib/module/utils/index.js.map +1 -1
  168. package/lib/module/utils/mq.js +32 -0
  169. package/lib/module/utils/mq.js.map +1 -0
  170. package/lib/module/utils/mqParser.js +78 -0
  171. package/lib/module/utils/mqParser.js.map +1 -0
  172. package/lib/module/utils/styles.js +50 -72
  173. package/lib/module/utils/styles.js.map +1 -1
  174. package/lib/module/utils/withPlugins.js +8 -0
  175. package/lib/module/utils/withPlugins.js.map +1 -0
  176. package/lib/typescript/src/common.d.ts +46 -0
  177. package/lib/typescript/src/common.d.ts.map +1 -0
  178. package/lib/typescript/src/core/UnistyleRegistry.d.ts +56 -0
  179. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
  180. package/lib/typescript/src/core/Unistyles.d.ts +13 -0
  181. package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
  182. package/lib/typescript/src/core/UnistylesModule.d.ts +19 -0
  183. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
  184. package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
  185. package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
  186. package/lib/typescript/src/core/UnistylesRuntime.d.ts +81 -0
  187. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
  188. package/lib/typescript/src/core/index.d.ts +3 -0
  189. package/lib/typescript/src/core/index.d.ts.map +1 -0
  190. package/lib/typescript/src/createStyleSheet.d.ts +8 -0
  191. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  192. package/lib/typescript/src/global.d.ts +7 -0
  193. package/lib/typescript/src/global.d.ts.map +1 -0
  194. package/lib/typescript/src/hooks/index.d.ts +4 -1
  195. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  196. package/lib/typescript/src/hooks/useCSS.d.ts +3 -0
  197. package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -0
  198. package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
  199. package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
  200. package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
  201. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
  202. package/lib/typescript/src/hooks/useUnistyles.d.ts +14 -0
  203. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
  204. package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
  205. package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
  206. package/lib/typescript/src/index.d.ts +76 -2
  207. package/lib/typescript/src/index.d.ts.map +1 -1
  208. package/lib/typescript/src/normalizer/index.d.ts +3 -0
  209. package/lib/typescript/src/normalizer/index.d.ts.map +1 -0
  210. package/lib/typescript/src/normalizer/normalizeStyle.d.ts +3 -0
  211. package/lib/typescript/src/normalizer/normalizeStyle.d.ts.map +1 -0
  212. package/lib/typescript/src/normalizer/normalizer.d.ts.map +1 -0
  213. package/lib/typescript/src/normalizer/normalizer.macos.d.ts +1 -0
  214. package/lib/typescript/src/normalizer/normalizer.macos.d.ts.map +1 -0
  215. package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts +3 -0
  216. package/lib/typescript/src/plugins/cssMediaQueriesPlugin.d.ts.map +1 -0
  217. package/lib/typescript/src/plugins/index.d.ts +3 -0
  218. package/lib/typescript/src/plugins/index.d.ts.map +1 -0
  219. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
  220. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
  221. package/lib/typescript/src/types/breakpoints.d.ts +25 -16
  222. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  223. package/lib/typescript/src/types/common.d.ts +3 -0
  224. package/lib/typescript/src/types/common.d.ts.map +1 -0
  225. package/lib/typescript/src/types/core.d.ts +11 -25
  226. package/lib/typescript/src/types/core.d.ts.map +1 -1
  227. package/lib/typescript/src/types/index.d.ts +7 -2
  228. package/lib/typescript/src/types/index.d.ts.map +1 -1
  229. package/lib/typescript/src/types/plugin.d.ts +7 -0
  230. package/lib/typescript/src/types/plugin.d.ts.map +1 -0
  231. package/lib/typescript/src/types/stylesheet.d.ts +40 -0
  232. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
  233. package/lib/typescript/src/types/unistyles.d.ts +53 -0
  234. package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
  235. package/lib/typescript/src/types/variants.d.ts +14 -0
  236. package/lib/typescript/src/types/variants.d.ts.map +1 -0
  237. package/lib/typescript/src/useStyles.d.ts +16 -0
  238. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  239. package/lib/typescript/src/utils/breakpoints.d.ts +2 -62
  240. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  241. package/lib/typescript/src/utils/cssMediaQuery.d.ts +4 -0
  242. package/lib/typescript/src/utils/cssMediaQuery.d.ts.map +1 -0
  243. package/lib/typescript/src/utils/generateId.d.ts +2 -0
  244. package/lib/typescript/src/utils/generateId.d.ts.map +1 -0
  245. package/lib/typescript/src/utils/hash32.d.ts +2 -0
  246. package/lib/typescript/src/utils/hash32.d.ts.map +1 -0
  247. package/lib/typescript/src/utils/index.d.ts +7 -6
  248. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  249. package/lib/typescript/src/utils/mq.d.ts +26 -0
  250. package/lib/typescript/src/utils/mq.d.ts.map +1 -0
  251. package/lib/typescript/src/utils/mqParser.d.ts +16 -0
  252. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
  253. package/lib/typescript/src/utils/styles.d.ts +4 -49
  254. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  255. package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
  256. package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
  257. package/package.json +46 -25
  258. package/react-native-unistyles.podspec +22 -0
  259. package/src/__tests__/mocks.ts +24 -0
  260. package/src/common.ts +55 -0
  261. package/src/core/UnistyleRegistry.ts +108 -0
  262. package/src/core/Unistyles.ts +35 -0
  263. package/src/core/UnistylesModule.native.ts +7 -0
  264. package/src/core/UnistylesModule.ts +230 -0
  265. package/src/core/UnistylesRuntime.ts +135 -0
  266. package/src/core/index.ts +2 -0
  267. package/src/createStyleSheet.ts +8 -0
  268. package/src/global.ts +6 -0
  269. package/src/hooks/index.ts +4 -1
  270. package/src/hooks/useCSS.native.ts +3 -0
  271. package/src/hooks/useCSS.ts +51 -0
  272. package/src/hooks/useInitialTheme.ts +11 -0
  273. package/src/hooks/useUnistyles.ts +64 -0
  274. package/src/hooks/useVariants.ts +10 -0
  275. package/src/index.ts +50 -2
  276. package/src/normalizer/index.ts +2 -0
  277. package/src/{utils/normalizeStyles.web.ts → normalizer/normalizeStyle.ts} +3 -3
  278. package/src/normalizer/normalizer.macos.ts +1 -0
  279. package/src/{utils → normalizer}/normalizer.ts +5 -4
  280. package/src/plugins/cssMediaQueriesPlugin.ts +8 -0
  281. package/src/plugins/index.ts +2 -0
  282. package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
  283. package/src/types/breakpoints.ts +55 -27
  284. package/src/types/common.ts +2 -0
  285. package/src/types/core.ts +11 -36
  286. package/src/types/index.ts +12 -7
  287. package/src/types/plugin.ts +7 -0
  288. package/src/types/stylesheet.ts +49 -0
  289. package/src/types/unistyles.ts +63 -0
  290. package/src/types/variants.ts +19 -0
  291. package/src/useStyles.ts +60 -0
  292. package/src/utils/breakpoints.ts +28 -124
  293. package/src/utils/cssMediaQuery.ts +268 -0
  294. package/src/utils/generateId.ts +10 -0
  295. package/src/utils/hash32.ts +53 -0
  296. package/src/utils/index.ts +7 -13
  297. package/src/utils/mq.ts +57 -0
  298. package/src/utils/mqParser.ts +99 -0
  299. package/src/utils/styles.ts +62 -102
  300. package/src/utils/withPlugins.ts +13 -0
  301. package/lib/commonjs/UnistylesTheme.js +0 -21
  302. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  303. package/lib/commonjs/createUnistyles.js +0 -57
  304. package/lib/commonjs/createUnistyles.js.map +0 -1
  305. package/lib/commonjs/hooks/useDimensions.js +0 -10
  306. package/lib/commonjs/hooks/useDimensions.js.map +0 -1
  307. package/lib/commonjs/hooks/useDimensions.web.js +0 -34
  308. package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
  309. package/lib/commonjs/types/mediaQueries.js +0 -2
  310. package/lib/commonjs/utils/common.js +0 -18
  311. package/lib/commonjs/utils/common.js.map +0 -1
  312. package/lib/commonjs/utils/mediaQueries.js +0 -189
  313. package/lib/commonjs/utils/mediaQueries.js.map +0 -1
  314. package/lib/commonjs/utils/normalizeStyles.js +0 -10
  315. package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
  316. package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
  317. package/lib/commonjs/utils/normalizer.js.map +0 -1
  318. package/lib/module/UnistylesTheme.js +0 -12
  319. package/lib/module/UnistylesTheme.js.map +0 -1
  320. package/lib/module/createUnistyles.js +0 -50
  321. package/lib/module/createUnistyles.js.map +0 -1
  322. package/lib/module/hooks/useDimensions.js +0 -3
  323. package/lib/module/hooks/useDimensions.js.map +0 -1
  324. package/lib/module/hooks/useDimensions.web.js +0 -27
  325. package/lib/module/hooks/useDimensions.web.js.map +0 -1
  326. package/lib/module/types/mediaQueries.js +0 -2
  327. package/lib/module/utils/common.js +0 -10
  328. package/lib/module/utils/common.js.map +0 -1
  329. package/lib/module/utils/mediaQueries.js +0 -176
  330. package/lib/module/utils/mediaQueries.js.map +0 -1
  331. package/lib/module/utils/normalizeStyles.js +0 -3
  332. package/lib/module/utils/normalizeStyles.js.map +0 -1
  333. package/lib/module/utils/normalizeStyles.web.js.map +0 -1
  334. package/lib/module/utils/normalizer.js.map +0 -1
  335. package/lib/typescript/examples/expo/src/App.d.ts +0 -3
  336. package/lib/typescript/examples/expo/src/App.d.ts.map +0 -1
  337. package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts +0 -3
  338. package/lib/typescript/examples/expo/src/examples/Breakpoints.d.ts.map +0 -1
  339. package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts +0 -3
  340. package/lib/typescript/examples/expo/src/examples/EmptyStyles.d.ts.map +0 -1
  341. package/lib/typescript/examples/expo/src/examples/Extreme.d.ts +0 -7
  342. package/lib/typescript/examples/expo/src/examples/Extreme.d.ts.map +0 -1
  343. package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts +0 -3
  344. package/lib/typescript/examples/expo/src/examples/MediaQueries.d.ts.map +0 -1
  345. package/lib/typescript/examples/expo/src/examples/Memoization.d.ts +0 -3
  346. package/lib/typescript/examples/expo/src/examples/Memoization.d.ts.map +0 -1
  347. package/lib/typescript/examples/expo/src/examples/Minimal.d.ts +0 -3
  348. package/lib/typescript/examples/expo/src/examples/Minimal.d.ts.map +0 -1
  349. package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts +0 -3
  350. package/lib/typescript/examples/expo/src/examples/MinimalWithCreateStyleSheet.d.ts.map +0 -1
  351. package/lib/typescript/examples/expo/src/examples/Theme.d.ts +0 -3
  352. package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +0 -1
  353. package/lib/typescript/examples/expo/src/examples/index.d.ts +0 -8
  354. package/lib/typescript/examples/expo/src/examples/index.d.ts.map +0 -1
  355. package/lib/typescript/examples/expo/src/index.d.ts +0 -2
  356. package/lib/typescript/examples/expo/src/index.d.ts.map +0 -1
  357. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +0 -8
  358. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +0 -1
  359. package/lib/typescript/examples/expo/src/styles/index.d.ts +0 -46
  360. package/lib/typescript/examples/expo/src/styles/index.d.ts.map +0 -1
  361. package/lib/typescript/examples/expo/src/styles/theme.d.ts +0 -24
  362. package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +0 -1
  363. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  364. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  365. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  366. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  367. package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
  368. package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
  369. package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
  370. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
  371. package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
  372. package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
  373. package/lib/typescript/src/utils/common.d.ts +0 -5
  374. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  375. package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
  376. package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
  377. package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
  378. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
  379. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
  380. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
  381. package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
  382. package/src/UnistylesTheme.tsx +0 -17
  383. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  384. package/src/createUnistyles.ts +0 -70
  385. package/src/hooks/useDimensions.ts +0 -4
  386. package/src/hooks/useDimensions.web.ts +0 -34
  387. package/src/types/mediaQueries.ts +0 -10
  388. package/src/utils/common.ts +0 -12
  389. package/src/utils/mediaQueries.ts +0 -201
  390. package/src/utils/normalizeStyles.ts +0 -2
  391. /package/lib/commonjs/{utils → normalizer}/module.d.js +0 -0
  392. /package/lib/module/{utils → normalizer}/module.d.js +0 -0
  393. /package/lib/typescript/src/{utils → normalizer}/normalizer.d.ts +0 -0
  394. /package/src/{utils → normalizer}/module.d.ts +0 -0
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "cssMediaQueriesPlugin", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _cssMediaQueriesPlugin.cssMediaQueriesPlugin;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "normalizeWebStylesPlugin", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _normalizeWebStylesPlugin.normalizeWebStylesPlugin;
16
+ }
17
+ });
18
+ var _normalizeWebStylesPlugin = require("./normalizeWebStylesPlugin");
19
+ var _cssMediaQueriesPlugin = require("./cssMediaQueriesPlugin");
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizeWebStylesPlugin","require","_cssMediaQueriesPlugin"],"sourceRoot":"../../../src","sources":["plugins/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,yBAAA,GAAAC,OAAA;AACA,IAAAC,sBAAA,GAAAD,OAAA"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeWebStylesPlugin = void 0;
7
+ var _normalizer = require("../normalizer");
8
+ const normalizeWebStylesPlugin = exports.normalizeWebStylesPlugin = {
9
+ name: '__unistylesNormalizeWebStyles',
10
+ onParsedStyle: (_key, styles) => (0, _normalizer.normalizeStyle)(styles)
11
+ };
12
+ //# sourceMappingURL=normalizeWebStylesPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizer","require","normalizeWebStylesPlugin","exports","name","onParsedStyle","_key","styles","normalizeStyle"],"sourceRoot":"../../../src","sources":["plugins/normalizeWebStylesPlugin.ts"],"mappings":";;;;;;AACA,IAAAA,WAAA,GAAAC,OAAA;AAEO,MAAMC,wBAAyC,GAAAC,OAAA,CAAAD,wBAAA,GAAG;EACrDE,IAAI,EAAE,+BAA+B;EACrCC,aAAa,EAAEA,CAACC,IAAI,EAAEC,MAAM,KAAK,IAAAC,0BAAc,EAACD,MAAM;AAC1D,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/common.ts"],"mappings":""}
@@ -14,4 +14,15 @@ Object.keys(_normalizer).forEach(function (key) {
14
14
  }
15
15
  });
16
16
  });
17
+ var _unistyles = require("./unistyles");
18
+ Object.keys(_unistyles).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _unistyles[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _unistyles[key];
25
+ }
26
+ });
27
+ });
17
28
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_normalizer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA"}
1
+ {"version":3,"names":["_normalizer","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_unistyles"],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":";;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,WAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,WAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,WAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,UAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,UAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,UAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,UAAA,CAAAL,GAAA;IAAA;EAAA;AAAA"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/plugin.ts"],"mappings":""}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=stylesheet.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/mediaQueries.ts"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/stylesheet.ts"],"mappings":""}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ //# sourceMappingURL=unistyles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/mediaQueries.ts"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/unistyles.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=variants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/variants.ts"],"mappings":""}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useStyles = void 0;
7
+ var _react = require("react");
8
+ var _reactNative = require("react-native");
9
+ var _utils = require("./utils");
10
+ var _hooks = require("./hooks");
11
+ var _core = require("./core");
12
+ var _common = require("./common");
13
+ /**
14
+ * Hook that enables all the features of Unistyles
15
+ * @param stylesheet - The stylesheet with superpowers to be used
16
+ * @param variantsMap - The map of variants to be used
17
+ * @returns - The theme, current breakpoint and RN compatible styles
18
+ */
19
+ const useStyles = (stylesheet, variantsMap) => {
20
+ const {
21
+ theme,
22
+ layout,
23
+ plugins
24
+ } = (0, _hooks.useUnistyles)();
25
+ const variants = (0, _hooks.useVariants)(variantsMap);
26
+ const parsedStyles = (0, _react.useMemo)(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
27
+ const dynamicStyleSheet = (0, _react.useMemo)(() => Object.entries(parsedStyles || {}).reduce((acc, [key, value]) => {
28
+ if (typeof value === 'function') {
29
+ return {
30
+ ...acc,
31
+ [key]: (0, _utils.proxifyFunction)(key, value, variants)
32
+ };
33
+ }
34
+ return _reactNative.StyleSheet.create({
35
+ ...acc,
36
+ [key]: (0, _utils.withPlugins)(key, (0, _utils.parseStyle)(value, variants, !_common.isWeb || !_core.unistyles.registry.config.experimentalCSSMediaQueries))
37
+ });
38
+ }, {}), [parsedStyles, variants, plugins]);
39
+ (0, _hooks.useCSS)(dynamicStyleSheet);
40
+ return {
41
+ theme,
42
+ breakpoint: layout.breakpoint,
43
+ styles: dynamicStyleSheet
44
+ };
45
+ };
46
+ exports.useStyles = useStyles;
47
+ //# sourceMappingURL=useStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_reactNative","_utils","_hooks","_core","_common","useStyles","stylesheet","variantsMap","theme","layout","plugins","useUnistyles","variants","useVariants","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","key","value","proxifyFunction","StyleSheet","create","withPlugins","parseStyle","isWeb","unistyles","registry","config","experimentalCSSMediaQueries","useCSS","breakpoint","styles","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAGA,IA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AO;IACHR,KAAK;IACL0B,UAAU,EAAEzB,MAAM,CAACyB,UAAU;IAC7BC,MAAM,EAAEnB;EACZ,CAAC;AACL,CAAC;AAAAoB,OAAA,CAAA/B,SAAA,GAAAA,SAAA"}
@@ -3,133 +3,31 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.sortAndValidateBreakpoints = exports.getValueForBreakpoint = exports.getBreakpointFromScreenWidth = void 0;
7
- var _common = require("./common");
8
- var _mediaQueries = require("./mediaQueries");
9
- /**
10
- * Sorts the breakpoints object based on its numeric values in ascending order and validates them.
11
- *
12
- * This function takes an object where keys represent breakpoint names and values are numeric.
13
- * It returns a new object with the same keys but sorted based on their corresponding numeric values.
14
- * Additionally, it validates that:
15
- * 1. The first breakpoint starts with a value of 0.
16
- * 2. No duplicate breakpoint values exist.
17
- *
18
- * If the validation fails, appropriate error messages are logged to the console.
19
- *
20
- * @template B - An object type where keys are strings and values are numbers.
21
- * @param {B} breakpoints - The breakpoints object to be sorted and validated.
22
- * @returns {B} A new object with sorted and validated breakpoints.
23
- *
24
- * @example
25
- * const input = { md: 768, lg: 1024, sm: 0 }
26
- * sortAndValidateBreakpoints(input) // returns { sm: 0, md: 768, lg: 1024 }
27
- */
28
- const sortAndValidateBreakpoints = breakpoints => {
29
- const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
30
- const [, value1] = breakpoint1;
31
- const [, value2] = breakpoint2;
32
- return value1 - value2;
33
- });
34
- const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs));
35
- const breakpointValues = Object.values(sortedBreakpoints);
36
- const [firstBreakpoint] = breakpointValues;
37
- if (firstBreakpoint !== 0) {
38
- (0, _common.throwError)('first breakpoint must start with 0');
6
+ exports.getValueForBreakpoint = void 0;
7
+ var _core = require("../core");
8
+ var _common = require("../common");
9
+ var _mqParser = require("./mqParser");
10
+ const getValueForBreakpoint = value => {
11
+ const customMediaQueryKey = (0, _mqParser.getKeyForUnistylesMediaQuery)(Object.entries(value), _core.unistyles.runtime.screen);
12
+ if (customMediaQueryKey) {
13
+ return value[customMediaQueryKey];
39
14
  }
40
- if (breakpointValues.length !== new Set(breakpointValues).size) {
41
- (0, _common.throwError)('breakpoint values are duplicated');
15
+ const hasBreakpoints = _core.unistyles.registry.sortedBreakpointPairs.length > 0;
16
+ if (!hasBreakpoints && _common.isMobile && (_common.ScreenOrientation.Landscape in value || _common.ScreenOrientation.Portrait in value)) {
17
+ return value[_core.unistyles.runtime.orientation];
42
18
  }
43
- return sortedBreakpoints;
44
- };
45
-
46
- /**
47
- * Determines the appropriate breakpoint key for a given screen width based on provided breakpoints.
48
- *
49
- * This function takes a screen width and an object of breakpoints. It returns the key of the breakpoint
50
- * that the screen width falls into. The breakpoints are assumed to be sorted in ascending order.
51
- *
52
- * @template B - An object type where keys are strings and values are numbers representing screen widths.
53
- * @param {number} width - The screen width to determine the breakpoint for.
54
- * @param breakpointEntries - sorted pairs of breakpoints
55
- * @returns {keyof B & string} The key of the breakpoint that the screen width falls into.
56
- *
57
- * @example
58
- * const breakpoints = { sm: 0, md: 768, lg: 1024 }
59
- * getBreakpointFromScreenWidth(800, breakpoints) // returns 'md'
60
- */
61
- exports.sortAndValidateBreakpoints = sortAndValidateBreakpoints;
62
- const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
63
- const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
64
- let [, value] = _ref;
65
- const minVal = value;
66
- const maxVal = otherBreakpoints[index + 1]?.[1];
67
- if (!maxVal) {
68
- return true;
69
- }
70
- return width >= minVal && width < maxVal;
71
- });
72
- return key;
73
- };
74
-
75
- /**
76
- * Retrieves the value associated with a given breakpoint or custom media query based on the provided screen size.
77
- *
78
- * The function first checks for custom media queries. If a matching custom media query is found, its associated value is returned.
79
- * If no custom media query matches, the function then checks for a direct breakpoint match.
80
- * If there's no direct breakpoint match, the function simulates CSS cascading to find the closest matching breakpoint.
81
- *
82
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
83
- *
84
- * @param {Record<keyof B & string, string | number>} value - An object containing values associated with breakpoints or custom media queries.
85
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
86
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
87
- * @param breakpointPairs - sorted pairs of breakpoints
88
- *
89
- * @returns {string | number | undefined} Returns the value associated with the matching breakpoint or custom media query, or `undefined` if no match is found.
90
- *
91
- * @example
92
- *
93
- * const values = { ':w[200]': 'value1', sm: 'value2', md: 'value3' }
94
- * const screenSize = { width: 250, height: 400 }
95
- * const breakpoints = { sm: 300, md: 600, lg: 900 }
96
- *
97
- * getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
98
- */
99
- exports.getBreakpointFromScreenWidth = getBreakpointFromScreenWidth;
100
- const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointPairs) => {
101
- // the highest priority is for custom media queries
102
- const customMediaQueries = Object.entries(value).filter(_ref2 => {
103
- let [key] = _ref2;
104
- return (0, _mediaQueries.isMediaQuery)(key);
105
- });
106
- const customMediaQueryKey = (0, _mediaQueries.getKeyForCustomMediaQuery)(customMediaQueries, screenSize);
107
- if (customMediaQueryKey && customMediaQueryKey in value) {
108
- return value[customMediaQueryKey];
19
+ const breakpoint = _core.unistyles.runtime.breakpoint;
20
+ if (!breakpoint) {
21
+ return undefined;
109
22
  }
110
-
111
- // if no custom media query, or didn't match, proceed with defined breakpoints
112
- const unifiedKey = breakpoint;
113
- const directBreakpoint = value[unifiedKey];
114
-
115
- // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
116
- if (directBreakpoint || unifiedKey in value) {
23
+ const directBreakpoint = value[breakpoint];
24
+ if (directBreakpoint || breakpoint in value) {
117
25
  return directBreakpoint;
118
26
  }
119
-
120
- // there is no direct hit for breakpoint nor media-query, so let's simulate CSS cascading
121
- const currentBreakpoint = breakpointPairs.findIndex(_ref3 => {
122
- let [key] = _ref3;
123
- return key === unifiedKey;
124
- });
125
- const availableBreakpoints = breakpointPairs.filter((_ref4, index) => {
126
- let [key] = _ref4;
127
- return index < currentBreakpoint && key && key in value;
128
- }).map(_ref5 => {
129
- let [key] = _ref5;
130
- return key;
131
- });
132
- return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
27
+ const breakpointPairs = _core.unistyles.registry.sortedBreakpointPairs;
28
+ const currentBreakpointIndex = breakpointPairs.findIndex(([key]) => key === breakpoint);
29
+ const availableBreakpoints = breakpointPairs.filter(([key], index) => index < currentBreakpointIndex && key in value).map(([key]) => key);
30
+ return value[availableBreakpoints[availableBreakpoints.length - 1]];
133
31
  };
134
32
  exports.getValueForBreakpoint = getValueForBreakpoint;
135
33
  //# sourceMappingURL=breakpoints.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_common","require","_mediaQueries","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","throwError","length","Set","size","exports","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","breakpointPairs","customMediaQueries","filter","_ref2","isMediaQuery","customMediaQueryKey","getKeyForCustomMediaQuery","unifiedKey","directBreakpoint","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AAEA,IAAAC,aAAA,GAAAD,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAME,0BAA0B,GAA2BC,WAAc,IAAQ;EACpF,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EA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AAG,CAACC,KAAA;IAAA,IAAC,CAAC1B,GAAG,CAAC,GAAA0B,KAAA;IAAA,OAAK1B,GAAG;EAAA,EAAC;EAExB,OAAOW,eAAe,CAAClB,MAAM,GAAG,CAAC,GAC3BY,KAAK,CAACkB,oBAAoB,CAACA,oBAAoB,CAAC9B,MAAM,GAAG,CAAC,CAAC,CAAqB,GAChFkC,SAAS;AACnB,CAAC;AAAA/B,OAAA,CAAAY,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_core","require","_common","_mqParser","getValueForBreakpoint","value","customMediaQueryKey","getKeyForUnistylesMediaQuery","Object","entries","unistyles","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","isMobile","ScreenOrientation","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","key","availableBreakpoints","filter","index","map","exports"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAG,IAAAC,sCAA4B,EACpDC,MAAM,CAACC,OAAO,CAACJ,KAAK,CAAC,EACrBK,eAAS,CAACC,OAAO,CAACC,MACtB,CAAuB;EAEvB,IAAIN,mBAAmB,EAAE;IACrB,OAAOD,KAAK,CAACC,mBAAmB,CAAC;EACrC;EAEA,MAAMO,cAAc,GAAGH,eAAS,CAACI,QAAQ,CAACC,qBAAqB,CAACC,MAAM,GAAG,CAAC;EAE1E,IAAI,CAACH,cAAc,IAAII,gBAAQ,KAAKC,yBAAiB,CAACC,SAAS,IAAId,KAAK,IAAIa,yBAAiB,CAACE,QAAQ,IAAIf,KAAK,CAAC,EAAE;IAC9G,OAAOA,KAAK,CAACK,eAAS,CAACC,OAAO,CAACU,WAAW,CAAC;EAC/C;EAEA,MAAMC,UAAU,GAAGZ,eAAS,CAACC,OAAO,CAACW,UAAU;EAE/C,IAAI,CAACA,UAAU,EAAE;IACb,OAAOC,SAAS;EACpB;EAEA,MAAMC,gBAAgB,GAAGnB,KAAK,CAACiB,UAAU,CAAC;EAE1C,IAAIE,gBAAgB,IAAKF,UAAU,IAAIjB,KAAM,EAAE;IAC3C,OAAOmB,gBAAgB;EAC3B;EAEA,MAAMC,eAAe,GAAGf,eAAS,CAACI,QAAQ,CAACC,qBAAqB;EAChE,MAAMW,sBAAsB,GAAGD,eAAe,CACzCE,SAAS,CAAC,CAAC,CAACC,GAAG,CAAC,KAAKA,GAAG,KAAKN,UAAU,CAAC;EAE7C,MAAMO,oBAAoB,GAAGJ,eAAe,CACvCK,MAAM,CAAC,CAAC,CAACF,GAAG,CAAC,EAAEG,KAAK,KAAKA,KAAK,GAAGL,sBAAsB,IAAIE,GAAG,IAAIvB,KAAK,CAAC,CACxE2B,GAAG,CAAC,CAAC,CAACJ,GAAG,CAAC,KAAKA,GAAG,CAAC;EAExB,OAAOvB,KAAK,CAACwB,oBAAoB,CAACA,oBAAoB,CAACb,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC;AAAAiB,OAAA,CAAA7B,qBAAA,GAAAA,qBAAA"}
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createMediaQueryForStyles = void 0;
7
+ var _normalizer = require("../normalizer");
8
+ var _mqParser = require("./mqParser");
9
+ var _generateId = require("./generateId");
10
+ const createMediaQueryForStyles = (styles, runtime) => {
11
+ const withMediaQueries = Object.entries(styles).filter(([, value]) => typeof value === 'object').reduce((acc, [prop, value]) => {
12
+ const objectKeys = Object.keys(value);
13
+ const mediaQueries = objectKeys.filter(key => (0, _mqParser.isUnistylesMq)(key));
14
+ const breakpoints = objectKeys.filter(key => runtime.breakpoints[key]);
15
+ if (mediaQueries.length === 0 && breakpoints.length === 0) {
16
+ return acc;
17
+ }
18
+ const className = (0, _generateId.generateReactNativeWebId)(prop, '""');
19
+ const breakpointsStyles = getBreakpointsStyles(prop, value, runtime, className);
20
+ const mediaQueriesStyles = getMediaQueriesFromMQ(prop, value, className);
21
+ return {
22
+ ...acc,
23
+ [prop]: `
24
+ ${breakpointsStyles}
25
+ ${mediaQueriesStyles}
26
+ `.trim()
27
+ };
28
+ }, {});
29
+ return {
30
+ ...styles,
31
+ ...withMediaQueries
32
+ };
33
+ };
34
+ exports.createMediaQueryForStyles = createMediaQueryForStyles;
35
+ const getMaxWidthMediaQuery = width => {
36
+ if (!width) {
37
+ return '';
38
+ }
39
+ if (width.to === Infinity) {
40
+ return '';
41
+ }
42
+ return `and (max-width: ${width.to}px)`;
43
+ };
44
+ const getMaxHeightMediaQuery = height => {
45
+ if (!height) {
46
+ return '';
47
+ }
48
+ if (height.to === Infinity) {
49
+ return '';
50
+ }
51
+ return `and (max-height: ${height.to}px)`;
52
+ };
53
+ const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc, [key, value]) => {
54
+ const result = (0, _mqParser.parseMq)(key);
55
+ if (!(0, _mqParser.isValidMq)(result)) {
56
+ return acc;
57
+ }
58
+ if (result.width && result.height) {
59
+ return `${acc}
60
+
61
+ @media screen and (min-width: ${result.width.from}px) and (min-height: ${result.height.from}px) ${getMaxWidthMediaQuery(result.width)} ${getMaxHeightMediaQuery(result.height)} {
62
+ .${className} {
63
+ ${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
64
+ }
65
+ }
66
+ `;
67
+ }
68
+ if (result.width) {
69
+ return `${acc}
70
+
71
+ @media screen and (min-width: ${result.width.from}px) ${getMaxWidthMediaQuery(result.width)} {
72
+ .${className} {
73
+ ${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
74
+ }
75
+ }
76
+ `;
77
+ }
78
+ if (result.height) {
79
+ return `${acc}
80
+
81
+ @media screen and (min-height: ${result.height.from}px) ${getMaxHeightMediaQuery(result.height)} {
82
+ .${className} {
83
+ ${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
84
+ }
85
+ }
86
+ `;
87
+ }
88
+ return acc;
89
+ }, '');
90
+ const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc, [key, value]) => {
91
+ const breakpoint = runtime.breakpoints[key];
92
+ if (breakpoint === undefined) {
93
+ return acc;
94
+ }
95
+ return `${acc}
96
+
97
+ @media screen and (min-width: ${breakpoint}px) {
98
+ .${className} {
99
+ ${normalizePropName(prop)}: ${normalizeWebValue(prop, value)};
100
+ }
101
+ }
102
+ `;
103
+ }, '');
104
+ const normalizePropName = prop => prop.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
105
+ const normalizeWebValue = (prop, value) => {
106
+ if (value === undefined) {
107
+ return 'unset';
108
+ }
109
+ switch (prop) {
110
+ // colors
111
+ case 'color':
112
+ case 'backgroundColor':
113
+ case 'borderColor':
114
+ case 'borderBottomColor':
115
+ case 'borderLeftColor':
116
+ case 'borderRightColor':
117
+ case 'borderTopColor':
118
+ case 'borderBlockColor':
119
+ case 'borderBlockEndColor':
120
+ case 'borderBlockStartColor':
121
+ case 'textDecorationColor':
122
+ return (0, _normalizer.normalizeColor)(value);
123
+
124
+ // dimensions
125
+ case 'width':
126
+ case 'height':
127
+ case 'minWidth':
128
+ case 'minHeight':
129
+ case 'maxWidth':
130
+ case 'maxHeight':
131
+ case 'borderRadius':
132
+ case 'borderWidth':
133
+ case 'borderBottomLeftRadius':
134
+ case 'borderBottomRightRadius':
135
+ case 'borderEndEndRadius':
136
+ case 'borderEndStartRadius':
137
+ case 'borderStartEndRadius':
138
+ case 'borderStartStartRadius':
139
+ case 'borderTopLeftRadius':
140
+ case 'borderTopRightRadius':
141
+ case 'borderBottomWidth':
142
+ case 'borderLeftWidth':
143
+ case 'borderRightWidth':
144
+ case 'borderTopWidth':
145
+ case 'bottom':
146
+ case 'left':
147
+ case 'right':
148
+ case 'top':
149
+ case 'marginTop':
150
+ case 'marginBottom':
151
+ case 'marginLeft':
152
+ case 'marginRight':
153
+ case 'paddingTop':
154
+ case 'paddingBottom':
155
+ case 'paddingLeft':
156
+ case 'paddingRight':
157
+ case 'flexBasis':
158
+ case 'rowGap':
159
+ case 'columnGap':
160
+ case 'gap':
161
+ case 'margin':
162
+ case 'padding':
163
+ case 'fontSize':
164
+ case 'letterSpacing':
165
+ return `${value}px`;
166
+
167
+ // without unit
168
+ case 'borderStyle':
169
+ case 'pointerEvents':
170
+ case 'backfaceVisibility':
171
+ case 'alignContent':
172
+ case 'alignItems':
173
+ case 'alignSelf':
174
+ case 'flexDirection':
175
+ case 'flexWrap':
176
+ case 'flex':
177
+ case 'aspectRatio':
178
+ case 'opacity':
179
+ case 'direction':
180
+ case 'zIndex':
181
+ case 'justifyContent':
182
+ case 'overflow':
183
+ case 'display':
184
+ case 'position':
185
+ case 'flexGrow':
186
+ case 'flexShrink':
187
+ case 'fontFamily':
188
+ case 'fontStyle':
189
+ case 'textDecorationLine':
190
+ case 'textAlign':
191
+ case 'textDecorationStyle':
192
+ case 'lineHeight':
193
+ case 'textTransform':
194
+ case 'fontVariant':
195
+ case 'verticalAlign':
196
+ case 'objectFit':
197
+ return value;
198
+
199
+ // to be transformed for now
200
+ // not supported
201
+ case 'marginHorizontal':
202
+ case 'paddingHorizontal':
203
+ case 'marginVertical':
204
+ case 'paddingVertical':
205
+ case 'shadowColor':
206
+ case 'shadowOffset':
207
+ case 'shadowOpacity':
208
+ case 'shadowRadius':
209
+ case 'transform':
210
+ case 'transformMatrix':
211
+ case 'fontWeight':
212
+ case 'textShadowOffset':
213
+ case 'textShadowRadius':
214
+ case 'textShadowColor':
215
+ return '';
216
+
217
+ // unsupported
218
+ case 'borderStartColor':
219
+ case 'borderEndColor':
220
+ case 'borderEndWidth':
221
+ case 'borderBottomEndRadius':
222
+ case 'borderBottomStartRadius':
223
+ case 'borderCurve':
224
+ case 'elevation':
225
+ case 'borderTopEndRadius':
226
+ case 'borderTopStartRadius':
227
+ case 'borderStartWidth':
228
+ case 'start':
229
+ case 'end':
230
+ case 'margin-end':
231
+ case 'margin-start':
232
+ case 'padding-end':
233
+ case 'padding-start':
234
+ case 'writingDirection':
235
+ case 'textAlignVertical':
236
+ case 'includeFontPadding':
237
+ case 'resizeMode':
238
+ case 'overlayColor':
239
+ case 'tintColor':
240
+ default:
241
+ return '';
242
+ }
243
+ };
244
+ //# sourceMappingURL=cssMediaQuery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizer","require","_mqParser","_generateId","createMediaQueryForStyles","styles","runtime","withMediaQueries","Object","entries","filter","value","reduce","acc","prop","objectKeys","keys","mediaQueries","key","isUnistylesMq","breakpoints","length","className","generateReactNativeWebId","breakpointsStyles","getBreakpointsStyles","mediaQueriesStyles","getMediaQueriesFromMQ","trim","exports","getMaxWidthMediaQuery","width","to","Infinity","getMaxHeightMediaQuery","height","result","parseMq","isValidMq","from","normalizePropName","normalizeWebValue","breakpoint","undefined","replace","toLowerCase","normalizeColor"],"sourceRoot":"../../../src","sources":["utils/cssMediaQuery.ts"],"mappings":";;;;;;AAAA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,WAAA,GAAAF,OAAA;AAGO,MAAMG,yBAAyB,GAAGA,CAACC,MAAe,EAAEC,OAAyB,KAAc;EAC9F,MAAMC,gBAAgB,GAAGC,MAAM,CAC1BC,OAAO,CAACJ,MAAM,CAAC,CACfK,MAAM,CAAC,CAAC,GAAGC,KAAK,CAAC,KAAK,OAAOA,KAAK,KAAK,QAAQ,CAAC,CAChDC,MAAM,CAAC,CAACC,GAAG,EAAE,CAACC,IAAI,EAAEH,KAAK,CAAC,KAAK;IAC5B,MAAMI,UAAU,GAAGP,MAAM,CAACQ,IAAI,CAACL,KAAK,CAAC;IACrC,MAAMM,YAAY,GAAGF,UAAU,CAACL,MAAM,CAACQ,GAAG,IAAI,IAAAC,uBAAa,EAACD,GAAG,CAAC,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AAK,oBAAoB;IACzB,KAAK,WAAW;IAChB,KAAK,qBAAqB;IAC1B,KAAK,YAAY;IACjB,KAAK,eAAe;IACpB,KAAK,aAAa;IAClB,KAAK,eAAe;IACpB,KAAK,WAAW;MACZ,OAAOA,KAAK;;IAEhB;IACA;IACA,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,gBAAgB;IACrB,KAAK,iBAAiB;IACtB,KAAK,aAAa;IAClB,KAAK,cAAc;IACnB,KAAK,eAAe;IACpB,KAAK,cAAc;IACnB,KAAK,WAAW;IAChB,KAAK,iBAAiB;IACtB,KAAK,YAAY;IACjB,KAAK,kBAAkB;IACvB,KAAK,kBAAkB;IACvB,KAAK,iBAAiB;MAClB,OAAO,EAAE;;IAEb;IACA,KAAK,kBAAkB;IACvB,KAAK,gBAAgB;IACrB,KAAK,gBAAgB;IACrB,KAAK,uBAAuB;IAC5B,KAAK,yBAAyB;IAC9B,KAAK,aAAa;IAClB,KAAK,WAAW;IAChB,KAAK,oBAAoB;IACzB,KAAK,sBAAsB;IAC3B,KAAK,kBAAkB;IACvB,KAAK,OAAO;IACZ,KAAK,KAAK;IACV,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,aAAa;IAClB,KAAK,eAAe;IACpB,KAAK,kBAAkB;IACvB,KAAK,mBAAmB;IACxB,KAAK,oBAAoB;IACzB,KAAK,YAAY;IACjB,KAAK,cAAc;IACnB,KAAK,WAAW;IAChB;MACI,OAAO,EAAE;EACjB;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.generateReactNativeWebId = void 0;
7
+ var _hash = require("./hash32");
8
+ // eslint-disable-next-line camelcase
9
+
10
+ const generateReactNativeWebId = (key, value) => {
11
+ const hashedString = (0, _hash.murmurhash2_32_gc)(key + value, 1).toString(36);
12
+ return process.env.NODE_ENV !== 'production' ? `r-${key}-${hashedString}` : `r-${hashedString}`;
13
+ };
14
+ exports.generateReactNativeWebId = generateReactNativeWebId;
15
+ //# sourceMappingURL=generateId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_hash","require","generateReactNativeWebId","key","value","hashedString","murmurhash2_32_gc","toString","process","env","NODE_ENV","exports"],"sourceRoot":"../../../src","sources":["utils/generateId.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AADA;;AAGO,MAAMC,wBAAwB,GAAGA,CAACC,GAAW,EAAEC,KAAa,KAAa;EAC5E,MAAMC,YAAY,GAAG,IAAAC,uBAAiB,EAACH,GAAG,GAAGC,KAAK,EAAE,CAAC,CAAC,CAACG,QAAQ,CAAC,EAAE,CAAC;EAEnE,OAAOC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,GACrC,KAAIP,GAAI,IAAGE,YAAa,EAAC,GACzB,KAAIA,YAAa,EAAC;AAC7B,CAAC;AAAAM,OAAA,CAAAT,wBAAA,GAAAA,wBAAA"}