react-native-unistyles 2.0.0-beta.7 → 2.0.0-rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. package/README.md +22 -35
  2. package/lib/commonjs/core/UnistyleRegistry.js +15 -25
  3. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  4. package/lib/commonjs/core/UnistylesModule.js +187 -2
  5. package/lib/commonjs/core/UnistylesModule.js.map +1 -1
  6. package/lib/commonjs/core/UnistylesModule.native.js +9 -0
  7. package/lib/commonjs/core/UnistylesModule.native.js.map +1 -0
  8. package/lib/commonjs/core/UnistylesRuntime.js +64 -0
  9. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  10. package/lib/commonjs/createStyleSheet.js +5 -0
  11. package/lib/commonjs/createStyleSheet.js.map +1 -1
  12. package/lib/commonjs/hooks/useCSS.js +36 -1
  13. package/lib/commonjs/hooks/useCSS.js.map +1 -1
  14. package/lib/commonjs/hooks/useCSS.native.js +9 -0
  15. package/lib/commonjs/hooks/useCSS.native.js.map +1 -0
  16. package/lib/commonjs/index.js +16 -0
  17. package/lib/commonjs/index.js.map +1 -1
  18. package/lib/commonjs/normalizer/normalizer.js +1 -2
  19. package/lib/commonjs/normalizer/normalizer.js.map +1 -1
  20. package/lib/commonjs/useStyles.js +7 -2
  21. package/lib/commonjs/useStyles.js.map +1 -1
  22. package/lib/commonjs/utils/breakpoints.js +2 -11
  23. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  24. package/lib/commonjs/utils/cssMediaQuery.js +3 -9
  25. package/lib/commonjs/utils/cssMediaQuery.js.map +1 -1
  26. package/lib/commonjs/utils/mq.js +17 -36
  27. package/lib/commonjs/utils/mq.js.map +1 -1
  28. package/lib/commonjs/utils/mqParser.js +1 -2
  29. package/lib/commonjs/utils/mqParser.js.map +1 -1
  30. package/lib/commonjs/utils/styles.js +34 -39
  31. package/lib/commonjs/utils/styles.js.map +1 -1
  32. package/lib/module/core/UnistyleRegistry.js +15 -25
  33. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  34. package/lib/module/core/UnistylesModule.js +186 -2
  35. package/lib/module/core/UnistylesModule.js.map +1 -1
  36. package/lib/module/core/UnistylesModule.native.js +3 -0
  37. package/lib/module/core/UnistylesModule.native.js.map +1 -0
  38. package/lib/module/core/UnistylesRuntime.js +64 -0
  39. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  40. package/lib/module/createStyleSheet.js +5 -0
  41. package/lib/module/createStyleSheet.js.map +1 -1
  42. package/lib/module/hooks/useCSS.js +36 -1
  43. package/lib/module/hooks/useCSS.js.map +1 -1
  44. package/lib/module/hooks/useCSS.native.js +2 -0
  45. package/lib/module/hooks/useCSS.native.js.map +1 -0
  46. package/lib/module/index.js +17 -0
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/normalizer/normalizer.js +1 -2
  49. package/lib/module/normalizer/normalizer.js.map +1 -1
  50. package/lib/module/useStyles.js +7 -2
  51. package/lib/module/useStyles.js.map +1 -1
  52. package/lib/module/utils/breakpoints.js +2 -11
  53. package/lib/module/utils/breakpoints.js.map +1 -1
  54. package/lib/module/utils/cssMediaQuery.js +3 -9
  55. package/lib/module/utils/cssMediaQuery.js.map +1 -1
  56. package/lib/module/utils/mq.js +17 -36
  57. package/lib/module/utils/mq.js.map +1 -1
  58. package/lib/module/utils/mqParser.js +1 -2
  59. package/lib/module/utils/mqParser.js.map +1 -1
  60. package/lib/module/utils/styles.js +34 -39
  61. package/lib/module/utils/styles.js.map +1 -1
  62. package/lib/typescript/src/core/UnistylesModule.d.ts +17 -4
  63. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -1
  64. package/lib/typescript/src/core/UnistylesModule.native.d.ts +6 -0
  65. package/lib/typescript/src/core/UnistylesModule.native.d.ts.map +1 -0
  66. package/lib/typescript/src/core/UnistylesRuntime.d.ts +52 -0
  67. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  68. package/lib/typescript/src/createStyleSheet.d.ts +5 -0
  69. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -1
  70. package/lib/typescript/src/hooks/useCSS.d.ts +1 -1
  71. package/lib/typescript/src/hooks/useCSS.d.ts.map +1 -1
  72. package/lib/typescript/src/hooks/useCSS.native.d.ts +3 -0
  73. package/lib/typescript/src/hooks/useCSS.native.d.ts.map +1 -0
  74. package/lib/typescript/src/index.d.ts +16 -0
  75. package/lib/typescript/src/index.d.ts.map +1 -1
  76. package/lib/typescript/src/useStyles.d.ts +6 -0
  77. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  78. package/lib/typescript/src/utils/mq.d.ts +4 -0
  79. package/lib/typescript/src/utils/mq.d.ts.map +1 -1
  80. package/package.json +14 -16
  81. package/src/core/UnistylesModule.native.ts +7 -0
  82. package/src/core/UnistylesModule.ts +224 -4
  83. package/src/core/UnistylesRuntime.ts +52 -0
  84. package/src/createStyleSheet.ts +5 -0
  85. package/src/hooks/useCSS.native.ts +3 -0
  86. package/src/hooks/useCSS.ts +49 -1
  87. package/src/index.ts +16 -0
  88. package/src/useStyles.ts +6 -0
  89. package/src/utils/mq.ts +4 -0
  90. package/lib/commonjs/core/UnistylesModule.web.js +0 -199
  91. package/lib/commonjs/core/UnistylesModule.web.js.map +0 -1
  92. package/lib/commonjs/hooks/useCSS.web.js +0 -46
  93. package/lib/commonjs/hooks/useCSS.web.js.map +0 -1
  94. package/lib/module/core/UnistylesModule.web.js +0 -192
  95. package/lib/module/core/UnistylesModule.web.js.map +0 -1
  96. package/lib/module/hooks/useCSS.web.js +0 -39
  97. package/lib/module/hooks/useCSS.web.js.map +0 -1
  98. package/lib/typescript/src/core/UnistylesModule.web.d.ts +0 -19
  99. package/lib/typescript/src/core/UnistylesModule.web.d.ts.map +0 -1
  100. package/lib/typescript/src/hooks/useCSS.web.d.ts +0 -3
  101. package/lib/typescript/src/hooks/useCSS.web.d.ts.map +0 -1
  102. package/src/core/UnistylesModule.web.ts +0 -227
  103. package/src/hooks/useCSS.web.ts +0 -51
