react-native-unistyles 3.0.0-nightly-20250203 → 3.0.0-nightly-20250207

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 (204) hide show
  1. package/cxx/core/HostUnistyle.cpp +18 -4
  2. package/lib/commonjs/components/native/Animated.js +2 -2
  3. package/lib/commonjs/components/native/Animated.js.map +1 -1
  4. package/lib/commonjs/components/native/ImageBackground.js +5 -5
  5. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  6. package/lib/commonjs/components/native/NativeText.native.js.map +1 -1
  7. package/lib/commonjs/components/native/NativeView.native.js.map +1 -1
  8. package/lib/commonjs/components/native/Pressable.js +1 -1
  9. package/lib/commonjs/components/native/Pressable.js.map +1 -1
  10. package/lib/commonjs/components/native/Pressable.native.js +6 -10
  11. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  12. package/lib/commonjs/core/createUnistylesElement.js +5 -5
  13. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  14. package/lib/commonjs/core/createUnistylesElement.native.js +1 -1
  15. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  16. package/lib/commonjs/core/createUnistylesImageBackground.js +1 -1
  17. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  18. package/lib/commonjs/core/withUnistyles/withUnistyles.js +1 -1
  19. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  20. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +1 -1
  21. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  22. package/lib/commonjs/hooks/useMedia.native.js +1 -1
  23. package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
  24. package/lib/commonjs/mq.js.map +1 -1
  25. package/lib/commonjs/server/getServerUnistyles.js +1 -1
  26. package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
  27. package/lib/commonjs/server/hydrateServerUnistyles.js +1 -1
  28. package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
  29. package/lib/commonjs/server/resetServerUnistyles.js +1 -1
  30. package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
  31. package/lib/commonjs/server/useServerUnistyles.js +2 -2
  32. package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
  33. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  34. package/lib/commonjs/specs/StyleSheet/index.js +1 -1
  35. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  36. package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
  37. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  38. package/lib/commonjs/specs/index.native.js +3 -3
  39. package/lib/commonjs/specs/index.native.js.map +1 -1
  40. package/lib/commonjs/web/convert/index.js +3 -3
  41. package/lib/commonjs/web/convert/index.js.map +1 -1
  42. package/lib/commonjs/web/convert/object/boxShadow.js +4 -4
  43. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
  44. package/lib/commonjs/web/convert/object/filter.js +3 -3
  45. package/lib/commonjs/web/convert/object/filter.js.map +1 -1
  46. package/lib/commonjs/web/convert/object/transform.js +1 -1
  47. package/lib/commonjs/web/convert/object/transform.js.map +1 -1
  48. package/lib/commonjs/web/convert/utils.js.map +1 -1
  49. package/lib/commonjs/web/index.js +1 -1
  50. package/lib/commonjs/web/index.js.map +1 -1
  51. package/lib/commonjs/web/registry.js +1 -1
  52. package/lib/commonjs/web/registry.js.map +1 -1
  53. package/lib/commonjs/web/runtime.js.map +1 -1
  54. package/lib/commonjs/web/shadowRegistry.js +1 -1
  55. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  56. package/lib/commonjs/web/state.js +1 -1
  57. package/lib/commonjs/web/state.js.map +1 -1
  58. package/lib/commonjs/web/utils/unistyle.js +2 -2
  59. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  60. package/lib/module/components/native/Animated.js +2 -2
  61. package/lib/module/components/native/Animated.js.map +1 -1
  62. package/lib/module/components/native/ImageBackground.js +3 -3
  63. package/lib/module/components/native/ImageBackground.js.map +1 -1
  64. package/lib/module/components/native/NativeText.native.js.map +1 -1
  65. package/lib/module/components/native/NativeView.native.js.map +1 -1
  66. package/lib/module/components/native/Pressable.js +1 -1
  67. package/lib/module/components/native/Pressable.js.map +1 -1
  68. package/lib/module/components/native/Pressable.native.js +6 -10
  69. package/lib/module/components/native/Pressable.native.js.map +1 -1
  70. package/lib/module/core/createUnistylesElement.js +3 -3
  71. package/lib/module/core/createUnistylesElement.js.map +1 -1
  72. package/lib/module/core/createUnistylesElement.native.js +1 -1
  73. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  74. package/lib/module/core/createUnistylesImageBackground.js +1 -1
  75. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  76. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  77. package/lib/module/core/withUnistyles/withUnistyles.js +1 -1
  78. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  79. package/lib/module/core/withUnistyles/withUnistyles.native.js +1 -1
  80. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  81. package/lib/module/hooks/useMedia.native.js +1 -1
  82. package/lib/module/hooks/useMedia.native.js.map +1 -1
  83. package/lib/module/mq.js.map +1 -1
  84. package/lib/module/server/getServerUnistyles.js +1 -1
  85. package/lib/module/server/getServerUnistyles.js.map +1 -1
  86. package/lib/module/server/hydrateServerUnistyles.js +1 -1
  87. package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
  88. package/lib/module/server/resetServerUnistyles.js +1 -1
  89. package/lib/module/server/resetServerUnistyles.js.map +1 -1
  90. package/lib/module/server/useServerUnistyles.js +2 -2
  91. package/lib/module/server/useServerUnistyles.js.map +1 -1
  92. package/lib/module/specs/StatusBar/index.js.map +1 -1
  93. package/lib/module/specs/StyleSheet/index.js +1 -1
  94. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  95. package/lib/module/specs/UnistylesRuntime/index.js +1 -1
  96. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  97. package/lib/module/specs/index.native.js +4 -4
  98. package/lib/module/specs/index.native.js.map +1 -1
  99. package/lib/module/web/convert/index.js +4 -4
  100. package/lib/module/web/convert/index.js.map +1 -1
  101. package/lib/module/web/convert/object/boxShadow.js +2 -2
  102. package/lib/module/web/convert/object/boxShadow.js.map +1 -1
  103. package/lib/module/web/convert/object/filter.js +3 -3
  104. package/lib/module/web/convert/object/filter.js.map +1 -1
  105. package/lib/module/web/convert/object/transform.js +1 -1
  106. package/lib/module/web/convert/object/transform.js.map +1 -1
  107. package/lib/module/web/convert/utils.js.map +1 -1
  108. package/lib/module/web/index.js +1 -1
  109. package/lib/module/web/index.js.map +1 -1
  110. package/lib/module/web/registry.js +1 -1
  111. package/lib/module/web/registry.js.map +1 -1
  112. package/lib/module/web/runtime.js.map +1 -1
  113. package/lib/module/web/shadowRegistry.js +1 -1
  114. package/lib/module/web/shadowRegistry.js.map +1 -1
  115. package/lib/module/web/state.js +1 -1
  116. package/lib/module/web/state.js.map +1 -1
  117. package/lib/module/web/utils/unistyle.js +2 -2
  118. package/lib/module/web/utils/unistyle.js.map +1 -1
  119. package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
  120. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
  121. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
  122. package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
  123. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  124. package/lib/typescript/src/mq.d.ts +1 -1
  125. package/lib/typescript/src/mq.d.ts.map +1 -1
  126. package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
  127. package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
  128. package/lib/typescript/src/specs/StatusBar/index.d.ts +1 -1
  129. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  130. package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -1
  131. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  132. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
  133. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  134. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +5 -5
  135. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  136. package/lib/typescript/src/specs/index.native.d.ts +4 -4
  137. package/lib/typescript/src/specs/index.native.d.ts.map +1 -1
  138. package/lib/typescript/src/types/breakpoints.d.ts +2 -2
  139. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  140. package/lib/typescript/src/types/core.d.ts +1 -1
  141. package/lib/typescript/src/types/core.d.ts.map +1 -1
  142. package/lib/typescript/src/types/stylesheet.d.ts +4 -4
  143. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  144. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
  145. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
  146. package/lib/typescript/src/web/convert/types.d.ts +1 -1
  147. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  148. package/lib/typescript/src/web/convert/utils.d.ts +2 -2
  149. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  150. package/lib/typescript/src/web/create.d.ts +1 -1
  151. package/lib/typescript/src/web/create.d.ts.map +1 -1
  152. package/lib/typescript/src/web/index.d.ts +1 -1
  153. package/lib/typescript/src/web/index.d.ts.map +1 -1
  154. package/lib/typescript/src/web/registry.d.ts +1 -1
  155. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  156. package/lib/typescript/src/web/runtime.d.ts +1 -1
  157. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  158. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  159. package/lib/typescript/src/web/state.d.ts +1 -1
  160. package/lib/typescript/src/web/state.d.ts.map +1 -1
  161. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  162. package/package.json +4 -2
  163. package/plugin/index.js +27 -29
  164. package/plugin/stylesheet.js +423 -188
  165. package/src/components/native/Animated.tsx +2 -2
  166. package/src/components/native/ImageBackground.tsx +4 -4
  167. package/src/components/native/NativeText.native.tsx +1 -1
  168. package/src/components/native/NativeView.native.tsx +1 -1
  169. package/src/components/native/Pressable.native.tsx +7 -12
  170. package/src/components/native/Pressable.tsx +1 -1
  171. package/src/core/createUnistylesElement.native.tsx +1 -1
  172. package/src/core/createUnistylesElement.tsx +3 -3
  173. package/src/core/createUnistylesImageBackground.tsx +1 -1
  174. package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +1 -1
  175. package/src/core/withUnistyles/withUnistyles.native.tsx +2 -2
  176. package/src/core/withUnistyles/withUnistyles.tsx +3 -3
  177. package/src/hooks/useMedia.native.ts +1 -1
  178. package/src/mq.ts +1 -1
  179. package/src/server/getServerUnistyles.tsx +1 -1
  180. package/src/server/hydrateServerUnistyles.ts +1 -1
  181. package/src/server/resetServerUnistyles.ts +1 -1
  182. package/src/server/useServerUnistyles.tsx +2 -2
  183. package/src/specs/StatusBar/index.ts +1 -1
  184. package/src/specs/StyleSheet/index.ts +3 -3
  185. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
  186. package/src/specs/UnistylesRuntime/index.ts +5 -5
  187. package/src/specs/index.native.ts +4 -4
  188. package/src/types/breakpoints.ts +2 -2
  189. package/src/types/core.ts +1 -1
  190. package/src/types/stylesheet.ts +4 -4
  191. package/src/web/convert/index.ts +4 -4
  192. package/src/web/convert/object/boxShadow.ts +2 -2
  193. package/src/web/convert/object/filter.ts +3 -3
  194. package/src/web/convert/object/transform.ts +2 -2
  195. package/src/web/convert/types.ts +1 -1
  196. package/src/web/convert/utils.ts +2 -2
  197. package/src/web/create.ts +1 -1
  198. package/src/web/index.ts +3 -3
  199. package/src/web/registry.ts +2 -2
  200. package/src/web/runtime.ts +2 -2
  201. package/src/web/shadowRegistry.ts +2 -2
  202. package/src/web/state.ts +4 -4
  203. package/src/web/utils/unistyle.ts +3 -3
  204. package/plugin/common.js +0 -154
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-nightly-20250203",
3
+ "version": "3.0.0-nightly-20250207",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
7
7
  "test:coverage": "jest --passWithNoTests --coverage",
