react-native-unistyles 2.0.0-rc.1 → 2.0.0-rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. package/lib/commonjs/core/UnistyleRegistry.js +15 -25
  2. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  3. package/lib/commonjs/core/UnistylesModule.js +187 -2
  4. package/lib/commonjs/core/UnistylesModule.js.map +1 -1
  5. package/lib/commonjs/core/UnistylesModule.native.js +9 -0
  6. package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
  7. package/lib/commonjs/hooks/useCSS.js +36 -1
  8. package/lib/commonjs/hooks/useCSS.js.map +1 -1
  9. package/lib/commonjs/hooks/useCSS.native.js +9 -0
  10. package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
  11. package/lib/commonjs/normalizer/normalizer.js +1 -2
  12. package/lib/commonjs/normalizer/normalizer.js.map +1 -1
  13. package/lib/commonjs/useStyles.js +1 -2
  14. package/lib/commonjs/useStyles.js.map +1 -1
  15. package/lib/commonjs/utils/breakpoints.js +2 -11
  16. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  17. package/lib/commonjs/utils/cssMediaQuery.js +3 -9
  18. package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
  19. package/lib/commonjs/utils/mq.js +12 -36
  20. package/lib/commonjs/utils/mq.js.map +1 -1
  21. package/lib/commonjs/utils/mqParser.js +1 -2
  22. package/lib/commonjs/utils/mqParser.js.map +1 -1
  23. package/lib/commonjs/utils/styles.js +34 -39
  24. package/lib/commonjs/utils/styles.js.map +1 -1
  25. package/lib/module/core/UnistyleRegistry.js +15 -25
  26. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  27. package/lib/module/core/UnistylesModule.js +186 -2
  28. package/lib/module/core/UnistylesModule.js.map +1 -1
  29. package/lib/module/core/UnistylesModule.native.js +3 -0
  30. package/lib/module/core/UnistylesModule.native.js.map +1 -0
  31. package/lib/module/hooks/useCSS.js +36 -1
  32. package/lib/module/hooks/useCSS.js.map +1 -1
  33. package/lib/module/hooks/useCSS.native.js +2 -0
  34. package/lib/module/hooks/useCSS.native.js.map +1 -0
  35. package/lib/module/normalizer/normalizer.js +1 -2
  36. package/lib/module/normalizer/normalizer.js.map +1 -1
  37. package/lib/module/useStyles.js +1 -2
  38. package/lib/module/useStyles.js.map +1 -1
  39. package/lib/module/utils/breakpoints.js +2 -11
  40. package/lib/module/utils/breakpoints.js.map +1 -1
  41. package/lib/module/utils/cssMediaQuery.js +3 -9
  42. package/lib/module/utils/cssMediaQuery.js.map +1 -1
  43. package/lib/module/utils/mq.js +12 -36
  44. package/lib/module/utils/mq.js.map +1 -1
  45. package/lib/module/utils/mqParser.js +1 -2
  46. package/lib/module/utils/mqParser.js.map +1 -1
  47. package/lib/module/utils/styles.js +34 -39
  48. package/lib/module/utils/styles.js.map +1 -1
  49. package/lib/typescript/src/core/UnistylesModule.d.ts +17 -4
  50. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
  51. package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
  52. package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
  53. package/lib/typescript/src/hooks/useCSS.d.ts +1 -1
  54. package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
  55. package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
  56. package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
  57. package/package.json +6 -8
  58. package/src/core/UnistylesModule.native.ts +7 -0
  59. package/src/core/UnistylesModule.ts +224 -4
  60. package/src/hooks/useCSS.native.ts +3 -0
  61. package/src/hooks/useCSS.ts +49 -1
  62. package/lib/commonjs/core/UnistylesModule.web.js +0 -199
  63. package/lib/commonjs/core/UnistylesModule.web.js.map +0 -1
  64. package/lib/commonjs/hooks/useCSS.web.js +0 -46
  65. package/lib/commonjs/hooks/useCSS.web.js.map +0 -1
  66. package/lib/module/core/UnistylesModule.web.js +0 -192
  67. package/lib/module/core/UnistylesModule.web.js.map +0 -1
  68. package/lib/module/hooks/useCSS.web.js +0 -39
  69. package/lib/module/hooks/useCSS.web.js.map +0 -1
  70. package/lib/typescript/src/core/UnistylesModule.web.d.ts +0 -19
  71. package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +0 -1
  72. package/lib/typescript/src/hooks/useCSS.web.d.ts +0 -3
  73. package/lib/typescript/src/hooks/useCSS.web.d.ts.map +0 -1
  74. package/src/core/UnistylesModule.web.ts +0 -227
  75. package/src/hooks/useCSS.web.ts +0 -51
