react-native-unistyles 3.0.0-nightly-20250208 → 3.0.0-nightly-20250213

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 (77) hide show
  1. package/README.md +3 -0
  2. package/android/CMakeLists.txt +1 -1
  3. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +4 -0
  4. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +20 -1
  5. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +4 -0
  6. package/android/src/main/java/com/unistyles/UnistylesModule.kt +5 -0
  7. package/cxx/core/HashGenerator.cpp +1 -1
  8. package/cxx/core/HostUnistyle.cpp +15 -5
  9. package/cxx/core/HostUnistyle.h +1 -0
  10. package/cxx/core/UnistyleWrapper.h +6 -6
  11. package/cxx/core/UnistylesCommitHook.cpp +20 -17
  12. package/cxx/core/UnistylesRegistry.cpp +8 -6
  13. package/cxx/shadowTree/ShadowTrafficController.h +10 -4
  14. package/cxx/shadowTree/ShadowTreeManager.cpp +38 -35
  15. package/lib/commonjs/components/native/Pressable.native.js +8 -1
  16. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  17. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -2
  18. package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  19. package/lib/commonjs/core/warn.js +1 -1
  20. package/lib/commonjs/core/withUnistyles/withUnistyles.js +1 -1
  21. package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
  22. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +4 -2
  23. package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
  24. package/lib/commonjs/web/convert/index.js +1 -1
  25. package/lib/commonjs/web/convert/index.js.map +1 -1
  26. package/lib/commonjs/web/utils/common.js +1 -1
  27. package/lib/commonjs/web/utils/unistyle.js +3 -3
  28. package/lib/module/components/native/Pressable.native.js +8 -1
  29. package/lib/module/components/native/Pressable.native.js.map +1 -1
  30. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -2
  31. package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
  32. package/lib/module/core/warn.js +1 -1
  33. package/lib/module/core/withUnistyles/withUnistyles.js +1 -1
  34. package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
  35. package/lib/module/core/withUnistyles/withUnistyles.native.js +5 -3
  36. package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
  37. package/lib/module/web/convert/index.js +1 -1
  38. package/lib/module/web/convert/index.js.map +1 -1
  39. package/lib/module/web/utils/common.js +1 -1
  40. package/lib/module/web/utils/unistyle.js +3 -3
  41. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
  42. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +2 -1
  43. package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
  44. package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
  45. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +23 -39
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/unistylesOnLoad.kt +35 -0
  48. package/nitrogen/generated/ios/Unistyles+autolinking.rb +2 -0
  49. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +1 -1
  50. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +3 -1
  51. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +2 -3
  52. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +18 -18
  53. package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
  54. package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -1
  55. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
  56. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
  57. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
  58. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
  59. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
  60. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
  61. package/nitrogen/generated/shared/c++/Insets.hpp +1 -1
  62. package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
  63. package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +1 -1
  64. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -1
  65. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -1
  66. package/package.json +3 -3
  67. package/plugin/import.js +1 -1
  68. package/plugin/index.js +2 -2
  69. package/plugin/stylesheet.js +2 -2
  70. package/src/components/native/Pressable.native.tsx +9 -1
  71. package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +2 -2
  72. package/src/core/warn.ts +1 -1
  73. package/src/core/withUnistyles/withUnistyles.native.tsx +6 -4
  74. package/src/core/withUnistyles/withUnistyles.tsx +1 -1
  75. package/src/web/convert/index.ts +1 -1
  76. package/src/web/utils/common.ts +1 -1
  77. package/src/web/utils/unistyle.ts +3 -3