8
8
  "tsc": "node_modules/typescript/bin/tsc --noEmit",
9
9
  "lint": "biome lint",
10
+ "check": "biome check --write",
11
+ "check:ci": "biome check",
10
12
  "prepare": "husky && bob build",
11
- "precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn test'",
13
+ "precommit": "concurrently 'yarn tsc' 'yarn lint' 'yarn check' 'yarn test'",
12
14
  "release": "release-it"
13
15
  },
14
16
  "main": "lib/commonjs/index.js",
package/plugin/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  const { addUnistylesImport, isInsideNodeModules } = require('./import')
2
2
  const { hasStringRef } = require('./ref')
3
- const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyles, isKindOfStyleSheet, maybeAddThemeDependencyToMemberExpression, addThemeDependencyToMemberExpression, getStyleSheetLocalNames } = require('./stylesheet')
3
+ const { isUnistylesStyleSheet, addStyleSheetTag, isKindOfStyleSheet, getStylesDependenciesFromFunction, addDependencies, getStylesDependenciesFromObject } = require('./stylesheet')
4
4
  const { extractVariants } = require('./variants')
5
5
  const { REACT_NATIVE_COMPONENT_NAMES, REPLACE_WITH_UNISTYLES_PATHS, REPLACE_WITH_UNISTYLES_EXOTIC_PATHS, NATIVE_COMPONENTS_PATHS } = require('./consts')
