react-native-unistyles 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (396) 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 +45 -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 +44 -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 -17
  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 +3 -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 +58 -33
  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 +54 -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 -20
  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 -12
  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/PlatformColors.d.ts +0 -3
  352. package/lib/typescript/examples/expo/src/examples/PlatformColors.d.ts.map +0 -1
  353. package/lib/typescript/examples/expo/src/examples/Theme.d.ts +0 -3
  354. package/lib/typescript/examples/expo/src/examples/Theme.d.ts.map +0 -1
  355. package/lib/typescript/examples/expo/src/examples/index.d.ts +0 -9
  356. package/lib/typescript/examples/expo/src/examples/index.d.ts.map +0 -1
  357. package/lib/typescript/examples/expo/src/index.d.ts +0 -2
  358. package/lib/typescript/examples/expo/src/index.d.ts.map +0 -1
  359. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +0 -8
  360. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +0 -1
  361. package/lib/typescript/examples/expo/src/styles/index.d.ts +0 -46
  362. package/lib/typescript/examples/expo/src/styles/index.d.ts.map +0 -1
  363. package/lib/typescript/examples/expo/src/styles/theme.d.ts +0 -24
  364. package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +0 -1
  365. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  366. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  367. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  368. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  369. package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
  370. package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
  371. package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
  372. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
  373. package/lib/typescript/src/types/mediaQueries.d.ts +0 -8
  374. package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
  375. package/lib/typescript/src/utils/common.d.ts +0 -7
  376. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  377. package/lib/typescript/src/utils/mediaQueries.d.ts +0 -130
  378. package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
  379. package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
  380. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
  381. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
  382. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
  383. package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
  384. package/src/UnistylesTheme.tsx +0 -17
  385. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  386. package/src/createUnistyles.ts +0 -70
  387. package/src/hooks/useDimensions.ts +0 -4
  388. package/src/hooks/useDimensions.web.ts +0 -34
  389. package/src/types/mediaQueries.ts +0 -10
  390. package/src/utils/common.ts +0 -14
  391. package/src/utils/mediaQueries.ts +0 -201
  392. package/src/utils/normalizeStyles.ts +0 -2
  393. /package/lib/commonjs/{utils → normalizer}/module.d.js +0 -0
  394. /package/lib/module/{utils → normalizer}/module.d.js +0 -0
  395. /package/lib/typescript/src/{utils → normalizer}/normalizer.d.ts +0 -0
  396. /package/src/{utils → normalizer}/module.d.ts +0 -0