@@ -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","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,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;M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AAK;AAChB,CAAC;AAAAO,OAAA,CAAAK,yBAAA,GAAAA,yBAAA;AAED,MAAME,gBAAgB,GAAGA,CAAClB,KAAiC,EAAEoB,WAAmB,KAAc;EAC1F,MAAM;IAAEb,IAAI;IAAEE;EAAG,CAAC,GAAGT,KAA0B;EAE/C,OAAOoB,WAAW,IAAIb,IAAI,IAAIa,WAAW,IAAIX,EAAE;AACnD,CAAC;AAED,MAAMU,iBAAiB,GAAGA,CAACf,MAAmC,EAAEiB,YAAoB,KAAc;EAC9F,MAAM;IAAEd,IAAI;IAAEE;EAAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOiB,YAAY,IAAId,IAAI,IAAIc,YAAY,IAAIZ,EAAE;AACrD,CAAC;AAEM,MAAMa,4BAA4B,GAAGA,CAACC,YAAsC,EAAEN,UAAsB,KAAuB;EAC9H,MAAMlB,EAAE,GAAGwB,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,GAAGjB,OAAO,CAAC4B,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,OAAOlB,EAAE,EAAE4B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAhB,OAAA,CAAAW,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","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,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;AAAAC,OAAA,CAAAb,OAAA,GAAAA,OAAA;AAEM,MAAMc,aAAa,GAAIb,EAAU,IAAKJ,kBAAkB,CAACkB,IAAI,CAACd,EAAE,CAAC;AAAAY,OAAA,CAAAC,aAAA,GAAAA,aAAA;AAEjE,MAAME,SAAS,GAAIC,QAA2B,IAAK;EACtD,MAAM;IAAEf,KAAK;IAAEI;EAAO,CAAC,GAAGW,QAAQ;EAElC,IAAIf,KAAK,IAAII,MAAM,EAAE;IACjB,OAAOJ,KAAK,CAACO,IAAI,IAAIP,KAAK,CAACS,EAAE,IAAIL,MAAM,CAACG,IAAI,IAAIH,MAAM,CAACK,EAAE;EAC7D;EAEA,IAAIT,KAAK,EAAE;IACP,OAAOA,K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lB,EAAE,GAAGwB,YAAY,CAACC,IAAI,CAAC,CAAC,CAACC,GAAG,CAAC,KAAK;IACpC,IAAI,CAACb,aAAa,CAACa,GAAa,CAAC,EAAE;MAC/B,OAAO,KAAK;IAChB;IAEA,MAAMV,QAAQ,GAAGjB,OAAO,CAAC2B,GAAa,CAAC;IAEvC,IAAI,CAACX,SAAS,CAACC,QAAQ,CAAC,EAAE;MACtB,OAAO,KAAK;IAChB;IAEA,OAAOC,yBAAyB,CAACD,QAAQ,EAAEE,UAAU,CAAC;EAC1D,CAAC,CAAC;EAEF,OAAOlB,EAAE,EAAE2B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC;AAAAf,OAAA,CAAAW,4BAAA,GAAAA,4BAAA"}
@@ -18,51 +18,46 @@ const isPlatformColor = value => {
18
18
  return _common.isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
19
19
  };
20
20
  exports.isPlatformColor = isPlatformColor;
21
- const parseStyle = function (style) {
22
- let variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23
- let parseMediaQueries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
24
- return Object.entries(style || {}).reduce((acc, _ref) => {
25
- let [key, value] = _ref;
26
- // nested objects
27
- if (key === 'shadowOffset' || key === 'textShadowOffset') {
28
- acc[key] = parseStyle(value, variant);
29
- return acc;
30
- }
21
+ const parseStyle = (style, variant = {}, parseMediaQueries = true) => Object.entries(style || {}).reduce((acc, [key, value]) => {
22
+ // nested objects
23
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
24
+ acc[key] = parseStyle(value, variant);
25
+ return acc;
26
+ }
31
27
 
32
- // transforms
33
- if (key === 'transform' && Array.isArray(value)) {
34
- acc[key] = value.map(value => parseStyle(value, variant));
35
- return acc;
36
- }
28
+ // transforms
29
+ if (key === 'transform' && Array.isArray(value)) {
30
+ acc[key] = value.map(value => parseStyle(value, variant));
31
+ return acc;
32
+ }
37
33
 
38
- // values or platform colors
39
- if (typeof value !== 'object' || isPlatformColor(value)) {
40
- acc[key] = value;
41
- return acc;
42
- }
43
- if (key === 'variants') {
44
- return {
34
+ // values or platform colors
35
+ if (typeof value !== 'object' || isPlatformColor(value)) {
36
+ acc[key] = value;
37
+ return acc;
38
+ }
39
+ if (key === 'variants') {
40
+ return {
41
+ ...acc,
42
+ ...Object.keys(value).reduce((acc, key) => ({
45
43
  ...acc,
46
- ...Object.keys(value).reduce((acc, key) => ({
47
- ...acc,
48
- // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
49
- ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
50
- }), {})
51
- };
52
- }
44
+ // this will parse the styles of the selected variant (or default if it is undefined), if selected variant has no styles then it will fallback to default styles
45
+ ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
46
+ }), {})
47
+ };
48
+ }
53
49
 
54
- // don't parse media queries and breakpoints
55
- if (!parseMediaQueries) {
56
- return {
57
- ...acc,
58
- [key]: value
59
- };
60
- }
50
+ // don't parse media queries and breakpoints
51
+ if (!parseMediaQueries) {
61
52
  return {
62
53
  ...acc,
63
- [key]: (0, _breakpoints.getValueForBreakpoint)(value)
54
+ [key]: value
64
55
  };
65
- }, {});
66
- };
56
+ }
57
+ return {
58
+ ...acc,
59
+ [key]: (0, _breakpoints.getValueForBreakpoint)(value)
60
+ };
61
+ }, {});
67
62
  exports.parseStyle = parseStyle;
