react-native-unistyles 3.0.0-beta.5 → 3.0.0-beta.6

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 (156) 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/android/src/main/java/com/unistyles/UnistylesPackage.kt +6 -6
  8. package/components/native/Animated/package.json +5 -0
  9. package/components/native/NativeText/package.json +5 -0
  10. package/components/native/NativeView/package.json +5 -0
  11. package/cxx/core/Unistyle.h +4 -0
  12. package/cxx/core/UnistylesRegistry.cpp +24 -3
  13. package/cxx/core/UnistylesRegistry.h +3 -0
  14. package/cxx/hybridObjects/HybridShadowRegistry.cpp +7 -0
  15. package/cxx/hybridObjects/HybridStyleSheet.cpp +27 -2
  16. package/cxx/parser/Parser.cpp +9 -3
  17. package/ios/NativePlatform+ios.swift +16 -4
  18. package/ios/UnistylesModuleOnLoad.h +4 -4
  19. package/ios/UnistylesModuleOnLoad.mm +4 -8
  20. package/lib/commonjs/components/native/Animated.js +23 -0
  21. package/lib/commonjs/components/native/Animated.js.map +1 -0
  22. package/lib/commonjs/components/native/ImageBackground.js +3 -1
  23. package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
  24. package/lib/commonjs/components/native/NativeText.js +13 -0
  25. package/lib/commonjs/components/native/NativeText.js.map +1 -0
  26. package/lib/commonjs/components/native/NativeText.native.js +18 -0
  27. package/lib/commonjs/components/native/NativeText.native.js.map +1 -0
  28. package/lib/commonjs/components/native/NativeView.js +9 -0
  29. package/lib/commonjs/components/native/NativeView.js.map +1 -0
  30. package/lib/commonjs/components/native/NativeView.native.js +20 -0
  31. package/lib/commonjs/components/native/NativeView.native.js.map +1 -0
  32. package/lib/commonjs/components/native/Pressable.native.js +16 -3
  33. package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
  34. package/lib/commonjs/core/createUnistylesElement.js +26 -22
  35. package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
  36. package/lib/commonjs/core/createUnistylesElement.native.js +37 -23
  37. package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
  38. package/lib/commonjs/core/createUnistylesImageBackground.js +34 -30
  39. package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
  40. package/lib/commonjs/core/getClassname.js +1 -3
  41. package/lib/commonjs/core/getClassname.js.map +1 -1
  42. package/lib/commonjs/server/getServerUnistyles.js +3 -1
  43. package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
  44. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  45. package/lib/commonjs/utils.js +16 -1
  46. package/lib/commonjs/utils.js.map +1 -1
  47. package/lib/commonjs/web/utils/unistyle.js +5 -1
  48. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  49. package/lib/module/components/native/Animated.js +19 -0
  50. package/lib/module/components/native/Animated.js.map +1 -0
  51. package/lib/module/components/native/ImageBackground.js +3 -1
  52. package/lib/module/components/native/ImageBackground.js.map +1 -1
  53. package/lib/module/components/native/NativeText.js +4 -0
  54. package/lib/module/components/native/NativeText.js.map +1 -0
  55. package/lib/module/components/native/NativeText.native.js +15 -0
  56. package/lib/module/components/native/NativeText.native.js.map +1 -0
  57. package/lib/module/components/native/NativeView.js +5 -0
  58. package/lib/module/components/native/NativeView.js.map +1 -0
  59. package/lib/module/components/native/NativeView.native.js +17 -0
  60. package/lib/module/components/native/NativeView.native.js.map +1 -0
  61. package/lib/module/components/native/Pressable.native.js +17 -4
  62. package/lib/module/components/native/Pressable.native.js.map +1 -1
  63. package/lib/module/core/createUnistylesElement.js +26 -22
  64. package/lib/module/core/createUnistylesElement.js.map +1 -1
  65. package/lib/module/core/createUnistylesElement.native.js +38 -24
  66. package/lib/module/core/createUnistylesElement.native.js.map +1 -1
  67. package/lib/module/core/createUnistylesImageBackground.js +35 -31
  68. package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
  69. package/lib/module/core/getClassname.js +2 -4
  70. package/lib/module/core/getClassname.js.map +1 -1
  71. package/lib/module/server/getServerUnistyles.js +3 -1
  72. package/lib/module/server/getServerUnistyles.js.map +1 -1
  73. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  74. package/lib/module/utils.js +14 -0
  75. package/lib/module/utils.js.map +1 -1
  76. package/lib/module/web/utils/unistyle.js +5 -1
  77. package/lib/module/web/utils/unistyle.js.map +1 -1
  78. package/lib/typescript/src/components/native/ActivityIndicator.d.ts +1 -3
  79. package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
  80. package/lib/typescript/src/components/native/Animated.d.ts +39 -0
  81. package/lib/typescript/src/components/native/Animated.d.ts.map +1 -0
  82. package/lib/typescript/src/components/native/FlatList.d.ts +1 -3
  83. package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
  84. package/lib/typescript/src/components/native/Image.d.ts +1 -3
  85. package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
  86. package/lib/typescript/src/components/native/ImageBackground.d.ts +1 -8
  87. package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
  88. package/lib/typescript/src/components/native/ImageBackground.native.d.ts +1 -2
  89. package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
  90. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +1 -3
  91. package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
  92. package/lib/typescript/src/components/native/NativeText.d.ts +2 -0
  93. package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -0
  94. package/lib/typescript/src/components/native/NativeText.native.d.ts +2 -0
  95. package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -0
  96. package/lib/typescript/src/components/native/NativeView.d.ts +3 -0
  97. package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -0
  98. package/lib/typescript/src/components/native/NativeView.native.d.ts +3 -0
  99. package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -0
  100. package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
  101. package/lib/typescript/src/components/native/RefreshControl.d.ts +1 -3
  102. package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
  103. package/lib/typescript/src/components/native/ScrollView.d.ts +1 -3
  104. package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
  105. package/lib/typescript/src/components/native/SectionList.d.ts +1 -3
  106. package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
  107. package/lib/typescript/src/components/native/Switch.d.ts +1 -3
  108. package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
  109. package/lib/typescript/src/components/native/Text.d.ts +1 -3
  110. package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
  111. package/lib/typescript/src/components/native/TextInput.d.ts +1 -3
  112. package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
  113. package/lib/typescript/src/components/native/TouchableHighlight.d.ts +1 -3
  114. package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
  115. package/lib/typescript/src/components/native/TouchableOpacity.d.ts +1 -3
  116. package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
  117. package/lib/typescript/src/components/native/View.d.ts +1 -3
  118. package/lib/typescript/src/components/native/View.d.ts.map +1 -1
  119. package/lib/typescript/src/components/native/VirtualizedList.d.ts +1 -3
  120. package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
  121. package/lib/typescript/src/core/createUnistylesElement.d.ts +1 -7
  122. package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
  123. package/lib/typescript/src/core/createUnistylesElement.native.d.ts +1 -2
  124. package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
  125. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +2 -3
  126. package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
  127. package/lib/typescript/src/core/getClassname.d.ts +2 -2
  128. package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
  129. package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
  130. package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -0
  131. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  132. package/lib/typescript/src/utils.d.ts +1 -0
  133. package/lib/typescript/src/utils.d.ts.map +1 -1
  134. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  135. package/package.json +11 -9
  136. package/plugin/consts.js +63 -0
  137. package/plugin/exotic.js +54 -0
  138. package/plugin/index.d.ts +84 -36
  139. package/plugin/index.js +27 -33
  140. package/plugin/stylesheet.js +12 -1
  141. package/plugin/variants.js +1 -1
  142. package/src/components/native/Animated.tsx +17 -0
  143. package/src/components/native/ImageBackground.tsx +4 -1
  144. package/src/components/native/NativeText.native.tsx +12 -0
  145. package/src/components/native/NativeText.tsx +1 -0
  146. package/src/components/native/NativeView.native.tsx +13 -0
  147. package/src/components/native/NativeView.tsx +3 -0
  148. package/src/components/native/Pressable.native.tsx +22 -4
  149. package/src/core/createUnistylesElement.native.tsx +42 -27
  150. package/src/core/createUnistylesElement.tsx +34 -29
  151. package/src/core/createUnistylesImageBackground.tsx +39 -34
  152. package/src/core/getClassname.ts +5 -4
  153. package/src/server/getServerUnistyles.tsx +2 -1
  154. package/src/specs/StyleSheet/index.ts +2 -1
  155. package/src/utils.ts +17 -0
  156. package/src/web/utils/unistyle.ts +7 -1
