react-native-unistyles 2.0.0-alpha.10 → 2.0.0-alpha.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. package/cxx/UnistylesRuntime.cpp +55 -1
  2. package/cxx/UnistylesRuntime.h +10 -4
  3. package/ios/UnistylesModule.mm +12 -2
  4. package/lib/commonjs/common.js +19 -6
  5. package/lib/commonjs/common.js.map +1 -1
  6. package/lib/commonjs/core/UnistyleRegistry.js +49 -1
  7. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  8. package/lib/commonjs/core/UnistylesRuntime.js +12 -16
  9. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  10. package/lib/commonjs/hooks/useUnistyles.js +8 -2
  11. package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/plugins/index.js +45 -0
  14. package/lib/commonjs/plugins/index.js.map +1 -0
  15. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
  16. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
  17. package/lib/commonjs/plugins/normalizer/index.js +32 -0
  18. package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
  19. package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
  20. package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
  21. package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
  22. package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
  23. package/lib/commonjs/plugins/withPlugins.js +18 -0
  24. package/lib/commonjs/plugins/withPlugins.js.map +1 -0
  25. package/lib/commonjs/types/plugin.js +6 -0
  26. package/lib/{module/utils/module.d.js.map → commonjs/types/plugin.js.map} +1 -1
  27. package/lib/commonjs/types/variants.js +2 -0
  28. package/lib/commonjs/{utils/module.d.js.map → types/variants.js.map} +1 -1
  29. package/lib/commonjs/useStyles.js +5 -4
  30. package/lib/commonjs/useStyles.js.map +1 -1
  31. package/lib/commonjs/utils/breakpoints.js +15 -70
  32. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  33. package/lib/commonjs/utils/index.js +12 -52
  34. package/lib/commonjs/utils/index.js.map +1 -1
  35. package/lib/commonjs/utils/mq.js +1 -1
  36. package/lib/commonjs/utils/mq.js.map +1 -1
  37. package/lib/commonjs/utils/mqParser.js +4 -1
  38. package/lib/commonjs/utils/mqParser.js.map +1 -1
  39. package/lib/commonjs/utils/styles.js +22 -11
  40. package/lib/commonjs/utils/styles.js.map +1 -1
  41. package/lib/commonjs/utils/variants.js +2 -5
  42. package/lib/commonjs/utils/variants.js.map +1 -1
  43. package/lib/module/common.js +17 -7
  44. package/lib/module/common.js.map +1 -1
  45. package/lib/module/core/UnistyleRegistry.js +49 -1
  46. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  47. package/lib/module/core/UnistylesRuntime.js +12 -16
  48. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  49. package/lib/module/hooks/useUnistyles.js +8 -2
  50. package/lib/module/hooks/useUnistyles.js.map +1 -1
  51. package/lib/module/index.js.map +1 -1
  52. package/lib/module/plugins/index.js +4 -0
  53. package/lib/module/plugins/index.js.map +1 -0
  54. package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
  55. package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
  56. package/lib/module/plugins/normalizer/index.js +3 -0
  57. package/lib/module/plugins/normalizer/index.js.map +1 -0
  58. package/lib/module/plugins/normalizer/module.d.js.map +1 -0
  59. package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
  60. package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
  61. package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
  62. package/lib/module/plugins/withPlugins.js +11 -0
  63. package/lib/module/plugins/withPlugins.js.map +1 -0
  64. package/lib/module/types/plugin.js +2 -0
  65. package/lib/module/types/plugin.js.map +1 -0
  66. package/lib/module/types/variants.js +2 -0
  67. package/lib/module/types/variants.js.map +1 -0
  68. package/lib/module/useStyles.js +5 -4
  69. package/lib/module/useStyles.js.map +1 -1
  70. package/lib/module/utils/breakpoints.js +13 -66
  71. package/lib/module/utils/breakpoints.js.map +1 -1
  72. package/lib/module/utils/index.js +2 -5
  73. package/lib/module/utils/index.js.map +1 -1
  74. package/lib/module/utils/mq.js +1 -1
  75. package/lib/module/utils/mq.js.map +1 -1
  76. package/lib/module/utils/mqParser.js +3 -3
  77. package/lib/module/utils/mqParser.js.map +1 -1
  78. package/lib/module/utils/styles.js +23 -12
  79. package/lib/module/utils/styles.js.map +1 -1
  80. package/lib/module/utils/variants.js +2 -5
  81. package/lib/module/utils/variants.js.map +1 -1
  82. package/lib/typescript/src/common.d.ts +16 -6
  83. package/lib/typescript/src/common.d.ts.map +1 -1
  84. package/lib/typescript/src/core/UnistyleRegistry.d.ts +7 -2
  85. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
  86. package/lib/typescript/src/core/UnistylesRuntime.d.ts +7 -8
  87. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  88. package/lib/typescript/src/core/index.d.ts +1 -0
  89. package/lib/typescript/src/core/index.d.ts.map +1 -1
  90. package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
  91. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
  92. package/lib/typescript/src/index.d.ts +4 -3
  93. package/lib/typescript/src/index.d.ts.map +1 -1
  94. package/lib/typescript/src/plugins/index.d.ts +4 -0
  95. package/lib/typescript/src/plugins/index.d.ts.map +1 -0
  96. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
  97. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
  98. package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
  99. package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
  100. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
  101. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
  102. package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
  103. package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
  104. package/lib/typescript/src/plugins/withPlugins.d.ts +3 -0
  105. package/lib/typescript/src/plugins/withPlugins.d.ts.map +1 -0
  106. package/lib/typescript/src/types/breakpoints.d.ts +3 -4
  107. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  108. package/lib/typescript/src/types/core.d.ts +4 -9
  109. package/lib/typescript/src/types/core.d.ts.map +1 -1
  110. package/lib/typescript/src/types/index.d.ts +3 -1
  111. package/lib/typescript/src/types/index.d.ts.map +1 -1
  112. package/lib/typescript/src/types/plugin.d.ts +7 -0
  113. package/lib/typescript/src/types/plugin.d.ts.map +1 -0
  114. package/lib/typescript/src/types/unistyles.d.ts +11 -2
  115. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  116. package/lib/typescript/src/types/variants.d.ts +8 -0
  117. package/lib/typescript/src/types/variants.d.ts.map +1 -0
  118. package/lib/typescript/src/useStyles.d.ts +2 -2
  119. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  120. package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
  121. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  122. package/lib/typescript/src/utils/index.d.ts +2 -5
  123. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  124. package/lib/typescript/src/utils/mqParser.d.ts +12 -0
  125. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
  126. package/lib/typescript/src/utils/styles.d.ts +3 -3
  127. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  128. package/lib/typescript/src/utils/variants.d.ts +1 -1
  129. package/lib/typescript/src/utils/variants.d.ts.map +1 -1
  130. package/package.json +4 -1
  131. package/src/__tests__/mocks.ts +24 -0
  132. package/src/common.ts +22 -7
  133. package/src/core/UnistyleRegistry.ts +46 -2
  134. package/src/core/UnistylesRuntime.ts +14 -20
  135. package/src/core/index.ts +1 -0
  136. package/src/hooks/useUnistyles.ts +7 -2
  137. package/src/index.ts +3 -1
  138. package/src/plugins/index.ts +3 -0
  139. package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
  140. package/src/plugins/normalizer/index.ts +2 -0
  141. package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
  142. package/src/{utils → plugins/normalizer}/normalizer.ts +1 -1
  143. package/src/plugins/withPlugins.ts +17 -0
  144. package/src/types/breakpoints.ts +5 -4
  145. package/src/types/core.ts +5 -10
  146. package/src/types/index.ts +12 -1
  147. package/src/types/plugin.ts +7 -0
  148. package/src/types/unistyles.ts +14 -4
  149. package/src/types/variants.ts +11 -0
  150. package/src/useStyles.ts +12 -6
  151. package/src/utils/breakpoints.ts +10 -75
  152. package/src/utils/index.ts +2 -5
  153. package/src/utils/mq.ts +1 -1
  154. package/src/utils/mqParser.ts +4 -4
  155. package/src/utils/styles.ts +35 -20
  156. package/src/utils/variants.ts +5 -9
  157. package/lib/commonjs/utils/common.js +0 -25
  158. package/lib/commonjs/utils/common.js.map +0 -1
  159. package/lib/commonjs/utils/normalizeStyles.js +0 -10
  160. package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
  161. package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
  162. package/lib/commonjs/utils/normalizer.js.map +0 -1
  163. package/lib/module/utils/common.js +0 -17
  164. package/lib/module/utils/common.js.map +0 -1
  165. package/lib/module/utils/normalizeStyles.js +0 -3
  166. package/lib/module/utils/normalizeStyles.js.map +0 -1
  167. package/lib/module/utils/normalizeStyles.web.js.map +0 -1
  168. package/lib/module/utils/normalizer.js.map +0 -1
  169. package/lib/typescript/src/utils/common.d.ts +0 -12
  170. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  171. package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
  172. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
  173. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
  174. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
  175. package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
  176. package/src/utils/common.ts +0 -20
  177. package/src/utils/normalizeStyles.ts +0 -2
  178. /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
  179. /package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +0 -0
  180. /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
  181. /package/lib/module/{utils → plugins/normalizer}/normalizer.js +0 -0
  182. /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -11,7 +11,8 @@ var _hooks = require("./hooks");
