react-native-unistyles 3.0.0-alpha.2 → 3.0.0-alpha.20

Sign up to get free protection for your applications and to get access to all the features.
Files changed (316) hide show
  1. package/Unistyles.podspec +3 -2
  2. package/cxx/common/Constants.h +2 -0
  3. package/cxx/common/Helpers.h +97 -5
  4. package/cxx/core/HostStyle.cpp +19 -13
  5. package/cxx/core/HostStyle.h +4 -0
  6. package/cxx/core/StyleSheet.h +0 -2
  7. package/cxx/core/StyleSheetRegistry.cpp +10 -13
  8. package/cxx/core/StyleSheetRegistry.h +4 -4
  9. package/cxx/core/Unistyle.h +7 -10
  10. package/cxx/core/UnistyleData.h +23 -0
  11. package/cxx/core/UnistyleWrapper.h +78 -10
  12. package/cxx/core/UnistylesCommitHook.cpp +22 -13
  13. package/cxx/core/UnistylesCommitHook.h +8 -1
  14. package/cxx/core/UnistylesCommitShadowNode.h +13 -0
  15. package/cxx/core/UnistylesMountHook.cpp +37 -0
  16. package/cxx/core/UnistylesMountHook.h +31 -0
  17. package/cxx/core/UnistylesRegistry.cpp +56 -81
  18. package/cxx/core/UnistylesRegistry.h +15 -13
  19. package/cxx/core/UnistylesState.cpp +14 -8
  20. package/cxx/core/UnistylesState.h +1 -0
  21. package/cxx/hybridObjects/HybridShadowRegistry.cpp +15 -9
  22. package/cxx/hybridObjects/HybridStyleSheet.cpp +43 -38
  23. package/cxx/hybridObjects/HybridStyleSheet.h +10 -7
  24. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +35 -16
  25. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
  26. package/cxx/parser/Parser.cpp +105 -164
  27. package/cxx/parser/Parser.h +8 -14
  28. package/cxx/shadowTree/ShadowLeafUpdate.h +1 -1
  29. package/cxx/shadowTree/ShadowTrafficController.h +33 -0
  30. package/cxx/shadowTree/ShadowTreeManager.cpp +13 -11
  31. package/cxx/shadowTree/ShadowTreeManager.h +1 -0
  32. package/ios/Unistyles.h +1 -0
  33. package/ios/UnistylesModuleOnLoad.h +2 -0
  34. package/ios/UnistylesModuleOnLoad.mm +8 -1
  35. package/lib/commonjs/index.js +4 -0
  36. package/lib/commonjs/index.js.map +1 -1
  37. package/lib/commonjs/specs/NavigtionBar/index.js +1 -1
  38. package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
  39. package/lib/commonjs/specs/ShadowRegistry/index.js +7 -6
  40. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  41. package/lib/commonjs/specs/StatusBar/index.js +1 -1
  42. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  43. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  44. package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
  45. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  46. package/lib/commonjs/specs/index.web.js +1 -1
  47. package/lib/commonjs/web/convert/boxShadow.js +77 -0
  48. package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
  49. package/lib/commonjs/web/convert/breakpoint.js +25 -0
  50. package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
  51. package/lib/commonjs/web/convert/index.js +76 -0
  52. package/lib/commonjs/web/convert/index.js.map +1 -0
  53. package/lib/commonjs/web/convert/module.d.js +2 -0
  54. package/lib/commonjs/web/convert/module.d.js.map +1 -0
  55. package/lib/commonjs/web/convert/shadow.js +68 -0
  56. package/lib/commonjs/web/convert/shadow.js.map +1 -0
  57. package/lib/commonjs/web/convert/style.js +89 -0
  58. package/lib/commonjs/web/convert/style.js.map +1 -0
  59. package/lib/commonjs/web/convert/textShadow.js +73 -0
  60. package/lib/commonjs/web/convert/textShadow.js.map +1 -0
  61. package/lib/commonjs/web/convert/transform.js +72 -0
  62. package/lib/commonjs/web/convert/transform.js.map +1 -0
  63. package/lib/commonjs/web/convert/types.js +9 -0
  64. package/lib/commonjs/web/convert/types.js.map +1 -0
  65. package/lib/commonjs/web/convert/utils.js +55 -0
  66. package/lib/commonjs/web/convert/utils.js.map +1 -0
  67. package/lib/commonjs/web/create.js +51 -0
  68. package/lib/commonjs/web/create.js.map +1 -0
  69. package/lib/commonjs/web/createUnistylesComponent.js +61 -0
  70. package/lib/commonjs/web/createUnistylesComponent.js.map +1 -0
  71. package/lib/commonjs/web/index.js +60 -0
  72. package/lib/commonjs/web/index.js.map +1 -0
  73. package/lib/commonjs/web/listener/index.js +20 -0
  74. package/lib/commonjs/web/listener/index.js.map +1 -0
  75. package/lib/commonjs/web/listener/listenToDependencies.js +38 -0
  76. package/lib/commonjs/web/listener/listenToDependencies.js.map +1 -0
  77. package/lib/commonjs/web/listener/listener.js +35 -0
  78. package/lib/commonjs/web/listener/listener.js.map +1 -0
  79. package/lib/commonjs/web/mock.js +28 -0
  80. package/lib/commonjs/web/mock.js.map +1 -0
  81. package/lib/commonjs/web/mq.js +23 -0
  82. package/lib/commonjs/web/mq.js.map +1 -0
  83. package/lib/commonjs/web/pseudo.js +10 -0
  84. package/lib/commonjs/web/pseudo.js.map +1 -0
  85. package/lib/commonjs/web/registry.js +50 -0
  86. package/lib/commonjs/web/registry.js.map +1 -0
  87. package/lib/commonjs/web/runtime.js +163 -0
  88. package/lib/commonjs/web/runtime.js.map +1 -0
  89. package/lib/commonjs/web/shadowRegistry.js +123 -0
  90. package/lib/commonjs/web/shadowRegistry.js.map +1 -0
  91. package/lib/commonjs/web/state.js +81 -0
  92. package/lib/commonjs/web/state.js.map +1 -0
  93. package/lib/commonjs/web/utils.js +130 -0
  94. package/lib/commonjs/web/utils.js.map +1 -0
  95. package/lib/commonjs/web/variants/getVariants.js +39 -0
  96. package/lib/commonjs/web/variants/getVariants.js.map +1 -0
  97. package/lib/commonjs/web/variants/index.js +28 -0
  98. package/lib/commonjs/web/variants/index.js.map +1 -0
  99. package/lib/commonjs/web/variants/useVariants.js +59 -0
  100. package/lib/commonjs/web/variants/useVariants.js.map +1 -0
  101. package/lib/module/index.js +4 -0
  102. package/lib/module/index.js.map +1 -1
  103. package/lib/module/specs/NavigtionBar/index.js +1 -1
  104. package/lib/module/specs/NavigtionBar/index.js.map +1 -1
  105. package/lib/module/specs/ShadowRegistry/index.js +7 -6
  106. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  107. package/lib/module/specs/StatusBar/index.js +1 -1
  108. package/lib/module/specs/StatusBar/index.js.map +1 -1
  109. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  110. package/lib/module/specs/UnistylesRuntime/index.js +1 -1
  111. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  112. package/lib/module/specs/index.web.js +1 -1
  113. package/lib/module/specs/index.web.js.map +1 -1
  114. package/lib/module/web/convert/boxShadow.js +72 -0
  115. package/lib/module/web/convert/boxShadow.js.map +1 -0
  116. package/lib/module/web/convert/breakpoint.js +20 -0
  117. package/lib/module/web/convert/breakpoint.js.map +1 -0
  118. package/lib/module/web/convert/index.js +71 -0
  119. package/lib/module/web/convert/index.js.map +1 -0
  120. package/lib/module/web/convert/module.d.js +2 -0
  121. package/lib/module/web/convert/module.d.js.map +1 -0
  122. package/lib/module/web/convert/shadow.js +63 -0
  123. package/lib/module/web/convert/shadow.js.map +1 -0
  124. package/lib/module/web/convert/style.js +84 -0
  125. package/lib/module/web/convert/style.js.map +1 -0
  126. package/lib/module/web/convert/textShadow.js +68 -0
  127. package/lib/module/web/convert/textShadow.js.map +1 -0
  128. package/lib/module/web/convert/transform.js +67 -0
  129. package/lib/module/web/convert/transform.js.map +1 -0
  130. package/lib/module/web/convert/types.js +5 -0
  131. package/lib/module/web/convert/types.js.map +1 -0
  132. package/lib/module/web/convert/utils.js +43 -0
  133. package/lib/module/web/convert/utils.js.map +1 -0
  134. package/lib/module/web/create.js +46 -0
  135. package/lib/module/web/create.js.map +1 -0
  136. package/lib/module/web/createUnistylesComponent.js +54 -0
  137. package/lib/module/web/createUnistylesComponent.js.map +1 -0
  138. package/lib/module/web/index.js +26 -0
  139. package/lib/module/web/index.js.map +1 -0
  140. package/lib/module/web/listener/index.js +5 -0
  141. package/lib/module/web/listener/index.js.map +1 -0
  142. package/lib/module/web/listener/listenToDependencies.js +33 -0
  143. package/lib/module/web/listener/listenToDependencies.js.map +1 -0
  144. package/lib/module/web/listener/listener.js +31 -0
  145. package/lib/module/web/listener/listener.js.map +1 -0
  146. package/lib/module/web/mock.js +24 -0
  147. package/lib/module/web/mock.js.map +1 -0
  148. package/lib/module/web/mq.js +17 -0
  149. package/lib/module/web/mq.js.map +1 -0
  150. package/lib/module/web/pseudo.js +5 -0
  151. package/lib/module/web/pseudo.js.map +1 -0
  152. package/lib/module/web/registry.js +46 -0
  153. package/lib/module/web/registry.js.map +1 -0
  154. package/lib/module/web/runtime.js +159 -0
  155. package/lib/module/web/runtime.js.map +1 -0
  156. package/lib/module/web/shadowRegistry.js +119 -0
  157. package/lib/module/web/shadowRegistry.js.map +1 -0
  158. package/lib/module/web/state.js +77 -0
  159. package/lib/module/web/state.js.map +1 -0
  160. package/lib/module/web/utils.js +112 -0
  161. package/lib/module/web/utils.js.map +1 -0
  162. package/lib/module/web/variants/getVariants.js +34 -0
  163. package/lib/module/web/variants/getVariants.js.map +1 -0
  164. package/lib/module/web/variants/index.js +5 -0
  165. package/lib/module/web/variants/index.js.map +1 -0
  166. package/lib/module/web/variants/useVariants.js +54 -0
  167. package/lib/module/web/variants/useVariants.js.map +1 -0
  168. package/lib/typescript/example/App.d.ts.map +1 -1
  169. package/lib/typescript/example/Typography.d.ts +12 -0
  170. package/lib/typescript/example/Typography.d.ts.map +1 -0
  171. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +3 -3
  172. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  173. package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -1
  174. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  175. package/lib/typescript/src/specs/index.web.d.ts +1 -1
  176. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  177. package/lib/typescript/src/types/stylesheet.d.ts +2 -2
  178. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  179. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
  180. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
  181. package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
  182. package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
  183. package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
  184. package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
  185. package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
  186. package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
  187. package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
  188. package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
  189. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
  190. package/lib/typescript/{web → src/web}/create.d.ts +11 -11
  191. package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
  192. package/lib/typescript/src/web/createUnistylesComponent.d.ts +3 -0
  193. package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +1 -0
  194. package/lib/typescript/{web → src/web}/index.d.ts +14 -13
  195. package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
  196. package/lib/typescript/src/web/listener/index.d.ts +3 -0
  197. package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
  198. package/lib/typescript/src/web/listener/listenToDependencies.d.ts +12 -0
  199. package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +1 -0
  200. package/lib/typescript/{web → src/web}/listener/listener.d.ts +3 -2
  201. package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
  202. package/lib/typescript/src/web/mock.d.ts +5 -0
  203. package/lib/typescript/src/web/mock.d.ts.map +1 -0
  204. package/lib/typescript/src/web/mq.d.ts.map +1 -0
  205. package/lib/typescript/src/web/pseudo.d.ts +6 -0
  206. package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
  207. package/lib/typescript/src/web/registry.d.ts +15 -0
  208. package/lib/typescript/src/web/registry.d.ts.map +1 -0
  209. package/lib/typescript/{web → src/web}/runtime.d.ts +6 -7
  210. package/lib/typescript/src/web/runtime.d.ts.map +1 -0
  211. package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
  212. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
  213. package/lib/typescript/{web → src/web}/state.d.ts +4 -9
  214. package/lib/typescript/src/web/state.d.ts.map +1 -0
  215. package/lib/typescript/src/web/utils.d.ts +35 -0
  216. package/lib/typescript/src/web/utils.d.ts.map +1 -0
  217. package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
  218. package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
  219. package/lib/typescript/src/web/variants/index.d.ts +3 -0
  220. package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
  221. package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
  222. package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
  223. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -3
  224. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +8 -3
  225. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +1 -1
  226. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +1 -1
  227. package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +14 -2
  228. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +3 -0
  229. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -0
  230. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +3 -0
  231. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
  232. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -0
  233. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
  234. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +4 -1
  235. package/package.json +3 -3
  236. package/plugin/__tests__/dependencies.spec.js +199 -111
  237. package/plugin/__tests__/ref.spec.js +638 -202
  238. package/plugin/__tests__/stylesheet.spec.js +182 -71
  239. package/plugin/index.js +110 -23
  240. package/plugin/ref.js +64 -13
  241. package/plugin/style.js +82 -22
  242. package/plugin/stylesheet.js +44 -1
  243. package/plugin/variants.js +33 -0
  244. package/src/index.ts +3 -0
  245. package/src/specs/NavigtionBar/index.ts +1 -1
  246. package/src/specs/ShadowRegistry/index.ts +10 -9
  247. package/src/specs/StatusBar/index.ts +1 -1
  248. package/src/specs/StyleSheet/index.ts +3 -1
  249. package/src/specs/UnistylesRuntime/index.ts +1 -1
  250. package/src/specs/index.web.ts +1 -1
  251. package/src/types/stylesheet.ts +2 -2
  252. package/{web → src/web}/convert/breakpoint.ts +1 -1
  253. package/{web → src/web}/convert/index.ts +2 -2
  254. package/{web → src/web}/convert/types.ts +1 -1
  255. package/src/web/create.ts +50 -0
  256. package/src/web/createUnistylesComponent.tsx +54 -0
  257. package/{web → src/web}/index.ts +3 -2
  258. package/src/web/listener/index.ts +2 -0
  259. package/src/web/listener/listenToDependencies.ts +45 -0
  260. package/{web → src/web}/listener/listener.ts +2 -2
  261. package/{web → src/web}/mock.ts +2 -12
  262. package/src/web/pseudo.ts +137 -0
  263. package/src/web/registry.ts +60 -0
  264. package/{web → src/web}/runtime.ts +4 -6
  265. package/src/web/shadowRegistry.ts +124 -0
  266. package/{web → src/web}/state.ts +5 -49
  267. package/{web → src/web}/utils.ts +91 -17
  268. package/src/web/variants/getVariants.ts +42 -0
  269. package/src/web/variants/index.ts +2 -0
  270. package/src/web/variants/useVariants.ts +65 -0
  271. package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
  272. package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
  273. package/lib/typescript/web/convert/index.d.ts.map +0 -1
  274. package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
  275. package/lib/typescript/web/convert/style.d.ts.map +0 -1
  276. package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
  277. package/lib/typescript/web/convert/transform.d.ts.map +0 -1
  278. package/lib/typescript/web/convert/types.d.ts.map +0 -1
  279. package/lib/typescript/web/convert/utils.d.ts.map +0 -1
  280. package/lib/typescript/web/listener/index.d.ts +0 -2
  281. package/lib/typescript/web/listener/index.d.ts.map +0 -1
  282. package/lib/typescript/web/listener/listener.d.ts.map +0 -1
  283. package/lib/typescript/web/mock.d.ts +0 -14
  284. package/lib/typescript/web/mock.d.ts.map +0 -1
  285. package/lib/typescript/web/mq.d.ts.map +0 -1
  286. package/lib/typescript/web/pseudo.d.ts +0 -4
  287. package/lib/typescript/web/pseudo.d.ts.map +0 -1
  288. package/lib/typescript/web/registry.d.ts +0 -12
  289. package/lib/typescript/web/registry.d.ts.map +0 -1
  290. package/lib/typescript/web/runtime.d.ts.map +0 -1
  291. package/lib/typescript/web/state.d.ts.map +0 -1
  292. package/lib/typescript/web/useVariants.d.ts +0 -3
  293. package/lib/typescript/web/useVariants.d.ts.map +0 -1
  294. package/lib/typescript/web/utils.d.ts +0 -18
  295. package/lib/typescript/web/utils.d.ts.map +0 -1
  296. package/web/create.ts +0 -102
  297. package/web/listener/index.ts +0 -1
  298. package/web/pseudo.ts +0 -11
  299. package/web/registry.ts +0 -41
  300. package/web/useVariants.ts +0 -99
  301. /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
  302. /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
  303. /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
  304. /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
  305. /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
  306. /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
  307. /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
  308. /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
  309. /package/{web → src/web}/convert/boxShadow.ts +0 -0
  310. /package/{web → src/web}/convert/module.d.ts +0 -0
  311. /package/{web → src/web}/convert/shadow.ts +0 -0
  312. /package/{web → src/web}/convert/style.ts +0 -0
  313. /package/{web → src/web}/convert/textShadow.ts +0 -0
  314. /package/{web → src/web}/convert/transform.ts +0 -0
  315. /package/{web → src/web}/convert/utils.ts +0 -0
  316. /package/{web → src/web}/mq.ts +0 -0
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getStyle = void 0;
7
+ var _utils = require("../utils");
8
+ const stylesToSkip = ['borderCurve', 'elevation', 'textAlignVertical', 'includeFontPadding', 'overlayColor', 'tintColor'];
9
+ const convertMap = {
10
+ marginHorizontal: value => ({
11
+ marginInline: value
12
+ }),
13
+ marginVertical: value => ({
14
+ marginBlock: value
15
+ }),
16
+ paddingHorizontal: value => ({
17
+ paddingInline: value
18
+ }),
19
+ paddingVertical: value => ({
20
+ paddingBlock: value
21
+ }),
22
+ writingDirection: value => ({
23
+ direction: value
24
+ }),
25
+ borderBottomEndRadius: value => ({
26
+ borderBottomRightRadius: value
27
+ }),
28
+ borderBottomStartRadius: value => ({
29
+ borderBottomLeftRadius: value
30
+ }),
31
+ borderEndColor: value => ({
32
+ borderInlineEndColor: value
33
+ }),
34
+ borderStartColor: value => ({
35
+ borderInlineStartColor: value
36
+ }),
37
+ borderTopEndRadius: value => ({
38
+ borderTopRightRadius: value
39
+ }),
40
+ borderTopStartRadius: value => ({
41
+ borderTopLeftRadius: value
42
+ }),
43
+ borderEndWidth: value => ({
44
+ borderInlineEndWidth: value
45
+ }),
46
+ borderStartWidth: value => ({
47
+ borderInlineStartWidth: value
48
+ }),
49
+ end: value => ({
50
+ right: value
51
+ }),
52
+ start: value => ({
53
+ left: value
54
+ }),
55
+ marginEnd: value => ({
56
+ marginRight: value
57
+ }),
58
+ marginStart: value => ({
59
+ marginLeft: value
60
+ }),
61
+ paddingEnd: value => ({
62
+ paddingRight: value
63
+ }),
64
+ paddingStart: value => ({
65
+ paddingLeft: value
66
+ }),
67
+ transformMatrix: value => ({
68
+ transform: `matrix(${value.join(', ')})`
69
+ }),
70
+ resizeMode: value => ({
71
+ backgroundSize: value
72
+ }),
73
+ lineHeight: value => ({
74
+ lineHeight: `${value}px`
75
+ })
76
+ };
77
+ const getStyle = (key, value) => {
78
+ if (stylesToSkip.includes(key)) {
79
+ return {};
80
+ }
81
+ if ((0, _utils.keyInObject)(convertMap, key)) {
82
+ return convertMap[key]?.(value) ?? {};
83
+ }
84
+ return {
85
+ [key]: value
86
+ };
87
+ };
88
+ exports.getStyle = getStyle;
89
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","stylesToSkip","convertMap","marginHorizontal","value","marginInline","marginVertical","marginBlock","paddingHorizontal","paddingInline","paddingVertical","paddingBlock","writingDirection","direction","borderBottomEndRadius","borderBottomRightRadius","borderBottomStartRadius","borderBottomLeftRadius","borderEndColor","borderInlineEndColor","borderStartColor","borderInlineStartColor","borderTopEndRadius","borderTopRightRadius","borderTopStartRadius","borderTopLeftRadius","borderEndWidth","borderInlineEndWidth","borderStartWidth","borderInlineStartWidth","end","right","start","left","marginEnd","marginRight","marginStart","marginLeft","paddingEnd","paddingRight","paddingStart","paddingLeft","transformMatrix","transform","join","resizeMode","backgroundSize","lineHeight","getStyle","key","includes","keyInObject","exports"],"sourceRoot":"../../../../src","sources":["web/convert/style.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAGA,MAAMC,YAAY,GAAG,CACjB,aAAa,EACb,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,WAAW,CACd;AAED,MAAMC,UAAU,GAAG;EACfC,gBAAgB,EAAGC,KAAa,KAAM;IAClCC,YAAY,EAAED;EAClB,CAAC,CAAC;EACFE,cAAc,EAAGF,KAAa,KAAM;IAChCG,WAAW,EAAEH;EACjB,CAAC,CAAC;EACFI,iBAAiB,EAAGJ,KAAa,KAAM;IACnCK,aAAa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C,CAAC;EACFsC,eAAe,EAAGtC,KAAoB,KAAM;IACxCuC,SAAS,EAAE,UAAUvC,KAAK,CAACwC,IAAI,CAAC,IAAI,CAAC;EACzC,CAAC,CAAC;EACFC,UAAU,EAAGzC,KAAa,KAAM;IAC5B0C,cAAc,EAAE1C;EACpB,CAAC,CAAC;EACF2C,UAAU,EAAG3C,KAAa,KAAM;IAC5B2C,UAAU,EAAE,GAAG3C,KAAK;EACxB,CAAC;AACL,CAA6D;AAEtD,MAAM4C,QAAQ,GAAGA,CAACC,GAAW,EAAE7C,KAAU,KAAK;EACjD,IAAIH,YAAY,CAACiD,QAAQ,CAACD,GAAG,CAAC,EAAE;IAC5B,OAAO,CAAC,CAAC;EACb;EAEA,IAAI,IAAAE,kBAAW,EAACjD,UAAU,EAAE+C,GAAG,CAAC,EAAE;IAC9B,OAAO/C,UAAU,CAAC+C,GAAG,CAAC,GAAG7C,KAAK,CAAC,IAAI,CAAC,CAAC;EACzC;EAEA,OAAO;IACH,CAAC6C,GAAG,GAAG7C;EACX,CAAC;AACL,CAAC;AAAAgD,OAAA,CAAAJ,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTextShadowStyle = 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 createTextShadowValue = style => {
14
+ const {
15
+ textShadowColor,
16
+ textShadowOffset,
17
+ textShadowRadius
18
+ } = style;
19
+ const offsetX = (0, _utils2.normalizeNumericValue)(textShadowOffset.width);
20
+ const offsetY = (0, _utils2.normalizeNumericValue)(textShadowOffset.height);
21
+ const radius = (0, _utils2.normalizeNumericValue)(textShadowRadius);
22
+ const color = (0, _utils2.normalizeColor)(textShadowColor);
23
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
24
+ };
25
+ const getTextShadowStyle = styles => {
26
+ const missingStyles = _types.TEXT_SHADOW_STYLES.filter(key => !(key in styles));
27
+ if (missingStyles.length) {
28
+ (0, _utils.warn)(`can't apply text shadow as you miss these properties: ${missingStyles.join(', ')}`);
29
+ return {};
30
+ }
31
+ const breakpointsSet = new Set();
32
+ try {
33
+ (0, _shadow.validateShadow)(_types.TEXT_SHADOW_STYLES, styles, breakpointsSet);
34
+ } catch (error) {
35
+ if (typeof error === 'string') {
36
+ (0, _utils.warn)(error);
37
+ }
38
+ return {};
39
+ }
40
+ const breakpoints = Array.from(breakpointsSet);
41
+
42
+ // If no breakpoints were used return styles without media queries
43
+ if (breakpoints.length === 0) {
44
+ return {
45
+ textShadow: createTextShadowValue(styles)
46
+ };
47
+ }
48
+
49
+ // Create textShadow for each breakpoint
50
+ const breakpointStyles = breakpoints.map(breakpoint => {
51
+ const color = (0, _utils2.extractShadowValue)('textShadowColor', breakpoint, styles);
52
+ const {
53
+ width,
54
+ height
55
+ } = (0, _utils2.extractShadowValue)('textShadowOffset', breakpoint, styles);
56
+ const radius = (0, _utils2.extractShadowValue)('textShadowRadius', breakpoint, styles);
57
+ return (0, _typestyle.media)((0, _breakpoint.convertBreakpoint)(breakpoint), {
58
+ textShadow: createTextShadowValue({
59
+ textShadowColor: color,
60
+ textShadowOffset: {
61
+ width,
62
+ height
63
+ },
64
+ textShadowRadius: radius
65
+ })
66
+ });
67
+ });
68
+
69
+ // Merge all breakpoints styles into one
70
+ return (0, _utils.deepMergeObjects)(...breakpointStyles);
71
+ };
72
+ exports.getTextShadowStyle = getTextShadowStyle;
73
+ //# sourceMappingURL=textShadow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_typestyle","require","_utils","_shadow","_breakpoint","_types","_utils2","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","normalizeNumericValue","width","offsetY","height","radius","color","normalizeColor","getTextShadowStyle","styles","missingStyles","TEXT_SHADOW_STYLES","filter","key","length","warn","join","breakpointsSet","Set","validateShadow","error","breakpoints","Array","from","textShadow","breakpointStyles","map","breakpoint","extractShadowValue","media","convertBreakpoint","deepMergeObjects","exports"],"sourceRoot":"../../../../src","sources":["web/convert/textShadow.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,qBAAqB,GAAIC,KAAiB,IAAK;EACjD,MAAM;IAAEC,eAAe;IAAEC,gBAAgB;IAAEC;EAAiB,CAAC,GAAGH,KAAK;EACrE,MAAMI,OAAO,GAAG,IAAAC,6BAAqB,EAACH,gBAAgB,CAACI,KAAK,CAAC;EAC7D,MAAMC,OAAO,GAAG,IAAAF,6BAAqB,EAACH,gBAAgB,CAACM,MAAM,CAAC;EAC9D,MAAMC,MAAM,GAAG,IAAAJ,6BAAqB,EAACF,gBAAgB,CAAC;EACtD,MAAMO,KAAK,GAAG,IAAAC,sBAAc,EAACV,eAAyB,CAAC;EAEvD,OAAO,GAAGG,OAAO,IAAIG,OAAO,IAAIE,MAAM,IAAIC,KAAK,EAAE;AACrD,CAAC;AAEM,MAAME,kBAAkB,GAAIC,MAA2B,IAA0B;EACpF,MAAMC,aAAa,GAAGC,yBAAkB,CAACC,MAAM,CAACC,GAAG,IAAI,EAAEA,GAAG,IAAIJ,MAAM,CAAC,CAAC;EAExE,IAAIC,aAAa,CAACI,MAAM,EAAE;IACtB,IAAAC,WAAI,EAAC,yDAAyDL,aAAa,CAACM,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAEzF,OAAO,CAAC,CAAC;EACb;EAEA,MAAMC,cAAc,GAAG,IAAIC,GAAG,CAAS,CAAC;EAExC,IAAI;IACA,IAAAC,sBAAc,EAACR,yBA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yle = void 0;
7
+ var _typestyle = require("typestyle");
8
+ var _utils = require("../utils");
9
+ var _utils2 = require("./utils");
10
+ var _breakpoint = require("./breakpoint");
11
+ const normalizeTransform = (key, value) => {
12
+ if (key.includes('scale')) {
13
+ return value;
14
+ }
15
+ if (typeof value === 'number') {
16
+ return (0, _utils2.normalizeNumericValue)(value);
17
+ }
18
+ return value;
19
+ };
20
+ const createTransformValue = transforms => transforms.map(transform => {
21
+ const [key] = Object.keys(transform);
22
+ if (!key) {
23
+ return undefined;
24
+ }
25
+ const value = transform[key];
26
+ switch (key) {
27
+ case 'matrix':
28
+ case 'matrix3d':
29
+ return `${key}(${value.join(',')})`;
30
+ default:
31
+ return `${key}(${normalizeTransform(key, value)})`;
32
+ }
33
+ }).filter(Boolean).join(' ');
34
+ const getTransformStyle = transforms => {
35
+ const breakpoints = new Set();
36
+ const normalTransforms = [];
37
+ transforms.forEach(transform => {
38
+ const [property] = Object.keys(transform);
39
+ if (!property) {
40
+ return;
41
+ }
42
+ const value = transform[property];
43
+ if (typeof value === 'object' && !Array.isArray(value)) {
44
+ Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
45
+ return;
46
+ }
47
+ normalTransforms.push(transform);
48
+ });
49
+ const breakpointTransforms = Array.from(breakpoints).flatMap(breakpoint => {
50
+ const transformsPerBreakpoint = transforms.flatMap(transform => {
51
+ const [property] = Object.keys(transform);
52
+ if (!property) {
53
+ return [];
54
+ }
55
+ const value = transform[property];
56
+ if (typeof value === 'object' && !Array.isArray(value)) {
57
+ return (0, _utils.keyInObject)(value, breakpoint) ? [{
58
+ [property]: value[breakpoint]
59
+ }] : [];
60
+ }
61
+ return [];
62
+ });
63
+ return (0, _typestyle.media)((0, _breakpoint.convertBreakpoint)(breakpoint), {
64
+ transform: createTransformValue(transformsPerBreakpoint)
65
+ });
66
+ });
67
+ return (0, _utils.deepMergeObjects)({
68
+ transform: createTransformValue(normalTransforms)
69
+ }, ...breakpointTransforms);
70
+ };
71
+ exports.getTransformStyle = getTransformStyle;
72
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_typestyle","require","_utils","_utils2","_breakpoint","normalizeTransform","key","value","includes","normalizeNumericValue","createTransformValue","transforms","map","transform","Object","keys","undefined","join","filter","Boolean","getTransformStyle","breakpoints","Set","normalTransforms","forEach","property","Array","isArray","breakpoint","add","push","breakpointTransforms","from","flatMap","transformsPerBreakpoint","keyInObject","media","convertBreakpoint","deepMergeObjects","exports"],"sourceRoot":"../../../../src","sources":["web/convert/transform.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,WAAA,GAAAH,OAAA;AAIA,MAAMI,kBAAkB,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAAK;EACpD,IAAID,GAAG,CAACE,QAAQ,CAAC,OAAO,CAAC,EAAE;IACvB,OAAOD,KAAK;EAChB;EAEA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAO,IAAAE,6BAAqB,EAACF,KAAK,CAAC;EACvC;EAEA,OAAOA,KAAK;AAChB,CAAC;AAED,MAAMG,oBAAoB,GAAIC,UAAsB,IAAKA,UAAU,CAC9DC,GAAG,CAACC,SAAS,IAAI;EACd,MAAM,CAACP,GAAG,CAAC,GAAGQ,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;EAEpC,IAAI,CAACP,GAAG,EAAE;IACN,OAAOU,SAAS;EACpB;EAEA,MAAMT,KAAK,GAAGM,SAAS,CAACP,GAAG,CAAC;EAE5B,QAAOA,GAAG;IACN,KAAK,QAAQ;IACb,KAAK,UAAU;MACX,OAAO,GAAGA,GAAG,IAAKC,KAAK,CAAmBU,IAAI,CAAC,GAAG,CAAC,GAAG;IAC1D;MACI,OAAO,GAAGX,GAAG,IAAID,kBAAkB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAG;EAC1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G,CAAC;UAAE,CAACH,QAAQ,GAAGlB,KAAK,CAACqB,UAAU;QAAE,CAAC,CAAC,GAAG,EAAE;MACpF;MAEA,OAAO,EAAE;IACb,CAAC,CAAC;IAEF,OAAO,IAAAQ,gBAAK,EAAC,IAAAC,6BAAiB,EAACT,UAAU,CAAC,EAAE;MACxCf,SAAS,EAAEH,oBAAoB,CAACwB,uBAAuB;IAC3D,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAO,IAAAI,uBAAgB,EAAC;IACpBzB,SAAS,EAAEH,oBAAoB,CAACa,gBAAgB;EACpD,CAAC,EAAE,GAAGQ,oBAAoB,CAAC;AAC/B,CAAC;AAAAQ,OAAA,CAAAnB,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.TEXT_SHADOW_STYLES = exports.BOX_SHADOW_STYLES = void 0;
7
+ const TEXT_SHADOW_STYLES = exports.TEXT_SHADOW_STYLES = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'];
8
+ const BOX_SHADOW_STYLES = exports.BOX_SHADOW_STYLES = ['shadowColor', 'shadowRadius', 'shadowOpacity', 'shadowOffset'];
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TEXT_SHADOW_STYLES","exports","BOX_SHADOW_STYLES"],"sourceRoot":"../../../../src","sources":["web/convert/types.ts"],"mappings":";;;;;;AAKO,MAAMA,kBAAkB,GAAAC,OAAA,CAAAD,kBAAA,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,CAAU;AAI/F,MAAME,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAG,CAAC,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAU","ignoreList":[]}
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.normalizeNumericValue = exports.normalizeColor = exports.isTransform = exports.isTextShadow = exports.isBoxShadow = exports.extractShadowValue = void 0;
7
+ var _normalizeColors = _interopRequireDefault(require("@react-native/normalize-colors"));
8
+ var _types = require("./types");
9
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
+ // based on react-native-web normalizer
11
+ // https://github.com/necolas/react-native-web
12
+
13
+ const isTransform = (key, value) => key === 'transform' && Array.isArray(value);
14
+ exports.isTransform = isTransform;
15
+ const isTextShadow = key => _types.TEXT_SHADOW_STYLES.includes(key);
16
+ exports.isTextShadow = isTextShadow;
17
+ const isBoxShadow = key => _types.BOX_SHADOW_STYLES.includes(key);
18
+ exports.isBoxShadow = isBoxShadow;
19
+ const normalizeNumericValue = value => value ? `${value}px` : value;
20
+ exports.normalizeNumericValue = normalizeNumericValue;
21
+ const normalizeColor = (color, opacity = 1) => {
22
+ // If the opacity is 1 there's no need to normalize the color
23
+ if (opacity === 1) {
24
+ return color;
25
+ }
26
+ const integer = (0, _normalizeColors.default)(color);
27
+
28
+ // If the color is an unknown format, the return value is null
29
+ if (integer === null) {
30
+ return color;
31
+ }
32
+ const hex = integer.toString(16).padStart(8, '0');
33
+ if (hex.length === 8) {
34
+ const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
35
+ return `rgba(${r},${g},${b},${a / 255 * opacity})`;
36
+ }
37
+ return color;
38
+ };
39
+ exports.normalizeColor = normalizeColor;
40
+ const extractShadowValue = (key, breakpoint, styles) => {
41
+ const value = styles[key];
42
+ if (key === 'textShadowOffset' || key === 'shadowOffset') {
43
+ const {
44
+ width,
45
+ height
46
+ } = value;
47
+ return {
48
+ width: typeof width === 'object' ? width[breakpoint] : width,
49
+ height: typeof height === 'object' ? height[breakpoint] : height
50
+ };
51
+ }
52
+ return typeof value === 'object' ? value[breakpoint] : value;
53
+ };
54
+ exports.extractShadowValue = extractShadowValue;
55
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","_types","e","__esModule","default","isTransform","key","value","Array","isArray","exports","isTextShadow","TEXT_SHADOW_STYLES","includes","isBoxShadow","BOX_SHADOW_STYLES","normalizeNumericValue","normalizeColor","color","opacity","integer","normalizeColors","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","extractShadowValue","breakpoint","styles","width","height"],"sourceRoot":"../../../../src","sources":["web/convert/utils.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAmG,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAHnG;AACA;;AAIO,MAAMG,WAAW,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAA0CD,GAAG,KAAK,WAAW,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAAAG,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAEjI,MAAMM,YAAY,GAAIL,GAAW,IAAKM,yBAAkB,CAACC,QAAQ,CAACP,GAAwC,CAAC;AAAAI,OAAA,CAAAC,YAAA,GAAAA,YAAA;AAE3G,MAAMG,WAAW,GAAIR,GAAW,IAAKS,wBAAiB,CAACF,QAAQ,CAACP,GAAuC,CAAC;AAAAI,OAAA,CAAAI,WAAA,GAAAA,WAAA;AAExG,MAAME,qBAAqB,GAAIT,KAAa,IAAKA,KAAK,GAAG,GAAGA,KAAK,IAAI,GAAGA,KAAK;AAAAG,OAAA,CAAAM,qBAAA,GAAAA,qBAAA;AAE7E,MAAMC,cAAc,GAAGA,CAACC,KAAa,EAAEC,OAAe,GAAG,CAAC,KAAK;EAClE;EACA,IAAIA,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,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EA,OAAO,OAAOlC,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAAC+B,UAAU,CAAC,GAAG/B,KAAK;AAChE,CAAC;AAAAG,OAAA,CAAA2B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.create = void 0;
7
+ var _utils = require("./utils");
8
+ var _runtime = require("./runtime");
9
+ var _variants = require("./variants");
10
+ const create = stylesheet => {
11
+ const computedStylesheet = typeof stylesheet === 'function' ? stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : stylesheet;
12
+ const selectedVariants = new Map();
13
+ const copyVariants = () => Object.fromEntries(selectedVariants.entries());
14
+ const addSecrets = (value, key, args) => (0, _utils.assignSecrets)(value, {
15
+ __uni__key: key,
16
+ __uni__refs: new Set(),
17
+ __uni__stylesheet: stylesheet,
18
+ __uni__args: args,
19
+ __uni__variants: copyVariants()
20
+ });
21
+ const styles = (0, _utils.reduceObject)(computedStylesheet, (value, _key) => {
22
+ const key = String(_key);
23
+ if (typeof value === 'function') {
24
+ const dynamicStyle = (...args) => {
25
+ const result = value(...args);
26
+ const variants = Object.fromEntries((0, _variants.getVariants)({
27
+ [key]: result
28
+ }, copyVariants()));
29
+ const resultWithVariants = {
30
+ ...result,
31
+ ...variants[key]
32
+ };
33
+
34
+ // Add secrets to result of dynamic styles function
35
+ return addSecrets((0, _utils.getStyles)(resultWithVariants), key, args);
36
+ };
37
+
38
+ // Add secrets to dynamic styles function
39
+ return addSecrets(dynamicStyle, key);
40
+ }
41
+
42
+ // Add secrets to static styles
43
+ return addSecrets((0, _utils.getStyles)(value), key);
44
+ });
45
+
46
+ // Inject useVariants hook to styles
47
+ (0, _variants.createUseVariants)(styles, newVariants => Object.entries(newVariants).forEach(([key, value]) => selectedVariants.set(key, value)));
48
+ return styles;
49
+ };
50
+ exports.create = create;
51
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","_runtime","_variants","create","stylesheet","computedStylesheet","UnistylesRuntime","theme","miniRuntime","selectedVariants","Map","copyVariants","Object","fromEntries","entries","addSecrets","value","key","args","assignSecrets","__uni__key","__uni__refs","Set","__uni__stylesheet","__uni__args","__uni__variants","styles","reduceObject","_key","String","dynamicStyle","result","variants","getVariants","resultWithVariants","getStyles","createUseVariants","newVariants","forEach","set","exports"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;;;;;AAEA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEO,MAAMG,MAAM,GAAIC,UAAiD,IAAK;EACzE,MAAMC,kBAAkB,GAAG,OAAOD,UAAU,KAAK,UAAU,GACrDA,UAAU,CAACE,yBAAgB,CAACC,KAAK,EAAED,yBAAgB,CAACE,WAAW,CAAC,GAChEJ,UAAU;EAChB,MAAMK,gBAAgB,GAAG,IAAIC,GAAG,CAAc,CAAC;EAE/C,MAAMC,YAAY,GAAGA,CAAA,KAAMC,MAAM,CAACC,WAAW,CAACJ,gBAAgB,CAACK,OAAO,CAAC,CAAC,CAAC;EACzE,MAAMC,UAAU,GAAGA,CAACC,KAAU,EAAEC,GAAW,EAAEC,IAAiB,KAAK,IAAAC,oBAAa,EAACH,KAAK,EAAE;IACpFI,UAAU,EAAEH,GAAG;IACfI,WAAW,EAAE,IAAIC,GAAG,CAAC,CAAC;IACtBC,iBAAiB,EAAEnB,UAAU;IAC7BoB,WAAW,EAAEN,IAAI;IACjBO,eAAe,EAAEd,YAAY,CAAC;EAClC,CAAC,CAAC;EAEF,MAAMe,MAAM,GAAG,IAAAC,mBAAY,EAACtB,kBAAkB,EAAE,CAACW,KAAK,EAAEY,IAAI,KAAK;IAC7D,MAAMX,GAAG,GAAGY,MAAM,CAACD,IAAI,CAAC;IAExB,IAAI,OAAOZ,KAAK,KAAK,UAAU,EAAE;MAC7B,MAAMc,YAAY,GAAGA,CAAC,GAAGZ,IAAgB,KAAK;QAC1C,MAAMa,MAAM,GAAGf,KAAK,CAAC,GAAGE,IAAI,CAAC;QAC7B,MAAMc,QAAQ,GAAGpB,MAAM,CAACC,WAAW,CAAC,IAAAoB,qBAAW,EAAC;UAAE,CAAChB,GAAG,GAAGc;QAAO,CAAC,EAAuCpB,YAAY,CAAC,CAAC,CAAC,CAAC;QACxH,MAAMuB,kBAAkB,GAAG;UACvB,GAAGH,MAAM;UACT,GAAGC,QAAQ,CAACf,GAAG;QACnB,CAAC;;QAED;QACA,OAAOF,UAAU,CAAC,IAAAoB,gBAAS,EAACD,kBAAkB,CAAC,EAAEjB,GAAG,EAAEC,IAAI,CAAC;MAC/D,CAAC;;MAED;MACA,OAAOH,UAAU,CAACe,YAAY,EAAEb,GAAG,CAAC;IACxC;;IAEA;IACA,OAAOF,UAAU,CAAC,IAAAoB,gBAAS,EAACnB,KAAK,CAAC,EAAEC,GAAG,CAAC;EAC5C,CAAC,CAAsC;;EAEvC;EACA,IAAAmB,2BAAiB,EAACV,MAAM,EAAEW,WAAW,IAAIzB,MAAM,CAACE,OAAO,CAACuB,WAAW,CAAC,CAACC,OAAO,CAAC,CAAC,CAACrB,GAAG,EAAED,KAAK,CAAC,KAAKP,gBAAgB,CAAC8B,GAAG,CAACtB,GAAG,EAAED,KAAK,CAAC,CAAC,CAAC;EAEjI,OAAOU,MAAM;AACjB,CAAC;AAAAc,OAAA,CAAArC,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.createUnistylesComponent = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _utils = require("./utils");
9
+ var _variants = require("./variants");
10
+ var _listener = require("./listener");
11
+ var _registry = require("./registry");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ const getStyles = value => {
16
+ const secrets = (0, _utils.extractSecrets)(value);
17
+ if (secrets.length === 0) {
18
+ return undefined;
19
+ }
20
+ return secrets.reduce((acc, {
21
+ __uni__stylesheet,
22
+ __uni__key,
23
+ __uni__args = [],
24
+ __uni__variants
25
+ }) => {
26
+ const newComputedStylesheet = _registry.UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
27
+ const style = newComputedStylesheet[__uni__key];
28
+ const resultHidden = typeof style === 'function' ? style(...__uni__args) : style;
29
+ const result = (0, _utils.extractHiddenProperties)(resultHidden);
30
+ const {
31
+ variants
32
+ } = Object.fromEntries((0, _variants.getVariants)({
33
+ variants: result
34
+ }, __uni__variants));
35
+ const resultWithVariants = {
36
+ ...result,
37
+ ...variants
38
+ };
39
+ return {
40
+ ...acc,
41
+ ...resultWithVariants
42
+ };
43
+ }, {});
44
+ };
45
+ const createUnistylesComponent = Component => props => {
46
+ const passedStyles = props.style ?? {};
47
+ const [style, setStyle] = (0, _react.useState)(getStyles(passedStyles));
48
+ (0, _react.useEffect)(() => {
49
+ const newStyles = getStyles(passedStyles);
50
+ const dependencies = newStyles?.['uni__dependencies'] ?? [];
51
+ const dispose = _listener.UnistylesListener.addListeners(dependencies, () => setStyle(getStyles(passedStyles)));
52
+ setStyle(newStyles);
53
+ return dispose;
54
+ }, [passedStyles]);
55
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, {
56
+ ...props,
57
+ style: style
58
+ });
59
+ };
60
+ exports.createUnistylesComponent = createUnistylesComponent;
61
+ //# sourceMappingURL=createUnistylesComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_utils","_variants","_listener","_registry","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getStyles","value","secrets","extractSecrets","length","undefined","reduce","acc","__uni__stylesheet","__uni__key","__uni__args","__uni__variants","newComputedStylesheet","UnistylesRegistry","getComputedStylesheet","style","resultHidden","result","extractHiddenProperties","variants","fromEntries","getVariants","resultWithVariants","createUnistylesComponent","Component","props","passedStyles","setStyle","useState","useEffect","newStyles","dependencies","dispose","UnistylesListener","addListeners","jsx","exports"],"sourceRoot":"../../../src","sources":["web/createUnistylesComponent.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAA8C,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,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,SAAAR,wBAAAQ,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,GAAA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5
+ });
6
+ var _exportNames = {
7
+ StyleSheet: true,
8
+ getSSRUnistyles: true,
9
+ UnistylesRuntime: true,
10
+ UnistylesShadowRegistry: true
11
+ };
12
+ exports.StyleSheet = void 0;
13
+ Object.defineProperty(exports, "UnistylesRuntime", {
14
+ enumerable: true,
15
+ get: function () {
16
+ return _runtime.UnistylesRuntime;
17
+ }
18
+ });
19
+ Object.defineProperty(exports, "UnistylesShadowRegistry", {
20
+ enumerable: true,
21
+ get: function () {
22
+ return _shadowRegistry.UnistylesShadowRegistry;
23
+ }
24
+ });
25
+ exports.getSSRUnistyles = void 0;
26
+ var _create = require("./create");
27
+ var _state = require("./state");
28
+ var _utils = require("./utils");
29
+ var _runtime = require("./runtime");
30
+ var _shadowRegistry = require("./shadowRegistry");
31
+ var _mock = require("./mock");
32
+ Object.keys(_mock).forEach(function (key) {
33
+ if (key === "default" || key === "__esModule") return;
34
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
35
+ if (key in exports && exports[key] === _mock[key]) return;
36
+ Object.defineProperty(exports, key, {
37
+ enumerable: true,
38
+ get: function () {
39
+ return _mock[key];
40
+ }
41
+ });
42
+ });
43
+ const StyleSheet = exports.StyleSheet = {
44
+ configure: _state.UnistylesState.init,
45
+ create: _create.create,
46
+ absoluteFill: {
47
+ position: 'absolute',
48
+ left: 0,
49
+ top: 0,
50
+ right: 0,
51
+ bottom: 0
52
+ },
53
+ compose: (a, b) => (0, _utils.deepMergeObjects)(a, b),
54
+ flatten: (...styles) => (0, _utils.deepMergeObjects)(...styles),
55
+ hairlineWidth: 1
56
+ };
57
+ // TODO: Work on SSR
58
+ const getSSRUnistyles = () => [];
59
+ exports.getSSRUnistyles = getSSRUnistyles;
60
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_create","require","_state","_utils","_runtime","_shadowRegistry","_mock","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","StyleSheet","configure","UnistylesState","init","create","absoluteFill","position","left","top","right","bottom","compose","a","b","deepMergeObjects","flatten","styles","hairlineWidth","getSSRUnistyles"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAiBA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAAAM,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAjBO,MAAMS,UAAU,GAAAJ,OAAA,CAAAI,UAAA,GAAG;EACtBC,SAAS,EAAEC,qBAAc,CAACC,IAAI;EAC9BC,MAAM,EAANA,cAAM;EACNC,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAK,IAAAC,uBAAgB,EAACF,CAAC,EAAEC,CAAC,CAAC;EACzDE,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAK,IAAAF,uBAAgB,EAAC,GAAGE,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAMD;AACO,MAAMC,eAAe,GAAGA,CAAA,KAAM,EAAE;AAAAtB,OAAA,CAAAsB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "UnistylesListener", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _listener.UnistylesListener;
10
+ }
11
+ });
12
+ Object.defineProperty(exports, "listenToDependencies", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _listenToDependencies.listenToDependencies;
16
+ }
17
+ });
18
+ var _listener = require("./listener");
19
+ var _listenToDependencies = require("./listenToDependencies");
20
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_listener","require","_listenToDependencies"],"sourceRoot":"../../../../src","sources":["web/listener/index.ts"],"mappings":";;;;;;;;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,qBAAA,GAAAD,OAAA","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.listenToDependencies = void 0;
7
+ var _listener = require("./listener");
8
+ var _utils = require("../utils");
9
+ var _registry = require("../registry");
10
+ const listenToDependencies = ({
11
+ key,
12
+ className,
13
+ unistyles,
14
+ args = [],
15
+ stylesheet
16
+ }) => {
17
+ const newComputedStylesheet = _registry.UnistylesRegistry.getComputedStylesheet(stylesheet);
18
+ const _value = (0, _utils.keyInObject)(newComputedStylesheet, key) ? newComputedStylesheet[key] : undefined;
19
+ if (!_value) {
20
+ return;
21
+ }
22
+ const value = typeof _value === 'function' ? _value(...args) : _value;
23
+ const dependencies = 'uni__dependencies' in value ? value['uni__dependencies'] : [];
24
+ if (dependencies.length === 0) {
25
+ return;
26
+ }
27
+ return _listener.UnistylesListener.addListeners(dependencies, () => {
28
+ const newComputedStylesheet = _registry.UnistylesRegistry.getComputedStylesheet(stylesheet);
29
+ if (!(0, _utils.keyInObject)(newComputedStylesheet, key)) {
30
+ return;
31
+ }
32
+ const value = newComputedStylesheet[key];
33
+ const result = typeof value === 'function' ? value(...args) : value;
34
+ _registry.UnistylesRegistry.updateStyles(unistyles, result, className);
35
+ });
36
+ };
37
+ exports.listenToDependencies = listenToDependencies;
38
+ //# sourceMappingURL=listenToDependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_listener","require","_utils","_registry","listenToDependencies","key","className","unistyles","args","stylesheet","newComputedStylesheet","UnistylesRegistry","getComputedStylesheet","_value","keyInObject","undefined","value","dependencies","length","UnistylesListener","addListeners","result","updateStyles","exports"],"sourceRoot":"../../../../src","sources":["web/listener/listenToDependencies.ts"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAUO,MAAMG,oBAAoB,GAAGA,CAAC;EAAEC,GAAG;EAAEC,SAAS;EAAEC,SAAS;EAAEC,IAAI,GAAG,EAAE;EAAEC;AAAsC,CAAC,KAAK;EACrH,MAAMC,qBAAqB,GAAGC,2BAAiB,CAACC,qBAAqB,CAACH,UAAU,CAAC;EACjF,MAAMI,MAAM,GAAG,IAAAC,kBAAW,EAACJ,qBAAqB,EAAEL,GAAG,CAAC,GAAGK,qBAAqB,CAACL,GAAG,CAAC,GAAGU,SAAS;EAE/F,IAAI,CAACF,MAAM,EAAE;IACT;EACJ;EAEA,MAAMG,KAAK,GAAG,OAAOH,MAAM,KAAK,UAAU,GAAGA,MAAM,CAAC,GAAGL,IAAI,CAAC,GAAGK,MAAM;EACrE,MAAMI,YAAY,GAAI,mBAAmB,IAAID,KAAK,GAAGA,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAgC;EAElH,IAAIC,YAAY,CAACC,MAAM,KAAK,CAAC,EAAE;IAC3B;EACJ;EAEA,OAAOC,2BAAiB,CAACC,YAAY,CAACH,YAAY,EAAE,MAAM;IACtD,MAAMP,qBAAqB,GAAGC,2BAAiB,CAACC,qBAAqB,CAACH,UAAU,CAAC;IAEjF,IAAI,CAAC,IAAAK,kBAAW,EAACJ,qBAAqB,EAAEL,GAAG,CAAC,EAAE;MAC1C;IACJ;IAEA,MAAMW,KAAK,GAAGN,qBAAqB,CAACL,GAAG,CAAE;IACzC,MAAMgB,MAAM,GAAG,OAAOL,KAAK,KAAK,UAAU,GACpCA,KAAK,CAAC,GAAGR,IAAI,CAAC,GACdQ,KAAK;IAEXL,2BAAiB,CAACW,YAAY,CAACf,SAAS,EAAEc,MAAM,EAAEf,SAAS,CAAC;EAChE,CAAC,CAAC;AACN,CAAC;AAAAiB,OAAA,CAAAnB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesListener = void 0;
7
+ var _NativePlatform = require("../../specs/NativePlatform");
8
+ var _runtime = require("../runtime");
9
+ class UnistylesListenerBuilder {
10
+ isInitialized = false;
11
+ listeners = Array.from({
12
+ length: Object.keys(_NativePlatform.UnistyleDependency).length / 2
13
+ }, () => new Set());
14
+ emitChange = dependency => {
15
+ this.listeners[dependency]?.forEach(listener => listener());
16
+ };
17
+ initListeners = () => {
18
+ if (this.isInitialized) {
19
+ return;
20
+ }
21
+ this.isInitialized = true;
22
+ _runtime.UnistylesRuntime.darkMedia?.addEventListener('change', () => this.emitChange(_NativePlatform.UnistyleDependency.ColorScheme));
23
+ _runtime.UnistylesRuntime.lightMedia?.addEventListener('change', () => this.emitChange(_NativePlatform.UnistyleDependency.ColorScheme));
24
+ window.addEventListener('orientationchange', () => this.emitChange(_NativePlatform.UnistyleDependency.Orientation));
25
+ window.addEventListener('resize', () => this.emitChange(_NativePlatform.UnistyleDependency.Dimensions));
26
+ };
27
+ addListeners = (dependencies, listener) => {
28
+ dependencies.forEach(dependency => this.listeners[dependency]?.add(listener));
29
+ return () => {
30
+ dependencies.forEach(dependency => this.listeners[dependency]?.delete(listener));
31
+ };
32
+ };
33
+ }
34
+ const UnistylesListener = exports.UnistylesListener = new UnistylesListenerBuilder();
35
+ //# sourceMappingURL=listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","UnistylesListener","exports"],"sourceRoot":"../../../../src","sources":["web/listener/listener.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,wBAAwB,CAAC;EACnBC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,kCAAkB,CAAC,CAACH,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAII,GAAG,CAAe,CAAC,CAAC;EAErHC,UAAU,GAAIC,UAA8B,IAAK;IAC7C,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEC,OAAO,CAACC,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC;EAC/D,CAAC;EAEDC,aAAa,GAAGA,CAAA,KAAM;IAClB,IAAI,IAAI,CAACb,aAAa,EAAE;MACpB;IACJ;IAEA,IAAI,CAACA,aAAa,GAAG,IAAI;IACzBc,yBAAgB,CAACC,SAAS,EAAEC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACU,WAAW,CAAC,CAAC;IAC7GH,yBAAgB,CAACI,UAAU,EAAEF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF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