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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. package/cxx/UnistylesRuntime.cpp +55 -1
  2. package/cxx/UnistylesRuntime.h +10 -4
  3. package/ios/UnistylesModule.mm +12 -2
  4. package/lib/commonjs/common.js +19 -6
  5. package/lib/commonjs/common.js.map +1 -1
  6. package/lib/commonjs/core/UnistyleRegistry.js +49 -1
  7. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  8. package/lib/commonjs/core/UnistylesRuntime.js +12 -16
  9. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -1
  10. package/lib/commonjs/hooks/useUnistyles.js +8 -2
  11. package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/plugins/index.js +45 -0
  14. package/lib/commonjs/plugins/index.js.map +1 -0
  15. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js +12 -0
  16. package/lib/commonjs/plugins/normalizeWebStylesPlugin.js.map +1 -0
  17. package/lib/commonjs/plugins/normalizer/index.js +32 -0
  18. package/lib/commonjs/plugins/normalizer/index.js.map +1 -0
  19. package/lib/commonjs/plugins/normalizer/module.d.js.map +1 -0
  20. package/lib/commonjs/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +5 -5
  21. package/lib/commonjs/plugins/normalizer/normalizeStyle.js.map +1 -0
  22. package/lib/commonjs/plugins/normalizer/normalizer.js.map +1 -0
  23. package/lib/commonjs/plugins/withPlugins.js +18 -0
  24. package/lib/commonjs/plugins/withPlugins.js.map +1 -0
  25. package/lib/commonjs/types/plugin.js +6 -0
  26. package/lib/{module/utils/module.d.js.map → commonjs/types/plugin.js.map} +1 -1
  27. package/lib/commonjs/useStyles.js +6 -5
  28. package/lib/commonjs/useStyles.js.map +1 -1
  29. package/lib/commonjs/utils/breakpoints.js +13 -59
  30. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  31. package/lib/commonjs/utils/index.js +10 -50
  32. package/lib/commonjs/utils/index.js.map +1 -1
  33. package/lib/commonjs/utils/mq.js +1 -1
  34. package/lib/commonjs/utils/mq.js.map +1 -1
  35. package/lib/commonjs/utils/mqParser.js +4 -1
  36. package/lib/commonjs/utils/mqParser.js.map +1 -1
  37. package/lib/commonjs/utils/styles.js +8 -8
  38. package/lib/commonjs/utils/styles.js.map +1 -1
  39. package/lib/module/common.js +17 -7
  40. package/lib/module/common.js.map +1 -1
  41. package/lib/module/core/UnistyleRegistry.js +49 -1
  42. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  43. package/lib/module/core/UnistylesRuntime.js +12 -16
  44. package/lib/module/core/UnistylesRuntime.js.map +1 -1
  45. package/lib/module/hooks/useUnistyles.js +8 -2
  46. package/lib/module/hooks/useUnistyles.js.map +1 -1
  47. package/lib/module/index.js.map +1 -1
  48. package/lib/module/plugins/index.js +4 -0
  49. package/lib/module/plugins/index.js.map +1 -0
  50. package/lib/module/plugins/normalizeWebStylesPlugin.js +6 -0
  51. package/lib/module/plugins/normalizeWebStylesPlugin.js.map +1 -0
  52. package/lib/module/plugins/normalizer/index.js +3 -0
  53. package/lib/module/plugins/normalizer/index.js.map +1 -0
  54. package/lib/module/plugins/normalizer/module.d.js.map +1 -0
  55. package/lib/module/{utils/normalizeStyles.web.js → plugins/normalizer/normalizeStyle.js} +3 -3
  56. package/lib/module/plugins/normalizer/normalizeStyle.js.map +1 -0
  57. package/lib/module/plugins/normalizer/normalizer.js.map +1 -0
  58. package/lib/module/plugins/withPlugins.js +11 -0
  59. package/lib/module/plugins/withPlugins.js.map +1 -0
  60. package/lib/module/types/plugin.js +2 -0
  61. package/lib/{commonjs/utils/module.d.js.map → module/types/plugin.js.map} +1 -1
  62. package/lib/module/useStyles.js +6 -5
  63. package/lib/module/useStyles.js.map +1 -1
  64. package/lib/module/utils/breakpoints.js +12 -56
  65. package/lib/module/utils/breakpoints.js.map +1 -1
  66. package/lib/module/utils/index.js +2 -5
  67. package/lib/module/utils/index.js.map +1 -1
  68. package/lib/module/utils/mq.js +1 -1
  69. package/lib/module/utils/mq.js.map +1 -1
  70. package/lib/module/utils/mqParser.js +3 -3
  71. package/lib/module/utils/mqParser.js.map +1 -1
  72. package/lib/module/utils/styles.js +8 -8
  73. package/lib/module/utils/styles.js.map +1 -1
  74. package/lib/typescript/src/common.d.ts +16 -6
  75. package/lib/typescript/src/common.d.ts.map +1 -1
  76. package/lib/typescript/src/core/UnistyleRegistry.d.ts +7 -2
  77. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
  78. package/lib/typescript/src/core/UnistylesRuntime.d.ts +7 -8
  79. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -1
  80. package/lib/typescript/src/core/index.d.ts +1 -0
  81. package/lib/typescript/src/core/index.d.ts.map +1 -1
  82. package/lib/typescript/src/hooks/useUnistyles.d.ts +2 -1
  83. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -1
  84. package/lib/typescript/src/index.d.ts +4 -3
  85. package/lib/typescript/src/index.d.ts.map +1 -1
  86. package/lib/typescript/src/plugins/index.d.ts +4 -0
  87. package/lib/typescript/src/plugins/index.d.ts.map +1 -0
  88. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts +3 -0
  89. package/lib/typescript/src/plugins/normalizeWebStylesPlugin.d.ts.map +1 -0
  90. package/lib/typescript/src/plugins/normalizer/index.d.ts +3 -0
  91. package/lib/typescript/src/plugins/normalizer/index.d.ts.map +1 -0
  92. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts +3 -0
  93. package/lib/typescript/src/plugins/normalizer/normalizeStyle.d.ts.map +1 -0
  94. package/lib/typescript/src/{utils → plugins/normalizer}/normalizer.d.ts +1 -1
  95. package/lib/typescript/src/plugins/normalizer/normalizer.d.ts.map +1 -0
  96. package/lib/typescript/src/plugins/withPlugins.d.ts +3 -0
  97. package/lib/typescript/src/plugins/withPlugins.d.ts.map +1 -0
  98. package/lib/typescript/src/types/core.d.ts +1 -0
  99. package/lib/typescript/src/types/core.d.ts.map +1 -1
  100. package/lib/typescript/src/types/index.d.ts +2 -1
  101. package/lib/typescript/src/types/index.d.ts.map +1 -1
  102. package/lib/typescript/src/types/plugin.d.ts +7 -0
  103. package/lib/typescript/src/types/plugin.d.ts.map +1 -0
  104. package/lib/typescript/src/types/unistyles.d.ts +11 -2
  105. package/lib/typescript/src/types/unistyles.d.ts.map +1 -1
  106. package/lib/typescript/src/utils/breakpoints.d.ts +2 -5
  107. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  108. package/lib/typescript/src/utils/index.d.ts +2 -5
  109. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  110. package/lib/typescript/src/utils/mqParser.d.ts +12 -0
  111. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -1
  112. package/lib/typescript/src/utils/styles.d.ts +3 -3
  113. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  114. package/package.json +4 -1
  115. package/src/__tests__/mocks.ts +24 -0
  116. package/src/common.ts +22 -7
  117. package/src/core/UnistyleRegistry.ts +46 -2
  118. package/src/core/UnistylesRuntime.ts +14 -20
  119. package/src/core/index.ts +1 -0
  120. package/src/hooks/useUnistyles.ts +7 -2
  121. package/src/index.ts +3 -1
  122. package/src/plugins/index.ts +3 -0
  123. package/src/plugins/normalizeWebStylesPlugin.ts +7 -0
  124. package/src/plugins/normalizer/index.ts +2 -0
  125. package/src/{utils/normalizeStyles.web.ts → plugins/normalizer/normalizeStyle.ts} +3 -3
  126. package/src/{utils → plugins/normalizer}/normalizer.ts +1 -1
  127. package/src/plugins/withPlugins.ts +17 -0
  128. package/src/types/core.ts +1 -0
  129. package/src/types/index.ts +11 -1
  130. package/src/types/plugin.ts +7 -0
  131. package/src/types/unistyles.ts +14 -4
  132. package/src/useStyles.ts +5 -5
  133. package/src/utils/breakpoints.ts +10 -66
  134. package/src/utils/index.ts +2 -5
  135. package/src/utils/mq.ts +1 -1
  136. package/src/utils/mqParser.ts +4 -4
  137. package/src/utils/styles.ts +11 -11
  138. package/lib/commonjs/utils/common.js +0 -25
  139. package/lib/commonjs/utils/common.js.map +0 -1
  140. package/lib/commonjs/utils/normalizeStyles.js +0 -10
  141. package/lib/commonjs/utils/normalizeStyles.js.map +0 -1
  142. package/lib/commonjs/utils/normalizeStyles.web.js.map +0 -1
  143. package/lib/commonjs/utils/normalizer.js.map +0 -1
  144. package/lib/module/utils/common.js +0 -17
  145. package/lib/module/utils/common.js.map +0 -1
  146. package/lib/module/utils/normalizeStyles.js +0 -3
  147. package/lib/module/utils/normalizeStyles.js.map +0 -1
  148. package/lib/module/utils/normalizeStyles.web.js.map +0 -1
  149. package/lib/module/utils/normalizer.js.map +0 -1
  150. package/lib/typescript/src/utils/common.d.ts +0 -12
  151. package/lib/typescript/src/utils/common.d.ts.map +0 -1
  152. package/lib/typescript/src/utils/normalizeStyles.d.ts +0 -2
  153. package/lib/typescript/src/utils/normalizeStyles.d.ts.map +0 -1
  154. package/lib/typescript/src/utils/normalizeStyles.web.d.ts +0 -5
  155. package/lib/typescript/src/utils/normalizeStyles.web.d.ts.map +0 -1
  156. package/lib/typescript/src/utils/normalizer.d.ts.map +0 -1
  157. package/src/utils/common.ts +0 -20
  158. package/src/utils/normalizeStyles.ts +0 -2
  159. /package/lib/commonjs/{utils → plugins/normalizer}/module.d.js +0 -0
  160. /package/lib/commonjs/{utils → plugins/normalizer}/normalizer.js +0 -0
  161. /package/lib/module/{utils → plugins/normalizer}/module.d.js +0 -0
  162. /package/lib/module/{utils → plugins/normalizer}/normalizer.js +0 -0
  163. /package/src/{utils → plugins/normalizer}/module.d.ts +0 -0
