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
@@ -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,WAAW,EAAE,MAAM,eAAe,CAAA;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,KAAK,YAAY,GAAG;IAChB,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,CAAC,CAAC,IAAI;IACrB,YAAY,CAAC,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esThemes, UnistylesBreakpoints } from '../global';
2
+ export type Nullable<T> = T | null;
3
+ export type ColorSchemeName = 'light' | 'dark' | undefined;
4
+ export type UnistylesConfig = {
5
+ adaptiveThemes?: boolean;
6
+ };
7
+ export declare enum ScreenOrientation {
8
+ Portrait = 1,
9
+ Landscape = 2
10
+ }
11
+ export type UnistylesBridge = {
12
+ screenWidth: number;
13
+ screenHeight: number;
14
+ hasAdaptiveThemes: boolean;
15
+ theme: keyof UnistylesThemes;
16
+ breakpoint: keyof UnistylesBreakpoints;
17
+ colorScheme: ColorSchemeName;
18
+ sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>;
19
+ themes: Array<keyof UnistylesThemes>;
20
+ useBreakpoints(breakpoints: UnistylesBreakpoints): void;
21
+ useTheme(name: keyof UnistylesThemes): void;
22
+ useAdaptiveThemes(enable: boolean): void;
23
+ };
24
+ export declare enum CxxUnistylesEventTypes {
25
+ Theme = "theme",
26
+ Size = "size",
27
+ Breakpoint = "breakpoint"
28
+ }
29
+ export type CxxUnistylesThemeEvent = {
30
+ type: CxxUnistylesEventTypes.Theme;
31
+ payload: {
32
+ themeName: keyof UnistylesThemes;
33
+ };
34
+ };
35
+ export type CxxUnistylesSizeEvent = {
36
+ type: CxxUnistylesEventTypes.Size;
37
+ payload: {
38
+ width: number;
39
+ height: number;
40
+ };
41
+ };
42
+ export type CxxUnistylesBreakpointEvent = {
43
+ type: CxxUnistylesEventTypes.Breakpoint;
44
+ payload: {
45
+ breakpoint: keyof UnistylesBreakpoints;
46
+ };
47
+ };
48
+ export type UnistylesEvents = CxxUnistylesThemeEvent | CxxUnistylesSizeEvent | CxxUnistylesBreakpointEvent;
49
+ export declare enum UnistylesError {
50
+ RuntimeUnavailable = "UNISTYLES_ERROR_RUNTIME_UNAVAILABLE",
51
+ ThemeNotFound = "UNISTYLES_ERROR_THEME_NOT_FOUND"
52
+ }
53
+ //# sourceMappingURL=cxx.d.ts.map
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CAAA;KACnC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,qBAAqB,GAAG;IAChC,IAAI,EAAE,sBAAsB,CAAC,IAAI,CAAC;IAClC,OAAO,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAA;KACjB,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACtC,IAAI,EAAE,sBAAsB,CAAC,UAAU,CAAC;IACxC,OAAO,EAAE;QACL,UAAU,EAAE,MAAM,oBAAoB,CAAA;KACzC,CAAA;CACJ,CAAA;AAED,MAAM,MAAM,eAAe,GAAG,sBAAsB,GAAG,qBAAqB,GAAG,2BAA2B,CAAA;AAE1G,oBAAY,cAAc;IACtB,kBAAkB,wCAAwC;IAC1D,aAAa,oCAAoC;CACpD"}
@@ -1,3 +1,6 @@
1
+ export * from './normalizer';
2
+ export * from './cxx';
1
3
  export type { CustomNamedStyles } from './core';