11
11
  const useStyles = (stylesheet, variant) => {
12
12
  const {
13
13
  theme,
14
- layout
14
+ layout,
15
+ plugins
15
16
  } = (0, _hooks.useUnistyles)();
16
17
  const {
17
18
  screenSize,
@@ -31,14 +32,14 @@ const useStyles = (stylesheet, variant) => {
31
32
  if (typeof value === 'function') {
32
33
  return {
33
34
  ...acc,
34
- [key]: (0, _utils.proxifyFunction)(value, breakpoint, screenSize, variant)
35
+ [key]: (0, _utils.proxifyFunction)(key, value, breakpoint, screenSize, variant)
35
36
  };
36
37
  }
37
38
  return _reactNative.StyleSheet.create({
38
39
  ...acc,
39
- [key]: (0, _utils.parseStyle)(style, breakpoint, screenSize, variant)
40
+ [key]: (0, _utils.parseStyle)(key, style, breakpoint, screenSize, variant)
40
41
  });
41
- }, {}), [breakpoint, screenSize, parsedStyles, variant]);
42
+ }, {}), [breakpoint, screenSize, parsedStyles, variant, plugins]);
42
43
  return {
43
44
  theme,
44
45
  breakpoint,
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_reactNative","_utils","_hooks","useStyles","stylesheet","variant","theme","layout","useUnistyles","screenSize","breakpoint","styles","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","style","proxifyFunction","StyleSheet","create","parseStyle","exports"],"sourceRoot":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AAC,CAAO,CAAC,EAAE,CAACK,UAAU,EAAED,UAAU,EAAEG,YAAY,EAAEP,OAAO,CAAC,CAA8B;EAE/F,OAAO;IACHC,KAAK;IACLI,UAAU;IACVC,MAAM,EAAEG;EACZ,CAAC;AACL,CAAC;AAAAa,OAAA,CAAAxB,SAAA,GAAAA,SAAA"}
1
+ {"version":3,"names":["_react","require","_reactNative","_utils","_hooks","useStyles","stylesheet","variant","theme","layout","plugins","useUnistyles","screenSize","breakpoint","styles","parsedStyles","useMemo","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","style","proxifyFunction","StyleSheet","create","parseStyle","exports"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAQA,IAAAG,MAAA,GAAAH,OAAA;AASO,MAAMI,SAAS,GAAGA,CACrBC,UAAyD,EACzDC,OAAyD,KAClC;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EACjD,MAAM;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGJ,MAAM;EAEzC,IAAI,CAACH,UAAU,EAAE;IACb,OAAO;MACHE,KAAK;MACLK,UAAU;MACVC,MAAM,EAAE,CAAC;IACb,CAAC;EACL;EAEA,MAAMC,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOV,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,CAAC,CAAC;EAEtC,MAAMW,iBAAiB,GAAG,IAAAD,cAAO,EAAC,MAAME,MAAM,CACzCC,OAAO,CAACJ,YAAY,CAAC,CACrBK,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,GAAG,IAAAG,sBAAe,EAACH,GAAG,EAAEC,KAAK,EAAEX,UAAU,EAAED,UAAU,EAAEL,OAAO;MACtE,CAAC;IACL;IAEA,OAAOoB,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGP,GAAG;MACN,CAACE,GAAG,GAAG,IAAAM,iBAAU,EAAKN,GAAG,EAAEE,KAAK,EAAEZ,UAAU,EAAED,UAAU,EAAEL,OAAO;IACrE,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAO,CAAC,EAAE,CAACM,UAAU,EAAED,UAAU,EAAEG,YAAY,EAAER,OAAO,EAAEG,OAAO,CAAC,CAA8B;EAExG,OAAO;IACHF,KAAK;IACLK,UAAU;IACVC,MAAM,EAAEG;EACZ,CAAC;AACL,CAAC;AAAAa,OAAA,CAAAzB,SAAA,GAAAA,SAAA"}
@@ -3,95 +3,40 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.sortAndValidateBreakpoints = exports.getValueForNestedStyle = 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
- var _variants = require("./variants");
12
- const sortAndValidateBreakpoints = breakpoints => {
13
- const sortedPairs = Object.entries(breakpoints).sort((breakpoint1, breakpoint2) => {
14
- const [, value1] = breakpoint1;
15
- const [, value2] = breakpoint2;
16
- return value1 - value2;
17
- });
18
- const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs));
19
- const breakpointValues = Object.values(sortedBreakpoints);
20
- const [firstBreakpoint] = breakpointValues;
21
- if (firstBreakpoint !== 0) {
22
- (0, _common.throwError)('first breakpoint must start with 0');
23
- }
24
- if (breakpointValues.length !== new Set(breakpointValues).size) {
25
- (0, _common.throwError)('breakpoint values are duplicated');
26
- }
27
- return sortedBreakpoints;
28
- };
29
- exports.sortAndValidateBreakpoints = sortAndValidateBreakpoints;
30
- const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
31
- const [key] = breakpointEntries.find((_ref, index, otherBreakpoints) => {
32
- let [, value] = _ref;
33
- const minVal = value;
34
- const maxVal = otherBreakpoints[index + 1]?.[1];
35
- if (!maxVal) {
36
- return true;
37
- }
38
- return width >= minVal && width < maxVal;
39
- });
40
- return key;
41
- };
42
-
43
- // todo move it to different file
44
- exports.getBreakpointFromScreenWidth = getBreakpointFromScreenWidth;
45
- const getValueForNestedStyle = (value, variant) => {
46
- // the highest priority is for variants
47
- const variantKey = (0, _variants.getKeyForVariant)(value, variant);
48
- if (variantKey) {
49
- return value.variants[variantKey];
50
- }
51
-
52
- // then custom media queries
10
+ const getValueForBreakpoint = value => {
53
11
  const customMediaQueryKey = (0, _mqParser.getKeyForUnistylesMediaQuery)(Object.entries(value), _core.unistyles.runtime.screen);
54
12
  if (customMediaQueryKey) {
55
13
  return value[customMediaQueryKey];
56
14
  }
57
-
58
- // at this point user didn't use custom media queries (:w, :h)
59
- // check if user defined any breakpoints
60
- const hasBreakpoints = _core.unistyles.runtime.sortedBreakpoints.length > 0;
61
-
62
- // if not then we can fall back to horizontal and portrait (mobile only)
63
- if (!hasBreakpoints && _common.isMobile && (_common.Orientation.Landscape in value || _common.Orientation.Portrait in value)) {
64
- 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];
65
18
  }
66
-
67
- // let's get the current breakpoint
68
19
  const breakpoint = _core.unistyles.runtime.breakpoint;
69
20
  if (!breakpoint) {
70
21
  return undefined;
71
22
  }
72
-
73
- // if user defined breakpoints, then we look for the valid one
74
23
  const directBreakpoint = value[breakpoint];
75
-
76
- // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
77
24
  if (directBreakpoint || breakpoint in value) {
78
25
  return directBreakpoint;
79
26
  }
80
-
81
- // there is no direct hit for breakpoint nor media-query, let's simulate CSS cascading
82
- const breakpointPairs = _core.unistyles.runtime.sortedBreakpoints;
83
- const currentBreakpoint = breakpointPairs.findIndex(_ref2 => {
84
- let [key] = _ref2;
27
+ const breakpointPairs = _core.unistyles.registry.sortedBreakpointPairs;
28
+ const currentBreakpointIndex = breakpointPairs.findIndex(_ref => {
29
+ let [key] = _ref;
85
30
  return key === breakpoint;
86
31
  });
87
- 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 => {
88
36
  let [key] = _ref3;
89
- return index < currentBreakpoint && key && key in value;
90
- }).map(_ref4 => {
91
- let [key] = _ref4;
92
37
  return key;
93
38
  });
94
- return breakpointPairs.length > 0 ? value[availableBreakpoints[availableBreakpoints.length - 1]] : undefined;
39
+ return value[availableBreakpoints[availableBreakpoints.length - 1]];
95
40
  };
96
- exports.getValueForNestedStyle = getValueForNestedStyle;
41
+ exports.getValueForBreakpoint = getValueForBreakpoint;
97
42
  //# sourceMappingURL=breakpoints.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_core","require","_common","_common2","_mqParser","_variants","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","getValueForNestedStyle","variant","variantKey","getKeyForVariant","variants","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;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEO,MAAMK,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAQC,MAAM,GAAeC,MAAiB;EAClD,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAyB;EACjG,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAAM,CAACJ,iBAAiB,CAAC;EACzD,MAAM,CAACK,eAAe,CAAC,GAAGF,gBAAgB;EAE1C,IAAIE,eAAe,KAAK,CAAC,EAAE;IACvB,IAAAC,kBAAU,EAAC,oCAAoC,CAAC;EACpD;EAEA,IAAIH,gBAAgB,CAACI,MAAM,KAAK,IAAIC,GAAG,CAACL,gBAAgB,CAAC,CAACM,IAAI,EAAE;IAC5D,IAAAH,kBAAU,EAAC,kCAAkC,CAAC;EAClD;EAEA,OAAON,iBAAiB;AAC5B,CAAC;AAAAU,OAAA,CAAApB,0BAAA,GAAAA,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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,KAAkB,IAAwB;EAC5E,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,38 +3,12 @@
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
- getKeyForVariant: true,
11
- getKeyForUnistylesMediaQuery: true,
12
- getBreakpointFromScreenWidth: true,
13
- sortAndValidateBreakpoints: true,
14
- getValueForNestedStyle: true,
15
- proxifyFunction: true,
16
- parseStyle: true,
17
- isServer: true,
18
- Orientation: true
19
- };
20
6
  Object.defineProperty(exports, "MQSymbol", {
21
7
  enumerable: true,
22
8
  get: function () {
23
9
  return _mq.MQSymbol;
24
10
  }
25
11
  });
