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,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.murmurhash2_32_gc = void 0;
7
+ /*
8
+ Authors: Gary Court and Austin Appleby
9
+ Compatible with React Native Web
10
+ https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/exports/StyleSheet/compiler/hash.js#L65
11
+ */
12
+ const murmurhash2_32_gc = (str, seed) => {
13
+ let l = str.length;
14
+ let h = seed ^ l;
15
+ let i = 0;
16
+ let k;
17
+ while (l >= 4) {
18
+ k = str.charCodeAt(i) & 0xff | (str.charCodeAt(++i) & 0xff) << 8 | (str.charCodeAt(++i) & 0xff) << 16 | (str.charCodeAt(++i) & 0xff) << 24;
19
+ k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
20
+ k ^= k >>> 24;
21
+ k = (k & 0xffff) * 0x5bd1e995 + (((k >>> 16) * 0x5bd1e995 & 0xffff) << 16);
22
+ h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16) ^ k;
23
+ l -= 4;
24
+ ++i;
25
+ }
26
+ switch (l) {
27
+ // @ts-ignore
28
+ case 3:
29
+ h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
30
+ // @ts-ignore
31
+ case 2:
32
+ h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
33
+ case 1:
34
+ h ^= str.charCodeAt(i) & 0xff;
35
+ h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
36
+ }
37
+ h ^= h >>> 13;
38
+ h = (h & 0xffff) * 0x5bd1e995 + (((h >>> 16) * 0x5bd1e995 & 0xffff) << 16);
39
+ h ^= h >>> 15;
40
+ return h >>> 0;
41
+ };
42
+ exports.murmurhash2_32_gc = murmurhash2_32_gc;
43
+ //# sourceMappingURL=hash32.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["murmurhash2_32_gc","str","seed","l","length","h","i","k","charCodeAt","exports"],"sourceRoot":"../../../src","sources":["utils/hash32.ts"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACO,MAAMA,iBAAiB,GAAGA,CAACC,GAAW,EAAEC,IAAY,KAAK;EAC5D,IAAIC,CAAC,GAAGF,GAAG,CAACG,MAAM;EAClB,IAAIC,CAAC,GAAGH,IAAI,GAAGC,CAAC;EAChB,IAAIG,CAAC,GAAG,CAAC;EACT,IAAIC,CAAC;EAEL,OAAOJ,CAAC,IAAI,CAAC,EAAE;IACXI,CAAC,GACAN,GAAG,CAACO,UAAU,CAACF,CAAC,CAAC,GAAG,IAAI,GACxB,CAACL,GAAG,CAACO,UAAU,CAAC,EAAEF,CAAC,CAAC,GAAG,IAAI,KAAK,CAAE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,UAAU,IAAI,CAAE,CAACA,CAAC,KAAK,EAAE,IAAI,UAAU,GAAI,MAAM,KAAK,EAAE,CAAC;EAC5EA,CAAC,IAAIA,CAAC,KAAK,EAAE;EAEb,OAAOA,CAAC,KAAK,CAAC;AAClB,CAAC;AAAAI,OAAA,CAAAT,iBAAA,GAAAA,iBAAA"}
@@ -3,37 +3,16 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {
7
- normalizeStyles: true,
8
- getBreakpointFromScreenWidth: true,
9
- sortAndValidateBreakpoints: true,
10
- getValueForBreakpoint: true,
11
- proxifyFunction: true,
12
- parseStyle: true,
13
- isServer: true,
14
- extractValues: true,
15
- getKeyForCustomMediaQuery: true,
16
- isMediaQuery: true,
17
- isWithinTheHeight: true,
18
- isWithinTheWidth: true,
19
- isWithinTheWidthAndHeight: true
20
- };
21
- Object.defineProperty(exports, "extractValues", {
6
+ Object.defineProperty(exports, "generateReactNativeWebId", {
22
7
  enumerable: true,
23
8
  get: function () {
24
- return _mediaQueries.extractValues;
9
+ return _generateId.generateReactNativeWebId;
25
10
  }
26
11
  });
27
- Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
12
+ Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
28
13
  enumerable: true,
29
14
  get: function () {
30
- return _breakpoints.getBreakpointFromScreenWidth;
31
- }
32
- });
33
- Object.defineProperty(exports, "getKeyForCustomMediaQuery", {
34
- enumerable: true,
35
- get: function () {
36
- return _mediaQueries.getKeyForCustomMediaQuery;
15
+ return _mqParser.getKeyForUnistylesMediaQuery;
37
16
  }
38
17
  });