2
- export type { ScreenSize, Breakpoints, CreateStylesFactory, ExtractBreakpoints, RemoveKeysWithPrefix, SortedBreakpointEntries } from './breakpoints';
4
+ export type { MediaQueries } from './mediaQueries';
5
+ export type { ScreenSize, CreateStylesFactory, ExtractBreakpoints, RemoveKeysWithPrefix } from './breakpoints';
3
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC/C,YAAY,EACR,UAAU,EACV,WAAW,EACX,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACpB,uBAAuB,EAC1B,MAAM,eAAe,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,OAAO,CAAA;AACrB,YAAY,EAAE,iBAAiB,EAAE,MAAM,QAAQ,CAAA;AAC/C,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAClD,YAAY,EACR,UAAU,EACV,mBAAmB,EACnB,kBAAkB,EAClB,oBAAoB,EACvB,MAAM,eAAe,CAAA"}
@@ -0,0 +1,20 @@
1
+ import type { ShadowStyleIOS, TextStyle, TransformsStyle } from 'react-native';
2
+ type TransformArrayElement<T> = T extends Array<infer U> ? U : never;
3
+ type BoxShadow = Required<ShadowStyleIOS>;
4
+ type TextShadow = Required<Pick<TextStyle, 'textShadowColor' | 'textShadowOffset' | 'textShadowRadius'>>;
5
+ type Transforms = Array<TransformArrayElement<TransformsStyle['transform']>>;
6
+ type NormalizedBoxShadow = {
7
+ shadowColor: undefined;
8
+ shadowOffset: undefined;
9
+ shadowOpacity: undefined;
10
+ shadowRadius: undefined;
11
+ boxShadow?: string;
12
+ };
13
+ type NormalizedTextShadow = {
14
+ textShadowColor: undefined;
15
+ textShadowOffset: undefined;
16
+ textShadowRadius: undefined;
17
+ textShadow?: string;
18
+ };
19
+ export type { BoxShadow, TextShadow, Transforms, NormalizedBoxShadow, NormalizedTextShadow };
20
+ //# sourceMappingURL=normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../../src/types/normalizer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAE9E,KAAK,qBAAqB,CAAC,CAAC,IAAI,CAAC,SAAS,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK,CAAA;AACpE,KAAK,SAAS,GAAG,QAAQ,CAAC,cAAc,CAAC,CAAA;AACzC,KAAK,UAAU,GAAG,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,iBAAiB,GAAG,kBAAkB,GAAG,kBAAkB,CAAC,CAAC,CAAA;AACxG,KAAK,UAAU,GAAG,KAAK,CAAC,qBAAqB,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAA;AAE5E,KAAK,mBAAmB,GAAG;IACvB,WAAW,EAAE,SAAS,CAAC;IACvB,YAAY,EAAE,SAAS,CAAC;IACxB,aAAa,EAAE,SAAS,CAAC;IACzB,YAAY,EAAE,SAAS,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAA;CACrB,CAAA;AAED,KAAK,oBAAoB,GAAG;IACxB,eAAe,EAAE,SAAS,CAAA;IAC1B,gBAAgB,EAAE,SAAS,CAAA;IAC3B,gBAAgB,EAAE,SAAS,CAAC;IAC5B,UAAU,CAAC,EAAE,MAAM,CAAA;CACtB,CAAA;AAED,YAAY,EACR,SAAS,EACT,UAAU,EACV,UAAU,EACV,mBAAmB,EACnB,oBAAoB,EACvB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { UnistylesThemes } from './global';
2
+ export declare const useInitialTheme: (forName: keyof UnistylesThemes) => void;
3
+ //# sourceMappingURL=useInitialTheme.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInitialTheme.d.ts","sourceRoot":"","sources":["../../../src/useInitialTheme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE/C,eAAO,MAAM,eAAe,YAAa,MAAM,eAAe,SAE7D,CAAA"}
@@ -0,0 +1,46 @@
1
+ import type { CreateStylesFactory, CustomNamedStyles, ExtractBreakpoints, RemoveKeysWithPrefix } from './types';
2
+ import type { UnistylesThemes } from './global';
3
+ type T = UnistylesThemes[keyof UnistylesThemes];
4
+ export declare const useStyles: <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, T> | undefined) => {
5
+ theme: {
6
+ colors: {
7
+ backgroundColor: string;
8
+ typography: string;
9
+ accent: string;
10
+ barbie: string;
11
+ oak: string;
12
+ sky: string;
13
+ fog: string;
14
+ aloes: string;
15
+ blood: string;
16
+ };
17
+ } | {
18
+ colors: {
19
+ backgroundColor: string;
20
+ typography: string;
21
+ accent: string;
22
+ barbie: string;
23
+ oak: string;
24
+ sky: string;
25
+ fog: string;
26
+ aloes: string;
27
+ blood: string;
28
+ };
29
+ } | {
30
+ colors: {
31
+ backgroundColor: string;
32
+ typography: string;
33
+ accent: string;
34
+ barbie: string;
35
+ oak: string;
36
+ sky: string;
37
+ fog: string;
38
+ aloes: string;
39
+ blood: string;
40
+ };
41
+ };
42
+ breakpoint: "xs" | "sm" | "md" | "lg" | "xl";
43
+ styles: ExtractBreakpoints<RemoveKeysWithPrefix<ST>>;
44
+ };
45
+ export {};
46
+ //# sourceMappingURL=useStyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useStyles.d.ts","sourceRoot":"","sources":["../../../src/useStyles.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAA;AAE/G,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAG/C,KAAK,CAAC,GAAG,eAAe,CAAC,MAAM,eAAe,CAAC,CAAA;AAE/C,eAAO,MAAM,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCrB,CAAA"}
@@ -0,0 +1,45 @@
1
+ export declare const useUnistyles: () => {
2
+ theme: {
3
+ colors: {
4
+ backgroundColor: string;
5
+ typography: string;
6
+ accent: string;
7
+ barbie: string;
8
+ oak: string;
9
+ sky: string;
10
+ fog: string;
11
+ aloes: string;
12
+ blood: string;
13
+ };
14
+ } | {
15
+ colors: {
16
+ backgroundColor: string;
17
+ typography: string;
18
+ accent: string;
19
+ barbie: string;
20
+ oak: string;
21
+ sky: string;
22
+ fog: string;
23
+ aloes: string;
24
+ blood: string;
25
+ };
26
+ } | {
27
+ colors: {
28
+ backgroundColor: string;
29
+ typography: string;
30
+ accent: string;
31
+ barbie: string;
32
+ oak: string;
33
+ sky: string;
34
+ fog: string;
35
+ aloes: string;
36
+ blood: string;
37
+ };
38
+ };
39
+ breakpoint: "xs" | "sm" | "md" | "lg" | "xl";
40
+ screenSize: {
41
+ width: number;
42
+ height: number;
43
+ };
44
+ };
45
+ //# sourceMappingURL=useUnistyles.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUnistyles.d.ts","sourceRoot":"","sources":["../../../src/useUnistyles.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoDxB,CAAA"}
@@ -1,4 +1,5 @@
1
- import type { Breakpoints, ScreenSize, SortedBreakpointEntries } from '../types';
1
+ import type { ScreenSize, MediaQueries } from '../types';
2
+ import type { UnistylesBreakpoints } from '../global';
2
3
  /**
3
4
  * Sorts the breakpoints object based on its numeric values in ascending order and validates them.
4
5
  *
@@ -18,7 +19,7 @@ import type { Breakpoints, ScreenSize, SortedBreakpointEntries } from '../types'
18
19
  * const input = { md: 768, lg: 1024, sm: 0 }
19
20
  * sortAndValidateBreakpoints(input) // returns { sm: 0, md: 768, lg: 1024 }
20
21
  */
