react-native-unistyles 2.0.0-alpha.9 → 2.0.0-beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. package/android/CMakeLists.txt +28 -0
  2. package/android/build.gradle +40 -0
  3. package/android/src/main/cxx/cpp-adapter.cpp +108 -0
  4. package/android/src/main/java/com/unistyles/UnistylesModule.kt +159 -0
  5. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +18 -0
  6. package/cxx/UnistylesRuntime.cpp +55 -2
  7. package/cxx/UnistylesRuntime.h +15 -9
  8. package/ios/UnistylesModule.mm +12 -2
  9. package/lib/commonjs/common.js +30 -16
  10. package/lib/commonjs/common.js.map +1 -1
  11. package/lib/commonjs/core/UnistyleRegistry.js +65 -3
  12. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  13. package/lib/commonjs/core/UnistylesRuntime.js +15 -16
  14. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  15. package/lib/commonjs/createStyleSheet.js +1 -6
  16. package/lib/commonjs/createStyleSheet.js.map +1 -1
  17. package/lib/commonjs/hooks/index.js +7 -0
  18. package/lib/commonjs/hooks/index.js.map +1 -1
  19. package/lib/commonjs/hooks/useUnistyles.js +11 -8
  20. package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
  21. package/lib/commonjs/hooks/useVariants.js +14 -0
  22. package/lib/commonjs/hooks/useVariants.js.map +1 -0
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/plugins/index.js +38 -0
  25. package/lib/commonjs/plugins/index.js.map +1 -0
  26. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
  27. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
  28. package/lib/commonjs/plugins/normalizer/index.js +32 -0
  29. package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
  30. package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
  31. package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
  32. package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
  33. package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +1 -1
  34. package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
  35. package/lib/commonjs/types/{mq.js → plugin.js} +1 -1
  36. package/lib/commonjs/types/{mq.js.map → plugin.js.map} +1 -1
  37. package/lib/commonjs/types/stylesheet.js +6 -0
  38. package/lib/commonjs/types/stylesheet.js.map +1 -0
  39. package/lib/commonjs/types/variants.js +2 -0
  40. package/lib/commonjs/{utils/module.d.js.map → types/variants.js.map} +1 -1
  41. package/lib/commonjs/useStyles.js +10 -20
  42. package/lib/commonjs/useStyles.js.map +1 -1
  43. package/lib/commonjs/utils/breakpoints.js +13 -59
  44. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  45. package/lib/commonjs/utils/index.js +13 -51
  46. package/lib/commonjs/utils/index.js.map +1 -1
  47. package/lib/commonjs/utils/mq.js +36 -68
  48. package/lib/commonjs/utils/mq.js.map +1 -1
  49. package/lib/commonjs/utils/mqParser.js +4 -1
  50. package/lib/commonjs/utils/mqParser.js.map +1 -1
  51. package/lib/commonjs/utils/styles.js +35 -20
  52. package/lib/commonjs/utils/styles.js.map +1 -1
  53. package/lib/commonjs/utils/withPlugins.js +15 -0
  54. package/lib/commonjs/utils/withPlugins.js.map +1 -0
  55. package/lib/module/common.js +28 -17
  56. package/lib/module/common.js.map +1 -1
  57. package/lib/module/core/UnistyleRegistry.js +65 -3
  58. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  59. package/lib/module/core/UnistylesRuntime.js +15 -16
  60. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  61. package/lib/module/createStyleSheet.js +1 -6
  62. package/lib/module/createStyleSheet.js.map +1 -1
  63. package/lib/module/hooks/index.js +1 -0
  64. package/lib/module/hooks/index.js.map +1 -1
  65. package/lib/module/hooks/useUnistyles.js +12 -9
  66. package/lib/module/hooks/useUnistyles.js.map +1 -1
  67. package/lib/module/hooks/useVariants.js +7 -0
  68. package/lib/module/hooks/useVariants.js.map +1 -0
  69. package/lib/module/index.js.map +1 -1
  70. package/lib/module/plugins/index.js +3 -0
  71. package/lib/module/plugins/index.js.map +1 -0
  72. package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
  73. package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
  74. package/lib/module/plugins/normalizer/index.js +3 -0
  75. package/lib/module/plugins/normalizer/index.js.map +1 -0
  76. package/lib/module/plugins/normalizer/module.d.js.map +1 -0
  77. package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
  78. package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
  79. package/lib/module/{utils → plugins/normalizer}/normalizer.js +1 -1
  80. package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
  81. package/lib/module/types/plugin.js +2 -0
  82. package/lib/module/types/{mq.js.map → plugin.js.map} +1 -1
  83. package/lib/module/types/stylesheet.js +2 -0
  84. package/lib/module/types/stylesheet.js.map +1 -0
  85. package/lib/module/types/variants.js +2 -0
  86. package/lib/module/{utils/module.d.js.map → types/variants.js.map} +1 -1
  87. package/lib/module/useStyles.js +12 -22
  88. package/lib/module/useStyles.js.map +1 -1
  89. package/lib/module/utils/breakpoints.js +12 -56
  90. package/lib/module/utils/breakpoints.js.map +1 -1
  91. package/lib/module/utils/index.js +4 -6
  92. package/lib/module/utils/index.js.map +1 -1
  93. package/lib/module/utils/mq.js +35 -67
  94. package/lib/module/utils/mq.js.map +1 -1
  95. package/lib/module/utils/mqParser.js +3 -3
  96. package/lib/module/utils/mqParser.js.map +1 -1
  97. package/lib/module/utils/styles.js +35 -20
  98. package/lib/module/utils/styles.js.map +1 -1
  99. package/lib/module/utils/withPlugins.js +8 -0
  100. package/lib/module/utils/withPlugins.js.map +1 -0
  101. package/lib/typescript/src/common.d.ts +23 -12
  102. package/lib/typescript/src/common.d.ts.map +1 -1
  103. package/lib/typescript/src/core/UnistyleRegistry.d.ts +45 -4
  104. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
  105. package/lib/typescript/src/core/UnistylesRuntime.d.ts +8 -9
  106. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  107. package/lib/typescript/src/core/index.d.ts +1 -0
  108. package/lib/typescript/src/core/index.d.ts.map +1 -1
  109. package/lib/typescript/src/createStyleSheet.d.ts +2 -2
  110. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
  111. package/lib/typescript/src/global.d.ts.map +1 -1
  112. package/lib/typescript/src/hooks/index.d.ts +1 -0
  113. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  114. package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
  115. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
  116. package/lib/typescript/src/hooks/useVariants.d.ts +3 -0
  117. package/lib/typescript/src/hooks/useVariants.d.ts.map +1 -0
  118. package/lib/typescript/src/index.d.ts +51 -5
  119. package/lib/typescript/src/index.d.ts.map +1 -1
  120. package/lib/typescript/src/plugins/index.d.ts +3 -0
  121. package/lib/typescript/src/plugins/index.d.ts.map +1 -0
  122. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
  123. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
  124. package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
  125. package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
  126. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
  127. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
  128. package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
  129. package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
  130. package/lib/typescript/src/types/breakpoints.d.ts +25 -12
  131. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  132. package/lib/typescript/src/types/core.d.ts +6 -27
  133. package/lib/typescript/src/types/core.d.ts.map +1 -1
  134. package/lib/typescript/src/types/index.d.ts +4 -2
  135. package/lib/typescript/src/types/index.d.ts.map +1 -1
  136. package/lib/typescript/src/types/plugin.d.ts +7 -0
  137. package/lib/typescript/src/types/plugin.d.ts.map +1 -0
  138. package/lib/typescript/src/types/stylesheet.d.ts +40 -0
  139. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -0
  140. package/lib/typescript/src/types/unistyles.d.ts +16 -11
  141. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  142. package/lib/typescript/src/types/variants.d.ts +14 -0
  143. package/lib/typescript/src/types/variants.d.ts.map +1 -0
  144. package/lib/typescript/src/useStyles.d.ts +3 -3
  145. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  146. package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
  147. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  148. package/lib/typescript/src/utils/index.d.ts +4 -6
  149. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  150. package/lib/typescript/src/utils/mq.d.ts +15 -14
  151. package/lib/typescript/src/utils/mq.d.ts.map +1 -1
  152. package/lib/typescript/src/utils/mqParser.d.ts +14 -2
  153. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
  154. package/lib/typescript/src/utils/styles.d.ts +3 -4
  155. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  156. package/lib/typescript/src/utils/withPlugins.d.ts +3 -0
  157. package/lib/typescript/src/utils/withPlugins.d.ts.map +1 -0
  158. package/package.json +19 -16
  159. package/src/__tests__/mocks.ts +24 -0
  160. package/src/common.ts +30 -14
  161. package/src/core/UnistyleRegistry.ts +66 -4
  162. package/src/core/UnistylesRuntime.ts +18 -20
  163. package/src/core/index.ts +1 -0
  164. package/src/createStyleSheet.ts +2 -8
  165. package/src/global.ts +1 -0
  166. package/src/hooks/index.ts +1 -0
  167. package/src/hooks/useUnistyles.ts +11 -9
  168. package/src/hooks/useVariants.ts +10 -0
  169. package/src/index.ts +3 -1
  170. package/src/plugins/index.ts +2 -0
  171. package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
  172. package/src/plugins/normalizer/index.ts +2 -0
  173. package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
  174. package/src/{utils → plugins/normalizer}/normalizer.ts +3 -3
  175. package/src/types/breakpoints.ts +57 -25
  176. package/src/types/core.ts +9 -43
  177. package/src/types/index.ts +11 -2
  178. package/src/types/plugin.ts +7 -0
  179. package/src/types/stylesheet.ts +49 -0
  180. package/src/types/unistyles.ts +18 -13
  181. package/src/types/variants.ts +19 -0
  182. package/src/useStyles.ts +18 -25
  183. package/src/utils/breakpoints.ts +11 -67
  184. package/src/utils/index.ts +4 -6
  185. package/src/utils/mq.ts +31 -84
  186. package/src/utils/mqParser.ts +5 -5
  187. package/src/utils/styles.ts +44 -50
  188. package/src/utils/withPlugins.ts +13 -0
  189. package/lib/commonjs/utils/common.js +0 -25
  190. package/lib/commonjs/utils/common.js.map +0 -1
  191. package/lib/commonjs/utils/normalizeStyles.js +0 -10
  192. package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
  193. package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
  194. package/lib/commonjs/utils/normalizer.js.map +0 -1
  195. package/lib/module/types/mq.js +0 -2
  196. package/lib/module/utils/common.js +0 -17
  197. package/lib/module/utils/common.js.map +0 -1
  198. package/lib/module/utils/normalizeStyles.js +0 -3
  199. package/lib/module/utils/normalizeStyles.js.map +0 -1
  200. package/lib/module/utils/normalizeStyles.web.js.map +0 -1
  201. package/lib/module/utils/normalizer.js.map +0 -1
  202. package/lib/typescript/src/types/mq.d.ts +0 -3
  203. package/lib/typescript/src/types/mq.d.ts.map +0 -1
  204. package/lib/typescript/src/utils/common.d.ts +0 -12
  205. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  206. package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
  207. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
  208. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
  209. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
  210. package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
  211. package/src/types/mq.ts +0 -3
  212. package/src/utils/common.ts +0 -20
  213. package/src/utils/normalizeStyles.ts +0 -2
  214. /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
  215. /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
  216. /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -1,5 +1,8 @@
