react-native-unistyles 3.0.0-nightly-20250127 → 3.0.0-nightly-20250131

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 (140) hide show
  1. package/README.md +14 -2
  2. package/android/src/main/cxx/NativeUnistylesModule.cpp +1 -1
  3. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +1 -2
  4. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +4 -0
  5. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +2 -1
  6. package/android/src/main/java/com/unistyles/UnistylesModule.kt +0 -4
  7. package/components/native/Animated/package.json +5 -0
  8. package/components/native/NativeText/package.json +5 -0
  9. package/components/native/NativeView/package.json +5 -0
  10. package/cxx/core/Unistyle.h +4 -0
  11. package/cxx/core/UnistylesRegistry.cpp +24 -3
  12. package/cxx/core/UnistylesRegistry.h +3 -0
  13. package/cxx/hybridObjects/HybridShadowRegistry.cpp +7 -0
  14. package/cxx/hybridObjects/HybridStyleSheet.cpp +27 -2
  15. package/cxx/parser/Parser.cpp +10 -4
  16. package/ios/NativePlatform+ios.swift +16 -4
  17. package/lib/commonjs/components/native/Animated.js +23 -0
  18. package/lib/commonjs/components/native/Animated.js.map +1 -0
  19. package/lib/commonjs/components/native/ImageBackground.js +3 -1
  20. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  21. package/lib/commonjs/components/native/NativeText.js +13 -0
  22. package/lib/commonjs/components/native/NativeText.js.map +1 -0
  23. package/lib/commonjs/components/native/NativeText.native.js +18 -0
  24. package/lib/commonjs/components/native/NativeText.native.js.map +1 -0
  25. package/lib/commonjs/components/native/NativeView.js +9 -0
  26. package/lib/commonjs/components/native/NativeView.js.map +1 -0
  27. package/lib/commonjs/components/native/NativeView.native.js +20 -0
  28. package/lib/commonjs/components/native/NativeView.native.js.map +1 -0
  29. package/lib/commonjs/components/native/Pressable.native.js +15 -2
  30. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  31. package/lib/commonjs/core/createUnistylesElement.js +26 -22
  32. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  33. package/lib/commonjs/core/createUnistylesElement.native.js +25 -21
  34. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  35. package/lib/commonjs/core/createUnistylesImageBackground.js +34 -30
  36. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  37. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  38. package/lib/commonjs/utils.js +16 -1
  39. package/lib/commonjs/utils.js.map +1 -1
  40. package/lib/commonjs/web/utils/unistyle.js +5 -1
  41. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  42. package/lib/module/components/native/Animated.js +19 -0
  43. package/lib/module/components/native/Animated.js.map +1 -0
  44. package/lib/module/components/native/ImageBackground.js +3 -1
  45. package/lib/module/components/native/ImageBackground.js.map +1 -1
  46. package/lib/module/components/native/NativeText.js +4 -0
  47. package/lib/module/components/native/NativeText.js.map +1 -0
  48. package/lib/module/components/native/NativeText.native.js +15 -0
  49. package/lib/module/components/native/NativeText.native.js.map +1 -0
  50. package/lib/module/components/native/NativeView.js +5 -0
  51. package/lib/module/components/native/NativeView.js.map +1 -0
  52. package/lib/module/components/native/NativeView.native.js +17 -0
  53. package/lib/module/components/native/NativeView.native.js.map +1 -0
  54. package/lib/module/components/native/Pressable.native.js +15 -2
  55. package/lib/module/components/native/Pressable.native.js.map +1 -1
  56. package/lib/module/core/createUnistylesElement.js +26 -22
  57. package/lib/module/core/createUnistylesElement.js.map +1 -1
  58. package/lib/module/core/createUnistylesElement.native.js +25 -21
  59. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  60. package/lib/module/core/createUnistylesImageBackground.js +34 -30
  61. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  62. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  63. package/lib/module/utils.js +14 -0
  64. package/lib/module/utils.js.map +1 -1
  65. package/lib/module/web/utils/unistyle.js +5 -1
  66. package/lib/module/web/utils/unistyle.js.map +1 -1
  67. package/lib/typescript/src/components/native/ActivityIndicator.d.ts +1 -3
  68. package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
  69. package/lib/typescript/src/components/native/Animated.d.ts +39 -0
  70. package/lib/typescript/src/components/native/Animated.d.ts.map +1 -0
  71. package/lib/typescript/src/components/native/FlatList.d.ts +1 -3
  72. package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
  73. package/lib/typescript/src/components/native/Image.d.ts +1 -3
  74. package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
  75. package/lib/typescript/src/components/native/ImageBackground.d.ts +1 -8
  76. package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
  77. package/lib/typescript/src/components/native/ImageBackground.native.d.ts +1 -2
  78. package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
  79. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +1 -3
  80. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
  81. package/lib/typescript/src/components/native/NativeText.d.ts +2 -0
  82. package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -0
  83. package/lib/typescript/src/components/native/NativeText.native.d.ts +2 -0
  84. package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -0
  85. package/lib/typescript/src/components/native/NativeView.d.ts +3 -0
  86. package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -0
  87. package/lib/typescript/src/components/native/NativeView.native.d.ts +3 -0
  88. package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -0
  89. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
  90. package/lib/typescript/src/components/native/RefreshControl.d.ts +1 -3
  91. package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
  92. package/lib/typescript/src/components/native/ScrollView.d.ts +1 -3
  93. package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
  94. package/lib/typescript/src/components/native/SectionList.d.ts +1 -3
  95. package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
  96. package/lib/typescript/src/components/native/Switch.d.ts +1 -3
  97. package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
  98. package/lib/typescript/src/components/native/Text.d.ts +1 -3
  99. package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
  100. package/lib/typescript/src/components/native/TextInput.d.ts +1 -3
  101. package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
  102. package/lib/typescript/src/components/native/TouchableHighlight.d.ts +1 -3
  103. package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
  104. package/lib/typescript/src/components/native/TouchableOpacity.d.ts +1 -3
  105. package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
  106. package/lib/typescript/src/components/native/View.d.ts +1 -3
  107. package/lib/typescript/src/components/native/View.d.ts.map +1 -1
  108. package/lib/typescript/src/components/native/VirtualizedList.d.ts +1 -3
  109. package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
  110. package/lib/typescript/src/core/createUnistylesElement.d.ts +1 -7
  111. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  112. package/lib/typescript/src/core/createUnistylesElement.native.d.ts +1 -2
  113. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  114. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +2 -3
  115. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  116. package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -0
  117. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  118. package/lib/typescript/src/utils.d.ts +1 -0
  119. package/lib/typescript/src/utils.d.ts.map +1 -1
  120. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  121. package/package.json +9 -7
  122. package/plugin/consts.js +63 -0
  123. package/plugin/exotic.js +54 -0
  124. package/plugin/index.d.ts +79 -33
  125. package/plugin/index.js +23 -31
  126. package/plugin/stylesheet.js +12 -1
  127. package/plugin/variants.js +1 -1
  128. package/src/components/native/Animated.tsx +17 -0
  129. package/src/components/native/ImageBackground.tsx +4 -1
  130. package/src/components/native/NativeText.native.tsx +12 -0
  131. package/src/components/native/NativeText.tsx +1 -0
  132. package/src/components/native/NativeView.native.tsx +13 -0
  133. package/src/components/native/NativeView.tsx +3 -0
  134. package/src/components/native/Pressable.native.tsx +20 -2
  135. package/src/core/createUnistylesElement.native.tsx +28 -23
  136. package/src/core/createUnistylesElement.tsx +34 -29
  137. package/src/core/createUnistylesImageBackground.tsx +38 -33
  138. package/src/specs/StyleSheet/index.ts +2 -1
  139. package/src/utils.ts +17 -0
  140. package/src/web/utils/unistyle.ts +7 -1