68
63
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","arguments","length","undefined","parseMediaQueries","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","default","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,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AAGS,UAAU,CAACG,KAAK,EAAEV,OAAO,CAAC;MAErC,OAAOuB,GAAG;IACd;;IAEA;IACA,IAAIzB,GAAG,KAAK,WAAW,IAAI2B,KAAK,CAACC,OAAO,CAAChB,KAAK,CAAC,EAAE;MAC7Ca,GAAG,CAACzB,GAAG,CAAC,GAAGY,KAAK,CAACiB,GAAG,CAACjB,KAAK,IAAIH,UAAU,CAACG,KAAK,EAAEV,OAAO,CAAC,CAAC;MAEzD,OAAOuB,GAAG;IACd;;IAEA;IACA,IAAI,OAAOb,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;MACrDa,GAAG,CAACzB,GAAG,CAAY,GAAGY,KAAK;MAE3B,OAAOa,GAAG;IACd;IAEA,IAAIzB,GAAG,KAAK,UAAU,EAAE;MACpB,OAAO;QACH,GAAGyB,GAAG;QACN,GAAIH,MAAM,CACLQ,IAAI,CAAClB,KAAK,CAAC,CACXY,MAAM,CAAC,CAACC,GAAG,EAAEzB,GAAG,MAAM;UACnB,GAAGyB,GAAG;UACN;UACA,GAAGhB,UAAU,CAAEG,KAAK,CAAEZ,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAKY,KAAK,CAAEZ,GAAG,CAAC,CAAC+B,OAAO,IAAI,CAAC,CAAC;QAC/G,CAAC,CAAC,EAAE,CAAC,CAAC;MACd,CAAC;IACL;;IAEA;IACA,IAAI,CAACV,iBAAiB,EAAE;MACpB,OAAO;QACH,GAAGI,GAAG;QACN,CAACzB,GAAG,GAAGY;MACX,CAAC;IACL;IAEA,OAAO;MACH,GAAGa,GAAG;MACN,CAACzB,GAAG,GAAG,IAAAgC,kCAAqB,EAACpB,KAAgC;IACjE,CAAC;EACL,CAAC,EAAE,CAAC,CAAM,CAAC;AAAA;AAAAF,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_breakpoints","require","_common","_withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","withPlugins","parseStyle","exports","isPlatformColor","value","isIOS","semantic","isAndroid","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","default","getValueForBreakpoint"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AACA,IAAAE,YAAA,GAAAF,OAAA;AAEO,MAAMG,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAK,IAAAC,wBAAW,EAACR,GAAG,EAAES,UAAU,CAACJ,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAAAQ,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAEK,MAAMY,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIC,aAAK,EAAE;IACP,OAAO,UAAU,IAAID,KAAK,IAAI,OAAOA,KAAK,CAACE,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOC,iBAAS,IAAI,gBAAgB,IAAIH,KAAK,IAAI,OAAOA,KAAK,CAACI,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAAAN,OAAA,CAAAC,eAAA,GAAAA,eAAA;AAEM,MAAMF,UAAU,GAAGA,CACtBQ,KAAQ,EACRf,OAAyC,GAAG,CAAC,CAAC,EAC9CgB,iBAAiB,GAAG,IAAI,KACpBC,MAAM,CACTC,OAAO,CAACH,KAAK,IAAI,CAAC,CAAC,CAAC,CACpBI,MAAM,CAAC,CAACC,GAAG,EAAE,CAACtB,GAAG,EAAEY,KAAK,CAAC,KAAK;EAC3B;EACA,IAAIZ,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAM,kBAAkB,EAAE;IACvDs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throw new Error(UnistylesError.ThemeNotSelected);
63
63
  };
64
- addPlugin = (() => {
65
- var _this = this;
66
- return function (plugin) {
67
- let notify = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
68
- if (plugin.name.startsWith('__unistyles')) {
69
- throw new Error(UnistylesError.InvalidPluginName);
70
- }
71
- if (_this.plugins.some(_ref => {
72
- let {
73
- name
74
- } = _ref;
75
- return name === plugin.name;
76
- })) {
77
- throw new Error(UnistylesError.DuplicatePluginName);
78
- }
79
- _this.plugins = [plugin].concat(_this.plugins);
80
- _this.unistylesBridge.addPlugin(plugin.name, notify);
81
- };
82
- })();
64
+ addPlugin = (plugin, notify = true) => {
65
+ if (plugin.name.startsWith('__unistyles')) {
66
+ throw new Error(UnistylesError.InvalidPluginName);
67
+ }
68
+ if (this.plugins.some(({
69
+ name
70
+ }) => name === plugin.name)) {
71
+ throw new Error(UnistylesError.DuplicatePluginName);
72
+ }
73
+ this.plugins = [plugin].concat(this.plugins);
74
+ this.unistylesBridge.addPlugin(plugin.name, notify);
75
+ };
83
76
  removePlugin = plugin => {
84
77
  if (plugin.name.startsWith('__unistyles')) {
85
78
  throw new Error(UnistylesError.CantRemoveInternalPlugin);
86
79
  }
87
- this.plugins = this.plugins.filter(_ref2 => {
88
- let {
89
- name
90
- } = _ref2;
91
- return name !== plugin.name;
92
- });
80
+ this.plugins = this.plugins.filter(({
81
+ name
82
+ }) => name !== plugin.name);
93
83
  this.unistylesBridge.removePlugin(plugin.name);
94
84
  };
95
85
  hasTheme = name => name in this.themes;
