react-native-unistyles 3.0.0-alpha.35 → 3.0.0-alpha.37

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. package/Unistyles.podspec +1 -1
  2. package/android/CMakeLists.txt +19 -36
  3. package/android/build.gradle +2 -1
  4. package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
  5. package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
  6. package/android/src/main/cxx/cpp-adapter.cpp +8 -86
  7. package/android/src/main/java/com/unistyles/Equatable.kt +61 -0
  8. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +302 -0
  9. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +148 -0
  10. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +54 -0
  11. package/android/src/main/java/com/unistyles/UnistylesModule.kt +51 -0
  12. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
  13. package/cxx/NativePlatform.h +11 -0
  14. package/cxx/common/Helpers.h +1 -1
  15. package/cxx/core/Unistyle.h +1 -1
  16. package/cxx/core/UnistyleData.h +1 -1
  17. package/cxx/core/UnistyleWrapper.h +1 -2
  18. package/cxx/core/UnistylesCommitHook.cpp +1 -1
  19. package/cxx/core/UnistylesMountHook.cpp +1 -1
  20. package/cxx/core/UnistylesRegistry.cpp +4 -13
  21. package/cxx/core/UnistylesRegistry.h +2 -3
  22. package/cxx/core/UnistylesState.cpp +10 -7
  23. package/cxx/hybridObjects/HybridNavigationBar.h +3 -3
  24. package/cxx/hybridObjects/HybridStatusBar.h +3 -3
  25. package/cxx/hybridObjects/HybridStyleSheet.cpp +21 -18
  26. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -8
  27. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -3
  28. package/cxx/parser/Parser.cpp +3 -27
  29. package/cxx/parser/Parser.h +2 -3
  30. package/cxx/shadowTree/ShadowTrafficController.h +9 -5
  31. package/cxx/shadowTree/ShadowTreeManager.cpp +10 -5
  32. package/cxx/shadowTree/ShadowTreeManager.h +1 -1
  33. package/lib/commonjs/components/useMedia.js.map +1 -1
  34. package/lib/commonjs/components/useMedia.web.js +43 -0
  35. package/lib/commonjs/components/useMedia.web.js.map +1 -0
  36. package/lib/commonjs/core/createUnistylesComponent.js +57 -4
  37. package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
  38. package/lib/commonjs/core/createUnistylesComponent.native.js +6 -5
  39. package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
  40. package/lib/commonjs/web/convert/index.js +16 -11
  41. package/lib/commonjs/web/convert/index.js.map +1 -1
  42. package/lib/commonjs/web/convert/object/boxShadow.js +58 -0
  43. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
  44. package/lib/commonjs/web/convert/object/filter.js +42 -0
  45. package/lib/commonjs/web/convert/object/filter.js.map +1 -0
  46. package/lib/commonjs/web/convert/object/index.js +39 -0
  47. package/lib/commonjs/web/convert/object/index.js.map +1 -0
  48. package/lib/commonjs/web/convert/object/objectStyle.js +55 -0
  49. package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
  50. package/lib/commonjs/web/convert/object/transform.js +27 -0
  51. package/lib/commonjs/web/convert/object/transform.js.map +1 -0
  52. package/lib/commonjs/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
  53. package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
  54. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
  55. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  56. package/lib/commonjs/web/convert/shadow/index.js +28 -0
  57. package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
  58. package/lib/commonjs/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
  59. package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
  60. package/lib/commonjs/web/convert/utils.js +7 -3
  61. package/lib/commonjs/web/convert/utils.js.map +1 -1
  62. package/lib/commonjs/web/listener.js +10 -0
  63. package/lib/commonjs/web/listener.js.map +1 -1
  64. package/lib/commonjs/web/registry.js +13 -26
  65. package/lib/commonjs/web/registry.js.map +1 -1
  66. package/lib/commonjs/web/runtime.js +3 -0
  67. package/lib/commonjs/web/runtime.js.map +1 -1
  68. package/lib/commonjs/web/shadowRegistry.js +79 -39
  69. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  70. package/lib/commonjs/web/utils/common.js +3 -33
  71. package/lib/commonjs/web/utils/common.js.map +1 -1
  72. package/lib/commonjs/web/utils/unistyle.js +4 -1
  73. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  74. package/lib/module/components/useMedia.js.map +1 -1
  75. package/lib/module/components/useMedia.web.js +38 -0
  76. package/lib/module/components/useMedia.web.js.map +1 -0
  77. package/lib/module/core/createUnistylesComponent.js +55 -3
  78. package/lib/module/core/createUnistylesComponent.js.map +1 -1
  79. package/lib/module/core/createUnistylesComponent.native.js +6 -5
  80. package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
  81. package/lib/module/web/convert/index.js +14 -9
  82. package/lib/module/web/convert/index.js.map +1 -1
  83. package/lib/module/web/convert/object/boxShadow.js +53 -0
  84. package/lib/module/web/convert/object/boxShadow.js.map +1 -0
  85. package/lib/module/web/convert/object/filter.js +37 -0
  86. package/lib/module/web/convert/object/filter.js.map +1 -0
  87. package/lib/module/web/convert/object/index.js +6 -0
  88. package/lib/module/web/convert/object/index.js.map +1 -0
  89. package/lib/module/web/convert/object/objectStyle.js +50 -0
  90. package/lib/module/web/convert/object/objectStyle.js.map +1 -0
  91. package/lib/module/web/convert/object/transform.js +22 -0
  92. package/lib/module/web/convert/object/transform.js.map +1 -0
  93. package/lib/module/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
  94. package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
  95. package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
  96. package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  97. package/lib/module/web/convert/shadow/index.js +5 -0
  98. package/lib/module/web/convert/shadow/index.js.map +1 -0
  99. package/lib/module/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
  100. package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
  101. package/lib/module/web/convert/utils.js +4 -2
  102. package/lib/module/web/convert/utils.js.map +1 -1
  103. package/lib/module/web/listener.js +10 -0
  104. package/lib/module/web/listener.js.map +1 -1
  105. package/lib/module/web/registry.js +14 -27
  106. package/lib/module/web/registry.js.map +1 -1
  107. package/lib/module/web/runtime.js +3 -0
  108. package/lib/module/web/runtime.js.map +1 -1
  109. package/lib/module/web/shadowRegistry.js +80 -40
  110. package/lib/module/web/shadowRegistry.js.map +1 -1
  111. package/lib/module/web/utils/common.js +1 -31
  112. package/lib/module/web/utils/common.js.map +1 -1
  113. package/lib/module/web/utils/unistyle.js +4 -1
  114. package/lib/module/web/utils/unistyle.js.map +1 -1
  115. package/lib/typescript/src/components/useMedia.web.d.ts +6 -0
  116. package/lib/typescript/src/components/useMedia.web.d.ts.map +1 -0
  117. package/lib/typescript/src/core/createUnistylesComponent.d.ts +4 -3
  118. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
  119. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +4 -3
  120. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
  121. package/lib/typescript/src/types/common.d.ts +1 -0
  122. package/lib/typescript/src/types/common.d.ts.map +1 -1
  123. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  124. package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
  125. package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
  126. package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
  127. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
  128. package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
  129. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
  130. package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
  131. package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
  132. package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
  133. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
  134. package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
  135. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
  136. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
  137. package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
  138. package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
  139. package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
  140. package/lib/typescript/src/web/convert/types.d.ts +7 -1
  141. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  142. package/lib/typescript/src/web/convert/utils.d.ts +8 -4
  143. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  144. package/lib/typescript/src/web/create.d.ts +8 -8
  145. package/lib/typescript/src/web/index.d.ts +8 -8
  146. package/lib/typescript/src/web/listener.d.ts +2 -0
  147. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  148. package/lib/typescript/src/web/registry.d.ts +5 -9
  149. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  150. package/lib/typescript/src/web/runtime.d.ts +1 -0
  151. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  152. package/lib/typescript/src/web/shadowRegistry.d.ts +4 -1
  153. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  154. package/lib/typescript/src/web/utils/common.d.ts +1 -6
  155. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  156. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  157. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -0
  158. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
  159. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void.kt +1 -0
  160. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency_.kt +1 -0
  161. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
  162. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +1 -0
  163. package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
  164. package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
  165. package/package.json +3 -3
  166. package/src/components/useMedia.ts +1 -1
  167. package/src/components/useMedia.web.ts +47 -0
  168. package/src/core/createUnistylesComponent.native.tsx +12 -10
  169. package/src/core/createUnistylesComponent.tsx +72 -6
  170. package/src/types/common.ts +1 -0
  171. package/src/web/convert/index.ts +16 -9
  172. package/src/web/convert/object/boxShadow.ts +54 -0
  173. package/src/web/convert/object/filter.ts +39 -0
  174. package/src/web/convert/object/index.ts +3 -0
  175. package/src/web/convert/object/objectStyle.ts +68 -0
  176. package/src/web/convert/object/transform.ts +24 -0
  177. package/src/web/convert/{boxShadow.ts → shadow/boxShadow.ts} +9 -30
  178. package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
  179. package/src/web/convert/shadow/index.ts +2 -0
  180. package/src/web/convert/{textShadow.ts → shadow/textShadow.ts} +9 -29
  181. package/src/web/convert/types.ts +8 -1
  182. package/src/web/convert/utils.ts +11 -5
  183. package/src/web/listener.ts +10 -0
  184. package/src/web/registry.ts +10 -31
  185. package/src/web/runtime.ts +4 -0
  186. package/src/web/shadowRegistry.ts +85 -46
  187. package/src/web/utils/common.ts +1 -37
  188. package/src/web/utils/unistyle.ts +5 -1
  189. package/android/src/main/cxx/helpers.cpp +0 -105
  190. package/android/src/main/cxx/helpers.h +0 -16
  191. package/android/src/main/cxx/platform.cpp +0 -170
  192. package/android/src/main/cxx/platform.h +0 -20
  193. package/lib/commonjs/web/convert/boxShadow.js.map +0 -1
  194. package/lib/commonjs/web/convert/shadow.js +0 -68
  195. package/lib/commonjs/web/convert/shadow.js.map +0 -1
  196. package/lib/commonjs/web/convert/textShadow.js.map +0 -1
  197. package/lib/commonjs/web/convert/transform.js +0 -72
  198. package/lib/commonjs/web/convert/transform.js.map +0 -1
  199. package/lib/module/web/convert/boxShadow.js.map +0 -1
  200. package/lib/module/web/convert/shadow.js +0 -63
  201. package/lib/module/web/convert/shadow.js.map +0 -1
  202. package/lib/module/web/convert/textShadow.js.map +0 -1
  203. package/lib/module/web/convert/transform.js +0 -67
  204. package/lib/module/web/convert/transform.js.map +0 -1
  205. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +0 -1
  206. package/lib/typescript/src/web/convert/shadow.d.ts +0 -2
  207. package/lib/typescript/src/web/convert/shadow.d.ts.map +0 -1
  208. package/lib/typescript/src/web/convert/textShadow.d.ts.map +0 -1
  209. package/lib/typescript/src/web/convert/transform.d.ts +0 -4
  210. package/lib/typescript/src/web/convert/transform.d.ts.map +0 -1
  211. package/src/web/convert/shadow.ts +0 -68
  212. package/src/web/convert/transform.ts +0 -88
  213. /package/lib/typescript/src/web/convert/{boxShadow.d.ts → shadow/boxShadow.d.ts} +0 -0
  214. /package/lib/typescript/src/web/convert/{textShadow.d.ts → shadow/textShadow.d.ts} +0 -0
