react-native-unistyles 2.0.0-alpha.1 → 2.0.0-alpha.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. package/README.md +4 -4
  2. package/ios/UnistylesModule.h +12 -0
  3. package/ios/UnistylesModule.mm +163 -0
  4. package/ios/UnistylesRuntime.h +48 -0
  5. package/ios/UnistylesRuntime.mm +228 -0
  6. package/lib/commonjs/UnistyleRegistry.js +34 -0
  7. package/lib/commonjs/UnistyleRegistry.js.map +1 -0
  8. package/lib/commonjs/Unistyles.js +36 -0
  9. package/lib/commonjs/Unistyles.js.map +1 -0
  10. package/lib/commonjs/UnistylesEngine.js +22 -0
  11. package/lib/commonjs/UnistylesEngine.js.map +1 -0
  12. package/lib/commonjs/UnistylesModule.js +9 -0
  13. package/lib/commonjs/UnistylesModule.js.map +1 -0
  14. package/lib/commonjs/UnistylesRuntime.js +63 -0
  15. package/lib/commonjs/UnistylesRuntime.js.map +1 -0
  16. package/lib/commonjs/createStyleSheet.js +14 -0
  17. package/lib/commonjs/createStyleSheet.js.map +1 -0
  18. package/lib/commonjs/global.js +2 -0
  19. package/lib/commonjs/global.js.map +1 -0
  20. package/lib/commonjs/hooks/useDimensions.web.js +3 -2
  21. package/lib/commonjs/hooks/useDimensions.web.js.map +1 -1
  22. package/lib/commonjs/index.js +33 -6
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/types/cxx.js +23 -0
  25. package/lib/commonjs/types/cxx.js.map +1 -0
  26. package/lib/commonjs/types/index.js +26 -0
  27. package/lib/commonjs/types/index.js.map +1 -1
  28. package/lib/commonjs/types/normalizer.js +6 -0
  29. package/lib/commonjs/types/normalizer.js.map +1 -0
  30. package/lib/commonjs/useInitialTheme.js +13 -0
  31. package/lib/commonjs/useInitialTheme.js.map +1 -0
  32. package/lib/commonjs/useStyles.js +48 -0
  33. package/lib/commonjs/useStyles.js.map +1 -0
  34. package/lib/commonjs/useUnistyles.js +57 -0
  35. package/lib/commonjs/useUnistyles.js.map +1 -0
  36. package/lib/commonjs/utils/breakpoints.js +4 -2
  37. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  38. package/lib/commonjs/utils/common.js +3 -3
  39. package/lib/commonjs/utils/common.js.map +1 -1
  40. package/lib/commonjs/utils/index.js +34 -0
  41. package/lib/commonjs/utils/index.js.map +1 -1
  42. package/lib/commonjs/utils/module.d.js +2 -0
  43. package/lib/commonjs/utils/module.d.js.map +1 -0
  44. package/lib/commonjs/utils/normalizeStyles.web.js +13 -13
  45. package/lib/commonjs/utils/normalizeStyles.web.js.map +1 -1
  46. package/lib/commonjs/utils/normalizer.js +89 -0
  47. package/lib/commonjs/utils/normalizer.js.map +1 -0
  48. package/lib/commonjs/utils/styles.js +7 -7
  49. package/lib/commonjs/utils/styles.js.map +1 -1
  50. package/lib/module/UnistyleRegistry.js +27 -0
  51. package/lib/module/UnistyleRegistry.js.map +1 -0
  52. package/lib/module/Unistyles.js +30 -0
  53. package/lib/module/Unistyles.js.map +1 -0
  54. package/lib/module/UnistylesEngine.js +15 -0
  55. package/lib/module/UnistylesEngine.js.map +1 -0
  56. package/lib/module/UnistylesModule.js +3 -0
  57. package/lib/module/UnistylesModule.js.map +1 -0
  58. package/lib/module/UnistylesRuntime.js +56 -0
  59. package/lib/module/UnistylesRuntime.js.map +1 -0
  60. package/lib/module/createStyleSheet.js +7 -0
  61. package/lib/module/createStyleSheet.js.map +1 -0
  62. package/lib/module/global.js +2 -0
  63. package/lib/module/global.js.map +1 -0
  64. package/lib/module/hooks/useDimensions.web.js +3 -2
  65. package/lib/module/hooks/useDimensions.web.js.map +1 -1
  66. package/lib/module/index.js +18 -2
  67. package/lib/module/index.js.map +1 -1
  68. package/lib/module/types/cxx.js +17 -0
  69. package/lib/module/types/cxx.js.map +1 -0
  70. package/lib/module/types/index.js +2 -1
  71. package/lib/module/types/index.js.map +1 -1
  72. package/lib/module/types/normalizer.js +2 -0
  73. package/lib/module/types/normalizer.js.map +1 -0
  74. package/lib/module/useInitialTheme.js +6 -0
  75. package/lib/module/useInitialTheme.js.map +1 -0
  76. package/lib/module/useStyles.js +42 -0
  77. package/lib/module/useStyles.js.map +1 -0
  78. package/lib/module/useUnistyles.js +50 -0
  79. package/lib/module/useUnistyles.js.map +1 -0
  80. package/lib/module/utils/breakpoints.js +4 -3
  81. package/lib/module/utils/breakpoints.js.map +1 -1
  82. package/lib/module/utils/common.js +2 -1
  83. package/lib/module/utils/common.js.map +1 -1
  84. package/lib/module/utils/index.js +2 -0
  85. package/lib/module/utils/index.js.map +1 -1
  86. package/lib/module/utils/module.d.js +2 -0
  87. package/lib/module/utils/module.d.js.map +1 -0
  88. package/lib/module/utils/normalizeStyles.web.js +13 -13
  89. package/lib/module/utils/normalizeStyles.web.js.map +1 -1
  90. package/lib/module/utils/normalizer.js +79 -0
  91. package/lib/module/utils/normalizer.js.map +1 -0
  92. package/lib/module/utils/styles.js +7 -8
  93. package/lib/module/utils/styles.js.map +1 -1
  94. package/lib/typescript/examples/expo/src/App.d.ts +3 -0
  95. package/lib/typescript/examples/expo/src/App.d.ts.map +1 -0
  96. package/lib/typescript/examples/expo/src/examples/Cxx.d.ts +3 -0
  97. package/lib/typescript/examples/expo/src/examples/Cxx.d.ts.map +1 -0
  98. package/lib/typescript/examples/expo/src/examples/index.d.ts +2 -0
  99. package/lib/typescript/examples/expo/src/examples/index.d.ts.map +1 -0
  100. package/lib/typescript/examples/expo/src/index.d.ts +2 -0
  101. package/lib/typescript/examples/expo/src/index.d.ts.map +1 -0
  102. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts +8 -0
  103. package/lib/typescript/examples/expo/src/styles/breakpoints.d.ts.map +1 -0
  104. package/lib/typescript/examples/expo/src/styles/index.d.ts +16 -0
  105. package/lib/typescript/examples/expo/src/styles/index.d.ts.map +1 -0
  106. package/lib/typescript/examples/expo/src/styles/theme.d.ts +40 -0
  107. package/lib/typescript/examples/expo/src/styles/theme.d.ts.map +1 -0
  108. package/lib/typescript/src/UnistyleRegistry.d.ts +14 -0
  109. package/lib/typescript/src/UnistyleRegistry.d.ts.map +1 -0
  110. package/lib/typescript/src/Unistyles.d.ts +16 -0
  111. package/lib/typescript/src/Unistyles.d.ts.map +1 -0
  112. package/lib/typescript/src/UnistylesEngine.d.ts +8 -0
  113. package/lib/typescript/src/UnistylesEngine.d.ts.map +1 -0
  114. package/lib/typescript/src/UnistylesModule.d.ts +6 -0
  115. package/lib/typescript/src/UnistylesModule.d.ts.map +1 -0
  116. package/lib/typescript/src/UnistylesRuntime.d.ts +60 -0
  117. package/lib/typescript/src/UnistylesRuntime.d.ts.map +1 -0
  118. package/lib/typescript/src/createStyleSheet.d.ts +6 -0
  119. package/lib/typescript/src/createStyleSheet.d.ts.map +1 -0
  120. package/lib/typescript/src/global.d.ts +5 -0
  121. package/lib/typescript/src/global.d.ts.map +1 -0
  122. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +1 -1
  123. package/lib/typescript/src/index.d.ts +14 -2
  124. package/lib/typescript/src/index.d.ts.map +1 -1
  125. package/lib/typescript/src/types/breakpoints.d.ts +6 -7
  126. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  127. package/lib/typescript/src/types/core.d.ts +4 -4
  128. package/lib/typescript/src/types/core.d.ts.map +1 -1
  129. package/lib/typescript/src/types/cxx.d.ts +53 -0
  130. package/lib/typescript/src/types/cxx.d.ts.map +1 -0
  131. package/lib/typescript/src/types/index.d.ts +4 -1
  132. package/lib/typescript/src/types/index.d.ts.map +1 -1
  133. package/lib/typescript/src/types/normalizer.d.ts +20 -0
  134. package/lib/typescript/src/types/normalizer.d.ts.map +1 -0
  135. package/lib/typescript/src/useInitialTheme.d.ts +3 -0
  136. package/lib/typescript/src/useInitialTheme.d.ts.map +1 -0
  137. package/lib/typescript/src/useStyles.d.ts +46 -0
  138. package/lib/typescript/src/useStyles.d.ts.map +1 -0
  139. package/lib/typescript/src/useUnistyles.d.ts +45 -0
  140. package/lib/typescript/src/useUnistyles.d.ts.map +1 -0
  141. package/lib/typescript/src/utils/breakpoints.d.ts +5 -4
  142. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  143. package/lib/typescript/src/utils/common.d.ts +2 -1
  144. package/lib/typescript/src/utils/common.d.ts.map +1 -1
  145. package/lib/typescript/src/utils/index.d.ts +2 -0
  146. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  147. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +4 -1
  148. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +1 -1
  149. package/lib/typescript/src/utils/normalizer.d.ts +11 -0
  150. package/lib/typescript/src/utils/normalizer.d.ts.map +1 -0
  151. package/lib/typescript/src/utils/styles.d.ts +4 -3
  152. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  153. package/package.json +13 -3
  154. package/react-native-unistyles.podspec +21 -0
  155. package/src/UnistyleRegistry.ts +35 -0
  156. package/src/Unistyles.ts +41 -0
  157. package/src/UnistylesEngine.ts +15 -0
  158. package/src/UnistylesModule.ts +7 -0
  159. package/src/UnistylesRuntime.ts +69 -0
  160. package/src/createStyleSheet.ts +12 -0
  161. package/src/global.ts +2 -0
  162. package/src/hooks/useDimensions.web.ts +3 -2
  163. package/src/index.ts +30 -2
  164. package/src/types/breakpoints.ts +9 -11
  165. package/src/types/core.ts +6 -6
  166. package/src/types/cxx.ts +65 -0
  167. package/src/types/index.ts +4 -3
  168. package/src/types/normalizer.ts +29 -0
  169. package/src/useInitialTheme.ts +7 -0
  170. package/src/useStyles.ts +49 -0
  171. package/src/useUnistyles.ts +66 -0
  172. package/src/utils/breakpoints.ts +16 -14
  173. package/src/utils/common.ts +2 -1
  174. package/src/utils/index.ts +2 -0
  175. package/src/utils/module.d.ts +3 -0
  176. package/src/utils/normalizeStyles.web.ts +21 -42
  177. package/src/utils/normalizer.ts +99 -0
  178. package/src/utils/styles.ts +17 -19
  179. package/lib/commonjs/UnistylesTheme.js +0 -21
  180. package/lib/commonjs/UnistylesTheme.js.map +0 -1
  181. package/lib/commonjs/createUnistyles.js +0 -57
  182. package/lib/commonjs/createUnistyles.js.map +0 -1
  183. package/lib/module/UnistylesTheme.js +0 -12
  184. package/lib/module/UnistylesTheme.js.map +0 -1
  185. package/lib/module/createUnistyles.js +0 -50
  186. package/lib/module/createUnistyles.js.map +0 -1
  187. package/lib/typescript/src/UnistylesTheme.d.ts +0 -9
  188. package/lib/typescript/src/UnistylesTheme.d.ts.map +0 -1
  189. package/lib/typescript/src/createUnistyles.d.ts +0 -10
  190. package/lib/typescript/src/createUnistyles.d.ts.map +0 -1
  191. package/src/UnistylesTheme.tsx +0 -17
  192. package/src/__tests__/createUnistyles.spec.tsx +0 -192
  193. package/src/createUnistyles.ts +0 -70
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.preprocessor = exports.normalizeNumericValue = exports.normalizeColor = void 0;
7
+ var _normalizeColors = _interopRequireDefault(require("@react-native/normalize-colors"));
8
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
9
+ // based on react-native-web normalizer
10
+ // https://github.com/necolas/react-native-web
11
+
12
+ const normalizeColor = function (color) {
13
+ let opacity = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
14
+ // If the opacity is 1 there's no need to normalize the color
15
+ if (opacity === 1) {
16
+ return color;
17
+ }
18
+ const integer = (0, _normalizeColors.default)(color);
19
+
20
+ // If the colour is an unknown format, the return value is null
21
+ if (integer === null) {
22
+ return color;
23
+ }
24
+ const hex = integer.toString(16).padStart(8, '0');
25
+ if (hex.length === 8) {
26
+ const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
27
+ return `rgba(${r},${g},${b},${a / 255 * opacity})`;
28
+ }
29
+ return color;
30
+ };
31
+ exports.normalizeColor = normalizeColor;
32
+ const normalizeNumericValue = value => value ? `${value}px` : value;
33
+ exports.normalizeNumericValue = normalizeNumericValue;
34
+ const normalizeTransform = (key, value) => {
35
+ if (key.includes('scale')) {
36
+ return value;
37
+ }
38
+ if (typeof value === 'number') {
39
+ return normalizeNumericValue(value);
40
+ }
41
+ return value;
42
+ };
43
+ const createTextShadowValue = style => {
44
+ // at this point every prop is present
45
+ const {
46
+ textShadowColor,
47
+ textShadowOffset,
48
+ textShadowRadius
49
+ } = style;
50
+ const offsetX = normalizeNumericValue(textShadowOffset.width);
51
+ const offsetY = normalizeNumericValue(textShadowOffset.height);
52
+ const radius = normalizeNumericValue(textShadowRadius);
53
+ const color = normalizeColor(textShadowColor);
54
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
55
+ };
56
+ const createBoxShadowValue = style => {
57
+ // at this point every prop is present
58
+ const {
59
+ shadowColor,
60
+ shadowOffset,
61
+ shadowOpacity,
62
+ shadowRadius
63
+ } = style;
64
+ const offsetX = normalizeNumericValue(shadowOffset.width);
65
+ const offsetY = normalizeNumericValue(shadowOffset.height);
66
+ const radius = normalizeNumericValue(shadowRadius);
67
+ const color = normalizeColor(shadowColor, shadowOpacity);
68
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
69
+ };
70
+ const createTransformValue = transforms => transforms.map(transform => {
71
+ const [key] = Object.keys(transform);
72
+ if (!key) {
73
+ return undefined;
74
+ }
75
+ const value = transform[key];
76
+ switch (key) {
77
+ case 'matrix':
78
+ case 'matrix3d':
79
+ return `${key}(${value.join(',')})`;
80
+ default:
81
+ return `${key}(${normalizeTransform(key, value)})`;
82
+ }
83
+ }).filter(Boolean).join(' ');
84
+ const preprocessor = exports.preprocessor = {
85
+ createTextShadowValue,
86
+ createBoxShadowValue,
87
+ createTransformValue
88
+ };
89
+ //# sourceMappingURL=normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","arguments","length","undefined","integer","normalizeColors","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","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":["utils/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAAC,UAAA,GAAAD,GAAA,KAAAE,OAAA,EAAAF,GAAA;AAF5D;AACA;;AAUO,MAAMG,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,GAAG,IAAAC,wBAAe,EAACN,KAAK,CAAkB;;EAEvD;EACA,IAAIK,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOL,KAAK;EAChB;EAEA,MAAMO,GAAG,GAAGF,OAAO,CAACG,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACJ,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACO,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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AqB,CAACiB,YAAY,CAACJ,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAGd,qBAAqB,CAACmB,YAAY,CAAC;EAClD,MAAMzC,KAAK,GAAGD,cAAc,CAACuC,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAQ,GAAER,OAAQ,IAAGE,OAAQ,IAAGE,MAAO,IAAGpC,KAAM,EAAC;AACrD,CAAC;AAED,MAAM0C,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9D5B,GAAG,CAAC6B,SAAS,IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOrB,SAAS;EACpB;EAEA,MAAMmB,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,CACDL,MAAM,CAAC8B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEP,MAAME,YAA0B,GAAA5B,OAAA,CAAA4B,YAAA,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -28,8 +28,8 @@ var _common = require("./common");
28
28
  * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
