react-native-unistyles 2.0.0-alpha.7 → 2.0.0-alpha.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. package/cxx/UnistylesRuntime.cpp +24 -31
  2. package/cxx/UnistylesRuntime.h +11 -12
  3. package/ios/UnistylesModule.mm +20 -20
  4. package/lib/commonjs/{types/cxx.js → common.js} +6 -6
  5. package/lib/commonjs/common.js.map +1 -0
  6. package/lib/commonjs/{UnistyleRegistry.js → core/UnistyleRegistry.js} +1 -8
  7. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -0
  8. package/lib/commonjs/{Unistyles.js → core/Unistyles.js} +2 -7
  9. package/lib/commonjs/core/Unistyles.js.map +1 -0
  10. package/lib/commonjs/core/UnistylesModule.js.map +1 -0
  11. package/lib/commonjs/{UnistylesRuntime.js → core/UnistylesRuntime.js} +6 -6
  12. package/lib/commonjs/core/UnistylesRuntime.js.map +1 -0
  13. package/lib/commonjs/core/index.js +13 -0
  14. package/lib/commonjs/core/index.js.map +1 -0
  15. package/lib/commonjs/hooks/index.js +10 -3
  16. package/lib/commonjs/hooks/index.js.map +1 -1
  17. package/lib/commonjs/{useInitialTheme.js → hooks/useInitialTheme.js} +6 -2
  18. package/lib/commonjs/hooks/useInitialTheme.js.map +1 -0
  19. package/lib/commonjs/hooks/useUnistyles.js +54 -0
  20. package/lib/commonjs/hooks/useUnistyles.js.map +1 -0
  21. package/lib/commonjs/index.js +10 -16
  22. package/lib/commonjs/index.js.map +1 -1
  23. package/lib/commonjs/types/common.js +2 -0
  24. package/lib/commonjs/types/{mediaQueries.js.map → common.js.map} +1 -1
  25. package/lib/commonjs/types/index.js +4 -4
  26. package/lib/commonjs/types/index.js.map +1 -1
  27. package/lib/commonjs/types/mq.js +6 -0
  28. package/lib/{module/types/mediaQueries.js.map → commonjs/types/mq.js.map} +1 -1
  29. package/lib/commonjs/types/unistyles.js +6 -0
  30. package/lib/commonjs/types/unistyles.js.map +1 -0
  31. package/lib/commonjs/useStyles.js +7 -4
  32. package/lib/commonjs/useStyles.js.map +1 -1
  33. package/lib/commonjs/utils/breakpoints.js +18 -20
  34. package/lib/commonjs/utils/breakpoints.js.map +1 -1
  35. package/lib/commonjs/utils/index.js +10 -38
  36. package/lib/commonjs/utils/index.js.map +1 -1
  37. package/lib/commonjs/utils/mq.js +67 -53
  38. package/lib/commonjs/utils/mq.js.map +1 -1
  39. package/lib/commonjs/utils/mqParser.js +86 -0
  40. package/lib/commonjs/utils/mqParser.js.map +1 -0
  41. package/lib/commonjs/utils/styles.js.map +1 -1
  42. package/lib/module/{types/cxx.js → common.js} +8 -6
  43. package/lib/module/common.js.map +1 -0
  44. package/lib/module/{UnistyleRegistry.js → core/UnistyleRegistry.js} +1 -8
  45. package/lib/module/core/UnistyleRegistry.js.map +1 -0
  46. package/lib/module/{Unistyles.js → core/Unistyles.js} +1 -6
  47. package/lib/module/core/Unistyles.js.map +1 -0
  48. package/lib/module/core/UnistylesModule.js.map +1 -0
  49. package/lib/module/{UnistylesRuntime.js → core/UnistylesRuntime.js} +2 -2
  50. package/lib/module/core/UnistylesRuntime.js.map +1 -0
  51. package/lib/module/core/index.js +2 -0
  52. package/lib/module/core/index.js.map +1 -0
  53. package/lib/module/hooks/index.js +2 -1
  54. package/lib/module/hooks/index.js.map +1 -1
  55. package/lib/module/hooks/useInitialTheme.js +10 -0
  56. package/lib/module/hooks/useInitialTheme.js.map +1 -0
  57. package/lib/module/hooks/useUnistyles.js +47 -0
  58. package/lib/module/hooks/useUnistyles.js.map +1 -0
  59. package/lib/module/index.js +11 -18
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/types/common.js +2 -0
  62. package/lib/module/types/common.js.map +1 -0
  63. package/lib/module/types/index.js +1 -1
  64. package/lib/module/types/index.js.map +1 -1
  65. package/lib/module/types/mq.js +2 -0
  66. package/lib/module/types/mq.js.map +1 -0
  67. package/lib/module/types/unistyles.js +2 -0
  68. package/lib/module/types/unistyles.js.map +1 -0
  69. package/lib/module/useStyles.js +6 -3
  70. package/lib/module/useStyles.js.map +1 -1
  71. package/lib/module/utils/breakpoints.js +14 -16
  72. package/lib/module/utils/breakpoints.js.map +1 -1
  73. package/lib/module/utils/index.js +2 -2
  74. package/lib/module/utils/index.js.map +1 -1
  75. package/lib/module/utils/mq.js +65 -51
  76. package/lib/module/utils/mq.js.map +1 -1
  77. package/lib/module/utils/mqParser.js +79 -0
  78. package/lib/module/utils/mqParser.js.map +1 -0
  79. package/lib/module/utils/styles.js.map +1 -1
  80. package/lib/typescript/src/common.d.ts +17 -0
  81. package/lib/typescript/src/common.d.ts.map +1 -0
  82. package/lib/typescript/src/{UnistyleRegistry.d.ts → core/UnistyleRegistry.d.ts} +2 -3
  83. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -0
  84. package/lib/typescript/src/{Unistyles.d.ts → core/Unistyles.d.ts} +0 -3
  85. package/lib/typescript/src/core/Unistyles.d.ts.map +1 -0
  86. package/lib/typescript/src/core/UnistylesModule.d.ts.map +1 -0
  87. package/lib/typescript/src/{UnistylesRuntime.d.ts → core/UnistylesRuntime.d.ts} +6 -6
  88. package/lib/typescript/src/core/UnistylesRuntime.d.ts.map +1 -0
  89. package/lib/typescript/src/core/index.d.ts +2 -0
  90. package/lib/typescript/src/core/index.d.ts.map +1 -0
  91. package/lib/typescript/src/hooks/index.d.ts +2 -1
  92. package/lib/typescript/src/hooks/index.d.ts.map +1 -1
  93. package/lib/typescript/src/hooks/useInitialTheme.d.ts +3 -0
  94. package/lib/typescript/src/hooks/useInitialTheme.d.ts.map +1 -0
  95. package/lib/typescript/src/hooks/useUnistyles.d.ts +12 -0
  96. package/lib/typescript/src/hooks/useUnistyles.d.ts.map +1 -0
  97. package/lib/typescript/src/index.d.ts +10 -12
  98. package/lib/typescript/src/index.d.ts.map +1 -1
  99. package/lib/typescript/src/types/breakpoints.d.ts +5 -9
  100. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  101. package/lib/typescript/src/types/common.d.ts +3 -0
  102. package/lib/typescript/src/types/common.d.ts.map +1 -0
  103. package/lib/typescript/src/types/core.d.ts +9 -4
  104. package/lib/typescript/src/types/core.d.ts.map +1 -1
  105. package/lib/typescript/src/types/index.d.ts +5 -4
  106. package/lib/typescript/src/types/index.d.ts.map +1 -1
  107. package/lib/typescript/src/types/mq.d.ts +3 -0
  108. package/lib/typescript/src/types/mq.d.ts.map +1 -0
  109. package/lib/typescript/src/types/{cxx.d.ts → unistyles.d.ts} +4 -23
  110. package/lib/typescript/src/types/unistyles.d.ts.map +1 -0
  111. package/lib/typescript/src/useStyles.d.ts +8 -6
  112. package/lib/typescript/src/useStyles.d.ts.map +1 -1
  113. package/lib/typescript/src/utils/breakpoints.d.ts +2 -2
  114. package/lib/typescript/src/utils/breakpoints.d.ts.map +1 -1
  115. package/lib/typescript/src/utils/index.d.ts +2 -2
  116. package/lib/typescript/src/utils/index.d.ts.map +1 -1
  117. package/lib/typescript/src/utils/mq.d.ts +15 -9
  118. package/lib/typescript/src/utils/mq.d.ts.map +1 -1
  119. package/lib/typescript/src/utils/mqParser.d.ts +3 -0
  120. package/lib/typescript/src/utils/mqParser.d.ts.map +1 -0
  121. package/lib/typescript/src/utils/styles.d.ts.map +1 -1
  122. package/package.json +1 -1
  123. package/src/common.ts +19 -0
  124. package/src/{UnistyleRegistry.ts → core/UnistyleRegistry.ts} +3 -12
  125. package/src/{Unistyles.ts → core/Unistyles.ts} +2 -9
  126. package/src/{UnistylesRuntime.ts → core/UnistylesRuntime.ts} +4 -4
  127. package/src/core/index.ts +1 -0
  128. package/src/hooks/index.ts +2 -1
  129. package/src/hooks/useInitialTheme.ts +11 -0
  130. package/src/hooks/useUnistyles.ts +55 -0
  131. package/src/index.ts +17 -20
  132. package/src/types/breakpoints.ts +6 -11
  133. package/src/types/common.ts +2 -0
  134. package/src/types/core.ts +10 -4
  135. package/src/types/index.ts +5 -9
  136. package/src/types/mq.ts +3 -0
  137. package/src/types/{cxx.ts → unistyles.ts} +4 -28
  138. package/src/useStyles.ts +15 -8
  139. package/src/utils/breakpoints.ts +13 -12
  140. package/src/utils/index.ts +2 -9
  141. package/src/utils/mq.ts +75 -46
  142. package/src/utils/mqParser.ts +99 -0
  143. package/src/utils/styles.ts +2 -2
  144. package/lib/commonjs/UnistyleRegistry.js.map +0 -1
  145. package/lib/commonjs/Unistyles.js.map +0 -1
  146. package/lib/commonjs/UnistylesEngine.js +0 -26
  147. package/lib/commonjs/UnistylesEngine.js.map +0 -1
  148. package/lib/commonjs/UnistylesModule.js.map +0 -1
  149. package/lib/commonjs/UnistylesRuntime.js.map +0 -1
  150. package/lib/commonjs/hooks/useDimensions.js +0 -10
  151. package/lib/commonjs/hooks/useDimensions.js.map +0 -1
  152. package/lib/commonjs/hooks/useDimensions.web.js +0 -34
  153. package/lib/commonjs/hooks/useDimensions.web.js.map +0 -1
  154. package/lib/commonjs/types/cxx.js.map +0 -1
  155. package/lib/commonjs/types/mediaQueries.js +0 -2
  156. package/lib/commonjs/useInitialTheme.js.map +0 -1
  157. package/lib/commonjs/useUnistyles.js +0 -51
  158. package/lib/commonjs/useUnistyles.js.map +0 -1
  159. package/lib/commonjs/utils/mediaQueries.js +0 -98
  160. package/lib/commonjs/utils/mediaQueries.js.map +0 -1
  161. package/lib/module/UnistyleRegistry.js.map +0 -1
  162. package/lib/module/Unistyles.js.map +0 -1
  163. package/lib/module/UnistylesEngine.js +0 -19
  164. package/lib/module/UnistylesEngine.js.map +0 -1
  165. package/lib/module/UnistylesModule.js.map +0 -1
  166. package/lib/module/UnistylesRuntime.js.map +0 -1
  167. package/lib/module/hooks/useDimensions.js +0 -3
  168. package/lib/module/hooks/useDimensions.js.map +0 -1
  169. package/lib/module/hooks/useDimensions.web.js +0 -27
  170. package/lib/module/hooks/useDimensions.web.js.map +0 -1
  171. package/lib/module/types/cxx.js.map +0 -1
  172. package/lib/module/types/mediaQueries.js +0 -2
  173. package/lib/module/useInitialTheme.js +0 -6
  174. package/lib/module/useInitialTheme.js.map +0 -1
  175. package/lib/module/useUnistyles.js +0 -44
  176. package/lib/module/useUnistyles.js.map +0 -1
  177. package/lib/module/utils/mediaQueries.js +0 -85
  178. package/lib/module/utils/mediaQueries.js.map +0 -1
  179. package/lib/typescript/src/UnistyleRegistry.d.ts.map +0 -1
  180. package/lib/typescript/src/Unistyles.d.ts.map +0 -1
  181. package/lib/typescript/src/UnistylesEngine.d.ts +0 -11
  182. package/lib/typescript/src/UnistylesEngine.d.ts.map +0 -1
  183. package/lib/typescript/src/UnistylesModule.d.ts.map +0 -1
  184. package/lib/typescript/src/UnistylesRuntime.d.ts.map +0 -1
  185. package/lib/typescript/src/hooks/useDimensions.d.ts +0 -3
  186. package/lib/typescript/src/hooks/useDimensions.d.ts.map +0 -1
  187. package/lib/typescript/src/hooks/useDimensions.web.d.ts +0 -3
  188. package/lib/typescript/src/hooks/useDimensions.web.d.ts.map +0 -1
  189. package/lib/typescript/src/types/cxx.d.ts.map +0 -1
  190. package/lib/typescript/src/types/mediaQueries.d.ts +0 -10
  191. package/lib/typescript/src/types/mediaQueries.d.ts.map +0 -1
  192. package/lib/typescript/src/useInitialTheme.d.ts +0 -3
  193. package/lib/typescript/src/useInitialTheme.d.ts.map +0 -1
  194. package/lib/typescript/src/useUnistyles.d.ts +0 -10
  195. package/lib/typescript/src/useUnistyles.d.ts.map +0 -1
  196. package/lib/typescript/src/utils/mediaQueries.d.ts +0 -11
  197. package/lib/typescript/src/utils/mediaQueries.d.ts.map +0 -1
  198. package/src/UnistylesEngine.ts +0 -24
  199. package/src/hooks/useDimensions.ts +0 -4
  200. package/src/hooks/useDimensions.web.ts +0 -34
  201. package/src/types/mediaQueries.ts +0 -15
  202. package/src/useInitialTheme.ts +0 -7
  203. package/src/useUnistyles.ts +0 -61
  204. package/src/utils/mediaQueries.ts +0 -152
  205. /package/lib/commonjs/{UnistylesModule.js → core/UnistylesModule.js} +0 -0
  206. /package/lib/module/{UnistylesModule.js → core/UnistylesModule.js} +0 -0
  207. /package/lib/typescript/src/{UnistylesModule.d.ts → core/UnistylesModule.d.ts} +0 -0
  208. /package/src/{UnistylesModule.ts → core/UnistylesModule.ts} +0 -0