6
6
  const { handleExoticImport } = require('./exotic')
@@ -17,6 +17,7 @@ module.exports = function ({ types: t }) {
17
17
  .some(path => state.filename.includes(path))
18
18
 
19
19
  state.file.hasAnyUnistyle = false
20
+ state.file.hasUnistylesImport = false
20
21
  state.file.hasVariants = false
21
22
  state.file.styleSheetLocalName = ''
22
23
  state.file.tagNumber = 0
@@ -95,6 +96,8 @@ module.exports = function ({ types: t }) {
95
96
  const importSource = path.node.source.value
96
97
 
97
98
  if (importSource.includes('react-native-unistyles')) {
99
+ state.file.hasUnistylesImport = true
100
+
98
101
  path.node.specifiers.forEach(specifier => {
99
102
  if (specifier.imported && specifier.imported.name === 'StyleSheet') {
100
103
  state.file.styleSheetLocalName = specifier.local.name
@@ -149,43 +152,38 @@ module.exports = function ({ types: t }) {
149
152
 
150
153
  const arg = path.node.arguments[0]
151
154
 
152
- // Object passed to StyleSheet.create
155
+ // Object passed to StyleSheet.create (may contain variants)
153
156
  if (t.isObjectExpression(arg)) {
154
- arg.properties.forEach(property => {
155
- if (t.isObjectProperty(property)) {
156
- const propertyValues = getUnistyles(t, property)
157
+ const detectedDependencies = getStylesDependenciesFromObject(t, path)
157
158
 
158
- propertyValues.forEach(propertyValue => {
159
- analyzeDependencies(t, state, property.key.name, propertyValue, [], [])
159
+ if (detectedDependencies) {
160
+ if (t.isObjectExpression(arg)) {
161
+ arg.properties.forEach(property => {
162
+ if (detectedDependencies[property.key.name]) {
163
+ addDependencies(t, state, property.key.name, property, detectedDependencies[property.key.name])
164
+ }
160
165
  })
161
166
  }
162
- })
167
+ }
163
168
  }
164
169
 
165
170
  // Function passed to StyleSheet.create (e.g., theme => ({ container: {} }))
166
171
  if (t.isArrowFunctionExpression(arg) || t.isFunctionExpression(arg)) {
167
- const localNames = getStyleSheetLocalNames(t, arg)
168
- const body = t.isBlockStatement(arg.body)
169
- ? arg.body.body.find(statement => t.isReturnStatement(statement)).argument
170
- : arg.body
171
-
172
- // Ensure the function body returns an object
173
- if (t.isObjectExpression(body)) {
174
- body.properties.forEach(property => {
175
- if (t.isObjectProperty(property)) {
176
- const propertyValues = getUnistyles(t, property)
177
-
178
- // special case for non object/function properties
179
- // maybe user used inlined theme? ({ container: theme.components.container })
180
- if (propertyValues.length === 0 && maybeAddThemeDependencyToMemberExpression(t, property, localNames.theme)) {
181
- addThemeDependencyToMemberExpression(t, property)
172
+ const detectedDependencies = getStylesDependenciesFromFunction(t, path)
173
+
174
+ if (detectedDependencies) {
175
+ const body = t.isBlockStatement(arg.body)
176
+ ? arg.body.body.find(statement => t.isReturnStatement(statement)).argument
177
+ : arg.body
178
+
179
+ // Ensure the function body returns an object
180
+ if (t.isObjectExpression(body)) {
181
+ body.properties.forEach(property => {
182
+ if (detectedDependencies[property.key.name]) {
183
+ addDependencies(t, state, property.key.name, property, detectedDependencies[property.key.name])
182
184
  }
183
-
184
- propertyValues.forEach(propertyValue => {
185
- analyzeDependencies(t, state, property.key.name, propertyValue, localNames.theme, localNames.miniRuntime)
186
- })
187
- }
188
- })
185
+ })
186
+ }
189
187
  }
190
188
  }
191
189
  }