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

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 +5 -4
  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 +5 -4
  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 +4 -4
  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
package/src/types/core.ts CHANGED
@@ -78,6 +78,7 @@ export type CustomNamedStyles<T> = {
78
78
  : StaticStyles
79
79
  }
80
80
 
81
+ export type RNStyle = ViewStyle | TextStyle | ImageStyle
81
82
  export type RNValue = number | string | undefined
82
83
  export type NestedStyle = Record<keyof UnistylesBreakpoints | MediaQuery, RNValue>
83
84
  export type NestedStylePairs = Array<[keyof UnistylesBreakpoints | MediaQuery, RNValue]>
@@ -2,6 +2,16 @@ 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 {
6
+ CustomNamedStyles,
7
+ NestedStylePairs,
8
+ UnistylesTheme,
9
+ CreateStylesFactory,
10
+ ScreenSize,
11
+ NestedStyle,
12
+ RNValue,
13
+ RNStyle
14
+ } from './core'
6
15
  export type { ReactNativeStyleSheet } from './breakpoints'
7
16
  export type { ExtractVariantNames } from './variants'
17
+ export type { UnistylesPlugin } from './plugin'
@@ -0,0 +1,7 @@
1
+ import type { RNStyle } from './core'
2
+ import type { UnistylesRuntime } from '../core'
3
+
4
+ export type UnistylesPlugin = {
5
+ name: string,
6
+ onParsedStyle?: (styleKey: string, style: RNStyle, runtime: UnistylesRuntime) => RNStyle
7
+ }
@@ -2,17 +2,21 @@ 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
 
6
7
  export type ColorSchemeName = Optional<'light' | 'dark'>
7
8
 
8
9
  export type UnistylesConfig = {
9
- adaptiveThemes?: boolean
10
+ adaptiveThemes?: boolean,
11
+ experimentalPlugins?: Array<UnistylesPlugin>,
12
+ initialTheme?: keyof UnistylesThemes
10
13
  }
11
14
 
12
15
  export type UnistylesBridge = {
13
16
  // getters
14
17
  screenWidth: number,
15
18
  screenHeight: number,
19
+ enabledPlugins: Array<string>,
16
20
  hasAdaptiveThemes: boolean,
17
21
  themeName: keyof UnistylesThemes,
18
22
  breakpoint: keyof UnistylesBreakpoints,
@@ -23,7 +27,9 @@ export type UnistylesBridge = {
23
27
  themes: Array<keyof UnistylesThemes>,
24
28
  useBreakpoints(breakpoints: UnistylesBreakpoints): void,
25
29
  useTheme(name: keyof UnistylesThemes): void,
26
- useAdaptiveThemes(enable: boolean): void
30
+ useAdaptiveThemes(enable: boolean): void,
31
+ addPlugin(pluginName: string, notify: boolean): void,
32
+ removePlugin(pluginName: string): void
27
33
  }
28
34
 
29
35
  export type UnistylesThemeEvent = {
@@ -38,8 +44,12 @@ export type UnistylesMobileLayoutEvent = {
38
44
  payload: {
39
45
  screen: ScreenSize,
40
46
  breakpoint: keyof UnistylesBreakpoints,
41
- orientation: ScreenOrientation
47
+ orientation: typeof ScreenOrientation[keyof typeof ScreenOrientation]
42
48
  }
43
49
  }
44
50
 
45
- export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent
51
+ export type UnistylesPluginEvent = {
52
+ type: CxxUnistylesEventTypes.Plugin
53
+ }
54
+
55
+ export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent | UnistylesPluginEvent
package/src/useStyles.ts CHANGED
@@ -21,7 +21,7 @@ export const useStyles = <ST extends CustomNamedStyles<ST>>(
21
21
  stylesheet?: ST | CreateStylesFactory<ST, UnistylesTheme>,
22
22
  variant?: ExtractVariantNames<typeof stylesheet> & string
23
23
  ): ParsedStylesheet<ST> => {
24
- const { theme, layout } = useUnistyles()
24
+ const { theme, layout, plugins } = useUnistyles()
25
25
  const { screenSize, breakpoint } = layout
26
26
 
27
27
  if (!stylesheet) {
@@ -44,15 +44,15 @@ export const useStyles = <ST extends CustomNamedStyles<ST>>(
44
44
  if (typeof value === 'function') {
45
45
  return {
46
46
  ...acc,
47
- [key]: proxifyFunction(value, breakpoint, screenSize, variant)
47
+ [key]: proxifyFunction(key, value, breakpoint, screenSize, variant)
48
48
  }
49
49
  }
50
50
 
51
51
  return StyleSheet.create({
52
52
  ...acc,
53
- [key]: parseStyle<ST>(style, breakpoint, screenSize, variant)
53
+ [key]: parseStyle<ST>(key, style, breakpoint, screenSize, variant)
54
54
  })
55
- }, {} as ST), [breakpoint, screenSize, parsedStyles, variant]) as ReactNativeStyleSheet<ST>
55
+ }, {} as ST), [breakpoint, screenSize, parsedStyles, variant, plugins]) as ReactNativeStyleSheet<ST>
56
56
 