@@ -8,44 +8,25 @@ const getMQValue = value => {
8
8
  }
9
9
  return unistyles.registry.breakpoints[value] ?? 0;
10
10
  };
11
+
12
+ /**
13
+ * Utility to create cross-platform media queries
14
+ * @returns - JavaScript symbol to be used in your stylesheet
15
+ */
11
16
  export const mq = {
12
17
  only: {
13
- width: function () {
14
- let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
15
- let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
16
- return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`;
17
- },
18
- height: function () {
19
- let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
20
- let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
21
- return `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
22
- }
23
- },
24
- width: function () {
25
- let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
26
- let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
27
- return {
28
- and: {
29
- height: function () {
30
- let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
31
- let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
32
- return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
33
- }
34
- }
35
- };
18
+ width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
19
+ height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
36
20
  },
37
- height: function () {
38
- let hMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
39
- let hMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
40
- return {
41
- and: {
42
- width: function () {
43
- let wMin = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
44
- let wMax = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Infinity;
45
- return `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`;
46
- }
47
- }
48
- };
49
- }
21
+ width: (wMin = 0, wMax = Infinity) => ({
22
+ and: {
23
+ height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
24
+ }
25
+ }),
26
+ height: (hMin = 0, hMax = Infinity) => ({
27
+ and: {
28
+ width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
29
+ }
30
+ })
50
31
  };
51
32
  //# sourceMappingURL=mq.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["unistyles","getMQValue","value","registry","breakpoints","mq","only","width","wMin","arguments","length","undefined","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":"AAEA,SAASA,SAAS,QAAQ,SAAS;AAqBnC,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOF,SAAS,CAACG,QAAQ,CAACC,WAAW,CAACF,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;AAED,OAAO,MAAMG,EAAa,GAAG;EACzBC,IAAI,EAAE;IACFC,KAAK,EAAE,SAAAA,CAAA;MAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;MAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;MAAA,OAAO,MAAKZ,UAAU,CAACO,IAAI,CAAE,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AA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;IAAA,OAAM;MAChEI,GAAG,EAAE;QACDV,KAAK,EAAE,SAAAA,CAAA;UAAA,IAACC,IAAuB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC;UAAA,IAAEG,IAAa,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAGI,QAAQ;UAAA,OACvD,MAAKZ,UAAU,CAACO,IAAI,CAAE,KAAIP,UAAU,CAACW,IAAI,CAAE,OAAMX,UAAU,CAACc,IAAI,CAAE,KAAId,UAAU,CAACe,IAAI,CAAE,GAAE;QAAA;MACnG;IACJ,CAAC;EAAA;AACL,CAAC"}