21
- export declare const sortAndValidateBreakpoints: <B extends Breakpoints>(breakpoints: B) => B;
22
+ export declare const sortAndValidateBreakpoints: (breakpoints: UnistylesBreakpoints) => UnistylesBreakpoints;
22
23
  /**
23
24
  * Determines the appropriate breakpoint key for a given screen width based on provided breakpoints.
24
25
  *
@@ -34,7 +35,7 @@ export declare const sortAndValidateBreakpoints: <B extends Breakpoints>(breakpo
34
35
  * const breakpoints = { sm: 0, md: 768, lg: 1024 }
35
36
  * getBreakpointFromScreenWidth(800, breakpoints) // returns 'md'
36
37
  */
37
- export declare const getBreakpointFromScreenWidth: <B extends Breakpoints>(width: number, breakpointEntries: SortedBreakpointEntries<B>) => keyof B & string;
38
+ export declare const getBreakpointFromScreenWidth: (width: number, breakpointEntries: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>) => keyof UnistylesBreakpoints & string;
38
39
  /**
39
40
  * Retrieves the value associated with a given breakpoint or custom media query based on the provided screen size.
40
41
  *
@@ -59,5 +60,5 @@ export declare const getBreakpointFromScreenWidth: <B extends Breakpoints>(width
59
60
  *
60
61
  * getValueForBreakpoint(values, 'sm', screenSize, breakpoints); // 'value1'
61
62
  */
