react-native-unistyles 3.0.0-alpha.34 → 3.0.0-alpha.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. package/android/CMakeLists.txt +31 -36
  2. package/android/build.gradle +2 -1
  3. package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
  4. package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
  5. package/android/src/main/cxx/cpp-adapter.cpp +8 -86
  6. package/android/src/main/java/com/unistyles/NativePlatform.kt +184 -0
  7. package/android/src/main/java/com/unistyles/UnistylesModule+insets.kt +8 -0
  8. package/android/src/main/java/com/unistyles/UnistylesModule.kt +47 -0
  9. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
  10. package/cxx/NativePlatform.h +11 -0
  11. package/cxx/common/Helpers.h +1 -1
  12. package/cxx/core/Unistyle.h +1 -1
  13. package/cxx/core/UnistylesRegistry.h +1 -1
  14. package/cxx/hybridObjects/HybridNavigationBar.h +3 -3
  15. package/cxx/hybridObjects/HybridStatusBar.h +3 -3
  16. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -4
  17. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
  18. package/lib/commonjs/components/useMedia.js.map +1 -1
  19. package/lib/commonjs/components/useMedia.web.js +43 -0
  20. package/lib/commonjs/components/useMedia.web.js.map +1 -0
  21. package/lib/commonjs/core/createUnistylesComponent.js +57 -4
  22. package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
  23. package/lib/commonjs/core/createUnistylesComponent.native.js +6 -5
  24. package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
  25. package/lib/commonjs/specs/ShadowRegistry/index.js +5 -0
  26. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  27. package/lib/commonjs/web/convert/index.js +16 -11
  28. package/lib/commonjs/web/convert/index.js.map +1 -1
  29. package/lib/commonjs/web/convert/object/boxShadow.js +58 -0
  30. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
  31. package/lib/commonjs/web/convert/object/filter.js +42 -0
  32. package/lib/commonjs/web/convert/object/filter.js.map +1 -0
  33. package/lib/commonjs/web/convert/object/index.js +39 -0
  34. package/lib/commonjs/web/convert/object/index.js.map +1 -0
  35. package/lib/commonjs/web/convert/object/objectStyle.js +55 -0
  36. package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
  37. package/lib/commonjs/web/convert/object/transform.js +27 -0
  38. package/lib/commonjs/web/convert/object/transform.js.map +1 -0
  39. package/lib/commonjs/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
  40. package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
  41. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
  42. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  43. package/lib/commonjs/web/convert/shadow/index.js +28 -0
  44. package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
  45. package/lib/commonjs/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
  46. package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
  47. package/lib/commonjs/web/convert/utils.js +7 -3
  48. package/lib/commonjs/web/convert/utils.js.map +1 -1
  49. package/lib/commonjs/web/listener.js +10 -0
  50. package/lib/commonjs/web/listener.js.map +1 -1
  51. package/lib/commonjs/web/registry.js +13 -26
  52. package/lib/commonjs/web/registry.js.map +1 -1
  53. package/lib/commonjs/web/runtime.js +3 -0
  54. package/lib/commonjs/web/runtime.js.map +1 -1
  55. package/lib/commonjs/web/shadowRegistry.js +79 -39
  56. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  57. package/lib/commonjs/web/utils/common.js +3 -33
  58. package/lib/commonjs/web/utils/common.js.map +1 -1
  59. package/lib/commonjs/web/utils/unistyle.js +4 -1
  60. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  61. package/lib/module/components/useMedia.js.map +1 -1
  62. package/lib/module/components/useMedia.web.js +38 -0
  63. package/lib/module/components/useMedia.web.js.map +1 -0
  64. package/lib/module/core/createUnistylesComponent.js +55 -3
  65. package/lib/module/core/createUnistylesComponent.js.map +1 -1
  66. package/lib/module/core/createUnistylesComponent.native.js +6 -5
  67. package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
  68. package/lib/module/specs/ShadowRegistry/index.js +5 -0
  69. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  70. package/lib/module/web/convert/index.js +14 -9
  71. package/lib/module/web/convert/index.js.map +1 -1
  72. package/lib/module/web/convert/object/boxShadow.js +53 -0
  73. package/lib/module/web/convert/object/boxShadow.js.map +1 -0
  74. package/lib/module/web/convert/object/filter.js +37 -0
  75. package/lib/module/web/convert/object/filter.js.map +1 -0
  76. package/lib/module/web/convert/object/index.js +6 -0
  77. package/lib/module/web/convert/object/index.js.map +1 -0
  78. package/lib/module/web/convert/object/objectStyle.js +50 -0
  79. package/lib/module/web/convert/object/objectStyle.js.map +1 -0
  80. package/lib/module/web/convert/object/transform.js +22 -0
  81. package/lib/module/web/convert/object/transform.js.map +1 -0
  82. package/lib/module/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
  83. package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
  84. package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
  85. package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  86. package/lib/module/web/convert/shadow/index.js +5 -0
  87. package/lib/module/web/convert/shadow/index.js.map +1 -0
  88. package/lib/module/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
  89. package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
  90. package/lib/module/web/convert/utils.js +4 -2
  91. package/lib/module/web/convert/utils.js.map +1 -1
  92. package/lib/module/web/listener.js +10 -0
  93. package/lib/module/web/listener.js.map +1 -1
  94. package/lib/module/web/registry.js +14 -27
  95. package/lib/module/web/registry.js.map +1 -1
  96. package/lib/module/web/runtime.js +3 -0
  97. package/lib/module/web/runtime.js.map +1 -1
  98. package/lib/module/web/shadowRegistry.js +80 -40
  99. package/lib/module/web/shadowRegistry.js.map +1 -1
  100. package/lib/module/web/utils/common.js +1 -31
  101. package/lib/module/web/utils/common.js.map +1 -1
  102. package/lib/module/web/utils/unistyle.js +4 -1
  103. package/lib/module/web/utils/unistyle.js.map +1 -1
  104. package/lib/typescript/src/components/useMedia.web.d.ts +6 -0
  105. package/lib/typescript/src/components/useMedia.web.d.ts.map +1 -0
  106. package/lib/typescript/src/core/createUnistylesComponent.d.ts +4 -3
  107. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
  108. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +4 -3
  109. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
  110. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  111. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +3 -0
  112. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  113. package/lib/typescript/src/types/common.d.ts +1 -0
  114. package/lib/typescript/src/types/common.d.ts.map +1 -1
  115. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  116. package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
  117. package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
  118. package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
  119. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
  120. package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
  121. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
  122. package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
  123. package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
  124. package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
  125. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
  126. package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
  127. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
  128. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
  129. package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
  130. package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
  131. package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
  132. package/lib/typescript/src/web/convert/types.d.ts +7 -1
  133. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  134. package/lib/typescript/src/web/convert/utils.d.ts +8 -4
  135. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  136. package/lib/typescript/src/web/create.d.ts +8 -8
  137. package/lib/typescript/src/web/index.d.ts +8 -8
  138. package/lib/typescript/src/web/listener.d.ts +2 -0
  139. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  140. package/lib/typescript/src/web/registry.d.ts +5 -9
  141. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  142. package/lib/typescript/src/web/runtime.d.ts +1 -0
  143. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  144. package/lib/typescript/src/web/shadowRegistry.d.ts +4 -1
  145. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  146. package/lib/typescript/src/web/utils/common.d.ts +1 -6
  147. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  148. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  149. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -0
  150. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
  151. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void.kt +1 -0
  152. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency_.kt +1 -0
  153. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +1 -0
  155. package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
  156. package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
  157. package/package.json +3 -3
  158. package/src/components/useMedia.ts +1 -1
  159. package/src/components/useMedia.web.ts +47 -0
  160. package/src/core/createUnistylesComponent.native.tsx +12 -10
  161. package/src/core/createUnistylesComponent.tsx +72 -6
  162. package/src/specs/ShadowRegistry/index.ts +5 -0
  163. package/src/specs/ShadowRegistry/types.ts +4 -1
  164. package/src/types/common.ts +1 -0
  165. package/src/web/convert/index.ts +16 -9
  166. package/src/web/convert/object/boxShadow.ts +54 -0
  167. package/src/web/convert/object/filter.ts +39 -0
  168. package/src/web/convert/object/index.ts +3 -0
  169. package/src/web/convert/object/objectStyle.ts +68 -0
  170. package/src/web/convert/object/transform.ts +24 -0
  171. package/src/web/convert/{boxShadow.ts → shadow/boxShadow.ts} +9 -30
  172. package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
  173. package/src/web/convert/shadow/index.ts +2 -0
  174. package/src/web/convert/{textShadow.ts → shadow/textShadow.ts} +9 -29
  175. package/src/web/convert/types.ts +8 -1
  176. package/src/web/convert/utils.ts +11 -5
  177. package/src/web/listener.ts +10 -0
  178. package/src/web/registry.ts +10 -31
  179. package/src/web/runtime.ts +4 -0
  180. package/src/web/shadowRegistry.ts +85 -46
  181. package/src/web/utils/common.ts +1 -37
  182. package/src/web/utils/unistyle.ts +5 -1
  183. package/android/src/main/cxx/helpers.cpp +0 -105
  184. package/android/src/main/cxx/helpers.h +0 -16
  185. package/android/src/main/cxx/platform.cpp +0 -170
  186. package/android/src/main/cxx/platform.h +0 -20
  187. package/lib/commonjs/web/convert/boxShadow.js.map +0 -1
  188. package/lib/commonjs/web/convert/shadow.js +0 -68
  189. package/lib/commonjs/web/convert/shadow.js.map +0 -1
  190. package/lib/commonjs/web/convert/textShadow.js.map +0 -1
  191. package/lib/commonjs/web/convert/transform.js +0 -72
  192. package/lib/commonjs/web/convert/transform.js.map +0 -1
  193. package/lib/module/web/convert/boxShadow.js.map +0 -1
  194. package/lib/module/web/convert/shadow.js +0 -63
  195. package/lib/module/web/convert/shadow.js.map +0 -1
  196. package/lib/module/web/convert/textShadow.js.map +0 -1
  197. package/lib/module/web/convert/transform.js +0 -67
  198. package/lib/module/web/convert/transform.js.map +0 -1
  199. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +0 -1
  200. package/lib/typescript/src/web/convert/shadow.d.ts +0 -2
  201. package/lib/typescript/src/web/convert/shadow.d.ts.map +0 -1
  202. package/lib/typescript/src/web/convert/textShadow.d.ts.map +0 -1
  203. package/lib/typescript/src/web/convert/transform.d.ts +0 -4
  204. package/lib/typescript/src/web/convert/transform.d.ts.map +0 -1
  205. package/src/web/convert/shadow.ts +0 -68
  206. package/src/web/convert/transform.ts +0 -88
  207. /package/lib/typescript/src/web/convert/{boxShadow.d.ts → shadow/boxShadow.d.ts} +0 -0
  208. /package/lib/typescript/src/web/convert/{textShadow.d.ts → shadow/textShadow.d.ts} +0 -0