@@ -0,0 +1,55 @@
1
+ import { NativeEventEmitter, NativeModules } from 'react-native'
2
+ import { useEffect, useState } from 'react'
3
+ import { unistyles } from '../core'
4
+ import { CxxUnistylesEventTypes } from '../common'
5
+ import type { UnistylesEvents, UnistylesMobileLayoutEvent, UnistylesThemeEvent } from '../types'
6
+
7
+ const unistylesEvents = new NativeEventEmitter(NativeModules.Unistyles)
8
+
9
+ export const useUnistyles = () => {
10
+ const [theme, setTheme] = useState(unistyles.runtime.getTheme(unistyles.runtime.themeName))
11
+ const [layout, setLayout] = useState({
12
+ breakpoint: unistyles.runtime.breakpoint,
13
+ orientation: unistyles.runtime.orientation,
14
+ screenSize: {
15
+ width: unistyles.runtime.screen.width,
16
+ height: unistyles.runtime.screen.height
17
+ }
18
+ })
19
+
20
+ useEffect(() => {
21
+ const subscription = unistylesEvents.addListener(
22
+ 'onChange',
23
+ (event: UnistylesEvents) => {
24
+ switch (event.type) {
25
+ case CxxUnistylesEventTypes.Theme: {
26
+ const themeEvent = event as UnistylesThemeEvent
27
+
28
+ return setTheme(unistyles.runtime.getTheme(themeEvent.payload.themeName))
29
+ }
30
+ case CxxUnistylesEventTypes.Layout: {
31
+ const layoutEvent = event as UnistylesMobileLayoutEvent
32
+
33
+ return setLayout({
34
+ breakpoint: layoutEvent.payload.breakpoint,
35
+ orientation: layoutEvent.payload.orientation,
36
+ screenSize: {
37
+ width: layoutEvent.payload.screen.width,
38
+ height: layoutEvent.payload.screen.height
39
+ }
40
+ })
41
+ }
42
+ default:
43
+ return
44
+ }
45
+ }
46
+ )
47
+
48
+ return subscription.remove
49
+ }, [])
50
+
51
+ return {
52
+ theme,
53
+ layout
54
+ }
55
+ }
package/src/index.ts CHANGED
@@ -1,30 +1,27 @@
1
- import { unistyles } from './Unistyles'
1
+ import { unistyles } from './core'
2
+ import { mq } from './utils'
3
+ import { useInitialTheme } from './hooks'
2
4
  import type { UnistylesThemes, UnistylesBreakpoints } from './global'