62
- export declare const getValueForBreakpoint: <B extends Breakpoints>(value: Record<keyof B & string, string | number | undefined>, breakpoint: keyof B & string, screenSize: ScreenSize, breakpointPairs: SortedBreakpointEntries<B>) => string | number | undefined;
63
+ export declare const getValueForBreakpoint: (value: Record<keyof UnistylesBreakpoints | MediaQueries, string | number | undefined>, breakpoint: keyof UnistylesBreakpoints, screenSize: ScreenSize) => string | number | undefined;
63
64
  //# sourceMappingURL=breakpoints.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAGhF;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,8CAuBtC,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,4BAA4B,iCAAkC,MAAM,oEAchF,CAAA;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,qBAAqB,kIAGlB,UAAU,kDAEvB,MAAM,GAAG,MAAM,GAAG,SA+BpB,CAAA"}
1
+ {"version":3,"file":"breakpoints.d.ts","sourceRoot":"","sources":["../../../../src/utils/breakpoints.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,UAAU,CAAA;AAExD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAErD;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,0BAA0B,gBAAiB,oBAAoB,KAAG,oBAuB9E,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,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;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,qBAAqB,UACvB,OAAO,MAAM,oBAAoB,GAAG,YAAY,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,cACzE,MAAM,oBAAoB,cAC1B,UAAU,KACvB,MAAM,GAAG,MAAM,GAAG,SAgCpB,CAAA"}
@@ -1,4 +1,5 @@
1
1
  export declare const throwError: (message: string) => never;
2
2
  export declare const warn: (message: string) => void;
3
- export declare const isWeb: () => boolean;
3
+ export declare const isWeb: boolean;
4
+ export declare const isServer: boolean;
4
5
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/utils/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,YAAa,MAAM,UAEzC,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,KAAK,eAA8B,CAAA"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../src/utils/common.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,UAAU,YAAa,MAAM,UAEzC,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,SAEnC,CAAA;AAED,eAAO,MAAM,KAAK,SAAwB,CAAA;AAC1C,eAAO,MAAM,QAAQ,SAAgC,CAAA"}
@@ -1,5 +1,7 @@
1
1
  export { normalizeStyles } from './normalizeStyles';
2
+ export * from './normalizer';
2
3
  export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints';
3
4
  export { proxifyFunction, parseStyle } from './styles';
5
+ export { isServer } from './common';
4
6
  export { extractValues, getKeyForCustomMediaQuery, isMediaQuery, isWithinTheHeight, isWithinTheWidth, isWithinTheWidthAndHeight } from './mediaQueries';
5
7
  //# 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,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAA;AAC/G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACtD,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
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,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,MAAM,UAAU,CAAA;AACnC,OAAO,EACH,aAAa,EACb,yBAAyB,EACzB,YAAY,EACZ,iBAAiB,EACjB,gBAAgB,EAChB,yBAAyB,EAC5B,MAAM,gBAAgB,CAAA"}
@@ -1,2 +1,5 @@
1
- export declare const normalizeStyles: <T extends {}>(styles: T) => T;
1
+ import type { Transforms } from '../types';
2
+ export declare const normalizeStyles: <T extends Required<import("react-native").ShadowStyleIOS> | Required<Pick<import("react-native").TextStyle, "textShadowColor" | "textShadowOffset" | "textShadowRadius">> | {
3
+ transform: Transforms;
4
+ }>(style: T) => T;
2
5
  //# sourceMappingURL=normalizeStyles.web.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalizeStyles.web.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizeStyles.web.ts"],"names":[],"mappings":"AA8EA,eAAO,MAAM,eAAe,gCAwB3B,CAAA"}
1
+ {"version":3,"file":"normalizeStyles.web.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizeStyles.web.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAoE,UAAU,EAAE,MAAM,UAAU,CAAA;AAuD5G,eAAO,MAAM,eAAe;;iBAwB3B,CAAA"}
@@ -0,0 +1,11 @@
1
+ import type { TextShadow, Transforms, BoxShadow } from '../types';
2
+ type Preprocessor = {
3
+ createTextShadowValue(style: TextShadow): string;
4
+ createBoxShadowValue(style: Required<BoxShadow>): string;
5
+ createTransformValue(transforms: Required<Transforms>): string;
6
+ };
7
+ export declare const normalizeColor: (color: string, opacity?: number) => string;
8
+ export declare const normalizeNumericValue: (value: number) => string | number;
9
+ export declare const preprocessor: Preprocessor;
10
+ export {};
11
+ //# sourceMappingURL=normalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizer.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizer.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEjE,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"}
@@ -1,4 +1,5 @@
1
- import type { Breakpoints, CustomNamedStyles, ScreenSize, SortedBreakpointEntries } from '../types';
1
+ import type { CustomNamedStyles, ScreenSize } from '../types';
2
+ import type { UnistylesBreakpoints } from '../global';
2
3
  /**
3
4
  * Proxies a function to parse its return value for custom media queries or breakpoints.
4
5
  *
@@ -20,7 +21,7 @@ import type { Breakpoints, CustomNamedStyles, ScreenSize, SortedBreakpointEntrie
20
21
  * const proxifiedFunction = proxifyFunction(myFunction, 'sm', screenSize, breakpoints)
21
22
  * proxifiedFunction() // parsed style based on screenSize and breakpoints
22
23
  */