29
29
  * proxifiedFunction() // parsed style based on screenSize and breakpoints
30
30
  */
31
- const proxifyFunction = (fn, breakpoint, screenSize, breakpointPairs) => new Proxy(fn, {
32
- apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, breakpointPairs)
31
+ const proxifyFunction = (fn, breakpoint, screenSize) => new Proxy(fn, {
32
+ apply: (target, thisArg, argumentsList) => parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize)
33
33
  });
34
34
 
35
35
  /**
@@ -58,26 +58,26 @@ const proxifyFunction = (fn, breakpoint, screenSize, breakpointPairs) => new Pro
58
58
  * // { fontSize: '12px' }
59
59
  */
60
60
  exports.proxifyFunction = proxifyFunction;
61
- const parseStyle = (style, breakpoint, screenSize, breakpointPairs) => {
61
+ const parseStyle = (style, breakpoint, screenSize) => {
62
62
  const entries = Object.entries(style);
63
63
  const parsedStyles = Object.fromEntries(entries.map(_ref => {
64
64
  let [key, value] = _ref;
65
65
  const hasNestedProperties = key === 'shadowOffset' || key === 'textShadowOffset';
66
66
  if (hasNestedProperties) {
67
- return [key, parseStyle(value, breakpoint, screenSize, breakpointPairs)];
67
+ return [key, parseStyle(value, breakpoint, screenSize)];
68
68
  }
69
69
  const isTransform = key === 'transform';
70
70
  if (isTransform && Array.isArray(value)) {
71
- return [key, value.map(value => parseStyle(value, breakpoint, screenSize, breakpointPairs))];
71
+ return [key, value.map(value => parseStyle(value, breakpoint, screenSize))];
72
72
  }
73
73
  const isDynamicFunction = typeof value === 'function';
74
74
  const isValidStyle = typeof value !== 'object';
75
75
  if (isDynamicFunction || isValidStyle) {
76
76
  return [key, value];
77
77
  }
78
- return [key, (0, _breakpoints.getValueForBreakpoint)(value, breakpoint, screenSize, breakpointPairs)];
78
+ return [key, (0, _breakpoints.getValueForBreakpoint)(value, breakpoint, screenSize)];
79
79
  }));
80
- return (0, _common.isWeb)() ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
80
+ return _common.isWeb ? (0, _normalizeStyles.normalizeStyles)(parsedStyles) : parsedStyles;
81
81
  };
82
82
  exports.parseStyle = parseStyle;
83
83
  //# sourceMappingURL=styles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","breakpointPairs","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","value","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;AACA,IAAAE,OAAA,GAAAF,OAAA;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMG,eAAe,GAAGA,CAC3BC,EAAY,EAAEC,UAA4B,EAC1CC,UAAsB,EACtBC,eAA2C,KAChC,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,eAAe;AAChG,CAAC,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAxBAO,OAAA,CAAAX,eAAA,GAAAA,eAAA;AAyBO,MAAMU,UAAU,GAAGA,CACtBE,KAA8B,EAC9BV,UAA4B,EAC5BC,UAAsB,EACtBC,eAA2C,KACvC;EACJ,MAAMS,OAAO,GAAGC,MAAM,CAACD,OAAO,CAACD,KAAK,CAGnC;EAED,MAAMG,YAAY,GAAGD,MAAM,CACtBE,WAAW,CAACH,OAAO,CACfI,GAAG,CAACC,IAAA,IAAkB;IAAA,IAAjB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAAF,IAAA;IACd,MAAMG,mBAAmB,GAAGF,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAK,kBAAkB;IAEhF,IAAIE,mBAAmB,EAAE;MACrB,OAAO,CACHF,GAAG,EACHT,UAAU,CAACU,KAAK,EAA6BlB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CACxF;IACL;IAEA,MAAMkB,WAAW,GAAGH,GAAG,KAAK,WAAW;IAEvC,IAAIG,WAAW,IAAIC,KAAK,CAACC,OAAO,CAACJ,KAAK,CAAC,EAAE;MACrC,OAAO,CACHD,GAAG,EACHC,KAAK,CAACH,GAAG,CAACG,KAAK,IAAIV,UAAU,CAACU,KAAK,EAAElB,UAAU,EAAEC,UAAU,EAAEC,eAAe,CAAC,CAAC,CACjF;IACL;IAEA,MAAMqB,iBAAiB,GAAG,OAAOL,KAAK,KAAK,UAAU;IACrD,MAAMM,YAAY,GAAG,OAAON,KAAK,KAAK,QAAQ;IAE9C,IAAIK,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACP,GAAG,EAAEC,KAAK,CAAC;IACvB;IAEA,OAAO,CACHD,GAAG,EACH,IAAAQ,kCAAqB,EACjBP,KAAK,EACLlB,UAAU,EACVC,UAAU,EACVC,eACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAO,IAAAwB,aAAK,EAAC,CAAC,GACR,IAAAC,gCAAe,EAACd,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;AAAAJ,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
1
+ {"version":3,"names":["_breakpoints","require","_normalizeStyles","_common","proxifyFunction","fn","breakpoint","screenSize","Proxy","apply","target","thisArg","argumentsList","parseStyle","exports","style","entries","Object","parsedStyles","fromEntries","map","_ref","key","value","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;AACA,IAAAE,OAAA,GAAAF,OAAA;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EAAEjB,UAAU,EAAEC,UAAU,CAAC,CAAC,CAChE;IACL;IAEA,MAAMqB,iBAAiB,GAAG,OAAOL,KAAK,KAAK,UAAU;IACrD,MAAMM,YAAY,GAAG,OAAON,KAAK,KAAK,QAAQ;IAE9C,IAAIK,iBAAiB,IAAIC,YAAY,EAAE;MACnC,OAAO,CAACP,GAAG,EAAEC,KAAK,CAAC;IACvB;IAEA,OAAO,CACHD,GAAG,EACH,IAAAQ,kCAAqB,EACjBP,KAAK,EACLjB,UAAU,EACVC,UACJ,CAAC,CACJ;EACL,CAAC,CACL,CAAC;EAEL,OAAOwB,aAAK,GACN,IAAAC,gCAAe,EAACd,YAAY,CAAC,GAC7BA,YAAY;AACtB,CAAC;AAAAJ,OAAA,CAAAD,UAAA,GAAAA,UAAA"}
@@ -0,0 +1,27 @@
1
+ export class UnistyleRegistry {
2
+ config = {};
3
+ themes = {};
4
+ breakpoints = {};
5
+ sortedBreakpointPairs = [];
6
+ constructor(unistylesBridge) {
7
+ this.unistylesBridge = unistylesBridge;
8
+ }
9
+ addThemes = themes => {
10
+ this.themes = themes;
11
+ this.unistylesBridge.themes = Object.keys(themes);
12
+ return this;
13
+ };
14
+ addBreakpoints = breakpoints => {
15
+ this.unistylesBridge.useBreakpoints(breakpoints);
16
+ this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs;
17
+ return this;
18
+ };
19
+ addConfig = config => {
20
+ this.config = config;
21
+ if (config.adaptiveThemes) {
22
+ this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes);
23
+ }
24
+ return this;
25
+ };
26
+ }
27
+ //# sourceMappingURL=UnistyleRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistyleRegistry","config","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","Object","keys","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":"AAGA,OAAO,MAAMA,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,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;IACpB,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,MAAM,CAACC,IAAI,CAACP,MAAM,CAAiC;IAEjF,OAAO,IAAI;EACf,CAAC;EAEMQ,cAAc,GAAIP,WAAiC,IAAK;IAC3D,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,GAAIX,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACY,cAAc,EAAE;MACvB,IAAI,CAACP,eAAe,CAACQ,iBAAiB,CAACb,MAAM,CAACY,cAAc,CAAC;IACjE;IAEA,OAAO,IAAI;EACf,CAAC;AACL"}
@@ -0,0 +1,30 @@
1
+ import { UnistylesModule } from './UnistylesModule';
2
+ import { UnistylesRuntime } from './UnistylesRuntime';
3
+ import { UnistylesEngine } from './UnistylesEngine';
4
+ import { UnistyleRegistry } from './UnistyleRegistry';
5
+ import { UnistylesError } from './types';
6
+ class Unistyles {
7
+ constructor() {
8
+ const isInstalled = UnistylesModule?.install() ?? false;
9
+ if (!isInstalled) {
10
+ throw new Error(UnistylesError.RuntimeUnavailable);
11
+ }
12
+
13
+ // @ts-ignore
14
+ this._bridge = global.__UNISTYLES__;
15
+ this._registry = new UnistyleRegistry(this._bridge);
16
+ this._runtime = new UnistylesRuntime(this._bridge, this._registry);
17
+ this._engine = new UnistylesEngine(this._registry, this._runtime);
18
+ }
19
+ get registry() {
20
+ return this._registry;
21
+ }
22
+ get runtime() {
23
+ return this._runtime;
24
+ }
25
+ get engine() {
26
+ return this._engine;
27
+ }
28
+ }
29
+ export const unistyles = new Unistyles();
30
+ //# sourceMappingURL=Unistyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistylesModule","UnistylesRuntime","UnistylesEngine","UnistyleRegistry","UnistylesError","Unistyles","constructor","isInstalled","install","Error","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","_runtime","_engine","registry","runtime","engine","unistyles"],"sourceRoot":"../../src","sources":["Unistyles.ts"],"mappings":"AAAA,SAASA,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AACrD,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,SAASC,cAAc,QAAQ,SAAS;AAExC,MAAMC,SAAS,CAAC;EAMZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGP,eAAe,EAAEQ,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACD,WAAW,EAAE;MACd,MAAM,IAAIE,KAAK,CAACL,cAAc,CAACM,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,aAAgC;IACtD,IAAI,CAACC,SAAS,GAAG,IAAIX,gBAAgB,CAAC,IAAI,CAACQ,OAAO,CAAC;IACnD,IAAI,CAACI,QAAQ,GAAG,IAAId,gBAAgB,CAAC,IAAI,CAACU,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;IAClE,IAAI,CAACE,OAAO,GAAG,IAAId,eAAe,CAAC,IAAI,CAACY,SAAS,EAAE,IAAI,CAACC,QAAQ,CAAC;EACrE;EAEA,IAAWE,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACH,SAAS;EACzB;EAEA,IAAWI,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACH,QAAQ;EACxB;EAEA,IAAWI,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACH,OAAO;EACvB;AACJ;AAEA,OAAO,MAAMI,SAAS,GAAG,IAAIf,SAAS,CAAC,CAAC"}
@@ -0,0 +1,15 @@
1
+ // todo implement engine
2
+ export class UnistylesEngine {
3
+ // @ts-ignore
4
+ constructor(registry, runtime) {
5
+ this.registry = registry;
6
+ this.runtime = runtime;
7
+ this.registry = registry;
8
+ this.runtime = runtime;
9
+ }
10
+
11
+ // UnistylesEngine.parseStyleSheet
12
+ // UnistylesEngine.parseStyle
13
+ // UnistylesEngine.proxify
14
+ }
15
+ //# sourceMappingURL=UnistylesEngine.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistylesEngine","constructor","registry","runtime"],"sourceRoot":"../../src","sources":["UnistylesEngine.ts"],"mappings":"AAGA;AACA,OAAO,MAAMA,eAAe,CAAC;EACzB;EACAC,WAAWA,CAASC,QAA0B,EAAUC,OAAyB,EAAE;IAAA,KAA/DD,QAA0B,GAA1BA,QAA0B;IAAA,KAAUC,OAAyB,GAAzBA,OAAyB;IAC7E,IAAI,CAACD,QAAQ,GAAGA,QAAQ;IACxB,IAAI,CAACC,OAAO,GAAGA,OAAO;EAC1B;;EAEA;EACA;EACA;AACJ"}
@@ -0,0 +1,3 @@
1
+ import { NativeModules } from 'react-native';
2
+ export const UnistylesModule = NativeModules?.Unistyles;
3
+ //# sourceMappingURL=UnistylesModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeModules","UnistylesModule","Unistyles"],"sourceRoot":"../../src","sources":["UnistylesModule.ts"],"mappings":"AAAA,SAASA,aAAa,QAAQ,cAAc;AAM5C,OAAO,MAAMC,eAAe,GAAGD,aAAa,EAAEE,SAAkC"}
@@ -0,0 +1,56 @@
1
+ import { ScreenOrientation, UnistylesError } from './types';
2
+ export class UnistylesRuntime {
3
+ constructor(unistylesBridge, registry) {
4
+ this.unistylesBridge = unistylesBridge;
5
+ this.registry = registry;
6
+ }
7
+ get colorScheme() {
8
+ return this.unistylesBridge.colorScheme;
9
+ }
10
+ get hasAdaptiveThemes() {
11
+ return this.unistylesBridge.hasAdaptiveThemes;
12
+ }
13
+ get sortedBreakpoints() {
14
+ return this.registry.sortedBreakpointPairs;
15
+ }
16
+ get themeName() {
17
+ return this.unistylesBridge.theme;
18
+ }
19
+ get breakpoint() {
20
+ return this.unistylesBridge.breakpoint;
21
+ }
22
+ get screen() {
23
+ return {
24
+ width: this.unistylesBridge.screenWidth,
25
+ height: this.unistylesBridge.screenHeight
26
+ };
27
+ }
28
+ get orientation() {
29
+ const {
30
+ width,
31
+ height
32
+ } = this.screen;
33
+ if (width > height) {
34
+ return ScreenOrientation.Landscape;
35
+ }
36
+ return ScreenOrientation.Portrait;
37
+ }
38
+ setTheme = name => {
39
+ if (name !== this.themeName && this.hasTheme(name)) {
40
+ this.unistylesBridge.useTheme(name);
41
+ return true;
42
+ }
43
+ return false;
44
+ };
45
+ getTheme = forName => {
46
+ if (!this.hasTheme(forName)) {
47
+ throw new Error(UnistylesError.ThemeNotFound);
48
+ }
49
+ return this.registry.themes[forName];
50
+ };
51
+ setAdaptiveThemes = enable => {
52
+ this.unistylesBridge.useAdaptiveThemes(enable);
53
+ };
54
+ hasTheme = name => name in this.registry.themes;
55
+ }
56
+ //# sourceMappingURL=UnistylesRuntime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ScreenOrientation","UnistylesError","UnistylesRuntime","constructor","unistylesBridge","registry","colorScheme","hasAdaptiveThemes","sortedBreakpoints","sortedBreakpointPairs","themeName","theme","breakpoint","screen","width","screenWidth","height","screenHeight","orientation","Landscape","Portrait","setTheme","name","hasTheme","useTheme","getTheme","forName","Error","ThemeNotFound","themes","setAdaptiveThemes","enable","useAdaptiveThemes"],"sourceRoot":"../../src","sources":["UnistylesRuntime.ts"],"mappings":"AAEA,SAASA,iBAAiB,EAAEC,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QAAQ,GAAIC,OAA8B,IAAK;IAClD,IAAI,CAAC,IAAI,CAACH,QAAQ,CAACG,OAAO,CAAC,EAAE;MACzB,MAAM,IAAIC,KAAK,CAAC1B,cAAc,CAAC2B,aAAa,CAAC;IACjD;IAEA,OAAO,IAAI,CAACvB,QAAQ,CAACwB,MAAM,CAACH,OAAO,CAAC;EACxC,CAAC;EAEMI,iBAAiB,GAAIC,MAAe,IAAK;IAC5C,IAAI,CAAC3B,eAAe,CAAC4B,iBAAiB,CAACD,MAAM,CAAC;EAClD,CAAC;EAEOR,QAAQ,GAAID,IAA2B,IAAKA,IAAI,IAAI,IAAI,CAACjB,QAAQ,CAACwB,MAAM;AACpF"}
@@ -0,0 +1,7 @@
1
+ export const createStyleSheet = styles => {
2
+ if (typeof styles === 'function') {
3
+ return styles;
4
+ }
5
+ return styles;
6
+ };
7
+ //# sourceMappingURL=createStyleSheet.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["createStyleSheet","styles"],"sourceRoot":"../../src","sources":["createStyleSheet.ts"],"mappings":"AAKA,OAAO,MAAMA,gBAAgB,GAAuCC,MAA+E,IAAY;EAC3J,IAAI,OAAOA,MAAM,KAAK,UAAU,EAAE;IAC9B,OAAOA,MAAM;EACjB;EAEA,OAAOA,MAAM;AACjB,CAAC"}
@@ -0,0 +1,2 @@
1
+
2
+ //# sourceMappingURL=global.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../src","sources":["global.ts"],"mappings":""}
@@ -1,9 +1,10 @@
1
1
  import { useEffect, useRef, useState } from 'react';
2
+ import { isServer } from '../utils';
2
3
  export const useDimensions = () => {
3
4
  const timerRef = useRef();
4
5
  const [screenSize, setScreenSize] = useState({
5
- width: window.innerWidth,
6
- height: window.innerHeight
6
+ width: isServer ? 0 : window.innerWidth,
7
+ height: isServer ? 0 : window.innerHeight
7
8
  });
8
9
  useEffect(() => {
9
10
  const handleResize = () => {
@@ -1 +1 @@
1
- {"version":3,"names":["useEffect","useRef","useState","useDimensions","timerRef","screenSize","setScreenSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAGnD,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAGH,MAAM,CAAgC,CAAC;EACxD,MAAM,CAACI,UAAU,EAAEC,aAAa,CAAC,GAAGJ,QAAQ,CAAa;IACrDK,KAAK,EAAEC,MAAM,CAACC,UAAU;IACxBC,MAAM,EAAEF,MAAM,CAACG;EACnB,CAAC,CAAC;EAEFX,SAAS,CAAC,MAAM;IACZ,MAAMY,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;MAE9BV,QAAQ,CAACU,OAAO,GAAGC,UAAU,CAAC,MAAMT,aAAa,CAAC;QAC9CC,KAAK,EAAEC,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACQ,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTJ,MAAM,CAACS,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOT,UAAU;AACrB,CAAC"}
1
+ {"version":3,"names":["useEffect","useRef","useState","isServer","useDimensions","timerRef","screenSize","setScreenSize","width","window","innerWidth","height","innerHeight","handleResize","clearTimeout","current","setTimeout","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useDimensions.web.ts"],"mappings":"AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AAEnD,SAASC,QAAQ,QAAQ,UAAU;AAEnC,OAAO,MAAMC,aAAa,GAAGA,CAAA,KAAkB;EAC3C,MAAMC,QAAQ,GAAGJ,MAAM,CAAgC,CAAC;EACxD,MAAM,CAACK,UAAU,EAAEC,aAAa,CAAC,GAAGL,QAAQ,CAAa;IACrDM,KAAK,EAAEL,QAAQ,GAAG,CAAC,GAAGM,MAAM,CAACC,UAAU;IACvCC,MAAM,EAAER,QAAQ,GAAG,CAAC,GAAGM,MAAM,CAACG;EAClC,CAAC,CAAC;EAEFZ,SAAS,CAAC,MAAM;IACZ,MAAMa,YAAY,GAAGA,CAAA,KAAM;MACvBC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;MAE9BV,QAAQ,CAACU,OAAO,GAAGC,UAAU,CAAC,MAAMT,aAAa,CAAC;QAC9CC,KAAK,EAAEC,MAAM,CAACC,UAAU;QACxBC,MAAM,EAAEF,MAAM,CAACG;MACnB,CAAC,CAAC,EAAE,GAAG,CAAC;IACZ,CAAC;IAEDH,MAAM,CAACQ,gBAAgB,CAAC,QAAQ,EAAEJ,YAAY,CAAC;IAE/C,OAAO,MAAM;MACTJ,MAAM,CAACS,mBAAmB,CAAC,QAAQ,EAAEL,YAAY,CAAC;MAClDC,YAAY,CAACT,QAAQ,CAACU,OAAO,CAAC;IAClC,CAAC;EACL,CAAC,EAAE,EAAE,CAAC;EAEN,OAAOT,UAAU;AACrB,CAAC"}
@@ -1,3 +1,19 @@
1
- export { UnistylesTheme } from './UnistylesTheme';
2
- export { createUnistyles } from './createUnistyles';
1
+ import { unistyles } from './Unistyles';
2
+ import { ScreenOrientation } from './types';
3
+ export { useInitialTheme } from './useInitialTheme';
4
+ export { useStyles } from './useStyles';
5
+ export { createStyleSheet } from './createStyleSheet';
6
+ const {
7
+ addThemes,
8
+ addBreakpoints,
9
+ addConfig
10
+ } = unistyles.registry;
11
+ const UnistylesRuntime = unistyles.runtime;
12
+ const UnistylesRegistry = {
13
+ addThemes,
14
+ addBreakpoints,
15
+ addConfig
16
+ };
17
+ export { UnistylesRuntime, UnistylesRegistry };
18
+ export { ScreenOrientation };
3
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["UnistylesTheme","createUnistyles"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,cAAc,QAAQ,kBAAkB;AACjD,SAASC,eAAe,QAAQ,mBAAmB"}
1
+ {"version":3,"names":["unistyles","ScreenOrientation","useInitialTheme","useStyles","createStyleSheet","addThemes","addBreakpoints","addConfig","registry","UnistylesRuntime","runtime","UnistylesRegistry"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,aAAa;AAEvC,SAASC,iBAAiB,QAAQ,SAAS;AAE3C,SAASC,eAAe,QAAQ,mBAAmB;AAEnD,SAASC,SAAS,QAAQ,aAAa;AACvC,SAASC,gBAAgB,QAAQ,oBAAoB;AAErD,MAAM;EAAEC,SAAS;EAAEC,cAAc;EAAEC;AAAW,CAAC,GAAGP,SAAS,CAACQ,QAAQ;AACpE,MAAMC,gBAAgB,GAAGT,SAAS,CAACU,OAAO;AAC1C,MAAMC,iBAAiB,GAAG;EACtBN,SAAS;EACTC,cAAc;EACdC;AACJ,CAAC;AAED,SACIE,gBAAgB,EAChBE,iBAAiB;AAGrB,SACIV,iBAAiB"}
@@ -0,0 +1,17 @@
1
+ export let ScreenOrientation = /*#__PURE__*/function (ScreenOrientation) {
2
+ ScreenOrientation[ScreenOrientation["Portrait"] = 1] = "Portrait";
3
+ ScreenOrientation[ScreenOrientation["Landscape"] = 2] = "Landscape";
4
+ return ScreenOrientation;
5
+ }({});
6
+ export let CxxUnistylesEventTypes = /*#__PURE__*/function (CxxUnistylesEventTypes) {
7
+ CxxUnistylesEventTypes["Theme"] = "theme";
8
+ CxxUnistylesEventTypes["Size"] = "size";
9
+ CxxUnistylesEventTypes["Breakpoint"] = "breakpoint";
10
+ return CxxUnistylesEventTypes;
11
+ }({});
12
+ export let UnistylesError = /*#__PURE__*/function (UnistylesError) {
13
+ UnistylesError["RuntimeUnavailable"] = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE";
14
+ UnistylesError["ThemeNotFound"] = "UNISTYLES_ERROR_THEME_NOT_FOUND";
15
+ return UnistylesError;
16
+ }({});
17
+ //# sourceMappingURL=cxx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["ScreenOrientation","CxxUnistylesEventTypes","UnistylesError"],"sourceRoot":"../../../src","sources":["types/cxx.ts"],"mappings":"AASA,WAAYA,iBAAiB,0BAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAjBA,iBAAiB,CAAjBA,iBAAiB;EAAA,OAAjBA,iBAAiB;AAAA;AAsB7B,WAAYC,sBAAsB,0BAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAtBA,sBAAsB;EAAA,OAAtBA,sBAAsB;AAAA;AA8BlC,WAAYC,cAAc,0BAAdA,cAAc;EAAdA,cAAc;EAAdA,cAAc;EAAA,OAAdA,cAAc;AAAA"}
@@ -1,2 +1,3 @@
1
-
1
+ export * from './normalizer';
2
+ export * from './cxx';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":""}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/index.ts"],"mappings":"AAAA,cAAc,cAAc;AAC5B,cAAc,OAAO"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=normalizer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["types/normalizer.ts"],"mappings":""}
@@ -0,0 +1,6 @@
1
+ import { useRef } from 'react';
2
+ import { unistyles } from './Unistyles';
3
+ export const useInitialTheme = forName => {
4
+ useRef(unistyles.runtime.setTheme(forName));
5
+ };
6
+ //# sourceMappingURL=useInitialTheme.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useRef","unistyles","useInitialTheme","forName","runtime","setTheme"],"sourceRoot":"../../src","sources":["useInitialTheme.ts"],"mappings":"AAAA,SAASA,MAAM,QAAQ,OAAO;AAC9B,SAASC,SAAS,QAAQ,aAAa;AAGvC,OAAO,MAAMC,eAAe,GAAIC,OAA8B,IAAK;EAC/DH,MAAM,CAACC,SAAS,CAACG,OAAO,CAACC,QAAQ,CAACF,OAAO,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,42 @@
1
+ import { useMemo } from 'react';
2
+ import { StyleSheet } from 'react-native';
3
+ import { parseStyle, proxifyFunction } from './utils';
4
+ import { useUnistyles } from './useUnistyles';
5
+
6
+ // todo types
7
+
8
+ export const useStyles = stylesheet => {
9
+ const {
10
+ theme,
11
+ breakpoint,
12
+ screenSize
13
+ } = useUnistyles();
14
+ if (!stylesheet) {
15
+ return {
16
+ theme,
17
+ breakpoint,
18
+ styles: {}
19
+ };
20
+ }
21
+ const parsedStyles = useMemo(() => typeof stylesheet === 'function' ? stylesheet(theme) : stylesheet, [theme, stylesheet]);
22
+ const dynamicStyleSheet = useMemo(() => Object.entries(parsedStyles).reduce((acc, _ref) => {
23
+ let [key, value] = _ref;
24
+ const style = value;
25
+ if (typeof value === 'function') {
26
+ return {
27
+ ...acc,
28
+ [key]: proxifyFunction(value, breakpoint, screenSize)
29
+ };
30
+ }
31
+ return StyleSheet.create({
32
+ ...acc,
33
+ [key]: parseStyle(style, breakpoint, screenSize)
34
+ });
35
+ }, {}), [breakpoint, screenSize, parsedStyles]);
36
+ return {
37
+ theme,
38
+ breakpoint,
39
+ styles: dynamicStyleSheet
40
+ };
41
+ };
42
+ //# sourceMappingURL=useStyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMemo","StyleSheet","parseStyle","proxifyFunction","useUnistyles","useStyles","stylesheet","theme","breakpoint","screenSize","styles","parsedStyles","dynamicStyleSheet","Object","entries","reduce","acc","_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AEzD,OAAO;IACHJ,KAAK;IACLC,UAAU;IACVE,MAAM,EAAEE;EACZ,CAAC;AACL,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { NativeEventEmitter, NativeModules } from 'react-native';
2
+ import { useEffect, useState } from 'react';
3
+ import { CxxUnistylesEventTypes } from './types';
4
+ import { unistyles } from './Unistyles';
5
+ const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles);
6
+ export const useUnistyles = () => {
7
+ const [theme, setTheme] = useState(unistyles.runtime.getTheme(unistyles.runtime.themeName));
8
+ const [breakpoint, setBreakpoint] = useState(unistyles.runtime.breakpoint);
9
+ const [screenSize, setScreenSize] = useState({
10
+ width: 0,
11
+ height: 0
12
+ });
13
+ useEffect(() => {
14
+ const subscription = unistylesEvents.addListener('onChange', event => {
15
+ switch (event.type) {
16
+ case CxxUnistylesEventTypes.Theme:
17
+ {
18
+ const themeEvent = event;
19
+ setTheme(unistyles.runtime.getTheme(themeEvent.payload.themeName));
20
+ return;
21
+ }
22
+ // this event is not available on mobile
23
+ case CxxUnistylesEventTypes.Size:
24
+ {
25
+ const sizeEvent = event;
26
+ setScreenSize({
27
+ width: sizeEvent.payload.width,
28
+ height: sizeEvent.payload.height
29
+ });
30
+ return;
31
+ }
32
+ case CxxUnistylesEventTypes.Breakpoint:
33
+ {
34
+ const breakpointEvent = event;
35
+ setBreakpoint(breakpointEvent.payload.breakpoint);
36
+ return;
37
+ }
38
+ default:
39
+ return;
40
+ }
41
+ });
42
+ return subscription.remove;
43
+ }, []);
44
+ return {
45
+ theme,
46
+ breakpoint,
47
+ screenSize
48
+ };
49
+ };
50
+ //# sourceMappingURL=useUnistyles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["NativeEventEmitter","NativeModules","useEffect","useState","CxxUnistylesEventTypes","unistyles","unistylesEvents","Unistyles","useUnistyles","theme","setTheme","runtime","getTheme","themeName","breakpoint","setBreakpoint","screenSize","setScreenSize","width","height","subscription","addListener","event","type","Theme","themeEvent","payload","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,OAAO,CAACP;YAC9B,CAAC,CAAC;YAEF;UACJ;QACA,KAAKf,sBAAsB,CAACyB,UAAU;UAAE;YACpC,MAAMC,eAAe,GAAGR,KAAoC;YAE5DP,aAAa,CAACe,eAAe,CAACJ,OAAO,CAACZ,UAAU,CAAC;YAEjD;UACJ;QACA;UACI;MACR;IACJ,CACJ,CAAC;IAED,OAAOM,YAAY,CAACW,MAAM;EAC9B,CAAC,EAAE,EAAE,CAAC;EAEN,OAAO;IACHtB,KAAK;IACLK,UAAU;IACVE;EACJ,CAAC;AACL,CAAC"}
@@ -1,6 +1,6 @@
1
+ import { unistyles } from '../Unistyles';
1
2
  import { throwError } from './common';
2
3
  import { getKeyForCustomMediaQuery, isMediaQuery } from './mediaQueries';
3
-
4
4
  /**
5
5
  * Sorts the breakpoints object based on its numeric values in ascending order and validates them.
6
6
  *
@@ -90,7 +90,7 @@ export const getBreakpointFromScreenWidth = (width, breakpointEntries) => {
90
90
  *
91
91
  * getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
92
92
  */
93
- export const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointPairs) => {
93
+ export const getValueForBreakpoint = (value, breakpoint, screenSize) => {
94
94
  // the highest priority is for custom media queries
95
95
  const customMediaQueries = Object.entries(value).filter(_ref2 => {
96
96
  let [key] = _ref2;
@@ -102,7 +102,7 @@ export const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointP
102
102
  }
103
103
 
104
104
  // if no custom media query, or didn't match, proceed with defined breakpoints
105
- const unifiedKey = breakpoint.toLowerCase();
105
+ const unifiedKey = breakpoint?.toLowerCase();
106
106
  const directBreakpoint = value[unifiedKey];
107
107
 
108
108
  // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
@@ -111,6 +111,7 @@ export const getValueForBreakpoint = (value, breakpoint, screenSize, breakpointP
111
111
  }
112
112
 
113
113
  // there is no direct hit for breakpoint nor media-query, so let's simulate CSS cascading
114
+ const breakpointPairs = unistyles.runtime.sortedBreakpoints;
114
115
  const currentBreakpoint = breakpointPairs.findIndex(_ref3 => {
115
116
  let [key] = _ref3;
116
117
  return key === unifiedKey;
@@ -1 +1 @@
1
- {"version":3,"names":["throwError","getKeyForCustomMediaQuery","isMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","breakpointPairs","customMediaQueries","filter","_ref2","customMediaQueryKey","unifiedKey","toLowerCase","directBreakpoint","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,UAAU,QAAQ,UAAU;AAErC,SAASC,yBAAyB,EAAEC,YAAY,QAAQ,gBAAgB;;AAExE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAA2BC,WAAc,IAAQ;EACpF,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,OAAOC,MAAM,GAAGC,MAAM;EAC1B,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAM;EAC9E,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAAM,CAACJ,iBAAiB,CAAC;EACzD,MAAM,CAACK,eAAe,CAAC,GAAGF,gBAAgB;EAE1C,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A,EAAC;EACzC,MAAMe,mBAAmB,GAAGvC,yBAAyB,CAACoC,kBAAkB,EAAEF,UAAU,CAAC;EAErF,IAAIK,mBAAmB,IAAIA,mBAAmB,IAAIV,KAAK,EAAE;IACrD,OAAOA,KAAK,CAACU,mBAAmB,CAAC;EACrC;;EAEA;EACA,MAAMC,UAAU,GAAGP,UAAU,CAACQ,WAAW,CAAC,CAAC;EAC3C,MAAMC,gBAAgB,GAAGb,KAAK,CAACW,UAAU,CAAC;;EAE1C;EACA,IAAIE,gBAAgB,IAAKF,UAAU,IAAIX,KAAM,EAAE;IAC3C,OAAOa,gBAAgB;EAC3B;;EAEA;EACA,MAAMC,iBAAiB,GAAGR,eAAe,CACpCS,SAAS,CAACC,KAAA;IAAA,IAAC,CAACrB,GAAG,CAAC,GAAAqB,KAAA;IAAA,OAAKrB,GAAG,KAAKgB,UAAU;EAAA,EAAC;EAE7C,MAAMM,oBAAoB,GAAGX,eAAe,CACvCE,MAAM,CAAC,CAAAU,KAAA,EAAQpB,KAAK;IAAA,IAAZ,CAACH,GAAG,CAAC,GAAAuB,KAAA;IAAA,OAAYpB,KAAK,GAAGgB,iBAAiB,IAAInB,GAAG,IAAIA,GAAG,IAAIK,KAAK;EAAA,EAAC,CAC1EmB,GAAG,CAACC,KAAA;IAAA,IAAC,CAACzB,GAAG,CAAC,GAAAyB,KAAA;IAAA,OAAKzB,GAAG;EAAA,EAAC;EAExB,OAAOW,eAAe,CAACjB,MAAM,GAAG,CAAC,GAC3BW,KAAK,CAACiB,oBAAoB,CAACA,oBAAoB,CAAC5B,MAAM,GAAG,CAAC,CAAC,CAAqB,GAChFgC,SAAS;AACnB,CAAC"}
1
+ {"version":3,"names":["unistyles","throwError","getKeyForCustomMediaQuery","isMediaQuery","sortAndValidateBreakpoints","breakpoints","sortedPairs","Object","entries","sort","breakpoint1","breakpoint2","value1","value2","sortedBreakpoints","freeze","fromEntries","breakpointValues","values","firstBreakpoint","length","Set","size","getBreakpointFromScreenWidth","width","breakpointEntries","key","find","_ref","index","otherBreakpoints","value","minVal","maxVal","getValueForBreakpoint","breakpoint","screenSize","customMediaQueries","filter","_ref2","customMediaQueryKey","unifiedKey","toLowerCase","directBreakpoint","breakpointPairs","runtime","currentBreakpoint","findIndex","_ref3","availableBreakpoints","_ref4","map","_ref5","undefined"],"sourceRoot":"../../../src","sources":["utils/breakpoints.ts"],"mappings":"AAAA,SAASA,SAAS,QAAQ,cAAc;AACxC,SAASC,UAAU,QAAQ,UAAU;AAErC,SAASC,yBAAyB,EAAEC,YAAY,QAAQ,gBAAgB;AAGxE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,0BAA0B,GAAIC,WAAiC,IAA2B;EACnG,MAAMC,WAAW,GAAGC,MAAM,CACrBC,OAAO,CAACH,WAAW,CAAC,CACpBI,IAAI,CAAC,CAACC,WAAW,EAAEC,WAAW,KAAK;IAChC,MAAM,GAAGC,MAAM,CAAC,GAAGF,WAAW;IAC9B,MAAM,GAAGG,MAAM,CAAC,GAAGF,WAAW;IAE9B,OAAQC,MAAM,GAAeC,MAAiB;EAClD,CAAC,CAAC;EAEN,MAAMC,iBAAiB,GAAIP,MAAM,CAACQ,MAAM,CAACR,MAAM,CAACS,WAAW,CAACV,WAAW,CAAC,CAAyB;EACjG,MAAMW,gBAAgB,GAAGV,MAAM,CAACW,MAAM,CAACJ,iBAAiB,CAAC;EACzD,MAAM,CAACK,eAAe,CAAC,GAAGF,gBAAgB;EAE1C,IAAIE,eAAe,KAAK,CAAC,EAAE;IACvBlB,UAAU,CAAC,oCAAoC,CAAC;EACpD;EAEA,IAAIgB,gBAAgB,CAACG,MAAM,KAAK,IAAIC,GAAG,CAACJ,gBAAgB,CAAC,CAACK,IAAI,EAAE;IAC5DrB,UAAU,CAAC,kCAAkC,CAAC;EAClD;EAEA,OAAOa,iBAAiB;AAC5B,CAAC;;AAED;AACA;AACA;A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KAAK,CAACU,UAAU,CAAC;;EAE1C;EACA,IAAIE,gBAAgB,IAAKF,UAAU,IAAIV,KAAM,EAAE;IAC3C,OAAOY,gBAAgB;EAC3B;;EAEA;EACA,MAAMC,eAAe,GAAG5C,SAAS,CAAC6C,OAAO,CAAC/B,iBAAiB;EAC3D,MAAMgC,iBAAiB,GAAGF,eAAe,CACpCG,SAAS,CAACC,KAAA;IAAA,IAAC,CAACtB,GAAG,CAAC,GAAAsB,KAAA;IAAA,OAAKtB,GAAG,KAAKe,UAAU;EAAA,EAAC;EAE7C,MAAMQ,oBAAoB,GAAGL,eAAe,CACvCN,MAAM,CAAC,CAAAY,KAAA,EAAQrB,KAAK;IAAA,IAAZ,CAACH,GAAG,CAAC,GAAAwB,KAAA;IAAA,OAAYrB,KAAK,GAAGiB,iBAAiB,IAAIpB,GAAG,IAAIA,GAAG,IAAIK,KAAK;EAAA,EAAC,CAC1EoB,GAAG,CAACC,KAAA;IAAA,IAAC,CAAC1B,GAAG,CAAC,GAAA0B,KAAA;IAAA,OAAK1B,GAAG;EAAA,EAAC;EAExB,OAAOkB,eAAe,CAACxB,MAAM,GAAG,CAAC,GAC3BW,KAAK,CAACkB,oBAAoB,CAACA,oBAAoB,CAAC7B,MAAM,GAAG,CAAC,CAAC,CAAwC,GACnGiC,SAAS;AACnB,CAAC"}
@@ -5,5 +5,6 @@ export const throwError = message => {
5
5
  export const warn = message => {
6
6
  console.warn(`🦄 [react-native-unistyles]: ${message}`);
7
7
  };
8
- export const isWeb = () => Platform.OS === 'web';
8
+ export const isWeb = Platform.OS === 'web';
9
+ export const isServer = typeof window === 'undefined';
9
10
  //# sourceMappingURL=common.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Platform","throwError","message","Error","warn","console","isWeb","OS"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,KAAK,GAAGA,CAAA,KAAMN,QAAQ,CAACO,EAAE,KAAK,KAAK"}
1
+ {"version":3,"names":["Platform","throwError","message","Error","warn","console","isWeb","OS","isServer","window"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,KAAK,GAAGN,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMC,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW"}