react-native-unistyles 3.0.0-rc.2 → 3.0.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (222) hide show
  1. package/README.md +17 -17
  2. package/Unistyles.podspec +1 -0
  3. package/components/native/ActivityIndicator/package.json +1 -0
  4. package/components/native/Animated/package.json +1 -0
  5. package/components/native/FlatList/package.json +1 -0
  6. package/components/native/Image/package.json +1 -0
  7. package/components/native/ImageBackground/package.json +1 -0
  8. package/components/native/KeyboardAvoidingView/package.json +1 -0
  9. package/components/native/NativeText/package.json +1 -0
  10. package/components/native/NativeView/package.json +1 -0
  11. package/components/native/Pressable/package.json +1 -0
  12. package/components/native/RefreshControl/package.json +1 -0
  13. package/components/native/ScrollView/package.json +1 -0
  14. package/components/native/SectionList/package.json +1 -0
  15. package/components/native/Switch/package.json +1 -0
  16. package/components/native/Text/package.json +1 -0
  17. package/components/native/TextInput/package.json +1 -0
  18. package/components/native/TouchableHighlight/package.json +1 -0
  19. package/components/native/TouchableOpacity/package.json +1 -0
  20. package/components/native/View/package.json +1 -0
  21. package/components/native/VirtualizedList/package.json +1 -0
  22. package/cxx/core/UnistylesCommitHook.cpp +8 -1
  23. package/cxx/core/UnistylesMountHook.cpp +1 -3
  24. package/ios/NativePlatform+ios.swift +1 -1
  25. package/ios/NativePlatformListener+ios.swift +12 -7
  26. package/lib/commonjs/components/native/Image.js +4 -3
  27. package/lib/commonjs/components/native/Image.js.map +1 -1
  28. package/lib/commonjs/components/native/ImageBackground.js +3 -2
  29. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  30. package/lib/commonjs/core/createUnistylesElement.js +17 -5
  31. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  32. package/lib/commonjs/core/getClassname.js +10 -4
  33. package/lib/commonjs/core/getClassname.js.map +1 -1
  34. package/lib/commonjs/core/useProxifiedUnistyles/listener.js +5 -3
  35. package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
  36. package/lib/commonjs/core/withUnistyles/withUnistyles.js +2 -1
  37. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  38. package/lib/commonjs/hooks/useMedia.js +4 -4
  39. package/lib/commonjs/hooks/useMedia.js.map +1 -1
  40. package/lib/commonjs/hooks/useMedia.native.js +4 -4
  41. package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
  42. package/lib/commonjs/mocks.js +203 -0
  43. package/lib/commonjs/mocks.js.map +1 -0
  44. package/lib/commonjs/mq.js +1 -23
  45. package/lib/commonjs/mq.js.map +1 -1
  46. package/lib/commonjs/reanimated/index.js +13 -0
  47. package/lib/commonjs/reanimated/index.js.map +1 -0
  48. package/lib/commonjs/reanimated/useAnimatedTheme.js +22 -0
  49. package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -0
  50. package/lib/commonjs/reanimated/useAnimatedTheme.native.js +24 -0
  51. package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -0
  52. package/lib/commonjs/server/getServerUnistyles.js +5 -3
  53. package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
  54. package/lib/commonjs/server/hydrateServerUnistyles.js +4 -2
  55. package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
  56. package/lib/commonjs/server/resetServerUnistyles.js +4 -2
  57. package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
  58. package/lib/commonjs/utils.js +23 -1
  59. package/lib/commonjs/utils.js.map +1 -1
  60. package/lib/commonjs/web/convert/index.js +4 -7
  61. package/lib/commonjs/web/convert/index.js.map +1 -1
  62. package/lib/commonjs/web/convert/object/filter.js +7 -8
  63. package/lib/commonjs/web/convert/object/filter.js.map +1 -1
  64. package/lib/commonjs/web/create.js +6 -4
  65. package/lib/commonjs/web/create.js.map +1 -1
  66. package/lib/commonjs/web/css/state.js +1 -1
  67. package/lib/commonjs/web/css/state.js.map +1 -1
  68. package/lib/commonjs/web/index.js +7 -12
  69. package/lib/commonjs/web/index.js.map +1 -1
  70. package/lib/commonjs/web/services.js +7 -2
  71. package/lib/commonjs/web/services.js.map +1 -1
  72. package/lib/commonjs/web/shadowRegistry.js +18 -4
  73. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  74. package/lib/commonjs/web/types.js +2 -0
  75. package/lib/commonjs/web/types.js.map +1 -1
  76. package/lib/commonjs/web/utils/createUnistylesRef.js +7 -4
  77. package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
  78. package/lib/commonjs/web/utils/index.js +0 -11
  79. package/lib/commonjs/web/utils/index.js.map +1 -1
  80. package/lib/commonjs/web/utils/unistyle.js +40 -12
  81. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  82. package/lib/commonjs/web-only/getWebProps.js +19 -0
  83. package/lib/commonjs/web-only/getWebProps.js.map +1 -0
  84. package/lib/commonjs/web-only/index.js +13 -0
  85. package/lib/commonjs/web-only/index.js.map +1 -0
  86. package/lib/module/components/native/Image.js +4 -3
  87. package/lib/module/components/native/Image.js.map +1 -1
  88. package/lib/module/components/native/ImageBackground.js +2 -1
  89. package/lib/module/components/native/ImageBackground.js.map +1 -1
  90. package/lib/module/core/createUnistylesElement.js +18 -6
  91. package/lib/module/core/createUnistylesElement.js.map +1 -1
  92. package/lib/module/core/getClassname.js +8 -4
  93. package/lib/module/core/getClassname.js.map +1 -1
  94. package/lib/module/core/useProxifiedUnistyles/listener.js +3 -3
  95. package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -1
  96. package/lib/module/core/withUnistyles/withUnistyles.js +2 -1
  97. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  98. package/lib/module/hooks/useMedia.js +1 -1
  99. package/lib/module/hooks/useMedia.js.map +1 -1
  100. package/lib/module/hooks/useMedia.native.js +1 -1
  101. package/lib/module/hooks/useMedia.native.js.map +1 -1
  102. package/lib/module/mocks.js +201 -0
  103. package/lib/module/mocks.js.map +1 -0
  104. package/lib/module/mq.js +0 -19
  105. package/lib/module/mq.js.map +1 -1
  106. package/lib/module/reanimated/index.js +4 -0
  107. package/lib/module/reanimated/index.js.map +1 -0
  108. package/lib/module/reanimated/useAnimatedTheme.js +17 -0
  109. package/lib/module/reanimated/useAnimatedTheme.js.map +1 -0
  110. package/lib/module/reanimated/useAnimatedTheme.native.js +19 -0
  111. package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -0
  112. package/lib/module/server/getServerUnistyles.js +3 -3
  113. package/lib/module/server/getServerUnistyles.js.map +1 -1
  114. package/lib/module/server/hydrateServerUnistyles.js +2 -2
  115. package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
  116. package/lib/module/server/resetServerUnistyles.js +2 -2
  117. package/lib/module/server/resetServerUnistyles.js.map +1 -1
  118. package/lib/module/utils.js +19 -0
  119. package/lib/module/utils.js.map +1 -1
  120. package/lib/module/web/convert/index.js +4 -7
  121. package/lib/module/web/convert/index.js.map +1 -1
  122. package/lib/module/web/convert/object/filter.js +3 -4
  123. package/lib/module/web/convert/object/filter.js.map +1 -1
  124. package/lib/module/web/create.js +4 -4
  125. package/lib/module/web/create.js.map +1 -1
  126. package/lib/module/web/css/state.js +1 -1
  127. package/lib/module/web/css/state.js.map +1 -1
  128. package/lib/module/web/index.js +4 -10
  129. package/lib/module/web/index.js.map +1 -1
  130. package/lib/module/web/services.js +7 -1
  131. package/lib/module/web/services.js.map +1 -1
  132. package/lib/module/web/shadowRegistry.js +18 -4
  133. package/lib/module/web/shadowRegistry.js.map +1 -1
  134. package/lib/module/web/types.js +1 -1
  135. package/lib/module/web/types.js.map +1 -1
  136. package/lib/module/web/utils/createUnistylesRef.js +5 -4
  137. package/lib/module/web/utils/createUnistylesRef.js.map +1 -1
  138. package/lib/module/web/utils/index.js +0 -1
  139. package/lib/module/web/utils/index.js.map +1 -1
  140. package/lib/module/web/utils/unistyle.js +32 -9
  141. package/lib/module/web/utils/unistyle.js.map +1 -1
  142. package/lib/module/web-only/getWebProps.js +14 -0
  143. package/lib/module/web-only/getWebProps.js.map +1 -0
  144. package/lib/module/web-only/index.js +4 -0
  145. package/lib/module/web-only/index.js.map +1 -0
  146. package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
  147. package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
  148. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  149. package/lib/typescript/src/core/getClassname.d.ts +5 -5
  150. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  151. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  152. package/lib/typescript/src/mocks.d.ts +2 -0
  153. package/lib/typescript/src/mocks.d.ts.map +1 -0
  154. package/lib/typescript/src/mq.d.ts +0 -8
  155. package/lib/typescript/src/mq.d.ts.map +1 -1
  156. package/lib/typescript/src/reanimated/index.d.ts +2 -0
  157. package/lib/typescript/src/reanimated/index.d.ts.map +1 -0
  158. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts +4 -0
  159. package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -0
  160. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts +4 -0
  161. package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -0
  162. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts +0 -1
  163. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
  164. package/lib/typescript/src/server/resetServerUnistyles.d.ts.map +1 -1
  165. package/lib/typescript/src/utils.d.ts +8 -0
  166. package/lib/typescript/src/utils.d.ts.map +1 -1
  167. package/lib/typescript/src/web/convert/index.d.ts +2 -1
  168. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  169. package/lib/typescript/src/web/convert/object/filter.d.ts +2 -1
  170. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
  171. package/lib/typescript/src/web/index.d.ts +0 -5
  172. package/lib/typescript/src/web/index.d.ts.map +1 -1
  173. package/lib/typescript/src/web/services.d.ts +6 -1
  174. package/lib/typescript/src/web/services.d.ts.map +1 -1
  175. package/lib/typescript/src/web/shadowRegistry.d.ts +2 -2
  176. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  177. package/lib/typescript/src/web/types.d.ts +3 -0
  178. package/lib/typescript/src/web/types.d.ts.map +1 -1
  179. package/lib/typescript/src/web/utils/createUnistylesRef.d.ts +8 -5
  180. package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -1
  181. package/lib/typescript/src/web/utils/index.d.ts +0 -1
  182. package/lib/typescript/src/web/utils/index.d.ts.map +1 -1
  183. package/lib/typescript/src/web/utils/unistyle.d.ts +5 -1
  184. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  185. package/lib/typescript/src/web-only/getWebProps.d.ts +7 -0
  186. package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -0
  187. package/lib/typescript/src/web-only/index.d.ts +2 -0
  188. package/lib/typescript/src/web-only/index.d.ts.map +1 -0
  189. package/package.json +43 -7
  190. package/plugin/index.js +24 -17
  191. package/reanimated/package.json +6 -0
  192. package/src/components/native/Image.tsx +4 -3
  193. package/src/components/native/ImageBackground.tsx +2 -1
  194. package/src/core/createUnistylesElement.tsx +26 -9
  195. package/src/core/getClassname.ts +14 -4
  196. package/src/core/useProxifiedUnistyles/listener.ts +3 -3
  197. package/src/core/withUnistyles/withUnistyles.tsx +2 -1
  198. package/src/hooks/useMedia.native.ts +1 -1
  199. package/src/hooks/useMedia.ts +1 -1
  200. package/src/mocks.ts +217 -0
  201. package/src/mq.ts +0 -24
  202. package/src/reanimated/index.ts +1 -0
  203. package/src/reanimated/useAnimatedTheme.native.ts +21 -0
  204. package/src/reanimated/useAnimatedTheme.ts +19 -0
  205. package/src/server/getServerUnistyles.tsx +3 -3
  206. package/src/server/hydrateServerUnistyles.ts +3 -2
  207. package/src/server/resetServerUnistyles.ts +4 -3
  208. package/src/utils.ts +25 -0
  209. package/src/web/convert/index.ts +5 -7
  210. package/src/web/convert/object/filter.ts +4 -4
  211. package/src/web/create.ts +4 -4
  212. package/src/web/css/state.ts +1 -1
  213. package/src/web/index.ts +4 -16
  214. package/src/web/services.ts +14 -1
  215. package/src/web/shadowRegistry.ts +20 -5
  216. package/src/web/types.ts +9 -4
  217. package/src/web/utils/createUnistylesRef.ts +12 -8
  218. package/src/web/utils/index.ts +0 -1
  219. package/src/web/utils/unistyle.ts +47 -13
  220. package/src/web-only/getWebProps.ts +18 -0
  221. package/src/web-only/index.ts +2 -0
  222. package/web-only/package.json +6 -0