@@ -1 +1 @@
1
- {"version":3,"names":["isWeb","UnistylesError","cssMediaQueriesPlugin","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","concat","name","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","_this","notify","arguments","undefined","startsWith","InvalidPluginName","some","_ref","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter","_ref2"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,cAAc,QAAQ,WAAW;AACjD,SAASC,qBAAqB,EAAEC,wBAAwB,QAAQ,YAAY;AAE5E,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BN,KAAK,GACxC,CAACG,wBAAwB,CAAC,GAC1B,EAAE;EACDI,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;MACHE,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCC,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMD,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;IAC9B,IAAI,CAACG,eAAe,CAACM,cAAc,CAACT,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO;MACHG,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBI,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMA,SAAS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":3,"names":["isWeb","UnistylesError","cssMediaQueriesPlugin","normalizeWebStylesPlugin","UnistyleRegistry","config","plugins","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","addConfig","useBreakpoints","adaptiveThemes","useAdaptiveThemes","forEach","plugin","addPlugin","initialTheme","useTheme","experimentalCSSMediaQueries","concat","name","getTheme","forName","length","hasTheme","themeName","Error","ThemeNotFound","ThemeNotSelected","notify","startsWith","InvalidPluginName","some","DuplicatePluginName","removePlugin","CantRemoveInternalPlugin","filter"],"sourceRoot":"../../../src","sources":["core/UnistyleRegistry.ts"],"mappings":"AAEA,SAASA,KAAK,EAAEC,cAAc,QAAQ,WAAW;AACjD,SAASC,qBAAqB,EAAEC,wBAAwB,QAAQ,YAAY;AAE5E,OAAO,MAAMC,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,OAAO,GAA2BN,KAAK,GACxC,CAACG,wBAAwB,CAAC,GAC1B,EAAE;EACDI,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;MACHE,cAAc,EAAE,IAAI,CAACA,cAAc;MACnCC,SAAS,EAAE,IAAI,CAACA;IACpB,CAAC;EACL,CAAC;EAEMD,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACA,WAAW,GAAGA,WAAW;I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AAI,CAACpB,MAAM;AAC1E"}
@@ -1,3 +1,187 @@
1
- import { NativeModules } from 'react-native';
2
- export const UnistylesModule = NativeModules?.Unistyles;
1
+ import { NativeEventEmitter, NativeModules } from 'react-native';
2
+ import { normalizeWebStylesPlugin } from '../plugins';
3
+ import { isServer } from '../common';
4
+ export class UnistylesBridgeWeb {
5
+ #timerRef = undefined;
6
+ #hasAdaptiveThemes = false;
7
+ #supportsAutomaticColorScheme = false;
8
+ #screenWidth = isServer ? undefined : window.innerWidth;
9
+ #screenHeight = isServer ? undefined : window.innerHeight;
10
+ #themes = [];
11
+ #breakpoints = {};
12
+ #colorScheme = this.getPreferredColorScheme();
13
+ #themeName = '';
14
+ #enabledPlugins = [normalizeWebStylesPlugin.name];
15
+ #unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
16
+ #sortedBreakpointPairs = [];
17
+ #breakpoint = '';
18
+ constructor() {
19
+ if (!isServer) {
20
+ this.setupListeners();
21
+ this.#screenWidth = window.innerWidth;
22
+ this.#screenHeight = window.innerHeight;
23
+ }
24
+ }
25
+ install() {
26
+ // @ts-ignore
27
+ // eslint-disable-next-line no-undef
28
+ globalThis.__UNISTYLES__ = new Proxy({}, {
29
+ get: (_target, prop) => {
30
+ switch (prop) {
31
+ case 'themeName':
32
+ return this.getTheme();
33
+ case 'screenWidth':
34
+ return this.#screenWidth;
35
+ case 'screenHeight':
36
+ return this.#screenHeight;
37
+ case 'breakpoint':
38
+ return this.#breakpoint || undefined;
39
+ case 'breakpoints':
40
+ return this.#breakpoints;
41
+ case 'hasAdaptiveThemes':
42
+ return this.#hasAdaptiveThemes;
43
+ case 'sortedBreakpointPairs':
44
+ return this.#sortedBreakpointPairs;
45
+ case 'enabledPlugins':
46
+ return this.#enabledPlugins;
47
+ case 'colorScheme':
48
+ return this.#colorScheme;
49
+ case 'useTheme':
50
+ return themeName => this.useTheme(themeName);
51
+ case 'useBreakpoints':
52
+ return breakpoints => this.useBreakpoints(breakpoints);
53
+ case 'useAdaptiveThemes':
54
+ return enable => this.useAdaptiveThemes(enable);
55
+ case 'addPlugin':
56
+ return (pluginName, notify) => this.addPlugin(pluginName, notify);
57
+ case 'removePlugin':
58
+ return pluginName => this.removePlugin(pluginName);
59
+ default:
60
+ return Reflect.get(this, prop);
61
+ }
62
+ },
63
+ set: (target, prop, newValue, receiver) => {
64
+ switch (prop) {
65
+ case 'themes':
66
+ {
67
+ this.#themes = newValue;
68
+ this.#supportsAutomaticColorScheme = newValue.includes('light') && newValue.includes('dark');
69
+ return true;
70
+ }
71
+ case 'themeName':
72
+ {
73
+ this.#themeName = newValue;
74
+ this.emitThemeChange();
75
+ return true;
76
+ }
77
+ default:
78
+ return Reflect.set(target, prop, newValue, receiver);
79
+ }
80
+ }
81
+ });
82
+ return true;
83
+ }
84
+ useTheme(themeName) {
85
+ this.#themeName = themeName;
86
+ this.emitThemeChange();
87
+ }
88
+ useBreakpoints(breakpoints) {
89
+ this.#breakpoints = breakpoints;
90
+ this.#sortedBreakpointPairs = Object.entries(breakpoints).sort(([, a], [, b]) => (a ?? 0) - (b ?? 0));
91
+ if (!isServer) {
92
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
93
+ }
94
+ }
95
+ useAdaptiveThemes(enable) {
96
+ this.#hasAdaptiveThemes = enable;
97
+ if (!this.#hasAdaptiveThemes || !this.#supportsAutomaticColorScheme) {
98
+ return;
99
+ }
100
+ if (this.#themeName !== this.#colorScheme) {
101
+ this.#themeName = this.#colorScheme;
102
+ this.emitThemeChange();
103
+ }
104
+ }
105
+ addPlugin(pluginName, notify) {
106
+ this.#enabledPlugins = [pluginName].concat(this.#enabledPlugins);
107
+ if (notify) {
108
+ this.emitPluginChange();
109
+ }
110
+ }
111
+ removePlugin(pluginName) {
112
+ this.#enabledPlugins = this.#enabledPlugins.filter(name => name !== pluginName);
113
+ this.emitPluginChange();
114
+ }
115
+ getTheme() {
116
+ if (this.#themes.length === 1) {
117
+ return this.#themes.at(0);
118
+ }
119
+ return this.#themeName;
120
+ }
121
+ setupListeners() {
122
+ window.addEventListener('resize', () => {
123
+ clearTimeout(this.#timerRef);
124
+ this.#timerRef = setTimeout(() => {
125
+ this.#screenWidth = window.innerWidth;
126
+ this.#screenHeight = window.innerHeight;
127
+ this.#breakpoint = this.getBreakpointFromScreenWidth(this.#screenWidth);
128
+ this.emitLayoutChange();
129
+ }, 100);
130
+ });
131
+ window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', event => {
132
+ this.#colorScheme = event.matches ? 'dark' : 'light';
133
+ if (!this.#supportsAutomaticColorScheme || !this.#hasAdaptiveThemes) {
134
+ return;
135
+ }
136
+ if (this.#colorScheme !== this.#themeName) {
137
+ this.#themeName = this.#colorScheme;
138
+ this.emitThemeChange();
139
+ }
140
+ });
141
+ }
142
+ getBreakpointFromScreenWidth(width) {
143
+ const breakpoint = this.#sortedBreakpointPairs.find(([, value], index, otherBreakpoints) => {
144
+ const minVal = value;
145
+ const maxVal = otherBreakpoints[index + 1]?.[1];
146
+ if (!maxVal) {
147
+ return true;
148
+ }
149
+ return width >= minVal && width < maxVal;
150
+ });
151
+ return breakpoint?.at(0);
152
+ }
153
+ getPreferredColorScheme() {
154
+ if (!isServer && window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) {
155
+ return 'dark';
156
+ }
157
+ return 'light';
158
+ }
159
+ emitPluginChange() {
160
+ this.#unistylesEvents.emit('__unistylesOnChange', {
161
+ type: 'plugin'
162
+ });
163
+ }
164
+ emitThemeChange() {
165
+ this.#unistylesEvents.emit('__unistylesOnChange', {
166
+ type: 'theme',
167
+ payload: {
168
+ themeName: this.#themeName
169
+ }
170
+ });
171
+ }
172
+ emitLayoutChange() {
173
+ this.#unistylesEvents.emit('__unistylesOnChange', {
174
+ type: 'layout',
175
+ payload: {
176
+ breakpoint: this.#breakpoint,
177
+ orientation: this.#screenWidth > this.#screenHeight ? 'landscape' : 'portrait',
178
+ screen: {
179
+ width: this.#screenWidth,
180
+ height: this.#screenHeight
181
+ }
182
+ }
183
+ });
184
+ }
185
+ }
186
+ export const UnistylesModule = new UnistylesBridgeWeb();
3
187
  //# sourceMappingURL=UnistylesModule.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","normalizeWebStylesPlugin","isServer","UnistylesBridgeWeb","timerRef","undefined","hasAdaptiveThemes","supportsAutomaticColorScheme","screenWidth","window","innerWidth","screenHeight","innerHeight","themes","breakpoints","colorScheme","getPreferredColorScheme","themeName","enabledPlugins","name","unistylesEvents","Unistyles","sortedBreakpointPairs","breakpoint","constructor","setupListeners","install","globalThis","__UNISTYLES__","Proxy","get","_target","prop","getTheme","useTheme","useBreakpoints","enable","useAdaptiveThemes","pluginName","notify","addPlugin","removePlugin","Reflect","set","target","newValue","receiver","includes","emitThemeChange","Object","entries","sort","a","b","getBreakpointFromScreenWidth","concat","emitPluginChange","filter","length","at","addEventListener","clearTimeout","setTimeout","emitLayoutChange","matchMedia","event","matches","width","find","value","index","otherBreakpoints","minVal","maxVal","emit","type","payload","orientation","screen","height","UnistylesModule"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAGhE,SAASC,wBAAwB,QAAQ,YAAY;AACrD,SAASC,QAAQ,QAAQ,WAAW;AAEpC,OAAO,MAAMC,kBAAkB,CAAC;EAC5B,CAACC,QAAQ,GAAmCC,SAAS;EACrD,CAACC,iBAAiB,GAAY,KAAK;EACnC,CAACC,4BAA4B,GAAG,KAAK;EACrC,CAACC,WAAW,GAAGN,QAAQ,GAAGG,SAAS,GAAGI,MAAM,CAACC,UAAU;EACvD,CAACC,YAAY,GAAGT,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C9CC,IAAI,EAAE,QAAQ;MACdC,OAAO,EAAE;QACLrD,UAAU,EAAE,IAAI,CAAC,CAACA,UAAU;QAC5BsD,WAAW,EAAG,IAAI,CAAC,CAACrE,WAAW,GAAe,IAAI,CAAC,CAACG,YAAuB,GACrE,WAAW,GACX,UAAU;QAChBmE,MAAM,EAAE;UACJX,KAAK,EAAE,IAAI,CAAC,CAAC3D,WAAW;UACxBuE,MAAM,EAAE,IAAI,CAAC,CAACpE;QAClB;MACJ;IACJ,CAAC,CAAC;EACN;AACJ;AAEA,OAAO,MAAMqE,eAAe,GAAG,IAAI7E,kBAAkB,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { NativeModules } from 'react-native';