@@ -3,43 +3,48 @@ import type { Image, ImageBackground, ImageBackgroundProps } from 'react-native'
3
3
  import { UnistylesShadowRegistry } from '../specs'
4
4
  import { passForwardedRef } from './passForwardRef'
5
5
  import { maybeWarnAboutMultipleUnistyles } from './warn'
6
+ import { copyComponentProperties } from '../utils'
6
7
 
7
- export const createUnistylesImageBackground = (Component: typeof ImageBackground) => React.forwardRef<ImageBackground, ImageBackgroundProps>((props, forwardedRef) => {
8
- const storedImageRef = useRef<Image | null>(null)
8
+ export const createUnistylesImageBackground = (Component: typeof ImageBackground) => {
9
+ const UnistylesImageBackground = React.forwardRef<ImageBackground, ImageBackgroundProps>((props, forwardedRef) => {
10
+ const storedImageRef = useRef<Image | null>(null)
9
11
 
10
- useLayoutEffect(() => {
11
- return () => {
12
- if (storedImageRef.current) {
13
- // @ts-ignore
14
- UnistylesShadowRegistry.remove(storedImageRef.current)
12
+ useLayoutEffect(() => {
13
+ return () => {
14
+ if (storedImageRef.current) {
15
+ // @ts-ignore
16
+ UnistylesShadowRegistry.remove(storedImageRef.current)
17
+ }
15
18
  }
16
- }
17
- }, [])
19
+ }, [])
18
20
 
19
- // @ts-expect-error we don't know the type of the component
20
- maybeWarnAboutMultipleUnistyles(props.style, 'ImageBackground')
21
- // @ts-ignore we don't know the type of the component
22
- maybeWarnAboutMultipleUnistyles(props.imageStyle, 'ImageBackground')
21
+ // @ts-expect-error we don't know the type of the component
22
+ maybeWarnAboutMultipleUnistyles(props.style, 'ImageBackground')
23
+ // @ts-ignore we don't know the type of the component
24
+ maybeWarnAboutMultipleUnistyles(props.imageStyle, 'ImageBackground')
23
25
 
24
- return (
25
- <Component
26
- {...props}
27
- ref={ref => {
28
- passForwardedRef(props, ref, forwardedRef)
26
+ return (
27
+ <Component
28
+ {...props}
29
+ ref={ref => {
30
+ passForwardedRef(props, ref, forwardedRef)
29
31
 
30
- return () => {
31
- // @ts-ignore
32
- UnistylesShadowRegistry.remove(ref)
33
- }
34
- }}
35
- imageRef={ref => {
36
- if (ref) {
37
- storedImageRef.current = ref
38
- }
32
+ return () => {
33
+ // @ts-ignore
34
+ UnistylesShadowRegistry.remove(ref)
35
+ }
36
+ }}
37
+ imageRef={ref => {
38
+ if (ref) {
39
+ storedImageRef.current = ref
40
+ }
41
+
42
+ // @ts-expect-error web types are not compatible with RN styles
43
+ UnistylesShadowRegistry.add(ref, props.imageStyle)
44
+ }}
45
+ />
46
+ )
47
+ })
39
48
 
40
- // @ts-expect-error web types are not compatible with RN styles
41
- UnistylesShadowRegistry.add(ref, props.imageStyle)
42
- }}
43
- />
44
- )
45
- })
49
+ return copyComponentProperties(Component, UnistylesImageBackground)
50
+ }
@@ -12,7 +12,8 @@ type UnistylesThemeSettings = {
12
12
  }
13
13
 
14
14
  type UnistylesSettings = UnistylesThemeSettings & {
15
- CSSVars?: boolean
15
+ CSSVars?: boolean,
16
+ nativeBreakpointsMode?: 'pixels' | 'points'
16
17
  }
17
18
 
18
19
  export type UnistylesConfig = {
package/src/utils.ts CHANGED
@@ -24,3 +24,20 @@ export const deepMergeObjects = <T extends Record<PropertyKey, any>>(...sources:
24
24
 
25
25
  return target
26
26
  }
27
+
28
+ export const copyComponentProperties = (Component: any, UnistylesComponent: any) => {
29
+ Object.entries(Component).forEach(([key, value]) => {
30
+ // Filter out the keys we don't want to copy
31
+ if (['$$typeof', 'render'].includes(key)) {
32
+ return
33
+ }
34
+
35
+ UnistylesComponent[key] = value
36
+ })
37
+
38
+ // Those are not enumerable, so we need to copy them manually
39
+ UnistylesComponent.displayName = Component.displayName
40
+ UnistylesComponent.name = Component.name
41
+
42
+ return UnistylesComponent
43
+ }
@@ -49,7 +49,13 @@ export const extractSecrets = (object: any) => {
49
49
  return undefined
50
50
  }
51
51
 
52
- return reduceObject(Object.getOwnPropertyDescriptors(secrets), secret => secret.value)
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)
53
59
  }
54
60
 
55
61
  export const removeInlineStyles = (values: UnistylesValues) => {