39
18
  Object.defineProperty(exports, "getValueForBreakpoint", {
@@ -42,40 +21,40 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
42
21
  return _breakpoints.getValueForBreakpoint;
43
22
  }
44
23
  });
45
- Object.defineProperty(exports, "isMediaQuery", {
24
+ Object.defineProperty(exports, "isPlatformColor", {
46
25
  enumerable: true,
47
26
  get: function () {
48
- return _mediaQueries.isMediaQuery;
27
+ return _styles.isPlatformColor;
49
28
  }
50
29
  });
51
- Object.defineProperty(exports, "isServer", {
30
+ Object.defineProperty(exports, "isUnistylesMq", {
52
31
  enumerable: true,
53
32
  get: function () {
54
- return _common.isServer;
33
+ return _mqParser.isUnistylesMq;
55
34
  }
56
35
  });
57
- Object.defineProperty(exports, "isWithinTheHeight", {
36
+ Object.defineProperty(exports, "isValidMq", {
58
37
  enumerable: true,
59
38
  get: function () {
60
- return _mediaQueries.isWithinTheHeight;
39
+ return _mqParser.isValidMq;
61
40
  }
62
41
  });
63
- Object.defineProperty(exports, "isWithinTheWidth", {
42
+ Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
64
43
  enumerable: true,
65
44
  get: function () {
66
- return _mediaQueries.isWithinTheWidth;
45
+ return _mqParser.isWithinTheWidthAndHeight;
67
46
  }
68
47
  });
69
- Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
48
+ Object.defineProperty(exports, "mq", {
70
49
  enumerable: true,
71
50
  get: function () {
72
- return _mediaQueries.isWithinTheWidthAndHeight;
51
+ return _mq.mq;
73
52
  }
74
53
  });
75
- Object.defineProperty(exports, "normalizeStyles", {
54
+ Object.defineProperty(exports, "parseMq", {
76
55
  enumerable: true,
77
56
  get: function () {
78
- return _normalizeStyles.normalizeStyles;
57
+ return _mqParser.parseMq;
79
58
  }
80
59
  });
81
60
  Object.defineProperty(exports, "parseStyle", {
@@ -90,27 +69,16 @@ Object.defineProperty(exports, "proxifyFunction", {
90
69
  return _styles.proxifyFunction;
91
70
  }
92
71
  });
93
- Object.defineProperty(exports, "sortAndValidateBreakpoints", {
72
+ Object.defineProperty(exports, "withPlugins", {
94
73
  enumerable: true,
95
74
  get: function () {
96
- return _breakpoints.sortAndValidateBreakpoints;
75
+ return _withPlugins.withPlugins;
97
76
  }
98
77
  });
99
- var _normalizeStyles = require("./normalizeStyles");
100
- var _normalizer = require("./normalizer");
101
- Object.keys(_normalizer).forEach(function (key) {
102
- if (key === "default" || key === "__esModule") return;
103
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
104
- if (key in exports && exports[key] === _normalizer[key]) return;
105
- Object.defineProperty(exports, key, {
106
- enumerable: true,
107
- get: function () {
108
- return _normalizer[key];
109
- }
110
- });
111
- });
78
+ var _mq = require("./mq");
79
+ var _mqParser = require("./mqParser");
112
80
  var _breakpoints = require("./breakpoints");
113
81
  var _styles = require("./styles");
114
- var _common = require("./common");
115
- var _mediaQueries = require("./mediaQueries");
82
+ var _withPlugins = require("./withPlugins");
83
+ var _generateId = require("./generateId");
116
84
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_normalizeStyles","require","_normalizer","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_breakpoints","_styles","_common","_mediaQueries"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAAAE,MAAA,CAAAC,IAAA,CAAAF,WAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,WAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,WAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,YAAA,GAAAd,OAAA;AACA,IAAAe,OAAA,GAAAf,OAAA;AACA,IAAAgB,OAAA,GAAAhB,OAAA;AACA,IAAAiB,aAAA,GAAAjB,OAAA"}
1
+ {"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles","_withPlugins","_generateId"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.mq = void 0;
7
+ var _core = require("../core");
8
+ const getMQValue = value => {
9
+ if (typeof value === 'number') {
10
+ return value;
11
+ }
12
+ if (value === null) {
13
+ return 0;
14
+ }
15
+ return _core.unistyles.registry.breakpoints[value] ?? 0;
16
+ };
17
+
18
+ /**
19
+ * Utility to create cross-platform media queries
20
+ * @returns - JavaScript symbol to be used in your stylesheet
21
+ */
22
+ const mq = exports.mq = {
23
+ only: {
24
+ width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
25
+ height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
26
+ },
27
+ width: (wMin = 0, wMax = Infinity) => ({
28
+ and: {
29
+ height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
30
+ }
31
+ }),
32
+ height: (hMin = 0, hMax = Infinity) => ({
33
+ and: {
34
+ width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
35
+ }
36
+ })
37
+ };
38
+ //# sourceMappingURL=mq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_core","require","getMQValue","value","unistyles","registry","breakpoints","mq","exports","only","width","wMin","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAqBA,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOC,eAAS,CAACC,QAAQ,CAACC,WAAW,CAACH,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;;AAED;AACA;AACA;AACA;AACO,MAAMI,EAAa,GAAAC,OAAA,CAAAD,EAAA,GAAG;EACzBE,IAAI,EAAE;IACFC,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KAAO,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,GAAwB;IACvIE,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KAAO,MAAKX,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;EACpH,CAAC;EACDN,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,MAAM;IAC/DI,GAAG,EAAE;MACDH,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KACxD,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,OAAMV,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;IACjG;EACJ,CAAC,CAAC;EACFF,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,MAAM;IAChEI,GAAG,EAAE;MACDP,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KACvD,MAAKX,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACU,IAAI,CAAE,OAAMV,UAAU,CAACa,IAAI,CAAE,KAAIb,UAAU,CAACc,IAAI,CAAE;IACjG;EACJ,CAAC;AACL,CAAC"}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseMq = exports.isWithinTheWidthAndHeight = exports.isValidMq = exports.isUnistylesMq = exports.getKeyForUnistylesMediaQuery = void 0;
7
+ const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
8
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
9
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
10
+ const parseMq = mq => {
11
+ const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
12
+ const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
13
+ return {
14
+ width: width ? {
15
+ from: Number(fromW),
16
+ to: Number(toW)
17
+ } : undefined,
18
+ height: height ? {
19
+ from: Number(fromH),
20
+ to: Number(toH)
21
+ } : undefined
22
+ };
23
+ };
24
+ exports.parseMq = parseMq;
25
+ const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
26
+ exports.isUnistylesMq = isUnistylesMq;
27
+ const isValidMq = parsedMq => {
28
+ const {
29
+ width,
30
+ height
31
+ } = parsedMq;
32
+ if (width && height) {
33
+ return width.from <= width.to && height.from <= height.to;
34
+ }
35
+ if (width) {
36
+ return width.from <= width.to;
37
+ }
38
+ if (height) {
39
+ return height.from <= height.to;
40
+ }
41
+ return false;
42
+ };
43
+ exports.isValidMq = isValidMq;
44
+ const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
45
+ const {
46
+ width,
47
+ height
48
+ } = parsedMq;
49
+ if (width && height) {
50
+ return isWithinTheWidth(width, screenSize.width) && isWithinTheHeight(height, screenSize.height);
51
+ }
52
+ if (width) {
53
+ return isWithinTheWidth(width, screenSize.width);
54
+ }
55
+ if (height) {
56
+ return isWithinTheHeight(height, screenSize.height);
57
+ }
58
+ return false;
59
+ };
60
+ exports.isWithinTheWidthAndHeight = isWithinTheWidthAndHeight;
61
+ const isWithinTheWidth = (width, screenWidth) => {
62
+ const {
63
+ from,
64
+ to
65
+ } = width;
66
+ return screenWidth >= from && screenWidth <= to;
67
+ };
68
+ const isWithinTheHeight = (height, screenHeight) => {
69
+ const {
70
+ from,
71
+ to
72
+ } = height;
73
+ return screenHeight >= from && screenHeight <= to;
74
+ };
75
+ const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
76
+ const mq = mediaQueries.find(([key]) => {
77
+ if (!isUnistylesMq(key)) {
78
+ return false;
79
+ }
80
+ const parsedMq = parseMq(key);
81
+ if (!isValidMq(parsedMq)) {
82
+ return false;
83
+ }
84
+ return isWithinTheWidthAndHeight(parsedMq, screenSize);
85
+ });
86
+ return mq?.at(0);
87
+ };
88
+ exports.getKeyForUnistylesMediaQuery = getKeyForUnistylesMediaQuery;
89
+ //# sourceMappingURL=mqParser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","from","Number","to","undefined","exports","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","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CAAC,CAAC,CAACC,GAAG,CAAC,KAAK;IACpC,IAAI,CAACb,aAAa,CAACa,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMV,QAAQ,GAAGjB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACX,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOlB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAf,OAAA,CAAAW,4BAAA,GAAAA,4BAAA"}
@@ -5,31 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.proxifyFunction = exports.parseStyle = exports.isPlatformColor = void 0;
7
7
  var _breakpoints = require("./breakpoints");
8
- var _normalizeStyles = require("./normalizeStyles");
9
- var _common = require("./common");
10
- /**
11
- * Proxies a function to parse its return value for custom media queries or breakpoints.
12
- *
13
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
14
- *
15
- * @param {Function} fn - The function to be proxified.
16
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
17
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
18
- * @param breakpointPairs - sorted pairs of breakpoints
19
- *
20
- * @returns {Function} Returns the proxified function
21
- *
22
- * @example
23
- *
24
- * const myFunction = () => ({ ':w[200]': 'value1', sm: 'value2' })
25
- * const screenSize = { width: 250, height: 400 }
26
- * const breakpoints = { sm: 300, md: 600 }
27
- *
28
- * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
29
- * proxifiedFunction() // parsed style based on screenSize and breakpoints
30
- */
31
- const proxifyFunction = (fn, breakpoint, screenSize, breakpointPairs) => new Proxy(fn, {
32
- apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, breakpointPairs)
8
+ var _common = require("../common");
9
+ var _withPlugins = require("./withPlugins");
10
+ const proxifyFunction = (key, fn, variant) => new Proxy(fn, {
11
+ apply: (target, thisArg, argumentsList) => (0, _withPlugins.withPlugins)(key, parseStyle(target.apply(thisArg, argumentsList), variant))
33
12
  });
34
13
  exports.proxifyFunction = proxifyFunction;
35
14
  const isPlatformColor = value => {
@@ -38,53 +17,47 @@ const isPlatformColor = value => {
38
17
  }
39
18
  return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
40
19
  };
41
-
42
- /**
43
- * Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
44
- *
45
- * 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),
46
- * it is returned as-is. Otherwise, the function attempts to resolve the value based on the provided breakpoint, screen size, and defined breakpoints.
47
- *
48
- * @template T - The type of the style object.
49
- * @template B - An object type where keys represent breakpoint names and values represent breakpoint values.
50
- *
51
- * @param {CustomNamedStyles<T, B>} style - The style object to be parsed.
52
- * @param {keyof B & string} breakpoint - The breakpoint name to check against.
53
- * @param {ScreenSize} screenSize - An object representing the screen size to be checked against the media queries.
54
- * @param breakpointPairs - sorted pairs of breakpoints
55
- *
56
- * @returns {Record<string, string | number | Function>} Returns the parsed style object with resolved custom media queries or breakpoints.
57
- *
58
- * @example
59
- *
60
- * const style = { fontSize: { sm: '12px', md: '16px' } }
61
- * const screenSize = { width: 300, height: 400 }
62
- * const breakpoints = { xs: 0, sm: 300, md: 600 }
63
- *
64
- * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
65
- * // { fontSize: '12px' }
66
- */
67
20
  exports.isPlatformColor = isPlatformColor;
68
- const parseStyle = (style, breakpoint, screenSize, breakpointPairs) => {
69
- const entries = Object.entries(style || {});
70
- const parsedStyles = Object.fromEntries(entries.map(_ref => {
71
- let [key, value] = _ref;
72
- const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
73
- if (hasNestedProperties) {
74
- return [key, parseStyle(value, breakpoint, screenSize, breakpointPairs)];
75
- }
76
- const isTransform = key === 'transform';
77
- if (isTransform && Array.isArray(value)) {
78
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize, breakpointPairs))];
79
- }
80
- const isDynamicFunction = typeof value === 'function';
81
- const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
82
- if (isDynamicFunction || isValidStyle) {
83
- return [key, value];
84
- }
85
- return [key, (0, _breakpoints.getValueForBreakpoint)(value, breakpoint, screenSize, breakpointPairs)];
86
- }));
87
- return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
88
- };
21
+ const parseStyle = (style, variant = {}, parseMediaQueries = true) => Object.entries(style || {}).reduce((acc, [key, value]) => {
22
+ // nested objects
23
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
24
+ acc[key] = parseStyle(value, variant);
25
+ return acc;
26
+ }
27
+
28
+ // transforms
29
+ if (key === 'transform' && Array.isArray(value)) {
30
+ acc[key] = value.map(value => parseStyle(value, variant));
31
+ return acc;
32
+ }
33
+
34
+ // values or platform colors
35
+ if (typeof value !== 'object' || isPlatformColor(value)) {
36
+ acc[key] = value;
37
+ return acc;
38
+ }
39
+ if (key === 'variants') {
40
+ return {
41
+ ...acc,
42
+ ...Object.keys(value).reduce((acc, key) => ({
43
+ ...acc,
44
+ // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
45
+ ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
46
+ }), {})
47
+ };
48
+ }
49
+
50
+ // don't parse media queries and breakpoints
51
+ if (!parseMediaQueries) {
52
+ return {
53
+ ...acc,
54
+ [key]: value
55
+ };
56
+ }
57
+ return {
58
+ ...acc,
59
+ [key]: (0, _breakpoints.getValueForBreakpoint)(value)
60
+ };
61
+ }, {});
89
62
  exports.parseStyle = parseStyle;
90
63
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","breakpointPairs","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle","getValueForBreakpoint","isWeb","normalizeStyles"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA4B,EAC1CC,UAAsB,EACtBC,eAA2C,KAChC,IAAIC,KAAK,CAACJ,EAAE,EAAE;EACzBK,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEP,UAAU,EAAEC,UAAU,EAAEC,eAAe;AAChG,CAAC,CAAC;AAAAO,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAEK,MAAMY,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iBAAS,IAAI,gBAAgB,IAAIH,KAAK,IAAI,OAAOA,KAAK,CAACI,cAAc,KAAK,QAAQ;AAC7F,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAxBAN,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAyBO,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AC;AAAAV,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","default","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAK,IAAAC,wBAAW,EAACR,GAAG,EAAES,UAAU,CAACJ,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAAAQ,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAEK,MAAMY,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iBAAS,IAAI,gBAAgB,IAAIH,KAAK,IAAI,OAAOA,KAAK,CAACI,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAAAN,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAEM,MAAMF,UAAU,GAAGA,CACtBQ,KAAQ,EACRf,OAAyC,GAAG,CAAC,CAAC,EAC9CgB,iBAAiB,GAAG,IAAI,KACpBC,MAAM,CACTC,OAAO,CAACH,KAAK,IAAI,CAAC,CAAC,CAAC,CACpBI,MAAM,CAAC,CAACC,GAAG,EAAE,CAACtB,G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AAC,CAAM,CAAC;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.withPlugins = void 0;
7
+ var _core = require("../core");
8
+ const withPlugins = (key, style) => _core.unistyles.registry.plugins.reduce((acc, plugin) => {
9
+ if (plugin.onParsedStyle) {
10
+ return plugin.onParsedStyle(key, acc, _core.unistyles.runtime);
11
+ }
12
+ return acc;
13
+ }, style);
14
+ exports.withPlugins = withPlugins;
15
+ //# sourceMappingURL=withPlugins.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_core","require","withPlugins","key","style","unistyles","registry","plugins","reduce","acc","plugin","onParsedStyle","runtime","exports"],"sourceRoot":"../../../src","sources":["utils/withPlugins.ts"],"mappings":";;;;;;AACA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,WAAW,GAAGA,CACvBC,GAAW,EACXC,KAAc,KACbC,eAAS,CAACC,QAAQ,CAACC,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,EAAEC,MAAM,KAAK;EACpD,IAAIA,MAAM,CAACC,aAAa,EAAE;IACtB,OAAOD,MAAM,CAACC,aAAa,CAACR,GAAG,EAAEM,GAAG,EAAEJ,eAAS,CAACO,OAAO,CAAC;EAC5D;EAEA,OAAOH,GAAG;AACd,CAAC,EAAEL,KAAK,CAAC;AAAAS,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
@@ -0,0 +1,53 @@
1
+ import { Platform } from 'react-native';
2
+ export const warn = message => {
3
+ console.warn(`🦄 [react-native-unistyles]: ${message}`);
4
+ };
5
+ export const isWeb = Platform.OS === 'web';
6
+ export const isIOS = Platform.OS === 'ios';
7
+ export const isAndroid = Platform.OS === 'android';
8
+ export const isMobile = isIOS || isAndroid;
9
+ export const isServer = typeof window === 'undefined';
10
+ export const ScreenOrientation = {
11
+ Landscape: 'landscape',
12
+ Portrait: 'portrait'
13
+ };
14
+ export let IOSContentSizeCategory = /*#__PURE__*/function (IOSContentSizeCategory) {
15
+ IOSContentSizeCategory["ExtraExtraExtraLarge"] = "xxxLarge";
16
+ IOSContentSizeCategory["ExtraExtraLarge"] = "xxLarge";
17
+ IOSContentSizeCategory["ExtraLarge"] = "xLarge";
18
+ IOSContentSizeCategory["Large"] = "Large";
19
+ IOSContentSizeCategory["Medium"] = "Medium";
20
+ IOSContentSizeCategory["Small"] = "Small";
21
+ IOSContentSizeCategory["ExtraSmall"] = "xSmall";
22
+ IOSContentSizeCategory["Unspecified"] = "unspecified";
23
+ return IOSContentSizeCategory;
24
+ }({});
25
+ export let AndroidContentSizeCategory = /*#__PURE__*/function (AndroidContentSizeCategory) {
26
+ AndroidContentSizeCategory["Small"] = "Small";
27
+ AndroidContentSizeCategory["Default"] = "Default";
28
+ AndroidContentSizeCategory["Large"] = "Large";
29
+ AndroidContentSizeCategory["ExtraLarge"] = "ExtraLarge";
30
+ AndroidContentSizeCategory["Huge"] = "Huge";
31
+ return AndroidContentSizeCategory;
32
+ }({});
33
+ export let UnistylesEventType = /*#__PURE__*/function (UnistylesEventType) {
34
+ UnistylesEventType["Theme"] = "theme";
35
+ UnistylesEventType["Layout"] = "layout";
36
+ UnistylesEventType["Plugin"] = "plugin";
37
+ UnistylesEventType["DynamicTypeSize"] = "dynamicTypeSize";
38
+ return UnistylesEventType;
39
+ }({});
40
+ export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
41
+ UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions";
42
+ UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered with UnistylesRegistry";
43
+ UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that was not registered with UnistylesRegistry";
44
+ UnistylesError["ThemeNotSelected"] = "Your themes are registered, but you didn't select the initial theme";
45
+ UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register empty themes object";
46
+ UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register empty breakpoints object";
47
+ UnistylesError["BreakpointsMustStartFromZero"] = "You are trying to register breakpoints that don't start from 0";
48
+ UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix __unistyles";
49
+ UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered";
50
+ UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin";
51
+ return UnistylesError;
52
+ }({});
53
+ //# sourceMappingURL=common.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","ScreenOrientation","Landscape","Portrait","IOSContentSizeCategory","AndroidContentSizeCategory","UnistylesEventType","UnistylesError"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,IAAI,GAAIC,OAAe,IAAK;EACrCC,OAAO,CAACF,IAAI,CAAE,gCAA+BC,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAME,KAAK,GAAGJ,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,SAAS,GAAGP,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMG,QAAQ,GAAGF,KAAK,IAAIC,SAAS;AAC1C,OAAO,MAAME,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAEV,WAAYC,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAWlC,WAAYC,0BAA0B,0BAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAA1BA,0BAA0B;EAAA,OAA1BA,0BAA0B;AAAA;AAQtC,WAAYC,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAO9B,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
@@ -0,0 +1,87 @@
1
+ import { isWeb, UnistylesError } from '../common';
2
+ import { cssMediaQueriesPlugin, normalizeWebStylesPlugin } from '../plugins';
3
+ export class UnistyleRegistry {
4
+ config = {};
5
+ plugins = isWeb ? [normalizeWebStylesPlugin] : [];
6
+ themeNames = [];
7
+ themes = {};
8
+ breakpoints = {};
9
+ sortedBreakpointPairs = [];
10
+ constructor(unistylesBridge) {
11
+ this.unistylesBridge = unistylesBridge;
12
+ }
13
+ addThemes = themes => {
14
+ this.themes = themes;
15
+ const keys = Object.keys(themes);
16
+ this.unistylesBridge.themes = keys;
17
+ this.themeNames = keys;
18
+ return {
19
+ addBreakpoints: this.addBreakpoints,
20
+ addConfig: this.addConfig
21
+ };
22
+ };
23
+ addBreakpoints = breakpoints => {
24
+ this.breakpoints = breakpoints;
25
+ this.unistylesBridge.useBreakpoints(breakpoints);
26
+ this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
27
+ return {
28
+ addThemes: this.addThemes,
29
+ addConfig: this.addConfig
30
+ };
31
+ };
32
+ addConfig = config => {
33
+ this.config = config;
34
+ if (config.adaptiveThemes) {
35
+ this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
36
+ }
37
+ if (config.plugins) {
38
+ config.plugins.forEach(plugin => this.addPlugin(plugin, false));
39
+ }
40
+ if (config.initialTheme) {
41
+ this.unistylesBridge.useTheme(config.initialTheme);
42
+ }
43
+ if (config.experimentalCSSMediaQueries) {
44
+ this.plugins = [cssMediaQueriesPlugin].concat(this.plugins);
45
+ this.unistylesBridge.addPlugin(cssMediaQueriesPlugin.name, false);
46
+ }
47
+ return {
48
+ addBreakpoints: this.addBreakpoints,
49
+ addThemes: this.addThemes
50
+ };
51
+ };
52
+ getTheme = forName => {
53
+ if (this.themeNames.length === 0) {
54
+ return {};
55
+ }
56
+ if (this.hasTheme(forName)) {
57
+ return this.themes[forName];
58
+ }
59
+ if (this.unistylesBridge.themeName) {
60
+ throw new Error(UnistylesError.ThemeNotFound);
61
+ }
62
+ throw new Error(UnistylesError.ThemeNotSelected);
63
+ };
64
+ addPlugin = (plugin, notify = true) => {
65
+ if (plugin.name.startsWith('__unistyles')) {
66
+ throw new Error(UnistylesError.InvalidPluginName);
67
+ }
68
+ if (this.plugins.some(({
69
+ name
70
+ }) => name === plugin.name)) {
71
+ throw new Error(UnistylesError.DuplicatePluginName);
72
+ }
73
+ this.plugins = [plugin].concat(this.plugins);
74
+ this.unistylesBridge.addPlugin(plugin.name, notify);
75
+ };
76
+ removePlugin = plugin => {
77
+ if (plugin.name.startsWith('__unistyles')) {
78
+ throw new Error(UnistylesError.CantRemoveInternalPlugin);
79
+ }
80
+ this.plugins = this.plugins.filter(({
81
+ name
82
+ }) => name !== plugin.name);
83
+ this.unistylesBridge.removePlugin(plugin.name);
84
+ };
85
+ hasTheme = name => name in this.themes;
86
+ }
87
+ //# sourceMappingURL=UnistyleRegistry.js.map