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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (182) hide show
  1. package/cxx/UnistylesRuntime.cpp +55 -1
  2. package/cxx/UnistylesRuntime.h +10 -4
  3. package/ios/UnistylesModule.mm +12 -2
  4. package/lib/commonjs/common.js +19 -6
  5. package/lib/commonjs/common.js.map +1 -1
  6. package/lib/commonjs/core/UnistyleRegistry.js +49 -1
  7. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  8. package/lib/commonjs/core/UnistylesRuntime.js +12 -16
  9. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  10. package/lib/commonjs/hooks/useUnistyles.js +8 -2
  11. package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/plugins/index.js +45 -0
  14. package/lib/commonjs/plugins/index.js.map +1 -0
  15. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
  16. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
  17. package/lib/commonjs/plugins/normalizer/index.js +32 -0
  18. package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
  19. package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
  20. package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
  21. package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
  22. package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
  23. package/lib/commonjs/plugins/withPlugins.js +18 -0
  24. package/lib/commonjs/plugins/withPlugins.js.map +1 -0
  25. package/lib/commonjs/types/plugin.js +6 -0
  26. package/lib/{module/utils/module.d.js.map → commonjs/types/plugin.js.map} +1 -1
  27. package/lib/commonjs/types/variants.js +2 -0
  28. package/lib/commonjs/{utils/module.d.js.map → types/variants.js.map} +1 -1
  29. package/lib/commonjs/useStyles.js +5 -4
  30. package/lib/commonjs/useStyles.js.map +1 -1
  31. package/lib/commonjs/utils/breakpoints.js +15 -70
  32. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  33. package/lib/commonjs/utils/index.js +12 -52
  34. package/lib/commonjs/utils/index.js.map +1 -1
  35. package/lib/commonjs/utils/mq.js +1 -1
  36. package/lib/commonjs/utils/mq.js.map +1 -1
  37. package/lib/commonjs/utils/mqParser.js +4 -1
  38. package/lib/commonjs/utils/mqParser.js.map +1 -1
  39. package/lib/commonjs/utils/styles.js +22 -11
  40. package/lib/commonjs/utils/styles.js.map +1 -1
  41. package/lib/commonjs/utils/variants.js +2 -5
  42. package/lib/commonjs/utils/variants.js.map +1 -1
  43. package/lib/module/common.js +17 -7
  44. package/lib/module/common.js.map +1 -1
  45. package/lib/module/core/UnistyleRegistry.js +49 -1
  46. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  47. package/lib/module/core/UnistylesRuntime.js +12 -16
  48. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  49. package/lib/module/hooks/useUnistyles.js +8 -2
  50. package/lib/module/hooks/useUnistyles.js.map +1 -1
  51. package/lib/module/index.js.map +1 -1
  52. package/lib/module/plugins/index.js +4 -0
  53. package/lib/module/plugins/index.js.map +1 -0
  54. package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
  55. package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
  56. package/lib/module/plugins/normalizer/index.js +3 -0
  57. package/lib/module/plugins/normalizer/index.js.map +1 -0
  58. package/lib/module/plugins/normalizer/module.d.js.map +1 -0
  59. package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
  60. package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
  61. package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
  62. package/lib/module/plugins/withPlugins.js +11 -0
  63. package/lib/module/plugins/withPlugins.js.map +1 -0
  64. package/lib/module/types/plugin.js +2 -0
  65. package/lib/module/types/plugin.js.map +1 -0
  66. package/lib/module/types/variants.js +2 -0
  67. package/lib/module/types/variants.js.map +1 -0
  68. package/lib/module/useStyles.js +5 -4
  69. package/lib/module/useStyles.js.map +1 -1
  70. package/lib/module/utils/breakpoints.js +13 -66
  71. package/lib/module/utils/breakpoints.js.map +1 -1
  72. package/lib/module/utils/index.js +2 -5
  73. package/lib/module/utils/index.js.map +1 -1
  74. package/lib/module/utils/mq.js +1 -1
  75. package/lib/module/utils/mq.js.map +1 -1
  76. package/lib/module/utils/mqParser.js +3 -3
  77. package/lib/module/utils/mqParser.js.map +1 -1
  78. package/lib/module/utils/styles.js +23 -12
  79. package/lib/module/utils/styles.js.map +1 -1
  80. package/lib/module/utils/variants.js +2 -5
  81. package/lib/module/utils/variants.js.map +1 -1
  82. package/lib/typescript/src/common.d.ts +16 -6
  83. package/lib/typescript/src/common.d.ts.map +1 -1
  84. package/lib/typescript/src/core/UnistyleRegistry.d.ts +7 -2
  85. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
  86. package/lib/typescript/src/core/UnistylesRuntime.d.ts +7 -8
  87. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  88. package/lib/typescript/src/core/index.d.ts +1 -0
  89. package/lib/typescript/src/core/index.d.ts.map +1 -1
  90. package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
  91. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
  92. package/lib/typescript/src/index.d.ts +4 -3
  93. package/lib/typescript/src/index.d.ts.map +1 -1
  94. package/lib/typescript/src/plugins/index.d.ts +4 -0
  95. package/lib/typescript/src/plugins/index.d.ts.map +1 -0
  96. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
  97. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
  98. package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
  99. package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
  100. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
  101. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
  102. package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
  103. package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
  104. package/lib/typescript/src/plugins/withPlugins.d.ts +3 -0
  105. package/lib/typescript/src/plugins/withPlugins.d.ts.map +1 -0
  106. package/lib/typescript/src/types/breakpoints.d.ts +3 -4
  107. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  108. package/lib/typescript/src/types/core.d.ts +4 -9
  109. package/lib/typescript/src/types/core.d.ts.map +1 -1
  110. package/lib/typescript/src/types/index.d.ts +3 -1
  111. package/lib/typescript/src/types/index.d.ts.map +1 -1
  112. package/lib/typescript/src/types/plugin.d.ts +7 -0
  113. package/lib/typescript/src/types/plugin.d.ts.map +1 -0
  114. package/lib/typescript/src/types/unistyles.d.ts +11 -2
  115. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  116. package/lib/typescript/src/types/variants.d.ts +8 -0
  117. package/lib/typescript/src/types/variants.d.ts.map +1 -0
  118. package/lib/typescript/src/useStyles.d.ts +2 -2
  119. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  120. package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
  121. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  122. package/lib/typescript/src/utils/index.d.ts +2 -5
  123. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  124. package/lib/typescript/src/utils/mqParser.d.ts +12 -0
  125. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
  126. package/lib/typescript/src/utils/styles.d.ts +3 -3
  127. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  128. package/lib/typescript/src/utils/variants.d.ts +1 -1
  129. package/lib/typescript/src/utils/variants.d.ts.map +1 -1
  130. package/package.json +4 -1
  131. package/src/__tests__/mocks.ts +24 -0
  132. package/src/common.ts +22 -7
  133. package/src/core/UnistyleRegistry.ts +46 -2
  134. package/src/core/UnistylesRuntime.ts +14 -20
  135. package/src/core/index.ts +1 -0
  136. package/src/hooks/useUnistyles.ts +7 -2
  137. package/src/index.ts +3 -1
  138. package/src/plugins/index.ts +3 -0
  139. package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
  140. package/src/plugins/normalizer/index.ts +2 -0
  141. package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
  142. package/src/{utils → plugins/normalizer}/normalizer.ts +1 -1
  143. package/src/plugins/withPlugins.ts +17 -0
  144. package/src/types/breakpoints.ts +5 -4
  145. package/src/types/core.ts +5 -10
  146. package/src/types/index.ts +12 -1
  147. package/src/types/plugin.ts +7 -0
  148. package/src/types/unistyles.ts +14 -4
  149. package/src/types/variants.ts +11 -0
  150. package/src/useStyles.ts +12 -6
  151. package/src/utils/breakpoints.ts +10 -75
  152. package/src/utils/index.ts +2 -5
  153. package/src/utils/mq.ts +1 -1
  154. package/src/utils/mqParser.ts +4 -4
  155. package/src/utils/styles.ts +35 -20
  156. package/src/utils/variants.ts +5 -9
  157. package/lib/commonjs/utils/common.js +0 -25
  158. package/lib/commonjs/utils/common.js.map +0 -1
  159. package/lib/commonjs/utils/normalizeStyles.js +0 -10
  160. package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
  161. package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
  162. package/lib/commonjs/utils/normalizer.js.map +0 -1
  163. package/lib/module/utils/common.js +0 -17
  164. package/lib/module/utils/common.js.map +0 -1
  165. package/lib/module/utils/normalizeStyles.js +0 -3
  166. package/lib/module/utils/normalizeStyles.js.map +0 -1
  167. package/lib/module/utils/normalizeStyles.web.js.map +0 -1
  168. package/lib/module/utils/normalizer.js.map +0 -1
  169. package/lib/typescript/src/utils/common.d.ts +0 -12
  170. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  171. package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
  172. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
  173. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
  174. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
  175. package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
  176. package/src/utils/common.ts +0 -20
  177. package/src/utils/normalizeStyles.ts +0 -2
  178. /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
  179. /package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +0 -0
  180. /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
  181. /package/lib/module/{utils → plugins/normalizer}/normalizer.js +0 -0
  182. /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -1,6 +1,17 @@