3
- import { ScreenOrientation } from './types'
5
+ import { ScreenOrientation } from './common'
6
+ import { useStyles } from './useStyles'
7
+ import { createStyleSheet } from './createStyleSheet'
4
8
 
5
- export { mq } from './utils'
6
- export { useInitialTheme } from './useInitialTheme'
7
-
8
- export { useStyles } from './useStyles'
9
- export { createStyleSheet } from './createStyleSheet'
10
-
11
- const { addThemes, addBreakpoints, addConfig } = unistyles.registry
12
- const UnistylesRuntime = unistyles.runtime
13
9
  const UnistylesRegistry = {
14
- addThemes,
15
- addBreakpoints,
16
- addConfig
10
+ addThemes: unistyles.registry.addThemes,
11
+ addBreakpoints: unistyles.registry.addBreakpoints,
12
+ addConfig: unistyles.registry.addConfig
17
13
  }
18
14
 
19
- export const __dangerouslyUnregister = unistyles.registry.dangerouslyUnregister
20
-
21
- export {
22
- UnistylesRuntime,
23
- UnistylesRegistry
24
- }
15
+ const UnistylesRuntime = unistyles.runtime
25
16
 
26
17
  export {
27
- ScreenOrientation
18
+ mq,
19
+ useStyles,
20
+ useInitialTheme,
21
+ createStyleSheet,
22
+ ScreenOrientation,
23
+ UnistylesRegistry,
24
+ UnistylesRuntime
28
25
  }
