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
@@ -3,86 +3,40 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.sortAndValidateBreakpoints = exports.getValueForBreakpoint = exports.getBreakpointFromScreenWidth = void 0;
6
+ exports.getValueForBreakpoint = void 0;
7
7
  var _core = require("../core");
8
- var _common = require("./common");
9
- var _common2 = require("../common");
8
+ var _common = require("../common");
10
9
  var _mqParser = require("./mqParser");
11
- const sortAndValidateBreakpoints = breakpoints => {
12
- const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
13
- const [, value1] = breakpoint1;
14
- const [, value2] = breakpoint2;
15
- return value1 - value2;
16
- });
17
- const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs));
18
- const breakpointValues = Object.values(sortedBreakpoints);
19
- const [firstBreakpoint] = breakpointValues;
20
- if (firstBreakpoint !== 0) {
21
- (0, _common.throwError)('first breakpoint must start with 0');
22
- }
23
- if (breakpointValues.length !== new Set(breakpointValues).size) {
24
- (0, _common.throwError)('breakpoint values are duplicated');
25
- }
26
- return sortedBreakpoints;
27
- };
28
- exports.sortAndValidateBreakpoints = sortAndValidateBreakpoints;
29
- const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
30
- const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
31
- let [, value] = _ref;
32
- const minVal = value;
33
- const maxVal = otherBreakpoints[index + 1]?.[1];
34
- if (!maxVal) {
35
- return true;
36
- }
37
- return width >= minVal && width < maxVal;
38
- });
39
- return key;
40
- };
41
- exports.getBreakpointFromScreenWidth = getBreakpointFromScreenWidth;
42
10
  const getValueForBreakpoint = value => {
43
- // the highest priority is for custom media queries
44
11
  const customMediaQueryKey = (0, _mqParser.getKeyForUnistylesMediaQuery)(Object.entries(value), _core.unistyles.runtime.screen);
45
12
  if (customMediaQueryKey) {
46
13
  return value[customMediaQueryKey];
47
14
  }
48
-
49
- // at this point user didn't use custom media queries (:w, :h)
50
- // check if user defined any breakpoints
51
- const hasBreakpoints = _core.unistyles.runtime.sortedBreakpoints.length > 0;
52
-
53
- // if not then we can fall back to horizontal and portrait (mobile only)
54
- if (!hasBreakpoints && _common.isMobile && (_common.Orientation.Landscape in value || _common.Orientation.Portrait in value)) {
55
- return value[_core.unistyles.runtime.orientation === _common2.ScreenOrientation.Portrait ? _common.Orientation.Portrait : _common.Orientation.Landscape];
15
+ const hasBreakpoints = _core.unistyles.registry.sortedBreakpointPairs.length > 0;
16
+ if (!hasBreakpoints && _common.isMobile && (_common.ScreenOrientation.Landscape in value || _common.ScreenOrientation.Portrait in value)) {
17
+ return value[_core.unistyles.runtime.orientation];
56
18
  }
57
-
58
- // let's get the current breakpoint
59
19
  const breakpoint = _core.unistyles.runtime.breakpoint;
60
20
  if (!breakpoint) {
61
21
  return undefined;
62
22
  }
63
-
64
- // if user defined breakpoints, then we look for the valid one
65
23
  const directBreakpoint = value[breakpoint];
66
-
67
- // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
68
24
  if (directBreakpoint || breakpoint in value) {
69
25
  return directBreakpoint;
70
26
  }
71
-
72
- // there is no direct hit for breakpoint nor media-query, let's simulate CSS cascading
73
- const breakpointPairs = _core.unistyles.runtime.sortedBreakpoints;
74
- const currentBreakpoint = breakpointPairs.findIndex(_ref2 => {
75
- let [key] = _ref2;
27
+ const breakpointPairs = _core.unistyles.registry.sortedBreakpointPairs;
28
+ const currentBreakpointIndex = breakpointPairs.findIndex(_ref => {
29
+ let [key] = _ref;
76
30
  return key === breakpoint;
77
31
  });
78
- const availableBreakpoints = breakpointPairs.filter((_ref3, index) => {
32
+ const availableBreakpoints = breakpointPairs.filter((_ref2, index) => {
33
+ let [key] = _ref2;
34
+ return index < currentBreakpointIndex && key in value;
35
+ }).map(_ref3 => {
79
36
  let [key] = _ref3;
80
- return index < currentBreakpoint && key && key in value;
81
- }).map(_ref4 => {
82
- let [key] = _ref4;
83
37
  return key;
84
38
  });
85
- return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
39
+ return value[availableBreakpoints[availableBreakpoints.length - 1]];
86
40
  };
87
41
  exports.getValueForBreakpoint = getValueForBreakpoint;
88
42
  //# sourceMappingURL=breakpoints.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_core","require","_common","_common2","_mqParser","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","throwError","length","Set","size","exports","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","customMediaQueryKey","getKeyForUnistylesMediaQuery","unistyles","runtime","screen","hasBreakpoints","isMobile","Orientation","Landscape","Portrait","orientation","ScreenOrientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpoint","findIndex","_ref2","availableBreakpoints","filter","_ref3","map","_ref4"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAGA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEO,MAAMI,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WA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GAAG,CAAC,GAAA8B,KAAA;IAAA,OAAY3B,KAAK,GAAGsB,iBAAiB,IAAIzB,GAAG,IAAIA,GAAG,IAAIK,KAAK;EAAA,EAAC,CAC1E0B,GAAG,CAACC,KAAA;IAAA,IAAC,CAAChC,GAAG,CAAC,GAAAgC,KAAA;IAAA,OAAKhC,GAAG;EAAA,EAAC;EAExB,OAAOwB,eAAe,CAAC/B,MAAM,GAAG,CAAC,GAC3BY,KAAK,CAACuB,oBAAoB,CAACA,oBAAoB,CAACnC,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnG6B,SAAS;AACnB,CAAC;AAAA1B,OAAA,CAAAY,qBAAA,GAAAA,qBAAA"}
1
+ {"version":3,"names":["_core","require","_common","_mqParser","getValueForBreakpoint","value","customMediaQueryKey","getKeyForUnistylesMediaQuery","Object","entries","unistyles","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","isMobile","ScreenOrientation","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","_ref","key","availableBreakpoints","filter","_ref2","index","map","_ref3","exports"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAGA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAG,IAAAC,sCAA4B,EACpDC,MAAM,CAACC,OAAO,CAACJ,KAAK,CAAC,EACrBK,eAAS,CAACC,OAAO,CAACC,MACtB,CAAuB;EAEvB,IAAIN,mBAAmB,EAAE;IACrB,OAAOD,KAAK,CAACC,mBAAmB,CAAC;EACrC;EAEA,MAAMO,cAAc,GAAGH,eAAS,CAACI,QAAQ,CAACC,qBAAqB,CAACC,MAAM,GAAG,CAAC;EAE1E,IAAI,CAACH,cAAc,IAAII,gBAAQ,KAAKC,yBAAiB,CAACC,SAAS,IAAId,KAAK,IAAIa,yBAAiB,CAACE,QAAQ,IAAIf,KAAK,CAAC,EAAE;IAC9G,OAAOA,KAAK,CAACK,eAAS,CAACC,OAAO,CAACU,WAAW,CAAC;EAC/C;EAEA,MAAMC,UAAU,GAAGZ,eAAS,CAACC,OAAO,CAACW,UAAU;EAE/C,IAAI,CAACA,UAAU,EAAE;IACb,OAAOC,SAAS;EACpB;EAEA,MAAMC,gBAAgB,GAAGnB,KAAK,CAACiB,UAAU,CAAC;EAE1C,IAAIE,gBAAgB,IAAKF,UAAU,IAAIjB,KAAM,EAAE;IAC3C,OAAOmB,gBAAgB;EAC3B;EAEA,MAAMC,eAAe,GAAGf,eAAS,CAACI,QAAQ,CAACC,qBAAqB;EAChE,MAAMW,sBAAsB,GAAGD,eAAe,CACzCE,SAAS,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,IAAIxB,KAAK;EAAA,EAAC,CACxE6B,GAAG,CAACC,KAAA;IAAA,IAAC,CAACN,GAAG,CAAC,GAAAM,KAAA;IAAA,OAAKN,GAAG;EAAA,EAAC;EAExB,OAAOxB,KAAK,CAACyB,oBAAoB,CAACA,oBAAoB,CAACd,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC;AAAAoB,OAAA,CAAAhC,qBAAA,GAAAA,qBAAA"}
@@ -3,37 +3,6 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- var _exportNames = {
7
- normalizeStyles: true,
8
- mq: true,
9
- MQSymbol: true,
10
- getKeyForUnistylesMediaQuery: true,
11
- getBreakpointFromScreenWidth: true,
12
- sortAndValidateBreakpoints: true,
13
- getValueForBreakpoint: true,
14
- proxifyFunction: true,
15
- parseStyle: true,
16
- isServer: true,
17
- Orientation: true
18
- };
19
- Object.defineProperty(exports, "MQSymbol", {
20
- enumerable: true,
21
- get: function () {
22
- return _mq.MQSymbol;
23
- }
24
- });
25
- Object.defineProperty(exports, "Orientation", {
26
- enumerable: true,
27
- get: function () {
28
- return _common.Orientation;
29
- }
30
- });
31
- Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
32
- enumerable: true,
33
- get: function () {
34
- return _breakpoints.getBreakpointFromScreenWidth;
35
- }
36
- });
37
6
  Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
38
7
  enumerable: true,
39
8
  get: function () {
@@ -46,10 +15,16 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
46
15
  return _breakpoints.getValueForBreakpoint;
47
16
  }
48
17
  });
49
- Object.defineProperty(exports, "isServer", {
18
+ Object.defineProperty(exports, "isValidMq", {
19
+ enumerable: true,
20
+ get: function () {
21
+ return _mqParser.isValidMq;
22
+ }
23
+ });
24
+ Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
50
25
  enumerable: true,
51
26
  get: function () {
52
- return _common.isServer;
27
+ return _mqParser.isWithinTheWidthAndHeight;
53
28
  }
54
29
  });
55
30
  Object.defineProperty(exports, "mq", {
@@ -58,10 +33,10 @@ Object.defineProperty(exports, "mq", {
58
33
  return _mq.mq;
59
34
  }
60
35
  });
61
- Object.defineProperty(exports, "normalizeStyles", {
36
+ Object.defineProperty(exports, "parseMq", {
62
37
  enumerable: true,
63
38
  get: function () {
64
- return _normalizeStyles.normalizeStyles;
39
+ return _mqParser.parseMq;
65
40
  }
66
41
  });
67
42
  Object.defineProperty(exports, "parseStyle", {
@@ -76,28 +51,15 @@ Object.defineProperty(exports, "proxifyFunction", {
76
51
  return _styles.proxifyFunction;
77
52
  }
78
53
  });
79
- Object.defineProperty(exports, "sortAndValidateBreakpoints", {
54
+ Object.defineProperty(exports, "withPlugins", {
80
55
  enumerable: true,
81
56
  get: function () {
82
- return _breakpoints.sortAndValidateBreakpoints;
57
+ return _withPlugins.withPlugins;
83
58
  }
84
59
  });
85
- var _normalizeStyles = require("./normalizeStyles");
86
- var _normalizer = require("./normalizer");
87
- Object.keys(_normalizer).forEach(function (key) {
88
- if (key === "default" || key === "__esModule") return;
89
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
90
- if (key in exports && exports[key] === _normalizer[key]) return;
91
- Object.defineProperty(exports, key, {
92
- enumerable: true,
93
- get: function () {
94
- return _normalizer[key];
95
- }
96
- });
97
- });
98
60
  var _mq = require("./mq");
99
61
  var _mqParser = require("./mqParser");
100
62
  var _breakpoints = require("./breakpoints");
101
63
  var _styles = require("./styles");
102
- var _common = require("./common");
64
+ var _withPlugins = require("./withPlugins");
103
65
  //# 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","_mq","_mqParser","_breakpoints","_styles","_common"],"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,GAAA,GAAAd,OAAA;AACA,IAAAe,SAAA,GAAAf,OAAA;AACA,IAAAgB,YAAA,GAAAhB,OAAA;AACA,IAAAiB,OAAA,GAAAjB,OAAA;AACA,IAAAkB,OAAA,GAAAlB,OAAA"}
1
+ {"version":3,"names":["_mq","require","_mqParser","_breakpoints","_styles","_withPlugins"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA"}
@@ -3,17 +3,8 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.mq = exports.MQSymbol = void 0;
6
+ exports.mq = void 0;
7
7
  var _core = require("../core");
8
- const MQSymbol = exports.MQSymbol = Symbol('unistyles-mq');
9
- var MQProp = /*#__PURE__*/function (MQProp) {
10
- MQProp["toString"] = "toString";
11
- MQProp["width"] = "width";
12
- MQProp["height"] = "height";
13
- MQProp["shortW"] = "w";
14
- MQProp["shortH"] = "h";
15
- return MQProp;
16
- }(MQProp || {});
17
8
  const getMQValue = value => {
18
9
  if (typeof value === 'number') {
19
10
  return value;
@@ -23,67 +14,44 @@ const getMQValue = value => {
23
14
  }
24
15
  return _core.unistyles.registry.breakpoints[value] ?? 0;
25
16
  };
26
- const widthHandler = function () {
27
- let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
28
- let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
29
- return new Proxy({}, {
30
- get: (target, prop, receiver) => {
31
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
32
- return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
33
- }
34
- if (prop === MQProp.width || prop === MQProp.shortW) {
35
- return function () {
36
- let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
37
- let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
38
- return new Proxy({}, {
39
- get: (target, prop, receiver) => {
40
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
41
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
42
- }
43
- return Reflect.get(target, prop, receiver);
44
- }
45
- });
46
- };
47
- }
48
- return Reflect.get(target, prop, receiver);
17
+ const mq = exports.mq = {
18
+ only: {
19
+ width: function () {
20
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
21
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
22
+ return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
23
+ },
24
+ height: function () {
25
+ let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
26
+ let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
27
+ return `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
49
28
  }
50
- });
51
- };
52
- const heightHandler = function () {
53
- let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
54
- let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
55
- return new Proxy({}, {
56
- get: (target, prop, receiver) => {
57
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
58
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
59
- }
60
- if (prop === MQProp.height || prop === MQProp.shortH) {
61
- return function () {
29
+ },
30
+ width: function () {
31
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
32
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
33
+ return {
34
+ and: {
35
+ height: function () {
62
36
  let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
63
37
  let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
64
- return new Proxy({}, {
65
- get: (target, prop, receiver) => {
66
- if (prop === Symbol.toPrimitive || MQProp.toString) {
67
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
68
- }
69
- return Reflect.get(target, prop, receiver);
70
- }
71
- });
72
- };
38
+ return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
39
+ }
73
40
  }
74
- return Reflect.get(target, prop, receiver);
75
- }
76
- });
77
- };
78
- const mq = exports.mq = new Proxy({}, {
79
- get: (target, prop, receiver) => {
80
- if (prop === MQProp.shortW || prop === MQProp.width) {
81
- return heightHandler;
82
- }
83
- if (prop === MQProp.shortH || prop === MQProp.height) {
84
- return widthHandler;
85
- }
86
- return Reflect.get(target, prop, receiver);
41
+ };
42
+ },
43
+ height: function () {
44
+ let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
45
+ let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
46
+ return {
47
+ and: {
48
+ width: function () {
49
+ let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
50
+ let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
51
+ return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
52
+ }
53
+ }
54
+ };
87
55
  }
88
- });
56
+ };
89
57
  //# sourceMappingURL=mq.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_core","require","MQSymbol","exports","Symbol","MQProp","getMQValue","value","unistyles","registry","breakpoints","widthHandler","hMin","arguments","length","undefined","hMax","Infinity","Proxy","get","target","prop","receiver","toPrimitive","toString","width","shortW","wMin","wMax","Reflect","heightHandler","height","shortH","mq"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":";;;;;;AAEA,IAAAA,KAAA,GAAAC,OAAA;AAEO,MAAMC,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAGE,MAAM,CAAC,cAAc,CAAC;AAAA,IAyBzCC,MAAM,0BAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAANA,MAAM;EAAA,OAANA,MAAM;AAAA,EAANA,MAAM;AAQX,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,MAAMI,YAAY,GAAG,SAAAA,CAAA;EAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;EAAA,OAAK,IAAIC,KAAK,CAAgB,CAAC,CAAC,EAAmB;IAC1HC,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,KAAK;MAC7B,IAAID,IAAI,KAAKjB,MAAM,CAACmB,WAAW,IAAIF,IAAI,KAAKhB,MAAM,CAACmB,QAAQ,EAAE;QACzD,OAAO,MAAO,MAAKlB,UAAU,CAACM,IAAI,CAAE,KAAIN,UAAU,CAACU,IAAI,CAAE,GAAE;MAC/D;MAEA,IAAIK,IAAI,KAAKhB,MAAM,CAACoB,KAAK,IAA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KAAKhB,MAAM,CAACqB,MAAM,IAAIL,IAAI,KAAKhB,MAAM,CAACoB,KAAK,EAAE;MACjD,OAAOK,aAAa;IACxB;IAEA,IAAIT,IAAI,KAAKhB,MAAM,CAAC2B,MAAM,IAAIX,IAAI,KAAKhB,MAAM,CAAC0B,MAAM,EAAE;MAClD,OAAOpB,YAAY;IACvB;IAEA,OAAOkB,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;EAC9C;AACJ,CAAC,CAAC"}
1
+ {"version":3,"names":["_core","require","getMQValue","value","unistyles","registry","breakpoints","mq","exports","only","width","wMin","arguments","length","undefined","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;AAEM,MAAMI,EAAa,GAAAC,OAAA,CAAAD,EAAA,GAAG;EACzBE,IAAI,EAAE;IACFC,KAAK,EAAE,SAAAA,CAAA;MAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;MAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;MAAA,OAAO,MAAKd,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACa,IAAI,CAAE,GAAE;IAAA,CAAsB;IACvIE,MAAM,EAAE,SAAAA,CAAA;MAAA,IAACC,IAAuB,GAAAN,SAAA,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AAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;UAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;UAAA,OACvD,MAAKd,UAAU,CAACS,IAAI,CAAE,KAAIT,UAAU,CAACa,IAAI,CAAE,OAAMb,UAAU,CAACgB,IAAI,CAAE,KAAIhB,UAAU,CAACiB,IAAI,CAAE,GAAE;QAAA;MACnG;IACJ,CAAC;EAAA;AACL,CAAC"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getKeyForUnistylesMediaQuery = void 0;
6
+ exports.parseMq = exports.isWithinTheWidthAndHeight = exports.isValidMq = exports.getKeyForUnistylesMediaQuery = void 0;
7
7
  const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
8
8
  const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
9
9
  const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
@@ -21,6 +21,7 @@ const parseMq = mq => {
21
21
  } : undefined
22
22
  };
23
23
  };
24
+ exports.parseMq = parseMq;
24
25
  const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
25
26
  const isValidMq = parsedMq => {
26
27
  const {
@@ -38,6 +39,7 @@ const isValidMq = parsedMq => {
38
39
  }
39
40
  return false;
40
41
  };
42
+ exports.isValidMq = isValidMq;
41
43
  const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
42
44
  const {
43
45
  width,
@@ -54,6 +56,7 @@ const isWithinTheWidthAndHeight = (parsedMq, screenSize) => {
54
56
  }
55
57
  return false;
56
58
  };
59
+ exports.isWithinTheWidthAndHeight = isWithinTheWidthAndHeight;
57
60
  const isWithinTheWidth = (width, screenWidth) => {
58
61
  const {
59
62
  from,
@@ -1 +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","isUnistylesMq","test","isValidMq","parsedMq","isWithinTheWidthAndHeight","screenSize","isWithinTheWidth","isWithinTheHeight","screenWidth","screenHeight","getKeyForUnistylesMediaQuery","mediaQueries","find","_ref","key","at","exports"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EAC/C,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MAAM,CAACP,KAAK,CAAC;MACnBQ,EAAE,EAAED,MAAM,CAACN,GAAG;IAClB,CAAC,GAAGQ,SAAS;IACbN,MAAM,EAAEA,MAAM,GAAG;MACbG,IAAI,EAAEC,MAAM,CAACH,KAAK,CAAC;MACnBI,EAAE,EAAED,MAAM,CAACF,GAAG;IAClB,CAAC,GAAGI;EACR,CAAC;AACL,CAAC;AAED,MAAMC,aAAa,GAAIZ,EAAU,IAAKJ,kBAAkB,CAACiB,IAAI,CAACb,EAAE,CAAC;AAEjE,MAAMc,SAAS,GAAIC,QAA2B,IAAK;EAC/C,MAAM;IAAEd,KAAK;IAAEI;EAAO,CAAC,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,IAAIb,IAAI,IAAIa,YAAY,IAAIX,EAAE;AACrD,CAAC;AAEM,MAAMY,4BAA4B,GAAGA,CAACC,YAAwB,EAAEN,UAAsB,KAAK;EAC9F,MAAMjB,EAAE,GAAGuB,YAAY,CAACC,IAAI,CAACC,IAAA,IAAW;IAAA,IAAV,CAACC,GAAG,CAAC,GAAAD,IAAA;IAC/B,IAAI,CAACb,aAAa,CAACc,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMX,QAAQ,GAAGhB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACZ,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOjB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAC,OAAA,CAAAN,4BAAA,GAAAA,4BAAA"}
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","find","_ref","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAY7D,MAAMC,OAAO,GAAIC,EAAU,IAAwB;EACtD,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAA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CAAC;AAAAhB,OAAA,CAAAW,4BAAA,GAAAA,4BAAA"}
@@ -5,10 +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
- const proxifyFunction = (fn, breakpoint, screenSize) => new Proxy(fn, {
11
- apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize)
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))
12
12
  });
13
13
  exports.proxifyFunction = proxifyFunction;
14
14
  const isPlatformColor = value => {
@@ -18,26 +18,41 @@ const isPlatformColor = value => {
18
18
  return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
19
19
  };
20
20
  exports.isPlatformColor = isPlatformColor;
21
- const parseStyle = (style, breakpoint, screenSize) => {
22
- const entries = Object.entries(style || {});
23
- const parsedStyles = Object.fromEntries(entries.map(_ref => {
21
+ const parseStyle = function (style) {
22
+ let variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23
+ return Object.entries(style || {}).reduce((acc, _ref) => {
24
24
  let [key, value] = _ref;
25
- const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
26
- if (hasNestedProperties) {
27
- return [key, parseStyle(value, breakpoint, screenSize)];
25
+ // nested objects
26
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
27
+ acc[key] = parseStyle(value, variant);
28
+ return acc;
28
29
  }
29
- const isTransform = key === 'transform';
30
- if (isTransform && Array.isArray(value)) {
31
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize))];
30
+
31
+ // transforms
32
+ if (key === 'transform' && Array.isArray(value)) {
33
+ acc[key] = value.map(value => parseStyle(value, variant));
34
+ return acc;
35
+ }
36
+
37
+ // values or platform colors
38
+ if (typeof value !== 'object' || isPlatformColor(value)) {
39
+ acc[key] = value;
40
+ return acc;
32
41
  }
33
- const isDynamicFunction = typeof value === 'function';
34
- const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
35
- if (isDynamicFunction || isValidStyle) {
36
- return [key, value];
42
+ if (key === 'variants') {
43
+ return {
44
+ ...acc,
45
+ ...Object.keys(value).reduce((acc, key) => ({
46
+ ...acc,
47
+ ...parseStyle(value[key][variant[key] || 'default'] ?? {})
48
+ }), {})
49
+ };
37
50
  }
38
- return [key, (0, _breakpoints.getValueForBreakpoint)(value)];
39
- }));
40
- return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
51
+ return {
52
+ ...acc,
53
+ [key]: (0, _breakpoints.getValueForBreakpoint)(value)
54
+ };
55
+ }, {});
41
56
  };
42
57
  exports.parseStyle = parseStyle;
43
58
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","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;AAEA,IAAAE,OAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA+C,EAC7DC,UAAsB,KACX,IAAIC,KAAK,CAACH,EAAE,EAAE;EACzBI,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UA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AK,KAAK,UAAU;IACrD,MAAMkB,YAAY,GAAG,OAAOlB,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC;IAExE,IAAIiB,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACN,GAAG,EAAEZ,KAAK,CAAC;IACvB;IAEA,OAAO,CACHY,GAAG,EACH,IAAAO,kCAAqB,EAACnB,KAAqF,CAAC,CAC/G;EACL,CAAC,CACL,CAAC;EAEL,OAAOoB,aAAK,GACN,IAAAC,gCAAe,EAACb,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;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","arguments","length","undefined","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","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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B,GAAGwB,GAAG;UACN,GAAGf,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC;QACvF,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;IAEA,OAAO;MACH,GAAGwB,GAAG;MACN,CAACxB,GAAG,GAAG,IAAA8B,kCAAqB,EAAClB,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA;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, style, _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,EAAEC,KAAK,EAAEC,eAAS,CAACO,OAAO,CAAC;EAC9D;EAEA,OAAOH,GAAG;AACd,CAAC,EAAEL,KAAK,CAAC;AAAAS,OAAA,CAAAX,WAAA,GAAAA,WAAA"}
@@ -1,22 +1,33 @@
1
- export let CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
2
- CxxUnistylesEventTypes["Theme"] = "theme";
3
- CxxUnistylesEventTypes["Layout"] = "layout";
4
- return CxxUnistylesEventTypes;
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 UnistylesEventType = /*#__PURE__*/function (UnistylesEventType) {
15
+ UnistylesEventType["Theme"] = "theme";
16
+ UnistylesEventType["Layout"] = "layout";
17
+ UnistylesEventType["Plugin"] = "plugin";
18
+ return UnistylesEventType;
5
19
  }({});
6
20
  export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
7
- UnistylesError["RuntimeUnavailable"] = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE";
8
- UnistylesError["ThemeNotFound"] = "UNISTYLES_ERROR_THEME_NOT_FOUND";
9
- UnistylesError["ThemeNotRegistered"] = "UNISTYLES_ERROR_THEME_NOT_REGISTERED";
10
- UnistylesError["ThemesCannotBeEmpty"] = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY";
11
- UnistylesError["BreakpointsCannotBeEmpty"] = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY";
12
- UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
21
+ UnistylesError["RuntimeUnavailable"] = "Unistyles runtime is not available. Make sure you followed the installation instructions";
22
+ UnistylesError["ThemeNotFound"] = "You are trying to get a theme that is not registered with UnistylesRegistry";
23
+ UnistylesError["ThemeNotRegistered"] = "You are trying to set a theme that was not registered with UnistylesRegistry";
24
+ UnistylesError["ThemeNotSelected"] = "Your themes are registered, but you didn't select the initial theme";
25
+ UnistylesError["ThemesCannotBeEmpty"] = "You are trying to register empty themes object";
26
+ UnistylesError["BreakpointsCannotBeEmpty"] = "You are trying to register empty breakpoints object";
27
+ UnistylesError["BreakpointsMustStartFromZero"] = "You are trying to register breakpoints that don't start from 0";
28
+ UnistylesError["InvalidPluginName"] = "Plugin name can't start from reserved prefix __unistyles";
29
+ UnistylesError["DuplicatePluginName"] = "You are trying to register a plugin with a name that is already registered";
30
+ UnistylesError["CantRemoveInternalPlugin"] = "You are trying to remove an internal unistyles plugin";
13
31
  return UnistylesError;
14
32
  }({});
15
-
16
- // todo to string?
17
- export let ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
18
- ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
19
- ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
20
- return ScreenOrientation;
21
- }({});
22
33
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["CxxUnistylesEventTypes","UnistylesError","ScreenOrientation"],"sourceRoot":"../../src","sources":["common.ts"],"mappings":"AAAA,WAAYA,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAKlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA;;AAS1B;AACA,WAAYC,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA"}
1
+ {"version":3,"names":["Platform","warn","message","console","isWeb","OS","isIOS","isAndroid","isMobile","isServer","window","ScreenOrientation","Landscape","Portrait","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,kBAAkB,0BAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAlBA,kBAAkB;EAAA,OAAlBA,kBAAkB;AAAA;AAM9B,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"}