23
- export declare const proxifyFunction: <B extends Breakpoints>(fn: Function, breakpoint: keyof B & string, screenSize: ScreenSize, breakpointPairs: SortedBreakpointEntries<B>) => Function;
24
+ export declare const proxifyFunction: (fn: Function, breakpoint: keyof UnistylesBreakpoints & string, screenSize: ScreenSize) => Function;
24
25
  /**
25
26
  * Parses a style object to resolve custom media queries or breakpoints based on the provided screen size and breakpoints.
26
27
  *
@@ -46,5 +47,5 @@ export declare const proxifyFunction: <B extends Breakpoints>(fn: Function, brea
46
47
  * const parsedStyle = parseStyle(style, 'sm', screenSize, breakpoints)
47
48
  * // { fontSize: '12px' }
48
49
  */
49
- export declare const parseStyle: <T, B extends Breakpoints>(style: CustomNamedStyles<T, B>, breakpoint: keyof B & string, screenSize: ScreenSize, breakpointPairs: SortedBreakpointEntries<B>) => T;
50
+ export declare const parseStyle: <T>(style: CustomNamedStyles<T>, breakpoint: keyof UnistylesBreakpoints & string, screenSize: ScreenSize) => T;
50
51
  //# 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,WAAW,EAAE,iBAAiB,EAAE,UAAU,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAKnG;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,8BACpB,QAAQ,4CACA,UAAU,kDAEvB,QAGD,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,uGAGP,UAAU,mDAmDzB,CAAA"}
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;AAI7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAA;AAErD;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,eAAe,OACpB,QAAQ,cAAc,MAAM,oBAAoB,GAAG,MAAM,cACjD,UAAU,KACvB,QAGD,CAAA;AAEF;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,eAAO,MAAM,UAAU,+CAEP,MAAM,oBAAoB,GAAG,MAAM,cACnC,UAAU,MAiDzB,CAAA"}
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "2.0.0-alpha.1",
3
+ "version": "2.0.0-alpha.3",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
7
+ "test:coverage": "jest --coverage",
7
8
  "tsc": "node_modules/typescript/bin/tsc --noEmit",
8
9
  "lint": "eslint . --ext .ts,.tsx",
9
10
  "prepare": "husky install && bob build",
@@ -18,7 +19,10 @@
18
19
  "files": [
19
20
  "src",
20
21
  "lib",
22
+ "ios",
23
+ "react-native-unistyles.podspec",
21
24
  "!**/*.spec.ts",
25
+ "!**/*.spec.tsx",
22
26
  "!**/.*"
23
27
  ],
24
28
  "keywords": [
@@ -39,6 +43,7 @@
39
43
  "devDependencies": {
40
44
  "@commitlint/config-conventional": "17.8.0",
41
45
  "@react-native/eslint-config": "0.74.0",
46
+ "@react-native/normalize-colors": "0.74.1",
42
47
  "@release-it/conventional-changelog": "7.0.2",
43
48
  "@testing-library/react-hooks": "8.0.1",
44
49
  "@types/jest": "29.5.6",
@@ -72,6 +77,7 @@
72
77
  "typescript": "5.2.2"
73
78
  },
74
79
  "peerDependencies": {
80
+ "@react-native/normalize-colors": "*",
75
81
  "react": "*",
76
82
  "react-native": "*",
77
83
  "react-native-web": "*"
@@ -82,7 +88,7 @@
82
88
  }
83
89
  },
84
90
  "workspaces": [
85
- "example",
91
+ "examples/expo",
86
92
  "docs"
87
93
  ],
88
94
  "packageManager": "yarn@3.6.1",