29
26
 
30
27
  export type {
@@ -1,17 +1,10 @@
1
1
  import type { OpaqueColorValue } from 'react-native'
2
2
  import type { UnistylesBreakpoints } from '../global'
3
- import type { MediaQueries } from './mediaQueries'
4
-
5
- export type ScreenSize = {
6
- width: number,
7
- height: number
8
- }
9
-
10
- export type CreateStylesFactory<ST, Theme> = (theme: Theme) => ST
3
+ import type { MediaQuery } from './mq'
11
4
 
12
5
  type WithEmptyObject<V> = keyof V extends never ? {} : V
13
6
 
14
- export type ExtractBreakpoints<T> = T extends Partial<Record<keyof UnistylesBreakpoints & string, infer V>>
7
+ type ExtractBreakpoints<T> = T extends Partial<Record<keyof UnistylesBreakpoints & string, infer V>>
15
8
  ? WithEmptyObject<V>
16
9
  : T extends (...args: infer A) => infer R
17
10
  ? (...args: A) => ExtractBreakpoints<R>
@@ -23,12 +16,14 @@ export type ExtractBreakpoints<T> = T extends Partial<Record<keyof UnistylesBrea
23
16
  : T[K]
24
17
  }
25
18
 
26
- export type RemoveKeysWithPrefix<T> = T extends (...args: Array<any>) => infer R
19
+ type RemoveKeysWithPrefix<T> = T extends (...args: Array<any>) => infer R
27
20
  ? (...args: Parameters<T>) => RemoveKeysWithPrefix<R>
28
21
  : T extends object
29
22
  ? T extends OpaqueColorValue
30
23
  ? string
31
24
  : T extends Record<string, infer _V>
32
- ? { [K in keyof T as K extends MediaQueries ? keyof UnistylesBreakpoints & string : K]: RemoveKeysWithPrefix<T[K]> }
25
+ ? { [K in keyof T as K extends MediaQuery ? keyof UnistylesBreakpoints & string : K]: RemoveKeysWithPrefix<T[K]> }
33
26
  : { [K in keyof T]: RemoveKeysWithPrefix<T[K]> }
34
27
  : T
28
+
29
+ export type ReactNativeStyleSheet<T> = ExtractBreakpoints<RemoveKeysWithPrefix<T>>
@@ -0,0 +1,2 @@
1
+ export type Optional<T> = T | undefined
2
+ export type Nullable<T> = T | null
package/src/types/core.ts CHANGED
@@ -14,14 +14,19 @@ import type {
14
14
  TranslateYTransform
15
15
  } from 'react-native/Libraries/StyleSheet/StyleSheetTypes'
16
16
  import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
17
- import type { MediaQueries } from './mediaQueries'
18
17
  import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
18
+ import type { MediaQuery } from './mq'
19
19
 
20
20
  type ShadowOffset = {
21
21
  width: number,
22
22
  height: number
23
23
  }
24
24
 
25
+ export type ScreenSize = {
26
+ width: number,
27
+ height: number
28
+ }
29
+
25
30
  type TransformStyles =
26
31
  & PerpectiveTransform
27
32
  & RotateTransform
@@ -44,9 +49,9 @@ type UnistyleNested = {
44
49
  }
45
50
 
46
51
  type UniStyle<V> = {
47
- [innerKey in keyof UnistylesBreakpoints]: V
52
+ [innerKey in keyof UnistylesBreakpoints]?: V
48
53
  } | {
49
- [innerKey in MediaQueries]: V
54
+ [innerKey in MediaQuery]: V
50
55
  }
51
56
 