1
+ export declare const warn: (message: string) => void;
2
+ export declare const isMobile: boolean;
3
+ export declare const isWeb: boolean;
4
+ export declare const isIOS: boolean;
5
+ export declare const isAndroid: boolean;
6
+ export declare const isServer: boolean;
7
+ export declare const ScreenOrientation: {
8
+ readonly Landscape: "landscape";
9
+ readonly Portrait: "portrait";
10
+ };
1
11
  export declare enum CxxUnistylesEventTypes {
2
12
  Theme = "theme",
3
- Layout = "layout"
13
+ Layout = "layout",
14
+ Plugin = "plugin"
4
15
  }
5
16
  export declare enum UnistylesError {
6
17
  RuntimeUnavailable = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE",
@@ -8,10 +19,9 @@ export declare enum UnistylesError {
8
19
  ThemeNotRegistered = "UNISTYLES_ERROR_THEME_NOT_REGISTERED",
9
20
  ThemesCannotBeEmpty = "UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY",
10
21
  BreakpointsCannotBeEmpty = "UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY",
11
- BreakpointsMustStartFromZero = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO"
12
- }
13
- export declare enum ScreenOrientation {
14
- Portrait = 1,
15
- Landscape = 2
22
+ BreakpointsMustStartFromZero = "UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO",
23
+ InvalidPluginName = "UNISTYLES_ERROR_INVALID_PLUGIN_NAME",
24
+ DuplicatePluginName = "UNISTYLES_ERROR_DUPLICATE_PLUGIN_NAME",
25
+ CantRemoveInternalPlugin = "UNISTYLES_ERROR_CANT_REMOVE_INTERNAL_PLUGIN"
16
26
  }
17
27
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAAA,oBAAY,sBAAsB;IAC9B,KAAK,UAAU;IACf,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,wCAAwC;IAC1D,aAAa,oCAAoC;IACjD,kBAAkB,yCAAyC;IAC3D,mBAAmB,2CAA2C;IAC9D,wBAAwB,gDAAgD;IACxE,4BAA4B,qDAAqD;CACpF;AAGD,oBAAY,iBAAiB;IACzB,QAAQ,IAAI;IACZ,SAAS,IAAI;CAChB"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,SAAqD,CAAA;AAC1E,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,SAAS,SAA4B,CAAA;AAClD,eAAO,MAAM,QAAQ,SAAgC,CAAA;AAErD,eAAO,MAAM,iBAAiB;;;CAGpB,CAAA;AAEV,oBAAY,sBAAsB;IAC9B,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CACpB;AAED,oBAAY,cAAc;IACtB,kBAAkB,wCAAwC;IAC1D,aAAa,oCAAoC;IACjD,kBAAkB,yCAAyC;IAC3D,mBAAmB,2CAA2C;IAC9D,wBAAwB,gDAAgD;IACxE,4BAA4B,qDAAqD;IACjF,iBAAiB,wCAAwC;IACzD,mBAAmB,0CAA0C;IAC7D,wBAAwB,gDAAgD;CAC3E"}
@@ -1,8 +1,9 @@
1
- import type { UnistylesBridge, UnistylesConfig } from '../types';
1
+ import type { UnistylesBridge, UnistylesConfig, UnistylesPlugin } from '../types';
2
2
  import type { UnistylesBreakpoints, UnistylesThemes } from '../global';