@@ -4,7 +4,7 @@
4
4
  using namespace margelo::nitro::unistyles;
5
5
 
6
6
  ColorScheme HybridUnistylesRuntime::getColorScheme() {
7
- int colorScheme = this->_nativePlatform.getColorScheme();
7
+ auto colorScheme = this->_nativePlatform.getColorScheme();
8
8
 
9
9
  return static_cast<ColorScheme>(colorScheme);
10
10
  }
@@ -44,7 +44,7 @@ Insets HybridUnistylesRuntime::getInsets() {
44
44
  };
45
45
 
46
46
  Orientation HybridUnistylesRuntime::getOrientation() {
47
- int orientation = this->_nativePlatform.getOrientation();
47
+ auto orientation = this->_nativePlatform.getOrientation();
48
48
 
49
49
  return static_cast<Orientation>(orientation);
50
50
  };
@@ -61,11 +61,11 @@ std::unordered_map<std::string, double> HybridUnistylesRuntime::getBreakpoints()
61
61
  auto& state = core::UnistylesRegistry::get().getState(*_rt);
62
62
  auto sortedBreakpointPairs = state.getSortedBreakpointPairs();
63
63
  std::unordered_map<std::string, double> breakpoints{};
64
-
64
+
65
65
  std::for_each(sortedBreakpointPairs.begin(), sortedBreakpointPairs.end(), [&breakpoints](std::pair<std::string, double>& pair){
66
66
  breakpoints[pair.first] = pair.second;
67
67
  });
68
-
68
+
69
69
  return breakpoints;
70
70
  }
71
71
 
@@ -228,10 +228,6 @@ jsi::Value HybridUnistylesRuntime::getMiniRuntimeAsValue(jsi::Runtime& rt) {
228
228
  return obj;
229
229
  }
230
230
 
231
- jsi::Runtime& HybridUnistylesRuntime::getRuntime() {
232
- return *this->_rt;
233
- }
234
-
235
231
  void HybridUnistylesRuntime::registerPlatformListener(const std::function<void(std::vector<UnistyleDependency>)>& listener) {
236
232
  this->_nativePlatform.registerPlatformListener(listener);
237
233
  this->_onDependenciesChange = listener;
@@ -2,7 +2,7 @@
2
2
 
3
3
  #include "HybridUnistylesRuntimeSpec.hpp"
4
4
  #include "HybridNativePlatformSpec.hpp"
5
- #include "Unistyles-Swift-Cxx-Umbrella.hpp"
5
+ #include "NativePlatform.h"
6
6
  #include "UnistylesState.h"
7
7
  #include "HybridUnistylesStatusBarSpec.hpp"
8
8
  #include "HybridNavigationBar.h"
@@ -65,9 +65,8 @@ struct HybridUnistylesRuntime: public HybridUnistylesRuntimeSpec {
65
65
  void setRootViewBackgroundColor(double color) override;
66
66
  UnistylesCxxMiniRuntime getMiniRuntime() override;
67
67
  std::unordered_map<std::string, double> getBreakpoints() override;
68
-
68
+
69
69
  jsi::Value getMiniRuntimeAsValue(jsi::Runtime& rt);
70
- jsi::Runtime& getRuntime();
71
70
  void includeDependenciesForColorSchemeChange(std::vector<UnistyleDependency>& deps);
72
71
  void calculateNewThemeAndDependencies(std::vector<UnistyleDependency>& deps);
73
72
  std::function<void(std::function<void(jsi::Runtime&)>&&)> runOnJSThread;
@@ -93,13 +93,12 @@ void parser::Parser::rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_
93
93
  continue;
94
94
  }
95
95
 
96
- // todo skip dynamic functions
97
96
  this->rebuildUnistyle(rt, styleSheet, unistyle, variants, std::nullopt);
98
97
  }