52
57
  type DeepUniStyle<T> = {
@@ -72,5 +77,6 @@ export type CustomNamedStyles<T> = {
72
77
  : StaticStyles
73
78
  }
74
79
 
75
- export type NestedKeys = Array<[keyof UnistylesBreakpoints | MediaQueries, string | number | undefined]>
80
+ export type NestedKeys = Array<[keyof UnistylesBreakpoints | MediaQuery, string | number | undefined]>
76
81
  export type UnistylesTheme = UnistylesThemes[keyof UnistylesThemes]
82
+ export type CreateStylesFactory<ST, Theme> = (theme: Theme) => ST
@@ -1,10 +1,6 @@
1
1
  export * from './normalizer'
2
- export * from './cxx'
3
- export type { CustomNamedStyles, NestedKeys, UnistylesTheme } from './core'
4
- export type { MediaQueries } from './mediaQueries'
5
- export type {
6
- ScreenSize,
7
- CreateStylesFactory,
8
- ExtractBreakpoints,
9
- RemoveKeysWithPrefix
10
- } from './breakpoints'
2
+ export * from './unistyles'
3
+ export type { Optional, Nullable } from './common'
4
+ export type { MediaQuery } from './mq'
5
+ export type { CustomNamedStyles, NestedKeys, UnistylesTheme, CreateStylesFactory, ScreenSize } from './core'
6
+ export type { ReactNativeStyleSheet } from './breakpoints'
@@ -0,0 +1,3 @@
1
+ import { MQSymbol } from '../utils'
2
+
3
+ export type MediaQuery = typeof MQSymbol
@@ -1,20 +1,14 @@
1
+ import { CxxUnistylesEventTypes, ScreenOrientation } from '../common'
1
2
  import type { UnistylesThemes, UnistylesBreakpoints } from '../global'
2
- import type { ScreenSize } from './breakpoints'
3
- import type { NestedKeys } from './core'
3
+ import type { NestedKeys, ScreenSize } from './core'
4
+ import type { Optional } from './common'
4
5
 
5
- export type Optional<T> = T | undefined
6
- export type Nullable<T> = T | null
7
6
  export type ColorSchemeName = Optional<'light' | 'dark'>
8
7
 
9
8
  export type UnistylesConfig = {
10
9
  adaptiveThemes?: boolean
11
10
  }
12
11
 
13
- export enum ScreenOrientation {
14
- Portrait = 1,
15
- Landscape = 2
16
- }
17
-
18
12
  export type UnistylesBridge = {
19
13
  // getters
20
14
  screenWidth: number,
@@ -29,15 +23,7 @@ export type UnistylesBridge = {
29
23
  themes: Array<keyof UnistylesThemes>,
30
24
  useBreakpoints(breakpoints: UnistylesBreakpoints): void,
31
25
  useTheme(name: keyof UnistylesThemes): void,
32
- useAdaptiveThemes(enable: boolean): void,
33
-
34
- // other
35
- unregister(): void
36
- }
37
-
38
- export enum CxxUnistylesEventTypes {
39
- Theme = 'theme',
40
- Layout = 'layout'
26
+ useAdaptiveThemes(enable: boolean): void
41
27
  }
42
28
 
43
29
  export type UnistylesThemeEvent = {
@@ -58,16 +44,6 @@ export type UnistylesMobileLayoutEvent = {
58
44
 
59
45
  export type UnistylesEvents = UnistylesThemeEvent | UnistylesMobileLayoutEvent
60
46
 
61
- export enum UnistylesError {
62
- RuntimeUnavailable = 'UNISTYLES_ERROR_RUNTIME_UNAVAILABLE',
63
- ThemeNotFound = 'UNISTYLES_ERROR_THEME_NOT_FOUND',
64
- ThemeNotRegistered = 'UNISTYLES_ERROR_THEME_NOT_REGISTERED',
65
- ThemesCannotBeEmpty = 'UNISTYLES_ERROR_THEMES_CANNOT_BE_EMPTY',
66
- BreakpointsCannotBeEmpty = 'UNISTYLES_ERROR_BREAKPOINTS_CANNOT_BE_EMPTY',
67
- BreakpointsMustStartFromZero = 'UNISTYLES_ERROR_BREAKPOINTS_MUST_START_FROM_ZERO',
68
- }
69
-
70
47
  export interface UnistylesEngine {
71
- isMediaQuery(key: string): boolean,
72
48
  didMatchMediaQuery(keys: NestedKeys): Optional<string>,
73
49
  }
package/src/useStyles.ts CHANGED
@@ -1,18 +1,25 @@
1
1
  import { useMemo } from 'react'
2
2
  import { StyleSheet } from 'react-native'
3
3
  import { parseStyle, proxifyFunction } from './utils'
4
- import type { CreateStylesFactory, CustomNamedStyles, ExtractBreakpoints, RemoveKeysWithPrefix } from './types'
5
- import { useUnistyles } from './useUnistyles'
6
- import type { UnistylesTheme } from './types'
4
+ import type { CreateStylesFactory, CustomNamedStyles, ReactNativeStyleSheet, UnistylesTheme } from './types'
5
+ import { useUnistyles } from './hooks'
6
+ import type { UnistylesBreakpoints } from './global'
7
7
 
8
- export const useStyles = <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, UnistylesTheme>) => {
9
- const { theme, breakpoint, screenSize } = useUnistyles()
8
+ type ParsedStylesheet<ST extends CustomNamedStyles<ST>> = {
9
+ theme: UnistylesTheme,
10
+ breakpoint: keyof UnistylesBreakpoints,
11
+ styles: ReactNativeStyleSheet<ST>
12
+ }
13
+
14
+ export const useStyles = <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | CreateStylesFactory<ST, UnistylesTheme>): ParsedStylesheet<ST> => {
15
+ const { theme, layout } = useUnistyles()
16
+ const { screenSize, breakpoint } = layout
10
17
 
11
18
  if (!stylesheet) {
12
19
  return {
13
20
  theme,
14
21
  breakpoint,
15
- styles: {} as ExtractBreakpoints<RemoveKeysWithPrefix<ST>>
22
+ styles: {} as ReactNativeStyleSheet<ST>
16
23
  }
17
24
  }
18
25
 
@@ -36,11 +43,11 @@ export const useStyles = <ST extends CustomNamedStyles<ST>>(stylesheet?: ST | Cr
36
43
  ...acc,
37
44
  [key]: parseStyle<ST>(style, breakpoint, screenSize)
38
45
  })
39
- }, {} as ST), [breakpoint, screenSize, parsedStyles])
46
+ }, {} as ST), [breakpoint, screenSize, parsedStyles]) as ReactNativeStyleSheet<ST>
40
47
 
41
48
  return {
42
49
  theme,
43
50
  breakpoint,
44
- styles: dynamicStyleSheet as ExtractBreakpoints<RemoveKeysWithPrefix<ST>>
51
+ styles: dynamicStyleSheet
45
52
  }
46
53
  }
@@ -1,8 +1,9 @@
1
- import { unistyles } from '../Unistyles'
1
+ import { unistyles } from '../core'
2
2
  import { isMobile, Orientation, throwError } from './common'
3
- import type { MediaQueries } from '../types'
4
- import { ScreenOrientation } from '../types'
3
+ import type { MediaQuery, NestedKeys } from '../types'
5
4
  import type { UnistylesBreakpoints } from '../global'
5
+ import { ScreenOrientation } from '../common'
6
+ import { getKeyForUnistylesMediaQuery } from './mqParser'
6
7
 