@@ -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"}
@@ -33,6 +33,7 @@ export type StaticStyles = UnistyleView | UnistyleText | UnistyleImage & Unistyl
33
33
  export type CustomNamedStyles<T> = {
34
34
  [K in keyof T]: T[K] extends (...args: infer A) => StaticStyles ? (...args: A) => StaticStyles : StaticStyles;
35
35
  };
36
+ export type RNStyle = ViewStyle | TextStyle | ImageStyle;
36
37
  export type RNValue = number | string | undefined;
37
38
  export type NestedStyle = Record<keyof UnistylesBreakpoints | MediaQuery, RNValue>;
38
39
  export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | MediaQuery, RNValue]>;
@@ -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,GAA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B,CAAA;AAEpE,KAAK,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAA;AAC9D,KAAK,YAAY,GAAG,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,CAAC,CAAC,CAAA;AAC9D,KAAK,aAAa,GAAG,YAAY,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC,CAAA;AAEhE,MAAM,MAAM,YAAY,GAClB,YAAY,GACZ,YAAY,GACZ,aAAa,GACb,cAAc,CAAA;AAEpB,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,7 +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
7
  export type { ExtractVariantNames } from './variants';
8
+ export type { UnistylesPlugin } from './plugin';
8
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;AAC1D,YAAY,EAAE,mBAAmB,EAAE,MAAM,YAAY,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,EA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E,UAAU,CAAC;QACnB,UAAU,EAAE,MAAM,oBAAoB,CAAC;QACvC,WAAW,EAAE,OAAO,iBAAiB,CAAC,MAAM,OAAO,iBAAiB,CAAC,CAAA;KACxE,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IAC/B,IAAI,EAAE,sBAAsB,CAAC,MAAM,CAAA;CACtC,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG,0BAA0B,GAAG,oBAAoB,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 getValueForBreakpoint: (value: NestedStyle) => 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;AAIrD,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;AAED,eAAO,MAAM,qBAAqB,UAAW,WAAW,KAAG,OAmD1D,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, getValueForBreakpoint } 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,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,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;AAIrD,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,MA8DnB,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-alpha.11",
3
+ "version": "2.0.0-alpha.13",
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
  }