package/README.md CHANGED
@@ -47,6 +47,9 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
47
47
  <a href="https://galaxies.dev">
48
48
  <img src="https://avatars.githubusercontent.com/u/118431096?s=200&v=4" height="70px" width="70px" alt="galaxies-dev" />
49
49
  </a>
50
+ <a href="https://github.com/FTCHD">
51
+ <img src="https://avatars.githubusercontent.com/u/144691102?v=4" height="70px" width="70px" alt="FTCHD" />
52
+ </a>
50
53
  <a href="https://github.com/mobily">
51
54
  <img src="https://avatars.githubusercontent.com/u/1467712?v=4" height="70px" width="70px" alt="mobily" />
52
55
  </a>
@@ -62,8 +65,14 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
62
65
  <a href="https://github.com/oscklm">
63
66
  <img src="https://avatars.githubusercontent.com/u/22825865?v=4" height="70px" width="70px" alt="oscklm" />
64
67
  </a>
65
- <a href="https://github.com/giovannilondero">
66
- <img src="https://avatars.githubusercontent.com/u/10998991?v=4" height="70px" width="70px" alt="giovannilondero" />
68
+ <a href="https://github.com/guillaumehcht">
69
+ <img src="https://avatars.githubusercontent.com/u/80776475?v=4" height="70px" width="70px" alt="guillaumehcht" />
70
+ </a>
71
+ <a href="https://github.com/FilipiRafael">
72
+ <img src="https://avatars.githubusercontent.com/u/61629642?v=4" height="70px" width="70px" alt="FilipiRafael" />
73
+ </a>
74
+ <a href="https://github.com/4cc3ssX">
75
+ <img src="https://avatars.githubusercontent.com/u/57473799?v=4" height="70px" width="70px" alt="4cc3ssX" />
67
76
  </a>