@@ -0,0 +1,4 @@
1
+ import type { RNStyle } from '../types';
2
+ import type { UnistylesRuntime } from '../core';
3
+ export declare const createMediaQueryForStyles: (styles: RNStyle, runtime: UnistylesRuntime) => RNStyle;
4
+ //# sourceMappingURL=cssMediaQuery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cssMediaQuery.d.ts","sourceRoot":"","sources":["../../../../src/utils/cssMediaQuery.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAW,MAAM,UAAU,CAAA;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,eAAO,MAAM,yBAAyB,WAAY,OAAO,WAAW,gBAAgB,KAAG,OA8BtF,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const generateReactNativeWebId: (key: string, value: string) => string;
2
+ //# sourceMappingURL=generateId.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateId.d.ts","sourceRoot":"","sources":["../../../../src/utils/generateId.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,wBAAwB,QAAS,MAAM,SAAS,MAAM,KAAG,MAMrE,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const murmurhash2_32_gc: (str: string, seed: number) => number;
2
+ //# sourceMappingURL=hash32.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hash32.d.ts","sourceRoot":"","sources":["../../../../src/utils/hash32.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,iBAAiB,QAAS,MAAM,QAAQ,MAAM,WA+C1D,CAAA"}
@@ -1,7 +1,8 @@
1
- export { normalizeStyles } from './normalizeStyles';
2
- export * from './normalizer';
3
- export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
4
- export { proxifyFunction, parseStyle } from './styles';
5
- export { isServer } from './common';
6
- export { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
1
+ export { mq } from './mq';
2
+ export type { UnistylesParsedMq } from './mqParser';
3
+ export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq, isUnistylesMq } from './mqParser';
4
+ export { getValueForBreakpoint } from './breakpoints';
5
+ export { proxifyFunction, parseStyle, isPlatformColor } from './styles';
6
+ export { withPlugins } from './withPlugins';
7
+ export { generateReactNativeWebId } from './generateId';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACnC,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,MAAM,CAAA;AACzB,YAAY,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AACvH,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,26 @@
1
+ import type { Nullable } from '../types';
2
+ import type { UnistylesBreakpoints } from '../global';
3
+ type MQValue = keyof UnistylesBreakpoints | number;
4
+ type MQHandler = {
5
+ only: {
6
+ width(wMin?: Nullable<MQValue>, wMax?: MQValue): symbol;
7
+ height(hMin?: Nullable<MQValue>, hMax?: MQValue): symbol;
8
+ };
9
+ width(wMin?: Nullable<MQValue>, wMax?: MQValue): {
10
+ and: {
11
+ height(hMin?: Nullable<MQValue>, hMax?: MQValue): symbol;
12
+ };
13
+ };
14
+ height(hMin?: Nullable<MQValue>, hMax?: MQValue): {
15
+ and: {
16
+ width(wMin?: Nullable<MQValue>, wMax?: MQValue): symbol;
17
+ };
18
+ };
19
+ };
20
+ /**
21
+ * Utility to create cross-platform media queries
22
+ * @returns - JavaScript symbol to be used in your stylesheet
23
+ */
24
+ export declare const mq: MQHandler;
25
+ export {};
26
+ //# sourceMappingURL=mq.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/utils/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,KAAK,OAAO,GAAG,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAElD,KAAK,SAAS,GAAG;IACb,IAAI,EAAE;QACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KAC5D,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC7C,GAAG,EAAE;YACD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;SAC3D,CAAA;KACJ,CAAC;IACF,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC9C,GAAG,EAAE;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;SAC1D,CAAA;KACJ,CAAA;CACJ,CAAA;AAcD;;;GAGG;AACH,eAAO,MAAM,EAAE,EAAE,SAiBhB,CAAA"}
@@ -0,0 +1,16 @@
1
+ import type { Optional, RNValue, ScreenSize } from '../types';
2
+ type ParsedMqDimension = {
3
+ from: number;
4
+ to: number;
5
+ };
6
+ export type UnistylesParsedMq = {
7
+ width?: ParsedMqDimension;
8
+ height?: ParsedMqDimension;
9
+ };
10
+ export declare const parseMq: (mq: string) => UnistylesParsedMq;
11
+ export declare const isUnistylesMq: (mq: string) => boolean;
12
+ export declare const isValidMq: (parsedMq: UnistylesParsedMq) => boolean;
13
+ export declare const isWithinTheWidthAndHeight: (parsedMq: UnistylesParsedMq, screenSize: ScreenSize) => boolean;
14
+ export declare const getKeyForUnistylesMediaQuery: (mediaQueries: Array<[string, RNValue]>, screenSize: ScreenSize) => Optional<string>;
15
+ export {};
16
+ //# sourceMappingURL=mqParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mqParser.d.ts","sourceRoot":"","sources":["../../../../src/utils/mqParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAM7D,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAA;CACb,CAAA;AAED,MAAM,MAAM,iBAAiB,GAAG;IAC5B,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,OAAO,OAAQ,MAAM,KAAG,iBAcpC,CAAA;AAED,eAAO,MAAM,aAAa,OAAQ,MAAM,YAAgC,CAAA;AAExE,eAAO,MAAM,SAAS,aAAc,iBAAiB,YAgBpD,CAAA;AAED,eAAO,MAAM,yBAAyB,aAAc,iBAAiB,cAAc,UAAU,KAAG,OAgB/F,CAAA;AAcD,eAAO,MAAM,4BAA4B,iBAAkB,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,cAAc,UAAU,KAAG,SAAS,MAAM,CAgB5H,CAAA"}
@@ -1,51 +1,5 @@
1
- import type { Breakpoints, CustomNamedStyles, ScreenSize, SortedBreakpointEntries } from '../types';
2
- /**
3
- * Proxies a function to parse its return value for custom media queries or breakpoints.
4
- *
5
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
6
- *
7
- * @param {Function} fn - The function to be proxified.
8
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
9
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
10
- * @param breakpointPairs - sorted pairs of breakpoints
11
- *
12
- * @returns {Function} Returns the proxified function
13
- *
14
- * @example
15
- *
16
- * const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
17
- * const screenSize = { width: 250, height: 400 }
18
- * const breakpoints = { sm: 300, md: 600 }
19
- *
20
- * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
21
- * proxifiedFunction() // parsed style based on screenSize and breakpoints
22
- */
23
- export declare const proxifyFunction: <B extends Breakpoints>(fn: Function, breakpoint: keyof B & string, screenSize: ScreenSize, breakpointPairs: SortedBreakpointEntries<B>) => Function;
1
+ import type { Optional, RNStyle } from '../types';
2
+ export declare const proxifyFunction: (key: string, fn: Function, variant?: Record<string, Optional<string>>) => Function;
24
3
  export declare const isPlatformColor: <T extends {}>(value: T) => boolean;