99
98
  }
100
99
 
101
100
  // rebuild all unistyles that are affected by platform event
102
- void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet>> styleSheets) {
101
+ void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet>>& styleSheets) {
103
102
  std::unordered_map<std::shared_ptr<StyleSheet>, jsi::Value> parsedStyleSheets{};
104
103
  std::unordered_map<std::shared_ptr<core::Unistyle>, bool> parsedUnistyles{};
105
104
 
@@ -121,7 +120,7 @@ void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, Dependenc
121
120
  auto& unistyle = unistyleData->unistyle;
122
121
 
123
122
  // for RN styles or inline styles, compute styles only once
124
- if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY.c_str()) {
123
+ if (unistyle->styleKey == helpers::EXOTIC_STYLE_KEY) {
125
124
  if (!unistyleData->parsedStyle.has_value()) {
126
125
  unistyleData->parsedStyle = jsi::Value(rt, unistyle->rawValue).asObject(rt);
127
126
 
@@ -206,10 +205,9 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleShee
206
205
  }
207
206
 
208
207
  // convert dependency map to shadow tree updates
209
- void parser::Parser::rebuildShadowLeafUpdates(core::DependencyMap& dependencyMap) {
208
+ void parser::Parser::rebuildShadowLeafUpdates(jsi::Runtime& rt, core::DependencyMap& dependencyMap) {
210
209
  shadow::ShadowLeafUpdates updates;
211
210
  auto& registry = core::UnistylesRegistry::get();
212
- auto& rt = this->_unistylesRuntime->getRuntime();
213
211
 
214
212
  for (const auto& [shadowNode, unistyles] : dependencyMap) {
215
213
  auto rawProps = this->parseStylesToShadowTreeStyles(rt, unistyles);
@@ -218,8 +216,6 @@ void parser::Parser::rebuildShadowLeafUpdates(core::DependencyMap& dependencyMap
218
216
  }
219
217
 
220
218
  registry.trafficController.setUpdates(updates);
221
-
222
- // this is required, we need to indicate that there are new changes
223
219
  registry.trafficController.resumeUnistylesTraffic();
224
220
  }
225
221
 
@@ -764,26 +760,6 @@ folly::dynamic parser::Parser::parseStylesToShadowTreeStyles(jsi::Runtime& rt, c
764
760
  return jsi::dynamicFromValue(rt, std::move(convertedStyles));
765
761
  }
766
762
 
767
- folly::dynamic parser::Parser::parseUnistyleToShadowTreeStyles(jsi::Runtime& rt, const Unistyle::Shared unistyle) {
768
- jsi::Object convertedStyles = jsi::Object(rt);
769
- auto& state = core::UnistylesRegistry::get().getState(rt);
770
-
771
- // can happen for exotic styles
772
- if (!unistyle->parsedStyle.has_value()) {
773
- return nullptr;
774
- }
775
-
776
- helpers::enumerateJSIObject(rt, unistyle->parsedStyle.value(), [&](const std::string& propertyName, jsi::Value& propertyValue){
777
- if (this->isColor(propertyName)) {
778
- return convertedStyles.setProperty(rt, propertyName.c_str(), jsi::Value(state.parseColor(propertyValue)));
779
- }
780
-
781
- convertedStyles.setProperty(rt, propertyName.c_str(), propertyValue);
782
- });
783
-
784
- return jsi::dynamicFromValue(rt, std::move(convertedStyles));
785
- }
786
-
787
763
  // check is styleKey contains color
788
764
  bool parser::Parser::isColor(const std::string& propertyName) {
789
765
  std::string str = propertyName;
@@ -24,9 +24,8 @@ struct Parser {
24
24
  void buildUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet);
25
25
  void parseUnistyles(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet);
26
26
  void rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Variants& variants);
27
- void rebuildUnistylesInDependencyMap(jsi::Runtime& rt, core::DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet>> styleSheets);
28
- void rebuildShadowLeafUpdates(core::DependencyMap& dependencyMap);
29
- folly::dynamic parseUnistyleToShadowTreeStyles(jsi::Runtime& rt, const Unistyle::Shared unistyle);
27
+ void rebuildUnistylesInDependencyMap(jsi::Runtime& rt, core::DependencyMap& dependencyMap, std::vector<std::shared_ptr<core::StyleSheet>>& styleSheets);
28
+ void rebuildShadowLeafUpdates(jsi::Runtime& rt, core::DependencyMap& dependencyMap);
30
29
  folly::dynamic parseStylesToShadowTreeStyles(jsi::Runtime& rt, const std::vector<std::shared_ptr<UnistyleData>>& unistyles);
31
30
  void rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants, std::optional<std::vector<folly::dynamic>>);
32
31
 
@@ -13,20 +13,16 @@ struct ShadowTrafficController {
13
13
  }
14
14
 
15
15
  inline void stopUnistylesTraffic() {
16
- std::lock_guard<std::mutex> lock(_mutex);
17
-
18
16
  this->_canCommit = false;
19
17
  }
20
18
 
21
19
  inline void resumeUnistylesTraffic() {
22
- std::lock_guard<std::mutex> lock(_mutex);
23
-
24
20
  this->_canCommit = true;
25
21
  }
26
22
 
27
23
  inline shadow::ShadowLeafUpdates& getUpdates() {
28
24
  std::lock_guard<std::mutex> lock(_mutex);
29
-
25
+
30
26
  return _unistylesUpdates;
31
27
  }
32
28
 
@@ -47,6 +43,14 @@ struct ShadowTrafficController {
47
43
  targetUpdates.emplace(pair.first, std::move(pair.second));
48
44
  });
49
45
  }
46
+
47
+ inline void removeShadowNode(const ShadowNodeFamily* shadowNodeFamily) {
48
+ std::lock_guard<std::mutex> lock(_mutex);
49
+
50
+ if (_unistylesUpdates.contains(shadowNodeFamily)) {
51
+ _unistylesUpdates.erase(shadowNodeFamily);
52
+ }
53
+ }
50
54
 
51
55
  inline void restore() {
52
56
  std::lock_guard<std::mutex> lock(_mutex);
@@ -6,13 +6,11 @@ using namespace facebook;
6
6
 
7
7
  using AffectedNodes = std::unordered_map<const ShadowNodeFamily*, std::unordered_set<int>>;
8
8
 
9
- void shadow::ShadowTreeManager::updateShadowTree(facebook::jsi::Runtime& rt) {
9
+ void shadow::ShadowTreeManager::updateShadowTree(const ShadowTreeRegistry& shadowTreeRegistry) {
10
10
  auto& registry = core::UnistylesRegistry::get();
11
- auto& uiManager = UIManagerBinding::getBinding(rt)->getUIManager();
12
- const auto &shadowTreeRegistry = uiManager.getShadowTreeRegistry();
13
11
  auto updates = registry.trafficController.getUpdates();
14
12
 
15
- if (updates.size() == 0) {
13
+ if (updates.empty()) {
16
14
  return;
17
15
  }
18
16
 
@@ -111,9 +109,16 @@ ShadowNode::Unshared shadow::ShadowTreeManager::cloneShadowTree(const ShadowNode
111
109
  *shadowNode.getContextContainer()
112
110
  };
113
111
 
112
+ #ifdef ANDROID
113
+ auto safeProps = rawPropsIt->second == nullptr ? folly::dynamic::object() : rawPropsIt->second;
114
+ auto newProps = folly::dynamic::merge(shadowNode.getProps()->rawProps, safeProps);
115
+ #else
116
+ auto newProps = rawPropsIt->second;
117
+ #endif
118
+
114
119
  updatedProps = shadowNode
115
120
  .getComponentDescriptor()
116
- .cloneProps(propsParserContext, shadowNode.getProps(), RawProps(rawPropsIt->second));
121
+ .cloneProps(propsParserContext, shadowNode.getProps(), RawProps(newProps));
117
122
  }
118
123
 
119
124
  return shadowNode.clone({
@@ -16,7 +16,7 @@ using namespace facebook;
16
16
  using AffectedNodes = std::unordered_map<const ShadowNodeFamily *, std::unordered_set<int>>;
17
17
 
18
18
  struct ShadowTreeManager {
19
- static void updateShadowTree(jsi::Runtime& rt);
19
+ static void updateShadowTree(const ShadowTreeRegistry& shadowTreeRegistry);
20
20
  static AffectedNodes findAffectedNodes(const RootShadowNode& rootNode, ShadowLeafUpdates& updates);
21
21
  static ShadowNode::Unshared cloneShadowTree(const ShadowNode &shadowNode, ShadowLeafUpdates& updates, AffectedNodes& affectedNodes);
22
22
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_react","require","_specs","_mq","useMedia","config","computeIsVisible","maybeMq","mq","isUnistylesMq","console","error","parsedMq","parseMq","isValidMq","width","height","UnistylesRuntime","screen","minWidth","undefined","maxWidth","minHeight","maxHeight","isVisible","setIsVisible","useState","useEffect","useLayoutEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","includes","UnistyleDependency","Breakpoints","exports"],"sourceRoot":"../../../src","sources":["components/useMedia.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,GAAA,GAAAF,OAAA;AAEO,MAAMG,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,gBAAgB,GAAGA,CAAA,KAAe;IACpC,MAAMC,OAAO,GAAGF,MAAM,CAACG,EAAuB;IAE9C,IAAI,CAAC,IAAAC,iBAAa,EAACF,OAAO,CAAC,EAAE;MACzBG,OAAO,CAACC,KAAK,CAAC,sCAAsCJ,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMK,QAAQ,GAAI,IAAAC,WAAO,EAACN,OAAO,CAAC;IAElC,IAAI,CAAC,IAAAO,aAAS,EAACF,QAAQ,CAAC,EAAE;MACtBF,OAAO,CAACC,KAAK,CAAC,oEAAoEJ,OAAO,EAAE,CAAC;MAE5F,OAAO,KAAK;IAChB;IAEA,MAAM;MAAEQ,KAAK;MAAEC;IAAO,CAAC,GAAGC,uBAAgB,CAACC,MAAM;IAEjD,IAAIN,QAAQ,CAACO,QAAQ,KAAKC,SAAS,IAAIL,KAAK,GAAGH,QAAQ,CAACO,QAAQ,EAAE;MAC9D,OAAO,KAAK;IAChB;IAEA,IAAIP,QAAQ,CAACS,QAAQ,KAAKD,SAAS,IAAIL,KAAK,GAAGH,QAAQ,CAACS,QAAQ,EAAE;MAC9D,OAAO,KAAK;IAChB;IAEA,IAAIT,QAAQ,CAACU,SAAS,KAAKF,SAAS,IAAIJ,MAAM,GAAGJ,QAAQ,CAACU,SAAS,EAAE;MACjE,OAAO,KAAK;IAChB;IAEA,IAAIV,QAAQ,CAACW,SAAS,KAAKH,SAAS,IAAIJ,MAAM,GAAGJ,QAAQ,CAACW,SAAS,EAAE;MACjE,OAAO,KAAK;IAChB;IAEA,OAAO,IAAI;EACf,CAAC;EACD,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAG,IAAAC,eAAQ,EAAiBpB,gBAAgB,CAAC,CAAC,CAAC;EAE9E,IAAAqB,gBAAS,EAAC,MAAM;IACZF,YAAY,CAACnB,gBAAgB,CAAC,CAAC,CAAC;EACpC,CAAC,EAAE,CAACD,MAAM,CAACG,EAAE,CAAC,CAAC;EAEf,IAAAoB,sBAAe,EAAC,MAAM;IAClB,MAAMC,oBAAoB,GAAIC,iBAAU,CAAyBC,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACC,yBAAkB,CAACC,WAAW,CAAC,EAAE;QACvDV,YAAY,CAACnB,gBAAgB,CAAC,CAAC,CAAC;MACpC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTuB,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,CAACxB,MAAM,CAACG,EAAE,CAAC,CAAC;EAEf,OAAO;IACHgB;EACJ,CAAC;AACL,CAAC;AAAAY,OAAA,CAAAhC,QAAA,GAAAA,QAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","require","_specs","_mq","useMedia","config","computeIsVisible","maybeMq","mq","isUnistylesMq","console","error","parsedMq","parseMq","isValidMq","width","height","UnistylesRuntime","screen","minWidth","undefined","maxWidth","minHeight","maxHeight","isVisible","setIsVisible","useState","useEffect","useLayoutEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","includes","UnistyleDependency","Breakpoints","exports"],"sourceRoot":"../../../src","sources":["components/useMedia.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,GA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,CAAC,CAAC;EACpC,CAAC,EAAE,CAACD,MAAM,CAACG,EAAE,CAAC,CAAC;EAEf,IAAAoB,sBAAe,EAAC,MAAM;IAClB,MAAMC,oBAAoB,GAAIC,iBAAU,CAAyBC,iBAAiB,CAACC,YAAY,IAAI;MAC/F,IAAIA,YAAY,CAACC,QAAQ,CAACC,yBAAkB,CAACC,WAAW,CAAC,EAAE;QACvDV,YAAY,CAACnB,gBAAgB,CAAC,CAAC,CAAC;MACpC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTuB,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,CAACxB,MAAM,CAACG,EAAE,CAAC,CAAC;EAEf,OAAO;IACHgB;EACJ,CAAC;AACL,CAAC;AAAAY,OAAA,CAAAhC,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useMedia = void 0;
7
+ var _react = require("react");
8
+ var _mq = require("../mq");
9
+ const useMedia = config => {
10
+ const disposeRef = (0, _react.useRef)(() => {});
11
+ const [isVisible, setIsVisible] = (0, _react.useState)(() => {
12
+ const maybeMq = config.mq;
13
+ if (!(0, _mq.isUnistylesMq)(maybeMq)) {
14
+ console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`);
15
+ return false;
16
+ }
17
+ const parsedMq = (0, _mq.parseMq)(maybeMq);
18
+ if (!(0, _mq.isValidMq)(parsedMq)) {
19
+ console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`);
20
+ return false;
21
+ }
22
+ const {
23
+ minWidth,
24
+ maxWidth,
25
+ minHeight,
26
+ maxHeight
27
+ } = parsedMq;
28
+ const mediaQuery = [minWidth !== undefined ? `(min-width: ${minWidth}px)` : undefined, maxWidth !== undefined ? `(max-width: ${maxWidth}px)` : undefined, minHeight !== undefined ? `(min-height: ${minHeight}px)` : undefined, maxHeight !== undefined ? `(max-height: ${maxHeight}px)` : undefined].filter(Boolean).join(' and ');
29
+ const media = window.matchMedia(mediaQuery);
30
+ const handler = event => setIsVisible(event.matches);
31
+ media.addEventListener('change', handler);
32
+ disposeRef.current = () => media.removeEventListener('change', handler);
33
+ return media.matches;
34
+ });
35
+
36
+ // Unmount
37
+ (0, _react.useEffect)(() => () => disposeRef.current(), []);
38
+ return {
39
+ isVisible
40
+ };
41
+ };
42
+ exports.useMedia = useMedia;
43
+ //# sourceMappingURL=useMedia.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_mq","useMedia","config","disposeRef","useRef","isVisible","setIsVisible","useState","maybeMq","mq","isUnistylesMq","console","error","parsedMq","parseMq","isValidMq","minWidth","maxWidth","minHeight","maxHeight","mediaQuery","undefined","filter","Boolean","join","media","window","matchMedia","handler","event","matches","addEventListener","current","removeEventListener","useEffect","exports"],"sourceRoot":"../../../src","sources":["components/useMedia.web.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,GAAA,GAAAD,OAAA;AAEO,MAAME,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAAC,MAAM,CAAC,CAAC,CAAC;EACnC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAG,IAAAC,eAAQ,EAAC,MAAM;IAC7C,MAAMC,OAAO,GAAGN,MAAM,CAACO,EAAuB;IAE9C,IAAI,CAAC,IAAAC,iBAAa,EAACF,OAAO,CAAC,EAAE;MACzBG,OAAO,CAACC,KAAK,CAAC,sCAAsCJ,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMK,QAAQ,GAAG,IAAAC,WAAO,EAACN,OAAO,CAAC;IAEjC,IAAI,CAAC,IAAAO,aAAS,EAACF,QAAQ,CAAC,EAAE;MACtBF,OAAO,CAACC,KAAK,CAAC,oEAAoEJ,OAAO,EAAE,CAAC;MAE5F,OAAO,KAAK;IAChB;IAEA,MAAM;MAAEQ,QAAQ;MAAEC,QAAQ;MAAEC,SAAS;MAAEC;IAAU,CAAC,GAAGN,QAAQ;IAE7D,MAAMO,UAAU,GAAG,CACfJ,QAAQ,KAAKK,SAAS,GAAG,eAAeL,QAAQ,KAAK,GAAGK,SAAS,EACjEJ,QAAQ,KAAKI,SAAS,GAAG,eAAeJ,QAAQ,KAAK,GAAGI,SAAS,EACjEH,SAAS,KAAKG,SAAS,GAAG,gBAAgBH,SAAS,KAAK,GAAGG,SAAS,EACpEF,SAAS,KAAKE,SAAS,GAAG,gBAAgBF,SAAS,KAAK,GAAGE,SAAS,CACvE,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,OAAO,CAAC;IAE/B,MAAMC,KAAK,GAAGC,MAAM,CAACC,UAAU,CAACP,UAAU,CAAC;IAC3C,MAAMQ,OAAO,GAAIC,KAA0B,IAAKvB,YAAY,CAACuB,KAAK,CAACC,OAAO,CAAC;IAE3EL,KAAK,CAACM,gBAAgB,CAAC,QAAQ,EAAEH,OAAO,CAAC;IACzCzB,UAAU,CAAC6B,OAAO,GAAG,MAAMP,KAAK,CAACQ,mBAAmB,CAAC,QAAQ,EAAEL,OAAO,CAAC;IAEvE,OAAOH,KAAK,CAACK,OAAO;EACxB,CAAC,CAAC;;EAEF;EACA,IAAAI,gBAAS,EAAC,MAAM,MAAM/B,UAAU,CAAC6B,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC;EAE/C,OAAO;IACH3B;EACJ,CAAC;AACL,CAAC;AAAA8B,OAAA,CAAAlC,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -4,14 +4,67 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.createUnistylesComponent = void 0;
7
- var _react = _interopRequireDefault(require("react"));
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _specs = require("../specs");
9
+ var _NativePlatform = require("../specs/NativePlatform");
10
+ var _listener = require("../web/listener");
11
+ var _web = require("../web");
12
+ var _utils = require("../web/utils");
8
13
  var _jsxRuntime = require("react/jsx-runtime");
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
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); }
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; }
10
16
  const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'];
11
- const createUnistylesComponent = (Component, _ = () => ({})) => {
17
+ const ALL_DEPENDENCIES = Object.values(_NativePlatform.UnistyleDependency).filter(dependency => typeof dependency === 'number');
18
+ const useShadowRegistry = style => {
19
+ const [classNames, setClassNames] = (0, _react.useState)([]);
20
+ const [ref] = (0, _react.useState)(document.createElement('div'));
21
+ if (style) {
22
+ _web.UnistylesShadowRegistry.add(ref, style).then(newClassNames => {
23
+ if ((0, _utils.equal)(classNames, newClassNames)) {
24
+ return;
25
+ }
26
+ setClassNames(newClassNames);
27
+ });
28
+ }
29
+ (0, _react.useEffect)(() => () => {
30
+ // Remove styles on unmount
31
+ _web.UnistylesShadowRegistry.add(null, style);
32
+ });
33
+ return classNames;
34
+ };
35
+ const createUnistylesComponent = (Component, mappings) => {
12
36
  return props => {
37
+ const [mappingsProps, setMappingsProps] = (0, _react.useState)(mappings?.(_specs.UnistylesRuntime.getTheme()));
38
+ const styleClassNames = useShadowRegistry(props.style);
39
+ const contentContainerStyleClassNames = useShadowRegistry(props.contentContainerStyle);
40
+ (0, _react.useEffect)(() => {
41
+ const disposeMappings = _listener.UnistylesListener.addListeners(ALL_DEPENDENCIES, () => {
42
+ if (!mappings) {
43
+ disposeMappings();
44
+ return;
45
+ }
46
+ return setMappingsProps(mappings(_specs.UnistylesRuntime.getTheme()));
47
+ });
48
+ return () => disposeMappings();
49
+ }, [mappingsProps, props.style]);
50
+ const combinedProps = {
51
+ ...mappingsProps,
52
+ ...props,
53
+ ...(props.style ? {
54
+ style: {
55
+ $$css: true,
56
+ 'unistyles': styleClassNames.join(' ')
57
+ }
58
+ } : {}),
59
+ ...(props.contentContainerStyle ? {
60
+ style: {
61
+ $$css: true,
62
+ 'unistyles': contentContainerStyleClassNames.join(' ')
63
+ }
64
+ } : {})
65
+ };
13
66
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
14
- ...props
67
+ ...combinedProps
15
68
  });
16
69
  };
17
70
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireDefault","require","_jsxRuntime","e","__esModule","default","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","_","props","jsx","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAAsE,IAAAC,WAAA,GAAAD,OAAA;AAAA,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAKtE,MAAMG,qBAAqB,GAAG,CAAC,OAAO,EAAE,uBAAuB,CAAU;AAElE,MAAMC,wBAAwB,GAAGA,CAA+BC,SAAY,EAAEC,CAAc,GAAGA,CAAA,MAAO,CAAC,CAAC,CAAC,KAAK;EACjH,OAAQC,KAAwB,IAAK;IACjC,oBAAO,IAAAR,WAAA,CAAAS,GAAA,EAACH,SAAS;MAAA,GAAKE;IAAK,CAAG,CAAC;EACnC,CAAC;AACL,CAAC;AAAAE,OAAA,CAAAL,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_NativePlatform","_listener","_web","_utils","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SUPPORTED_STYLE_PROPS","ALL_DEPENDENCIES","values","UnistyleDependency","filter","dependency","useShadowRegistry","style","classNames","setClassNames","useState","ref","document","createElement","UnistylesShadowRegistry","add","then","newClassNames","equal","useEffect","createUnistylesComponent","Component","mappings","props","mappingsProps","setMappingsProps","UnistylesRuntime","getTheme","styleClassNames","contentContainerStyleClassNames","contentContainerStyle","disposeMappings","UnistylesListener","addListeners","combinedProps","$$css","join","jsx","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,eAAA,GAAAF,OAAA;AAEA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,IAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAAoC,IAAAM,WAAA,GAAAN,OAAA;AAAA,SAAAO,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAT,wBAAAS,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CA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b,KAAK,CAACO,qBAAqB,GAAG;QAC7BvB,KAAK,EAAE;UACH4B,KAAK,EAAE,IAAI;UACX,WAAW,EAAEN,+BAA+B,CAACO,IAAI,CAAC,GAAG;QACzD;MACJ,CAAC,GAAG,CAAC,CAAC;IACV,CAAsB;IAEtB,oBAAO,IAAAzD,WAAA,CAAA0D,GAAA,EAAChB,SAAS;MAAA,GAAKa;IAAa,CAAG,CAAC;EAC3C,CAAC;AACL,CAAC;AAAAI,OAAA,CAAAlB,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -10,7 +10,7 @@ var _jsxRuntime = require("react/jsx-runtime");
10
10
  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); }
11
11
  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; }
