react-native-unistyles 3.0.0-alpha.7 → 3.0.0-alpha.9

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 (218) hide show
  1. package/cxx/common/Helpers.h +58 -0
  2. package/cxx/core/Unistyle.h +0 -6
  3. package/cxx/core/UnistyleData.h +3 -2
  4. package/cxx/core/UnistyleWrapper.h +6 -6
  5. package/cxx/core/UnistylesRegistry.cpp +11 -10
  6. package/cxx/core/UnistylesRegistry.h +4 -3
  7. package/cxx/hybridObjects/HybridShadowRegistry.cpp +4 -2
  8. package/cxx/parser/Parser.cpp +24 -78
  9. package/cxx/parser/Parser.h +1 -2
  10. package/lib/commonjs/specs/ShadowRegistry/index.js +2 -2
  11. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  12. package/lib/commonjs/specs/index.web.js +1 -1
  13. package/lib/commonjs/web/convert/boxShadow.js +77 -0
  14. package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
  15. package/lib/commonjs/web/convert/breakpoint.js +25 -0
  16. package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
  17. package/lib/commonjs/web/convert/index.js +76 -0
  18. package/lib/commonjs/web/convert/index.js.map +1 -0
  19. package/lib/commonjs/web/convert/module.d.js +2 -0
  20. package/lib/commonjs/web/convert/module.d.js.map +1 -0
  21. package/lib/commonjs/web/convert/shadow.js +68 -0
  22. package/lib/commonjs/web/convert/shadow.js.map +1 -0
  23. package/lib/commonjs/web/convert/style.js +89 -0
  24. package/lib/commonjs/web/convert/style.js.map +1 -0
  25. package/lib/commonjs/web/convert/textShadow.js +73 -0
  26. package/lib/commonjs/web/convert/textShadow.js.map +1 -0
  27. package/lib/commonjs/web/convert/transform.js +72 -0
  28. package/lib/commonjs/web/convert/transform.js.map +1 -0
  29. package/lib/commonjs/web/convert/types.js +9 -0
  30. package/lib/commonjs/web/convert/types.js.map +1 -0
  31. package/lib/commonjs/web/convert/utils.js +55 -0
  32. package/lib/commonjs/web/convert/utils.js.map +1 -0
  33. package/lib/commonjs/web/create.js +89 -0
  34. package/lib/commonjs/web/create.js.map +1 -0
  35. package/lib/commonjs/web/index.js +51 -0
  36. package/lib/commonjs/web/index.js.map +1 -0
  37. package/lib/commonjs/web/listener/index.js +13 -0
  38. package/lib/commonjs/web/listener/index.js.map +1 -0
  39. package/lib/commonjs/web/listener/listener.js +36 -0
  40. package/lib/commonjs/web/listener/listener.js.map +1 -0
  41. package/lib/commonjs/web/mock.js +37 -0
  42. package/lib/commonjs/web/mock.js.map +1 -0
  43. package/lib/commonjs/web/mq.js +23 -0
  44. package/lib/commonjs/web/mq.js.map +1 -0
  45. package/lib/commonjs/web/pseudo.js +11 -0
  46. package/lib/commonjs/web/pseudo.js.map +1 -0
  47. package/lib/commonjs/web/registry.js +37 -0
  48. package/lib/commonjs/web/registry.js.map +1 -0
  49. package/lib/commonjs/web/runtime.js +164 -0
  50. package/lib/commonjs/web/runtime.js.map +1 -0
  51. package/lib/commonjs/web/state.js +121 -0
  52. package/lib/commonjs/web/state.js.map +1 -0
  53. package/lib/commonjs/web/utils.js +78 -0
  54. package/lib/commonjs/web/utils.js.map +1 -0
  55. package/lib/commonjs/web/variants/getVariants.js +39 -0
  56. package/lib/commonjs/web/variants/getVariants.js.map +1 -0
  57. package/lib/commonjs/web/variants/index.js +28 -0
  58. package/lib/commonjs/web/variants/index.js.map +1 -0
  59. package/lib/commonjs/web/variants/useVariants.js +75 -0
  60. package/lib/commonjs/web/variants/useVariants.js.map +1 -0
  61. package/lib/module/specs/ShadowRegistry/index.js +2 -2
  62. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  63. package/lib/module/specs/index.web.js +1 -1
  64. package/lib/module/specs/index.web.js.map +1 -1
  65. package/lib/module/web/convert/boxShadow.js +72 -0
  66. package/lib/module/web/convert/boxShadow.js.map +1 -0
  67. package/lib/module/web/convert/breakpoint.js +20 -0
  68. package/lib/module/web/convert/breakpoint.js.map +1 -0
  69. package/lib/module/web/convert/index.js +71 -0
  70. package/lib/module/web/convert/index.js.map +1 -0
  71. package/lib/module/web/convert/module.d.js +2 -0
  72. package/lib/module/web/convert/module.d.js.map +1 -0
  73. package/lib/module/web/convert/shadow.js +63 -0
  74. package/lib/module/web/convert/shadow.js.map +1 -0
  75. package/lib/module/web/convert/style.js +84 -0
  76. package/lib/module/web/convert/style.js.map +1 -0
  77. package/lib/module/web/convert/textShadow.js +68 -0
  78. package/lib/module/web/convert/textShadow.js.map +1 -0
  79. package/lib/module/web/convert/transform.js +67 -0
  80. package/lib/module/web/convert/transform.js.map +1 -0
  81. package/lib/module/web/convert/types.js +5 -0
  82. package/lib/module/web/convert/types.js.map +1 -0
  83. package/lib/module/web/convert/utils.js +43 -0
  84. package/lib/module/web/convert/utils.js.map +1 -0
  85. package/lib/module/web/create.js +84 -0
  86. package/lib/module/web/create.js.map +1 -0
  87. package/lib/module/web/index.js +24 -0
  88. package/lib/module/web/index.js.map +1 -0
  89. package/lib/module/web/listener/index.js +4 -0
  90. package/lib/module/web/listener/index.js.map +1 -0
  91. package/lib/module/web/listener/listener.js +31 -0
  92. package/lib/module/web/listener/listener.js.map +1 -0
  93. package/lib/module/web/mock.js +33 -0
  94. package/lib/module/web/mock.js.map +1 -0
  95. package/lib/module/web/mq.js +17 -0
  96. package/lib/module/web/mq.js.map +1 -0
  97. package/lib/module/web/pseudo.js +6 -0
  98. package/lib/module/web/pseudo.js.map +1 -0
  99. package/lib/module/web/registry.js +33 -0
  100. package/lib/module/web/registry.js.map +1 -0
  101. package/lib/module/web/runtime.js +160 -0
  102. package/lib/module/web/runtime.js.map +1 -0
  103. package/lib/module/web/state.js +117 -0
  104. package/lib/module/web/state.js.map +1 -0
  105. package/lib/module/web/utils.js +65 -0
  106. package/lib/module/web/utils.js.map +1 -0
  107. package/lib/module/web/variants/getVariants.js +34 -0
  108. package/lib/module/web/variants/getVariants.js.map +1 -0
  109. package/lib/module/web/variants/index.js +5 -0
  110. package/lib/module/web/variants/index.js.map +1 -0
  111. package/lib/module/web/variants/useVariants.js +70 -0
  112. package/lib/module/web/variants/useVariants.js.map +1 -0
  113. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
  114. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  115. package/lib/typescript/src/specs/index.web.d.ts +1 -1
  116. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  117. package/lib/typescript/src/types/stylesheet.d.ts +1 -1
  118. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  119. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
  120. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
  121. package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
  122. package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
  123. package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
  124. package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
  125. package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
  126. package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
  127. package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
  128. package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
  129. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
  130. package/lib/typescript/{web → src/web}/create.d.ts +11 -11
  131. package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
  132. package/lib/typescript/{web → src/web}/index.d.ts +12 -12
  133. package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
  134. package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
  135. package/lib/typescript/{web → src/web}/listener/listener.d.ts +1 -1
  136. package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
  137. package/lib/typescript/{web → src/web}/mock.d.ts +2 -2
  138. package/lib/typescript/src/web/mock.d.ts.map +1 -0
  139. package/lib/typescript/src/web/mq.d.ts.map +1 -0
  140. package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
  141. package/lib/typescript/{web → src/web}/registry.d.ts +1 -1
  142. package/lib/typescript/src/web/registry.d.ts.map +1 -0
  143. package/lib/typescript/{web → src/web}/runtime.d.ts +6 -6
  144. package/lib/typescript/src/web/runtime.d.ts.map +1 -0
  145. package/lib/typescript/{web → src/web}/state.d.ts +4 -4
  146. package/lib/typescript/src/web/state.d.ts.map +1 -0
  147. package/lib/typescript/{web → src/web}/utils.d.ts +5 -3
  148. package/lib/typescript/src/web/utils.d.ts.map +1 -0
  149. package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
  150. package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
  151. package/lib/typescript/src/web/variants/index.d.ts +3 -0
  152. package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
  153. package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
  154. package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
  155. package/package.json +1 -1
  156. package/plugin/__tests__/dependencies.spec.js +5 -5
  157. package/plugin/__tests__/ref.spec.js +132 -17
  158. package/plugin/__tests__/stylesheet.spec.js +9 -9
  159. package/plugin/index.js +12 -13
  160. package/plugin/ref.js +18 -14
  161. package/plugin/style.js +13 -7
  162. package/src/specs/ShadowRegistry/index.ts +4 -4
  163. package/src/specs/index.web.ts +1 -1
  164. package/src/types/stylesheet.ts +1 -1
  165. package/{web → src/web}/convert/breakpoint.ts +1 -1
  166. package/{web → src/web}/convert/index.ts +1 -1
  167. package/{web → src/web}/convert/types.ts +1 -1
  168. package/{web → src/web}/create.ts +36 -33
  169. package/{web → src/web}/listener/listener.ts +1 -1
  170. package/{web → src/web}/mock.ts +2 -2
  171. package/{web → src/web}/registry.ts +1 -1
  172. package/{web → src/web}/runtime.ts +4 -4
  173. package/{web → src/web}/state.ts +5 -5
  174. package/{web → src/web}/utils.ts +5 -5
  175. package/src/web/variants/getVariants.ts +42 -0
  176. package/src/web/variants/index.ts +2 -0
  177. package/{web → src/web/variants}/useVariants.ts +24 -44
  178. package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
  179. package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
  180. package/lib/typescript/web/convert/index.d.ts.map +0 -1
  181. package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
  182. package/lib/typescript/web/convert/style.d.ts.map +0 -1
  183. package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
  184. package/lib/typescript/web/convert/transform.d.ts.map +0 -1
  185. package/lib/typescript/web/convert/types.d.ts.map +0 -1
  186. package/lib/typescript/web/convert/utils.d.ts.map +0 -1
  187. package/lib/typescript/web/listener/index.d.ts.map +0 -1
  188. package/lib/typescript/web/listener/listener.d.ts.map +0 -1
  189. package/lib/typescript/web/mock.d.ts.map +0 -1
  190. package/lib/typescript/web/mq.d.ts.map +0 -1
  191. package/lib/typescript/web/pseudo.d.ts.map +0 -1
  192. package/lib/typescript/web/registry.d.ts.map +0 -1
  193. package/lib/typescript/web/runtime.d.ts.map +0 -1
  194. package/lib/typescript/web/state.d.ts.map +0 -1
  195. package/lib/typescript/web/useVariants.d.ts +0 -3
  196. package/lib/typescript/web/useVariants.d.ts.map +0 -1
  197. package/lib/typescript/web/utils.d.ts.map +0 -1
  198. /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
  199. /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
  200. /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
  201. /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
  202. /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
  203. /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
  204. /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
  205. /package/lib/typescript/{web → src/web}/listener/index.d.ts +0 -0
  206. /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
  207. /package/lib/typescript/{web → src/web}/pseudo.d.ts +0 -0
  208. /package/{web → src/web}/convert/boxShadow.ts +0 -0
  209. /package/{web → src/web}/convert/module.d.ts +0 -0
  210. /package/{web → src/web}/convert/shadow.ts +0 -0
  211. /package/{web → src/web}/convert/style.ts +0 -0
  212. /package/{web → src/web}/convert/textShadow.ts +0 -0
  213. /package/{web → src/web}/convert/transform.ts +0 -0
  214. /package/{web → src/web}/convert/utils.ts +0 -0
  215. /package/{web → src/web}/index.ts +0 -0
  216. /package/{web → src/web}/listener/index.ts +0 -0
  217. /package/{web → src/web}/mq.ts +0 -0
  218. /package/{web → src/web}/pseudo.ts +0 -0