2
+ export const UnistylesModule = NativeModules?.Unistyles;
3
+ //# sourceMappingURL=UnistylesModule.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../../src","sources":["core/UnistylesModule.native.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
@@ -1,2 +1,37 @@
1
- export const useCSS = _stylesheet => {};
1
+ import { useInsertionEffect, useRef } from 'react';
2
+ import { unistyles } from '../core';
3
+ import { generateReactNativeWebId } from '../utils';
4
+ export const useCSS = stylesheet => {
5
+ const insertedIds = useRef([]);
6
+ useInsertionEffect(() => {
7
+ if (!unistyles.registry.config.experimentalCSSMediaQueries) {
8
+ return;
9
+ }
10
+ Object.entries(stylesheet).forEach(([_key, value]) => {
11
+ Object.entries(value).forEach(([prop, val]) => {
12
+ if (!val.toString().includes('@media')) {
13
+ return;
14
+ }
15
+ const id = generateReactNativeWebId(prop, '""');
16
+ if (insertedIds.current.includes(id)) {
17
+ return;
18
+ }
19
+ const style = document.createElement('style');
20
+ style.id = id;
21
+ style.innerHTML = val;
22
+ document.head.appendChild(style);
23
+ insertedIds.current = [...insertedIds.current, id];
24
+ });
25
+ });
26
+ return () => {
27
+ insertedIds.current.forEach(id => {
28
+ const style = document.getElementById(id);
29
+ if (style) {
30
+ style.remove();
31
+ }
32
+ });
33
+ insertedIds.current = [];
34
+ };
35
+ }, [stylesheet]);
36
+ };
2
37
  //# sourceMappingURL=useCSS.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["useCSS","_stylesheet"],"sourceRoot":"../../../src","sources":["hooks/useCSS.ts"],"mappings":"AAEA,OAAO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC"}