3
3
  export declare class UnistyleRegistry {
4
4
  private unistylesBridge;
5
5
  config: UnistylesConfig;
6
+ plugins: Array<UnistylesPlugin>;
6
7
  themeNames: Array<keyof UnistylesThemes>;
7
8
  themes: UnistylesThemes;
8
9
  breakpoints: UnistylesBreakpoints;
@@ -10,6 +11,10 @@ export declare class UnistyleRegistry {
10
11
  constructor(unistylesBridge: UnistylesBridge);
11
12
  addThemes: (themes: UnistylesThemes) => this;
12
13
  addBreakpoints: (breakpoints: UnistylesBreakpoints) => this;
13
- addConfig: (config: UnistylesConfig) => this;
14
+ addConfig: (config: UnistylesConfig) => void;
15
+ getTheme: (forName: keyof UnistylesThemes) => never;
16
+ addPlugin: (plugin: UnistylesPlugin, notify?: boolean) => void;
17
+ removePlugin: (plugin: UnistylesPlugin) => void;
18
+ hasTheme: (name: keyof UnistylesThemes) => boolean;
14
19
  }
15
20
  //# sourceMappingURL=UnistyleRegistry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAChE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAEtE,qBAAa,gBAAgB;IAOb,OAAO,CAAC,eAAe;IAN5B,MAAM,EAAE,eAAe,CAAK;IAC5B,UAAU,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAK;IAC7C,MAAM,EAAE,eAAe,CAAwB;IAC/C,WAAW,EAAE,oBAAoB,CAA6B;IAC9D,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAK;gBAEpG,eAAe,EAAE,eAAe;IAE7C,SAAS,WAAY,eAAe,UAS1C;IAEM,cAAc,gBAAiB,oBAAoB,UAMzD;IAEM,SAAS,WAAY,eAAe,UAQ1C;CACJ"}
1
+ {"version":3,"file":"UnistyleRegistry.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistyleRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AACjF,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAGtE,qBAAa,gBAAgB;IAQb,OAAO,CAAC,eAAe;IAP5B,MAAM,EAAE,eAAe,CAAK;IAC5B,OAAO,EAAE,KAAK,CAAC,eAAe,CAAC,CAAK;IACpC,UAAU,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAK;IAC7C,MAAM,EAAE,eAAe,CAAwB;IAC/C,WAAW,EAAE,oBAAoB,CAA6B;IAC9D,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAK;gBAEpG,eAAe,EAAE,eAAe;IAE7C,SAAS,WAAY,eAAe,UAS1C;IAEM,cAAc,gBAAiB,oBAAoB,UAMzD;IAEM,SAAS,WAAY,eAAe,UAc1C;IAEM,QAAQ,YAAa,MAAM,eAAe,WAUhD;IAEM,SAAS,WAAY,eAAe,WAAU,OAAO,UAW3D;IAEM,YAAY,WAAY,eAAe,UAO7C;IAEM,QAAQ,SAAU,MAAM,eAAe,aAAwB;CACzE"}
@@ -1,24 +1,23 @@
1
- import { ScreenOrientation } from '../common';
2
- import type { UnistylesBridge } from '../types';
1
+ import type { UnistylesBridge, UnistylesPlugin } from '../types';
3
2
  import type { UnistylesThemes } from '../global';
4
3
  import type { UnistyleRegistry } from './UnistyleRegistry';
5
4
  export declare class UnistylesRuntime {
6
5
  private unistylesBridge;
7
- private registry;
8
- constructor(unistylesBridge: UnistylesBridge, registry: UnistyleRegistry);
6
+ private unistylesRegistry;
7
+ constructor(unistylesBridge: UnistylesBridge, unistylesRegistry: UnistyleRegistry);
9
8
  get colorScheme(): import("../types").ColorSchemeName;
10
9
  get hasAdaptiveThemes(): boolean;
11
- get sortedBreakpoints(): [keyof import("../global").UnistylesBreakpoints, number | undefined][];
12
10
  get themeName(): never;
13
11
  get breakpoint(): keyof import("../global").UnistylesBreakpoints;
12
+ get enabledPlugins(): string[];
14
13
  get screen(): {
15
14
  width: number;
16
15
  height: number;
17
16
  };
18
- get orientation(): ScreenOrientation;
17
+ get orientation(): "landscape" | "portrait";
19
18
  setTheme: (name: keyof UnistylesThemes) => boolean;
20
- getTheme: (forName: keyof UnistylesThemes) => never;
21
19
  setAdaptiveThemes: (enable: boolean) => void;
22
- private hasTheme;
20
+ addPlugin: (plugin: UnistylesPlugin) => void;
21
+ removePlugin: (plugin: UnistylesPlugin) => void;
23
22
  }
24
23
  //# sourceMappingURL=UnistylesRuntime.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"UnistylesRuntime.d.ts","sourceRoot":"","sources":["../../../../src/core/UnistylesRuntime.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAkB,MAAM,WAAW,CAAA;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/C,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,QAAQ;gBAAlD,eAAe,EAAE,eAAe,EAAU,QAAQ,EAAE,gBAAgB;IAExF,IAAW,WAAW,uCAErB;IAED,IAAW,iBAAiB,YAE3B;IAED,IAAW,iBAAiB,2EAE3B;IAED,IAAW,SAAS,UAEnB;IAED,IAAW,UAAU,mDAEpB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,sBAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,aAQ7C;IAEM,QAAQ,YAAa,MAAM,eAAe,WAUhD;IAEM,iBAAiB,WAAY,OAAO,UAE1C;IAED,OAAO,CAAC,QAAQ,CAAgE;CACnF"}
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,cAAc,aAExB;IAED,IAAW,MAAM;;;MAKhB;IAED,IAAW,WAAW,6BAQrB;IAEM,QAAQ,SAAU,MAAM,eAAe,aAQ7C;IAEM,iBAAiB,WAAY,OAAO,UAE1C;IAEM,SAAS,WAAY,eAAe,UAE1C;IAEM,YAAY,WAAY,eAAe,UAE7C;CACJ"}
@@ -1,2 +1,3 @@
1
1
  export { unistyles } from './Unistyles';
2
+ export type { UnistylesRuntime } from './UnistylesRuntime';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AACvC,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA"}
@@ -1,8 +1,9 @@
1
1
  export declare const useUnistyles: () => {
2
+ plugins: string[];
2
3
  theme: never;
3
4
  layout: {
4
5
  breakpoint: keyof import("..").UnistylesBreakpoints;
5
- orientation: import("../common").ScreenOrientation;
6
+ orientation: "landscape" | "portrait";
6
7
  screenSize: {
7
8
  width: number;
8
9
  height: number;
@@ -1 +1 @@
1
- {"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;CA8CxB,CAAA"}
1
+ {"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../../src/hooks/useUnistyles.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,YAAY;;;;;;;;;;;CAmDxB,CAAA"}
@@ -1,5 +1,6 @@
1
1
  import { mq } from './utils';
2
2
  import { useInitialTheme } from './hooks';
3
+ import type { UnistylesPlugin } from './types';
3
4
  import type { UnistylesThemes, UnistylesBreakpoints } from './global';
4
5
  import { ScreenOrientation } from './common';
5
6
  import { useStyles } from './useStyles';
@@ -7,9 +8,9 @@ import { createStyleSheet } from './createStyleSheet';
7
8
  declare const UnistylesRegistry: {
8
9
  addThemes: (themes: UnistylesThemes) => import("./core/UnistyleRegistry").UnistyleRegistry;
9
10
  addBreakpoints: (breakpoints: UnistylesBreakpoints) => import("./core/UnistyleRegistry").UnistyleRegistry;
10
- addConfig: (config: import("./types").UnistylesConfig) => import("./core/UnistyleRegistry").UnistyleRegistry;
11
+ addConfig: (config: import("./types").UnistylesConfig) => void;
11
12
  };
12
- declare const UnistylesRuntime: import("./core/UnistylesRuntime").UnistylesRuntime;
13
+ declare const UnistylesRuntime: import("./core").UnistylesRuntime;
13
14
  export { mq, useStyles, useInitialTheme, createStyleSheet, ScreenOrientation, UnistylesRegistry, UnistylesRuntime };
14
- export type { UnistylesThemes, UnistylesBreakpoints };
15
+ export type { UnistylesThemes, UnistylesBreakpoints, UnistylesPlugin };
15
16
  //# sourceMappingURL=index.d.ts.map
@@ -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,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,oDAAoB,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,EACvB,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,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"}
@@ -0,0 +1,4 @@
1
+ export { normalizeWebStylesPlugin } from './normalizeWebStylesPlugin';
2
+ export { preprocessor, normalizeNumericValue, normalizeColor, normalizeStyle } from './normalizer';
3
+ export { withPlugins } from './withPlugins';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAClG,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { UnistylesPlugin } from '../types';
2
+ export declare const normalizeWebStylesPlugin: UnistylesPlugin;
3
+ //# sourceMappingURL=normalizeWebStylesPlugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeWebStylesPlugin.d.ts","sourceRoot":"","sources":["../../../../src/plugins/normalizeWebStylesPlugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAG/C,eAAO,MAAM,wBAAwB,EAAE,eAGtC,CAAA"}
@@ -0,0 +1,3 @@
1
+ export { normalizeStyle } from './normalizeStyle';
2
+ export { preprocessor, normalizeNumericValue, normalizeColor } from './normalizer';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/normalizer/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { RNStyle } from '../../types';
2
+ export declare const normalizeStyle: <T extends RNStyle>(style: T) => T;
3
+ //# sourceMappingURL=normalizeStyle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeStyle.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/normalizer/normalizeStyle.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoE,OAAO,EAAE,MAAM,aAAa,CAAA;AAuD5G,eAAO,MAAM,cAAc,oCAwB1B,CAAA"}
@@ -1,4 +1,4 @@
1
- import type { TextShadow, Transforms, BoxShadow } from '../types';
1
+ import type { TextShadow, Transforms, BoxShadow } from '../../types';
2
2
  type Preprocessor = {
3
3
  createTextShadowValue(style: TextShadow): string;
4
4
  createBoxShadowValue(style: Required<BoxShadow>): string;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../../../src/plugins/normalizer/normalizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAEpE,KAAK,YAAY,GAAG;IAChB,qBAAqB,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAAC;IACjD,oBAAoB,CAAC,KAAK,EAAE,QAAQ,CAAC,SAAS,CAAC,GAAG,MAAM,CAAC;IACzD,oBAAoB,CAAC,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,GAAG,MAAM,CAAC;CAClE,CAAA;AAED,eAAO,MAAM,cAAc,UAAW,MAAM,YAAW,MAAM,WAyB5D,CAAA;AAED,eAAO,MAAM,qBAAqB,UAAW,MAAM,oBAAiC,CAAA;AAwDpF,eAAO,MAAM,YAAY,EAAE,YAI1B,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { RNStyle } from '../types';
2
+ export declare const withPlugins: (key: string, style: RNStyle) => RNStyle;
3
+ //# sourceMappingURL=withPlugins.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withPlugins.d.ts","sourceRoot":"","sources":["../../../../src/plugins/withPlugins.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AASvC,eAAO,MAAM,WAAW,QAAS,MAAM,SAAS,OAAO,YAO1C,CAAA"}
@@ -1,15 +1,14 @@
1
1
  import type { OpaqueColorValue } from 'react-native';
2
2
  import type { UnistylesBreakpoints } from '../global';
3
3
  import type { MediaQuery } from './mq';
4
- import type { VariantValue } from './core';
5
4
  type WithEmptyObject<V> = keyof V extends never ? {} : V;
6
5
  type ExtractBreakpoints<T> = T extends Partial<Record<keyof UnistylesBreakpoints & string, infer V>> ? WithEmptyObject<V> : T extends (...args: infer A) => infer R ? (...args: A) => ExtractBreakpoints<R> : {
7
6
  [K in keyof T]: T[K] extends (...args: infer A) => infer R ? (...args: A) => ExtractBreakpoints<R> : T[K] extends object ? ExtractBreakpoints<T[K]> : T[K];
8
7
  };
9
- type FlattenObjectTypes<T> = T[keyof T];
8
+ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
10
9
  type RemoveKeysWithPrefix<T> = T extends (...args: Array<any>) => infer R ? (...args: Parameters<T>) => RemoveKeysWithPrefix<R> : T extends object ? T extends OpaqueColorValue ? string : T extends Record<string, infer _V> ? T extends {
11
- variants: VariantValue;
12
- } ? RemoveKeysWithPrefix<FlattenObjectTypes<T['variants']>> : {
10
+ variants: infer _V;
11
+ } ? Omit<T, 'variants'> & UnionToIntersection<_V[keyof _V]> : {
13
12
  [K in keyof T as K extends MediaQuery ? keyof UnistylesBreakpoints & string : K]: RemoveKeysWithPrefix<T[K]>;
14
13
  } : {
15
14
  [K in keyof T]: RemoveKeysWithPrefix<T[K]>;
@@ -1 +1 @@
1
- {"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/types/breakpoints.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AACpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAA;AAE1C,KAAK,eAAe,CAAC,CAAC,IAAI,MAAM,CAAC,SAAS,KAAK,GAAG,EAAE,GAAG,CAAC,CAAA;AAExD,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,SAAS,OAAO,CAAC,MAAM,CAAC,MAAM,oBAAoB,GAAG,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,GAC9F,eAAe,CAAC,CAAC,CAAC,GAClB,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GACnC,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,GACrC;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,MAAM,CAAC,GACpD,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,kBAAkB,CAAC,CAAC,CAAC,GACrC,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,GACf,kBAAkB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GACxB,CAAC,CAAC,CAAC,CAAC;CACjB,CAAA;AAET,KAAK,kBAAkB,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,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EAAE,CAAC,MAAM,EAAE,CAAC,CAAC,GACvD;KAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,SAAS,UAAU,GAAG,MAAM,oBAAoB,GAAG,MAAM,GAAG,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACpH;KAAG,CAAC,IAAI,MAAM,CAAC,GAAG,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAAE,GACtD,CAAC,CAAA;AAEX,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI,kBAAkB,CAAC,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAA"}
@@ -15,15 +15,12 @@ type UnistyleNested = {
15
15
  shadowOffset?: DeepUniStyle<ShadowOffset>;
16
16
  textShadowOffset?: DeepUniStyle<ShadowOffset>;
17
17
  transform?: Array<DeepUniStyle<TransformStyles>>;
18
+ variants?: Record<string, UnistyleView | UnistyleText | UnistyleImage & Omit<UnistyleNested, 'variants'>>;
18
19
  };
19
20
  type UniStyle<V> = {
20
21
  [innerKey in keyof UnistylesBreakpoints]?: V;
21
22
  } | {
22
23
  [innerKey in MediaQuery]: V;
23
- } | {
24
- [innerKey in 'variants']?: {
25
- [variant: string]: V;
26
- };
27
24
  };
28
25
  type DeepUniStyle<T> = {
29
26
  [K in keyof T]?: UniStyle<T[K]> | T[K];
@@ -36,12 +33,10 @@ export type StaticStyles = UnistyleView | UnistyleText | UnistyleImage & Unistyl
36
33
  export type CustomNamedStyles<T> = {
37
34
  [K in keyof T]: T[K] extends (...args: infer A) => StaticStyles ? (...args: A) => StaticStyles : StaticStyles;
38
35
  };
36
+ export type RNStyle = ViewStyle | TextStyle | ImageStyle;
39
37
  export type RNValue = number | string | undefined;
40
- export type VariantValue = Record<string, RNValue>;
41
- export type NestedStyle = Record<keyof UnistylesBreakpoints | MediaQuery | 'variants', RNValue> & {
42
- variants: VariantValue;
43
- };
44
- export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | MediaQuery | 'variants', RNValue | VariantValue]>;
38
+ export type NestedStyle = Record<keyof UnistylesBreakpoints | MediaQuery, RNValue>;
39
+ export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | MediaQuery, RNValue]>;
45
40
  export type UnistylesTheme = UnistylesThemes[keyof UnistylesThemes];
46
41
  export type CreateStylesFactory<ST, Theme> = (theme: Theme) => ST;
47
42
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACR,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,gBAAgB,EAChB,gBAAgB,EAChB,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,eAAe,EACf,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACtB,MAAM,mDAAmD,CAAA;AAC1D,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACpE,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAEtC,KAAK,YAAY,GAAG;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,MAAM,MAAM,UAAU,GAAG;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAA;CACjB,CAAA;AAED,KAAK,eAAe,GACd,mBAAmB,GACnB,eAAe,GACf,gBAAgB,GAChB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,eAAe,GACf,mBAAmB,GACnB,mBAAmB,GACnB,cAAc,GACd,cAAc,GACd,eAAe,CAAA;AAErB,KAAK,cAAc,GAAG;IAClB,YAAY,CAAC,EAAE,YAAY,CAAC,YAAY,CAAC,CAAC;IAC1C,gBAAgB,CAAC,EAAE,YAAY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AEpB,MAAM,MAAM,iBAAiB,CAAC,CAAC,IAAI;KAC9B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,MAAM,CAAC,KAAK,YAAY,GACzD,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,YAAY,GAC5B,YAAY;CACrB,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,SAAS,GAAG,SAAS,GAAG,UAAU,CAAA;AACxD,MAAM,MAAM,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;AACjD,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,oBAAoB,GAAG,UAAU,EAAE,OAAO,CAAC,CAAA;AAClF,MAAM,MAAM,gBAAgB,GAAG,KAAK,CAAC,CAAC,MAAM,oBAAoB,GAAG,UAAU,EAAE,OAAO,CAAC,CAAC,CAAA;AACxF,MAAM,MAAM,cAAc,GAAG,eAAe,CAAC,MAAM,eAAe,CAAC,CAAA;AACnE,MAAM,MAAM,mBAAmB,CAAC,EAAE,EAAE,KAAK,IAAI,CAAC,KAAK,EAAE,KAAK,KAAK,EAAE,CAAA"}
@@ -2,6 +2,8 @@ export * from './normalizer';
2
2
  export * from './unistyles';
3
3
  export type { Optional, Nullable } from './common';
4
4
  export type { MediaQuery } from './mq';
5
- export type { CustomNamedStyles, NestedStylePairs, UnistylesTheme, CreateStylesFactory, ScreenSize, NestedStyle, RNValue } from './core';
5
+ export type { CustomNamedStyles, NestedStylePairs, UnistylesTheme, CreateStylesFactory, ScreenSize, NestedStyle, RNValue, RNStyle } from './core';
6
6
  export type { ReactNativeStyleSheet } from './breakpoints';
7
+ export type { ExtractVariantNames } from './variants';
8
+ export type { UnistylesPlugin } from './plugin';
7
9
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACtC,YAAY,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,cAAc,EAAE,mBAAmB,EAAE,UAAU,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACxI,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,aAAa,CAAA;AAC3B,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAClD,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AACtC,YAAY,EACR,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,mBAAmB,EACnB,UAAU,EACV,WAAW,EACX,OAAO,EACP,OAAO,EACV,MAAM,QAAQ,CAAA;AACf,YAAY,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAA;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA"}
@@ -0,0 +1,7 @@
1
+ import type { RNStyle } from './core';
2
+ import type { UnistylesRuntime } from '../core';
3
+ export type UnistylesPlugin = {
4
+ name: string;
5
+ onParsedStyle?: (styleKey: string, style: RNStyle, runtime: UnistylesRuntime) => RNStyle;
6
+ };
7
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../../src/types/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAA;AACrC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAE/C,MAAM,MAAM,eAAe,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,gBAAgB,KAAK,OAAO,CAAA;CAC3F,CAAA"}
@@ -2,13 +2,17 @@ import { CxxUnistylesEventTypes, ScreenOrientation } from '../common';
2
2
  import type { UnistylesThemes, UnistylesBreakpoints } from '../global';
3
3
  import type { ScreenSize } from './core';
4
4
  import type { Optional } from './common';
5
+ import type { UnistylesPlugin } from './plugin';
5
6
  export type ColorSchemeName = Optional<'light' | 'dark'>;
6
7
  export type UnistylesConfig = {
7
8
  adaptiveThemes?: boolean;
9
+ experimentalPlugins?: Array<UnistylesPlugin>;
10
+ initialTheme?: keyof UnistylesThemes;
8
11
  };
9
12
  export type UnistylesBridge = {
10
13
  screenWidth: number;
11
14
  screenHeight: number;
15
+ enabledPlugins: Array<string>;
12
16
  hasAdaptiveThemes: boolean;
13
17
  themeName: keyof UnistylesThemes;
14
18
  breakpoint: keyof UnistylesBreakpoints;
@@ -18,6 +22,8 @@ export type UnistylesBridge = {
18
22
  useBreakpoints(breakpoints: UnistylesBreakpoints): void;
19
23
  useTheme(name: keyof UnistylesThemes): void;
20
24
  useAdaptiveThemes(enable: boolean): void;
25
+ addPlugin(pluginName: string, notify: boolean): void;
26
+ removePlugin(pluginName: string): void;
21
27
  };
22
28
  export type UnistylesThemeEvent = {
23
29
  type: CxxUnistylesEventTypes.Theme;
@@ -30,8 +36,11 @@ export type UnistylesMobileLayoutEvent = {
30
36
  payload: {
31
37
  screen: ScreenSize;
32
38
  breakpoint: keyof UnistylesBreakpoints;
33
- orientation: ScreenOrientation;
39
+ orientation: typeof ScreenOrientation[keyof typeof ScreenOrientation];
34
40
  };
35
41
  };
36
- export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent;
42
+ export type UnistylesPluginEvent = {
43
+ type: CxxUnistylesEventTypes.Plugin;
44
+ };
45
+ export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent;
37
46
  //# sourceMappingURL=unistyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"unistyles.d.ts","sourceRoot":"","sources":["../../../../src/types/unistyles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AACrE,OAAO,KAAK,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AACtE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAExC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,OAAO,GAAG,MAAM,CAAC,CAAA;AAExD,MAAM,MAAM,eAAe,GAAG;IAC1B,cAAc,CAAC,EAAE,OAAO,CAAA;CAC3B,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAE1B,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,eAAe,CAAC;IACjC,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,WAAW,EAAE,eAAe,CAAC;IAC7B,qBAAqB,EAAE,KAAK,CAAC,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAG7G,MAAM,EAAE,KAAK,CAAC,MAAM,eAAe,CAAC,CAAC;IACrC,cAAc,CAAC,WAAW,EAAE,oBAAoB,GAAG,IAAI,CAAC;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,eAAe,GAAG,IAAI,CAAC;IAC5C,iBAAiB,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI,CAAA;CAC3C,CAAA;AAED,MAAM,MAAM,mBAAmB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infer V;
4
+ } ? V extends object ? {
5
+ [VK in keyof V]: VK extends 'default' ? never : VK;
6
+ }[keyof V] | ExtractVariantNames<V> : never : ExtractVariantNames<T[K]>;
7
+ }[keyof T] : never;
8
+ //# sourceMappingURL=variants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/types/variants.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,CAAC,CAAC,IAAI,CAAC,SAAS,MAAM,GAC/C;KACG,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS;QAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;KAAE,GAC5C,CAAC,SAAS,MAAM,GACX;SAAG,EAAE,IAAI,MAAM,CAAC,GAAG,EAAE,SAAS,SAAS,GACpC,KAAK,GAAG,EAAE;KAAE,CAAC,MAAM,CAAC,CAAC,GAAG,mBAAmB,CAAC,CAAC,CAAC,GAClD,KAAK,GACT,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;CAClC,CAAC,MAAM,CAAC,CAAC,GACR,KAAK,CAAA"}
@@ -1,10 +1,10 @@
1
- import type { CreateStylesFactory, CustomNamedStyles, ReactNativeStyleSheet, UnistylesTheme } from './types';
1
+ import type { CreateStylesFactory, CustomNamedStyles, ExtractVariantNames, ReactNativeStyleSheet, UnistylesTheme } from './types';
2
2
  import type { UnistylesBreakpoints } from './global';
3
3
  type ParsedStylesheet<ST extends CustomNamedStyles<ST>> = {
4
4
  theme: UnistylesTheme;
5
5
  breakpoint: keyof UnistylesBreakpoints;
6
6
  styles: ReactNativeStyleSheet<ST>;
7
7
  };
8
- export declare const useStyles: <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, never> | undefined, variant?: string) => ParsedStylesheet<ST>;
8
+ export declare const useStyles: <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, never> | undefined, variant?: (ExtractVariantNames<ST> & string) | undefined) => ParsedStylesheet<ST>;
9
9
  export {};
10
10
  //# sourceMappingURL=useStyles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAE5G,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,KAAK,gBAAgB,CAAC,EAAE,SAAS,iBAAiB,CAAC,EAAE,CAAC,IAAI;IACtD,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,6GAER,MAAM,yBAwCnB,CAAA"}
1
+ {"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACR,mBAAmB,EACnB,iBAAiB,EACjB,mBAAmB,EACnB,qBAAqB,EACrB,cAAc,EACjB,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAEpD,KAAK,gBAAgB,CAAC,EAAE,SAAS,iBAAiB,CAAC,EAAE,CAAC,IAAI;IACtD,KAAK,EAAE,cAAc,CAAC;IACtB,UAAU,EAAE,MAAM,oBAAoB,CAAC;IACvC,MAAM,EAAE,qBAAqB,CAAC,EAAE,CAAC,CAAA;CACpC,CAAA;AAED,eAAO,MAAM,SAAS,oLA0CrB,CAAA"}
@@ -1,6 +1,3 @@
1
- import type { NestedStyle, RNValue } from '../types';
2
- import type { UnistylesBreakpoints } from '../global';
3
- export declare const sortAndValidateBreakpoints: (breakpoints: UnistylesBreakpoints) => UnistylesBreakpoints;
4
- export declare const getBreakpointFromScreenWidth: (width: number, breakpointEntries: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>) => keyof UnistylesBreakpoints & string;
5
- export declare const getValueForNestedStyle: (value: NestedStyle, variant?: string) => RNValue;
1
+ import type { NestedStyle, Optional, RNValue } from '../types';
2
+ export declare const getValueForBreakpoint: (value: NestedStyle) => Optional<RNValue>;
6
3
  //# sourceMappingURL=breakpoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAoB,OAAO,EAAE,MAAM,UAAU,CAAA;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAKrD,eAAO,MAAM,0BAA0B,gBAAiB,oBAAoB,KAAG,oBAuB9E,CAAA;AAED,eAAO,MAAM,4BAA4B,UAAW,MAAM,qBAAqB,MAAM,CAAC,MAAM,oBAAoB,EAAE,oBAAoB,CAAC,MAAM,oBAAoB,CAAC,CAAC,CAAC,KAAG,MAAM,oBAAoB,GAAG,MAcnM,CAAA;AAGD,eAAO,MAAM,sBAAsB,UAAW,WAAW,YAAY,MAAM,KAAG,OA0D7E,CAAA"}
1
+ {"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAoB,QAAQ,EAAE,OAAO,EAAE,MAAM,UAAU,CAAA;AAKhF,eAAO,MAAM,qBAAqB,UAAW,WAAW,KAAG,SAAS,OAAO,CAqC1E,CAAA"}
@@ -1,9 +1,6 @@
1
- export { normalizeStyles } from './normalizeStyles';
2
- export * from './normalizer';
3
1
  export { mq, MQSymbol } from './mq';
4
2
  export { getKeyForVariant } from './variants';
5
- export { getKeyForUnistylesMediaQuery } from './mqParser';
6
- export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForNestedStyle } from './breakpoints';
3
+ export { getKeyForUnistylesMediaQuery, isWithinTheWidthAndHeight, isValidMq, parseMq } from './mqParser';
4
+ export { getValueForBreakpoint } from './breakpoints';
7
5
  export { proxifyFunction, parseStyle } from './styles';
8
- export { isServer, Orientation } from './common';
9
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,cAAc,cAAc,CAAA;AAC5B,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAA;AAChH,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAC7C,OAAO,EAAE,4BAA4B,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,YAAY,CAAA;AACxG,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA"}
@@ -1,3 +1,15 @@
1
1
  import type { NestedStylePairs, Optional, ScreenSize } from '../types';
2
+ type ParsedMqDimension = {
3
+ from: number;
4
+ to: number;
5
+ };
6
+ type UnistylesParsedMq = {
7
+ width?: ParsedMqDimension;
8
+ height?: ParsedMqDimension;
9
+ };
10
+ export declare const parseMq: (mq: string) => UnistylesParsedMq;
11
+ export declare const isValidMq: (parsedMq: UnistylesParsedMq) => boolean;
12
+ export declare const isWithinTheWidthAndHeight: (parsedMq: UnistylesParsedMq, screenSize: ScreenSize) => boolean;
2
13
  export declare const getKeyForUnistylesMediaQuery: (mediaQueries: NestedStylePairs, screenSize: ScreenSize) => Optional<string>;
14
+ export {};
3
15
  //# sourceMappingURL=mqParser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mqParser.d.ts","sourceRoot":"","sources":["../../../../src/utils/mqParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAkFtE,eAAO,MAAM,4BAA4B,+CAAgD,UAAU,qBAgBlG,CAAA"}
1
+ {"version":3,"file":"mqParser.d.ts","sourceRoot":"","sources":["../../../../src/utils/mqParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAMtE,KAAK,iBAAiB,GAAG;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAA;CACb,CAAA;AAED,KAAK,iBAAiB,GAAG;IACrB,KAAK,CAAC,EAAE,iBAAiB,CAAC;IAC1B,MAAM,CAAC,EAAE,iBAAiB,CAAA;CAC7B,CAAA;AAED,eAAO,MAAM,OAAO,OAAQ,MAAM,KAAG,iBAcpC,CAAA;AAID,eAAO,MAAM,SAAS,aAAc,iBAAiB,YAgBpD,CAAA;AAED,eAAO,MAAM,yBAAyB,aAAc,iBAAiB,cAAc,UAAU,KAAG,OAgB/F,CAAA;AAcD,eAAO,MAAM,4BAA4B,+CAAgD,UAAU,KAAG,SAAS,MAAM,CAgBpH,CAAA"}
@@ -1,6 +1,6 @@
1
- import type { CustomNamedStyles, ScreenSize } from '../types';
1
+ import type { CustomNamedStyles, ScreenSize, RNStyle } from '../types';
2
2
  import type { UnistylesBreakpoints } from '../global';
3
- export declare const proxifyFunction: (fn: Function, breakpoint: keyof UnistylesBreakpoints & string, screenSize: ScreenSize, variant?: string) => Function;
3
+ export declare const proxifyFunction: (key: string, fn: Function, breakpoint: keyof UnistylesBreakpoints & string, screenSize: ScreenSize, variant?: string) => Function;
4
4
  export declare const isPlatformColor: <T extends {}>(value: T) => boolean;
5
- export declare const parseStyle: <T>(style: CustomNamedStyles<T>, breakpoint: keyof UnistylesBreakpoints & string, screenSize: ScreenSize, variant?: string) => T;
5
+ export declare const parseStyle: <T extends RNStyle>(key: string, style: CustomNamedStyles<T>, breakpoint: keyof UnistylesBreakpoints & string, screenSize: ScreenSize, variant?: string) => T;
6
6
  //# sourceMappingURL=styles.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAe,MAAM,UAAU,CAAA;AAG1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAGrD,eAAO,MAAM,eAAe,OACpB,QAAQ,cAAc,MAAM,oBAAoB,GAAG,MAAM,cACjD,UAAU,YACZ,MAAM,KACjB,QAGD,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED,eAAO,MAAM,UAAU,+CAEP,MAAM,oBAAoB,GAAG,MAAM,cACnC,UAAU,YACZ,MAAM,MAgDnB,CAAA"}
1
+ {"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../../src/utils/styles.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,UAAU,EAAe,OAAO,EAAE,MAAM,UAAU,CAAA;AAEnF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAKrD,eAAO,MAAM,eAAe,QACnB,MAAM,MACP,QAAQ,cAAc,MAAM,oBAAoB,GAAG,MAAM,cACjD,UAAU,YACZ,MAAM,KACjB,QAGD,CAAA;AAEF,eAAO,MAAM,eAAe,8BAA6B,OAMxD,CAAA;AAED,eAAO,MAAM,UAAU,2BACd,MAAM,2CAEC,MAAM,oBAAoB,GAAG,MAAM,cACnC,UAAU,YACZ,MAAM,MA4DnB,CAAA"}
@@ -1,3 +1,3 @@
1
1
  import type { Optional, NestedStyle } from '../types';
2
- export declare const getKeyForVariant: (value: NestedStyle, variant?: string) => Optional<keyof import("..").UnistylesBreakpoints | typeof import("./mq").MQSymbol | "variants">;
2
+ export declare const getKeyForVariant: (value: NestedStyle, variant?: string) => Optional<string>;
3
3
  //# sourceMappingURL=variants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/utils/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,gBAAgB,UAAW,WAAW,YAAY,MAAM,oGAcpE,CAAA"}
1
+ {"version":3,"file":"variants.d.ts","sourceRoot":"","sources":["../../../../src/utils/variants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAErD,eAAO,MAAM,gBAAgB,UAAW,WAAW,YAAY,MAAM,KAAG,SAAS,MAAM,CAUtF,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-alpha.10",
3
+ "version": "2.0.0-alpha.12",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -111,6 +111,9 @@
111
111
  "<rootDir>/docs/node_modules",
112
112
  "<rootDir>/lib/"
113
113
  ],
114
+ "testMatch": [
115
+ "**/*.spec.(ts|tsx)"
116
+ ],
114
117
  "coverageReporters": [
115
118
  "html"
116
119
  ]
@@ -0,0 +1,24 @@
1
+ import type { ScreenSize } from '../types'
2
+
3
+ const TEST_BREAKPOINTS = {
4
+ xs: 0,
5
+ sm: 300,
6
+ md: 500,
7
+ lg: 750,
8
+ xl: 1000
9
+ } as const
10
+
11
+ export const mockRuntime = (screenSize: ScreenSize) => ({
12
+ breakpoint: Object.entries(TEST_BREAKPOINTS)
13
+ .reverse()
14
+ .find(([, value]) => screenSize.width >= value)?.at(0),
15
+ orientation: screenSize.width > screenSize.height
16
+ ? 'landscape'
17
+ : 'portrait',
18
+ screen: screenSize
19
+ })
20
+
21
+ export const mockRegistry = () => ({
22
+ sortedBreakpointPairs: Object.entries(TEST_BREAKPOINTS),
23
+ plugins: []
24
+ })
package/src/common.ts CHANGED
@@ -1,6 +1,24 @@
1
+ import { Platform } from 'react-native'
2
+
3
+ export const warn = (message: string) => {
4
+ console.warn(`🦄 [react-native-unistyles]: ${message}`)
5
+ }
6
+
7
+ export const isMobile = Platform.OS === 'android' || Platform.OS === 'ios'
8
+ export const isWeb = Platform.OS === 'web'
9
+ export const isIOS = Platform.OS === 'ios'
10
+ export const isAndroid = Platform.OS === 'android'
11
+ export const isServer = typeof window === 'undefined'
12
+
13
+ export const ScreenOrientation = {
14
+ Landscape: 'landscape',
15
+ Portrait: 'portrait'
16
+ } as const
17
+
1
18
  export enum CxxUnistylesEventTypes {
2
19
  Theme = 'theme',
3
- Layout = 'layout'
20
+ Layout = 'layout',
21
+ Plugin = 'plugin'
4
22
  }
5
23
 
6
24
  export enum UnistylesError {
@@ -10,10 +28,7 @@ export enum UnistylesError {
10
28
  ThemesCannotBeEmpty = 'UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY',
11
29
  BreakpointsCannotBeEmpty = 'UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY',
12
30
  BreakpointsMustStartFromZero = 'UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO',
13
- }
14
-
15
- // todo to string?
16
- export enum ScreenOrientation {
17
- Portrait = 1,
18
- Landscape = 2
31
+ InvalidPluginName = 'UNISTYLES_ERROR_INVALID_PLUGIN_NAME',
32
+ DuplicatePluginName = 'UNISTYLES_ERROR_DUPLICATE_PLUGIN_NAME',
33
+ CantRemoveInternalPlugin = 'UNISTYLES_ERROR_CANT_REMOVE_INTERNAL_PLUGIN'
19
34
  }