@@ -3,8 +3,9 @@ import { UnistylesRegistry } from './registry'
3
3
  import { UnistylesRuntime } from './runtime'
4
4
  import { UnistylesShadowRegistry } from './shadowRegistry'
5
5
  import { UnistylesState } from './state'
6
+ import { isServer } from './utils'
6
7
 
7
- export class UnistylesServices {
8
+ class UnistylesServices {
8
9
  runtime: UnistylesRuntime
9
10
  registry: UnistylesRegistry
10
11
  shadowRegistry: UnistylesShadowRegistry
@@ -26,3 +27,15 @@ export class UnistylesServices {
26
27
  this.services.listener = this.listener
27
28
  }
28
29
  }
30
+
31
+ declare global {
32
+ // @ts-ignore
33
+ var __unistyles__: UnistylesServices
34
+ }
35
+
36
+ if (isServer() && !globalThis.__unistyles__) {
37
+ // @ts-ignore
38
+ globalThis.__unistyles__ = new UnistylesServices()
39
+ }
40
+
41
+ export const services = isServer() ? globalThis.__unistyles__ : new UnistylesServices()
@@ -1,8 +1,8 @@
1
- import { UnistyleDependency } from '../specs'
1
+ import { UnistyleDependency } from '../specs/NativePlatform/NativePlatform.nitro'
2
2
  import type { UnistylesTheme, UnistylesValues } from '../types'
3
3
  import { deepMergeObjects } from '../utils'
4
- import type { UnistylesServices } from './types'
5
- import { extractSecrets, extractUnistyleDependencies } from './utils'
4
+ import type { UniGeneratedStyle, UnistylesServices } from './types'
5
+ import { extractSecrets, extractUnistyleDependencies, isGeneratedUnistyle, isServer } from './utils'
6
6
  import { getVariants } from './variants'
7
7
 
8
8
  export class UnistylesShadowRegistry {
@@ -28,6 +28,13 @@ export class UnistylesShadowRegistry {
28
28
  }
29
29
 
30
30
  addStyles = (unistyles: Array<UnistylesValues>, forChild?: boolean) => {
31
+ const [firstStyle] = unistyles
32
+
33
+ // If it is already a generated style, return it
34
+ if (firstStyle && isGeneratedUnistyle(firstStyle)) {
35
+ return firstStyle as UniGeneratedStyle
36
+ }
37
+
31
38
  const getParsedStyles = () => {
32
39
  const allStyles = unistyles.map(unistyle => {
33
40
  const secrets = extractSecrets(unistyle)
@@ -37,6 +44,11 @@ export class UnistylesShadowRegistry {
37
44
  return unistyle
38
45
  }
39
46
 
47
+ // Animated styles - shouldn't be processed
48
+ if (Object.keys(secrets).length === 0) {
49
+ return {}
50
+ }
51
+
40
52
  const { __uni__key, __uni__stylesheet, __uni__args = [], __uni_variants: variants } = secrets
41
53
  const newComputedStylesheet = this.services.registry.getComputedStylesheet(__uni__stylesheet, scopedTheme)
42
54
  const style = newComputedStylesheet[__uni__key] as (UnistylesValues | ((...args: any) => UnistylesValues))
@@ -52,7 +64,10 @@ export class UnistylesShadowRegistry {
52
64
  this.services.registry.addDependenciesToStylesheet(__uni__stylesheet, dependencies)
53
65
  }
54
66
 
55
- return resultWithVariants as UnistylesValues
67
+ return {
68
+ ...resultWithVariants,
69
+ ...resultWithVariants._web
70
+ } as UnistylesValues
56
71
  })
57
72
 
58
73
  return deepMergeObjects(...allStyles)
@@ -89,7 +104,7 @@ export class UnistylesShadowRegistry {
89
104
  getScopedTheme = () => this.scopedTheme
90
105
 
91
106
  remove = (ref: any, hash?: string) => {
92
- if (!(ref instanceof HTMLElement) || !hash) {
107
+ if (isServer() || !(ref instanceof HTMLElement) || !hash) {
93
108
  return
94
109
  }
95
110
 
package/src/web/types.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type { UnistylesListener } from './listener'
2
- import type{ UnistylesRegistry } from './registry'
3
- import type{ UnistylesRuntime } from './runtime'
4
- import type{ UnistylesShadowRegistry } from './shadowRegistry'
5
- import type{ UnistylesState } from './state'
2
+ import type { UnistylesRegistry } from './registry'
3
+ import type { UnistylesRuntime } from './runtime'
4
+ import type { UnistylesShadowRegistry } from './shadowRegistry'
5
+ import type { UnistylesState } from './state'
6
6
 
7
7
  export type UnistylesServices = {
8
8
  runtime: UnistylesRuntime,
@@ -11,3 +11,8 @@ export type UnistylesServices = {
11
11
  state: UnistylesState,
12
12
  listener: UnistylesListener
13
13
  }
14
+
15
+ export const UNI_GENERATED_KEYS = ['$$css', 'hash', 'injectedClassName'] as const
16
+ export type UniGeneratedKey = typeof UNI_GENERATED_KEYS[number]
17
+
18
+ export type UniGeneratedStyle = Record<UniGeneratedKey, string>
@@ -1,22 +1,26 @@
1
1
  import type React from 'react'
2
- import type { Nullable } from '../../types'
3
- import { UnistylesWeb } from '../index'
2
+ import type { Nullable, UnistylesValues } from '../../types'
3
+ import * as unistyles from '../services'
4
4
  import { isServer } from './common'
5
5
 
6
- type ClassNames = {
7
- hash: string
8
- }
6
+ type Styles = readonly [
7
+ {
8
+ hash: string
9
+ },
10
+ Array<UnistylesValues>
11
+ ]
9
12
 
10
- export const createUnistylesRef = <T>(classNames?: ClassNames, forwardedRef?: React.ForwardedRef<T>) => {
13
+ export const createUnistylesRef = <T>(styles?: Styles, forwardedRef?: React.ForwardedRef<T>) => {
11
14
  const storedRef = { current: null as Nullable<T> }
15
+ const [classNames] = styles ?? []
12
16
 
13
17
  return isServer() ? undefined : (ref: Nullable<T>) => {
14
18
  if (!ref) {
15
- UnistylesWeb.shadowRegistry.remove(storedRef, classNames?.hash)
19
+ unistyles.services.shadowRegistry.remove(storedRef, classNames?.hash)
16
20
  }
17
21
 
18
22
  storedRef.current = ref
19
- UnistylesWeb.shadowRegistry.add(ref, classNames?.hash)
23
+ unistyles.services.shadowRegistry.add(ref, classNames?.hash)
20
24
 
21
25
  if (typeof forwardedRef === 'function') {
22
26
  return forwardedRef(ref)
@@ -1,3 +1,2 @@
1
1
  export * from './common'
2
2
  export * from './unistyle'
3
- export * from './createUnistylesRef'
@@ -1,9 +1,11 @@
1
+ import { Animated } from 'react-native'
1
2
  import type { UnistylesBreakpoints } from '../../global'
2
- import { isUnistylesMq, parseMq } from '../../mq'
3
- import type { UnistyleDependency } from '../../specs/NativePlatform'
3
+ import type { UnistyleDependency } from '../../specs/NativePlatform/NativePlatform.nitro'
4
4
  import { ColorScheme, Orientation } from '../../specs/types'
5
5
  import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
6
- import { UnistylesWeb } from '../index'
6
+ import { isUnistylesMq, parseMq } from '../../utils'
7
+ import * as unistyles from '../services'
8
+ import { UNI_GENERATED_KEYS, type UniGeneratedKey, type UniGeneratedStyle } from '../types'
7
9
  import { keyInObject, reduceObject } from './common'
8
10
 
9
11
  export const schemeToTheme = (scheme: ColorScheme) => {
@@ -49,13 +51,7 @@ export const extractSecrets = (object: any) => {
49
51
  return undefined
50
52
  }
51
53
 
52
- const hiddenSecrets = Object.getOwnPropertyDescriptors(secrets)
53
-
54
- if (Object.keys(hiddenSecrets).length === 0) {
55
- return undefined
56
- }
57
-
58
- return reduceObject(hiddenSecrets, secret => secret.value)
54
+ return reduceObject(Object.getOwnPropertyDescriptors(secrets), secret => secret.value)
59
55
  }
60
56
 
61
57
  export const removeInlineStyles = (values: UnistylesValues) => {
@@ -87,10 +83,10 @@ export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
87
83
  return `@media ${queries}`
88
84
  }
89
85
 
90
- const breakpointValue = UnistylesWeb.runtime.breakpoints[query as keyof UnistylesBreakpoints] ?? 0
86
+ const breakpointValue = unistyles.services.runtime.breakpoints[query as keyof UnistylesBreakpoints] ?? 0
91
87
  const nextBreakpoint = allBreakpoints
92
- .filter((b): b is keyof UnistylesBreakpoints => b in UnistylesWeb.runtime.breakpoints)
93
- .map(b => UnistylesWeb.runtime.breakpoints[b] as number)
88
+ .filter((b): b is keyof UnistylesBreakpoints => b in unistyles.services.runtime.breakpoints)
89
+ .map(b => unistyles.services.runtime.breakpoints[b] as number)
94
90
  .sort((a, b) => a - b)
95
91
  .find(b => b > breakpointValue)
96
92
  const queries = [
@@ -110,3 +106,41 @@ export const extractUnistyleDependencies = (value: any) => {
110
106
 
111
107
  return Array.isArray(dependencies) ? dependencies : []
112
108
  }
109
+
110
+ export const checkForProp = (value: any, prop: string): boolean => {
111
+ if (Array.isArray(value)) {
112
+ return value.some(nestedValue => checkForProp(nestedValue, prop))
113
+ }
114
+
115
+ if (typeof value === 'object' && value !== null) {
116
+ return keyInObject(value, prop)
117
+ ? true
118
+ : keyInObject(value, '_web')
119
+ ? checkForProp(value._web, prop)
120
+ : false
121
+ }
122
+
123
+ return false
124
+ }
125
+
126
+ export const checkForAnimated = (value: any): boolean => {
127
+ if (Array.isArray(value)) {
128
+ return value.some(checkForAnimated)
129
+ }
130
+
131
+ if (typeof value === 'object' && value !== null) {
132
+ const objectValues = Object.values(value)
133
+ const secrets = extractSecrets(value)
134
+
135
+ // @ts-expect-error React Native Web exports Animated.AnimatedNode as Animated.Node
136
+ return value instanceof Animated.Node ||
137
+ objectValues.length > 0 && objectValues.some(checkForAnimated) ||
138
+ secrets && Object.keys(secrets).length === 0
139
+ }
140
+
141
+ return false
142
+ }
143
+
144
+ export const isGeneratedUnistyle = (value: Record<string, any>): value is UniGeneratedStyle => {
145
+ return Object.keys(value).every(key => UNI_GENERATED_KEYS.includes(key as UniGeneratedKey))
146
+ }
@@ -0,0 +1,18 @@
1
+ import type { StyleProp } from 'react-native'
2
+ import { getClassName } from '../core'
3
+ import type { RNStyle, UnistylesValues } from '../types'
4
+ import { createUnistylesRef } from '../web/utils/createUnistylesRef'
5
+
6
+ export const getWebProps = <T>(style: StyleProp<RNStyle>) => {
7
+ const styles = getClassName(style as UnistylesValues)
8
+ const ref = createUnistylesRef<T>(styles)
9
+ const [generatedStyles] = styles ?? []
10
+
11
+ return {
12
+ className: [
13
+ generatedStyles?.hash,
14
+ generatedStyles?.injectedClassName,
15
+ ].filter(Boolean).join(' '),
16
+ ref
17
+ }
18
+ }
@@ -0,0 +1,2 @@
1
+
2
+ export { getWebProps } from './getWebProps'
@@ -0,0 +1,6 @@
1
+ {
2
+ "main": "../lib/commonjs/web-only/index",
3
+ "module": "../lib/module/web-only/index",
4
+ "react-native": "../src/web-only/index",
5
+ "types": "../lib/typescript/src/web-only/index"
6
+ }