1
+ {"version":3,"names":["useInsertionEffect","useRef","unistyles","generateReactNativeWebId","useCSS","stylesheet","insertedIds","registry","config","experimentalCSSMediaQueries","Object","entries","forEach","_key","value","prop","val","toString","includes","id","current","style","document","createElement","innerHTML","head","appendChild","getElementById","remove"],"sourceRoot":"../../../src","sources":["hooks/useCSS.ts"],"mappings":"AAAA,SAASA,kBAAkB,EAAEC,MAAM,QAAQ,OAAO;AAClD,SAASC,SAAS,QAAQ,SAAS;AAEnC,SAASC,wBAAwB,QAAQ,UAAU;AAEnD,OAAO,MAAMC,MAAM,GAAOC,UAAoC,IAAK;EAC/D,MAAMC,WAAW,GAAGL,MAAM,CAAgB,EAAE,CAAC;EAE7CD,kBAAkB,CAAC,MAAM;IACrB,IAAI,CAACE,SAAS,CAACK,QAAQ,CAACC,MAAM,CAACC,2BAA2B,EAAE;MACxD;IACJ;IAEAC,MAAM,CACDC,OAAO,CAACN,UAAU,CAAC,CACnBO,OAAO,CAAC,CAAC,CAACC,IAAI,EAAEC,KAAK,CAAC,KAAK;MACxBJ,MAAM,CAACC,OAAO,CAACG,KAAM,CAAC,CACjBF,OAAO,CAAC,CAAC,CAACG,IAAI,EAAEC,GAAG,CAAC,KAAK;QACtB,IAAI,CAACA,GAAG,CAACC,QAAQ,CAAC,CAAC,CAACC,QAAQ,CAAC,QAAQ,CAAC,EAAE;UACpC;QACJ;QAEA,MAAMC,EAAE,GAAGhB,wBAAwB,CAACY,IAAI,EAAE,IAAI,CAAC;QAE/C,IAAIT,WAAW,CAACc,OAAO,CAACF,QAAQ,CAACC,EAAE,CAAC,EAAE;UAClC;QACJ;QAEA,MAAME,KAAK,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;QAE7CF,KAAK,CAACF,EAAE,GAAGA,EAAE;QACbE,KAAK,CAACG,SAAS,GAAGR,GAAG;QAErBM,QAAQ,CAACG,IAAI,CAACC,WAAW,CAACL,KAAK,CAAC;QAChCf,WAAW,CAACc,OAAO,GAAG,CAAC,GAAGd,WAAW,CAACc,OAAO,EAAED,EAAE,CAAC;MACtD,CAAC,CAAC;IACV,CAAC,CAAC;IAEN,OAAO,MAAM;MACTb,WAAW,CAACc,OAAO,CAACR,OAAO,CAACO,EAAE,IAAI;QAC9B,MAAME,KAAK,GAAGC,QAAQ,CAACK,cAAc,CAACR,EAAE,CAAC;QAEzC,IAAIE,KAAK,EAAE;UACPA,KAAK,CAACO,MAAM,CAAC,CAAC;QAClB;MACJ,CAAC,CAAC;MAEFtB,WAAW,CAACc,OAAO,GAAG,EAAE;IAC5B,CAAC;EACL,CAAC,EAAE,CAACf,UAAU,CAAC,CAAC;AACpB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export const useCSS = _stylesheet => {};
2
+ //# sourceMappingURL=useCSS.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useCSS","_stylesheet"],"sourceRoot":"../../../src","sources":["hooks/useCSS.native.ts"],"mappings":"AAEA,OAAO,MAAMA,MAAM,GAAOC,WAAqC,IAAW,CAAC,CAAC"}
@@ -1,8 +1,7 @@
1
1
  // based on react-native-web normalizer
2
2
  // https://github.com/necolas/react-native-web
3
3
  import normalizeColors from '@react-native/normalize-colors';
4
- export const normalizeColor = function (color) {
5
- let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
4
+ export const normalizeColor = (color, opacity = 1) => {
6
5
  // If the opacity is 1 there's no need to normalize the color
7
6
  if (opacity === 1) {
8
7
  return color;
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeColors","normalizeColor","color","opacity","arguments","length","undefined","integer","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["normalizer/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;EAC7D;EACA,IAAID,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAMK,OAAO,GAAGP,eAAe,CAACE,KAAK,CAAqB;;EAE1D;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMM,GAAG,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACH,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACM,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGN,GAAG,CACnCO,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GAAG,IAAI,CAACC,KAAK,CAACD,GAAG,CAAC,CAAC;IAE/B,OAAQ,QAAOT,CAAE,IAAGC,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,YAAY,CAAC;EAClD,MAAMvC,KAAK,GAAGD,cAAc,CAACqC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGlC,KAAM,EAAC;AACrD,CAAC;AAED,MAAMwC,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D3B,GAAG,CAAC4B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOnB,SAAS;EACpB;EAEA,MAAMiB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmBwB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEtB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDJ,MAAM,CAAC6B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
1
+ {"version":3,"names":["normalizeColors","normalizeColor","color","opacity","integer","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","undefined","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["normalizer/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,cAAc,GAA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ACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmByB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEvB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDJ,MAAM,CAAC8B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCvB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -18,8 +18,7 @@ export const useStyles = (stylesheet, variantsMap) => {
18
18
  } = useUnistyles();
19
19
  const variants = useVariants(variantsMap);
20
20
  const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet, layout]);
21
- const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles || {}).reduce((acc, _ref) => {
22
- let [key, value] = _ref;
21
+ const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles || {}).reduce((acc, [key, value]) => {
23
22
  if (typeof value === 'function') {
24
23
  return {
25
24
  ...acc,
@@ -1 +1 @@
1
- {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","withPlugins","useCSS","useUnistyles","useVariants","unistyles","isWeb","useStyles","stylesheet","variantsMap","theme","layout","plugins","variants","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_ref","key","value","create","registry","config","experimentalCSSMediaQueries","breakpoint","styles"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,EAAEC,WAAW,QAAQ,SAAS;AAClE,SAASC,MAAM,EAAEC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAG3D,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,KAAK,QAAQ,UAAU;AAQhC;AACA;AACA;AACA;AACA;AACA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+ {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","withPlugins","useCSS","useUnistyles","useVariants","unistyles","isWeb","useStyles","stylesheet","variantsMap","theme","layout","plugins","variants","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","key","value","create","registry","config","experimentalCSSMediaQueries","breakpoint","styles"],"sourceRoot":"../../src","sources":["useStyles.ts"],"mappings":"AAAA,SAASA,OAAO,QAAQ,OAAO;AAC/B,SAASC,UAAU,QAAQ,cAAc;AACzC,SAASC,UAAU,EAAEC,eAAe,EAAEC,WAAW,QAAQ,SAAS;AAClE,SAASC,MAAM,EAAEC,YAAY,EAAEC,WAAW,QAAQ,SAAS;AAG3D,SAASC,SAAS,QAAQ,QAAQ;AAClC,SAASC,KAAK,QAAQ,UAAU;AAQhC;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,SAAS,GAAGA,CACrBC,UAAe,EACfC,WAAoD,KAC7B;EACvB,MAAM;IAAEC,KAAK;IAAEC,MAAM;IAAEC;EAAQ,CAAC,GAAGT,YAAY,CAAC,CAAC;EACjD,MAAMU,QAAQ,GAAGT,WAAW,CAACK,WAAW,CAAC;EACzC,MAAMK,YAAY,GAAGjB,OAAO,CAAC,MAAM,OAAOW,UAAU,KAAK,UAAU,GAC7DA,UAAU,CAACE,KAAK,CAAC,GACjBF,UAAU,EAAE,CAACE,KAAK,EAAEF,UAAU,EAAEG,MAAM,CAAC,CAAC;EAE9C,MAAMI,iBAAiB,GAAGlB,OAAO,CAAC,MAAMmB,MAAM,CACzCC,OAAO,CAACH,YAAY,IAAI,CAAC,CAAC,CAAC,CAC3BI,MAAM,CAAC,CAACC,GAAG,EAAE,CAACC,GAAG,EAAEC,KAAK,CAAC,KAAK;IAC3B,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;MAC7B,OAAO;QACH,GAAGF,GAAG;QACN,CAACC,GAAG,GAAGpB,eAAe,CAACoB,GAAG,EAAEC,KAAK;MACrC,CAAC;IACL;IAEA,OAAOvB,UAAU,CAACwB,MAAM,CAAC;MACrB,GAAGH,GAAG;MACN,CAACC,GAAG,GAAGnB,WAAW,CAACmB,GAAG,EAAErB,UAAU,CAC9BsB,KAAK,EACLR,QAAQ,EACR,CAACP,KAAK,IAAI,CAACD,SAAS,CAACkB,QAAQ,CAACC,MAAM,CAACC,2BAA2B,CACpE;IACJ,CAAC,CAAC;EACN,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAACX,YAAY,EAAED,QAAQ,EAAED,OAAO,CAC5C,CAAC;EAEDV,MAAM,CAACa,iBAA8C,CAAC;EAEtD,OAAO;IACHL,KAAK;IACLgB,UAAU,EAAEf,MAAM,CAACe,UAAU;IAC7BC,MAAM,EAAEZ;EACZ,CAAC;AACL,CAAC"}
@@ -19,17 +19,8 @@ export const getValueForBreakpoint = value => {
19
19
  return directBreakpoint;
20
20
  }
21
21
  const breakpointPairs = unistyles.registry.sortedBreakpointPairs;
22
- const currentBreakpointIndex = breakpointPairs.findIndex(_ref => {
23
- let [key] = _ref;
24
- return key === breakpoint;
25
- });
26
- const availableBreakpoints = breakpointPairs.filter((_ref2, index) => {
27
- let [key] = _ref2;
28
- return index < currentBreakpointIndex && key in value;
29
- }).map(_ref3 => {
30
- let [key] = _ref3;
31
- return key;
32
- });
22
+ const currentBreakpointIndex = breakpointPairs.findIndex(([key]) => key === breakpoint);
23
+ const availableBreakpoints = breakpointPairs.filter(([key], index) => index < currentBreakpointIndex && key in value).map(([key]) => key);
33
24
  return value[availableBreakpoints[availableBreakpoints.length - 1]];
34
25
  };
35
26
  //# sourceMappingURL=breakpoints.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","ScreenOrientation","isMobile","getKeyForUnistylesMediaQuery","getValueForBreakpoint","value","customMediaQueryKey","Object","entries","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","_ref","key","availableBreakpoints","filter","_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AC,CAAAC,KAAA,EAAQC,KAAK;IAAA,IAAZ,CAACJ,GAAG,CAAC,GAAAG,KAAA;IAAA,OAAYC,KAAK,GAAGP,sBAAsB,IAAIG,GAAG,IAAIpB,KAAK;EAAA,EAAC,CACxEyB,GAAG,CAACC,KAAA;IAAA,IAAC,CAACN,GAAG,CAAC,GAAAM,KAAA;IAAA,OAAKN,GAAG;EAAA,EAAC;EAExB,OAAOpB,KAAK,CAACqB,oBAAoB,CAACA,oBAAoB,CAACZ,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC"}
1
+ {"version":3,"names":["unistyles","ScreenOrientation","isMobile","getKeyForUnistylesMediaQuery","getValueForBreakpoint","value","customMediaQueryKey","Object","entries","runtime","screen","hasBreakpoints","registry","sortedBreakpointPairs","length","Landscape","Portrait","orientation","breakpoint","undefined","directBreakpoint","breakpointPairs","currentBreakpointIndex","findIndex","key","availableBreakpoints","filter","index","map"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,SAAS;AAGnC,SAASC,iBAAiB,EAAEC,QAAQ,QAAQ,WAAW;AACvD,SAASC,4BAA4B,QAAQ,YAAY;AAEzD,OAAO,MAAMC,qBAAqB,GAAIC,KAA8B,IAAwB;EACxF,MAAMC,mBAAmB,GAAGH,4BAA4B,CACpDI,MAAM,CAACC,OAAO,CAACH,KAAK,CAAC,EACrBL,SAAS,CAACS,OAAO,CAACC,MACtB,CAAuB;EAEvB,IAAIJ,mBAAmB,EAAE;IACrB,OAAOD,KAAK,CAACC,mBAAmB,CAAC;EACrC;EAEA,MAAMK,cAAc,GAAGX,SAAS,CAACY,QAAQ,CAACC,qBAAqB,CAACC,MAAM,GAAG,CAAC;EAE1E,IAAI,CAACH,cAAc,IAAIT,QAAQ,KAAKD,iBAAiB,CAACc,SAAS,IAAIV,KAAK,IAAIJ,iBAAiB,CAACe,QAAQ,IAAIX,KAAK,CAAC,EAAE;IAC9G,OAAOA,KAAK,CAACL,SAAS,CAACS,OAAO,CAACQ,WAAW,CAAC;EAC/C;EAEA,MAAMC,UAAU,GAAGlB,SAAS,CAACS,OAAO,CAACS,UAAU;EAE/C,IAAI,CAACA,UAAU,EAAE;IACb,OAAOC,SAAS;EACpB;EAEA,MAAMC,gBAAgB,GAAGf,KAAK,CAACa,UAAU,CAAC;EAE1C,IAAIE,gBAAgB,IAAKF,UAAU,IAAIb,KAAM,EAAE;IAC3C,OAAOe,gBAAgB;EAC3B;EAEA,MAAMC,eAAe,GAAGrB,SAAS,CAACY,QAAQ,CAACC,qBAAqB;EAChE,MAAMS,sBAAsB,GAAGD,eAAe,CACzCE,SAAS,CAAC,CAAC,CAACC,GAAG,CAAC,KAAKA,GAAG,KAAKN,UAAU,CAAC;EAE7C,MAAMO,oBAAoB,GAAGJ,eAAe,CACvCK,MAAM,CAAC,CAAC,CAACF,GAAG,CAAC,EAAEG,KAAK,KAAKA,KAAK,GAAGL,sBAAsB,IAAIE,GAAG,IAAInB,KAAK,CAAC,CACxEuB,GAAG,CAAC,CAAC,CAACJ,GAAG,CAAC,KAAKA,GAAG,CAAC;EAExB,OAAOnB,KAAK,CAACoB,oBAAoB,CAACA,oBAAoB,CAACX,MAAM,GAAG,CAAC,CAAC,CAAwC;AAC9G,CAAC"}
@@ -2,11 +2,7 @@ import { normalizeColor } from '../normalizer';
2
2
  import { isUnistylesMq, isValidMq, parseMq } from './mqParser';
3
3
  import { generateReactNativeWebId } from './generateId';
4
4
  export const createMediaQueryForStyles = (styles, runtime) => {
5
- const withMediaQueries = Object.entries(styles).filter(_ref => {
6
- let [, value] = _ref;
7
- return typeof value === 'object';
8
- }).reduce((acc, _ref2) => {
9
- let [prop, value] = _ref2;
5
+ const withMediaQueries = Object.entries(styles).filter(([, value]) => typeof value === 'object').reduce((acc, [prop, value]) => {
10
6
  const objectKeys = Object.keys(value);
11
7
  const mediaQueries = objectKeys.filter(key => isUnistylesMq(key));
12
8
  const breakpoints = objectKeys.filter(key => runtime.breakpoints[key]);
@@ -47,8 +43,7 @@ const getMaxHeightMediaQuery = height => {
47
43
  }
48
44
  return `and (max-height: ${height.to}px)`;
49
45
  };
50
- const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc, _ref3) => {
51
- let [key, value] = _ref3;
46
+ const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).reduce((acc, [key, value]) => {
52
47
  const result = parseMq(key);
53
48
  if (!isValidMq(result)) {
54
49
  return acc;
@@ -85,8 +80,7 @@ const getMediaQueriesFromMQ = (prop, value, className) => Object.entries(value).
85
80
  }
86
81
  return acc;
87
82
  }, '');
88
- const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc, _ref4) => {
89
- let [key, value] = _ref4;
83
+ const getBreakpointsStyles = (prop, value, runtime, className) => Object.entries(value).reduce((acc, [key, value]) => {
90
84
  const breakpoint = runtime.breakpoints[key];
91
85
  if (breakpoint === undefined) {
92
86
  return acc;