57
57
  return {
58
58
  theme,
@@ -1,53 +1,10 @@
1
1
  import { unistyles } from '../core'
2
- import { isMobile, Orientation, throwError } from './common'
3
- import type { NestedStyle, NestedStylePairs, RNValue } from '../types'
2
+ import type { NestedStyle, NestedStylePairs, Optional, RNValue } from '../types'
4
3
  import type { UnistylesBreakpoints } from '../global'
5
- import { ScreenOrientation } from '../common'
4
+ import { ScreenOrientation, isMobile } from '../common'
6
5
  import { getKeyForUnistylesMediaQuery } from './mqParser'
7
6
 
8
- export const sortAndValidateBreakpoints = (breakpoints: UnistylesBreakpoints): UnistylesBreakpoints => {
9
- const sortedPairs = Object
10
- .entries(breakpoints)
11
- .sort((breakpoint1, breakpoint2) => {
12
- const [, value1] = breakpoint1
13
- const [, value2] = breakpoint2
14
-
15
- return (value1 as number) - (value2 as number)
16
- })
17
-
18
- const sortedBreakpoints = Object.freeze(Object.fromEntries(sortedPairs)) as UnistylesBreakpoints
19
- const breakpointValues = Object.values(sortedBreakpoints)
20
- const [firstBreakpoint] = breakpointValues
21
-
22
- if (firstBreakpoint !== 0) {
23
- throwError('first breakpoint must start with 0')
24
- }
25
-
26
- if (breakpointValues.length !== new Set(breakpointValues).size) {
27
- throwError('breakpoint values are duplicated')
28
- }
29
-
30
- return sortedBreakpoints
31
- }
32
-
33
- export const getBreakpointFromScreenWidth = (width: number, breakpointEntries: Array<[keyof UnistylesBreakpoints, UnistylesBreakpoints[keyof UnistylesBreakpoints]]>): keyof UnistylesBreakpoints & string => {
34
- const [key] = breakpointEntries
35
- .find(([, value], index, otherBreakpoints) => {
36
- const minVal = value as number
37
- const maxVal = otherBreakpoints[index + 1]?.[1]
38
-
39
- if (!maxVal) {
40
- return true
41
- }
42
-
43
- return width >= minVal && width < maxVal
44
- }) as [keyof UnistylesBreakpoints & string, number]
45
-
46
- return key
47
- }
48
-
49
- export const getValueForBreakpoint = (value: NestedStyle): RNValue => {
50
- // the highest priority is for custom media queries
7
+ export const getValueForBreakpoint = (value: NestedStyle): Optional<RNValue> => {
51
8
  const customMediaQueryKey = getKeyForUnistylesMediaQuery(
52
9
  Object.entries(value) as NestedStylePairs,
53
10
  unistyles.runtime.screen
@@ -57,44 +14,31 @@ export const getValueForBreakpoint = (value: NestedStyle): RNValue => {
57
14
  return value[customMediaQueryKey]
58
15
  }
59
16
 
60
- // at this point user didn't use custom media queries (:w, :h)
61
- // check if user defined any breakpoints
62
- const hasBreakpoints = unistyles.runtime.sortedBreakpoints.length > 0
17
+ const hasBreakpoints = unistyles.registry.sortedBreakpointPairs.length > 0
63
18
 
64
- // if not then we can fall back to horizontal and portrait (mobile only)
65
- if (!hasBreakpoints && isMobile && (Orientation.Landscape in value || Orientation.Portrait in value)) {
66
- return value[
67
- unistyles.runtime.orientation === ScreenOrientation.Portrait
68
- ? Orientation.Portrait
69
- : Orientation.Landscape
70
- ]
19
+ if (!hasBreakpoints && isMobile && (ScreenOrientation.Landscape in value || ScreenOrientation.Portrait in value)) {
20
+ return value[unistyles.runtime.orientation]
71
21
  }
72
22
 
73
- // let's get the current breakpoint
74
23
  const breakpoint = unistyles.runtime.breakpoint
75
24
 
76
25
  if (!breakpoint) {
77
26
  return undefined
78
27
  }
79
28
 
80
- // if user defined breakpoints, then we look for the valid one
81
29
  const directBreakpoint = value[breakpoint]
82
30
 
83
- // if there is a direct key like 'sm' or 'md', or value for this key exists but its undefined
84
31
  if (directBreakpoint || (breakpoint in value)) {
85
32
  return directBreakpoint
86
33
  }
87
34
 
88
- // there is no direct hit for breakpoint nor media-query, let's simulate CSS cascading
89
- const breakpointPairs = unistyles.runtime.sortedBreakpoints
90
- const currentBreakpoint = breakpointPairs
35
+ const breakpointPairs = unistyles.registry.sortedBreakpointPairs
36
+ const currentBreakpointIndex = breakpointPairs
91
37
  .findIndex(([key]) => key === breakpoint)
92
38
 
93
39
  const availableBreakpoints = breakpointPairs
94
- .filter(([key], index) => index < currentBreakpoint && key && key in value)
40
+ .filter(([key], index) => index < currentBreakpointIndex && key in value)
95
41
  .map(([key]) => key)
96
42
 
97
- return breakpointPairs.length > 0
98
- ? value[availableBreakpoints[availableBreakpoints.length - 1] as keyof UnistylesBreakpoints & string]
99
- : undefined
43
+ return value[availableBreakpoints[availableBreakpoints.length - 1] as keyof UnistylesBreakpoints & string]
100
44
  }
@@ -1,8 +1,5 @@
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'
package/src/utils/mq.ts CHANGED
@@ -78,7 +78,7 @@ const heightHandler = (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) =>
78
78
  if (prop === MQProp.height || prop === MQProp.shortH) {
79
79
  return (hMin: MQValue = 0, hMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
80
80
  get: (target, prop, receiver) => {
81
- if (prop === Symbol.toPrimitive || MQProp.toString) {
81
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
82
82
  return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
83
83
  }
84
84
 
@@ -14,7 +14,7 @@ type UnistylesParsedMq = {
14
14
  height?: ParsedMqDimension
15
15
  }
16
16
 
17
- const parseMq = (mq: string): UnistylesParsedMq => {
17
+ export const parseMq = (mq: string): UnistylesParsedMq => {
18
18
  const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || []
19
19
  const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || []
20
20
 
@@ -32,7 +32,7 @@ const parseMq = (mq: string): UnistylesParsedMq => {
32
32
 
33
33
  const isUnistylesMq = (mq: string) => IS_UNISTYLES_REGEX.test(mq)
34
34
 
35
- const isValidMq = (parsedMq: UnistylesParsedMq) => {
35
+ export const isValidMq = (parsedMq: UnistylesParsedMq) => {
36
36
  const { width, height } = parsedMq
37
37
 
38
38
  if (width && height) {
@@ -50,7 +50,7 @@ const isValidMq = (parsedMq: UnistylesParsedMq) => {
50
50
  return false
51
51
  }
52
52
 
53
- const isWithinTheWidthAndHeight = (parsedMq: UnistylesParsedMq, screenSize: ScreenSize): boolean => {
53
+ export const isWithinTheWidthAndHeight = (parsedMq: UnistylesParsedMq, screenSize: ScreenSize): boolean => {
54
54
  const { width, height } = parsedMq
55
55
 
56
56
  if (width && height) {
@@ -80,7 +80,7 @@ const isWithinTheHeight = (height: UnistylesParsedMq['height'], screenHeight: nu
80
80
  return screenHeight >= from && screenHeight <= to
81
81
  }
82
82
 
83
- export const getKeyForUnistylesMediaQuery = (mediaQueries: NestedStylePairs, screenSize: ScreenSize) => {
83
+ export const getKeyForUnistylesMediaQuery = (mediaQueries: NestedStylePairs, screenSize: ScreenSize): Optional<string> => {
84
84
  const mq = mediaQueries.find(([key]) => {
85
85
  if (!isUnistylesMq(key as string)) {
86
86
  return false
@@ -1,17 +1,18 @@
1
- import type { CustomNamedStyles, ScreenSize, NestedStyle } from '../types'
1
+ import type { CustomNamedStyles, ScreenSize, NestedStyle, RNStyle } from '../types'
2
2
  import { getValueForBreakpoint } from './breakpoints'
3
- import { normalizeStyles } from './normalizeStyles'
4
3
  import type { UnistylesBreakpoints } from '../global'
5
- import { isAndroid, isIOS, isWeb } from './common'
4
+ import { isAndroid, isIOS } from '../common'
6
5
  import { getKeyForVariant } from './variants'
6
+ import { withPlugins } from '../plugins'
7
7
 
8
8
  export const proxifyFunction = (
9
+ key: string,
9
10
  fn: Function, breakpoint: keyof UnistylesBreakpoints & string,
10
11
  screenSize: ScreenSize,
11
12
  variant?: string
12
13
  ): Function => new Proxy(fn, {
13
14
  apply: (target, thisArg, argumentsList) =>
14
- parseStyle(target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
15
+ parseStyle(key, target.apply(thisArg, argumentsList), breakpoint, screenSize, variant)
15
16
  })
16
17
 
17
18
  export const isPlatformColor = <T extends {}>(value: T): boolean => {
@@ -22,7 +23,8 @@ export const isPlatformColor = <T extends {}>(value: T): boolean => {
22
23
  return isAndroid && 'resource_paths' in value && typeof value.resource_paths === 'object'
23
24
  }
24
25
 
25
- export const parseStyle = <T>(
26
+ export const parseStyle = <T extends RNStyle>(
27
+ key: string,
26
28
  style: CustomNamedStyles<T>,
27
29
  breakpoint: keyof UnistylesBreakpoints & string,
28
30
  screenSize: ScreenSize,
@@ -58,7 +60,7 @@ export const parseStyle = <T>(
58
60
  if (hasNestedProperties) {
59
61
  return [
60
62
  key,
61
- parseStyle(value as CustomNamedStyles<T>, breakpoint, screenSize, variant)
63
+ parseStyle(key, value as CustomNamedStyles<T>, breakpoint, screenSize, variant)
62
64
  ]
63
65
  }
64
66
 
@@ -67,7 +69,7 @@ export const parseStyle = <T>(
67
69
  if (isTransform && Array.isArray(value)) {
68
70
  return [
69
71
  key,
70
- value.map(value => parseStyle(value, breakpoint, screenSize, variant))
72
+ value.map(value => parseStyle(key, value, breakpoint, screenSize, variant))
71
73
  ]
72
74
  }
73
75
 
@@ -83,9 +85,7 @@ export const parseStyle = <T>(
83
85
  getValueForBreakpoint(value as NestedStyle)
84
86
  ]
85
87
  })
86
- )
88
+ ) as T
87
89
 
88
- return isWeb
89
- ? normalizeStyles(parsedStyles)
90
- : parsedStyles
90
+ return withPlugins(key, parsedStyles) as T
91
91
  }
@@ -1,25 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.warn = exports.throwError = exports.isWeb = exports.isServer = exports.isMobile = exports.isIOS = exports.isAndroid = exports.Orientation = void 0;
7
- var _reactNative = require("react-native");
8
- const throwError = message => {
9
- throw new Error(`🦄 [react-native-unistyles]: ${message}`);
10
- };
11
- exports.throwError = throwError;
12
- const warn = message => {
13
- console.warn(`🦄 [react-native-unistyles]: ${message}`);
14
- };
15
- exports.warn = warn;
16
- const isMobile = exports.isMobile = _reactNative.Platform.OS === 'android' || _reactNative.Platform.OS === 'ios';
17
- const isWeb = exports.isWeb = _reactNative.Platform.OS === 'web';
18
- const isIOS = exports.isIOS = _reactNative.Platform.OS === 'ios';
19
- const isAndroid = exports.isAndroid = _reactNative.Platform.OS === 'android';
20
- const isServer = exports.isServer = typeof window === 'undefined';
21
- const Orientation = exports.Orientation = {
22
- Landscape: 'landscape',
23
- Portrait: 'portrait'
24
- };
25
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["_reactNative","require","throwError","message","Error","exports","warn","console","isMobile","Platform","OS","isWeb","isIOS","isAndroid","isServer","window","Orientation","Landscape","Portrait"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAAAE,OAAA,CAAAH,UAAA,GAAAA,UAAA;AAEM,MAAMI,IAAI,GAAIH,OAAe,IAAK;EACrCI,OAAO,CAACD,IAAI,CAAE,gCAA+BH,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAAAE,OAAA,CAAAC,IAAA,GAAAA,IAAA;AAEM,MAAME,QAAQ,GAAAH,OAAA,CAAAG,QAAA,GAAGC,qBAAQ,CAACC,EAAE,KAAK,SAAS,IAAID,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnE,MAAMC,KAAK,GAAAN,OAAA,CAAAM,KAAA,GAAGF,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAME,KAAK,GAAAP,OAAA,CAAAO,KAAA,GAAGH,qBAAQ,CAACC,EAAE,KAAK,KAAK;AACnC,MAAMG,SAAS,GAAAR,OAAA,CAAAQ,SAAA,GAAGJ,qBAAQ,CAACC,EAAE,KAAK,SAAS;AAC3C,MAAMI,QAAQ,GAAAT,OAAA,CAAAS,QAAA,GAAG,OAAOC,MAAM,KAAK,WAAW;AAE9C,MAAMC,WAAW,GAAAX,OAAA,CAAAW,WAAA,GAAG;EACvBC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU"}
@@ -1,10 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.normalizeStyles = void 0;
7
- // nothing to do here
8
- const normalizeStyles = styles => styles;
9
- exports.normalizeStyles = normalizeStyles;
10
- //# sourceMappingURL=normalizeStyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["normalizeStyles","styles","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,eAAe,GAAOC,MAAS,IAAKA,MAAW;AAAAC,OAAA,CAAAF,eAAA,GAAAA,eAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_common","require","_normalizer","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","warn","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","preprocessor","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow","exports"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":";;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAA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,eAAe,GAAkErB,KAAQ,IAAQ;EAC1G,MAAMsB,mBAAmB,GAAI,WAAW,IAAItB,KAAK,IAAIuB,KAAK,CAACC,OAAO,CAACxB,KAAK,CAACyB,SAAS,CAAC,GAC7E;IAAEA,SAAS,EAAEb,wBAAY,CAACc,oBAAoB,CAAC1B,KAAK,CAACyB,SAAS;EAAE,CAAC,GACjE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAI3B,KAAK,IACtB,cAAc,IAAIA,KAAK,IACvB,eAAe,IAAIA,KAAK,IACxB,cAAc,IAAIA,KAAK,GACvBD,kBAAkB,CAACC,KAAkB,CAAC,GAAG,CAAC,CAAC;EAE/C,MAAM4B,oBAAoB,GACtB,iBAAiB,IAAI5B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3Bc,mBAAmB,CAACd,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGsB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAR,eAAA,GAAAA,eAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","obj","__esModule","default","normalizeColor","color","opacity","arguments","length","undefined","integer","normalizeColors","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","exports","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["utils/normalizer.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AAA4D,SAAAD,uBAAAE,GAAA,WAAAA,GAAA,IAAAA,GAAA,CAAA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IAAI;EACd,MAAM,CAACnB,GAAG,CAAC,GAAGoB,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACnB,GAAG,EAAE;IACN,OAAOrB,SAAS;EACpB;EAEA,MAAMmB,KAAK,GAAGqB,SAAS,CAACnB,GAAG,CAA2B;EAEtD,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAQ,GAAEA,GAAI,IAAIF,KAAK,CAAmBwB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEtB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDL,MAAM,CAAC8B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEP,MAAME,YAA0B,GAAA5B,OAAA,CAAA4B,YAAA,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -1,17 +0,0 @@
1
- import { Platform } from 'react-native';
2
- export const throwError = message => {
3
- throw new Error(`🦄 [react-native-unistyles]: ${message}`);
4
- };
5
- export const warn = message => {
6
- console.warn(`🦄 [react-native-unistyles]: ${message}`);
7
- };
8
- export const isMobile = Platform.OS === 'android' || Platform.OS === 'ios';
9
- export const isWeb = Platform.OS === 'web';
10
- export const isIOS = Platform.OS === 'ios';
11
- export const isAndroid = Platform.OS === 'android';
12
- export const isServer = typeof window === 'undefined';
13
- export const Orientation = {
14
- Landscape: 'landscape',
15
- Portrait: 'portrait'
16
- };
17
- //# sourceMappingURL=common.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["Platform","throwError","message","Error","warn","console","isMobile","OS","isWeb","isIOS","isAndroid","isServer","window","Orientation","Landscape","Portrait"],"sourceRoot":"../../../src","sources":["utils/common.ts"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,cAAc;AAEvC,OAAO,MAAMC,UAAU,GAAIC,OAAe,IAAK;EAC3C,MAAM,IAAIC,KAAK,CAAE,gCAA+BD,OAAQ,EAAC,CAAC;AAC9D,CAAC;AAED,OAAO,MAAME,IAAI,GAAIF,OAAe,IAAK;EACrCG,OAAO,CAACD,IAAI,CAAE,gCAA+BF,OAAQ,EAAC,CAAC;AAC3D,CAAC;AAED,OAAO,MAAMI,QAAQ,GAAGN,QAAQ,CAACO,EAAE,KAAK,SAAS,IAAIP,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1E,OAAO,MAAMC,KAAK,GAAGR,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAME,KAAK,GAAGT,QAAQ,CAACO,EAAE,KAAK,KAAK;AAC1C,OAAO,MAAMG,SAAS,GAAGV,QAAQ,CAACO,EAAE,KAAK,SAAS;AAClD,OAAO,MAAMI,QAAQ,GAAG,OAAOC,MAAM,KAAK,WAAW;AAErD,OAAO,MAAMC,WAAW,GAAG;EACvBC,SAAS,EAAE,WAAW;EACtBC,QAAQ,EAAE;AACd,CAAU"}
@@ -1,3 +0,0 @@
1
- // nothing to do here
2
- export const normalizeStyles = styles => styles;
3
- //# sourceMappingURL=normalizeStyles.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["normalizeStyles","styles"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.ts"],"mappings":"AAAA;AACA,OAAO,MAAMA,eAAe,GAAOC,MAAS,IAAKA,MAAW"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["warn","preprocessor","normalizeBoxShadow","style","requiredBoxShadowProperties","every","prop","join","shadowColor","undefined","shadowOffset","shadowOpacity","shadowRadius","boxShadow","createBoxShadowValue","normalizeTextShadow","requiredTextShadowProperties","textShadowColor","textShadowOffset","textShadowRadius","textShadow","createTextShadowValue","normalizeStyles","normalizedTransform","Array","isArray","transform","createTransformValue","normalizedBoxShadow","normalizedTextShadow"],"sourceRoot":"../../../src","sources":["utils/normalizeStyles.web.ts"],"mappings":"AAAA,SAASA,IAAI,QAAQ,UAAU;AAC/B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Ae,GAAkEnB,KAAQ,IAAQ;EAC1G,MAAMoB,mBAAmB,GAAI,WAAW,IAAIpB,KAAK,IAAIqB,KAAK,CAACC,OAAO,CAACtB,KAAK,CAACuB,SAAS,CAAC,GAC7E;IAAEA,SAAS,EAAEzB,YAAY,CAAC0B,oBAAoB,CAACxB,KAAK,CAACuB,SAAS;EAAE,CAAC,GACjE,CAAC,CAAC;EAER,MAAME,mBAAmB,GACrB,aAAa,IAAIzB,KAAK,IACtB,cAAc,IAAIA,KAAK,IACvB,eAAe,IAAIA,KAAK,IACxB,cAAc,IAAIA,KAAK,GACvBD,kBAAkB,CAACC,KAAkB,CAAC,GAAG,CAAC,CAAC;EAE/C,MAAM0B,oBAAoB,GACtB,iBAAiB,IAAI1B,KAAK,IAC1B,kBAAkB,IAAIA,KAAK,IAC3B,kBAAkB,IAAIA,KAAK,GAC3BY,mBAAmB,CAACZ,KAAmB,CAAC,GAAG,CAAC,CAAC;EAEjD,OAAO;IACH,GAAGA,KAAK;IACR,GAAGoB,mBAAmB;IACtB,GAAGK,mBAAmB;IACtB,GAAGC;EACP,CAAC;AACL,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["normalizeColors","normalizeColor","color","opacity","arguments","length","undefined","integer","hex","toString","padStart","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","normalizeNumericValue","value","normalizeTransform","key","includes","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","createBoxShadowValue","shadowColor","shadowOffset","shadowOpacity","shadowRadius","createTransformValue","transforms","transform","Object","keys","join","Boolean","preprocessor"],"sourceRoot":"../../../src","sources":["utils/normalizer.ts"],"mappings":"AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAS5D,OAAO,MAAMC,cAAc,GAAG,SAAAA,CAACC,KAAa,EAA0B;EAAA,IAAxBC,OAAe,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG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BwB,IAAI,CAAC,GAAG,CAAE,GAAE;IAC1D;MACI,OAAQ,GAAEtB,GAAI,IAAGD,kBAAkB,CAACC,GAAG,EAAEF,KAAK,CAAE,GAAE;EAC1D;AACJ,CAAC,CAAC,CACDJ,MAAM,CAAC6B,OAAO,CAAC,CACfD,IAAI,CAAC,GAAG,CAAC;AAEd,OAAO,MAAME,YAA0B,GAAG;EACtCtB,qBAAqB;EACrBU,oBAAoB;EACpBK;AACJ,CAAC"}
@@ -1,12 +0,0 @@
1
- export declare const throwError: (message: string) => never;
2
- export declare const warn: (message: string) => void;
3
- export declare const isMobile: boolean;
4
- export declare const isWeb: boolean;
5
- export declare const isIOS: boolean;
6
- export declare const isAndroid: boolean;
7
- export declare const isServer: boolean;
8
- export declare const Orientation: {
9
- readonly Landscape: "landscape";
10
- readonly Portrait: "portrait";
11
- };
12
- //# sourceMappingURL=common.d.ts.map
@@ -1 +0,0 @@
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,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,WAAW;;;CAGd,CAAA"}
@@ -1,2 +0,0 @@
1
- export declare const normalizeStyles: <T>(styles: T) => T;
2
- //# sourceMappingURL=normalizeStyles.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeStyles.d.ts","sourceRoot":"","sources":["../../../../src/utils/normalizeStyles.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,eAAe,qBAAgC,CAAA"}
@@ -1,5 +0,0 @@
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;
5
- //# sourceMappingURL=normalizeStyles.web.d.ts.map
@@ -1 +0,0 @@
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"}
@@ -1 +0,0 @@
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,20 +0,0 @@
1
- import { Platform } from 'react-native'
2
-
3
- export const throwError = (message: string) => {
4
- throw new Error(`🦄 [react-native-unistyles]: ${message}`)
5
- }
6
-
7
- export const warn = (message: string) => {
8
- console.warn(`🦄 [react-native-unistyles]: ${message}`)
9
- }
10
-
11
- export const isMobile = Platform.OS === 'android' || Platform.OS === 'ios'
12
- export const isWeb = Platform.OS === 'web'
13
- export const isIOS = Platform.OS === 'ios'
14
- export const isAndroid = Platform.OS === 'android'
15
- export const isServer = typeof window === 'undefined'
16
-
17
- export const Orientation = {
18
- Landscape: 'landscape',
19
- Portrait: 'portrait'
20
- } as const
@@ -1,2 +0,0 @@
1
- // nothing to do here
2
- export const normalizeStyles = <T>(styles: T) => styles as T
File without changes