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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) 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/useStyles.js +5 -4
  28. package/lib/commonjs/useStyles.js.map +1 -1
  29. package/lib/commonjs/utils/breakpoints.js +13 -59
  30. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  31. package/lib/commonjs/utils/index.js +10 -50
  32. package/lib/commonjs/utils/index.js.map +1 -1
  33. package/lib/commonjs/utils/mq.js +1 -1
  34. package/lib/commonjs/utils/mq.js.map +1 -1
  35. package/lib/commonjs/utils/mqParser.js +4 -1
  36. package/lib/commonjs/utils/mqParser.js.map +1 -1
  37. package/lib/commonjs/utils/styles.js +8 -8
  38. package/lib/commonjs/utils/styles.js.map +1 -1
  39. package/lib/module/common.js +17 -7
  40. package/lib/module/common.js.map +1 -1
  41. package/lib/module/core/UnistyleRegistry.js +49 -1
  42. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  43. package/lib/module/core/UnistylesRuntime.js +12 -16
  44. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  45. package/lib/module/hooks/useUnistyles.js +8 -2
  46. package/lib/module/hooks/useUnistyles.js.map +1 -1
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/plugins/index.js +4 -0
  49. package/lib/module/plugins/index.js.map +1 -0
  50. package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
  51. package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
  52. package/lib/module/plugins/normalizer/index.js +3 -0
  53. package/lib/module/plugins/normalizer/index.js.map +1 -0
  54. package/lib/module/plugins/normalizer/module.d.js.map +1 -0
  55. package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
  56. package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
  57. package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
  58. package/lib/module/plugins/withPlugins.js +11 -0
  59. package/lib/module/plugins/withPlugins.js.map +1 -0
  60. package/lib/module/types/plugin.js +2 -0
  61. package/lib/{commonjs/utils/module.d.js.map → module/types/plugin.js.map} +1 -1
  62. package/lib/module/useStyles.js +5 -4
  63. package/lib/module/useStyles.js.map +1 -1
  64. package/lib/module/utils/breakpoints.js +12 -56
  65. package/lib/module/utils/breakpoints.js.map +1 -1
  66. package/lib/module/utils/index.js +2 -5
  67. package/lib/module/utils/index.js.map +1 -1
  68. package/lib/module/utils/mq.js +1 -1
  69. package/lib/module/utils/mq.js.map +1 -1
  70. package/lib/module/utils/mqParser.js +3 -3
  71. package/lib/module/utils/mqParser.js.map +1 -1
  72. package/lib/module/utils/styles.js +8 -8
  73. package/lib/module/utils/styles.js.map +1 -1
  74. package/lib/typescript/src/common.d.ts +16 -6
  75. package/lib/typescript/src/common.d.ts.map +1 -1
  76. package/lib/typescript/src/core/UnistyleRegistry.d.ts +7 -2
  77. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
  78. package/lib/typescript/src/core/UnistylesRuntime.d.ts +7 -8
  79. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  80. package/lib/typescript/src/core/index.d.ts +1 -0
  81. package/lib/typescript/src/core/index.d.ts.map +1 -1
  82. package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
  83. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
  84. package/lib/typescript/src/index.d.ts +4 -3
  85. package/lib/typescript/src/index.d.ts.map +1 -1
  86. package/lib/typescript/src/plugins/index.d.ts +4 -0
  87. package/lib/typescript/src/plugins/index.d.ts.map +1 -0
  88. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
  89. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
  90. package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
  91. package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
  92. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
  93. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
  94. package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
  95. package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
  96. package/lib/typescript/src/plugins/withPlugins.d.ts +3 -0
  97. package/lib/typescript/src/plugins/withPlugins.d.ts.map +1 -0
  98. package/lib/typescript/src/types/core.d.ts +1 -0
  99. package/lib/typescript/src/types/core.d.ts.map +1 -1
  100. package/lib/typescript/src/types/index.d.ts +2 -1
  101. package/lib/typescript/src/types/index.d.ts.map +1 -1
  102. package/lib/typescript/src/types/plugin.d.ts +7 -0
  103. package/lib/typescript/src/types/plugin.d.ts.map +1 -0
  104. package/lib/typescript/src/types/unistyles.d.ts +11 -2
  105. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  106. package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
  107. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  108. package/lib/typescript/src/utils/index.d.ts +2 -5
  109. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  110. package/lib/typescript/src/utils/mqParser.d.ts +12 -0
  111. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
  112. package/lib/typescript/src/utils/styles.d.ts +3 -3
  113. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  114. package/package.json +4 -1
  115. package/src/__tests__/mocks.ts +24 -0
  116. package/src/common.ts +22 -7
  117. package/src/core/UnistyleRegistry.ts +46 -2
  118. package/src/core/UnistylesRuntime.ts +14 -20
  119. package/src/core/index.ts +1 -0
  120. package/src/hooks/useUnistyles.ts +7 -2
  121. package/src/index.ts +3 -1
  122. package/src/plugins/index.ts +3 -0
  123. package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
  124. package/src/plugins/normalizer/index.ts +2 -0
  125. package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
  126. package/src/{utils → plugins/normalizer}/normalizer.ts +1 -1
  127. package/src/plugins/withPlugins.ts +17 -0
  128. package/src/types/core.ts +1 -0
  129. package/src/types/index.ts +11 -1
  130. package/src/types/plugin.ts +7 -0
  131. package/src/types/unistyles.ts +14 -4
  132. package/src/useStyles.ts +4 -4
  133. package/src/utils/breakpoints.ts +10 -66
  134. package/src/utils/index.ts +2 -5
  135. package/src/utils/mq.ts +1 -1
  136. package/src/utils/mqParser.ts +4 -4
  137. package/src/utils/styles.ts +11 -11
  138. package/lib/commonjs/utils/common.js +0 -25
  139. package/lib/commonjs/utils/common.js.map +0 -1
  140. package/lib/commonjs/utils/normalizeStyles.js +0 -10
  141. package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
  142. package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
  143. package/lib/commonjs/utils/normalizer.js.map +0 -1
  144. package/lib/module/utils/common.js +0 -17
  145. package/lib/module/utils/common.js.map +0 -1
  146. package/lib/module/utils/normalizeStyles.js +0 -3
  147. package/lib/module/utils/normalizeStyles.js.map +0 -1
  148. package/lib/module/utils/normalizeStyles.web.js.map +0 -1
  149. package/lib/module/utils/normalizer.js.map +0 -1
  150. package/lib/typescript/src/utils/common.d.ts +0 -12
  151. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  152. package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
  153. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
  154. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
  155. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
  156. package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
  157. package/src/utils/common.ts +0 -20
  158. package/src/utils/normalizeStyles.ts +0 -2
  159. /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
  160. /package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +0 -0
  161. /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
  162. /package/lib/module/{utils → plugins/normalizer}/normalizer.js +0 -0
  163. /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":"../../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;EAAO,CAAC,GAAG,IAAAC,mBAAY,EAAC,CAAC;EACxC,MAAM;IAAEC,UAAU;IAAEC;EAAW,CAAC,GAAGH,MAAM;EAEzC,IAAI,CAACH,UAAU,EAAE;IACb,OAAO;MACHE,KAAK;MACLI,UAAU;MACVC,MAAM,EAAE,CAAC;IACb,CAAC;EACL;EAEA,MAAMC,YAAY,GAAG,IAAAC,cAAO,EAAC,MAAM,OAAOT,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,CAAC,CAAC;EAEtC,MAAMU,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,EAACF,KAAK,EAAEX,UAAU,EAAED,UAAU,EAAEJ,OAAO;MACjE,CAAC;IACL;IAEA,OAAOmB,uBAAU,CAACC,MAAM,CAAC;MACrB,GAAGP,GAAG;MACN,CAACE,GAAG,GAAG,IAAAM,iBAAU,EAAKJ,KAAK,EAAEZ,UAAU,EAAED,UAAU,EAAEJ,OAAO;IAChE,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,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,EACzD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ACL,CAAC;AAAAa,OAAA,CAAAzB,SAAA,GAAAA,SAAA"}