@@ -1,88 +0,0 @@
1
- import { deepMergeObjects, keyInObject } from '../utils'
2
- import { normalizeNumericValue } from './utils'
3
-
4
- type Transforms = Array<Record<string, any>>
5
-
6
- const normalizeTransform = (key: string, value: any) => {
7
- if (key.includes('scale')) {
8
- return value
9
- }
10
-
11
- if (typeof value === 'number') {
12
- return normalizeNumericValue(value)
13
- }
14
-
15
- return value
16
- }
17
-
18
- const createTransformValue = (transforms: Transforms) => transforms
19
- .map(transform => {
20
- const [key] = Object.keys(transform)
21
-
22
- if (!key) {
23
- return undefined
24
- }
25
-
26
- const value = transform[key]
27
-
28
- switch(key) {
29
- case 'matrix':
30
- case 'matrix3d':
31
- return `${key}(${(value as Array<number>).join(',')})`
32
- default:
33
- return `${key}(${normalizeTransform(key, value)})`
34
- }
35
- })
36
- .filter(Boolean)
37
- .join(' ')
38
-
39
- export const getTransformStyle = (transforms: Transforms) => {
40
- const breakpoints = new Set<string>()
41
- const normalTransforms: Transforms = []
42
-
43
- transforms.forEach(transform => {
44
- const [property] = Object.keys(transform)
45
-
46
- if (!property) {
47
- return
48
- }
49
-
50
- const value = transform[property]
51
-
52
- if (typeof value === 'object' && !Array.isArray(value)) {
53
- Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint))
54
-
55
- return
56
- }
57
-
58
- normalTransforms.push(transform)
59
- })
60
-
61
- const breakpointTransforms = Array.from(breakpoints).flatMap(breakpoint => {
62
- const transformsPerBreakpoint = transforms.flatMap(transform => {
63
- const [property] = Object.keys(transform)
64
-
65
- if (!property) {
66
- return []
67
- }
68
-
69
- const value = transform[property]
70
-
71
- if (typeof value === 'object' && !Array.isArray(value)) {
72
- return keyInObject(value, breakpoint) ? [{ [property]: value[breakpoint] }] : []
73
- }
74
-
75
- return []
76
- })
77
-
78
- return [{
79
- [breakpoint]: {
80
- transform: createTransformValue(transformsPerBreakpoint)
81
- }
82
- }]
83
- })
84
-
85
- return deepMergeObjects<Record<string, any>>({
86
- transform: createTransformValue(normalTransforms)
87
- }, ...breakpointTransforms)
88
- }