7
8
  export const sortAndValidateBreakpoints = (breakpoints: UnistylesBreakpoints): UnistylesBreakpoints => {
8
9
  const sortedPairs = Object
@@ -45,15 +46,14 @@ export const getBreakpointFromScreenWidth = (width: number, breakpointEntries: A
45
46
  return key
46
47
  }
47
48
 
48
- export const getValueForBreakpoint = (value: Record<keyof UnistylesBreakpoints | MediaQueries, string | number | undefined>): string | number | undefined => {
49
+ export const getValueForBreakpoint = (value: Record<keyof UnistylesBreakpoints | MediaQuery, string | number | undefined>): string | number | undefined => {
49
50
  // the highest priority is for custom media queries
50
- const customMediaQueries = Object
51
- .entries(value)
52
- .filter(([key]) => unistyles.engine.isMediaQuery(key)) as Array<[keyof UnistylesBreakpoints | MediaQueries, string | number | undefined]>
53
- // const customMediaQueryKey = getKeyForCustomMediaQuery(customMediaQueries, screenSize) as keyof typeof value
54
- const customMediaQueryKey = unistyles.engine.didMatchMediaQuery(customMediaQueries) as keyof typeof value
51
+ const customMediaQueryKey = getKeyForUnistylesMediaQuery(
52
+ Object.entries(value) as NestedKeys,
53
+ unistyles.runtime.screen
54
+ ) as keyof typeof value
55
55
 
56
- if (customMediaQueryKey && customMediaQueryKey in value) {
56
+ if (customMediaQueryKey) {
57
57
  return value[customMediaQueryKey]
58
58
  }
59
59
 
@@ -61,8 +61,8 @@ export const getValueForBreakpoint = (value: Record<keyof UnistylesBreakpoints |
61
61
  // check if user defined any breakpoints
62
62
  const hasBreakpoints = unistyles.runtime.sortedBreakpoints.length > 0
63
63
 
64
- // if not then we can fallback to horizontal and portrait (mobile only)
65
- if (!hasBreakpoints && isMobile && (Orientation.Landscape in value || Orientation.Portrait in value)) {
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
66
  return value[
67
67
  unistyles.runtime.orientation === ScreenOrientation.Portrait
68
68
  ? Orientation.Portrait
@@ -70,6 +70,7 @@ export const getValueForBreakpoint = (value: Record<keyof UnistylesBreakpoints |
70
70
  ]
71
71
  }
72
72
 
73
+ // let's get the current breakpoint
73
74
  const breakpoint = unistyles.runtime.breakpoint
74
75
 
75
76
  if (!breakpoint) {
@@ -1,14 +1,7 @@
1
1
  export { normalizeStyles } from './normalizeStyles'
2
2
  export * from './normalizer'
3
- export { mq } from './mq'
3
+ export { mq, MQSymbol } from './mq'
4
+ export { getKeyForUnistylesMediaQuery } from './mqParser'
4
5
  export { getBreakpointFromScreenWidth, sortAndValidateBreakpoints, getValueForBreakpoint } from './breakpoints'
5
6
  export { proxifyFunction, parseStyle } from './styles'
6
7
  export { isServer, Orientation } from './common'
7
- export {
8
- extractValues,
9
- getKeyForCustomMediaQuery,
10
- isMediaQuery,
11
- isWithinTheHeight,
12
- isWithinTheWidth,
13
- isWithinTheWidthAndHeight
14
- } from './mediaQueries'
package/src/utils/mq.ts CHANGED
@@ -1,17 +1,27 @@
1
+ import type { MediaQuery, Nullable } from '../types'
1
2
  import type { UnistylesBreakpoints } from '../global'
2
- import { unistyles } from '../Unistyles'
3
+ import { unistyles } from '../core'
3
4
 
4
- const MQSymbol = Symbol('unistyles-mq')
5
+ export const MQSymbol = Symbol('unistyles-mq')
5
6
 
6
7
  type MQValue = keyof UnistylesBreakpoints | number
7
8
 
9
+ type MQHandler = {
10
+ w(wMin?: Nullable<MQValue>, wMax?: MQValue): WidthHandler,
11
+ width(wMin?: Nullable<MQValue>, wMax?: MQValue): WidthHandler,
12
+ h(hMin?: Nullable<MQValue>, hMax?: MQValue): HeightHandler,
13
+ height(hMin?: Nullable<MQValue>, hMax?: MQValue): HeightHandler
14
+ }
15
+
8
16
  type HeightHandler = {
9
- width(wMin?: MQValue, wMax?: MQValue): typeof MQSymbol
10
- } & typeof MQSymbol
17
+ w(wMin?: Nullable<MQValue>, wMax?: MQValue): MediaQuery,
18
+ width(wMin?: Nullable<MQValue>, wMax?: MQValue): MediaQuery
19
+ } & MediaQuery
11
20
 
12
21
  type WidthHandler = {
13
- height(hMin?: MQValue, hMax?: MQValue): typeof MQSymbol
14
- } & typeof MQSymbol
22
+ h(hMin?: Nullable<MQValue>, hMax?: MQValue): MediaQuery,
23
+ height(hMin?: Nullable<MQValue>, hMax?: MQValue): MediaQuery
24
+ } & MediaQuery
15
25
 
16
26
  type FinalHandler = {
17
27
  [MQSymbol]: true
@@ -20,58 +30,77 @@ type FinalHandler = {
20
30
  enum MQProp {
21
31
  toString = 'toString',
22
32
  width = 'width',
23
- height = 'height'
33
+ height = 'height',
34
+ shortW = 'w',
35
+ shortH = 'h'
24
36
  }
25
37
 
26
- const getMQValue = (value: MQValue) => {
38
+ const getMQValue = (value: Nullable<MQValue>) => {
27
39
  if (typeof value === 'number') {
28
40
  return value
29
41
  }
30
42
 
43
+ if (value === null) {
44
+ return 0
45
+ }
46
+
31
47
  return unistyles.registry.breakpoints[value] ?? 0
32
48
  }
33
49
 
34
- export const mq = {
35
- height: (hMin: MQValue = 0, hMax: MQValue = Infinity) => new Proxy<HeightHandler>({} as HeightHandler, {
36
- get: (target, prop, receiver) => {
37
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
38
- return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
39
- }
40
-
41
- if (prop === MQProp.width) {
42
- return (wMin: MQValue = 0, wMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
43
- get: (target, prop, receiver) => {
44
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
45
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
46
- }
47
-
48
- return Reflect.get(target, prop, receiver)
50
+ const widthHandler = (hMin: Nullable<MQValue> = 0, hMax: MQValue = Infinity) => new Proxy<HeightHandler>({} as HeightHandler, {
51
+ get: (target, prop, receiver) => {
52
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
53
+ return () => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
54
+ }
55
+
56
+ if (prop === MQProp.width || prop === MQProp.shortW) {
57
+ return (wMin: MQValue = 0, wMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
58
+ get: (target, prop, receiver) => {
59
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
60
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
49
61
  }
50
- })
51
- }
52
62
 
53
- return Reflect.get(target, prop, receiver)
63
+ return Reflect.get(target, prop, receiver)
64
+ }
65
+ })
66
+ }
67
+
68
+ return Reflect.get(target, prop, receiver)
69
+ }
70
+ })
71
+
72
+ const heightHandler = (wMin: Nullable<MQValue> = 0, wMax: MQValue = Infinity) => new Proxy({} as WidthHandler, {
73
+ get: (target, prop, receiver) => {
74
+ if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
75
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`
54
76
  }
55
- }),
56
- width: (wMin: MQValue = 0, wMax: MQValue = Infinity) => new Proxy({} as WidthHandler, {
57
- get: (target, prop, receiver) => {
58
- if (prop === Symbol.toPrimitive || prop === MQProp.toString) {
59
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`
60
- }
61
-
62
- if (prop === MQProp.height) {
63
- return (hMin: MQValue = 0, hMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
64
- get: (target, prop, receiver) => {
65
- if (prop === Symbol.toPrimitive || MQProp.toString) {
66
- return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
67
- }
68
-
69
- return Reflect.get(target, prop, receiver)
77
+
78
+ if (prop === MQProp.height || prop === MQProp.shortH) {
79
+ return (hMin: MQValue = 0, hMax: MQValue = Infinity) => new Proxy<FinalHandler>({} as FinalHandler, {
80
+ get: (target, prop, receiver) => {
81
+ if (prop === Symbol.toPrimitive || MQProp.toString) {
82
+ return () => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
70
83
  }
71
- })
72
- }
73
84
 
74
- return Reflect.get(target, prop, receiver)
85
+ return Reflect.get(target, prop, receiver)
86
+ }
87
+ })
75
88
  }
76
- })
77
- }
89
+
90
+ return Reflect.get(target, prop, receiver)
91
+ }
92
+ })
93
+
94
+ export const mq = new Proxy({} as MQHandler, {
95
+ get: (target, prop, receiver) => {
96
+ if (prop === MQProp.shortW || prop === MQProp.width) {
97
+ return heightHandler
98
+ }
99
+
100
+ if (prop === MQProp.shortH || prop === MQProp.height) {
101
+ return widthHandler
102
+ }
103
+
104
+ return Reflect.get(target, prop, receiver)
105
+ }
106
+ })
@@ -0,0 +1,99 @@
1
+ import type { NestedKeys, Optional, ScreenSize } from '../types'
2
+
3
+ const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/
4
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/
5
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/
6
+
7
+ type ParsedMqDimension = {
8
+ from: number,
9
+ to: number
10
+ }
11
+
12
+ type UnistylesParsedMq = {
13
+ width?: ParsedMqDimension,
14
+ height?: ParsedMqDimension
15
+ }
16
+
17
+ const parseMq = (mq: string): UnistylesParsedMq => {
18
+ const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || []
19
+ const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || []
20
+
21
+ return {
22
+ width: width ? {
23
+ from: Number(fromW),
24
+ to: Number(toW)
25
+ } : undefined,
26
+ height: height ? {
27
+ from: Number(fromH),
28
+ to: Number(toH)
29
+ } : undefined
30
+ }
31
+ }
32
+
33
+ const isUnistylesMq = (mq: string) => IS_UNISTYLES_REGEX.test(mq)
34
+
35
+ const isValidMq = (parsedMq: UnistylesParsedMq) => {
36
+ const { width, height } = parsedMq
37
+
38
+ if (width && height) {
39
+ return width.from <= width.to && height.from <= height.to
40
+ }
41
+
42
+ if (width) {
43
+ return width.from <= width.to
44
+ }
45
+
46
+ if (height) {
47
+ return height.from <= height.to
48
+ }
49
+
50
+ return false
51
+ }
52
+
53
+ const isWithinTheWidthAndHeight = (parsedMq: UnistylesParsedMq, screenSize: ScreenSize): boolean => {
54
+ const { width, height } = parsedMq
55
+
56
+ if (width && height) {
57
+ return isWithinTheWidth(width, screenSize.width) && isWithinTheHeight(height, screenSize.height)
58
+ }
59
+
60
+ if (width) {
61
+ return isWithinTheWidth(width, screenSize.width)
62
+ }
63
+
64
+ if (height) {
65
+ return isWithinTheHeight(height, screenSize.height)
66
+ }
67
+
68
+ return false
69
+ }
70
+
71
+ const isWithinTheWidth = (width: UnistylesParsedMq['width'], screenWidth: number): boolean => {
72
+ const { from, to } = width as ParsedMqDimension
73
+
74
+ return screenWidth >= from && screenWidth <= to
75
+ }
76
+
77
+ const isWithinTheHeight = (height: UnistylesParsedMq['height'], screenHeight: number): boolean => {
78
+ const { from, to } = height as ParsedMqDimension
79
+
80
+ return screenHeight >= from && screenHeight <= to
81
+ }
82
+
83
+ export const getKeyForUnistylesMediaQuery = (mediaQueries: NestedKeys, screenSize: ScreenSize) => {
84
+ const mq = mediaQueries.find(([key]) => {
85
+ if (!isUnistylesMq(key as string)) {
86
+ return false
87
+ }
88
+
89
+ const parsedMq = parseMq(key as string)
90
+
91
+ if (!isValidMq(parsedMq)) {
92
+ return false
93
+ }
94
+
95
+ return isWithinTheWidthAndHeight(parsedMq, screenSize)
96
+ })
97
+
98
+ return mq?.at(0) as Optional<string>
99
+ }
@@ -1,4 +1,4 @@
1
- import type { CustomNamedStyles, MediaQueries, ScreenSize } from '../types'
1
+ import type { CustomNamedStyles, ScreenSize, MediaQuery } from '../types'
2
2
  import { getValueForBreakpoint } from './breakpoints'
3
3
  import { normalizeStyles } from './normalizeStyles'
4
4
  import type { UnistylesBreakpoints } from '../global'
@@ -60,7 +60,7 @@ export const parseStyle = <T>(
60
60
 
61
61
  return [
62
62
  key,
63
- getValueForBreakpoint(value as Record<keyof UnistylesBreakpoints | MediaQueries, string | number | undefined>)
63
+ getValueForBreakpoint(value as Record<keyof UnistylesBreakpoints | MediaQuery, string | number | undefined>)
64
64
  ]
65
65
  })
66
66
  )
@@ -1 +0,0 @@
1
- {"version":3,"names":["UnistyleRegistry","config","themeNames","themes","breakpoints","sortedBreakpointPairs","constructor","unistylesBridge","addThemes","keys","Object","addBreakpoints","useBreakpoints","addConfig","adaptiveThemes","useAdaptiveThemes","dangerouslyUnregister","unregister","exports"],"sourceRoot":"../../src","sources":["UnistyleRegistry.ts"],"mappings":";;;;;;AAGO,MAAMA,gBAAgB,CAAC;EACnBC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,UAAU,GAAiC,EAAE;EAC7CC,MAAM,GAAoB,CAAC,CAAC;EAC5BC,WAAW,GAAyB,CAAC,CAAC;EACtCC,qBAAqB,GAA0F,EAAE;EAExHC,WAAWA,CAASC,eAAgC,EAAE;IAAA,KAAlCA,eAAgC,GAAhCA,eAAgC;EAAG;EAEhDC,SAAS,GAAIL,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,MAAMM,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACN,MAAM,CAAiC;IAEhE,IAAI,CAACI,eAAe,CAACJ,MAAM,GAAGM,IAAI;IAClC,IAAI,CAACP,UAAU,GAAGO,IAAI;IAEtB,OAAO,IAAI;EACf,CAAC;EAEME,cAAc,GAAIP,WAAiC,IAAK;IAC3D,IAAI,CAACG,eAAe,CAACK,cAAc,CAACR,WAAW,CAAC;IAChD,IAAI,CAACC,qBAAqB,GAAG,IAAI,CAACE,eAAe,CAACF,qBAAqB;IAEvE,OAAO,IAAI;EACf,CAAC;EAEMQ,SAAS,GAAIZ,MAAuB,IAAK;IAC5C,IAAI,CAACA,MAAM,GAAGA,MAAM;IAEpB,IAAIA,MAAM,CAACa,cAAc,EAAE;MACvB,IAAI,CAACP,eAAe,CAACQ,iBAAiB,CAACd,MAAM,CAACa,cAAc,CAAC;IACjE;IAEA,OAAO,IAAI;EACf,CAAC;EAEME,qBAAqB,GAAGA,CAAA,KAAM;IACjC,IAAI,CAACf,MAAM,GAAG,CAAC,CAAC;IAChB,IAAI,CAACC,UAAU,GAAG,EAAE;IACpB,IAAI,CAACC,MAAM,GAAG,CAAC,CAAoB;IACnC,IAAI,CAACC,WAAW,GAAG,CAAC,CAAyB;IAC7C,IAAI,CAACC,qBAAqB,GAAG,EAAE;IAE/B,IAAI,CAACE,eAAe,CAACU,UAAU,CAAC,CAAC;EACrC,CAAC;AACL;AAACC,OAAA,CAAAlB,gBAAA,GAAAA,gBAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["_UnistylesModule","require","_UnistylesRuntime","_UnistylesEngine","_UnistyleRegistry","_types","Unistyles","constructor","isInstalled","UnistylesModule","install","Error","UnistylesError","RuntimeUnavailable","_bridge","global","__UNISTYLES__","_registry","UnistyleRegistry","_runtime","UnistylesRuntime","_engine","UnistylesBuiltInEngine","registry","runtime","engine","unistyles","exports"],"sourceRoot":"../../src","sources":["Unistyles.ts"],"mappings":";;;;;;AAAA,IAAAA,gBAAA,GAAAC,OAAA;AACA,IAAAC,iBAAA,GAAAD,OAAA;AACA,IAAAE,gBAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,IAAAI,MAAA,GAAAJ,OAAA;AAEA,MAAMK,SAAS,CAAC;EAMZC,WAAWA,CAAA,EAAG;IACV,MAAMC,WAAW,GAAGC,gCAAe,EAAEC,OAAO,CAAC,CAAC,IAAI,KAAK;IAEvD,IAAI,CAACF,WAAW,EAAE;MACd,MAAM,IAAIG,KAAK,CAACC,qBAAc,CAACC,kBAAkB,CAAC;IACtD;;IAEA;IACA,IAAI,CAACC,OAAO,GAAGC,MAAM,CAACC,aAAgC;IACtD,IAAI,CAACC,SAAS,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACJ,OAAO,CAAC;IACnD,IAAI,CAACK,QAAQ,GAAG,IAAIC,kCAAgB,CAAC,IAAI,CAACN,OAAO,EAAE,IAAI,CAACG,SAAS,CAAC;IAClE,IAAI,CAACI,OAAO,GAAG,IAAIC,uCAAsB,CAAC,IAAI,CAACL,SAAS,EAAE,IAAI,CAACE,QAAQ,CAAC;EAC5E;EAEA,IAAWI,QAAQA,CAAA,EAAG;IAClB,OAAO,IAAI,CAACN,SAAS;EACzB;EAEA,IAAWO,OAAOA,CAAA,EAAG;IACjB,OAAO,IAAI,CAACL,QAAQ;EACxB;EAEA,IAAWM,MAAMA,CAAA,EAAG;IAChB,OAAO,IAAI,CAACJ,OAAO;EACvB;AACJ;AAEO,MAAMK,SAAS,GAAAC,OAAA,CAAAD,SAAA,GAAG,IAAIpB,SAAS,CAAC,CAAC"}