@@ -92,9 +98,13 @@
92
98
  "jest": {
93
99
  "preset": "react-native",
94
100
  "modulePathIgnorePatterns": [
95
- "<rootDir>/example/node_modules",
101
+ "<rootDir>/examples/expo/node_modules",
102
+ "<rootDir>/examples/ssr/node_modules",
96
103
  "<rootDir>/docs/node_modules",
97
104
  "<rootDir>/lib/"
105
+ ],
106
+ "coverageReporters": [
107
+ "html"
98
108
  ]
99
109
  },
100
110
  "commitlint": {
@@ -0,0 +1,21 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = package["name"]
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported }
14
+ s.source = { :git => package["repository"], :tag => "#{s.version}" }
15
+
16
+ s.source_files = [
17
+ "ios/*.{h,m,mm}"
18
+ ]
19
+
20
+ s.dependency "React-Core"
21
+ end
@@ -0,0 +1,35 @@
1
+ import type { UnistylesBridge, UnistylesConfig } from './types'
2
+ import type { UnistylesThemes, UnistylesBreakpoints } from './global'
3
+
4
+ export class UnistyleRegistry {
5
+ public config: UnistylesConfig = {}
6
+ public themes: UnistylesThemes = {} as UnistylesThemes
7
+ public breakpoints: UnistylesBreakpoints = {} as UnistylesBreakpoints
8
+ public sortedBreakpointPairs: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]> = []
9
+
10
+ constructor(private unistylesBridge: UnistylesBridge) {}
11
+
12
+ public addThemes = (themes: UnistylesThemes) => {
13
+ this.themes = themes
14
+ this.unistylesBridge.themes = Object.keys(themes) as Array<keyof UnistylesThemes>
15
+
16
+ return this
17
+ }
18
+
19
+ public addBreakpoints = (breakpoints: UnistylesBreakpoints) => {
20
+ this.unistylesBridge.useBreakpoints(breakpoints)
21
+ this.sortedBreakpointPairs = this.unistylesBridge.sortedBreakpointPairs
22
+
23
+ return this
24
+ }
25
+
26
+ public addConfig = (config: UnistylesConfig) => {
27
+ this.config = config
28
+
29
+ if (config.adaptiveThemes) {
30
+ this.unistylesBridge.useAdaptiveThemes(config.adaptiveThemes)
31
+ }
32
+
33
+ return this
34
+ }
35
+ }
@@ -0,0 +1,41 @@
1
+ import { UnistylesModule } from './UnistylesModule'
2
+ import { UnistylesRuntime } from './UnistylesRuntime'
3
+ import { UnistylesEngine } from './UnistylesEngine'
4
+ import { UnistyleRegistry } from './UnistyleRegistry'
5
+ import type { UnistylesBridge } from './types'
6
+ import { UnistylesError } from './types'
7
+
8
+ class Unistyles {
9
+ private _runtime: UnistylesRuntime
10
+ private _engine: UnistylesEngine
11
+ private _registry: UnistyleRegistry
12
+ private _bridge: UnistylesBridge
13
+
14
+ constructor() {
15
+ const isInstalled = UnistylesModule?.install() ?? false
16
+
17
+ if (!isInstalled) {
18
+ throw new Error(UnistylesError.RuntimeUnavailable)
19
+ }
20
+
21
+ // @ts-ignore
22
+ this._bridge = global.__UNISTYLES__ as UnistylesBridge
23
+ this._registry = new UnistyleRegistry(this._bridge)
24
+ this._runtime = new UnistylesRuntime(this._bridge, this._registry)
25
+ this._engine = new UnistylesEngine(this._registry, this._runtime)
26
+ }
27
+
28
+ public get registry() {
29
+ return this._registry
30
+ }
31
+
32
+ public get runtime() {
33
+ return this._runtime
34
+ }
35
+
36
+ public get engine() {
37
+ return this._engine
38
+ }
39
+ }
40
+
41
+ export const unistyles = new Unistyles()
@@ -0,0 +1,15 @@
1
+ import type { UnistyleRegistry } from './UnistyleRegistry'
2
+ import type { UnistylesRuntime } from './UnistylesRuntime'
3
+
4
+ // todo implement engine
5
+ export class UnistylesEngine {
6
+ // @ts-ignore
7
+ constructor(private registry: UnistyleRegistry, private runtime: UnistylesRuntime) {
8
+ this.registry = registry
9
+ this.runtime = runtime
10
+ }
11
+
12
+ // UnistylesEngine.parseStyleSheet
13
+ // UnistylesEngine.parseStyle
14
+ // UnistylesEngine.proxify
15
+ }
@@ -0,0 +1,7 @@
1
+ import { NativeModules } from 'react-native'
2
+
3
+ type UnistylesNativeModule = {
4
+ install(): boolean
5
+ }
6
+
7
+ export const UnistylesModule = NativeModules?.Unistyles as UnistylesNativeModule
@@ -0,0 +1,69 @@
1
+ import type { UnistylesBridge } from './types'
2
+ import type { UnistyleRegistry } from './UnistyleRegistry'
3
+ import { ScreenOrientation, UnistylesError } from './types'
4
+ import type { UnistylesThemes } from './global'
5
+
6
+ export class UnistylesRuntime {
7
+ constructor(private unistylesBridge: UnistylesBridge, private registry: UnistyleRegistry) {}
8
+
9
+ public get colorScheme() {
10
+ return this.unistylesBridge.colorScheme
11
+ }
12
+
13
+ public get hasAdaptiveThemes() {
14
+ return this.unistylesBridge.hasAdaptiveThemes
15
+ }
16
+
17
+ public get sortedBreakpoints() {
18
+ return this.registry.sortedBreakpointPairs
19
+ }
20
+
21
+ public get themeName() {
22
+ return this.unistylesBridge.theme
23
+ }
24
+
25
+ public get breakpoint() {
26
+ return this.unistylesBridge.breakpoint
27
+ }
28
+
29
+ public get screen() {
30
+ return {
31
+ width: this.unistylesBridge.screenWidth,
32
+ height: this.unistylesBridge.screenHeight
33
+ }
34
+ }
35
+
36
+ public get orientation() {
37
+ const { width, height } = this.screen
38
+
39
+ if (width > height) {
40
+ return ScreenOrientation.Landscape
41
+ }
42
+
43
+ return ScreenOrientation.Portrait
44
+ }
45
+
46
+ public setTheme = (name: keyof UnistylesThemes) => {
47
+ if (name !== this.themeName && this.hasTheme(name)) {
48
+ this.unistylesBridge.useTheme(name)
49
+
50
+ return true
51
+ }
52
+
53
+ return false
54
+ }
55
+
56
+ public getTheme = (forName: keyof UnistylesThemes) => {
57
+ if (!this.hasTheme(forName)) {
58
+ throw new Error(UnistylesError.ThemeNotFound)
59
+ }
60
+
61
+ return this.registry.themes[forName]
62
+ }
63
+
64
+ public setAdaptiveThemes = (enable: boolean) => {
65
+ this.unistylesBridge.useAdaptiveThemes(enable)
66
+ }
67
+
68
+ private hasTheme = (name: keyof UnistylesThemes) => name in this.registry.themes
69
+ }
@@ -0,0 +1,12 @@
1
+ import type { CustomNamedStyles } from './types'
2
+ import type { UnistylesThemes } from './global'
3
+
4
+ type T = UnistylesThemes[keyof UnistylesThemes]
5
+
6
+ export const createStyleSheet = <S extends CustomNamedStyles<S>, X>(styles: S | CustomNamedStyles<S> | X | ((theme: T) => X | CustomNamedStyles<X>)): S | X => {
7
+ if (typeof styles === 'function') {
8
+ return styles as X
9
+ }
10
+
11
+ return styles as S
12
+ }
package/src/global.ts ADDED
@@ -0,0 +1,2 @@
1
+ export interface UnistylesThemes {}
2
+ export interface UnistylesBreakpoints {}
@@ -1,11 +1,12 @@
1
1
  import { useEffect, useRef, useState } from 'react'
2
2
  import type { ScreenSize } from '../types'
3
+ import { isServer } from '../utils'
3
4
 
4
5
  export const useDimensions = (): ScreenSize => {
5
6
  const timerRef = useRef<ReturnType<typeof setTimeout>>()
6
7
  const [screenSize, setScreenSize] = useState<ScreenSize>({
7
- width: window.innerWidth,
8
- height: window.innerHeight
8
+ width: isServer ? 0 : window.innerWidth,
9
+ height: isServer ? 0 : window.innerHeight
9
10
  })
10
11
 
11
12
  useEffect(() => {