25
- /**
26
- * Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
27
- *
28
- * The function processes each key-value pair in the style object. If the value is a function or a valid style (not an object or a 'transform' key),
29
- * it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
30
- *
31
- * @template T - The type of the style object.
32
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
33
- *
34
- * @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
35
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
36
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
37
- * @param breakpointPairs - sorted pairs of breakpoints
38
- *
39
- * @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
40
- *
41
- * @example
42
- *
43
- * const style = { fontSize: { sm: '12px', md: '16px' } }
44
- * const screenSize = { width: 300, height: 400 }
45
- * const breakpoints = { xs: 0, sm: 300, md: 600 }
46
- *
47
- * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
48
- * // { fontSize: '12px' }
49
- */
50
- export declare const parseStyle: <T, B extends Breakpoints>(style: CustomNamedStyles<T, B>, breakpoint: keyof B & string, screenSize: ScreenSize, breakpointPairs: SortedBreakpointEntries<B>) => T;
4
+ export declare const parseStyle: <T extends RNStyle>(style: T, variant?: Record<string, Optional<string>>, parseMediaQueries?: boolean) => T;
51
5
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAKnG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,8BACpB,QAAQ,4CACA,UAAU,kDAEvB,QAGD,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,uGAGP,UAAU,mDAmDzB,CAAA"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAW,MAAM,UAAU,CAAA;AAK1D,eAAO,MAAM,eAAe,QACnB,MAAM,MACP,QAAQ,YACF,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,KAC3C,QAED,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED,eAAO,MAAM,UAAU,0CAEV,OAAO,MAAM,EAAE,SAAS,MAAM,CAAC,CAAC,mCAmD9B,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { RNStyle } from '../types';
2
+ export declare const withPlugins: (key: string, style: RNStyle) => RNStyle;
3
+ //# sourceMappingURL=withPlugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPlugins.d.ts","sourceRoot":"","sources":["../../../../src/utils/withPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAGvC,eAAO,MAAM,WAAW,QACf,MAAM,SACJ,OAAO,YAOT,CAAA"}
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
7
7
  "test:coverage": "jest --coverage",
8
8
  "tsc": "node_modules/typescript/bin/tsc --noEmit",
9
9
  "lint": "eslint . --ext .ts,.tsx",
10
- "clean": "del-cli lib",
11
10
  "prepare": "husky install && bob build",
12
11
  "precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
13
12
  "release": "release-it"