1
+ import { isWeb, UnistylesError } from '../common';
2
+ import { normalizeWebStylesPlugin } from '../plugins';
1
3
  export class UnistyleRegistry {
2
4
  config = {};
5
+ plugins = isWeb ? [normalizeWebStylesPlugin] : [];
3
6
  themeNames = [];
4
7
  themes = {};
5
8
  breakpoints = {};
@@ -12,20 +15,79 @@ export class UnistyleRegistry {
12
15
  const keys = Object.keys(themes);
13
16
  this.unistylesBridge.themes = keys;
14
17
  this.themeNames = keys;
15
- return this;
18
+ return {
19
+ addBreakpoints: this.addBreakpoints,
20
+ addConfig: this.addConfig
21
+ };
16
22
  };
17
23
  addBreakpoints = breakpoints => {
18
24
  this.breakpoints = breakpoints;
19
25
  this.unistylesBridge.useBreakpoints(breakpoints);
20
26
  this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
21
- return this;
27
+ return {
28
+ addThemes: this.addThemes,
29
+ addConfig: this.addConfig
30
+ };
22
31
  };
23
32
  addConfig = config => {
24
33
  this.config = config;
25
34
  if (config.adaptiveThemes) {
26
35
  this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
27
36
  }
28
- return this;
37
+ if (config.experimentalPlugins) {
38
+ config.experimentalPlugins.forEach(plugin => this.addPlugin(plugin, false));
39
+ }
40
+ if (config.initialTheme) {
41
+ this.unistylesBridge.useTheme(config.initialTheme);
42
+ }
43
+ return {
44
+ addBreakpoints: this.addBreakpoints,
45
+ addThemes: this.addThemes
46
+ };
47
+ };
48
+ getTheme = forName => {
49
+ if (this.themeNames.length === 0) {
50
+ return {};
51
+ }
52
+ if (this.hasTheme(forName)) {
53
+ return this.themes[forName];
54
+ }
55
+ if (this.unistylesBridge.themeName) {
56
+ throw new Error(UnistylesError.ThemeNotFound);
57
+ }
58
+ throw new Error(UnistylesError.ThemeNotSelected);
59
+ };
60
+ addPlugin = (() => {
61
+ var _this = this;
62
+ return function (plugin) {
63
+ let notify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
64
+ if (plugin.name.startsWith('__unistyles')) {
65
+ throw new Error(UnistylesError.InvalidPluginName);
66
+ }
67
+ if (_this.plugins.some(_ref => {
68
+ let {
69
+ name
70
+ } = _ref;
71
+ return name === plugin.name;
72
+ })) {
73
+ throw new Error(UnistylesError.DuplicatePluginName);
74
+ }
75
+ _this.plugins = [plugin].concat(_this.plugins);
76
+ _this.unistylesBridge.addPlugin(plugin.name, notify);
77
+ };
78
+ })();
79
+ removePlugin = plugin => {
80
+ if (plugin.name.startsWith('__unistyles')) {
81
+ throw new Error(UnistylesError.CantRemoveInternalPlugin);
82
+ }
83
+ this.plugins = this.plugins.filter(_ref2 => {
84
+ let {
85
+ name
86
+ } = _ref2;
87
+ return name !== plugin.name;
88
+ });
89
+ this.unistylesBridge.removePlugin(plugin.name);
29
90
  };
91
+ hasTheme = name => name in this.themes;
30
92
  }