68
77
 
69
78
  ## Past sponsors
@@ -89,6 +98,9 @@ Then follow [installation guides](https://unistyl.es/v3/start/getting-started) f
89
98
  <a href="https://github.com/hyoban">
90
99
  <img src="https://avatars.githubusercontent.com/u/38493346?v=4" height="70px" width="70px" alt="hyoban" />
91
100
  </a>
101
+ <a href="https://github.com/giovannilondero">
102
+ <img src="https://avatars.githubusercontent.com/u/10998991?v=4" height="70px" width="70px" alt="giovannilondero" />
103
+ </a>
92
104
 
93
105
  ## Sponsor my work
94
106
 
@@ -37,7 +37,7 @@ jni::local_ref<BindingsInstallerHolder::javaobject> UnistylesModule::getBindings
37
37
  auto& uiManager = jobj->cthis()->_uiManager;
38
38
  auto& nativePlatform = jobj->cthis()->_nativePlatform;
39
39
 
40
- return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, uiManager, nativePlatform](jsi::Runtime& rt) {
40
+ return BindingsInstallerHolder::newObjectCxxArgs([&runtimeExecutor, &uiManager, &nativePlatform](jsi::Runtime& rt) {
41
41
  // function is called on: first init and every live reload
42
42
  // check if this is live reload, if so let's replace UnistylesRuntime with new runtime
43
43
  auto hasUnistylesRuntime = HybridObjectRegistry::hasHybridObject("UnistylesRuntime");
@@ -32,9 +32,8 @@ class NativePlatformAndroid(private val reactContext: ReactApplicationContext):
32
32
  reactContext.addLifecycleEventListener(this)
33
33
  }
34
34
 
35
- fun invalidate() {
35
+ fun onDestroy() {
36
36
  reactContext.removeLifecycleEventListener(this)
37
- _listener.invalidate()
38
37
  }
39
38
 
40
39
  override fun onHostResume() {
@@ -23,6 +23,10 @@ class NativePlatformInsets(
23
23
  private val _imeListeners: MutableList<CxxImeListener> = mutableListOf()
24
24
  private var _insets: Insets = Insets(0.0, 0.0, 0.0, 0.0, 0.0)
25
25
 
26
+ fun onDestroy() {
27
+ this.removeImeListeners()
28
+ }
29
+
26
30
  fun getInsets(): Insets {
27
31
  val density = reactContext.resources.displayMetrics.density
28
32
 
@@ -31,7 +31,8 @@ class NativePlatformListener(
31
31
  reactContext.registerReceiver(configurationChangeReceiver, IntentFilter(Intent.ACTION_CONFIGURATION_CHANGED))
32
32
  }
33
33
 
34
- fun invalidate() {
34
+ fun onDestroy() {
35
+ this.removePlatformListeners()
35
36
  reactContext.unregisterReceiver(configurationChangeReceiver)
36
37
  }
37
38
 
@@ -26,10 +26,6 @@ class UnistylesModule(reactContext: ReactApplicationContext): NativeTurboUnistyl
26
26
  mHybridData = initializeHybridData(reactContext)
27
27
  }
28
28
 
29
- override fun invalidate() {
30
- _nativePlatform.invalidate()
31
- }
32
-
33
29
  private fun initializeHybridData(reactContext: ReactApplicationContext): HybridData {
34
30
  val runtimeExecutor = reactContext.catalystInstance?.runtimeExecutor
35
31
  ?: throw IllegalStateException("Unistyles: React Native runtime executor is not available. Please follow installation guides.")
@@ -1,12 +1,12 @@
1
1
  package com.unistyles
2
2
 
3
- import com.facebook.react.TurboReactPackage
3
+ import com.facebook.react.BaseReactPackage
4
4
  import com.facebook.react.bridge.NativeModule
5
5
  import com.facebook.react.bridge.ReactApplicationContext
6
6
  import com.facebook.react.module.model.ReactModuleInfo
7
7
  import com.facebook.react.module.model.ReactModuleInfoProvider
8
8
 
9
- class UnistylesPackage: TurboReactPackage() {
9
+ class UnistylesPackage: BaseReactPackage() {
10
10
  override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
11
11
  return if (name == UnistylesModule.NAME) {
12
12
  UnistylesModule(reactContext)
@@ -20,10 +20,10 @@ class UnistylesPackage: TurboReactPackage() {
20
20
  mapOf(UnistylesModule.NAME to ReactModuleInfo(
21
21
  UnistylesModule.NAME,
22
22
  UnistylesModule.NAME,
23
- _canOverrideExistingModule = true,
24
- _needsEagerInit = true,
25
- isCxxModule = true,
26
- isTurboModule = true
23
+ true,
24
+ true,
25
+ true,
26
+ true
27
27
  ))
28
28
  }
29
29
  }
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../../lib/commonjs/components/native/Animated.js",
3
+ "module": "../../../lib/module/components/native/Animated.js",
4
+ "react-native": "../../../src/components/native/Animated.tsx"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../../lib/commonjs/components/native/NativeText.js",
3
+ "module": "../../../lib/module/components/native/NativeText.js",
4
+ "react-native": "../../../src/components/native/NativeText.native.tsx"
5
+ }
@@ -0,0 +1,5 @@
1
+ {
2
+ "main": "../../../lib/commonjs/components/native/NativeView.js",
3
+ "module": "../../../lib/module/components/native/NativeView.js",
4
+ "react-native": "../../../src/components/native/NativeView.native.tsx"
5
+ }
@@ -54,6 +54,10 @@ struct Unistyle {
54
54
  inline bool dependsOn(UnistyleDependency dependency) {
55
55
  return std::find(this->dependencies.begin(), this->dependencies.end(), dependency) != this->dependencies.end();
56
56
  }
57
+
58
+ inline bool isSealed() {
59
+ return this->_isSealed;
60
+ }
57
61
 
58
62
  inline void seal() {
59
63
  this->_isSealed = true;
@@ -86,6 +86,27 @@ void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
86
86
  this->trafficController.resumeUnistylesTraffic();
87
87
  }
88
88
 
89
+ void core::UnistylesRegistry::removeDuplicatedUnistyles(jsi::Runtime& rt, const ShadowNodeFamily *shadowNodeFamily, std::vector<core::Unistyle::Shared>& unistyles) {
90
+ auto targetFamilyUnistyles = this->_shadowRegistry[&rt][shadowNodeFamily];
91
+
92
+ unistyles.erase(
93
+ std::remove_if(
94
+ unistyles.begin(),
95
+ unistyles.end(),
96
+ [&targetFamilyUnistyles](const core::Unistyle::Shared& unistyle) {
97
+ return std::any_of(
98
+ targetFamilyUnistyles.begin(),
99
+ targetFamilyUnistyles.end(),
100
+ [&unistyle](const std::shared_ptr<core::UnistyleData>& data) {
101
+ return data->unistyle == unistyle;
102
+ }
103
+ );
104
+ }
105
+ ),
106
+ unistyles.end()
107
+ );
108
+ }
109
+
89
110
  void core::UnistylesRegistry::unlinkShadowNodeWithUnistyles(jsi::Runtime& rt, const ShadowNodeFamily* shadowNodeFamily) {
90
111
  this->_shadowRegistry[&rt].erase(shadowNodeFamily);
91
112
  this->trafficController.removeShadowNode(shadowNodeFamily);
@@ -201,16 +222,16 @@ std::vector<std::shared_ptr<core::StyleSheet>> core::UnistylesRegistry::getStyle
201
222
  core::Unistyle::Shared core::UnistylesRegistry::getUnistyleById(jsi::Runtime& rt, std::string unistyleID) {
202
223
  for (auto& pair: this->_styleSheetRegistry[&rt]) {
203
224
  auto [_, stylesheet] = pair;
204
-
225
+
205
226
  for (auto unistylePair: stylesheet->unistyles) {
206
227
  auto [_, unistyle] = unistylePair;
207
-
228
+
208
229
  if (unistyle->unid == unistyleID) {
209
230
  return unistyle;
210
231
  }
211
232
  }
212
233
  }
213
-
234
+
214
235
  return nullptr;
215
236
  }
216
237
 
@@ -27,6 +27,8 @@ struct UnistylesRegistry: public StyleSheetRegistry {
27
27
 
28
28
  UnistylesRegistry(const UnistylesRegistry&) = delete;
29
29
  UnistylesRegistry(const UnistylesRegistry&&) = delete;
30
+
31
+ bool shouldUsePointsForBreakpoints = false;
30
32
 
31
33
  void registerTheme(jsi::Runtime& rt, std::string name, jsi::Value& theme);
32
34
  void registerBreakpoints(jsi::Runtime& rt, std::vector<std::pair<std::string, double>>& sortedBreakpoints);
@@ -44,6 +46,7 @@ struct UnistylesRegistry: public StyleSheetRegistry {
44
46
  void shadowLeafUpdateFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Value& maybePressableId);
45
47
  shadow::ShadowTrafficController trafficController{};
46
48
  const std::optional<std::string> getScopedTheme();
49
+ void removeDuplicatedUnistyles(jsi::Runtime& rt, const ShadowNodeFamily* shadowNodeFamily, std::vector<core::Unistyle::Shared>& unistyles);
47
50
  void setScopedTheme(std::optional<std::string> themeName);
48
51
  core::Unistyle::Shared getUnistyleById(jsi::Runtime& rt, std::string unistyleID);
49
52
 
@@ -12,6 +12,13 @@ jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisVa
12
12
  std::vector<std::vector<folly::dynamic>> arguments;
13
13
  auto& registry = core::UnistylesRegistry::get();
14
14
 
15
+ // this is special case for Animated, and prevents appending same unistyles to node
16
+ registry.removeDuplicatedUnistyles(rt, &shadowNodeWrapper->getFamily(), unistyleWrappers);
17
+
18
+ if (unistyleWrappers.empty()) {
19
+ return jsi::Value::undefined();
20
+ }
21
+
15
22
  for (size_t i = 0; i < unistyleWrappers.size(); i++) {
16
23
  if (unistyleWrappers[i]->type == core::UnistyleType::DynamicFunction) {
17
24
  try {
@@ -127,6 +127,20 @@ void HybridStyleSheet::parseSettings(jsi::Runtime &rt, jsi::Object settings) {
127
127
  if (propertyName == "CSSVars") {
128
128
  return;
129
129
  }
130
+
131
+ if (propertyName == "nativeBreakpointsMode") {
132
+ helpers::assertThat(rt, propertyValue.isString(), "StyleSheet.configure's nativeBreakpointsMode must be a string");
133
+
134
+ auto mode = propertyValue.asString(rt).utf8(rt);
135
+
136
+ helpers::assertThat(rt, mode == "pixels" || mode == "points", "StyleSheet.configure's nativeBreakpointsMode must be one of: pixels or points");
137
+
138
+ if (mode == "points") {
139
+ registry.shouldUsePointsForBreakpoints = true;
140
+ }
141
+
142
+ return;
143
+ }
130
144
 
131
145
  helpers::assertThat(rt, false, "StyleSheet.configure's settings received unexpected key: '" + std::string(propertyName) + "'");
132
146
  });
@@ -142,7 +156,13 @@ void HybridStyleSheet::parseBreakpoints(jsi::Runtime &rt, jsi::Object breakpoint
142
156
  auto& state = registry.getState(rt);
143
157
 
144
158
  registry.registerBreakpoints(rt, sortedBreakpoints);
145
- state.computeCurrentBreakpoint(this->_unistylesRuntime->getScreen().width);
159
+
160
+ auto rawWidth = this->_unistylesRuntime->getScreen().width;
161
+ auto width = registry.shouldUsePointsForBreakpoints
162
+ ? rawWidth / this->_unistylesRuntime->getPixelRatio()
163
+ : rawWidth;
164
+
165
+ state.computeCurrentBreakpoint(width);
146
166
  }
147
167
 
148
168
  void HybridStyleSheet::parseThemes(jsi::Runtime &rt, jsi::Object themes) {
@@ -293,7 +313,12 @@ void HybridStyleSheet::onPlatformNativeDependenciesChange(std::vector<UnistyleDe
293
313
  auto dimensionsIt = std::find(dependencies.begin(), dependencies.end(), UnistyleDependency::DIMENSIONS);
294
314
 
295
315
  if (dimensionsIt != dependencies.end()) {
296
- registry.getState(rt).computeCurrentBreakpoint(this->_unistylesRuntime->getScreen().width);
316
+ auto rawWidth = this->_unistylesRuntime->getScreen().width;
317
+ auto width = registry.shouldUsePointsForBreakpoints
318
+ ? rawWidth / this->_unistylesRuntime->getPixelRatio()
319
+ : rawWidth;
320
+
321
+ registry.getState(rt).computeCurrentBreakpoint(width);
297
322
  }
298
323
 
299
324
  // check if color scheme changed and then if Unistyles state depend on it (adaptive themes)
@@ -399,8 +399,10 @@ jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared u
399
399
 
400
400
  helpers::enumerateJSIObject(rt, style, [&](const std::string& propertyName, jsi::Value& propertyValue){
401
401
  // parse dependencies only once
402
- if (propertyName == helpers::STYLE_DEPENDENCIES && unistyle->dependencies.empty()) {
403
- unistyle->dependencies = this->parseDependencies(rt, propertyValue.asObject(rt));
402
+ if (propertyName == helpers::STYLE_DEPENDENCIES && !unistyle->isSealed()) {
403
+ auto newDeps = this->parseDependencies(rt, propertyValue.asObject(rt));
404
+
405
+ unistyle->dependencies.insert(unistyle->dependencies.end(), newDeps.begin(), newDeps.end());
404
406
 
405
407
  return;
406
408
  }
@@ -651,7 +653,11 @@ jsi::Value parser::Parser::getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::S
651
653
  auto sortedBreakpoints = state.getSortedBreakpointPairs();
652
654
  auto hasBreakpoints = !sortedBreakpoints.empty();
653
655
  auto currentBreakpoint = state.getCurrentBreakpointName();
654
- auto dimensions = this->_unistylesRuntime->getScreen();
656
+ auto rawDimensions = this->_unistylesRuntime->getScreen();
657
+ auto pixelRatio = this->_unistylesRuntime->getPixelRatio();
658
+ auto dimensions = registry.shouldUsePointsForBreakpoints
659
+ ? Dimensions(rawDimensions.width / pixelRatio, rawDimensions.height / pixelRatio)
660
+ : rawDimensions;
655
661
  auto currentOrientation = dimensions.width > dimensions.height
656
662
  ? "landscape"
657
663
  : "portrait";
@@ -114,6 +114,12 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
114
114
  func getScreenDimensionsFn() -> Dimensions {
115
115
  guard let presentedViewController = RCTPresentedViewController(),
116
116
  let windowFrame = presentedViewController.view.window?.frame else {
117
+
118
+ // when user goes to background RCTPresentedViewController is not available, try to get last known value
119
+ if let cachedRuntime = self.miniRuntime, UIApplication.shared.applicationState == .background {
120
+ return cachedRuntime.screen;
121
+ }
122
+
117
123
  // this should never happen, but it's better to return zeros
118
124
  return Dimensions(width: 0, height: 0)
119
125
  }
@@ -137,10 +143,10 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
137
143
  let screenDimensions = getScreenDimensions()
138
144
 
139
145
  if (screenDimensions.width > screenDimensions.height) {
140
- return Orientation.landscape;
146
+ return Orientation.landscape
141
147
  }
142
148
 
143
- return Orientation.portrait;
149
+ return Orientation.portrait
144
150
  }
145
151
 
146
152
  func getContentSizeCategory() -> String {
@@ -268,8 +274,14 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
268
274
  func getPixelRatioFn() -> Double {
269
275
  guard let presentedViewController = RCTPresentedViewController(),
270
276
  let window = presentedViewController.view.window else {
277
+
278
+ // when user goes to background RCTPresentedViewController is not available, try to get last known value
279
+ if let cachedRuntime = self.miniRuntime, UIApplication.shared.applicationState == .background {
280
+ return cachedRuntime.pixelRatio;
281
+ }
282
+
271
283
  // this should never happen, but it's better to return default
272
- return 1;
284
+ return 1
273
285
  }
274
286
 
275
287
  return window.screen.scale
@@ -297,7 +309,7 @@ class NativeIOSPlatform: HybridNativePlatformSpec {
297
309
  }
298
310
 
299
311
  func getNavigationBarDimensions() -> Dimensions {
300
- return Dimensions(width: 0, height: 0);
312
+ return Dimensions(width: 0, height: 0)
301
313
  }
302
314
 
303
315
  func setStatusBarHidden(isHidden: Bool) throws {
@@ -8,12 +8,12 @@
8
8
  #import "TurboUnistyles/TurboUnistyles.h"
9
9
  #import <React/RCTSurfacePresenter.h>
10
10
  #import <React/RCTScheduler.h>
11
- #import <React/RCTRuntimeExecutorModule.h>
12
- #import <ReactCommon/RCTRuntimeExecutor.h>
11
+ #import <React/RCTCallInvoker.h>
12
+ #import <React/RCTCallInvokerModule.h>
13
13
  #import <ReactCommon/RCTTurboModuleWithJSIBindings.h>
14
14
 
15
- @interface UnistylesModule: RCTEventEmitter<NativeTurboUnistylesSpec>
15
+ @interface UnistylesModule: RCTEventEmitter<NativeTurboUnistylesSpec, RCTCallInvokerModule>
16
16
  @end
17
17
 
18
- @interface UnistylesModule()<RCTTurboModuleWithJSIBindings, RCTRuntimeExecutorModule>
18
+ @interface UnistylesModule()<RCTTurboModuleWithJSIBindings>
19
19
  @end
@@ -11,7 +11,7 @@ using namespace margelo::nitro;
11
11
  RCT_EXPORT_MODULE(Unistyles)
12
12
 
13
13
  __weak RCTSurfacePresenter* _surfacePresenter;
14
- @synthesize runtimeExecutor = _runtimeExecutor;
14
+ @synthesize callInvoker = _callInvoker;
15
15
 
16
16
  + (BOOL)requiresMainQueueSetup {
17
17
  return YES;
@@ -36,13 +36,9 @@ __weak RCTSurfacePresenter* _surfacePresenter;
36
36
  }
37
37
 
38
38
  - (void)createHybrids:(jsi::Runtime&)rt {
39
- auto runOnJSThread = ([executor = _runtimeExecutor](std::function<void(jsi::Runtime& rt)> &&callback) {
40
- __block auto objcCallback = callback;
41
-
42
- [executor execute:^(jsi::Runtime& rt){
43
- objcCallback(rt);
44
- }];
45
- });
39
+ auto runOnJSThread = [callInvoker = _callInvoker.callInvoker](std::function<void(jsi::Runtime& rt)> &&callback){
40
+ callInvoker->invokeAsync(std::move(callback));
41
+ };
46
42
 
47
43
  auto nativePlatform = Unistyles::NativePlatform::create().getCxxPart();
48
44
  auto unistylesRuntime = std::make_shared<HybridUnistylesRuntime>(nativePlatform, rt, runOnJSThread);
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.Animated = void 0;
7
+ var _reactNative = require("react-native");
8
+ var _View = require("./View");
9
+ var _Text = require("./Text");
10
+ var _FlatList = require("./FlatList");
11
+ var _Image = require("./Image");
12
+ var _ScrollView = require("./ScrollView");
13
+ var _SectionList = require("./SectionList");
14
+ const Animated = exports.Animated = {
15
+ ..._reactNative.Animated,
16
+ View: _reactNative.Animated.createAnimatedComponent(_View.View),
17
+ Text: _reactNative.Animated.createAnimatedComponent(_Text.Text),
18
+ FlatList: _reactNative.Animated.createAnimatedComponent(_FlatList.FlatList),
19
+ Image: _reactNative.Animated.createAnimatedComponent(_Image.Image),
20
+ ScrollView: _reactNative.Animated.createAnimatedComponent(_ScrollView.ScrollView),
21
+ SectionList: _reactNative.Animated.createAnimatedComponent(_SectionList.SectionList)
22
+ };
23
+ //# sourceMappingURL=Animated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNative","require","_View","_Text","_FlatList","_Image","_ScrollView","_SectionList","Animated","exports","RNAnimated","View","createAnimatedComponent","Text","FlatList","Image","ScrollView","SectionList"],"sourceRoot":"../../../../src","sources":["components/native/Animated.tsx"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAEO,MAAMO,QAAQ,GAAAC,OAAA,CAAAD,QAAA,GAAG;EACpB,GAAGE,qBAAU;EACbC,IAAI,EAAED,qBAAU,CAACE,uBAAuB,CAACD,UAAI,CAAC;EAC9CE,IAAI,EAAEH,qBAAU,CAACE,uBAAuB,CAACC,UAAI,CAAC;EAC9CC,QAAQ,EAAEJ,qBAAU,CAACE,uBAAuB,CAACE,kBAAQ,CAAC;EACtDC,KAAK,EAAEL,qBAAU,CAACE,uBAAuB,CAACG,YAAK,CAAC;EAChDC,UAAU,EAAEN,qBAAU,CAACE,uBAAuB,CAACI,sBAAU,CAAC;EAC1DC,WAAW,EAAEP,qBAAU,CAACE,uBAAuB,CAACK,wBAAW;AAC/D,CAAC","ignoreList":[]}
@@ -9,10 +9,11 @@ var _reactNative = require("react-native");
9
9
  var _core = require("../../core");
10
10
  var _utils = require("../../web/utils");
11
11
  var _web = require("../../web");
12
+ var _utils2 = require("../../utils");
12
13
  var _jsxRuntime = require("react/jsx-runtime");
13
14
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
15
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
- const ImageBackground = exports.ImageBackground = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
16
+ const UnistylesImageBackground = /*#__PURE__*/(0, _react.forwardRef)((props, forwardedRef) => {
16
17
  let storedRef = null;
17
18
  let storedImageRef = null;
18
19
  const styleClassNames = (0, _core.getClassName)(props.style);
@@ -51,4 +52,5 @@ const ImageBackground = exports.ImageBackground = /*#__PURE__*/(0, _react.forwar
51
52
  })
52
53
  );
53
54
  });
55
+ const ImageBackground = exports.ImageBackground = (0, _utils2.copyComponentProperties)(_reactNative.ImageBackground, UnistylesImageBackground);
54
56
  //# sourceMappingURL=ImageBackground.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_core","_utils","_web","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","ImageBackground","exports","forwardRef","props","forwardedRef","storedRef","storedImageRef","styleClassNames","getClassName","style","imageClassNames","imageStyle","jsx","ref","isServer","undefined","UnistylesShadowRegistry","remove","hash","add","current","imageRef"],"sourceRoot":"../../../../src","sources":["components/native/ImageBackground.tsx"],"mappings":"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","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_core","_utils","_web","_utils2","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","UnistylesImageBackground","forwardRef","props","forwardedRef","storedRef","storedImageRef","styleClassNames","getClassName","style","imageClassNames","imageStyle","jsx","ImageBackground","ref","isServer","undefined","UnistylesShadowRegistry","remove","hash","add","current","imageRef","exports","copyComponentProperties","NativeImageBackground"],"sourceRoot":"../../../../src","sources":["components/native/ImageBackground.tsx"],"mappings":"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","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "Text", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _Text.Text;
10
+ }
11
+ });
12
+ var _Text = require("./Text");
13
+ //# sourceMappingURL=NativeText.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_Text","require"],"sourceRoot":"../../../../src","sources":["components/native/NativeText.tsx"],"mappings":";;;;;;;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.NativeText = void 0;
7
+ var _react = require("react");
8
+ var _core = require("../../core");
9
+ // credits to @hirbod
10
+ const LeanText = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
11
+ return /*#__PURE__*/(0, _react.createElement)('RCTText', {
12
+ ...props,
13
+ ref
14
+ });
15
+ });
16
+ LeanText.displayName = 'RCTText';
17
+ const NativeText = exports.NativeText = (0, _core.createUnistylesElement)(LeanText);
18
+ //# sourceMappingURL=NativeText.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_core","LeanText","forwardRef","props","ref","createElement","displayName","NativeText","exports","createUnistylesElement"],"sourceRoot":"../../../../src","sources":["components/native/NativeText.native.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA;AACA,MAAME,QAAQ,gBAAG,IAAAC,iBAAU,EAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACxC,oBAAO,IAAAC,oBAAa,EAAC,SAAS,EAAE;IAAE,GAAGF,KAAK;IAAEC;EAAI,CAAC,CAAC;AACtD,CAAC,CAA6B;AAE9BH,QAAQ,CAACK,WAAW,GAAG,SAAS;AAEzB,MAAMC,UAAU,GAAAC,OAAA,CAAAD,UAAA,GAAG,IAAAE,4BAAsB,EAACR,QAAQ,CAAC","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _View = require("./View");
8
+ var _default = exports.default = _View.View;
9
+ //# sourceMappingURL=NativeView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_View","require","_default","exports","default","View"],"sourceRoot":"../../../../src","sources":["components/native/NativeView.tsx"],"mappings":";;;;;;AAAA,IAAAA,KAAA,GAAAC,OAAA;AAA6B,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEdC,UAAI","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = require("react");
8
+ var _core = require("../../core");
9
+ // credits to @hirbod
10
+ const LeanView = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
11
+ return /*#__PURE__*/(0, _react.createElement)('RCTView', {
12
+ ...props,
13
+ ref
14
+ });
15
+ });
16
+ LeanView.displayName = 'RCTView';
17
+
18
+ // this will match default export from react-native
19
+ var _default = exports.default = (0, _core.createUnistylesElement)(LeanView);
20
+ //# sourceMappingURL=NativeView.native.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_core","LeanView","forwardRef","props","ref","createElement","displayName","_default","exports","default","createUnistylesElement"],"sourceRoot":"../../../../src","sources":["components/native/NativeView.native.tsx"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAEA;AACA,MAAME,QAAQ,gBAAG,IAAAC,iBAAU,EAAC,CAACC,KAAK,EAAEC,GAAG,KAAK;EACxC,oBAAO,IAAAC,oBAAa,EAAC,SAAS,EAAE;IAAE,GAAGF,KAAK;IAAEC;EAAI,CAAC,CAAC;AACtD,CAAC,CAA6B;AAE9BH,QAAQ,CAACK,WAAW,GAAG,SAAS;;AAEhC;AAAA,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GACe,IAAAC,4BAAsB,EAACT,QAAQ,CAAC","ignoreList":[]}
@@ -11,13 +11,24 @@ var _core = require("../../core");
11
11
  var _jsxRuntime = require("react/jsx-runtime");
12
12
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
13
13
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
14
+ const getStyles = (styleProps = {}) => {
15
+ const unistyleKey = Object.keys(styleProps).find(key => key.startsWith('unistyles-'));
16
+ if (!unistyleKey) {
17
+ return styleProps;
18
+ }
19
+ return {
20
+ // styles without C++ state
21
+ ...styleProps[unistyleKey].uni__getStyles(),
22
+ [unistyleKey]: styleProps[unistyleKey].uni__getStyles()
23
+ };
24
+ };
14
25
  const Pressable = exports.Pressable = /*#__PURE__*/(0, _react.forwardRef)(({
15
26
  variants,
16
27
  style,
17
28
  ...props
18
29
  }, forwardedRef) => {
19
30
  const storedRef = (0, _react.useRef)();
20
- (0, _react.useEffect)(() => {
31
+ (0, _react.useLayoutEffect)(() => {
21
32
  return () => {
22
33
  if (storedRef.current) {
23
34
  // @ts-expect-error - this is hidden from TS
@@ -32,7 +43,7 @@ const Pressable = exports.Pressable = /*#__PURE__*/(0, _react.forwardRef)(({
32
43
  pressed: false
33
44
  }) : style;
34
45
 
35
- // @ts-expect-error web types are not compatible with RN styles
46
+ // @ts-expect-error - this is hidden from TS
36
47
  _specs.UnistylesShadowRegistry.add(ref, unistyles);
37
48
  if (ref) {
38
49
  storedRef.current = ref;
@@ -40,11 +51,13 @@ const Pressable = exports.Pressable = /*#__PURE__*/(0, _react.forwardRef)(({
40
51
  return (0, _core.passForwardedRef)(props, ref, forwardedRef);
41
52
  },
42
53
  style: state => {
43
- const unistyles = typeof style === 'function' ? style(state) : style;
54
+ const unistyles = typeof style === 'function' ? style(state) : getStyles(style);
44
55
  if (!storedRef.current) {
45
56
  return unistyles;
46
57
  }
47
58
 
59
+ // @ts-expect-error - this is hidden from TS
60
+ _specs.UnistylesShadowRegistry.remove(storedRef.current);
48
61
  // @ts-expect-error - this is hidden from TS
49
62
  _specs.UnistylesShadowRegistry.add(storedRef.current, unistyles);
50
63
  return unistyles;