@@ -1,8 +1,10 @@
1
- import type { UnistylesBridge, UnistylesConfig } from '../types'
1
+ import type { UnistylesBridge, UnistylesConfig, UnistylesPlugin } from '../types'
2
2
  import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
3
+ import { UnistylesError } from '../common'
3
4
 
4
5
  export class UnistyleRegistry {
5
6
  public config: UnistylesConfig = {}
7
+ public plugins: Array<UnistylesPlugin> = []
6
8
  public themeNames: Array<keyof UnistylesThemes> = []
7
9
  public themes: UnistylesThemes = {} as UnistylesThemes
8
10
  public breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
@@ -36,6 +38,48 @@ export class UnistyleRegistry {
36
38
  this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes)
37
39
  }
38
40
 
39
- return this
41
+ if (config.experimentalPlugins) {
42
+ config.experimentalPlugins.forEach(plugin => this.addPlugin(plugin, false))
43
+ }
44
+
45
+ if (config.initialTheme) {
46
+ this.unistylesBridge.useTheme(config.initialTheme)
47
+ }
40
48
  }
49
+
50
+ public getTheme = (forName: keyof UnistylesThemes) => {
51
+ if (this.themeNames.length === 0) {
52
+ return {} as UnistylesThemes[keyof UnistylesThemes]
53
+ }
54
+
55
+ if (!this.hasTheme(forName)) {
56
+ throw new Error(UnistylesError.ThemeNotFound)
57
+ }
58
+
59
+ return this.themes[forName]
60
+ }
61
+
62
+ public addPlugin = (plugin: UnistylesPlugin, notify: boolean = true) => {
63
+ if (plugin.name.startsWith('__unistyles')) {
64
+ throw new Error(UnistylesError.InvalidPluginName)
65
+ }
66
+
67
+ if (this.plugins.some(({ name }) => name === plugin.name)) {
68
+ throw new Error(UnistylesError.DuplicatePluginName)
69
+ }
70
+
71
+ this.plugins = this.plugins.concat([plugin])
72
+ this.unistylesBridge.addPlugin(plugin.name, notify)
73
+ }
74
+
75
+ public removePlugin = (plugin: UnistylesPlugin) => {
76
+ if (plugin.name.startsWith('__unistyles')) {
77
+ throw new Error(UnistylesError.CantRemoveInternalPlugin)
78
+ }
79
+
80
+ this.plugins = this.plugins.filter(({ name }) => name !== plugin.name)
81
+ this.unistylesBridge.removePlugin(plugin.name)
82
+ }
83
+
84
+ public hasTheme = (name: keyof UnistylesThemes) => name in this.themes
41
85
  }