@@ -1,6 +1,8 @@
1
1
  #pragma once
2
2
 
3
3
  #include <jsi/jsi.h>
4
+ #include <jsi/JSIDynamic.h>
5
+ #include <folly/dynamic.h>
4
6
  #include <unordered_set>
5
7
 
6
8
  using namespace facebook;
@@ -114,4 +116,60 @@ inline Variants variantsToPairs(jsi::Runtime& rt, jsi::Object&& variants) {
114
116
  return pairs;
115
117
  }
116
118
 
119
+ inline std::vector<folly::dynamic> parseDynamicFunctionArguments(jsi::Runtime& rt, jsi::Array& arguments) {
120
+ std::vector<folly::dynamic> parsedArgument{};
121
+ size_t count = arguments.size(rt);
122
+
123
+ parsedArgument.reserve(count);
124
+
125
+ for (size_t i = 0; i < count; i++) {
126
+ jsi::Value arg = arguments.getValueAtIndex(rt, i);
127
+
128
+ if (arg.isBool()) {
129
+ parsedArgument.push_back(folly::dynamic(arg.asBool()));
130
+
131
+ continue;
132
+ }
133
+
134
+ if (arg.isNumber()) {
135
+ parsedArgument.push_back(folly::dynamic(arg.asNumber()));
136
+
137
+ continue;
138
+ }
139
+
140
+ if (arg.isString()) {
141
+ parsedArgument.push_back(folly::dynamic(arg.asString(rt).utf8(rt)));
142
+
143
+ continue;
144
+ }
145
+
146
+ if (arg.isUndefined()) {
147
+ parsedArgument.push_back(folly::dynamic());
148
+
149
+ continue;
150
+ }
151
+
152
+ if (arg.isNull()) {
153
+ parsedArgument.push_back(folly::dynamic(nullptr));
154
+
155
+ continue;
156
+ }
157
+
158
+ if (!arg.isObject()) {
159
+ continue;;
160
+ }
161
+
162
+ auto argObj = arg.asObject(rt);
163
+
164
+ // allow arrays and objects too
165
+ if (!argObj.isFunction(rt) && !argObj.isArrayBuffer(rt)) {
166
+ parsedArgument.push_back(jsi::dynamicFromValue(rt, arg));
167
+
168
+ continue;
169
+ }
170
+ }
171
+
172
+ return parsedArgument;
173
+ }
174
+
117
175
  }