@@ -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,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,C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B,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,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
- getValueForBreakpoint: 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 () {
@@ -53,10 +27,16 @@ Object.defineProperty(exports, "getValueForBreakpoint", {
53
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,K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AAC,CAAC,EAAkB;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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AAE;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"}
@@ -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,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B,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,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHC,KAAK,EAAEA,KAAK,GAAG;MACX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yle = exports.isPlatformColor = void 0;
7
7
  var _breakpoints = require("./breakpoints");
8
- var _normalizeStyles = require("./normalizeStyles");
9
- var _common = require("./common");
8
+ var _common = require("../common");
10
9
  var _variants = require("./variants");
11
- const proxifyFunction = (fn, breakpoint, screenSize, variant) => new Proxy(fn, {
12
- apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
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)
13
13
  });
14
14
  exports.proxifyFunction = proxifyFunction;
15
15
  const isPlatformColor = value => {
@@ -19,7 +19,7 @@ const isPlatformColor = value => {
19
19
  return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
20
20
  };
21
21
  exports.isPlatformColor = isPlatformColor;
22
- const parseStyle = (style, breakpoint, screenSize, variant) => {
22
+ const parseStyle = (key, style, breakpoint, screenSize, variant) => {
23
23
  const entries = Object.entries(style || {}).map(_ref => {
24
24
  let [key, value] = _ref;
25
25
  if (key !== 'variants') {
@@ -35,11 +35,11 @@ const parseStyle = (style, breakpoint, screenSize, variant) => {
35
35
  let [key, value] = _ref2;
36
36
  const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
37
37
  if (hasNestedProperties) {
38
- return [key, parseStyle(value, breakpoint, screenSize, variant)];
38
+ return [key, parseStyle(key, value, breakpoint, screenSize, variant)];
39
39
  }
40
40
  const isTransform = key === 'transform';
41
41
  if (isTransform && Array.isArray(value)) {
42
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize, variant))];
42
+ return [key, value.map(value => parseStyle(key, value, breakpoint, screenSize, variant))];
43
43
  }
44
44
  const isDynamicFunction = typeof value === 'function';
45
45
  const isValidStyle = typeof value !== 'object' || isPlatformColor(value);
@@ -48,7 +48,7 @@ const parseStyle = (style, breakpoint, screenSize, variant) => {
48
48
  }
49
49
  return [key, (0, _breakpoints.getValueForBreakpoint)(value)];
50
50
  }));
51
- return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
51
+ return (0, _plugins.withPlugins)(key, parsedStyles);
52
52
  };
53
53
  exports.parseStyle = parseStyle;
54
54
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","_variants","proxifyFunction","fn","breakpoint","screenSize","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","entries","Object","map","_ref","key","variantKey","getKeyForVariant","undefined","flat","filter","Boolean","parsedStyles","fromEntries","_ref2","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;AACA,IAAAG,SAAA,GAAAH,OAAA;AAEO,MAAMI,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;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iBAAS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OAAO,CACHU,GAAG,EACHV,KAAK,CAACQ,GAAG,CAACR,KAAK,IAAIH,UAAU,CAACG,KAAK,EAAEX,UAAU,EAAEC,UAAU,EAAEC,OAAO,CAAC,CAAC,CACzE;IACL;IAEA,MAAMiC,iBAAiB,GAAG,OAAOxB,KAAK,KAAK,UAAU;IACrD,MAAMyB,YAAY,GAAG,OAAOzB,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC;IAExE,IAAIwB,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACf,GAAG,EAAEV,KAAK,CAAC;IACvB;IAEA,OAAO,CACHU,GAAG,EACH,IAAAgB,kCAAqB,EAAC1B,KAAoB,CAAC,CAC9C;EACL,CAAC,CACL,CAAC;EAEL,OAAO2B,aAAK,GACN,IAAAC,gCAAe,EAACX,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;AAAAnB,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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B,CAAC/B,GAAG,EAAEa,KAAK,CAAC,GAAAkB,KAAA;IACd,MAAMC,mBAAmB,GAAGhC,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAK,kBAAkB;IAEhF,IAAIgC,mBAAmB,EAAE;MACrB,OAAO,CACHhC,GAAG,EACHU,UAAU,CAACV,GAAG,EAAEa,KAAK,EAA0BX,UAAU,EAAEC,UAAU,EAAEC,OAAO,CAAC,CAClF;IACL;IAEA,MAAM6B,WAAW,GAAGjC,GAAG,KAAK,WAAW;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"}
@@ -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/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,cAAc,QAAQ,WAAW;AAE1C,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2B,EAAE;EACpCC,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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OAAKJ,IAAI,KAAKd,MAAM,CAACc,IAAI;MAAA,EAAC,EAAE;QACvD,MAAM,IAAIN,KAAK,CAAC5B,cAAc,CAACuC,mBAAmB,CAAC;MACvD;MAEAT,KAAI,CAAC3B,OAAO,GAAG2B,KAAI,CAAC3B,OAAO,CAACqC,MAAM,CAAC,CAACpB,MAAM,CAAC,CAAC;MAC5CU,KAAI,CAACrB,eAAe,CAACY,SAAS,CAACD,MAAM,CAACc,IAAI,EAAEH,MAAM,CAAC;IACvD,CAAC;EAAA;EAEMU,YAAY,GAAIrB,MAAuB,IAAK;IAC/C,IAAIA,MAAM,CAACc,IAAI,CAACC,UAAU,CAAC,aAAa,CAAC,EAAE;MACvC,MAAM,IAAIP,KAAK,CAAC5B,cAAc,CAAC0C,wBAAwB,CAAC;IAC5D;IAEA,IAAI,CAACvC,OAAO,GAAG,IAAI,CAACA,OAAO,CAACwC,MAAM,CAACC,KAAA;MAAA,IAAC;QAAEV;MAAK,CAAC,GAAAU,KAAA;MAAA,OAAKV,IAAI,KAAKd,MAAM,CAACc,IAAI;IAAA,EAAC;IACtE,IAAI,CAACzB,eAAe,CAACgC,YAAY,CAACrB,MAAM,CAACc,IAAI,CAAC;EAClD,CAAC;EAEMP,QAAQ,GAAIO,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAC7B,MAAM;AAC1E"}
@@ -1,8 +1,8 @@
1
1
  import { ScreenOrientation, UnistylesError } from '../common';
2
2
  export class UnistylesRuntime {
3
- constructor(unistylesBridge, registry) {
3
+ constructor(unistylesBridge, unistylesRegistry) {
4
4
  this.unistylesBridge = unistylesBridge;
5
- this.registry = registry;
5
+ this.unistylesRegistry = unistylesRegistry;
6
6
  }
7
7
  get colorScheme() {
8
8
  return this.unistylesBridge.colorScheme;
@@ -10,15 +10,15 @@ export class UnistylesRuntime {
10
10
  get hasAdaptiveThemes() {
11
11
  return this.unistylesBridge.hasAdaptiveThemes;
12
12
  }
13
- get sortedBreakpoints() {
14
- return this.registry.sortedBreakpointPairs;
15
- }
16
13
  get themeName() {
17
14
  return this.unistylesBridge.themeName;
18
15
  }
19
16
  get breakpoint() {
20
17
  return this.unistylesBridge.breakpoint;
21
18
  }
19
+ get enabledPlugins() {
20
+ return this.unistylesBridge.enabledPlugins;
21
+ }
22
22
  get screen() {
23
23
  return {
24
24
  width: this.unistylesBridge.screenWidth,
@@ -36,24 +36,20 @@ export class UnistylesRuntime {
36
36
  return ScreenOrientation.Portrait;
37
37
  }
38
38
  setTheme = name => {
39
- if (this.hasTheme(name)) {
39
+ if (this.unistylesRegistry.hasTheme(name)) {
40
40
  this.unistylesBridge.useTheme(name);
41
41
  return true;
42
42
  }
43
43
  throw new Error(UnistylesError.ThemeNotRegistered);
44
44
  };
45
- getTheme = forName => {
46
- if (this.registry.themeNames.length === 0) {
47
- return {};
48
- }
49
- if (!this.hasTheme(forName)) {
50
- throw new Error(UnistylesError.ThemeNotFound);
51
- }
52
- return this.registry.themes[forName];
53
- };
54
45
  setAdaptiveThemes = enable => {
55
46
  this.unistylesBridge.useAdaptiveThemes(enable);
56
47
  };
57
- hasTheme = name => name in this.registry.themes;
48
+ addPlugin = plugin => {
49
+ this.unistylesRegistry.addPlugin(plugin);
50
+ };
51
+ removePlugin = plugin => {
52
+ this.unistylesRegistry.removePlugin(plugin);
53
+ };
58
54
  }
59
55
  //# sourceMappingURL=UnistylesRuntime.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","getTheme","forName","themeNames","length","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;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B,IAAK;IAClD,IAAI,IAAI,CAACtB,QAAQ,CAACuB,UAAU,CAACC,MAAM,KAAK,CAAC,EAAE;MACvC,OAAO,CAAC,CAAC;IACb;IAEA,IAAI,CAAC,IAAI,CAACP,QAAQ,CAACK,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIH,KAAK,CAACvB,cAAc,CAAC6B,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAACzB,QAAQ,CAAC0B,MAAM,CAACJ,OAAO,CAAC;EACxC,CAAC;EAEMK,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC7B,eAAe,CAAC8B,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOX,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAAChB,QAAQ,CAAC0B,MAAM;AACpF"}
1
+ {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","unistylesRegistry","colorScheme","hasAdaptiveThemes","themeName","breakpoint","enabledPlugins","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","Error","ThemeNotRegistered","setAdaptiveThemes","enable","useAdaptiveThemes","addPlugin","plugin","removePlugin"],"sourceRoot":"../../../src","sources":["core/UnistylesRuntime.ts"],"mappings":"AAAA,SAASA,iBAAiB,EAAEC,cAAc,QAAQ,WAAW;AAK7D,OAAO,MAAMC,gBAAgB,CAAC;EAC1BC,WAAWA,CAASC,eAAgC,EAAUC,iBAAmC,EAAE;IAAA,KAA/ED,eAAgC,GAAhCA,eAAgC;IAAA,KAAUC,iBAAmC,GAAnCA,iBAAmC;EAAG;EAEpG,IAAWC,WAAWA,CAAA,EAAG;IACrB,OAAO,IAAI,CAACF,eAAe,CAACE,WAAW;EAC3C;EAEA,IAAWC,iBAAiBA,CAAA,EAAG;IAC3B,OAAO,IAAI,CAACH,eAAe,CAACG,iBAAiB;EACjD;EAEA,IAAWC,SAASA,CAAA,EAAG;IACnB,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