1
+ {"version":3,"names":["unistyles","getMQValue","value","registry","breakpoints","mq","only","width","wMin","wMax","Infinity","height","hMin","hMax","and"],"sourceRoot":"../../../src","sources":["utils/mq.ts"],"mappings":"AAEA,SAASA,SAAS,QAAQ,SAAS;AAqBnC,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,OAAOF,SAAS,CAACG,QAAQ,CAACC,WAAW,CAACF,KAAK,CAAC,IAAI,CAAC;AACrD,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAMG,EAAa,GAAG;EACzBC,IAAI,EAAE;IACFC,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KAAO,MAAKT,UAAU,CAACO,IAAI,CAAE,KAAIP,UAAU,CAACQ,IAAI,CAAE,GAAwB;IACvIE,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KAAO,MAAKT,UAAU,CAACW,IAAI,CAAE,KAAIX,UAAU,CAACY,IAAI,CAAE;EACpH,CAAC;EACDN,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,MAAM;IAC/DI,GAAG,EAAE;MACDH,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KACxD,MAAKT,UAAU,CAACO,IAAI,CAAE,KAAIP,UAAU,CAACQ,IAAI,CAAE,OAAMR,UAAU,CAACW,IAAI,CAAE,KAAIX,UAAU,CAACY,IAAI,CAAE;IACjG;EACJ,CAAC,CAAC;EACFF,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,MAAM;IAChEI,GAAG,EAAE;MACDP,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KACvD,MAAKT,UAAU,CAACO,IAAI,CAAE,KAAIP,UAAU,CAACQ,IAAI,CAAE,OAAMR,UAAU,CAACW,IAAI,CAAE,KAAIX,UAAU,CAACY,IAAI,CAAE;IACjG;EACJ,CAAC;AACL,CAAC"}
@@ -63,8 +63,7 @@ const isWithinTheHeight = (height, screenHeight) => {
63
63
  return screenHeight >= from && screenHeight <= to;
64
64
  };