31
93
  //# sourceMappingURL=UnistyleRegistry.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAGA,OAAO,MAAMA,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACN,MAAM,CAAiC;IAEhE,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,IAAI;IAClC,IAAI,CAACP,UAAU,GAAGO,IAAI;IAEtB,OAAO,IAAI;EACf,CAAC;EAEME,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACG,eAAe,CAACK,cAAc,CAACR,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMQ,SAAS,GAAIZ,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACa,cAAc,EAAE;MACvB,IAAI,CAACP,eAAe,CAACQ,iBAAiB,CAACd,MAAM,CAACa,cAAc,CAAC;IACjE;IAEA,OAAO,IAAI;EACf,CAAC;AACL"}
1
+ {"version":3,"names":["isWeb","UnistylesError","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2"],"sourceRoot":"../../../src","sources":["core/Un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;QAAA,OAAKJ,IAAI,KAAKhB,MAAM,CAACgB,IAAI;MAAA,EAAC,EAAE;QACvD,MAAM,IAAIP,KAAK,CAAC9B,cAAc,CAAC0C,mBAAmB,CAAC;MACvD;MAEAT,KAAI,CAAC7B,OAAO,GAAG,CAACiB,MAAM,CAAC,CAACsB,MAAM,CAACV,KAAI,CAAC7B,OAAO,CAAC;MAC5C6B,KAAI,CAACvB,eAAe,CAACY,SAAS,CAACD,MAAM,CAACgB,IAAI,EAAEH,MAAM,CAAC;IACvD,CAAC;EAAA;EAEMU,YAAY,GAAIvB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACgB,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIR,KAAK,CAAC9B,cAAc,CAAC6C,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAACzC,OAAO,GAAG,IAAI,CAACA,OAAO,CAAC0C,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEV;MAAK,CAAC,GAAAU,KAAA;MAAA,OAAKV,IAAI,KAAKhB,MAAM,CAACgB,IAAI;IAAA,EAAC;IACtE,IAAI,CAAC3B,eAAe,CAACkC,YAAY,CAACvB,MAAM,CAACgB,IAAI,CAAC;EAClD,CAAC;EAEMT,QAAQ,GAAIS,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAC/B,MAAM;AAC1E"}
@@ -1,8 +1,8 @@
1
1
  import { ScreenOrientation, UnistylesError } from '../common';
2
2
  export class UnistylesRuntime {
3
- constructor(unistylesBridge, registry) {
3
+ constructor(unistylesBridge, unistylesRegistry) {
4
4
  this.unistylesBridge = unistylesBridge;
5
- this.registry = registry;
5
+ this.unistylesRegistry = unistylesRegistry;
6
6
  }
7
7
  get colorScheme() {
8
8
  return this.unistylesBridge.colorScheme;
@@ -10,15 +10,15 @@ export class UnistylesRuntime {
10
10
  get hasAdaptiveThemes() {
11
11
  return this.unistylesBridge.hasAdaptiveThemes;
12
12
  }
13
- get sortedBreakpoints() {
14
- return this.registry.sortedBreakpointPairs;
15
- }
16
13
  get themeName() {
17
14
  return this.unistylesBridge.themeName;
18
15
  }
19
16
  get breakpoint() {
20
17
  return this.unistylesBridge.breakpoint;
21
18
  }
19
+ get enabledPlugins() {
20
+ return this.unistylesBridge.enabledPlugins;
21
+ }
22
22
  get screen() {
23
23
  return {
24
24
  width: this.unistylesBridge.screenWidth,
@@ -36,24 +36,23 @@ export class UnistylesRuntime {
36
36
  return ScreenOrientation.Portrait;
37
37
  }
38
38
  setTheme = name => {
39
- if (this.hasTheme(name)) {
39
+ if (name === this.themeName) {
40
+ return;
41
+ }
42
+ if (this.unistylesRegistry.hasTheme(name)) {
40
43
  this.unistylesBridge.useTheme(name);
41
44
  return true;
42
45
  }
43
46
  throw new Error(UnistylesError.ThemeNotRegistered);
44
47
  };
45
- getTheme = forName => {
46
- if (this.registry.themeNames.length === 0) {
47
- return {};
48
- }
49
- if (!this.hasTheme(forName)) {
50
- throw new Error(UnistylesError.ThemeNotFound);
51
- }
52
- return this.registry.themes[forName];
53
- };
54
48
  setAdaptiveThemes = enable => {
55
49
  this.unistylesBridge.useAdaptiveThemes(enable);
56
50
  };
57
- hasTheme = name => name in this.registry.themes;
51
+ addPlugin = plugin => {
52
+ this.unistylesRegistry.addPlugin(plugin);
53
+ };
54
+ removePlugin = plugin => {
55
+ this.unistylesRegistry.removePlugin(plugin);
56
+ };
58
57
  }
59
58
  //# sourceMappingURL=UnistylesRuntime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"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kBAAkB,CAAC;EACtD,CAAC;EAEMC,QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,IAAI,CAACtB,QAAQ,CAACuB,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;MACvC,OAAO,CAAC,CAAC;IACb;IAEA,IAAI,CAAC,IAAI,CAACP,QAAQ,CAACK,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIH,KAAK,CAACvB,cAAc,CAAC6B,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAACzB,QAAQ,CAAC0B,MAAM,CAACJ,OAAO,CAAC;EACxC,CAAC;EAEMK,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC7B,eAAe,CAAC8B,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOX,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAChB,QAAQ,CAAC0B,MAAM;AACpF"}
1
+ {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;EAEpG,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG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iB,CAACyB,YAAY,CAACD,MAAM,CAAC;EAC/C,CAAC;AACL"}
@@ -1,7 +1,2 @@
1
- export const createStyleSheet = styles => {
2
- if (typeof styles === 'function') {
3
- return styles;
4
- }
5
- return styles;
6
- };
1
+ export const createStyleSheet = stylesheet => stylesheet;
7
2
  //# sourceMappingURL=createStyleSheet.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createStyleSheet","styles"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,GAAUC,MAA4F,IAAY;EAC3I,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM;EACjB;EAEA,OAAOA,MAAM;AACjB,CAAC"}
1
+ {"version":3,"names":["createStyleSheet","stylesheet"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAEA,OAAO,MAAMA,gBAAgB,GAAyCC,UAAa,IAAQA,UAAU"}
@@ -1,3 +1,4 @@
1
1
  export { useInitialTheme } from './useInitialTheme';
2
2
  export { useUnistyles } from './useUnistyles';
3
+ export { useVariants } from './useVariants';
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useInitialTheme","useUnistyles"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,YAAY,QAAQ,gBAAgB"}
1
+ {"version":3,"names":["useInitialTheme","useUnistyles","useVariants"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,WAAW,QAAQ,eAAe"}
@@ -1,10 +1,11 @@
1
1
  import { NativeEventEmitter, NativeModules } from 'react-native';
2
2
  import { useEffect, useState } from 'react';
3
3
  import { unistyles } from '../core';
4
- import { CxxUnistylesEventTypes } from '../common';
4
+ import { UnistylesEventType } from '../common';
5
5
  const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
6
6
  export const useUnistyles = () => {
7
- const [theme, setTheme] = useState(unistyles.runtime.getTheme(unistyles.runtime.themeName));
7
+ const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins);
8
+ const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName));
8
9
  const [layout, setLayout] = useState({
9
10
  breakpoint: unistyles.runtime.breakpoint,
10
11
  orientation: unistyles.runtime.orientation,
@@ -16,23 +17,24 @@ export const useUnistyles = () => {
16
17
  useEffect(() => {
17
18
  const subscription = unistylesEvents.addListener('onChange', event => {
18
19
  switch (event.type) {
19
- case CxxUnistylesEventTypes.Theme:
20
+ case UnistylesEventType.Theme:
20
21
  {
21
22
  const themeEvent = event;
22
- return setTheme(unistyles.runtime.getTheme(themeEvent.payload.themeName));
23
+ return setTheme(unistyles.registry.getTheme(themeEvent.payload.themeName));
23
24
  }
24
- case CxxUnistylesEventTypes.Layout:
25
+ case UnistylesEventType.Layout:
25
26
  {
26
27
  const layoutEvent = event;
27
28
  return setLayout({
28
29
  breakpoint: layoutEvent.payload.breakpoint,
29
30
  orientation: layoutEvent.payload.orientation,
30
- screenSize: {
31
- width: layoutEvent.payload.screen.width,
32
- height: layoutEvent.payload.screen.height
33
- }
31
+ screenSize: layoutEvent.payload.screen
34
32
  });
35
33
  }
34
+ case UnistylesEventType.Plugin:
35
+ {
36
+ return setPlugins(unistyles.runtime.enabledPlugins);
37
+ }
36
38
  default:
37
39
  return;
38
40
  }
@@ -40,6 +42,7 @@ export const useUnistyles = () => {
40
42
  return subscription.remove;
41
43
  }, []);
42
44
  return {
45
+ plugins,
43
46
  theme,
44
47
  layout
45
48
  };
@@ -1 +1 @@
1
- {"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","unistyles","CxxUnistylesEventTypes","unistylesEvents","Unistyles","useUnistyles","theme","setTheme","runtime","getTheme","themeName","layout","setLayout","breakpoint","orientation","screenSize","width","screen","height","subscription","addListener","event","type","Theme","themeEvent","payload","Layout","layoutEvent","remove"],"sourceRoot":"../../../src","sources":["hooks/useUnistyles.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,sBAAsB,QAAQ,WAAW;AAGlD,MAAMC,eAAe,GAAG,IAAIN,kBAAkB,CAACC,aAAa,CAACM,SAAS,CAAC;AAEvE,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGP,QAAQ,CAACC,SAAS,CAACO,OAAO,CAACC,QAAQ,CAACR,SAAS,CAACO,OAAO,CAACE,SAAS,CAAC,CAAC;EAC3F,MAAM,CAACC,MAAM,EAAEC,SAAS,CAAC,GAAGZ,QAAQ,CAAC;IACjCa,UAAU,EAAEZ,SAAS,CAACO,OAAO,CAACK,UAAU;IACxCC,WAAW,EAAEb,SAAS,CAACO,OAAO,CAACM,WAAW;IAC1CC,UAAU,EAAE;MACRC,KAAK,EAAEf,SAAS,CAACO,OAAO,CAACS,MAAM,CAACD,KAAK;MACrCE,MAAM,EAAEjB,SAAS,CAACO,OAAO,CAACS,MAAM,CAACC;IACrC;EACJ,CAAC,CAAC;EAEFnB,SAAS,CAAC,MAAM;IACZ,MAAMoB,YAAY,GAAGhB,eAAe,CAACiB,WAAW,CAC5C,UAAU,EACTC,KAAsB,IAAK;MACxB,QAAQA,KAAK,CAACC,IAAI;QACd,KAAKpB,sBAAsB,CAACqB,KAAK;UAAE;YAC/B,MAAMC,UAAU,GAAGH,KAA4B;YAE/C,OAAOd,QAAQ,CAACN,SAAS,CAACO,OAAO,CAACC,QAAQ,CAACe,UAAU,CAACC,OAAO,CAACf,SAAS,CAAC,CAAC;UAC7E;QACA,KAAKR,sBAAsB,CAACwB,MAAM;UAAE;YAChC,MAAMC,WAAW,GAAGN,KAAmC;YAEvD,OAAOT,SAAS,CAAC;cACbC,UAAU,EAAEc,WAAW,CAACF,OAAO,CAACZ,UAAU;cAC1CC,WAAW,EAAEa,WAAW,CAACF,OAAO,CAACX,WAAW;cAC5CC,UAAU,EAAE;gBACRC,KAAK,EAAEW,WAAW,CAACF,OAAO,CAACR,MAAM,CAACD,KAAK;gBACvCE,MAAM,EAAES,WAAW,CAACF,OAAO,CAACR,MAAM,CAACC;cACvC;YACJ,CAAC,CAAC;UACN;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOC,YAAY,CAACS,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACHtB,KAAK;IACLK;EACJ,CAAC;AACL,CAAC"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","unistyles","UnistylesEventType","unistylesEvents","Unistyles","useUnistyles","plugins","setPlugins","runtime","enabledPlugins","theme","setTheme","registry","getTheme","themeName","layout","setLayout","breakpoint","orientation","screenSize","width","screen","height","subscription","addListener","event","type","Theme","themeEvent","payload","Layout","layoutEvent","Plugin","remove"],"sourceRoot":"../../../src","sources":["hooks/useUnistyles.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAChE,SAASC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAC3C,SAASC,SAAS,QAAQ,SAAS;AACnC,SAASC,kBAAkB,QAAQ,WAAW;AAG9C,MAAMC,eAAe,GAAG,IAAIN,kBAAkB,CAACC,aAAa,CAACM,SAAS,CAAC;AAEvE,OAAO,MAAMC,YAAY,GAAGA,CAAA,KAAM;EAC9B,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGP,QAAQ,CAACC,SAAS,CAACO,OAAO,CAACC,cAAc,CAAC;EACxE,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGX,QAAQ,CAACC,SAAS,CAACW,QAAQ,CAACC,QAAQ,CAACZ,SAAS,CAACO,OAAO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AC"}
@@ -0,0 +1,7 @@
1
+ import { useRef } from 'react';
2
+ export const useVariants = variantsMap => {
3
+ const variantsRef = useRef(variantsMap);
4
+ variantsRef.current = variantsMap;
5
+ return variantsRef.current;
6
+ };
7
+ //# sourceMappingURL=useVariants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useRef","useVariants","variantsMap","variantsRef","current"],"sourceRoot":"../../../src","sources":["hooks/useVariants.ts"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAG9B,OAAO,MAAMC,WAAW,GAAIC,WAA8C,IAAK;EAC3E,MAAMC,WAAW,GAAGH,MAAM,CAA6CE,WAAW,CAAC;EAEnFC,WAAW,CAACC,OAAO,GAAGF,WAAW;EAEjC,OAAOC,WAAW,CAACC,OAAO;AAC9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","mq","useInitialTheme","ScreenOrientation","useStyles","createStyleSheet","UnistylesRegistry","addThemes","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,eAAe,QAAQ,SAAS;AAEzC,SAASC,iBAAiB,QAAQ,UAAU;AAC5C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,iBAAiB,GAAG;EACtBC,SAAS,EAAEP,SAAS,CAACQ,QAAQ,CAACD,SAAS;EACvCE,cAAc,EAAET,SAAS,CAACQ,QAAQ,CAACC,cAAc;EACjDC,SAAS,EAAEV,SAAS,CAACQ,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAGX,SAAS,CAACY,OAAO;AAE1C,SACIX,EAAE,EACFG,SAAS,EACTF,eAAe,EACfG,gBAAgB,EAChBF,iBAAiB,EACjBG,iBAAiB,EACjBK,gBAAgB"}
1
+ {"version":3,"names":["unistyles","mq","useInitialTheme","ScreenOrientation","useStyles","createStyleSheet","UnistylesRegistry","addThemes","registry","addBreakpoints","addConfig","UnistylesRuntime","runtime"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,QAAQ;AAClC,SAASC,EAAE,QAAQ,SAAS;AAC5B,SAASC,eAAe,QAAQ,SAAS;AAGzC,SAASC,iBAAiB,QAAQ,UAAU;AAC5C,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAMC,iBAAiB,GAAG;EACtBC,SAAS,EAAEP,SAAS,CAACQ,QAAQ,CAACD,SAAS;EACvCE,cAAc,EAAET,SAAS,CAACQ,QAAQ,CAACC,cAAc;EACjDC,SAAS,EAAEV,SAAS,CAACQ,QAAQ,CAACE;AAClC,CAAC;AAED,MAAMC,gBAAgB,GAAGX,SAAS,CAACY,OAAO;AAE1C,SACIX,EAAE,EACFG,SAAS,EACTF,eAAe,EACfG,gBAAgB,EAChBF,iBAAiB,EACjBG,iBAAiB,EACjBK,gBAAgB"}
@@ -0,0 +1,3 @@
1
+ export { normalizeWebStylesPlugin } from './normalizeWebStylesPlugin';
2
+ export { preprocessor, normalizeNumericValue, normalizeColor, normalizeStyle } from './normalizer';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalizeWebStylesPlugin","preprocessor","normalizeNumericValue","normalizeColor","normalizeStyle"],"sourceRoot":"../../../src","sources":["plugins/index.ts"],"mappings":"AAAA,SAASA,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,YAAY,EAAEC,qBAAqB,EAAEC,cAAc,EAAEC,cAAc,QAAQ,cAAc"}
@@ -0,0 +1,6 @@
1
+ import { normalizeStyle } from './normalizer';
2
+ export const normalizeWebStylesPlugin = {
3
+ name: '__unistylesNormalizeWebStyles',
4
+ onParsedStyle: (_key, styles) => normalizeStyle(styles)
5
+ };
6
+ //# sourceMappingURL=normalizeWebStylesPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalizeStyle","normalizeWebStylesPlugin","name","onParsedStyle","_key","styles"],"sourceRoot":"../../../src","sources":["plugins/normalizeWebStylesPlugin.ts"],"mappings":"AACA,SAASA,cAAc,QAAQ,cAAc;AAE7C,OAAO,MAAMC,wBAAyC,GAAG;EACrDC,IAAI,EAAE,+BAA+B;EACrCC,aAAa,EAAEA,CAACC,IAAI,EAAEC,MAAM,KAAKL,cAAc,CAACK,MAAM;AAC1D,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { normalizeStyle } from './normalizeStyle';
2
+ export { preprocessor, normalizeNumericValue, normalizeColor } from './normalizer';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalizeStyle","preprocessor","normalizeNumericValue","normalizeColor"],"sourceRoot":"../../../../src","sources":["plugins/normalizer/index.ts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,kBAAkB;AACjD,SAASC,YAAY,EAAEC,qBAAqB,EAAEC,cAAc,QAAQ,cAAc"}
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../../src","sources":["plugins/normalizer/module.d.ts"],"mappings":""}
@@ -1,5 +1,5 @@
1
- import { warn } from './common';
2
1
  import { preprocessor } from './normalizer';
2
+ import { warn } from '../../common';
3
3
  const normalizeBoxShadow = style => {
4
4
  const requiredBoxShadowProperties = ['shadowColor', 'shadowOffset', 'shadowOpacity', 'shadowRadius'];
5
5
  if (!requiredBoxShadowProperties.every(prop => prop in style)) {
@@ -36,7 +36,7 @@ const normalizeTextShadow = style => {
36
36
  textShadowRadius: undefined
37
37
  };
38
38
  };
39
- export const normalizeStyles = style => {
39
+ export const normalizeStyle = style => {
40
40
  const normalizedTransform = 'transform' in style && Array.isArray(style.transform) ? {
41
41
  transform: preprocessor.createTransformValue(style.transform)
42
42
  } : {};
@@ -49,4 +49,4 @@ export const normalizeStyles = style => {
49
49
  ...normalizedTextShadow
50
50
  };
51
51
  };
52
- //# sourceMappingURL=normalizeStyles.web.js.map
52
+ //# sourceMappingURL=normalizeStyle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["preprocessor","warn","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyle","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow"],"sourceRoot":"../../../../src","sources":["plugins/normalizer/normalizeStyle.ts"],"mappings":"AAAA,SAASA,YAAY,QAAQ,cAAc;AAC3C,SAASC,IAAI,QAAQ,cAAc;AAGnC,MAAMC,kBAAkB,GAAyBC,KAAQ,IAA0B;EAC/E,MAAMC,2BAA2B,GAAG,CAChC,aAAa,EACb,cAAc,EACd,eAAe,EACf,cAAc,CACjB;EAED,IAAI,CAACA,2BAA2B,CAACC,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC3DF,IAAI,CAAE,wEAAuEG,2BAA2B,CAACG,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAEtH,OAAO;MACHC,WAAW,EAAEC,SAAS;MACtBC,YAAY,EAAED,SAAS;MACvBE,aAAa,EAAEF,SAAS;MACxBG,YAAY,EAAEH;IAClB,CAAC;EACL;EAEA,OAAO;IACHI,SAAS,EAAEb,YAAY,CAACc,oBAAoB,CAACX,KAAK,CAAC;IACnDK,WAAW,EAAEC,SAAS;IACtBC,YAAY,EAAED,SAAS;IACvBE,aAAa,EAAEF,SAAS;IACxBG,YAAY,EAAEH;EAClB,CAAC;AACL,CAAC;AAED,MAAMM,mBAAmB,GAA0BZ,KAAQ,IAA2B;EAClF,MAAMa,4BAA4B,GAAG,CACjC,iBAAiB,EACjB,kBAAkB,EAClB,kBAAkB,CACrB;EAED,IAAI,CAACA,4BAA4B,CAACX,KAAK,CAACC,IAAI,IAAIA,IAAI,IAAIH,KAAK,CAAC,EAAE;IAC5DF,IAAI,CAAE,yEAAwEe,4BAA4B,CAACT,IAAI,CAAC,IAAI,CAAE,EAAC,CAAC;IAExH,OAAO;MACHU,eAAe,EAAER,SAAS;MAC1BS,gBAAgB,EAAET,SAAS;MAC3BU,gBAAgB,EAAEV;IACtB,CAAC;EACL;EAEA,OAAO;IACHW,UAAU,EAAEpB,YAAY,CAACqB,qBAAqB,CAAClB,KAAK,CAAC;IACrDc,eAAe,EAAER,SAAS;IAC1BS,gBAAgB,EAAET,SAAS;IAC3BU,gBAAgB,EAAEV;EACtB,CAAC;AACL,CAAC;AAED,OAAO,MAAMa,cAAc,GAAuBnB,KAAQ,IAAQ;EAC9D,MAAMoB,mBAAmB,GAAI,WAAW,IAAIpB,KAAK,IAAIqB,KAAK,CAACC,OAAO,CAACtB,KAAK,CAACuB,SAAS,CAAC,GAC7E;IAAEA,SAAS,EAAE1B,YAAY,CAAC2B,oBAAoB,CAACxB,KAAK,CAACuB,SAAS;EAAE,CAAC,GACjE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAIzB,KAAK,IACtB,cAAc,IAAIA,KAAK,IACvB,eAAe,IAAIA,KAAK,IACxB,cAAc,IAAIA,KAAK,GACvBD,kBAAkB,CAACC,KAAkB,CAAC,GAAG,CAAC,CAAC;EAE/C,MAAM0B,oBAAoB,GACtB,iBAAiB,IAAI1B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3BY,mBAAmB,CAACZ,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGoB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC"}
@@ -9,7 +9,7 @@ export const normalizeColor = function (color) {
9
9
  }
10
10
  const integer = normalizeColors(color);
11
11
 
12
- // If the colour is an unknown format, the return value is null
12
+ // If the color is an unknown format, the return value is null
13
13
  if (integer === null) {
14
14
  return color;
15
15
  }
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalizeColors","normalizeColor","color","opacity","arguments","length","undefined","integer","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../../src","sources":["plugins/normalizer/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAC7D;EACA,IAAID,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAMK,OAAO,GAAGP,eAAe,CAACE,KAAK,CAAqB;;EAE1D;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMM,GAAG,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACH,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACM,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGN,GAAG,CACnCO,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GA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AqB,CAACiB,YAAY,CAACJ,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAGd,qBAAqB,CAACmB,YAAY,CAAC;EAClD,MAAMvC,KAAK,GAAGD,cAAc,CAACqC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGlC,KAAM,EAAC;AACrD,CAAC;AAED,MAAMwC,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D3B,GAAG,CAAC4B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOnB,SAAS;EACpB;EAEA,MAAMiB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmBwB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEtB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDJ,MAAM,CAAC6B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=plugin.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/mq.ts"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/plugin.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=stylesheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/stylesheet.ts"],"mappings":""}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=variants.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["utils/module.d.ts"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/variants.ts"],"mappings":""}
@@ -1,41 +1,31 @@
1
1
  import { useMemo } from 'react';
2
2
  import { StyleSheet } from 'react-native';
3
- import { parseStyle, proxifyFunction } from './utils';
4
- import { useUnistyles } from './hooks';
5
- export const useStyles = stylesheet => {
3
+ import { parseStyle, proxifyFunction, withPlugins } from './utils';
4
+ import { useUnistyles, useVariants } from './hooks';
5
+ export const useStyles = (stylesheet, variantsMap) => {
6
6
  const {
7
7
  theme,
8
- layout
8
+ layout,
9
+ plugins
9
10
  } = useUnistyles();
10
- const {
11
- screenSize,
12
- breakpoint
13
- } = layout;
14
- if (!stylesheet) {
15
- return {
16
- theme,
17
- breakpoint,
18
- styles: {}
19
- };
20
- }
21
- const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet]);
22
- const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
11
+ const variants = useVariants(variantsMap);
12
+ const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
13
+ const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
23
14
  let [key, value] = _ref;
24
- const style = value;
25
15
  if (typeof value === 'function') {
26
16
  return {
27
17
  ...acc,
28
- [key]: proxifyFunction(value, breakpoint, screenSize)
18
+ [key]: proxifyFunction(key, value)
29
19
  };
30
20
  }
31
21
  return StyleSheet.create({
32
22
  ...acc,
33
- [key]: parseStyle(style, breakpoint, screenSize)
23
+ [key]: withPlugins(key, parseStyle(value, variants))
34
24
  });
35
- }, {}), [breakpoint, screenSize, parsedStyles]);
25
+ }, {}), [parsedStyles, variants, plugins]);
36
26
  return {
37
27
  theme,
38
- breakpoint,
28
+ breakpoint: layout.breakpoint,
39
29
  styles: dynamicStyleSheet
40
30
  };
41
31
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","useUnistyles","useStyles","stylesheet","theme","layout","screenSize","breakpoint","styles","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","style","create"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,QAAQ,SAAS;AAErD,SAASC,YAAY,QAAQ,SAAS;AAStC,OAAO,MAAMC,SAAS,GAAsCC,UAAyD,IAA2B;EAC5I,MAAM;IAAEC,KAAK;IAAEC;EAAO,CAAC,GAAGJ,YAAY,CAAC,CAAC;EACxC,MAAM;IAAEK,UAAU;IAAEC;EAAW,CAAC,GAAGF,MAAM;EAEzC,IAAI,CAACF,UAAU,EAAE;IACb,OAAO;MACHC,KAAK;MACLG,UAAU;MACVC,MAAM,EAAE,CAAC;IACb,CAAC;EACL;EAEA,MAAMC,YAAY,GAAGZ,OAAO,CAAC,MAAM,OAAOM,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACC,KAAK,CAAC,GACjBD,UAAU,EAAE,CAACC,KAAK,EAAED,UAAU,CAAC,CAAC;EAEtC,MAAMO,iBAAiB,GAAGb,OAAO,CAAC,MAAMc,MAAM,CACzCC,OAAO,CAACH,YAAY,CAAC,CACrBI,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,MAAMG,KAAK,GAAGD,KAA8B;IAE5C,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAGhB,eAAe,CAACiB,KAAK,EAAEV,UAAU,EAAED,UAAU;MACxD,CAAC;IACL;IAEA,OAAOR,UAAU,CAACqB,MAAM,CAAC;MACrB,GAAGL,GAAG;MACN,CAACE,GAAG,GAAGjB,UAAU,CAAKmB,KAAK,EAAEX,UAAU,EAAED,UAAU;IACvD,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAO,CAAC,EAAE,CAACC,UAAU,EAAED,UAAU,EAAEG,YAAY,CAAC,CAA8B;EAEtF,OAAO;IACHL,KAAK;IACLG,UAAU;IACVC,MAAM,EAAEE;EACZ,CAAC;AACL,CAAC"}
1
+ {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","withPlugins","useUnistyles","useVariants","useStyles","stylesheet","variantsMap","theme","layout","plugins","variants","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","create","breakpoint","styles"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,EAAEC,WAAW,QAAQ,SAAS;AAClE,SAASC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAUnD,OAAO,MAAMC,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGP,YAAY,CAAC,CAAC;EACjD,MAAMQ,QAAQ,GAAGP,WAAW,CAACG,WAAW,CAAC;EACzC,MAAMK,YAAY,GAAGd,OAAO,CAAC,MAAM,OAAOQ,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMI,iBAAiB,GAAGf,OAAO,CAAC,MAAMgB,MAAM,CACzCC,OAAO,CAACH,YAAY,IAAI,CAAC,CAAC,CAAC,CAC3BI,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACtB,IAAI,OAAOE,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGH,GAAG;QACN,CAACE,GAAG,GAAGlB,eAAe,CAACkB,GAAG,EAAEC,KAAK;MACrC,CAAC;IACL;IAEA,OAAOrB,UAAU,CAACsB,MAAM,CAAC;MACrB,GAAGJ,GAAG;MACN,CAACE,GAAG,GAAGjB,WAAW,CAACiB,GAAG,EAAEnB,UAAU,CAACoB,KAAK,EAAET,QAAQ,CAAC;IACvD,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAACC,YAAY,EAAED,QAAQ,EAAED,OAAO,CAC5C,CAAC;EAED,OAAO;IACHF,KAAK;IACLc,UAAU,EAAEb,MAAM,CAACa,UAAU;IAC7BC,MAAM,EAAEV;EACZ,CAAC;AACL,CAAC"}
@@ -1,79 +1,35 @@
1
1
  import { unistyles } from '../core';
2
- import { isMobile, Orientation, throwError } from './common';
3
- import { ScreenOrientation } from '../common';
2
+ import { ScreenOrientation, isMobile } from '../common';
4
3
  import { getKeyForUnistylesMediaQuery } from './mqParser';
5
- export const sortAndValidateBreakpoints = breakpoints => {
6
- const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
7
- const [, value1] = breakpoint1;
8
- const [, value2] = breakpoint2;
9
- return value1 - value2;
10
- });
11
- const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs));
12
- const breakpointValues = Object.values(sortedBreakpoints);
13
- const [firstBreakpoint] = breakpointValues;
14
- if (firstBreakpoint !== 0) {
15
- throwError('first breakpoint must start with 0');
16
- }
17
- if (breakpointValues.length !== new Set(breakpointValues).size) {
18
- throwError('breakpoint values are duplicated');
19
- }
20
- return sortedBreakpoints;
21
- };
22
- export const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
23
- const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
24
- let [, value] = _ref;
25
- const minVal = value;
26
- const maxVal = otherBreakpoints[index + 1]?.[1];
27
- if (!maxVal) {
28
- return true;
29
- }
30
- return width >= minVal && width < maxVal;
31
- });
32
- return key;
33
- };
34
4
  export const getValueForBreakpoint = value => {
35
- // the highest priority is for custom media queries
36
5
  const customMediaQueryKey = getKeyForUnistylesMediaQuery(Object.entries(value), unistyles.runtime.screen);
37
6
  if (customMediaQueryKey) {
38
7
  return value[customMediaQueryKey];
39
8
  }
40
-
41
- // at this point user didn't use custom media queries (:w, :h)
42
- // check if user defined any breakpoints
43
- const hasBreakpoints = unistyles.runtime.sortedBreakpoints.length > 0;
44
-
45
- // if not then we can fall back to horizontal and portrait (mobile only)
46
- if (!hasBreakpoints && isMobile && (Orientation.Landscape in value || Orientation.Portrait in value)) {
47
- return value[unistyles.runtime.orientation === ScreenOrientation.Portrait ? Orientation.Portrait : Orientation.Landscape];
9
+ const hasBreakpoints = unistyles.registry.sortedBreakpointPairs.length > 0;
10
+ if (!hasBreakpoints && isMobile && (ScreenOrientation.Landscape in value || ScreenOrientation.Portrait in value)) {
11
+ return value[unistyles.runtime.orientation];
48
12
  }
49
-
50
- // let's get the current breakpoint
51
13
  const breakpoint = unistyles.runtime.breakpoint;
52
14
  if (!breakpoint) {
53
15
  return undefined;
54
16
  }
55
-
56
- // if user defined breakpoints, then we look for the valid one
57
17
  const directBreakpoint = value[breakpoint];
58
-
59
- // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
60
18
  if (directBreakpoint || breakpoint in value) {
61
19
  return directBreakpoint;
62
20
  }
63
-
64
- // there is no direct hit for breakpoint nor media-query, let's simulate CSS cascading
65
- const breakpointPairs = unistyles.runtime.sortedBreakpoints;
66
- const currentBreakpoint = breakpointPairs.findIndex(_ref2 => {
67
- let [key] = _ref2;
21
+ const breakpointPairs = unistyles.registry.sortedBreakpointPairs;
22
+ const currentBreakpointIndex = breakpointPairs.findIndex(_ref => {
23
+ let [key] = _ref;
68
24
  return key === breakpoint;
69
25
  });
70
- const availableBreakpoints = breakpointPairs.filter((_ref3, index) => {
26
+ const availableBreakpoints = breakpointPairs.filter((_ref2, index) => {
27
+ let [key] = _ref2;
28
+ return index < currentBreakpointIndex && key in value;
29
+ }).map(_ref3 => {
71
30
  let [key] = _ref3;
72
- return index < currentBreakpoint && key && key in value;
73
- }).map(_ref4 => {
74
- let [key] = _ref4;
75
31
  return key;
76
32
  });
77
- return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
33
+ return value[availableBreakpoints[availableBreakpoints.length - 1]];
78
34
  };
79
35
  //# sourceMappingURL=breakpoints.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","isMobile","Orientation","throwError","ScreenOrientation","getKeyForUnistylesMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","customMediaQueryKey","runtime","screen","hasBreakpoints","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpoint","findIndex","_ref2","availableBreakpoints","filter","_ref3","map","_ref4"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,SAAS;AACnC,SAASC,QAAQ,EAAEC,WAAW,EAAEC,UAAU,QAAQ,UAAU;AAG5D,SAASC,iBAAiB,QAAQ,WAAW;AAC7C,SAASC,4BAA4B,QAAQ,YAAY;AAEzD,OAAO,MAAMC,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM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EAAA,EAAC,CAC1EqB,GAAG,CAACC,KAAA;IAAA,IAAC,CAAC3B,GAAG,CAAC,GAAA2B,KAAA;IAAA,OAAK3B,GAAG;EAAA,EAAC;EAExB,OAAOmB,eAAe,CAACzB,MAAM,GAAG,CAAC,GAC3BW,KAAK,CAACkB,oBAAoB,CAACA,oBAAoB,CAAC7B,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnGuB,SAAS;AACnB,CAAC"}
1
+ {"version":3,"names":["unistyles","ScreenOrientation","isMobile","getKeyForUnistylesMediaQuery","getValueForBreakpoint","value","customMediaQueryKey","Object","entries","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","_ref","key","availableBreakpoints","filter","_ref2","index","map","_ref3"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,SAAS;AAGnC,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,WAAW;AACvD,SAASC,4BAA4B,QAAQ,YAAY;AAEzD,OAAO,MAAMC,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAGH,4BAA4B,CACpDI,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,EACrBL,SAAS,CAACS,OAAO,CAACC,MACtB,CAAuB;EAEvB,IAAIJ,mBAAmB,EAAE;IACrB,OAAOD,KAAK,CAACC,mBAAmB,CAAC;EACrC;EAEA,MAAMK,cAAc,GAAGX,SAAS,CAACY,QAAQ,CAACC,qBAAqB,CAACC,MAAM,GAAG,CAAC;EAE1E,IAAI,CAACH,cAAc,IAAIT,QAAQ,KAAKD,iBAAiB,CAACc,SAAS,IAAIV,KAAK,IAAIJ,iBAAiB,CAACe,QAAQ,IAAIX,KAAK,CAAC,EAAE;IAC9G,OAAOA,KAAK,CAACL,SAAS,CAACS,OAAO,CAACQ,WAAW,CAAC;EAC/C;EAEA,MAAMC,UAAU,GAAGlB,SAAS,CAACS,OAAO,CAACS,UAAU;EAE/C,IAAI,CAACA,UAAU,EAAE;IACb,OAAOC,SAAS;EACpB;EAEA,MAAMC,gBAAgB,GAAGf,KAAK,CAACa,UAAU,CAAC;EAE1C,IAAIE,gBAAgB,IAAKF,UAAU,IAAIb,KAAM,EAAE;IAC3C,OAAOe,gBAAgB;EAC3B;EAEA,MAAMC,eAAe,GAAGrB,SAAS,CAACY,QAAQ,CAACC,qBAAqB;EAChE,MAAMS,sBAAsB,GAAGD,eAAe,CACzCE,SAAS,CAACC,IAAA;IAAA,IAAC,CAACC,GAAG,CAAC,GAAAD,IAAA;IAAA,OAAKC,GAAG,KAAKP,UAAU;EAAA,EAAC;EAE7C,MAAMQ,oBAAoB,GAAGL,eAAe,CACvCM,MAAM,CAAC,CAAAC,KAAA,EAAQC,KAAK;IAAA,IAAZ,CAACJ,GAAG,CAAC,GAAAG,KAAA;IAAA,OAAYC,KAAK,GAAGP,sBAAsB,IAAIG,GAAG,IAAIpB,KAAK;EAAA,EAAC,CACxEyB,GAAG,CAACC,KAAA;IAAA,IAAC,CAACN,GAAG,CAAC,GAAAM,KAAA;IAAA,OAAKN,GAAG;EAAA,EAAC;EAExB,OAAOpB,KAAK,CAACqB,oBAAoB,CAACA,oBAAoB,CAACZ,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC"}
@@ -1,8 +1,6 @@
1
- export { normalizeStyles } from './normalizeStyles';
2
- export * from './normalizer';
3
- export { mq, MQSymbol } from './mq';
4
- export { getKeyForUnistylesMediaQuery } from './mqParser';
5
- export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
1
+ export { mq } from './mq';
2
+ export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq } from './mqParser';
3
+ export { getValueForBreakpoint } from './breakpoints';
6
4
  export { proxifyFunction, parseStyle } from './styles';
7
- export { isServer, Orientation } from './common';
5
+ export { withPlugins } from './withPlugins';
8
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeStyles","mq","MQSymbol","getKeyForUnistylesMediaQuery","getBreakpointFromScreenWidth","sortAndValidateBreakpoints","getValueForBreakpoint","proxifyFunction","parseStyle","isServer","Orientation"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,cAAc,cAAc;AAC5B,SAASC,EAAE,EAAEC,QAAQ,QAAQ,MAAM;AACnC,SAASC,4BAA4B,QAAQ,YAAY;AACzD,SAASC,4BAA4B,EAAEC,0BAA0B,EAAEC,qBAAqB,QAAQ,eAAe;AAC/G,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,QAAQ,EAAEC,WAAW,QAAQ,UAAU"}
1
+ {"version":3,"names":["mq","getKeyForUnistylesMediaQuery","isWithinTheWidthAndHeight","isValidMq","parseMq","getValueForBreakpoint","proxifyFunction","parseStyle","withPlugins"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":"AAAA,SAASA,EAAE,QAAQ,MAAM;AACzB,SAASC,4BAA4B,EAAEC,yBAAyB,EAAEC,SAAS,EAAEC,OAAO,QAAQ,YAAY;AACxG,SAASC,qBAAqB,QAAQ,eAAe;AACrD,SAASC,eAAe,EAAEC,UAAU,QAAQ,UAAU;AACtD,SAASC,WAAW,QAAQ,eAAe"}