@@ -101,7 +101,7 @@ public class HybridNativePlatformSpec_cxx {
101
101
 
102
102
  // Methods
103
103
  @inline(__always)
104
- public func getInsets() -> bridge.Result_Insets_ {
104
+ public final func getInsets() -> bridge.Result_Insets_ {
105
105
  do {
106
106
  let __result = try self.__implementation.getInsets()
107
107
  let __resultCpp = __result
@@ -113,7 +113,7 @@ public class HybridNativePlatformSpec_cxx {
113
113
  }
114
114
 
115
115
  @inline(__always)
116
- public func getColorScheme() -> bridge.Result_ColorScheme_ {
116
+ public final func getColorScheme() -> bridge.Result_ColorScheme_ {
117
117
  do {
118
118
  let __result = try self.__implementation.getColorScheme()
119
119
  let __resultCpp = __result
@@ -125,7 +125,7 @@ public class HybridNativePlatformSpec_cxx {
125
125
  }
126
126
 
127
127
  @inline(__always)
128
- public func getFontScale() -> bridge.Result_double_ {
128
+ public final func getFontScale() -> bridge.Result_double_ {
129
129
  do {
130
130
  let __result = try self.__implementation.getFontScale()
131
131
  let __resultCpp = __result
@@ -137,7 +137,7 @@ public class HybridNativePlatformSpec_cxx {
137
137
  }
138
138
 
139
139
  @inline(__always)
140
- public func getPixelRatio() -> bridge.Result_double_ {
140
+ public final func getPixelRatio() -> bridge.Result_double_ {
141
141
  do {
142
142
  let __result = try self.__implementation.getPixelRatio()
143
143
  let __resultCpp = __result
@@ -149,7 +149,7 @@ public class HybridNativePlatformSpec_cxx {
149
149
  }
150
150
 
151
151
  @inline(__always)
152
- public func getOrientation() -> bridge.Result_Orientation_ {
152
+ public final func getOrientation() -> bridge.Result_Orientation_ {
153
153
  do {
154
154
  let __result = try self.__implementation.getOrientation()
155
155
  let __resultCpp = __result
@@ -161,7 +161,7 @@ public class HybridNativePlatformSpec_cxx {
161
161
  }
162
162
 
163
163
  @inline(__always)
164
- public func getContentSizeCategory() -> bridge.Result_std__string_ {
164
+ public final func getContentSizeCategory() -> bridge.Result_std__string_ {
165
165
  do {
166
166
  let __result = try self.__implementation.getContentSizeCategory()
167
167
  let __resultCpp = std.string(__result)
@@ -173,7 +173,7 @@ public class HybridNativePlatformSpec_cxx {
173
173
  }
174
174
 
175
175
  @inline(__always)
176
- public func getScreenDimensions() -> bridge.Result_Dimensions_ {
176
+ public final func getScreenDimensions() -> bridge.Result_Dimensions_ {
177
177
  do {
178
178
  let __result = try self.__implementation.getScreenDimensions()
179
179
  let __resultCpp = __result
@@ -185,7 +185,7 @@ public class HybridNativePlatformSpec_cxx {
185
185
  }
186
186
 
187
187
  @inline(__always)
188
- public func getStatusBarDimensions() -> bridge.Result_Dimensions_ {
188
+ public final func getStatusBarDimensions() -> bridge.Result_Dimensions_ {
189
189
  do {
190
190
  let __result = try self.__implementation.getStatusBarDimensions()
191
191
  let __resultCpp = __result
@@ -197,7 +197,7 @@ public class HybridNativePlatformSpec_cxx {
197
197
  }
198
198
 
199
199
  @inline(__always)
200
- public func getNavigationBarDimensions() -> bridge.Result_Dimensions_ {
200
+ public final func getNavigationBarDimensions() -> bridge.Result_Dimensions_ {
201
201
  do {
202
202
  let __result = try self.__implementation.getNavigationBarDimensions()
203
203
  let __resultCpp = __result
@@ -209,7 +209,7 @@ public class HybridNativePlatformSpec_cxx {
209
209
  }
210
210
 
211
211
  @inline(__always)
212
- public func getPrefersRtlDirection() -> bridge.Result_bool_ {
212
+ public final func getPrefersRtlDirection() -> bridge.Result_bool_ {
213
213
  do {
214
214
  let __result = try self.__implementation.getPrefersRtlDirection()
215
215
  let __resultCpp = __result
@@ -221,7 +221,7 @@ public class HybridNativePlatformSpec_cxx {
221
221
  }
222
222
 
223
223
  @inline(__always)
224
- public func setRootViewBackgroundColor(color: Double) -> bridge.Result_void_ {
224
+ public final func setRootViewBackgroundColor(color: Double) -> bridge.Result_void_ {
225
225
  do {
226
226
  try self.__implementation.setRootViewBackgroundColor(color: color)
227
227
  return bridge.create_Result_void_()
@@ -232,7 +232,7 @@ public class HybridNativePlatformSpec_cxx {
232
232
  }
233
233
 
234
234
  @inline(__always)
235
- public func setNavigationBarHidden(isHidden: Bool) -> bridge.Result_void_ {
235
+ public final func setNavigationBarHidden(isHidden: Bool) -> bridge.Result_void_ {
236
236
  do {
237
237
  try self.__implementation.setNavigationBarHidden(isHidden: isHidden)
238
238
  return bridge.create_Result_void_()
@@ -243,7 +243,7 @@ public class HybridNativePlatformSpec_cxx {
243
243
  }
244
244
 
245
245
  @inline(__always)
246
- public func setStatusBarHidden(isHidden: Bool) -> bridge.Result_void_ {
246
+ public final func setStatusBarHidden(isHidden: Bool) -> bridge.Result_void_ {
247
247
  do {
248
248
  try self.__implementation.setStatusBarHidden(isHidden: isHidden)
249
249
  return bridge.create_Result_void_()
@@ -254,7 +254,7 @@ public class HybridNativePlatformSpec_cxx {
254
254
  }
255
255
 
256
256
  @inline(__always)
257
- public func setImmersiveMode(isEnabled: Bool) -> bridge.Result_void_ {
257
+ public final func setImmersiveMode(isEnabled: Bool) -> bridge.Result_void_ {
258
258
  do {
259
259
  try self.__implementation.setImmersiveMode(isEnabled: isEnabled)
260
260
  return bridge.create_Result_void_()
@@ -265,7 +265,7 @@ public class HybridNativePlatformSpec_cxx {
265
265
  }
266
266
 
267
267
  @inline(__always)
268
- public func getMiniRuntime() -> bridge.Result_UnistylesNativeMiniRuntime_ {
268
+ public final func getMiniRuntime() -> bridge.Result_UnistylesNativeMiniRuntime_ {
269
269
  do {
270
270
  let __result = try self.__implementation.getMiniRuntime()
271
271
  let __resultCpp = __result
@@ -277,7 +277,7 @@ public class HybridNativePlatformSpec_cxx {
277
277
  }
278
278
 
279
279
  @inline(__always)
280
- public func registerPlatformListener(callback: bridge.Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime) -> bridge.Result_void_ {
280
+ public final func registerPlatformListener(callback: bridge.Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime) -> bridge.Result_void_ {
281
281
  do {
282
282
  try self.__implementation.registerPlatformListener(callback: { () -> ([UnistyleDependency], UnistylesNativeMiniRuntime) -> Void in
283
283
  let __wrappedFunction = bridge.wrap_Func_void_std__vector_UnistyleDependency__UnistylesNativeMiniRuntime(callback)
@@ -299,7 +299,7 @@ public class HybridNativePlatformSpec_cxx {
299
299
  }
300
300
 
301
301
  @inline(__always)
302
- public func registerImeListener(callback: bridge.Func_void_UnistylesNativeMiniRuntime) -> bridge.Result_void_ {
302
+ public final func registerImeListener(callback: bridge.Func_void_UnistylesNativeMiniRuntime) -> bridge.Result_void_ {
303
303
  do {
304
304
  try self.__implementation.registerImeListener(callback: { () -> (UnistylesNativeMiniRuntime) -> Void in
305
305
  let __wrappedFunction = bridge.wrap_Func_void_UnistylesNativeMiniRuntime(callback)
@@ -315,7 +315,7 @@ public class HybridNativePlatformSpec_cxx {
315
315
  }
316
316
 
317
317
  @inline(__always)
318
- public func unregisterPlatformListeners() -> bridge.Result_void_ {
318
+ public final func unregisterPlatformListeners() -> bridge.Result_void_ {
319
319
  do {
320
320
  try self.__implementation.unregisterPlatformListeners()
321
321
  return bridge.create_Result_void_()
@@ -42,7 +42,7 @@ namespace margelo::nitro {
42
42
 
43
43
  // C++ ColorScheme <> JS ColorScheme (union)
44
44
  template <>
45
- struct JSIConverter<ColorScheme> {
45
+ struct JSIConverter<ColorScheme> final {
46
46
  static inline ColorScheme fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
47
47
  std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
48
48
  switch (hashString(unionValue.c_str(), unionValue.size())) {
@@ -44,7 +44,7 @@ namespace margelo::nitro {
44
44
 
45
45
  // C++ Dimensions <> JS Dimensions (object)
46
46
  template <>
47
- struct JSIConverter<Dimensions> {
47
+ struct JSIConverter<Dimensions> final {
48
48
  static inline Dimensions fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
49
49
  jsi::Object obj = arg.asObject(runtime);
50
50
  return Dimensions(
@@ -59,7 +59,7 @@ namespace margelo::nitro::unistyles {
59
59
  explicit HybridNativePlatformSpec(): HybridObject(TAG) { }
60
60
 
61
61
  // Destructor
62
- virtual ~HybridNativePlatformSpec() { }
62
+ ~HybridNativePlatformSpec() override = default;
63
63
 
64
64
  public:
65
65
  // Properties
@@ -40,7 +40,7 @@ namespace margelo::nitro::unistyles {
40
40
  explicit HybridUnistylesNavigationBarSpec(): HybridObject(TAG) { }
41
41
 
42
42
  // Destructor
43
- virtual ~HybridUnistylesNavigationBarSpec() { }
43
+ ~HybridUnistylesNavigationBarSpec() override = default;
44
44
 
45
45
  public:
46
46
  // Properties
@@ -56,7 +56,7 @@ namespace margelo::nitro::unistyles {
56
56
  explicit HybridUnistylesRuntimeSpec(): HybridObject(TAG) { }
57
57
 
58
58
  // Destructor
59
- virtual ~HybridUnistylesRuntimeSpec() { }
59
+ ~HybridUnistylesRuntimeSpec() override = default;
60
60
 
61
61
  public:
62
62
  // Properties
@@ -40,7 +40,7 @@ namespace margelo::nitro::unistyles {
40
40
  explicit HybridUnistylesShadowRegistrySpec(): HybridObject(TAG) { }
41
41
 
42
42
  // Destructor
43
- virtual ~HybridUnistylesShadowRegistrySpec() { }
43
+ ~HybridUnistylesShadowRegistrySpec() override = default;
44
44
 
45
45
  public:
46
46
  // Properties
@@ -40,7 +40,7 @@ namespace margelo::nitro::unistyles {
40
40
  explicit HybridUnistylesStatusBarSpec(): HybridObject(TAG) { }
41
41
 
42
42
  // Destructor
43
- virtual ~HybridUnistylesStatusBarSpec() { }
43
+ ~HybridUnistylesStatusBarSpec() override = default;
44
44
 
45
45
  public:
46
46
  // Properties
@@ -43,7 +43,7 @@ namespace margelo::nitro::unistyles {
43
43
  explicit HybridUnistylesStyleSheetSpec(): HybridObject(TAG) { }
44
44
 
45
45
  // Destructor
46
- virtual ~HybridUnistylesStyleSheetSpec() { }
46
+ ~HybridUnistylesStyleSheetSpec() override = default;
47
47
 
48
48
  public:
49
49
  // Properties
@@ -47,7 +47,7 @@ namespace margelo::nitro {
47
47
 
48
48
  // C++ Insets <> JS Insets (object)
49
49
  template <>
50
- struct JSIConverter<Insets> {
50
+ struct JSIConverter<Insets> final {
51
51
  static inline Insets fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
52
52
  jsi::Object obj = arg.asObject(runtime);
53
53
  return Insets(
@@ -41,7 +41,7 @@ namespace margelo::nitro {
41
41
 
42
42
  // C++ Orientation <> JS Orientation (union)
43
43
  template <>
44
- struct JSIConverter<Orientation> {
44
+ struct JSIConverter<Orientation> final {
45
45
  static inline Orientation fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
46
46
  std::string unionValue = JSIConverter<std::string>::fromJSI(runtime, arg);
47
47
  switch (hashString(unionValue.c_str(), unionValue.size())) {
@@ -50,7 +50,7 @@ namespace margelo::nitro {
50
50
 
51
51
  // C++ UnistyleDependency <> JS UnistyleDependency (enum)
52
52
  template <>
53
- struct JSIConverter<UnistyleDependency> {
53
+ struct JSIConverter<UnistyleDependency> final {
54
54
  static inline UnistyleDependency fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
55
55
  int enumValue = JSIConverter<int>::fromJSI(runtime, arg);
56
56
  return static_cast<UnistyleDependency>(enumValue);
@@ -65,7 +65,7 @@ namespace margelo::nitro {
65
65
 
66
66
  // C++ UnistylesCxxMiniRuntime <> JS UnistylesCxxMiniRuntime (object)
67
67
  template <>
68
- struct JSIConverter<UnistylesCxxMiniRuntime> {
68
+ struct JSIConverter<UnistylesCxxMiniRuntime> final {
69
69
  static inline UnistylesCxxMiniRuntime fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
70
70
  jsi::Object obj = arg.asObject(runtime);
71
71
  return UnistylesCxxMiniRuntime(
@@ -61,7 +61,7 @@ namespace margelo::nitro {
61
61
 
62
62
  // C++ UnistylesNativeMiniRuntime <> JS UnistylesNativeMiniRuntime (object)
63
63
  template <>
64
- struct JSIConverter<UnistylesNativeMiniRuntime> {
64
+ struct JSIConverter<UnistylesNativeMiniRuntime> final {
65
65
  static inline UnistylesNativeMiniRuntime fromJSI(jsi::Runtime& runtime, const jsi::Value& arg) {
66
66
  jsi::Object obj = arg.asObject(runtime);
67
67
  return UnistylesNativeMiniRuntime(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-nightly-20250208",
3
+ "version": "3.0.0-nightly-20250213",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -98,11 +98,11 @@
98
98
  "husky": "9.1.7",
99
99
  "jest": "29.7.0",
100
100
  "metro-react-native-babel-preset": "0.77.0",
101
- "nitro-codegen": "0.21.0",
101
+ "nitro-codegen": "0.22.1",
102
102
  "react": "18.3.1",
103
103
  "react-native": "0.77.0",
104
104
  "react-native-builder-bob": "0.33.1",
105
- "react-native-nitro-modules": "0.21.0",
105
+ "react-native-nitro-modules": "0.22.1",
106
106
  "react-native-web": "0.19.13",
107
107
  "react-test-renderer": "18.3.1",
108
108
  "release-it": "17.6.0",
package/plugin/import.js CHANGED
@@ -31,7 +31,7 @@ function addUnistylesImport(t, path, state) {
31
31
  const newImport = t.importDeclaration(
32
32
  [t.importSpecifier(t.identifier(localName), t.identifier(name))],
33
33
  t.stringLiteral(state.opts.isLocal
34
- ? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${name}`)
34
+ ? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/src/components/native/${name}`)
35
35
  : `react-native-unistyles/components/native/${name}`
36
36
  )
37
37
  )
package/plugin/index.js CHANGED
@@ -159,7 +159,7 @@ module.exports = function ({ types: t }) {
159
159
  if (detectedDependencies) {
160
160
  if (t.isObjectExpression(arg)) {
161
161
  arg.properties.forEach(property => {
162
- if (detectedDependencies[property.key.name]) {
162
+ if (detectedDependencies.hasOwnProperty(property.key.name)) {
163
163
  addDependencies(t, state, property.key.name, property, detectedDependencies[property.key.name])
164
164
  }
165
165
  })
@@ -179,7 +179,7 @@ module.exports = function ({ types: t }) {
179
179
  // Ensure the function body returns an object
180
180
  if (t.isObjectExpression(body)) {
181
181
  body.properties.forEach(property => {
182
- if (detectedDependencies[property.key.name]) {
182
+ if (detectedDependencies.hasOwnProperty(property.key.name)) {
183
183
  addDependencies(t, state, property.key.name, property, detectedDependencies[property.key.name])
184
184
  }
185
185
  })
@@ -153,7 +153,7 @@ function getStylesDependenciesFromObject(t, path) {
153
153
  ...acc,
154
154
  [key]: [label]
155
155
  }
156
- }, [])
156
+ }, {})
157
157
  }
158
158
 
159
159
  function getStylesDependenciesFromFunction(t, path) {
@@ -415,7 +415,7 @@ function getStylesDependenciesFromFunction(t, path) {
415
415
  ...acc,
416
416
  [key]: [label]
417
417
  }
418
- }, [])
418
+ }, {})
419
419
  }
420
420
 
421
421
  function toUnistylesDependency(dependency) {
@@ -11,7 +11,7 @@ type PressableProps = Props & {
11
11
  const getStyles = (styleProps: Record<string, any> = {}) => {
12
12
  const unistyleKey = Object
13
13
  .keys(styleProps)
14
- .find(key => key.startsWith('unistyles-'))
14
+ .find(key => key.startsWith('unistyles_'))
15
15
 
16
16
  if (!unistyleKey) {
17
17
  return styleProps
@@ -40,10 +40,18 @@ export const Pressable = forwardRef<View, PressableProps>(({ variants, style, ..
40
40
  <NativePressableReactNative
41
41
  {...props}
42
42
  ref={ref => {
43
+ const isPropStyleAFunction = typeof style === 'function'
44
+ const unistyles = isPropStyleAFunction
45
+ ? style.call(style, { pressed: false })
46
+ : getStyles(style as unknown as Record<string, any>)
47
+
43
48
  if (ref) {
44
49
  storedRef.current = ref
45
50
  }
46
51
 
52
+ // @ts-expect-error - this is hidden from TS
53
+ UnistylesShadowRegistry.add(storedRef.current, unistyles)
54
+
47
55
  return passForwardedRef(props, ref, forwardedRef)
48
56
  }}
49
57
  style={state => {
@@ -26,8 +26,8 @@ const RTDependencyMap = {
26
26
  themeName: UnistyleDependency.ThemeName,
27
27
  } satisfies Partial<Record<keyof UnistylesMiniRuntime, UnistyleDependency>>
28
28
 
29
- export const useProxifiedUnistyles = () => {
30
- const scopedTheme = UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
29
+ export const useProxifiedUnistyles = (forcedTheme?: UnistylesTheme) => {
30
+ const scopedTheme = forcedTheme ?? UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme
31
31
  const [dependencies] = useState(() => new Set<number>())
32
32
  const [theme, setTheme] = useState(UnistylesRuntime.getTheme(scopedTheme))
33
33
  const [_, runtimeChanged] = useReducer(() => ({}), {})
package/src/core/warn.ts CHANGED
@@ -4,7 +4,7 @@ export const maybeWarnAboutMultipleUnistyles = (style: ViewStyle, displayName =
4
4
  if (__DEV__ && style && !Array.isArray(style)) {
5
5
  const unistylesKeys = Object
6
6
  .keys(style)
7
- .filter(key => key.startsWith('unistyles-'))
7
+ .filter(key => key.startsWith('unistyles_'))
8
8
 
9
9
  if (unistylesKeys.length > 1) {
10
10
  console.warn(`Unistyles: we detected style object with ${unistylesKeys.length} unistyles styles. This might cause no updates or unpredictable behavior. Please check style prop for "${displayName}" and use array syntax instead of object syntax.`)
@@ -1,5 +1,6 @@
1
- import React, { forwardRef, useEffect, type ComponentType } from 'react'
2
- import type { UnistyleDependency } from '../../specs'
1
+ import React, { forwardRef, useEffect, type ComponentType, useRef } from 'react'
2
+ import { type UnistyleDependency, UnistylesShadowRegistry } from '../../specs'
3
+ import type { UnistylesTheme } from '../../types'
3
4
  import type { PartialBy } from '../../types/common'
4
5
  import { deepMergeObjects } from '../../utils'
5
6
  import { useProxifiedUnistyles } from '../useProxifiedUnistyles'
@@ -19,7 +20,7 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
19
20
  const getSecrets = (styleProps: Record<string, any> = {}): { uni__getStyles(): any, uni__dependencies: Array<UnistyleDependency> } => {
20
21
  const unistyleKey = Object
21
22
  .keys(styleProps)
22
- .find(key => key.startsWith('unistyles-'))
23
+ .find(key => key.startsWith('unistyles_'))
23
24
 
24
25
  return unistyleKey
25
26
  ? styleProps[unistyleKey]
@@ -38,7 +39,8 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
38
39
  // @ts-ignore we don't know the type of the component
39
40
  maybeWarnAboutMultipleUnistyles(narrowedProps.contentContainerStyle, `withUnistyles(${Component.displayName ?? Component.name ?? 'Unknown'})`)
40
41
 
41
- const { proxifiedRuntime, proxifiedTheme, addDependencies } = useProxifiedUnistyles()
42
+ const scopedTheme = useRef(UnistylesShadowRegistry.getScopedTheme() as UnistylesTheme)
43
+ const { proxifiedRuntime, proxifiedTheme, addDependencies } = useProxifiedUnistyles(scopedTheme.current)
42
44
 
43
45
  useEffect(() => {
44
46
  const styleSecrets = getSecrets(narrowedProps.style)
@@ -37,7 +37,7 @@ export const withUnistyles = <TComponent, TMappings extends GenericComponentProp
37
37
  style: styleClassNames,
38
38
  } : {},
39
39
  ...narrowedProps.contentContainerStyle ? {
40
- style: contentContainerStyleClassNames,
40
+ contentContainerStyle: contentContainerStyleClassNames,
41
41
  } : {},
42
42
  } as any
43
43
 
@@ -17,7 +17,7 @@ export const convertUnistyles = (value: UnistylesValues) => {
17
17
  ...value._web
18
18
  }).flatMap(([unistylesKey, unistylesValue]) => {
19
19
  // Keys to omit
20
- if (['_classNames', '_web', 'variants', 'compoundVariants', 'uni__dependencies', '__unistyles-secrets__'].includes(unistylesKey) || unistylesKey.startsWith('variant-')) {
20
+ if (['_classNames', '_web', 'variants', 'compoundVariants', 'uni__dependencies'].includes(unistylesKey) || unistylesKey.startsWith('unistyles_')) {
21
21
  return []
22
22
  }
23
23
 
@@ -65,5 +65,5 @@ const cyrb53 = (data: string, seed = 0) => {
65
65
  export const generateHash = (value: any) => {
66
66
  const serialized = serialize(value)
67
67
 
68
- return `unistyles-${cyrb53(serialized).toString(36)}`
68
+ return `unistyles_${cyrb53(serialized).toString(36)}`
69
69
  }
@@ -27,9 +27,9 @@ export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
27
27
  const secretsId = Math.random().toString(36).slice(8)
28
28
 
29
29
  // @ts-expect-error assign hidden secrets
30
- object[`unistyles-${secretsId}`] = {}
30
+ object[`unistyles_${secretsId}`] = {}
31
31
  // @ts-expect-error assign hidden secrets
32
- Object.defineProperties(object[`unistyles-${secretsId}`], reduceObject(secrets, secret => ({
32
+ Object.defineProperties(object[`unistyles_${secretsId}`], reduceObject(secrets, secret => ({
33
33
  value: secret,
34
34
  enumerable: false,
35
35
  configurable: true
@@ -43,7 +43,7 @@ export const extractSecrets = (object: any) => {
43
43
  return undefined
44
44
  }
45
45
 
46
- const [, secrets] = Object.entries(object).find(([key]) => key.startsWith('unistyles-')) ?? []
46
+ const [, secrets] = Object.entries(object).find(([key]) => key.startsWith('unistyles_')) ?? []
47
47
 
48
48
  if (!secrets) {
49
49
  return undefined