65
65
  export const getKeyForUnistylesMediaQuery = (mediaQueries, screenSize) => {
66
- const mq = mediaQueries.find(_ref => {
67
- let [key] = _ref;
66
+ const mq = mediaQueries.find(([key]) => {
68
67
  if (!isUnistylesMq(key)) {
69
68
  return false;
70
69
  }
@@ -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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AEA,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"}
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","key","at"],"sourceRoot":"../../../src","sources":["utils/mqParser.ts"],"mappings":"AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAYpE,OAAO,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,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EAE/C,OAAOmB,WAAW,IAAIZ,IAAI,IAAIY,WAAW,IAAIV,EAAE;AACnD,CAAC;AAED,MAAMS,iBAAiB,GAAGA,CAACd,MAAmC,EAAEgB,YAAoB,KAAc;EAC9F,MAAM;IAAEb,IAAI;IAAEE;EAAG,CAAC,GAAGL,MAA2B;EAEhD,OAAOgB,YAAY,IAAIb,IAAI,IAAIa,YAAY,IAAIX,EAAE;AACrD,CAAC;AAED,OAAO,MAAMY,4BAA4B,GAAGA,CAACC,YAAsC,EAAEN,UAAsB,KAAuB;EAC9H,MAAMjB,EAAE,GAAGuB,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,GAAGhB,OAAO,CAAC0B,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,OAAOjB,EAAE,EAAE0B,EAAE,CAAC,CAAC,CAAC;AACpB,CAAC"}
@@ -10,50 +10,45 @@ export const isPlatformColor = value => {
10
10
  }
11
11
  return isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object';
12
12
  };
13
- export const parseStyle = function (style) {
14
- let variant = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
15
- let parseMediaQueries = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
16
- return Object.entries(style || {}).reduce((acc, _ref) => {
17
- let [key, value] = _ref;
18
- // nested objects
19
- if (key === 'shadowOffset' || key === 'textShadowOffset') {
20
- acc[key] = parseStyle(value, variant);
21
- return acc;
22
- }
13
+ export const parseStyle = (style, variant = {}, parseMediaQueries = true) => Object.entries(style || {}).reduce((acc, [key, value]) => {
14
+ // nested objects
15
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
16
+ acc[key] = parseStyle(value, variant);
17
+ return acc;
18
+ }
23
19
 
24
- // transforms
25
- if (key === 'transform' && Array.isArray(value)) {
26
- acc[key] = value.map(value => parseStyle(value, variant));
27
- return acc;
28
- }
20
+ // transforms
21
+ if (key === 'transform' && Array.isArray(value)) {
22
+ acc[key] = value.map(value => parseStyle(value, variant));
23
+ return acc;
24
+ }
29
25
 
30
- // values or platform colors
31
- if (typeof value !== 'object' || isPlatformColor(value)) {
32
- acc[key] = value;
33
- return acc;
34
- }
35
- if (key === 'variants') {
36
- return {
26
+ // values or platform colors
27
+ if (typeof value !== 'object' || isPlatformColor(value)) {
28
+ acc[key] = value;
29
+ return acc;
30
+ }
31
+ if (key === 'variants') {
32
+ return {
33
+ ...acc,
34
+ ...Object.keys(value).reduce((acc, key) => ({
37
35
  ...acc,
38
- ...Object.keys(value).reduce((acc, key) => ({
39
- ...acc,
40
- // 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
41
- ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
42
- }), {})
43
- };
44
- }
36
+ // 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
37
+ ...parseStyle(value[key][variant[key] || 'default'] ?? value[key].default ?? {})
38
+ }), {})
39
+ };
40
+ }
45
41
 
46
- // don't parse media queries and breakpoints
47
- if (!parseMediaQueries) {
48
- return {
49
- ...acc,
50
- [key]: value
51
- };
52
- }
42
+ // don't parse media queries and breakpoints
43
+ if (!parseMediaQueries) {
53
44
  return {
54
45
  ...acc,
55
- [key]: getValueForBreakpoint(value)
46
+ [key]: value
56
47
  };
57
- }, {});
58
- };
48
+ }
49
+ return {
50
+ ...acc,
51
+ [key]: getValueForBreakpoint(value)
52
+ };
53
+ }, {});
59
54
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getValueForBreakpoint","isAndroid","isIOS","withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","arguments","length","undefined","parseMediaQueries","Object","entries","reduce","acc","_ref","Array","isArray","map","keys","default"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,SAAS,EAAEC,KAAK,QAAQ,WAAW;AAC5C,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAKT,WAAW,CAACE,GAAG,EAAEQ,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAEF,OAAO,MAAMO,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIb,KAAK,EAAE;IACP,OAAO,UAAU,IAAIa,KAAK,IAAI,OAAOA,KAAK,CAACC,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOf,SAAS,IAAI,gBAAgB,IAAIc,KAAK,IAAI,OAAOA,KAAK,CAACE,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAED,OAAO,MAAMJ,UAAU,GAAG,SAAAA,CACtBK,KAAQ;EAAA,IACRX,OAAyC,GAAAY,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAAA,IAC9CG,iBAAiB,GAAAH,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,IAAI;EAAA,OACpBI,MAAM,CACTC,OAAO,CAACN,KAAK,IAAI,CAAC,CAAC,CAAC,CACpBO,MAAM,CAAC,CAACC,GAAG,EAAAC,IAAA,KAAmB;IAAA,IAAjB,CAAC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AAC,CAAM,CAAC;AAAA"}
1
+ {"version":3,"names":["getValueForBreakpoint","isAndroid","isIOS","withPlugins","proxifyFunction","key","fn","variant","Proxy","apply","target","thisArg","argumentsList","parseStyle","isPlatformColor","value","semantic","resource_paths","style","parseMediaQueries","Object","entries","reduce","acc","Array","isArray","map","keys","default"],"sourceRoot":"../../../src","sources":["utils/styles.ts"],"mappings":"AACA,SAASA,qBAAqB,QAAQ,eAAe;AACrD,SAASC,SAAS,EAAEC,KAAK,QAAQ,WAAW;AAC5C,SAASC,WAAW,QAAQ,eAAe;AAE3C,OAAO,MAAMC,eAAe,GAAGA,CAC3BC,GAAW,EACXC,EAAY,EACZC,OAA0C,KAC/B,IAAIC,KAAK,CAACF,EAAE,EAAE;EACzBG,KAAK,EAAEA,CAACC,MAAM,EAAEC,OAAO,EAAEC,aAAa,KAAKT,WAAW,CAACE,GAAG,EAAEQ,UAAU,CAACH,MAAM,CAACD,KAAK,CAACE,OAAO,EAAEC,aAAa,CAAC,EAAEL,OAAO,CAAC;AACzH,CAAC,CAAC;AAEF,OAAO,MAAMO,eAAe,GAAkBC,KAAQ,IAAc;EAChE,IAAIb,KAAK,EAAE;IACP,OAAO,UAAU,IAAIa,KAAK,IAAI,OAAOA,KAAK,CAACC,QAAQ,KAAK,QAAQ;EACpE;EAEA,OAAOf,SAAS,IAAI,gBAAgB,IAAIc,KAAK,IAAI,OAAOA,KAAK,CAACE,cAAc,KAAK,QAAQ;AAC7F,CAAC;AAED,OAAO,MAAMJ,UAAU,GAAGA,CACtBK,KAAQ,EACRX,OAAyC,GAAG,CAAC,CAAC,EAC9CY,iBAAiB,GAAG,IAAI,KACpBC,MAAM,CACTC,OAAO,CAACH,KAAK,IAAI,CAAC,CAAC,CAAC,CACpBI,MAAM,CAAC,CAACC,GAAG,EAAE,CAAClB,GAAG,EAAEU,KAAK,CAAC,KAAK;EAC3B;EACA,IAAIV,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAM,kBAAkB,EAAE;IACvDkB,GAAG,CAAClB,GAAG,CAAC,GAAGQ,UAAU,CAACE,KAAK,EAAER,OAAO,CAAC;IAErC,OAAOgB,GAAG;EACd;;EAEA;EACA,IAAIlB,GAAG,KAAK,WAAW,IAAImB,KAAK,CAACC,OAAO,CAACV,KAAK,CAAC,EAAE;IAC7CQ,GAAG,CAAClB,GAAG,CAAC,GAAGU,KAAK,CAACW,GAAG,CAACX,KAAK,IAAIF,UAAU,CAACE,KAAK,EAAER,OAAO,CAAC,CAAC;IAEzD,OAAOgB,GAAG;EACd;;EAEA;EACA,IAAI,OAAOR,KAAK,KAAK,QAAQ,IAAID,eAAe,CAACC,KAAK,CAAC,EAAE;IACrDQ,GAAG,CAAClB,GAAG,CAAY,GAAGU,KAAK;IAE3B,OAAOQ,GAAG;EACd;EAEA,IAAIlB,GAAG,KAAK,UAAU,EAAE;IACpB,OAAO;MACH,GAAGkB,GAAG;MACN,GAAIH,MAAM,CACLO,IAAI,CAACZ,KAAK,CAAC,CACXO,MAAM,CAAC,CAACC,GAAG,EAAElB,GAAG,MAAM;QACnB,GAAGkB,GAAG;QACN;QACA,GAAGV,UAAU,CAAEE,KAAK,CAAEV,GAAG,CAAC,CAACE,OAAO,CAACF,GAAG,CAAyB,IAAI,SAAS,CAAC,IAAKU,KAAK,CAAEV,GAAG,CAAC,CAACuB,OAAO,IAAI,CAAC,CAAC;MAC/G,CAAC,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;EACL;;EAEA;EACA,IAAI,CAACT,iBAAiB,EAAE;IACpB,OAAO;MACH,GAAGI,GAAG;MACN,CAAClB,GAAG,GAAGU;IACX,CAAC;EACL;EAEA,OAAO;IACH,GAAGQ,GAAG;IACN,CAAClB,GAAG,GAAGL,qBAAqB,CAACe,KAAgC;EACjE,CAAC;AACL,CAAC,EAAE,CAAC,CAAM,CAAC"}
@@ -1,6 +1,19 @@
1
- type UnistylesNativeModule = {
1
+ export declare class UnistylesBridgeWeb {
2
+ #private;
3
+ constructor();
2
4
  install(): boolean;
3
- };
4
- export declare const UnistylesModule: UnistylesNativeModule;
5
- export {};
5
+ private useTheme;
6
+ private useBreakpoints;
7
+ private useAdaptiveThemes;
8
+ private addPlugin;
9
+ private removePlugin;
10
+ private getTheme;
11
+ private setupListeners;
12
+ private getBreakpointFromScreenWidth;
13
+ private getPreferredColorScheme;
14
+ private emitPluginChange;
15
+ private emitThemeChange;
16
+ private emitLayoutChange;
17
+ }
18
+ export declare const UnistylesModule: UnistylesBridgeWeb;
6
19
  //# sourceMappingURL=UnistylesModule.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG;IACzB,OAAO,IAAI,OAAO,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,uBAAoD,CAAA"}
1
+ {"version":3,"file":"UnistylesModule.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.ts"],"names":[],"mappings":"AAMA,qBAAa,kBAAkB;;;IAuBpB,OAAO;IA6Dd,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,iBAAiB;IAazB,OAAO,CAAC,SAAS;IAQjB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,QAAQ;IAShB,OAAO,CAAC,cAAc;IA6BtB,OAAO,CAAC,4BAA4B;IAgBpC,OAAO,CAAC,uBAAuB;IAQ/B,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,eAAe;IASvB,OAAO,CAAC,gBAAgB;CAe3B;AAED,eAAO,MAAM,eAAe,oBAA2B,CAAA"}
@@ -0,0 +1,6 @@
1
+ type UnistylesNativeModule = {
2
+ install(): boolean;
3
+ };
4
+ export declare const UnistylesModule: UnistylesNativeModule;
5
+ export {};
6
+ //# sourceMappingURL=UnistylesModule.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnistylesModule.native.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesModule.native.ts"],"names":[],"mappings":"AAEA,KAAK,qBAAqB,GAAG;IACzB,OAAO,IAAI,OAAO,CAAA;CACrB,CAAA;AAED,eAAO,MAAM,eAAe,uBAAoD,CAAA"}
@@ -1,24 +1,76 @@
1
1
  import type { UnistylesBridge, UnistylesPlugin } from '../types';
2
2
  import type { UnistylesThemes } from '../global';
3
3
  import type { UnistyleRegistry } from './UnistyleRegistry';
4
+ /**
5
+ * Utility to interact with the Unistyles during runtime
6
+ */
4
7
  export declare class UnistylesRuntime {
5
8
  private unistylesBridge;
6
9
  private unistylesRegistry;
7
10
  constructor(unistylesBridge: UnistylesBridge, unistylesRegistry: UnistyleRegistry);
11
+ /**
12
+ * Get the current color scheme
13
+ * @returns - The current color scheme
14
+ */
8
15
  get colorScheme(): import("../types").ColorSchemeName;
16
+ /**
17
+ * Get info about adaptive themes
18
+ * @returns - boolean indicating if the adaptive themes are enabled
19
+ */
9
20
  get hasAdaptiveThemes(): boolean;
21
+ /**
22
+ * Get the current theme name
23
+ * @returns - The current theme name
24
+ */
10
25
  get themeName(): never;
26
+ /**
27
+ * Get the current breakpoint based on device size
28
+ * @returns - The current breakpoint
29
+ */
11
30
  get breakpoint(): keyof import("../global").UnistylesBreakpoints;
31
+ /**
32
+ * Get registered breakpoints with UnitylesRegistry
33
+ * @returns - The registered breakpoints
34
+ */
12
35
  get breakpoints(): import("../global").UnistylesBreakpoints;
36
+ /**
37
+ * Get the names of currently enabled plugins
38
+ * @returns - The names of currently enabled plugins
39
+ */
13
40
  get enabledPlugins(): string[];
41
+ /**
42
+ * Get the screen size
43
+ * @returns - The screen size { width, height }
44
+ */
14
45
  get screen(): {
15
46
  width: number;
16
47
  height: number;
17
48
  };
49
+ /**
50
+ * Get the screen orientation
51
+ * @returns - The screen orientation
52
+ */
18
53
  get orientation(): "landscape" | "portrait";
54
+ /**
55
+ * Switch to a different theme
56
+ * @param name - The name of the theme to switch to
57
+ * @returns - boolean indicating if the theme was switched
58
+ */
19
59
  setTheme: (name: keyof UnistylesThemes) => true | undefined;
60
+ /**
61
+ * Enable or disable adaptive themes
62
+ * @param enable - boolean indicating if adaptive themes should be enabled
63
+ */
20
64
  setAdaptiveThemes: (enable: boolean) => void;
65
+ /**
66
+ * Enable a plugin
67
+ * @param plugin - Plugin that conforms to UnistylesPlugin interface
68
+ */
21
69
  addPlugin: (plugin: UnistylesPlugin) => void;
70
+ /**
71
+ * Disable a plugin
72
+ * @param plugin - Plugin that conforms to UnistylesPlugin interface
73
+ */
22
74
  removePlugin: (plugin: UnistylesPlugin) => void;
23
75
  }
24
76
  //# sourceMappingURL=UnistylesRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG,IAAW,WAAW,uCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,SAAS,UAEnB;IAED,IAAW,UAAU,mDAEpB;IAED,IAAW,WAAW,6CAErB;IAED,IAAW,cAAc,aAExB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,6BAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAEM,iBAAiB,WAAY,OAAO,UAE1C;IAEM,SAAS,WAAY,eAAe,UAE1C;IAEM,YAAY,WAAY,eAAe,UAE7C;CACJ"}
1
+ {"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAE1D;;GAEG;AACH,qBAAa,gBAAgB;IACb,OAAO,CAAC,eAAe;IAAmB,OAAO,CAAC,iBAAiB;gBAA3D,eAAe,EAAE,eAAe,EAAU,iBAAiB,EAAE,gBAAgB;IAEjG;;;OAGG;IACH,IAAW,WAAW,uCAErB;IAED;;;OAGG;IACH,IAAW,iBAAiB,YAE3B;IAED;;;OAGG;IACH,IAAW,SAAS,UAEnB;IAED;;;OAGG;IACH,IAAW,UAAU,mDAEpB;IAED;;;OAGG;IACH,IAAW,WAAW,6CAErB;IAED;;;OAGG;IACH,IAAW,cAAc,aAExB;IAED;;;OAGG;IACH,IAAW,MAAM;;;MAKhB;IAED;;;OAGG;IACH,IAAW,WAAW,6BAQrB;IAED;;;;OAIG;IACI,QAAQ,SAAU,MAAM,eAAe,sBAY7C;IAED;;;OAGG;IACI,iBAAiB,WAAY,OAAO,UAE1C;IAED;;;OAGG;IACI,SAAS,WAAY,eAAe,UAE1C;IAED;;;OAGG;IACI,YAAY,WAAY,eAAe,UAE7C;CACJ"}
@@ -1,3 +1,8 @@
1
1
  import type { StyleSheetWithSuperPowers } from './types';
2
+ /**
3
+ * Utility to create a stylesheet with superpowers
4
+ * Compatible with React Native StyleSheet.create
5
+ * @param stylesheet - The stylesheet with superpowers to be used
6
+ */
2
7
  export declare const createStyleSheet: <S extends StyleSheetWithSuperPowers>(stylesheet: S) => S;
3
8
  //# sourceMappingURL=createStyleSheet.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"createStyleSheet.d.ts","sourceRoot":"","sources":["../../../src/createStyleSheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD,eAAO,MAAM,gBAAgB,2DAAwE,CAAA"}
1
+ {"version":3,"file":"createStyleSheet.d.ts","sourceRoot":"","sources":["../../../src/createStyleSheet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,SAAS,CAAA;AAExD;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,2DAAwE,CAAA"}
@@ -1,3 +1,3 @@
1
1
  import type { ReactNativeStyleSheet } from '../types';
2
- export declare const useCSS: <T>(_stylesheet: ReactNativeStyleSheet<T>) => void;
2
+ export declare const useCSS: <T>(stylesheet: ReactNativeStyleSheet<T>) => void;
3
3
  //# sourceMappingURL=useCSS.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useCSS.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCSS.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,MAAM,gDAA+C,IAAU,CAAA"}
1
+ {"version":3,"file":"useCSS.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCSS.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGrD,eAAO,MAAM,MAAM,mDA6ClB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ReactNativeStyleSheet } from '../types';
2
+ export declare const useCSS: <T>(_stylesheet: ReactNativeStyleSheet<T>) => void;
3
+ //# sourceMappingURL=useCSS.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCSS.native.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useCSS.native.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,MAAM,gDAA+C,IAAU,CAAA"}
@@ -5,7 +5,15 @@ import type { UnistylesThemes, UnistylesBreakpoints } from './global';
5
5
  import { ScreenOrientation } from './common';
6
6
  import { useStyles } from './useStyles';
7
7
  import { createStyleSheet } from './createStyleSheet';
8
+ /**
9
+ * Utility to interact with the Unistyles
10
+ * (should be called only once)
11
+ */
8
12
  declare const UnistylesRegistry: {
13
+ /**
14
+ * Register themes to be used in the app
15
+ * @param themes - Key value pair of themes
16
+ */
9
17
  addThemes: (themes: UnistylesThemes) => {
10
18
  addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
11
19
  addThemes: any;
@@ -22,6 +30,10 @@ declare const UnistylesRegistry: {
22
30
  addThemes: any;
23
31
  };
24
32
  };
33
+ /**
34
+ * Register breakpoints to be used in the app
35
+ * @param breakpoints - Key value pair of breakpoints
36
+ */
25
37
  addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
26
38
  addThemes: (themes: UnistylesThemes) => {
27
39
  addBreakpoints: any;
@@ -38,6 +50,10 @@ declare const UnistylesRegistry: {
38
50
  };
39
51
  };
40
52
  };
53
+ /**
54
+ * Register additional config to customize the Unistyles
55
+ * @param config - Key value pair of config
56
+ */
41
57
  addConfig: (config: import("./types").UnistylesConfig) => {
42
58
  addBreakpoints: (breakpoints: UnistylesBreakpoints) => {
43
59
  addThemes: (themes: UnistylesThemes) => {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAItB,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,EAAE,EAAE,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACrE,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAErD;;;GAGG;AACH,QAAA,MAAM,iBAAiB;IACnB;;;OAGG;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;IAEH;;;OAGG;;;;;;;;;;;;;;;;;CAEN,CAAA;AAED,QAAA,MAAM,gBAAgB,mCAAoB,CAAA;AAE1C,OAAO,EACH,EAAE,EACF,SAAS,EACT,eAAe,EACf,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACnB,CAAA;AAED,YAAY,EACR,eAAe,EACf,oBAAoB,EACpB,eAAe,EAClB,CAAA"}
@@ -5,6 +5,12 @@ type ParsedStylesheet<ST extends StyleSheetWithSuperPowers> = {
5
5
  breakpoint: keyof UnistylesBreakpoints;
6
6
  styles: ReactNativeStyleSheet<ST>;
7
7
  };
8
+ /**
9
+ * Hook that enables all the features of Unistyles
10
+ * @param stylesheet - The stylesheet with superpowers to be used
11
+ * @param variantsMap - The map of variants to be used
12
+ * @returns - The theme, current breakpoint and RN compatible styles
13
+ */
8
14
  export declare const useStyles: <ST extends StyleSheetWithSuperPowers>(stylesheet?: ST | undefined, variantsMap?: ExtractVariantNames<ST> | undefined) => ParsedStylesheet<ST>;
9
15
  export {};
10
16
  //# sourceMappingURL=useStyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAIpH,KAAK,gBAAgB,CAAC,EAAE,SAAS,yBAAyB,IAAI;IAC1D,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,gJAsCrB,CAAA"}
1
+ {"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AACpD,OAAO,KAAK,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,yBAAyB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAIpH,KAAK,gBAAgB,CAAC,EAAE,SAAS,yBAAyB,IAAI;IAC1D,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,gJAsCrB,CAAA"}
@@ -17,6 +17,10 @@ type MQHandler = {
17
17
  };
18
18
  };
19
19
  };
20
+ /**
21
+ * Utility to create cross-platform media queries
22
+ * @returns - JavaScript symbol to be used in your stylesheet
23
+ */
20
24
  export declare const mq: MQHandler;
21
25
  export {};
22
26
  //# sourceMappingURL=mq.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/utils/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,KAAK,OAAO,GAAG,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAElD,KAAK,SAAS,GAAG;IACb,IAAI,EAAE;QACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KAC5D,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC7C,GAAG,EAAE;YACD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;SAC3D,CAAA;KACJ,CAAC;IACF,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC9C,GAAG,EAAE;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;SAC1D,CAAA;KACJ,CAAA;CACJ,CAAA;AAcD,eAAO,MAAM,EAAE,EAAE,SAiBhB,CAAA"}
1
+ {"version":3,"file":"mq.d.ts","sourceRoot":"","sources":["../../../../src/utils/mq.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,KAAK,OAAO,GAAG,MAAM,oBAAoB,GAAG,MAAM,CAAA;AAElD,KAAK,SAAS,GAAG;IACb,IAAI,EAAE;QACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;QACxD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;KAC5D,CAAC;IACF,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC7C,GAAG,EAAE;YACD,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;SAC3D,CAAA;KACJ,CAAC;IACF,MAAM,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG;QAC9C,GAAG,EAAE;YACD,KAAK,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,MAAM,CAAA;SAC1D,CAAA;KACJ,CAAA;CACJ,CAAA;AAcD;;;GAGG;AACH,eAAO,MAAM,EAAE,EAAE,SAiBhB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-beta.7",
3
+ "version": "2.0.0-rc.2",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -9,7 +9,7 @@
9
9
  "lint": "eslint . --ext .ts,.tsx",
10
10
  "prepare": "husky install && bob build",
11
11
  "precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
12
- "release": "release-it patch --preRelease=beta --npm.tag=next"
12
+ "release": "release-it patch --preRelease=rc --npm.tag=next"
13
13
  },
14
14
  "main": "lib/commonjs/index",
15
15
  "module": "lib/module/index",
@@ -55,18 +55,18 @@
55
55
  "@react-native/normalize-colors": "0.74.1",
56
56
  "@release-it/conventional-changelog": "8.0.1",
57
57
  "@testing-library/react-hooks": "8.0.1",
58
- "@types/jest": "29.5.10",
59
- "@types/react": "18.2.39",
60
- "@typescript-eslint/eslint-plugin": "6.13.1",
61
- "@typescript-eslint/eslint-plugin-tslint": "6.13.1",
62
- "@typescript-eslint/parser": "6.13.1",
58
+ "@types/jest": "29.5.11",
59
+ "@types/react": "18.2.45",
60
+ "@typescript-eslint/eslint-plugin": "6.14.0",
61
+ "@typescript-eslint/eslint-plugin-tslint": "6.14.0",
62
+ "@typescript-eslint/parser": "6.14.0",
63
63
  "commitlint": "18.4.3",
64
64
  "concurrently": "8.2.2",
65
- "eslint": "8.54.0",
65
+ "eslint": "8.56.0",
66
66
  "eslint-config-codemask": "1.1.7",
67
67
  "eslint-plugin-functional": "6.0.0",
68
- "eslint-plugin-import": "2.29.0",
69
- "eslint-plugin-jsdoc": "46.9.0",
68
+ "eslint-plugin-import": "2.29.1",
69
+ "eslint-plugin-jsdoc": "46.9.1",
70
70
  "eslint-plugin-jsx-a11y": "6.8.0",
71
71
  "eslint-plugin-nested-if": "1.0.0",
72
72
  "eslint-plugin-no-else": "0.2.2",
@@ -81,8 +81,8 @@
81
81
  "react-native-builder-bob": "0.23.2",
82
82
  "react-native-web": "0.19.9",
83
83
  "react-test-renderer": "18.2.0",
84
- "release-it": "17.0.0",
85
- "typescript": "5.3.2"
84
+ "release-it": "17.0.1",
85
+ "typescript": "5.3.3"
86
86
  },
87
87
  "peerDependencies": {
88
88
  "@react-native/normalize-colors": "*",
@@ -132,13 +132,11 @@
132
132
  "publish": true
133
133
  },
134
134
  "github": {
135
- "release": false
135
+ "release": true
136
136
  },
137
137
  "plugins": {
138
138
  "@release-it/conventional-changelog": {
139
- "preset": {
140
- "name": "conventionalcommits"
141
- }
139
+ "preset": "angular"
142
140
  }
143
141
  }
144
142
  },
@@ -0,0 +1,7 @@
1
+ import { NativeModules } from 'react-native'
2
+
3
+ type UnistylesNativeModule = {
4
+ install(): boolean
5
+ }
6
+
7
+ export const UnistylesModule = NativeModules?.Unistyles as UnistylesNativeModule