@@ -14,11 +14,6 @@ enum class UnistyleType {
14
14
  DynamicFunction
15
15
  };
16
16
 
17
- struct DynamicFunctionMetadata {
18
- size_t count;
19
- std::vector<folly::dynamic> arguments;
20
- };
21
-
22
17
  struct Unistyle {
23
18
  using Shared = std::shared_ptr<Unistyle>;
24
19
 
@@ -75,7 +70,6 @@ struct UnistyleDynamicFunction: public Unistyle {
75
70
 
76
71
  std::optional<jsi::Object> unprocessedValue;
77
72
  std::optional<jsi::Function> proxiedFunction = std::nullopt;
78
- std::optional<DynamicFunctionMetadata> dynamicFunctionMetadata = std::nullopt;
79
73
  };
80
74
 
81
75
  }
@@ -8,8 +8,8 @@ namespace margelo::nitro::unistyles::core {
8
8
  using Variants = std::vector<std::pair<std::string, std::string>>;
9
9
 
10
10
  struct UnistyleData {
11
- UnistyleData(Unistyle::Shared unistyle, const Variants& variants)
12
- : unistyle{unistyle}, variants(std::move(variants)) {}
11
+ UnistyleData(Unistyle::Shared unistyle, const Variants& variants, std::vector<folly::dynamic>& arguments)
12
+ : unistyle{unistyle}, variants(std::move(variants)), dynamicFunctionMetadata{std::move(arguments)} {}
13
13
 
14
14
  UnistyleData(const UnistyleData&) = delete;
15
15
  UnistyleData(UnistyleData&& other): unistyle{other.unistyle}, variants(std::move(other.variants)) {}
@@ -17,6 +17,7 @@ struct UnistyleData {
17
17
  core::Unistyle::Shared unistyle;
18
18
  core::Variants variants;
19
19
  std::optional<jsi::Object> parsedStyle = std::nullopt;
20
+ std::optional<std::vector<folly::dynamic>> dynamicFunctionMetadata = std::nullopt;
20
21
  };
21
22
 
22
23
  }
@@ -26,24 +26,24 @@ inline static Unistyle::Shared unistyleFromValue(jsi::Runtime& rt, const jsi::Va
26
26
 
27
27
  inline static jsi::Value valueFromUnistyle(jsi::Runtime& rt, Unistyle::Shared unistyle) {
28
28
  auto wrappedUnistyle = std::make_shared<UnistyleWrapper>(unistyle);
29
-
29
+
30
30
  if (unistyle->type == UnistyleType::Object) {
31
31
  jsi::Object obj = jsi::Object(rt);
32
-
32
+
33
33
  obj.setNativeState(rt, std::move(wrappedUnistyle));
34
34
  helpers::defineHiddenProperty(rt, obj, helpers::UNISTYLES_ID.c_str(), unistyle->styleKey);
35
-
35
+
36
36
  helpers::mergeJSIObjects(rt, obj, unistyle->parsedStyle.value());
37
-
37
+
38
38
  return obj;
39
39
  }
40
-
40
+
41
41
  auto unistyleFn = std::dynamic_pointer_cast<UnistyleDynamicFunction>(unistyle);
42
42
  auto hostFn = jsi::Value(rt, unistyleFn->proxiedFunction.value()).asObject(rt).asFunction(rt);
43
43
 
44
44
  hostFn.setNativeState(rt, std::move(wrappedUnistyle));
45
45
  hostFn.setProperty(rt, helpers::UNISTYLES_ID.c_str(), unistyleFn->styleKey);
46
-
46
+
47
47
  return std::move(hostFn);
48
48
  }
49
49
 
@@ -74,19 +74,20 @@ void core::UnistylesRegistry::updateTheme(jsi::Runtime& rt, std::string& themeNa
74
74
  void core::UnistylesRegistry::linkShadowNodeWithUnistyle(
75
75
  const ShadowNodeFamily* shadowNodeFamily,
76
76
  const core::Unistyle::Shared unistyle,
77
- Variants& variants
77
+ Variants& variants,
78
+ std::vector<folly::dynamic>& arguments
78
79
  ) {
79
80
  if (!this->_shadowRegistry.contains(shadowNodeFamily)) {
80
81
  this->_shadowRegistry[shadowNodeFamily] = {};
81
82
  }
82
83
 
83
- this->_shadowRegistry[shadowNodeFamily].emplace_back(std::make_pair(unistyle, std::move(variants)));
84
+ this->_shadowRegistry[shadowNodeFamily].emplace_back(std::make_shared<UnistyleData>(unistyle, variants, arguments));
84
85
  }
85
86
 
86
87
  void core::UnistylesRegistry::unlinkShadowNodeWithUnistyle(const ShadowNodeFamily* shadowNodeFamily, const core::Unistyle::Shared unistyle) {
87
88
  auto& unistylesVec = this->_shadowRegistry[shadowNodeFamily];
88
- auto it = std::find_if(unistylesVec.begin(), unistylesVec.end(), [unistyle](std::pair<core::Unistyle::Shared, Variants> pair){
89
- return pair.first == unistyle;
89
+ auto it = std::find_if(unistylesVec.begin(), unistylesVec.end(), [unistyle](std::shared_ptr<UnistyleData> unistyleData){
90
+ return unistyleData->unistyle == unistyle;
90
91
  });
91
92
 
92
93
  if (it != unistylesVec.end()) {
@@ -124,12 +125,12 @@ core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt
124
125
  for (const auto& pair : this->_shadowRegistry) {
125
126
  const auto& [family, unistyles] = pair;
126
127
 
127
- for (const auto& [shadowUnistyle, variants] : unistyles) {
128
- if (unistyle != shadowUnistyle) {
128
+ for (const auto& unistyleData : unistyles) {
129
+ if (unistyle != unistyleData->unistyle) {
129
130
  continue;
130
131
  }
131
132
 
132
- dependencyMap[styleSheet][family].emplace_back(unistyle, variants);
133
+ dependencyMap[styleSheet][family].emplace_back(unistyleData);
133
134
  }
134
135
  }
135
136
  }
@@ -146,12 +147,12 @@ core::DependencyMap core::UnistylesRegistry::buildDependencyMap(jsi::Runtime& rt
146
147
  for (const auto& pair : this->_shadowRegistry) {
147
148
  const auto& [family, unistyles] = pair;
148
149
 
149
- for (const auto& [shadowUnistyle, variants] : unistyles) {
150
- if (unistyle != shadowUnistyle) {
150
+ for (const auto& unistyleData : unistyles) {
151
+ if (unistyle != unistyleData->unistyle) {
151
152
  continue;
152
153
  }
153
154
 
154
- dependencyMap[styleSheet][family].emplace_back(unistyle, variants);
155
+ dependencyMap[styleSheet][family].emplace_back(unistyleData);
155
156
  }
156
157
  }
157
158
  }
@@ -2,6 +2,7 @@
2
2
 
3
3
  #include "set"
4
4
  #include <jsi/jsi.h>
5
+ #include <folly/dynamic.h>
5
6
  #include <react/renderer/uimanager/UIManager.h>
6
7
  #include <unordered_map>
7
8
  #include <unordered_set>
@@ -20,7 +21,7 @@ using namespace facebook::react;
20
21
 
21
22
  using DependencyMap = std::unordered_map<
22
23
  std::shared_ptr<core::StyleSheet>,
23
- std::unordered_map<const ShadowNodeFamily*, std::vector<UnistyleData>>
24
+ std::unordered_map<const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>>
24
25
  >;
25
26
 
26
27
  struct UnistylesRegistry: public StyleSheetRegistry {
@@ -37,7 +38,7 @@ struct UnistylesRegistry: public StyleSheetRegistry {
37
38
 
38
39
  UnistylesState& getState(jsi::Runtime& rt);
39
40
  void createState(jsi::Runtime& rt);
40
- void linkShadowNodeWithUnistyle(const ShadowNodeFamily*, const core::Unistyle::Shared, Variants& variants);
41
+ void linkShadowNodeWithUnistyle(const ShadowNodeFamily*, const core::Unistyle::Shared, Variants& variants, std::vector<folly::dynamic>&);
41
42
  void unlinkShadowNodeWithUnistyle(const ShadowNodeFamily*, const core::Unistyle::Shared);
42
43
  std::shared_ptr<core::StyleSheet> addStyleSheet(jsi::Runtime& rt, int tag, core::StyleSheetType type, jsi::Object&& rawValue);
43
44
  DependencyMap buildDependencyMap(jsi::Runtime& rt, std::vector<UnistyleDependency>& deps);
@@ -48,7 +49,7 @@ private:
48
49
 
49
50
  std::unordered_map<jsi::Runtime*, UnistylesState> _states{};
50
51
  std::unordered_map<jsi::Runtime*, std::unordered_map<int, std::shared_ptr<core::StyleSheet>>> _styleSheetRegistry{};
51
- std::unordered_map<const ShadowNodeFamily*, std::vector<std::pair<core::Unistyle::Shared, Variants>>> _shadowRegistry{};
52
+ std::unordered_map<const ShadowNodeFamily*, std::vector<std::shared_ptr<UnistyleData>>> _shadowRegistry{};
52
53
  };
53
54
 
54
55
  UnistylesRegistry& UnistylesRegistry::get() {
@@ -4,15 +4,17 @@ using namespace margelo::nitro::unistyles;
4
4
  using namespace facebook::react;
5
5
 
6
6
  jsi::Value HybridShadowRegistry::link(jsi::Runtime &rt, const jsi::Value &thisValue, const jsi::Value *args, size_t count) {
7
- helpers::assertThat(rt, count == 3, "Unistyles: Invalid babel transform 'ShadowRegistry link' expected 3 arguments.");
7
+ helpers::assertThat(rt, count == 4, "Unistyles: Invalid babel transform 'ShadowRegistry link' expected 4 arguments.");
8
8
 
9
9
  ShadowNode::Shared shadowNodeWrapper = shadowNodeFromValue(rt, args[0]);
10
10
  core::Unistyle::Shared unistyleWrapper = core::unistyleFromValue(rt, args[1]);
11
11
  core::Variants variants = helpers::variantsToPairs(rt, args[2].asObject(rt));
12
+ auto rawArguments = args[3].asObject(rt).asArray(rt);
13
+ std::vector<folly::dynamic> arguments = helpers::parseDynamicFunctionArguments(rt, rawArguments);
12
14
 
13
15
  auto& registry = core::UnistylesRegistry::get();
14
16
 
15
- registry.linkShadowNodeWithUnistyle(&shadowNodeWrapper->getFamily(), unistyleWrapper, variants);
17
+ registry.linkShadowNodeWithUnistyle(&shadowNodeWrapper->getFamily(), unistyleWrapper, variants, arguments);
16
18
 
17
19
  return jsi::Value::undefined();
18
20
  }
@@ -91,7 +91,8 @@ void parser::Parser::rebuildUnistylesWithVariants(jsi::Runtime& rt, std::shared_
91
91
  continue;
92
92
  }
93
93
 
94
- this->rebuildUnistyle(rt, styleSheet, unistyle, variants);
94
+ // todo skip dynamic functions
95
+ this->rebuildUnistyle(rt, styleSheet, unistyle, variants, std::nullopt);
95
96
  }
96
97
  }
97
98
 
@@ -101,22 +102,24 @@ void parser::Parser::rebuildUnistylesInDependencyMap(jsi::Runtime& rt, Dependenc
101
102
  jsi::Object unwrappedStyleSheet = this->unwrapStyleSheet(rt, styleSheet);
102
103
 
103
104
  for (auto& [shadowNode, unistyles] : map) {
104
- for (auto& [unistyle, variants, parsedStyle] : unistyles) {
105
+ for (auto& unistyleData : unistyles) {
106
+ auto& unistyle = unistyleData->unistyle;
107
+
105
108
  // StyleSheet might have styles that are not affected
106
109
  if (!unwrappedStyleSheet.hasProperty(rt, unistyle->styleKey.c_str())) {
107
110
  continue;
108
111
  }
109
112
 
110
113
  unistyle->rawValue = unwrappedStyleSheet.getProperty(rt, unistyle->styleKey.c_str()).asObject(rt);
111
- this->rebuildUnistyle(rt, styleSheet, unistyle, variants);
112
- parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
114
+ this->rebuildUnistyle(rt, styleSheet, unistyle, unistyleData->variants, unistyleData->dynamicFunctionMetadata);
115
+ unistyleData->parsedStyle = jsi::Value(rt, unistyle->parsedStyle.value()).asObject(rt);
113
116
  }
114
117
  }
115
118
  }
116
119
  }
117
120
 
118
121
  // rebuild single unistyle
119
- void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants) {
122
+ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants, std::optional<std::vector<folly::dynamic>> metadata) {
120
123
  if (unistyle->type == core::UnistyleType::Object) {
121
124
  auto result = this->parseFirstLevel(rt, unistyle, variants);
122
125
 
@@ -125,20 +128,17 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleShee
125
128
 
126
129
  // for functions we need to call memoized function
127
130
  // with last know arguments and parse it with new theme and mini runtime
128
- if (unistyle->type == core::UnistyleType::DynamicFunction) {
131
+ if (unistyle->type == core::UnistyleType::DynamicFunction && metadata.has_value()) {
129
132
  auto unistyleFn = std::dynamic_pointer_cast<UnistyleDynamicFunction>(unistyle);
130
- auto maybeMetadata = unistyleFn->dynamicFunctionMetadata;
131
-
132
- helpers::assertThat(rt, maybeMetadata.has_value(), "Unistyles: Your dynamic function '" + unistyleFn->styleKey + "' has no metadata and can't be processed.");
133
133
 
134
134
  // convert arguments to jsi::Value
135
- auto metadata = unistyleFn->dynamicFunctionMetadata.value();
135
+ auto dynamicFunctionMetadata = metadata.value();
136
136
  std::vector<jsi::Value> args{};
137
137
 
138
- args.reserve(3);
138
+ args.reserve(dynamicFunctionMetadata.size());
139
139
 
140
- for (int i = 0; i < metadata.count; i++) {
141
- folly::dynamic& arg = metadata.arguments.at(i);
140
+ for (int i = 0; i < dynamicFunctionMetadata.size(); i++) {
141
+ folly::dynamic& arg = dynamicFunctionMetadata.at(i);
142
142
 
143
143
  args.emplace_back(jsi::valueFromDynamic(rt, arg));
144
144
  }
@@ -146,7 +146,7 @@ void parser::Parser::rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleShee
146
146
  const jsi::Value *argStart = args.data();
147
147
 
148
148
  // call cached function with memoized arguments
149
- auto functionResult = unistyleFn->proxiedFunction.value().callAsConstructor(rt, argStart, metadata.count).asObject(rt);
149
+ auto functionResult = unistyleFn->proxiedFunction.value().callAsConstructor(rt, argStart, dynamicFunctionMetadata.size()).asObject(rt);
150
150
 
151
151
  unistyleFn->unprocessedValue = std::move(functionResult);
152
152
  unistyleFn->parsedStyle = this->parseFirstLevel(rt, unistyleFn, variants);
@@ -160,9 +160,9 @@ shadow::ShadowLeafUpdates parser::Parser::dependencyMapToShadowLeafUpdates(core:
160
160
 
161
161
  for (const auto& [styleSheet, map] : dependencyMap) {
162
162
  for (const auto& [shadowNode, unistyles] : map) {
163
- for (const auto& [unistyle, variants, parsedStyle] : unistyles) {
164
- auto rawProps = this->parseStylesToShadowTreeStyles(rt, parsedStyle.value());
165
-
163
+ for (const auto& unistyleData : unistyles) {
164
+ auto rawProps = this->parseStylesToShadowTreeStyles(rt, unistyleData->parsedStyle.value());
165
+
166
166
  if (updates.contains(shadowNode)) {
167
167
  updates[shadowNode].emplace_back(std::move(rawProps));
168
168
 
@@ -177,62 +177,6 @@ shadow::ShadowLeafUpdates parser::Parser::dependencyMapToShadowLeafUpdates(core:
177
177
  return updates;
178
178
  }
179
179
 
180
- // convert jsi::Value arguments to folly::dynamic
181
- std::vector<folly::dynamic> parser::Parser::parseDynamicFunctionArguments(jsi::Runtime& rt, size_t count, const jsi::Value* arguments) {
182
- std::vector<folly::dynamic> parsedArgument{};
183
-
184
- parsedArgument.reserve(3);
185
-
186
- for (size_t i = 0; i < count; i++) {
187
- auto& arg = arguments[i];
188
-
189
- if (arg.isBool()) {
190
- parsedArgument.push_back(folly::dynamic(arg.asBool()));
191
-
192
- continue;
193
- }
194
-
195
- if (arg.isNumber()) {
196
- parsedArgument.push_back(folly::dynamic(arg.asNumber()));
197
-
198
- continue;
199
- }
200
-
201
- if (arg.isString()) {
202
- parsedArgument.push_back(folly::dynamic(arg.asString(rt).utf8(rt)));
203
-
204
- continue;
205
- }
206
-
207
- if (arg.isUndefined()) {
208
- parsedArgument.push_back(folly::dynamic());
209
-
210
- continue;
211
- }
212
-
213
- if (arg.isNull()) {
214
- parsedArgument.push_back(folly::dynamic(nullptr));
215
-
216
- continue;
217
- }
218
-
219
- if (!arg.isObject()) {
220
- continue;;
221
- }
222
-
223
- auto argObj = arg.asObject(rt);
224
-
225
- // allow arrays and objects too
226
- if (!argObj.isFunction(rt) && !argObj.isArrayBuffer(rt)) {
227
- parsedArgument.push_back(jsi::dynamicFromValue(rt, arg));
228
-
229
- continue;
230
- }
231
- }
232
-
233
- return parsedArgument;
234
- }
235
-
236
180
  // first level of StyleSheet, we can expect here different properties than on second level
237
181
  // eg. variants, compoundVariants, mq, breakpoints etc.
238
182
  jsi::Object parser::Parser::parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, std::optional<Variants> variants) {
@@ -352,13 +296,15 @@ jsi::Function parser::Parser::createDynamicFunctionProxy(jsi::Runtime& rt, Unist
352
296
 
353
297
  // memoize metadata to call it later
354
298
  auto unistyleFn = std::dynamic_pointer_cast<UnistyleDynamicFunction>(unistyle);
299
+ jsi::Array arguments = jsi::Array(rt, count);
355
300
 
356
- unistyleFn->dynamicFunctionMetadata = core::DynamicFunctionMetadata{
357
- count,
358
- this->parseDynamicFunctionArguments(rt, count, args)
359
- };
301
+ for (size_t i = 0; i < count; i++) {
302
+ arguments.setValueAtIndex(rt, i, args[i]);
303
+ }
360
304
 
361
305
  unistyleFn->unprocessedValue = jsi::Value(rt, result).asObject(rt);
306
+
307
+ // todo pass here variants
362
308
  unistyleFn->parsedStyle = this->parseFirstLevel(rt, unistyleFn, std::nullopt);
363
309
  unistyleFn->seal();
364
310
 
@@ -532,7 +478,7 @@ jsi::Value parser::Parser::getStylesForVariant(jsi::Runtime& rt, const std::stri
532
478
  ? selectedVariant.value().c_str()
533
479
  : "default";
534
480
  auto hasKey = groupValue.hasProperty(rt, selectedVariantKey);
535
-
481
+
536
482
  if (hasKey && !selectedVariant.has_value()) {
537
483
  // add 'default' selection to variants map
538
484
  variants.emplace_back(groupName, selectedVariantKey);
@@ -28,12 +28,11 @@ struct Parser {
28
28
  shadow::ShadowLeafUpdates dependencyMapToShadowLeafUpdates(core::DependencyMap& dependencyMap);
29
29
 
30
30
  private:
31
- void rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants);
31
+ void rebuildUnistyle(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet, Unistyle::Shared unistyle, const Variants& variants, std::optional<std::vector<folly::dynamic>>);
32
32
  jsi::Object unwrapStyleSheet(jsi::Runtime& rt, std::shared_ptr<StyleSheet> styleSheet);
33
33
  jsi::Object parseFirstLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, std::optional<Variants> variants);
34
34
  jsi::Value parseSecondLevel(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Value& nestedObject);
35
35
  jsi::Function createDynamicFunctionProxy(jsi::Runtime& rt, Unistyle::Shared unistyle);
36
- std::vector<folly::dynamic> parseDynamicFunctionArguments(jsi::Runtime& rt, size_t count, const jsi::Value* arguments);
37
36
  std::vector<UnistyleDependency> parseDependencies(jsi::Runtime &rt, jsi::Object&& dependencies);
38
37
  jsi::Value parseTransforms(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
39
38
  jsi::Value getValueFromBreakpoints(jsi::Runtime& rt, Unistyle::Shared unistyle, jsi::Object& obj);
@@ -14,11 +14,11 @@ const findShadowNodeForHandle = handle => {
14
14
  }
15
15
  return node;
16
16
  };
17
- HybridShadowRegistry.add = (handle, style, variants) => {
17
+ HybridShadowRegistry.add = (handle, style, variants, args) => {
18
18
  if (!handle || !style?.__unid) {
19
19
  return;
20
20
  }
21
- HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {});
21
+ HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? []);
22
22
  };
23
23
  HybridShadowRegistry.remove = (handle, style) => {
24
24
  if (!handle || !style?.__unid) {
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","__unid","link","remove","unlink","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAaA,MAAMC,oBAAoB,GAAGC,qCAAY,CAACC,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDL,oBAAoB,CAACW,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,KAAK;EACpD,IAAI,CAACT,MAAM,IAAI,CAACQ,KAAK,EAAEE,MAAM,EAAE;IAC3B;EACJ;EAEAd,oBAAoB,CAACe,IAAI,CAACZ,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,CAAC;AACrF,CAAC;AAEDb,oBAAoB,CAACgB,MAAM,GAAG,CAACZ,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEE,MAAM,EAAE;IAC3B;EACJ;EAEAd,oBAAoB,CAACiB,MAAM,CAACd,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQM,MAAMM,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGlB,oBAA4D","ignoreList":[]}
1
+ {"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","style","variants","args","__unid","link","remove","unlink","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAaA,MAAMC,oBAAoB,GAAGC,qCAAY,CAACC,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP;IACA,MAAM,IAAIK,KAAK,CAAC,uDAAuD,CAAC;EAC5E;EAEA,OAAOL,IAAI;AACf,CAAC;AAEDL,oBAAoB,CAACW,GAAG,GAAG,CAACP,MAAM,EAAEQ,KAAK,EAAEC,QAAQ,EAAEC,IAAI,KAAK;EAC1D,IAAI,CAACV,MAAM,IAAI,CAACQ,KAAK,EAAEG,MAAM,EAAE;IAC3B;EACJ;EAEAf,oBAAoB,CAACgB,IAAI,CAACb,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,EAAEC,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,CAAC;AACjG,CAAC;AAEDd,oBAAoB,CAACiB,MAAM,GAAG,CAACb,MAAM,EAAEQ,KAAK,KAAK;EAC7C,IAAI,CAACR,MAAM,IAAI,CAACQ,KAAK,EAAEG,MAAM,EAAE;IAC3B;EACJ;EAEAf,oBAAoB,CAACkB,MAAM,CAACf,uBAAuB,CAACC,MAAM,CAAC,EAAEQ,KAAK,CAAC;AACvE,CAAC;AAQM,MAAMO,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAGnB,oBAA4D","ignoreList":[]}
@@ -7,7 +7,7 @@ var _exportNames = {
7
7
  getSSRUnistyles: true
8
8
  };
9
9
  exports.getSSRUnistyles = void 0;
10
- var _web = require("../../web");
10
+ var _web = require("../web");
11
11
  Object.keys(_web).forEach(function (key) {
12
12
  if (key === "default" || key === "__esModule") return;
13
13
  if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getBoxShadowStyle = void 0;
7
+ var _typestyle = require("typestyle");
8
+ var _utils = require("../utils");
9
+ var _shadow = require("./shadow");
10
+ var _breakpoint = require("./breakpoint");
11
+ var _types = require("./types");
12
+ var _utils2 = require("./utils");
13
+ const createBoxShadowValue = style => {
14
+ // at this point every prop is present
15
+ const {
16
+ shadowColor,
17
+ shadowOffset,
18
+ shadowOpacity,
19
+ shadowRadius
20
+ } = style;
21
+ const offsetX = (0, _utils2.normalizeNumericValue)(shadowOffset.width);
22
+ const offsetY = (0, _utils2.normalizeNumericValue)(shadowOffset.height);
23
+ const radius = (0, _utils2.normalizeNumericValue)(shadowRadius);
24
+ const color = (0, _utils2.normalizeColor)(shadowColor, shadowOpacity);
25
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
26
+ };
27
+ const getBoxShadowStyle = styles => {
28
+ const missingStyles = _types.BOX_SHADOW_STYLES.filter(key => !(key in styles));
29
+ if (missingStyles.length) {
30
+ (0, _utils.warn)(`can't apply box shadow as you miss these properties: ${missingStyles.join(', ')}`);
31
+ return {};
32
+ }
33
+ const breakpointsSet = new Set();
34
+ try {
35
+ (0, _shadow.validateShadow)(_types.BOX_SHADOW_STYLES, styles, breakpointsSet);
36
+ } catch (error) {
37
+ if (typeof error === 'string') {
38
+ (0, _utils.warn)(error);
39
+ }
40
+ return {};
41
+ }
42
+ const breakpoints = Array.from(breakpointsSet);
43
+
44
+ // If no breakpoints were used return styles without media queries
45
+ if (breakpoints.length === 0) {
46
+ return {
47
+ boxShadow: createBoxShadowValue(styles)
48
+ };
49
+ }
50
+
51
+ // Create boxShadow for each breakpoint
52
+ const breakpointStyles = breakpoints.map(breakpoint => {
53
+ const color = (0, _utils2.extractShadowValue)('shadowColor', breakpoint, styles);
54
+ const {
55
+ width,
56
+ height
57
+ } = (0, _utils2.extractShadowValue)('shadowOffset', breakpoint, styles);
58
+ const radius = (0, _utils2.extractShadowValue)('shadowRadius', breakpoint, styles);
59
+ const opacity = (0, _utils2.extractShadowValue)('shadowOpacity', breakpoint, styles);
60
+ return (0, _typestyle.media)((0, _breakpoint.convertBreakpoint)(breakpoint), {
61
+ boxShadow: createBoxShadowValue({
62
+ shadowColor: color,
63
+ shadowOffset: {
64
+ width,
65
+ height
66
+ },
67
+ shadowRadius: radius,
68
+ shadowOpacity: opacity
69
+ })
70
+ });
71
+ });
72
+
73
+ // Merge all breakpoints styles into one
74
+ return (0, _utils.deepMergeObjects)(...breakpointStyles);
75
+ };
76
+ exports.getBoxShadowStyle = getBoxShadowStyle;
77
+ //# sourceMappingURL=boxShadow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_typestyle","require","_utils","_shadow","_breakpoint","_types","_utils2","createBoxShadowValue","style","shadowColor","shadowOffset","shadowOpacity","shadowRadius","offsetX","normalizeNumericValue","width","offsetY","height","radius","color","normalizeColor","getBoxShadowStyle","styles","missingStyles","BOX_SHADOW_STYLES","filter","key","length","warn","join","breakpointsSet","Set","validateShadow","error","breakpoints","Array","from","boxShadow","breakpointStyles","map","breakpoint","extractShadowValue","opacity","media","convertBreakpoint","deepMergeObjects","exports"],"sourceRoot":"../../../../src","sources":["web/convert/boxShadow.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AACA,IAAAI,MAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAEA,MAAMM,oBAAoB,GAAIC,KAAgB,IAAK;EAC/C;EACA,MAAM;IAAEC,WAAW;IAAEC,YAAY;IAAEC,aAAa;IAAEC;EAAa,CAAC,GAAGJ,KAAK;EACxE,MAAMK,OAAO,GAAG,IAAAC,6BAAqB,EAACJ,YAAY,CAACK,KAAK,CAAC;EACzD,MAAMC,OAAO,GAAG,IAAAF,6BAAqB,EAACJ,YAAY,CAACO,MAAM,CAAC;EAC1D,MAAMC,MAAM,GAAG,IAAAJ,6BAAqB,EAACF,YAAY,CAAC;EAClD,MAAMO,KAAK,GAAG,IAAAC,sBAAc,EAACX,WAAW,EAAYE,aAAuB,CAAC;EAE5E,OAAO,GAAGE,OAAO,IAAIG,OAAO,IAAIE,MAAM,IAAIC,KAAK,EAAE;AACrD,CAAC;AAEM,MAAME,iBAAiB,GAAIC,MAA2B,IAA0B;EACnF,MAAMC,aAAa,GAAGC,wBAAiB,CAACC,MAAM,CAACC,GAAG,IAAI,EAAEA,GAAG,IAAIJ,MAAM,CAAC,CAAC;EAEvE,IAAIC,aAAa,CAACI,MAAM,EAAE;IACtB,IAAAC,WAAI,EAAC,wDAAwDL,aAAa,CAACM,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAExF,OAAO,CAAC,CAAC;EACb;EAEA,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAS,CAAC;EAExC,IAAI;IACA,IAAAC,sBAAc,EAACR,wBAAiB,EAAEF,MAAM,EAAEQ,cAAc,CAAC;EAC7D,CAAC,CAAC,OAAOG,KAAK,EAAE;IACZ,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;MAC3B,IAAAL,WAAI,EAACK,KAAK,CAAC;IACf;IAEA,OAAO,CAAC,CAAC;EACb;EAEA,MAAMC,WAAW,GAAGC,KAAK,CAACC,IAAI,CAACN,cAAc,CAAC;;EAE9C;EACA,IAAII,WAAW,CAACP,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAO;MACHU,SAAS,EAAE9B,oBAAoB,CAACe,MAAmB;IACvD,CAAC;EACL;;EAEA;EACA,MAAMgB,gBAAgB,GAAGJ,WAAW,CAACK,GAAG,CAACC,UAAU,IAAI;IACnD,MAAMrB,KAAK,GAAG,IAAAsB,0BAAkB,EAAC,aAAa,EAAED,UAAU,EAAElB,MAAM,CAAC;IACnE,MAAM;MAAEP,KAAK;MAAEE;IAAO,CAAC,GAAG,IAAAwB,0BAAkB,EAAC,cAAc,EAAED,UAAU,EAAElB,MAAM,CAAC;IAChF,MAAMJ,MAAM,GAAG,IAAAuB,0BAAkB,EAAC,cAAc,EAAED,UAAU,EAAElB,MAAM,CAAC;IACrE,MAAMoB,OAAO,GAAG,IAAAD,0BAAkB,EAAC,eAAe,EAAED,UAAU,EAAElB,MAAM,CAAC;IAEvE,OAAO,IAAAqB,gBAAK,EAAC,IAAAC,6BAAiB,EAACJ,UAAU,CAAC,EAAE;MACxCH,SAAS,EAAE9B,oBAAoB,CAAC;QAC5BE,WAAW,EAAEU,KAAK;QAClBT,YAAY,EAAE;UACVK,KAAK;UACLE;QACJ,CAAC;QACDL,YAAY,EAAEM,MAAM;QACpBP,aAAa,EAAE+B;MACnB,CAAC;IACL,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;EACA,OAAO,IAAAG,uBAAgB,EAAC,GAAGP,gBAAgB,CAAC;AAChD,CAAC;AAAAQ,OAAA,CAAAzB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.convertBreakpoint = void 0;
7
+ var _state = require("../state");
8
+ var _utils = require("../utils");
9
+ var _mq = require("../mq");
10
+ var _types = require("../../specs/types");
11
+ const convertBreakpoint = breakpoint => {
12
+ if (Object.values(_types.Orientation).includes(breakpoint)) {
13
+ return {
14
+ orientation: breakpoint
15
+ };
16
+ }
17
+ if ((0, _mq.isUnistylesMq)(breakpoint)) {
18
+ return (0, _mq.parseMq)(breakpoint);
19
+ }
20
+ return {
21
+ minWidth: _state.UnistylesState.breakpoints && (0, _utils.keyInObject)(_state.UnistylesState.breakpoints, breakpoint) ? _state.UnistylesState.breakpoints[breakpoint] : undefined
22
+ };
23
+ };
24
+ exports.convertBreakpoint = convertBreakpoint;
25
+ //# sourceMappingURL=breakpoint.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_state","require","_utils","_mq","_types","convertBreakpoint","breakpoint","Object","values","Orientation","includes","orientation","isUnistylesMq","parseMq","minWidth","UnistylesState","breakpoints","keyInObject","undefined","exports"],"sourceRoot":"../../../../src","sources":["web/convert/breakpoint.ts"],"mappings":";;;;;;AACA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,GAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEO,MAAMI,iBAAiB,GAAIC,UAAkB,IAAiB;EACjE,IAAIC,MAAM,CAACC,MAAM,CAACC,kBAAW,CAAC,CAACC,QAAQ,CAACJ,UAAyB,CAAC,EAAE;IAChE,OAAO;MACHK,WAAW,EAAEL;IACjB,CAAC;EACL;EAEA,IAAI,IAAAM,iBAAa,EAACN,UAAU,CAAC,EAAE;IAC3B,OAAO,IAAAO,WAAO,EAACP,UAAU,CAAC;EAC9B;EAEA,OAAO;IACHQ,QAAQ,EAAEC,qBAAc,CAACC,WAAW,IAAI,IAAAC,kBAAW,EAACF,qBAAc,CAACC,WAAW,EAAEV,UAAU,CAAC,GAAGS,qBAAc,CAACC,WAAW,CAACV,UAAU,CAAC,GAAGY;EAC3I,CAAC;AACL,CAAC;AAAAC,OAAA,CAAAd,iBAAA,GAAAA,iBAAA","ignoreList":[]}