26
- Object.defineProperty(exports, "Orientation", {
27
- enumerable: true,
28
- get: function () {
29
- return _common.Orientation;
30
- }
31
- });
32
- Object.defineProperty(exports, "getBreakpointFromScreenWidth", {
33
- enumerable: true,
34
- get: function () {
35
- return _breakpoints.getBreakpointFromScreenWidth;
36
- }
37
- });
38
12
  Object.defineProperty(exports, "getKeyForUnistylesMediaQuery", {
39
13
  enumerable: true,
40
14
  get: function () {
@@ -47,16 +21,22 @@ Object.defineProperty(exports, "getKeyForVariant", {
47
21
  return _variants.getKeyForVariant;
48
22
  }
49
23
  });
50
- Object.defineProperty(exports, "getValueForNestedStyle", {
24
+ Object.defineProperty(exports, "getValueForBreakpoint", {
51
25
  enumerable: true,
52
26
  get: function () {
53
- return _breakpoints.getValueForNestedStyle;
27
+ return _breakpoints.getValueForBreakpoint;
54
28
  }
55
29
  });
56
- Object.defineProperty(exports, "isServer", {
30
+ Object.defineProperty(exports, "isValidMq", {
57
31
  enumerable: true,
58
32
  get: function () {
59
- return _common.isServer;
33
+ return _mqParser.isValidMq;
34
+ }
35
+ });
36
+ Object.defineProperty(exports, "isWithinTheWidthAndHeight", {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _mqParser.isWithinTheWidthAndHeight;
60
40
  }
61
41
  });
62
42
  Object.defineProperty(exports, "mq", {
@@ -65,10 +45,10 @@ Object.defineProperty(exports, "mq", {
65
45
  return _mq.mq;
66
46
  }
67
47
  });
68
- Object.defineProperty(exports, "normalizeStyles", {
48
+ Object.defineProperty(exports, "parseMq", {
69
49
  enumerable: true,
70
50
  get: function () {
71
- return _normalizeStyles.normalizeStyles;
51
+ return _mqParser.parseMq;
72
52
  }
73
53
  });
74
54
  Object.defineProperty(exports, "parseStyle", {
@@ -83,29 +63,9 @@ Object.defineProperty(exports, "proxifyFunction", {
83
63
  return _styles.proxifyFunction;
84
64
  }
85
65
  });
86
- Object.defineProperty(exports, "sortAndValidateBreakpoints", {
87
- enumerable: true,
88
- get: function () {
89
- return _breakpoints.sortAndValidateBreakpoints;
90
- }
91
- });
92
- var _normalizeStyles = require("./normalizeStyles");
93
- var _normalizer = require("./normalizer");
94
- Object.keys(_normalizer).forEach(function (key) {
95
- if (key === "default" || key === "__esModule") return;
96
- if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
97
- if (key in exports && exports[key] === _normalizer[key]) return;
98
- Object.defineProperty(exports, key, {
99
- enumerable: true,
100
- get: function () {
101
- return _normalizer[key];
102
- }
103
- });
104
- });
105
66
  var _mq = require("./mq");
106
67
  var _variants = require("./variants");
107
68
  var _mqParser = require("./mqParser");
108
69
  var _breakpoints = require("./breakpoints");
109
70
  var _styles = require("./styles");
110
- var _common = require("./common");
111
71
  //# 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","_variants","_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,SAAA,GAAAhB,OAAA;AACA,IAAAiB,YAAA,GAAAjB,OAAA;AACA,IAAAkB,OAAA,GAAAlB,OAAA;AACA,IAAAmB,OAAA,GAAAnB,OAAA"}
1
+ {"version":3,"names":["_mq","require","_variants","_mqParser","_breakpoints","_styles"],"sourceRoot":"../../../src","sources":["utils/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,GAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA"}
@@ -63,7 +63,7 @@ const heightHandler = function () {
63
63
  let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
64
64
  return new Proxy({}, {
65
65
  get: (target, prop, receiver) => {
66
- if (prop === Symbol.toPrimitive || MQProp.toString) {
66
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
67
67
  return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
68
68
  }
69
69
  return Reflect.get(target, prop, receiver);
@@ -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,E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YAChGC,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,KAAK;cAC7B,IAAID,IAAI,KAAKjB,MAAM,CAACmB,WAAW,IAAIlB,MAAM,CAACmB,QAAQ,EAAE;gBAChD,OAAO,MAAO,MAAKlB,UAAU,CAACqB,IAAI,CAAE,KAAIrB,UAAU,CAACsB,IAAI,CAAE,OAAMtB,UAAU,CAACM,IAAI,CAAE,KAAIN,UAAU,CAACU,IAAI,CAAE,GAAE;cAC3G;cAEA,OAAOa,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;YAC9C;UACJ,CAAC,CAAC;QAAA;MACN;MAEA,OAAOO,OAAO,CAACV,GAAG,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,CAAC;IAC9C;EACJ,CAAC,CAAC;AAAA;AAEK,MAAMW,EAAE,GAAA9B,OAAA,CAAA8B,EAAA,GAAG,IAAIf,KAAK,CAAC,CAAC,CAAC,EAAe;EACzCC,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,EAAEC,QAAQ,KAAK;IAC7B,IAAID,IAAI,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","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":"../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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"}
@@ -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,GAAGU,QAAQ;EAElC,IAAId,KAAK,IAAII,MAAM,EAAE;IACjB,OAAOJ,KAAK,CAACO,IAAI,IAAIP,KAAK,CAACS,EAAE,IAAIL,MAAM,CAACG,IAAI,IAAIH,MAAM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AAY,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,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACXO,IAAI,EAAEC,MA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 0;
7
7
  var _breakpoints = require("./breakpoints");
8
- var _normalizeStyles = require("./normalizeStyles");
9
- var _common = require("./common");
10
- const proxifyFunction = (fn, breakpoint, screenSize, variant) => new Proxy(fn, {
11
- apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
8
+ var _common = require("../common");
9
+ var _variants = require("./variants");
10
+ var _plugins = require("../plugins");
11
+ const proxifyFunction = (key, fn, breakpoint, screenSize, variant) => new Proxy(fn, {
12
+ apply: (target, thisArg, argumentsList) => parseStyle(key, target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
12
13
  });
13
14
  exports.proxifyFunction = proxifyFunction;
14
15
  const isPlatformColor = value => {
@@ -18,26 +19,36 @@ const isPlatformColor = value => {
18
19
  return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
19
20
  };
20
21
  exports.isPlatformColor = isPlatformColor;
21
- const parseStyle = (style, breakpoint, screenSize, variant) => {
22
- const entries = Object.entries(style || {});
23
- const parsedStyles = Object.fromEntries(entries.map(_ref => {
22
+ const parseStyle = (key, style, breakpoint, screenSize, variant) => {
23
+ const entries = Object.entries(style || {}).map(_ref => {
24
24
  let [key, value] = _ref;
25
+ if (key !== 'variants') {
26
+ return [key, value];
27
+ }
28
+ const variantKey = (0, _variants.getKeyForVariant)(value, variant);
29
+ if (!variantKey) {
30
+ return undefined;
31
+ }
32
+ return Object.entries(value[variantKey]).flat();
33
+ }).filter(Boolean);
34
+ const parsedStyles = Object.fromEntries(entries.map(_ref2 => {
35
+ let [key, value] = _ref2;
25
36
  const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
26
37
  if (hasNestedProperties) {
27
- return [key, parseStyle(value, breakpoint, screenSize, variant)];
38
+ return [key, parseStyle(key, value, breakpoint, screenSize, variant)];
28
39
  }
29
40
  const isTransform = key === 'transform';
30
41
  if (isTransform && Array.isArray(value)) {
31
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize, variant))];
42
+ return [key, value.map(value => parseStyle(key, value, breakpoint, screenSize, variant))];
32
43
  }
33
44
  const isDynamicFunction = typeof value === 'function';
34
45
  const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
35
46
  if (isDynamicFunction || isValidStyle) {
36
47
  return [key, value];
37
48
  }
38
- return [key, (0, _breakpoints.getValueForNestedStyle)(value, variant)];
49
+ return [key, (0, _breakpoints.getValueForBreakpoint)(value)];
39
50
  }));
40
- return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
51
+ return (0, _plugins.withPlugins)(key, parsedStyles);
41
52
  };
42
53
  exports.parseStyle = parseStyle;
43
54
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","variant","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","getValueForNestedStyle","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,EACtBC,OAAgB,KACL,IAAIC,KAAK,CAACJ,EAAE,EAAE;EACzBK,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEP,UAAU,EAAEC,UAAU,EAAEC,OAAO;AACxF,CAAC,CAAC;AAAAO,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAEK,MAAMY,eAAe,GAAkBC,KAAQ,IAAc;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ACnC,OAAO,CAACN,GAAG,EAAEZ,KAAK,CAAC;IACvB;IAEA,OAAO,CACHY,GAAG,EACH,IAAAO,mCAAsB,EAClBnB,KAAK,EACLT,OACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAO6B,aAAK,GACN,IAAAC,gCAAe,EAACb,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;AAAAV,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_breakpoints","require","_common","_variants","_plugins","proxifyFunction","key","fn","breakpoint","screenSize","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","map","_ref","variantKey","getKeyForVariant","undefined","flat","filter","Boolean","parsedStyles","fromEntries","_ref2","hasNestedProperties","isTransform","Array","isArray","isDynamicFunction","isValidStyle","getValueForBreakpoint","withPlugins"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAEO,MAAMI,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EAAEC,UAA+C,EAC7DC,UAAsB,EACtBC,OAAgB,KACL,IAAIC,KAAK,CAACJ,EAAE,EAAE;EACzBK,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAClCC,UAAU,CAACV,GAAG,EAAEO,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEP,UAAU,EAAEC,UAAU,EAAEC,OAAO;AAC7F,CAAC,CAAC;AAAAO,OAAA,CAAAZ,eAAA,GAAAA,eAAA;AAEK,MAAMa,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,C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AAW;IAEvC,IAAIiC,WAAW,IAAIC,KAAK,CAACC,OAAO,CAACtB,KAAK,CAAC,EAAE;MACrC,OAAO,CACHb,GAAG,EACHa,KAAK,CAACQ,GAAG,CAACR,KAAK,IAAIH,UAAU,CAACV,GAAG,EAAEa,KAAK,EAAEX,UAAU,EAAEC,UAAU,EAAEC,OAAO,CAAC,CAAC,CAC9E;IACL;IAEA,MAAMgC,iBAAiB,GAAG,OAAOvB,KAAK,KAAK,UAAU;IACrD,MAAMwB,YAAY,GAAG,OAAOxB,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC;IAExE,IAAIuB,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACrC,GAAG,EAAEa,KAAK,CAAC;IACvB;IAEA,OAAO,CACHb,GAAG,EACH,IAAAsC,kCAAqB,EAACzB,KAAoB,CAAC,CAC9C;EACL,CAAC,CACL,CAAM;EAEV,OAAO,IAAA0B,oBAAW,EAACvC,GAAG,EAAE6B,YAAY,CAAC;AACzC,CAAC;AAAAlB,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
@@ -5,13 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getKeyForVariant = void 0;
7
7
  const getKeyForVariant = (value, variant) => {
8
- if (!value.variants) {
9
- return undefined;
10
- }
11
- if (variant && variant in value.variants) {
8
+ if (variant && variant in value) {
12
9
  return variant;
13
10
  }
14
- if ('default' in value.variants) {
11
+ if ('default' in value) {
15
12
  return 'default';
16
13
  }
17
14
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"names":["getKeyForVariant","value","variant","variants","undefined","exports"],"sourceRoot":"../../../src","sources":["utils/variants.ts"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAGA,CAACC,KAAkB,EAAEC,OAAgB,KAAmC;EACpG,IAAI,CAACD,KAAK,CAACE,QAAQ,EAAE;IACjB,OAAOC,SAAS;EACpB;EAEA,IAAIF,OAAO,IAAIA,OAAO,IAAID,KAAK,CAACE,QAAQ,EAAE;IACtC,OAAOD,OAAO;EAClB;EAEA,IAAI,SAAS,IAAID,KAAK,CAACE,QAAQ,EAAE;IAC7B,OAAO,SAAS;EACpB;EAEA,OAAOC,SAAS;AACpB,CAAC;AAAAC,OAAA,CAAAL,gBAAA,GAAAA,gBAAA"}
1
+ {"version":3,"names":["getKeyForVariant","value","variant","undefined","exports"],"sourceRoot":"../../../src","sources":["utils/variants.ts"],"mappings":";;;;;;AAEO,MAAMA,gBAAgB,GAAGA,CAACC,KAAkB,EAAEC,OAAgB,KAAuB;EACxF,IAAIA,OAAO,IAAIA,OAAO,IAAID,KAAK,EAAE;IAC7B,OAAOC,OAAO;EAClB;EAEA,IAAI,SAAS,IAAID,KAAK,EAAE;IACpB,OAAO,SAAS;EACpB;EAEA,OAAOE,SAAS;AACpB,CAAC;AAAAC,OAAA,CAAAJ,gBAAA,GAAAA,gBAAA"}
@@ -1,6 +1,20 @@
1
+ import { Platform } from 'react-native';
2
+ export const warn = message => {
3
+ console.warn(`🦄 [react-native-unistyles]: ${message}`);
4
+ };
5
+ export const isMobile = Platform.OS === 'android' || Platform.OS === 'ios';
6
+ export const isWeb = Platform.OS === 'web';
7
+ export const isIOS = Platform.OS === 'ios';
8
+ export const isAndroid = Platform.OS === 'android';
9
+ export const isServer = typeof window === 'undefined';
10
+ export const ScreenOrientation = {
11
+ Landscape: 'landscape',
12
+ Portrait: 'portrait'
13
+ };
1
14
  export let CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
2
15
  CxxUnistylesEventTypes["Theme"] = "theme";
3
16
  CxxUnistylesEventTypes["Layout"] = "layout";
17
+ CxxUnistylesEventTypes["Plugin"] = "plugin";
4
18
  return CxxUnistylesEventTypes;
5
19
  }({});
6
20
  export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
@@ -10,13 +24,9 @@ export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
10
24
  UnistylesError["ThemesCannotBeEmpty"] = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY";
11
25
  UnistylesError["BreakpointsCannotBeEmpty"] = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY";
12
26
  UnistylesError["BreakpointsMustStartFromZero"] = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO";
27
+ UnistylesError["InvalidPluginName"] = "UNISTYLES_ERROR_INVALID_PLUGIN_NAME";
28
+ UnistylesError["DuplicatePluginName"] = "UNISTYLES_ERROR_DUPLICATE_PLUGIN_NAME";
29
+ UnistylesError["CantRemoveInternalPlugin"] = "UNISTYLES_ERROR_CANT_REMOVE_INTERNAL_PLUGIN";
13
30
  return UnistylesError;
14
31
  }({});
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
32
  //# 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","isMobile","OS","isWeb","isIOS","isAndroid","isServer","window","ScreenOrientation","Landscape","Portrait","CxxUnistylesEventTypes","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,QAAQ,GAAGJ,QAAQ,CAACK,EAAE,KAAK,SAAS,IAAIL,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1E,OAAO,MAAMC,KAAK,GAAGN,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,KAAK,GAAGP,QAAQ,CAACK,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMG,SAAS,GAAGR,QAAQ,CAACK,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMI,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,iBAAiB,GAAG;EAC7BC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU;AAEV,WAAYC,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AAMlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
@@ -1,5 +1,7 @@
1
+ import { UnistylesError } from '../common';
1
2
  export class UnistyleRegistry {
2
3
  config = {};
4
+ plugins = [];
3
5
  themeNames = [];
4
6
  themes = {};
5
7
  breakpoints = {};
@@ -25,7 +27,53 @@ export class UnistyleRegistry {
25
27
  if (config.adaptiveThemes) {
26
28
  this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
27
29
  }
28
- return this;
30
+ if (config.experimentalPlugins) {
31
+ config.experimentalPlugins.forEach(plugin => this.addPlugin(plugin, false));
32
+ }
33
+ if (config.initialTheme) {
34
+ this.unistylesBridge.useTheme(config.initialTheme);
35
+ }
36
+ };
37
+ getTheme = forName => {
38
+ if (this.themeNames.length === 0) {
39
+ return {};
40
+ }
41
+ if (!this.hasTheme(forName)) {
42
+ throw new Error(UnistylesError.ThemeNotFound);
43
+ }
44
+ return this.themes[forName];
45
+ };
46
+ addPlugin = (() => {
47
+ var _this = this;
48
+ return function (plugin) {
49
+ let notify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
50
+ if (plugin.name.startsWith('__unistyles')) {
51
+ throw new Error(UnistylesError.InvalidPluginName);
52
+ }
53
+ if (_this.plugins.some(_ref => {
54
+ let {
55
+ name
56
+ } = _ref;
57
+ return name === plugin.name;
58
+ })) {
59
+ throw new Error(UnistylesError.DuplicatePluginName);
60
+ }
61
+ _this.plugins = _this.plugins.concat([plugin]);
62
+ _this.unistylesBridge.addPlugin(plugin.name, notify);
63
+ };
64
+ })();
65
+ removePlugin = plugin => {
66
+ if (plugin.name.startsWith('__unistyles')) {
67
+ throw new Error(UnistylesError.CantRemoveInternalPlugin);
68
+ }
69
+ this.plugins = this.plugins.filter(_ref2 => {
70
+ let {
71
+ name
72
+ } = _ref2;
73
+ return name !== plugin.name;
74
+ });
75
+ this.unistylesBridge.removePlugin(plugin.name);
29
76
  };
77
+ hasTheme = name => name in this.themes;
30
78
  }
31
79
  //# 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":["UnistylesError","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","experimentalPlugins","forEach","plugin","addPlugin","initialTheme","useTheme","getTheme","forName","length","hasTheme","Error","ThemeNotFound","_this","notify","arguments","undefined","name","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","concat","removePlugin","CantRemoveInternalPlugin","filter","_ref2"],"sourceRoot":"../../../src","sources":["core/Unist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