12
12
  const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'];
13
- const createUnistylesComponent = (Component, mappings = () => ({})) => {
13
+ const createUnistylesComponent = (Component, mappings) => {
14
14
  return props => {
15
15
  const [theme, setTheme] = (0, _react.useState)(_specs.UnistylesRuntime.getTheme());
16
16
  const [, setRt] = (0, _react.useState)(0);
@@ -22,6 +22,8 @@ const createUnistylesComponent = (Component, mappings = () => ({})) => {
22
22
  if (Array.isArray(props[propName])) {
23
23
  console.error(`🦄 Unistyles: createUnistylesComponent requires ${propName} to be an object. Please check props for component: ${Component.displayName}`);
24
24
  }
25
+
26
+ // @ts-expect-error - this is hidden from TS
25
27
  if (props[propName].__unistyles_name && !props[propName].__proto__?.getStyle) {
26
28
  console.error(`🦄 Unistyles: createUnistylesComponent received style that is not bound. You likely used the spread operator on a Unistyle style. Please check props for component: ${Component.displayName}`);
27
29
  }
@@ -34,7 +36,7 @@ const createUnistylesComponent = (Component, mappings = () => ({})) => {
34
36
  }
35
37
  (0, _react.useEffect)(() => {
36
38
  const removeChangeListener = _specs.StyleSheet.addChangeListener(dependencies => {
37
- const componentDependencies = props.style?.__proto__.uni__dependencies || mappings(theme).style?.__proto__.uni__dependencies;
39
+ const componentDependencies = props.style?.__proto__.uni__dependencies || mappings?.(theme).style?.__proto__.uni__dependencies;
38
40
  if (dependencies.includes(_specs.UnistyleDependency.Theme) && (!componentDependencies || componentDependencies.includes(_specs.UnistyleDependency.Theme))) {
39
41
  setTheme(_specs.UnistylesRuntime.getTheme());
40
42
 
@@ -43,6 +45,7 @@ const createUnistylesComponent = (Component, mappings = () => ({})) => {
43
45
  if (props?.[propName]) {
44
46
  stylesRef.current = {
45
47
  ...stylesRef.current,
48
+ // @ts-expect-error - this is hidden from TS
46
49
  [propName]: props[propName].__proto__?.getStyle() || props[propName]
47
50
  };
48
51
  }
@@ -57,9 +60,7 @@ const createUnistylesComponent = (Component, mappings = () => ({})) => {
57
60
  removeChangeListener();
58
61
  };
59
62
  }, []);
60
- const mergedProps = {
61
- ...mappings(theme)
62
- };
63
+ const mergedProps = mappings?.(theme) ?? {};
63
64
  Object.keys(props).forEach(key => {
64
65
  if (key in mergedProps) {
65
66
  mergedProps[key] = Object.assign(props[key], mergedProps[key]);
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","mappings","props","theme","setTheme","useState","UnistylesRuntime","getTheme","setRt","stylesRef","useRef","isForcedRef","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","getStyle","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","UnistyleDependency","Theme","some","dependency","prevState","mergedProps","keys","key","assign","jsx","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAqG,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,C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AAC;MAEF,OAAO,MAAM;QACTZ,oBAAoB,CAAC,CAAC;MAC1B,CAAC;IACL,CAAC,EAAE,EAAE,CAAC;IAEN,MAAMa,WAAW,GAAG;MAAE,GAAGnC,QAAQ,CAACE,KAAK;IAAE,CAAsB;IAE/Db,MAAM,CAAC+C,IAAI,CAACnC,KAAK,CAAC,CAACW,OAAO,CAACyB,GAAG,IAAI;MAC9B,IAAIA,GAAG,IAAIF,WAAW,EAAE;QACpBA,WAAW,CAACE,GAAG,CAAC,GAAGhD,MAAM,CAACiD,MAAM,CAACrC,KAAK,CAACoC,GAAG,CAAC,EAAEF,WAAW,CAACE,GAAG,CAAC,CAAC;QAE9D;MACJ;MAEAF,WAAW,CAACE,GAAG,CAAC,GAAGpC,KAAK,CAACoC,GAAG,CAAC;IACjC,CAAC,CAAC;;IAEF;IACAxC,qBAAqB,CAACe,OAAO,CAACC,QAAQ,IAAI;MACtC,IAAIsB,WAAW,CAACtB,QAAQ,CAAC,EAAE;QACvBsB,WAAW,CAACtB,QAAQ,CAAC,GAAGL,SAAS,CAACG,OAAO,CAACE,QAAQ,CAAC;MACvD;IACJ,CAAC,CAAC;IAEFH,WAAW,CAACC,OAAO,GAAG,KAAK;IAE3B,oBAAO,IAAAnC,WAAA,CAAA+D,GAAA,EAACxC,SAAS;MAAA,GAAKoC;IAAW,CAAG,CAAC;EACzC,CAAC;AACL,CAAC;AAAAK,OAAA,CAAA1C,wBAAA,GAAAA,wBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","SUPPORTED_STYLE_PROPS","createUnistylesComponent","Component","mappings","props","theme","setTheme","useState","UnistylesRuntime","getTheme","setRt","stylesRef","useRef","isForcedRef","current","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","getStyle","useEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","componentDependencies","style","uni__dependencies","includes","UnistyleDependency","Theme","some","dependency","prevState","mergedProps","keys","key","assign","jsx","exports"],"sourceRoot":"../../../src","sources":["core/createUnistylesComponent.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AAAqG,IAAAE,WAAA,GAAAF,OAAA;AAAA,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAL,wBAAAK,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,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MAAMa,WAAW,GAAGnC,QAAQ,GAAGE,KAAK,CAAC,IAA2B,CAAC,CAAC;IAElEb,MAAM,CAAC+C,IAAI,CAACnC,KAAK,CAAC,CAACW,OAAO,CAACyB,GAAG,IAAI;MAC9B,IAAIA,GAAG,IAAIF,WAAW,EAAE;QACpBA,WAAW,CAACE,GAAG,CAAC,GAAGhD,MAAM,CAACiD,MAAM,CAACrC,KAAK,CAACoC,GAAG,CAAuB,EAAEF,WAAW,CAACE,GAAG,CAAC,CAAC;QAEpF;MACJ;MAEAF,WAAW,CAACE,GAAG,CAAC,GAAGpC,KAAK,CAACoC,GAAG,CAAuB;IACvD,CAAC,CAAC;;IAEF;IACAxC,qBAAqB,CAACe,OAAO,CAACC,QAAQ,IAAI;MACtC,IAAIsB,WAAW,CAACtB,QAAQ,CAAC,EAAE;QACvBsB,WAAW,CAACtB,QAAQ,CAAC,GAAGL,SAAS,CAACG,OAAO,CAACE,QAAQ,CAAC;MACvD;IACJ,CAAC,CAAC;IAEFH,WAAW,CAACC,OAAO,GAAG,KAAK;IAE3B,oBAAO,IAAAnC,WAAA,CAAA+D,GAAA,EAACxC,SAAS;MAAA,GAAKoC;IAAW,CAAa,CAAC;EACnD,CAAC;AACL,CAAC;AAAAK,OAAA,CAAA1C,wBAAA,GAAAA,wBAAA","ignoreList":[]}
@@ -7,15 +7,14 @@ exports.convertUnistyles = void 0;
7
7
  var _pseudo = require("./pseudo");
8
8
  var _style = require("./style");
9
9
  var _utils = require("../utils");
10
- var _transform = require("./transform");
10
+ var _object = require("./object");
11
11
  var _utils2 = require("./utils");
12
- var _textShadow = require("./textShadow");
13
- var _boxShadow = require("./boxShadow");
12
+ var _shadow = require("./shadow");
14
13
  const convertUnistyles = value => {
15
14
  // Flag to mark if textShadow is already created
16
15
  let hasTextShadow = false;
17
16
  // Flag to mark if boxShadow is already created
18
- let hasBoxShadow = false;
17
+ let hasShadow = false;
19
18
  const stylesArray = Object.entries({
20
19
  ...value,
21
20
  ...value._web
@@ -39,21 +38,27 @@ const convertUnistyles = value => {
39
38
  return [];
40
39
  }
41
40
  hasTextShadow = true;
42
- return (0, _textShadow.getTextShadowStyle)(value);
41
+ return (0, _shadow.getTextShadowStyle)(value);
43
42
  }
44
43
 
45
- // Box shadow
46
- if ((0, _utils2.isBoxShadow)(unistylesKey)) {
47
- if (hasBoxShadow) {
44
+ // RN shadows
45
+ if ((0, _utils2.isShadow)(unistylesKey)) {
46
+ if (hasShadow) {
48
47
  return [];
49
48
  }
50
- hasBoxShadow = true;
51
- return (0, _boxShadow.getBoxShadowStyle)(value);
49
+ hasShadow = true;
50
+ return (0, _shadow.getBoxShadowStyle)(value);
51
+ }
52
+ if ((0, _utils2.isFilter)(unistylesKey, unistylesValue)) {
53
+ return (0, _object.getFilterStyle)(unistylesValue);
54
+ }
55
+ if ((0, _utils2.isBoxShadow)(unistylesKey, unistylesValue)) {
56
+ return (0, _object.getBoxShadow)(unistylesValue);
52
57
  }
53
58
 
54
59
  // Transforms
55
60
  if ((0, _utils2.isTransform)(unistylesKey, unistylesValue)) {
56
- return (0, _transform.getTransformStyle)(unistylesValue);
61
+ return (0, _object.getTransformStyle)(unistylesValue);
57
62
  }
58
63
 
59
64
  // Breakpoints
@@ -1 +1 @@
1
- {"version":3,"names":["_pseudo","require","_style","_utils","_transform","_utils2","_textShadow","_boxShadow","convertUnistyles","value","hasTextShadow","hasBoxShadow","stylesArray","Object","entries","_web","flatMap","unistylesKey","unistylesValue","includes","startsWith","isPseudo","flattenValues","isTextShadow","getTextShadowStyle","isBoxShadow","getBoxShadowStyle","isTransform","getTransformStyle","map","breakpointKey","breakpointValue","getStyle","deepMergeObjects","exports"],"sourceRoot":"../../../../src","sources":["web/convert/index.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OA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IACA,IAAI,OAAOA,cAAc,KAAK,QAAQ,IAAIA,cAAc,KAAK,IAAI,EAAE;MAC/D,OAAOL,MAAM,CAACC,OAAO,CAACI,cAAc,CAAC,CAACW,GAAG,CAAC,CAAC,CAACC,aAAa,EAAEC,eAAe,CAAC,KAAK;QAC5E,OAAO;UAAE,CAACD,aAAa,GAAG,IAAAE,eAAQ,EAACf,YAAY,EAAEc,eAAe;QAAE,CAAC;MACvE,CAAC,CAAC;IACN;;IAEA;IACA,OAAO,IAAAC,eAAQ,EAACf,YAAY,EAAEC,cAAc,CAAC;EACjD,CAAC,CAA+B;EAEhC,OAAO,IAAAe,uBAAgB,EAAC,GAAGrB,WAAW,CAAC;AAC3C,CAAC;AAAAsB,OAAA,CAAA1B,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_pseudo","require","_style","_utils","_object","_utils2","_shadow","convertUnistyles","value","hasTextShadow","hasShadow","stylesArray","Object","entries","_web","flatMap","unistylesKey","unistylesValue","includes","startsWith","isPseudo","flattenValues","isTextShadow","getTextShadowStyle","isShadow","getBoxShadowStyle","isFilter","getFilterStyle","isBoxShadow","getBoxShadow","isTransform","getTransformStyle","map","breakpointKey","breakpointValue","getStyle","deepMergeObjects","exports"],"sourceRoot":"../../../../src","sources":["web/convert/index.ts"],"mappings":";;;;;;AACA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEO,MAAMM,gBAAgB,GAAIC,KAAsB,IAAK;EACxD;EACA,IAAIC,aAAa,GAAG,KAAK;EACzB;EACA,IAAIC,SAAS,GAAG,KAAK;EAErB,MAAMC,WAAW,GAAGC,MAAM,CAACC,OAAO,CAAC;IAC/B,GAAGL,KAAK;IACR,GAAGA,KAAK,CAACM;EACb,CAA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KAAK,IAAI,EAAE;MAC/D,OAAOL,MAAM,CAACC,OAAO,CAACI,cAAc,CAAC,CAACe,GAAG,CAAC,CAAC,CAACC,aAAa,EAAEC,eAAe,CAAC,KAAK;QAC5E,OAAO;UAAE,CAACD,aAAa,GAAG,IAAAE,eAAQ,EAACnB,YAAY,EAAEkB,eAAe;QAAE,CAAC;MACvE,CAAC,CAAC;IACN;;IAEA;IACA,OAAO,IAAAC,eAAQ,EAACnB,YAAY,EAAEC,cAAc,CAAC;EACjD,CAAC,CAA+B;EAEhC,OAAO,IAAAmB,uBAAgB,EAAC,GAAGzB,WAAW,CAAC;AAC3C,CAAC;AAAA0B,OAAA,CAAA9B,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBoxShadow = void 0;
7
+ var _utils = require("../utils");
8
+ var _utils2 = require("../../utils");
9
+ const createBoxShadowValue = style => {
10
+ const {
11
+ offsetX,
12
+ offsetY,
13
+ blurRadius = 0,
14
+ spreadDistance = 0,
15
+ color = '#000',
16
+ inset
17
+ } = style;
18
+ return `${inset ? 'inset ' : ''}${(0, _utils.normalizeNumericValue)(offsetX)} ${(0, _utils.normalizeNumericValue)(offsetY)} ${(0, _utils.normalizeNumericValue)(blurRadius)} ${(0, _utils.normalizeNumericValue)(spreadDistance)} ${color}`;
19
+ };
20
+ const getBoxShadow = boxShadow => {
21
+ const breakpoints = new Set();
22
+ boxShadow.forEach(shadow => {
23
+ const [key] = Object.keys(shadow);
24
+ const value = shadow[key];
25
+
26
+ // Breakpoints
27
+ if (typeof value === 'object') {
28
+ Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
29
+ }
30
+ });
31
+ if (breakpoints.size === 0) {
32
+ const boxShadowStyle = Object.fromEntries(boxShadow.map(shadow => {
33
+ const [key] = Object.keys(shadow);
34
+ return [key, shadow[key]];
35
+ }));
36
+ return {
37
+ boxShadow: createBoxShadowValue(boxShadowStyle)
38
+ };
39
+ }
40
+ const breakpointStyles = Array.from(breakpoints).map(breakpoint => {
41
+ const styles = Object.fromEntries(boxShadow.map(shadow => {
42
+ const [key] = Object.keys(shadow);
43
+ const value = shadow[key];
44
+ if (typeof value === 'object' && (0, _utils2.keyInObject)(value, breakpoint)) {
45
+ return [key, value[breakpoint]];
46
+ }
47
+ return [key, value];
48
+ }));
49
+ return {
50
+ [breakpoint]: {
51
+ boxShadow: createBoxShadowValue(styles)
52
+ }
53
+ };
54
+ });
55
+ return (0, _utils2.deepMergeObjects)(...breakpointStyles);
56
+ };
57
+ exports.getBoxShadow = getBoxShadow;
58
+ //# sourceMappingURL=boxShadow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","_utils2","createBoxShadowValue","style","offsetX","offsetY","blurRadius","spreadDistance","color","inset","normalizeNumericValue","getBoxShadow","boxShadow","breakpoints","Set","forEach","shadow","key","Object","keys","value","breakpoint","add","size","boxShadowStyle","fromEntries","map","breakpointStyles","Array","from","styles","keyInObject","deepMergeObjects","exports"],"sourceRoot":"../../../../../src","sources":["web/convert/object/boxShadow.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,OAAA,GAAAD,OAAA;AAEA,MAAME,oBAAoB,GAAIC,KAAqB,IAAK;EACpD,MAAM;IAAEC,OAAO;IAAEC,OAAO;IAAEC,UAAU,GAAG,CAAC;IAAEC,cAAc,GAAG,CAAC;IAAEC,KAAK,GAAG,MAAM;IAAEC;EAAM,CAAC,GAAGN,KAAK;EAE7F,OAAO,GAAGM,KAAK,GAAG,QAAQ,GAAG,EAAE,GAAG,IAAAC,4BAAqB,EAACN,OAAO,CAAC,IAAI,IAAAM,4BAAqB,EAACL,OAAO,CAAC,IAAI,IAAAK,4BAAqB,EAACJ,UAAoB,CAAC,IAAI,IAAAI,4BAAqB,EAACH,cAAwB,CAAC,IAAIC,KAAK,EAAE;AACnN,CAA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QAC7D,OAAO,CAACJ,GAAG,EAAEG,KAAK,CAACC,UAAU,CAAC,CAAC;MACnC;MAEA,OAAO,CAACJ,GAAG,EAAEG,KAAK,CAAC;IACvB,CAAC,CAAC,CAAC;IAEH,OAAO;MACH,CAACC,UAAU,GAAG;QACVT,SAAS,EAAEV,oBAAoB,CAAC4B,MAAM;MAC1C;IACJ,CAAC;EACL,CAAC,CAAC;EAEF,OAAO,IAAAE,wBAAgB,EAAC,GAAGL,gBAAgB,CAAC;AAChD,CAAC;AAAAM,OAAA,CAAAtB,YAAA,GAAAA,YAAA","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getFilterStyle = void 0;
7
+ var _utils = require("../../utils");
8
+ var _objectStyle = require("./objectStyle");
9
+ var _utils2 = require("../utils");
10
+ var _runtime = require("../../runtime");
11
+ var _mq = require("../../../mq");
12
+ const getDropShadowStyle = dropShadow => {
13
+ const {
14
+ offsetX = 0,
15
+ offsetY = 0,
16
+ standardDeviation = 0,
17
+ color = '#000'
18
+ } = dropShadow;
19
+ return `${(0, _utils2.normalizeColor)(String(color))} ${(0, _utils2.normalizeNumericValue)(offsetX)} ${(0, _utils2.normalizeNumericValue)(offsetY)} ${(0, _utils2.normalizeNumericValue)(standardDeviation)}`;
20
+ };
21
+ const getFilterStyle = filters => {
22
+ const restFilters = filters.filter(filter => Object.keys(filter)[0] !== 'dropShadow');
23
+ const dropShadow = (() => {
24
+ const dropShadowValue = filters.find(filter => Object.keys(filter)[0] === 'dropShadow')?.dropShadow;
25
+ if (typeof dropShadowValue !== 'object') {
26
+ return [];
27
+ }
28
+ const breakpoints = Object.keys(dropShadowValue).filter(key => Object.keys(_runtime.UnistylesRuntime.breakpoints).includes(key) || (0, _mq.isUnistylesMq)(key));
29
+ const breakpointsDropShadow = Object.fromEntries(breakpoints.map(breakpoint => [breakpoint, getDropShadowStyle(dropShadowValue[breakpoint])]));
30
+ if (breakpoints.length === 0) {
31
+ return [{
32
+ dropShadow: getDropShadowStyle(dropShadowValue)
33
+ }];
34
+ }
35
+ return [{
36
+ dropShadow: breakpointsDropShadow
37
+ }];
38
+ })();
39
+ return (0, _objectStyle.getObjectStyle)([...restFilters, ...dropShadow], 'filter', (key, value) => `${(0, _utils.hyphenate)(key)}(${(0, _utils2.normalizeNumericValue)(value)})`);
40
+ };
41
+ exports.getFilterStyle = getFilterStyle;
42
+ //# sourceMappingURL=filter.js.map