@@ -20,13 +19,28 @@
20
19
  "files": [
21
20
  "src",
22
21
  "lib",
22
+ "ios",
23
+ "android",
24
+ "cxx",
25
+ "react-native-unistyles.podspec",
26
+ "!lib/typescript/examples",
27
+ "!ios/build",
28
+ "!android/build",
29
+ "!android/gradle",
30
+ "!android/gradlew",
31
+ "!android/gradlew.bat",
32
+ "!android/local.properties",
23
33
  "!**/*.spec.ts",
34
+ "!**/*.spec.tsx",
24
35
  "!**/.*"
25
36
  ],
26
37
  "keywords": [
27
38
  "react-native",
28
39
  "ios",
29
- "android"
40
+ "android",
41
+ "react-native-macos",
42
+ "react-native-web",
43
+ "expo"
30
44
  ],
31
45
  "repository": "https://github.com/jpudysz/react-native-unistyles",
32
46
  "author": "Jacek Pudysz <jacekpudysz@gmail.com> (https://github.com/jpudysz)",
@@ -39,26 +53,24 @@
39
53
  "registry": "https://registry.npmjs.org/"
40
54
  },
41
55
  "devDependencies": {
42
- "@commitlint/config-conventional": "17.8.0",
56
+ "@commitlint/config-conventional": "18.4.3",
43
57
  "@react-native/eslint-config": "0.74.0",
44
58
  "@react-native/normalize-colors": "0.74.1",
45
- "@release-it/conventional-changelog": "5.1.1",
59
+ "@release-it/conventional-changelog": "8.0.1",
46
60
  "@testing-library/react-hooks": "8.0.1",
47
- "@types/jest": "29.5.5",
48
- "@types/react": "18.2.28",
49
- "@types/react-native": "0.72.3",
50
- "@typescript-eslint/eslint-plugin": "6.8.0",
51
- "@typescript-eslint/eslint-plugin-tslint": "6.8.0",
52
- "@typescript-eslint/parser": "6.8.0",
53
- "commitlint": "17.8.0",
54
- "concurrently": "8.2.1",
55
- "del-cli": "5.1.0",
56
- "eslint": "8.51.0",
61
+ "@types/jest": "29.5.11",
62
+ "@types/react": "18.2.46",
63
+ "@typescript-eslint/eslint-plugin": "6.16.0",
64
+ "@typescript-eslint/eslint-plugin-tslint": "6.16.0",
65
+ "@typescript-eslint/parser": "6.16.0",
66
+ "commitlint": "18.4.3",
67
+ "concurrently": "8.2.2",
68
+ "eslint": "8.56.0",
57
69
  "eslint-config-codemask": "1.1.7",
58
70
  "eslint-plugin-functional": "6.0.0",
59
- "eslint-plugin-import": "2.28.1",
60
- "eslint-plugin-jsdoc": "46.8.2",
61
- "eslint-plugin-jsx-a11y": "6.7.1",
71
+ "eslint-plugin-import": "2.29.1",
72
+ "eslint-plugin-jsdoc": "46.10.1",
73
+ "eslint-plugin-jsx-a11y": "6.8.0",
62
74
  "eslint-plugin-nested-if": "1.0.0",
63
75
  "eslint-plugin-no-else": "0.2.2",
64
76
  "eslint-plugin-no-loops": "0.3.0",
@@ -68,26 +80,31 @@
68
80
  "husky": "8.0.3",
69
81
  "jest": "29.7.0",
70
82
  "react": "18.2.0",
71
- "react-native": "0.72.6",
72
- "react-native-builder-bob": "0.23.1",
83
+ "react-native": "0.72.7",
84
+ "react-native-builder-bob": "0.23.2",
73
85
  "react-native-web": "0.19.9",
74
86
  "react-test-renderer": "18.2.0",
75
- "release-it": "16.2.1",
76
- "typescript": "5.2.2"
87
+ "release-it": "17.0.1",
88
+ "typescript": "5.3.3"
77
89
  },