@@ -1,10 +1,10 @@
1
1
  import { ScreenOrientation, UnistylesError } from '../common'
2
- import type { UnistylesBridge } from '../types'
2
+ import type { UnistylesBridge, UnistylesPlugin } from '../types'
3
3
  import type { UnistylesThemes } from '../global'
4
4
  import type { UnistyleRegistry } from './UnistyleRegistry'
5
5
 
6
6
  export class UnistylesRuntime {
7
- constructor(private unistylesBridge: UnistylesBridge, private registry: UnistyleRegistry) {}
7
+ constructor(private unistylesBridge: UnistylesBridge, private unistylesRegistry: UnistyleRegistry) {}
8
8
 
9
9
  public get colorScheme() {
10
10
  return this.unistylesBridge.colorScheme
@@ -14,10 +14,6 @@ export class UnistylesRuntime {
14
14
  return this.unistylesBridge.hasAdaptiveThemes
15
15
  }
16
16
 
17
- public get sortedBreakpoints() {
18
- return this.registry.sortedBreakpointPairs
19
- }
20
-
21
17
  public get themeName() {
22
18
  return this.unistylesBridge.themeName
23
19
  }
@@ -26,6 +22,10 @@ export class UnistylesRuntime {
26
22
  return this.unistylesBridge.breakpoint
27
23
  }
28
24
 
25
+ public get enabledPlugins() {
26
+ return this.unistylesBridge.enabledPlugins
27
+ }
28
+
29
29
  public get screen() {
30
30
  return {
31
31
  width: this.unistylesBridge.screenWidth,
@@ -44,7 +44,7 @@ export class UnistylesRuntime {
44
44
  }
45
45
 
46
46
  public setTheme = (name: keyof UnistylesThemes) => {
47
- if (this.hasTheme(name)) {
47
+ if (this.unistylesRegistry.hasTheme(name)) {
48
48
  this.unistylesBridge.useTheme(name)
49
49
 
50
50
  return true
@@ -53,21 +53,15 @@ export class UnistylesRuntime {
53
53
  throw new Error(UnistylesError.ThemeNotRegistered)
54
54
  }
55
55
 
56
- public getTheme = (forName: keyof UnistylesThemes) => {
57
- if (this.registry.themeNames.length === 0) {
58
- return {} as UnistylesThemes[keyof UnistylesThemes]
59
- }
60
-
61
- if (!this.hasTheme(forName)) {
62
- throw new Error(UnistylesError.ThemeNotFound)
63
- }
64
-
65
- return this.registry.themes[forName]
66
- }
67
-
68
56
  public setAdaptiveThemes = (enable: boolean) => {
69
57
  this.unistylesBridge.useAdaptiveThemes(enable)
70
58
  }
71
59
 
72
- private hasTheme = (name: keyof UnistylesThemes) => name in this.registry.themes
60
+ public addPlugin = (plugin: UnistylesPlugin) => {
61
+ this.unistylesRegistry.addPlugin(plugin)
62
+ }
63
+
64
+ public removePlugin = (plugin: UnistylesPlugin) => {
65
+ this.unistylesRegistry.removePlugin(plugin)
66
+ }
73
67
  }
package/src/core/index.ts CHANGED
@@ -1 +1,2 @@
1
1
  export { unistyles } from './Unistyles'
2
+ export type { UnistylesRuntime } from './UnistylesRuntime'
@@ -7,7 +7,8 @@ import type { UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent }
7
7
  const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
8
8
 
9
9
  export const useUnistyles = () => {
10
- const [theme, setTheme] = useState(unistyles.runtime.getTheme(unistyles.runtime.themeName))
10
+ const [plugins, setPlugins] = useState(unistyles.runtime.enabledPlugins)
11
+ const [theme, setTheme] = useState(unistyles.registry.getTheme(unistyles.runtime.themeName))
11
12
  const [layout, setLayout] = useState({
12
13
  breakpoint: unistyles.runtime.breakpoint,
13
14
  orientation: unistyles.runtime.orientation,
@@ -25,7 +26,7 @@ export const useUnistyles = () => {
25
26
  case CxxUnistylesEventTypes.Theme: {
26
27
  const themeEvent = event as UnistylesThemeEvent
27
28
 
28
- return setTheme(unistyles.runtime.getTheme(themeEvent.payload.themeName))
29
+ return setTheme(unistyles.registry.getTheme(themeEvent.payload.themeName))
29
30
  }
30
31
  case CxxUnistylesEventTypes.Layout: {
31
32
  const layoutEvent = event as UnistylesMobileLayoutEvent
@@ -39,6 +40,9 @@ export const useUnistyles = () => {
39
40
  }
40
41
  })
41
42
  }
43
+ case CxxUnistylesEventTypes.Plugin: {
44
+ return setPlugins(unistyles.runtime.enabledPlugins)
45
+ }
42
46
  default:
43
47
  return
44
48
  }
@@ -49,6 +53,7 @@ export const useUnistyles = () => {
49
53
  }, [])
50
54
 
51
55
  return {
56
+ plugins,
52
57
  theme,
53
58
  layout
54
59
  }
package/src/index.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { unistyles } from './core'
2
2
  import { mq } from './utils'
3
3
  import { useInitialTheme } from './hooks'
4
+ import type { UnistylesPlugin } from './types'
4
5
  import type { UnistylesThemes, UnistylesBreakpoints } from './global'
5
6
  import { ScreenOrientation } from './common'
6
7
  import { useStyles } from './useStyles'
@@ -26,5 +27,6 @@ export {
26
27
 
27
28
  export type {
28
29
  UnistylesThemes,
29
- UnistylesBreakpoints
30
+ UnistylesBreakpoints,
31
+ UnistylesPlugin
30
32
  }
@@ -0,0 +1,3 @@
1
+ export { normalizeWebStylesPlugin } from './normalizeWebStylesPlugin'
2
+ export { preprocessor, normalizeNumericValue, normalizeColor, normalizeStyle } from './normalizer'
3
+ export { withPlugins } from './withPlugins'
@@ -0,0 +1,7 @@
1
+ import type { UnistylesPlugin } from '../types'
2
+ import { normalizeStyle } from './normalizer'
3
+
4
+ export const normalizeWebStylesPlugin: UnistylesPlugin = {
5
+ name: '__unistylesNormalizeWebStyles',
6
+ onParsedStyle: (_key, styles) => normalizeStyle(styles)
7
+ }
@@ -0,0 +1,2 @@
1
+ export { normalizeStyle } from './normalizeStyle'
2
+ export { preprocessor, normalizeNumericValue, normalizeColor } from './normalizer'
@@ -1,6 +1,6 @@
1
- import { warn } from './common'
2
1
  import { preprocessor } from './normalizer'
3
- import type { NormalizedBoxShadow, NormalizedTextShadow, BoxShadow, TextShadow, Transforms } from '../types'
2
+ import { warn } from '../../common'
3
+ import type { NormalizedBoxShadow, NormalizedTextShadow, BoxShadow, TextShadow, RNStyle } from '../../types'
4
4
 
5
5
  const normalizeBoxShadow = <T extends BoxShadow>(style: T): NormalizedBoxShadow => {
6
6
  const requiredBoxShadowProperties = [
@@ -55,7 +55,7 @@ const normalizeTextShadow = <T extends TextShadow>(style: T): NormalizedTextShad
55
55
  }
56
56
  }
57
57
 
58
- export const normalizeStyles = <T extends BoxShadow | TextShadow | { transform: Transforms }>(style: T): T => {
58
+ export const normalizeStyle = <T extends RNStyle>(style: T): T => {
59
59
  const normalizedTransform = ('transform' in style && Array.isArray(style.transform))
60
60
  ? { transform: preprocessor.createTransformValue(style.transform) }
61
61
  : {}
@@ -1,7 +1,7 @@
1
1
  // based on react-native-web normalizer
2
2
  // https://github.com/necolas/react-native-web
3
3
  import normalizeColors from '@react-native/normalize-colors'
4
- import type { TextShadow, Transforms, BoxShadow } from '../types'
4
+ import type { TextShadow, Transforms, BoxShadow } from '../../types'
5
5
 
6
6
  type Preprocessor = {
7
7
  createTextShadowValue(style: TextShadow): string,