78
90
  "peerDependencies": {
79
91
  "@react-native/normalize-colors": "*",
80
92
  "react": "*",
81
93
  "react-native": "*",
94
+ "react-native-macos": "*",
82
95
  "react-native-web": "*"
83
96
  },
84
97
  "peerDependenciesMeta": {
98
+ "react-native-macos": {
99
+ "optional": true
100
+ },
85
101
  "react-native-web": {
86
102
  "optional": true
87
103
  }
88
104
  },
89
105
  "workspaces": [
90
106
  "examples/expo",
107
+ "examples/macos",
91
108
  "docs"
92
109
  ],
93
110
  "packageManager": "yarn@3.6.1",
@@ -98,10 +115,13 @@
98
115
  "preset": "react-native",
99
116
  "modulePathIgnorePatterns": [
100
117
  "<rootDir>/examples/expo/node_modules",
101
- "<rootDir>/examples/ssr/node_modules",
118
+ "<rootDir>/examples/macos/node_modules",
102
119
  "<rootDir>/docs/node_modules",
103
120
  "<rootDir>/lib/"
104
121
  ],
122
+ "testMatch": [
123
+ "**/*.spec.(ts|tsx)"
124
+ ],
105
125
  "coverageReporters": [
106
126
  "html"
107
127
  ]
@@ -124,13 +144,14 @@
124
144
  },
125
145
  "plugins": {
126
146
  "@release-it/conventional-changelog": {
127
- "preset": "conventionalcommits"
147
+ "preset": "angular"
128
148
  }
129
149
  }
130
150
  },
131
151
  "eslintIgnore": [
132
152
  "node_modules/",
133
- "lib/"
153
+ "lib/",
154
+ "src/utils/hash32.ts"
134
155
  ],
135
156
  "react-native-builder-bob": {
136
157
  "source": "src",
@@ -0,0 +1,22 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = package["name"]
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported, :osx => "10.14" }
14
+ s.source = { :git => package["repository"], :tag => "#{s.version}" }
15
+
16
+ s.source_files = [
17
+ "ios/**/*.{h,mm}",
18
+ "cxx/*.{h,cpp}"
19
+ ]
20
+
21
+ install_modules_dependencies(s)
22
+ end
@@ -0,0 +1,24 @@
1
+ import type { ScreenSize } from '../types'
2
+
3
+ const TEST_BREAKPOINTS = {
4
+ xs: 0,
5
+ sm: 300,
6
+ md: 500,
7
+ lg: 750,
8
+ xl: 1000
9
+ } as const
10
+
11
+ export const mockRuntime = (screenSize: ScreenSize) => ({
12
+ breakpoint: Object.entries(TEST_BREAKPOINTS)
13
+ .reverse()
14
+ .find(([, value]) => screenSize.width >= value)?.at(0),
15
+ orientation: screenSize.width > screenSize.height
16
+ ? 'landscape'
17
+ : 'portrait',
18
+ screen: screenSize
19
+ })
20
+
21
+ export const mockRegistry = () => ({
22
+ sortedBreakpointPairs: Object.entries(TEST_BREAKPOINTS),
23
+ plugins: []
24
+ })
package/src/common.ts ADDED
@@ -0,0 +1,55 @@
1
+ import { Platform } from 'react-native'
2
+
3
+ export const warn = (message: string) => {
4
+ console.warn(`🦄 [react-native-unistyles]: ${message}`)
5
+ }
6
+
7
+ export const isWeb = Platform.OS === 'web'
8
+ export const isIOS = Platform.OS === 'ios'
9
+ export const isAndroid = Platform.OS === 'android'
10
+ export const isMobile = isIOS || isAndroid
11
+ export const isServer = typeof window === 'undefined'
12
+
13
+ export const ScreenOrientation = {
14
+ Landscape: 'landscape',
15
+ Portrait: 'portrait'
16
+ } as const
17
+
18
+ export enum IOSContentSizeCategory {
19
+ ExtraExtraExtraLarge = 'xxxLarge',
20
+ ExtraExtraLarge = 'xxLarge',
21
+ ExtraLarge = 'xLarge',
22
+ Large = 'Large',
23
+ Medium = 'Medium',
24
+ Small = 'Small',
25
+ ExtraSmall = 'xSmall',
26
+ Unspecified = 'unspecified'
27
+ }
28
+
29
+ export enum AndroidContentSizeCategory {
30
+ Small = 'Small',
31
+ Default = 'Default',
32
+ Large = 'Large',
33
+ ExtraLarge = 'ExtraLarge',
34
+ Huge = 'Huge'
35
+ }
36
+
37
+ export enum UnistylesEventType {
38
+ Theme = 'theme',
39
+ Layout = 'layout',
40
+ Plugin = 'plugin',
41
+ DynamicTypeSize = 'dynamicTypeSize'
42
+ }
43
+
44
+ export enum UnistylesError {
45
+ RuntimeUnavailable = 'Unistyles runtime is not available. Make sure you followed the installation instructions',
46
+ ThemeNotFound = 'You are trying to get a theme that is not registered with UnistylesRegistry',
47
+ ThemeNotRegistered = 'You are trying to set a theme that was not registered with UnistylesRegistry',
48
+ ThemeNotSelected = 'Your themes are registered, but you didn\'t select the initial theme',
49
+ ThemesCannotBeEmpty = 'You are trying to register empty themes object',
50
+ BreakpointsCannotBeEmpty = 'You are trying to register empty breakpoints object',
51
+ BreakpointsMustStartFromZero = 'You are trying to register breakpoints that don\'t start from 0',
52
+ InvalidPluginName = 'Plugin name can\'t start from reserved prefix __unistyles',
53
+ DuplicatePluginName = 'You are trying to register a plugin with a name that is already registered',
54
+ CantRemoveInternalPlugin = 'You are trying to remove an internal unistyles plugin'
55
+ }
@@ -0,0 +1,108 @@
1
+ import type { UnistylesBridge, UnistylesConfig, UnistylesPlugin } from '../types'
2
+ import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
3
+ import { isWeb, UnistylesError } from '../common'
4
+ import { cssMediaQueriesPlugin, normalizeWebStylesPlugin } from '../plugins'
5
+
6
+ export class UnistyleRegistry {
7
+ public config: UnistylesConfig = {}
8
+ public plugins: Array<UnistylesPlugin> = isWeb
9
+ ? [normalizeWebStylesPlugin]
10
+ : []
11
+ public themeNames: Array<keyof UnistylesThemes> = []
12
+ public themes: UnistylesThemes = {} as UnistylesThemes
13
+ public breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
14
+ public sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]> = []
15
+
16
+ constructor(private unistylesBridge: UnistylesBridge) {}
17
+
18
+ public addThemes = (themes: UnistylesThemes) => {
19
+ this.themes = themes
20
+
21
+ const keys = Object.keys(themes) as Array<keyof UnistylesThemes>
22
+
23
+ this.unistylesBridge.themes = keys
24
+ this.themeNames = keys
25
+
26
+ return {
27
+ addBreakpoints: this.addBreakpoints,
28
+ addConfig: this.addConfig
29
+ }
30
+ }
31
+
32
+ public addBreakpoints = (breakpoints: UnistylesBreakpoints) => {
33
+ this.breakpoints = breakpoints
34
+ this.unistylesBridge.useBreakpoints(breakpoints)
35
+ this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs
36
+
37
+ return {
38
+ addThemes: this.addThemes,
39
+ addConfig: this.addConfig
40
+ }
41
+ }
42
+
43
+ public addConfig = (config: UnistylesConfig) => {
44
+ this.config = config
45
+
46
+ if (config.adaptiveThemes) {
47
+ this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes)
48
+ }
49
+
50
+ if (config.plugins) {
51
+ config.plugins.forEach(plugin => this.addPlugin(plugin, false))
52
+ }
53
+
54
+ if (config.initialTheme) {
55
+ this.unistylesBridge.useTheme(config.initialTheme)
56
+ }
57
+
58
+ if (config.experimentalCSSMediaQueries) {
59
+ this.plugins = [cssMediaQueriesPlugin].concat(this.plugins)
60
+ this.unistylesBridge.addPlugin(cssMediaQueriesPlugin.name, false)
61
+ }
62
+
63
+ return {
64
+ addBreakpoints: this.addBreakpoints,
65
+ addThemes: this.addThemes
66
+ }
67
+ }
68
+
69
+ public getTheme = (forName: keyof UnistylesThemes) => {
70
+ if (this.themeNames.length === 0) {
71
+ return {} as UnistylesThemes[keyof UnistylesThemes]
72
+ }
73
+
74
+ if (this.hasTheme(forName)) {
75
+ return this.themes[forName]
76
+ }
77
+
78
+ if (this.unistylesBridge.themeName) {
79
+ throw new Error(UnistylesError.ThemeNotFound)
80
+ }
81
+
82
+ throw new Error(UnistylesError.ThemeNotSelected)
83
+ }
84
+
85
+ public addPlugin = (plugin: UnistylesPlugin, notify: boolean = true) => {
86
+ if (plugin.name.startsWith('__unistyles')) {
87
+ throw new Error(UnistylesError.InvalidPluginName)
88
+ }
89
+
90
+ if (this.plugins.some(({ name }) => name === plugin.name)) {
91
+ throw new Error(UnistylesError.DuplicatePluginName)
92
+ }
93
+
94
+ this.plugins = [plugin].concat(this.plugins)
95
+ this.unistylesBridge.addPlugin(plugin.name, notify)
96
+ }
97
+
98
+ public removePlugin = (plugin: UnistylesPlugin) => {
99
+ if (plugin.name.startsWith('__unistyles')) {
100
+ throw new Error(UnistylesError.CantRemoveInternalPlugin)
101
+ }
102
+
103
+ this.plugins = this.plugins.filter(({ name }) => name !== plugin.name)
104
+ this.unistylesBridge.removePlugin(plugin.name)
105
+ }
106
+
107
+ public hasTheme = (name: keyof UnistylesThemes) => name in this.themes
108
+ }
@@ -0,0 +1,35 @@
1
+ import { UnistylesModule } from './UnistylesModule'
2
+ import { UnistylesRuntime } from './UnistylesRuntime'
3
+ import { UnistyleRegistry } from './UnistyleRegistry'
4
+ import type { UnistylesBridge } from '../types'
5
+ import { UnistylesError, isWeb } from '../common'
6
+
7
+ class Unistyles {
8
+ private _runtime: UnistylesRuntime
9
+ private _registry: UnistyleRegistry
10
+ private _bridge: UnistylesBridge
11
+
12
+ constructor() {
13
+ const isInstalled = UnistylesModule?.install() ?? false
14
+
15
+ if (!isInstalled) {
16
+ throw new Error(UnistylesError.RuntimeUnavailable)
17
+ }
18
+
19
+ // @ts-ignore
20
+ // eslint-disable-next-line no-undef
21
+ this._bridge = (isWeb ? globalThis : global).__UNISTYLES__ as UnistylesBridge
22
+ this._registry = new UnistyleRegistry(this._bridge)
23
+ this._runtime = new UnistylesRuntime(this._bridge, this._registry)
24
+ }
25
+
26
+ public get registry() {
27
+ return this._registry
28
+ }
29
+
30
+ public get runtime() {
31
+ return this._runtime
32
+ }
33
+ }
34
+
35
+ export const unistyles = new Unistyles()
@@ -0,0 +1,7 @@
1
+ import { NativeModules } from 'react-native'
2
+
3
+ type UnistylesNativeModule = {
4
+ install(): boolean
5
+ }
6
+
7
+ export const UnistylesModule = NativeModules?.Unistyles as UnistylesNativeModule