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,63 @@
1
+ "use strict";
2
+
3
+ export const validateShadow = (shadowProperties, styles, breakpoints) => {
4
+ // Collect breakpoints
5
+ shadowProperties.forEach(key => {
6
+ const value = styles[key];
7
+ if (typeof value !== 'object') {
8
+ return;
9
+ }
10
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
11
+ const {
12
+ width,
13
+ height
14
+ } = value;
15
+
16
+ // If shadowOffset.width has breakpoints
17
+ if (typeof width === 'object') {
18
+ Object.keys(width).forEach(breakpoint => breakpoints.add(breakpoint));
19
+ }
20
+
21
+ // If shadowOffset.height has breakpoints
22
+ if (typeof height === 'object') {
23
+ Object.keys(height).forEach(breakpoint => breakpoints.add(breakpoint));
24
+ }
25
+ return;
26
+ }
27
+
28
+ // Collect regular breakpoints
29
+ Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
30
+ });
31
+
32
+ // Validate if all breakpoints are present
33
+ shadowProperties.forEach(key => {
34
+ const value = styles[key];
35
+ if (typeof value !== 'object') {
36
+ return;
37
+ }
38
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
39
+ const {
40
+ width,
41
+ height
42
+ } = value;
43
+ if (typeof width === 'object') {
44
+ const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in width));
45
+ if (missingBreakpoints.length) {
46
+ throw `missing breakpoints in ${key}.width: ${missingBreakpoints.join(', ')}`;
47
+ }
48
+ }
49
+ if (typeof height === 'object') {
50
+ const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in height));
51
+ if (missingBreakpoints.length) {
52
+ throw `missing breakpoints in ${key}.height: ${missingBreakpoints.join(', ')}`;
53
+ }
54
+ }
55
+ return;
56
+ }
57
+ const missingBreakpoints = Array.from(breakpoints).filter(breakpoint => !(breakpoint in value));
58
+ if (missingBreakpoints.length) {
59
+ throw `missing breakpoints in ${key}: ${missingBreakpoints.join(', ')}`;
60
+ }
61
+ });
62
+ };
63
+ //# sourceMappingURL=shadow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["validateShadow","shadowProperties","styles","breakpoints","forEach","key","value","width","height","Object","keys","breakpoint","add","missingBreakpoints","Array","from","filter","length","join"],"sourceRoot":"../../../../src","sources":["web/convert/shadow.ts"],"mappings":";;AAEA,OAAO,MAAMA,cAAc,GAAGA,CAACC,gBAAuC,EAAEC,MAA2B,EAAEC,WAAwB,KAAK;EAC9H;EACAF,gBAAgB,CAACG,OAAO,CAACC,GAAG,IAAI;IAC5B,MAAMC,KAAK,GAAGJ,MAAM,CAACG,GAAG,CAAC;IAEzB,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAC3B;IACJ;IAEA,IAAID,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAK,kBAAkB,EAAE;MACtD,MAAM;QAAEE,KAAK;QAAEC;MAAO,CAAC,GAAGF,KAAqB;;MAE/C;MACA,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;QAC3BE,MAAM,CAACC,IAAI,CAACH,KAAK,CAAC,CAACH,OAAO,CAACO,UAAU,IAAIR,WAAW,CAACS,GAAG,CAACD,UAAU,CAAC,CAAC;MACzE;;MAEA;MACA,IAAI,OAAOH,MAAM,KAAK,QAAQ,EAAE;QAC5BC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACJ,OAAO,CAACO,UAAU,IAAIR,WAAW,CAACS,GAAG,CAACD,UAAU,CAAC,CAAC;MAC1E;MAEA;IACJ;;IAEA;IACAF,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC,CAACF,OAAO,CAACO,UAAU,IAAIR,WAAW,CAACS,GAAG,CAACD,UAAU,CAAC,CAAC;EACzE,CAAC,CAAC;;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":[]}
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+
3
+ import { keyInObject } from '../utils';
4
+ const stylesToSkip = ['borderCurve', 'elevation', 'textAlignVertical', 'includeFontPadding', 'overlayColor', 'tintColor'];
5
+ const convertMap = {
6
+ marginHorizontal: value => ({
7
+ marginInline: value
8
+ }),
9
+ marginVertical: value => ({
10
+ marginBlock: value
11
+ }),
12
+ paddingHorizontal: value => ({
13
+ paddingInline: value
14
+ }),
15
+ paddingVertical: value => ({
16
+ paddingBlock: value
17
+ }),
18
+ writingDirection: value => ({
19
+ direction: value
20
+ }),
21
+ borderBottomEndRadius: value => ({
22
+ borderBottomRightRadius: value
23
+ }),
24
+ borderBottomStartRadius: value => ({
25
+ borderBottomLeftRadius: value
26
+ }),
27
+ borderEndColor: value => ({
28
+ borderInlineEndColor: value
29
+ }),
30
+ borderStartColor: value => ({
31
+ borderInlineStartColor: value
32
+ }),
33
+ borderTopEndRadius: value => ({
34
+ borderTopRightRadius: value
35
+ }),
36
+ borderTopStartRadius: value => ({
37
+ borderTopLeftRadius: value
38
+ }),
39
+ borderEndWidth: value => ({
40
+ borderInlineEndWidth: value
41
+ }),
42
+ borderStartWidth: value => ({
43
+ borderInlineStartWidth: value
44
+ }),
45
+ end: value => ({
46
+ right: value
47
+ }),
48
+ start: value => ({
49
+ left: value
50
+ }),
51
+ marginEnd: value => ({
52
+ marginRight: value
53
+ }),
54
+ marginStart: value => ({
55
+ marginLeft: value
56
+ }),
57
+ paddingEnd: value => ({
58
+ paddingRight: value
59
+ }),
60
+ paddingStart: value => ({
61
+ paddingLeft: value
62
+ }),
63
+ transformMatrix: value => ({
64
+ transform: `matrix(${value.join(', ')})`
65
+ }),
66
+ resizeMode: value => ({
67
+ backgroundSize: value
68
+ }),
69
+ lineHeight: value => ({
70
+ lineHeight: `${value}px`
71
+ })
72
+ };
73
+ export const getStyle = (key, value) => {
74
+ if (stylesToSkip.includes(key)) {
75
+ return {};
76
+ }
77
+ if (keyInObject(convertMap, key)) {
78
+ return convertMap[key]?.(value) ?? {};
79
+ }
80
+ return {
81
+ [key]: value
82
+ };
83
+ };
84
+ //# sourceMappingURL=style.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["keyInObject","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"],"sourceRoot":"../../../../src","sources":["web/convert/style.ts"],"mappings":";;AAAA,SAASA,WAAW,QAAQ,UAAU;AAGtC,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,EAAEL;EACnB,CAAC,CAAC;EACFM,eAAe,EAAGN,KAAa,KAAM;IACjCO,YAAY,EAAEP;EAClB,CAAC,CAAC;EACFQ,gBAAgB,EAAGR,KAAa,KAAM;IAClCS,SAAS,EAAET;EACf,CAAC,CAAC;EACFU,qBAAqB,EAAGV,KAAa,KAAM;IACvCW,uBAAuB,EAAEX;EAC7B,CAAC,CAAC;EACFY,uBAAuB,EAAGZ,KAAa,KAAM;IACzCa,sBAAsB,EAAE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E7D,OAAO,MAAM4C,QAAQ,GAAGA,CAACC,GAAW,EAAE7C,KAAU,KAAK;EACjD,IAAIH,YAAY,CAACiD,QAAQ,CAACD,GAAG,CAAC,EAAE;IAC5B,OAAO,CAAC,CAAC;EACb;EAEA,IAAIjD,WAAW,CAACE,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","ignoreList":[]}
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+
3
+ import { media } from 'typestyle';
4
+ import { deepMergeObjects, warn } from '../utils';
5
+ import { validateShadow } from './shadow';
6
+ import { convertBreakpoint } from './breakpoint';
7
+ import { TEXT_SHADOW_STYLES } from './types';
8
+ import { extractShadowValue, normalizeColor, normalizeNumericValue } from './utils';
9
+ const createTextShadowValue = style => {
10
+ const {
11
+ textShadowColor,
12
+ textShadowOffset,
13
+ textShadowRadius
14
+ } = style;
15
+ const offsetX = normalizeNumericValue(textShadowOffset.width);
16
+ const offsetY = normalizeNumericValue(textShadowOffset.height);
17
+ const radius = normalizeNumericValue(textShadowRadius);
18
+ const color = normalizeColor(textShadowColor);
19
+ return `${offsetX} ${offsetY} ${radius} ${color}`;
20
+ };
21
+ export const getTextShadowStyle = styles => {
22
+ const missingStyles = TEXT_SHADOW_STYLES.filter(key => !(key in styles));
23
+ if (missingStyles.length) {
24
+ warn(`can't apply text shadow as you miss these properties: ${missingStyles.join(', ')}`);
25
+ return {};
26
+ }
27
+ const breakpointsSet = new Set();
28
+ try {
29
+ validateShadow(TEXT_SHADOW_STYLES, styles, breakpointsSet);
30
+ } catch (error) {
31
+ if (typeof error === 'string') {
32
+ warn(error);
33
+ }
34
+ return {};
35
+ }
36
+ const breakpoints = Array.from(breakpointsSet);
37
+
38
+ // If no breakpoints were used return styles without media queries
39
+ if (breakpoints.length === 0) {
40
+ return {
41
+ textShadow: createTextShadowValue(styles)
42
+ };
43
+ }
44
+
45
+ // Create textShadow for each breakpoint
46
+ const breakpointStyles = breakpoints.map(breakpoint => {
47
+ const color = extractShadowValue('textShadowColor', breakpoint, styles);
48
+ const {
49
+ width,
50
+ height
51
+ } = extractShadowValue('textShadowOffset', breakpoint, styles);
52
+ const radius = extractShadowValue('textShadowRadius', breakpoint, styles);
53
+ return media(convertBreakpoint(breakpoint), {
54
+ textShadow: createTextShadowValue({
55
+ textShadowColor: color,
56
+ textShadowOffset: {
57
+ width,
58
+ height
59
+ },
60
+ textShadowRadius: radius
61
+ })
62
+ });
63
+ });
64
+
65
+ // Merge all breakpoints styles into one
66
+ return deepMergeObjects(...breakpointStyles);
67
+ };
68
+ //# sourceMappingURL=textShadow.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["media","deepMergeObjects","warn","validateShadow","convertBreakpoint","TEXT_SHADOW_STYLES","extractShadowValue","normalizeColor","normalizeNumericValue","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","width","offsetY","height","radius","color","getTextShadowStyle","styles","missingStyles","filter","key","length","join","breakpointsSet","Set","error","breakpoints","Array","from","textShadow","breakpointStyles","map","breakpoint"],"sourceRoot":"../../../../src","sources":["web/convert/textShadow.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,WAAW;AAEjC,SAASC,gBAAgB,EAAEC,IAAI,QAAQ,UAAU;AACjD,SAASC,cAAc,QAAQ,UAAU;AACzC,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SAASC,kBAAkB,QAAyB,SAAS;AAC7D,SAASC,kBAAkB,EAAEC,cAAc,EAAEC,qBAAqB,QAAQ,SAAS;AAEnF,MAAMC,qBAAqB,GAAIC,KAAiB,IAAK;EACjD,MAAM;IAAEC,eAAe;IAAEC,gBAAgB;IAAEC;EAAiB,CAAC,GAAGH,KAAK;EACrE,MAAMI,OAAO,GAAGN,qBAAqB,CAACI,gBAAgB,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MAAEE;IAAO,CAAC,GAAGX,kBAAkB,CAAC,kBAAkB,EAAE8B,UAAU,EAAEf,MAAM,CAAC;IACpF,MAAMH,MAAM,GAAGZ,kBAAkB,CAAC,kBAAkB,EAAE8B,UAAU,EAAEf,MAAM,CAAC;IAEzE,OAAOrB,KAAK,CAACI,iBAAiB,CAACgC,UAAU,CAAC,EAAE;MACxCH,UAAU,EAAExB,qBAAqB,CAAC;QAC9BE,eAAe,EAAEQ,KAAK;QACtBP,gBAAgB,EAAE;UACdG,KAAK;UACLE;QACJ,CAAC;QACDJ,gBAAgB,EAAEK;MACtB,CAAC;IACL,CAAC,CAAC;EACN,CAAC,CAAC;;EAEF;EACA,OAAOjB,gBAAgB,CAAC,GAAGiC,gBAAgB,CAAC;AAChD,CAAC","ignoreList":[]}
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ import { media } from 'typestyle';
4
+ import { deepMergeObjects, keyInObject } from '../utils';
5
+ import { normalizeNumericValue } from './utils';
6
+ import { convertBreakpoint } from './breakpoint';
7
+ const normalizeTransform = (key, value) => {
8
+ if (key.includes('scale')) {
9
+ return value;
10
+ }
11
+ if (typeof value === 'number') {
12
+ return normalizeNumericValue(value);
13
+ }
14
+ return value;
15
+ };
16
+ const createTransformValue = transforms => transforms.map(transform => {
17
+ const [key] = Object.keys(transform);
18
+ if (!key) {
19
+ return undefined;
20
+ }
21
+ const value = transform[key];
22
+ switch (key) {
23
+ case 'matrix':
24
+ case 'matrix3d':
25
+ return `${key}(${value.join(',')})`;
26
+ default:
27
+ return `${key}(${normalizeTransform(key, value)})`;
28
+ }
29
+ }).filter(Boolean).join(' ');
30
+ export const getTransformStyle = transforms => {
31
+ const breakpoints = new Set();
32
+ const normalTransforms = [];
33
+ transforms.forEach(transform => {
34
+ const [property] = Object.keys(transform);
35
+ if (!property) {
36
+ return;
37
+ }
38
+ const value = transform[property];
39
+ if (typeof value === 'object' && !Array.isArray(value)) {
40
+ Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
41
+ return;
42
+ }
43
+ normalTransforms.push(transform);
44
+ });
45
+ const breakpointTransforms = Array.from(breakpoints).flatMap(breakpoint => {
46
+ const transformsPerBreakpoint = transforms.flatMap(transform => {
47
+ const [property] = Object.keys(transform);
48
+ if (!property) {
49
+ return [];
50
+ }
51
+ const value = transform[property];
52
+ if (typeof value === 'object' && !Array.isArray(value)) {
53
+ return keyInObject(value, breakpoint) ? [{
54
+ [property]: value[breakpoint]
55
+ }] : [];
56
+ }
57
+ return [];
58
+ });
59
+ return media(convertBreakpoint(breakpoint), {
60
+ transform: createTransformValue(transformsPerBreakpoint)
61
+ });
62
+ });
63
+ return deepMergeObjects({
64
+ transform: createTransformValue(normalTransforms)
65
+ }, ...breakpointTransforms);
66
+ };
67
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["media","deepMergeObjects","keyInObject","normalizeNumericValue","convertBreakpoint","normalizeTransform","key","value","includes","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"],"sourceRoot":"../../../../src","sources":["web/convert/transform.ts"],"mappings":";;AAAA,SAASA,KAAK,QAAQ,WAAW;AAEjC,SAASC,gBAAgB,EAAEC,WAAW,QAAQ,UAAU;AACxD,SAASC,qBAAqB,QAAQ,SAAS;AAC/C,SAASC,iBAAiB,QAAQ,cAAc;AAIhD,MAAMC,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,OAAOJ,qBAAqB,CAACI,KAAK,CAAC;EACvC;EAEA,OAAOA,KAAK;AAChB,CAAC;AAED,MAAME,oBAAoB,GAAIC,UAAsB,IAAKA,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Y,OAAO,CAACL,UAAU,IAAI;IACvE,MAAMM,uBAAuB,GAAGvB,UAAU,CAACsB,OAAO,CAACpB,SAAS,IAAI;MAC5D,MAAM,CAACY,QAAQ,CAAC,GAAGX,MAAM,CAACC,IAAI,CAACF,SAAS,CAAC;MAEzC,IAAI,CAACY,QAAQ,EAAE;QACX,OAAO,EAAE;MACb;MAEA,MAAMjB,KAAK,GAAGK,SAAS,CAACY,QAAQ,CAAC;MAEjC,IAAI,OAAOjB,KAAK,KAAK,QAAQ,IAAI,CAACkB,KAAK,CAACC,OAAO,CAACnB,KAAK,CAAC,EAAE;QACpD,OAAOL,WAAW,CAACK,KAAK,EAAEoB,UAAU,CAAC,GAAG,CAAC;UAAE,CAACH,QAAQ,GAAGjB,KAAK,CAACoB,UAAU;QAAE,CAAC,CAAC,GAAG,EAAE;MACpF;MAEA,OAAO,EAAE;IACb,CAAC,CAAC;IAEF,OAAO3B,KAAK,CAACI,iBAAiB,CAACuB,UAAU,CAAC,EAAE;MACxCf,SAAS,EAAEH,oBAAoB,CAACwB,uBAAuB;IAC3D,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAOhC,gBAAgB,CAAC;IACpBW,SAAS,EAAEH,oBAAoB,CAACa,gBAAgB;EACpD,CAAC,EAAE,GAAGQ,oBAAoB,CAAC;AAC/B,CAAC","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export const TEXT_SHADOW_STYLES = ['textShadowColor', 'textShadowOffset', 'textShadowRadius'];
4
+ export const BOX_SHADOW_STYLES = ['shadowColor', 'shadowRadius', 'shadowOpacity', 'shadowOffset'];
5
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["TEXT_SHADOW_STYLES","BOX_SHADOW_STYLES"],"sourceRoot":"../../../../src","sources":["web/convert/types.ts"],"mappings":";;AAKA,OAAO,MAAMA,kBAAkB,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,CAAU;AAItG,OAAO,MAAMC,iBAAiB,GAAG,CAAC,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAU","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ // based on react-native-web normalizer
4
+ // https://github.com/necolas/react-native-web
5
+ import normalizeColors from '@react-native/normalize-colors';
6
+ import { BOX_SHADOW_STYLES, TEXT_SHADOW_STYLES } from './types';
7
+ export const isTransform = (key, value) => key === 'transform' && Array.isArray(value);
8
+ export const isTextShadow = key => TEXT_SHADOW_STYLES.includes(key);
9
+ export const isBoxShadow = key => BOX_SHADOW_STYLES.includes(key);
10
+ export const normalizeNumericValue = value => value ? `${value}px` : value;
11
+ export const normalizeColor = (color, opacity = 1) => {
12
+ // If the opacity is 1 there's no need to normalize the color
13
+ if (opacity === 1) {
14
+ return color;
15
+ }
16
+ const integer = normalizeColors(color);
17
+
18
+ // If the color is an unknown format, the return value is null
19
+ if (integer === null) {
20
+ return color;
21
+ }
22
+ const hex = integer.toString(16).padStart(8, '0');
23
+ if (hex.length === 8) {
24
+ const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
25
+ return `rgba(${r},${g},${b},${a / 255 * opacity})`;
26
+ }
27
+ return color;
28
+ };
29
+ export const extractShadowValue = (key, breakpoint, styles) => {
30
+ const value = styles[key];
31
+ if (key === 'textShadowOffset' || key === 'shadowOffset') {
32
+ const {
33
+ width,
34
+ height
35
+ } = value;
36
+ return {
37
+ width: typeof width === 'object' ? width[breakpoint] : width,
38
+ height: typeof height === 'object' ? height[breakpoint] : height
39
+ };
40
+ }
41
+ return typeof value === 'object' ? value[breakpoint] : value;
42
+ };
43
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["normalizeColors","BOX_SHADOW_STYLES","TEXT_SHADOW_STYLES","isTransform","key","value","Array","isArray","isTextShadow","includes","isBoxShadow","normalizeNumericValue","normalizeColor","color","opacity","integer","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":";;AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAC5D,SAASC,iBAAiB,EAAEC,kBAAkB,QAA4C,SAAS;AAEnG,OAAO,MAAMC,WAAW,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAA0CD,GAAG,KAAK,WAAW,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAExI,OAAO,MAAMG,YAAY,GAAIJ,GAAW,IAAKF,kBAAkB,CAACO,QAAQ,CAACL,GAAwC,CAAC;AAElH,OAAO,MAAMM,WAAW,GAAIN,GAAW,IAAKH,iBAAiB,CAACQ,QAAQ,CAACL,GAAuC,CAAC;AAE/G,OAAO,MAAMO,qBAAqB,GAAIN,KAAa,IAAKA,KAAK,GAAG,GAAGA,KAAK,IAAI,GAAGA,KAAK;AAEpF,OAAO,MAAMO,cAAc,GAAGA,CAACC,KAAa,EAAEC,OAAe,GAAG,CAAC,KAAK;EAClE;EACA,IAAIA,OAAO,KAAK,CAAC,EAAE;IACf,OAAOD,KAAK;EAChB;EAEA,MAAME,OAAO,GAAGf,eAAe,CAACa,KAAK,CAAC;;EAEtC;EACA,IAAIE,OAAO,KAAK,IAAI,EAAE;IAClB,OAAOF,KAAK;EAChB;EAEA,MAAMG,GAAG,GAAGD,OAAO,CAACE,QAAQ,CAAC,EAAE,CAAC,CAACC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC;EAEjD,IAAIF,GAAG,CAACG,MAAM,KAAK,CAAC,EAAE;IAClB,MAAM,CAACC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGP,GAAG,CACnCQ,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GAAG,IAAI,CAACC,KAAK,CAACD,GAAG,CAAC,CAAC;IAE/B,OAAO,QAAQT,CAAC,IAAIC,CAAC,IAAIC,CAAC,IAAKC,CAAC,GAAG,GAAG,GAAIT,OAAO,GAAG;EACxD;EAEA,OAAOD,KAAK;AAChB,CAAC;AAED,OAAO,MAAMkB,kBAAkB,GAAGA,CAA6B3B,GAAS,EAAE4B,UAAkB,EAAEC,MAAW,KAAsB;EAC3H,MAAM5B,KAAK,GAAG4B,MAAM,CAAC7B,GAAG,CAAC;EAEzB,IAAIA,GAAG,KAAK,kBAAkB,IAAIA,GAAG,KAAK,cAAc,EAAE;IACtD,MAAM;MAAE8B,KAAK;MAAEC;IAAO,CAAC,GAAG9B,KAAK;IAE/B,OAAO;MACH6B,KAAK,EAAE,OAAOA,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAACF,UAAU,CAAC,GAAGE,KAAK;MAC5DC,MAAM,EAAE,OAAOA,MAAM,KAAK,QAAQ,GAAGA,MAAM,CAACH,UAAU,CAAC,GAAGG;IAC9D,CAAC;EACL;EAEA,OAAO,OAAO9B,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAAC2B,UAAU,CAAC,GAAG3B,KAAK;AAChE,CAAC","ignoreList":[]}
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ import { assignSecrets, reduceObject, getStyles } from './utils';
4
+ import { UnistylesRuntime } from './runtime';
5
+ import { createUseVariants, getVariants } from './variants';
6
+ export const create = stylesheet => {
7
+ const computedStylesheet = typeof stylesheet === 'function' ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : stylesheet;
8
+ const selectedVariants = new Map();
9
+ const copyVariants = () => Object.fromEntries(selectedVariants.entries());
10
+ const addSecrets = (value, key, args) => assignSecrets(value, {
11
+ __uni__key: key,
12
+ __uni__refs: new Set(),
13
+ __uni__stylesheet: stylesheet,
14
+ __uni__args: args,
15
+ __uni__variants: copyVariants()
16
+ });
17
+ const styles = reduceObject(computedStylesheet, (value, _key) => {
18
+ const key = String(_key);
19
+ if (typeof value === 'function') {
20
+ const dynamicStyle = (...args) => {
21
+ const result = value(...args);
22
+ const variants = Object.fromEntries(getVariants({
23
+ [key]: result
24
+ }, copyVariants()));
25
+ const resultWithVariants = {
26
+ ...result,
27
+ ...variants[key]
28
+ };
29
+
30
+ // Add secrets to result of dynamic styles function
31
+ return addSecrets(getStyles(resultWithVariants), key, args);
32
+ };
33
+
34
+ // Add secrets to dynamic styles function
35
+ return addSecrets(dynamicStyle, key);
36
+ }
37
+
38
+ // Add secrets to static styles
39
+ return addSecrets(getStyles(value), key);
40
+ });
41
+
42
+ // Inject useVariants hook to styles
43
+ createUseVariants(styles, newVariants => Object.entries(newVariants).forEach(([key, value]) => selectedVariants.set(key, value)));
44
+ return styles;
45
+ };
46
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["assignSecrets","reduceObject","getStyles","UnistylesRuntime","createUseVariants","getVariants","create","stylesheet","computedStylesheet","theme","miniRuntime","selectedVariants","Map","copyVariants","Object","fromEntries","entries","addSecrets","value","key","args","__uni__key","__uni__refs","Set","__uni__stylesheet","__uni__args","__uni__variants","styles","_key","String","dynamicStyle","result","variants","resultWithVariants","newVariants","forEach","set"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;AAEA,SAASA,aAAa,EAAEC,YAAY,EAAEC,SAAS,QAAQ,SAAS;AAChE,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,iBAAiB,EAAEC,WAAW,QAAQ,YAAY;AAE3D,OAAO,MAAMC,MAAM,GAAIC,UAAiD,IAAK;EACzE,MAAMC,kBAAkB,GAAG,OAAOD,UAAU,KAAK,UAAU,GACrDA,UAAU,CAACJ,gBAAgB,CAACM,KAAK,EAAEN,gBAAgB,CAACO,WAAW,CAAC,GAChEH,UAAU;EAChB,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f,iBAAiB,CAACuB,MAAM,EAAEO,WAAW,IAAIpB,MAAM,CAACE,OAAO,CAACkB,WAAW,CAAC,CAACC,OAAO,CAAC,CAAC,CAAChB,GAAG,EAAED,KAAK,CAAC,KAAKP,gBAAgB,CAACyB,GAAG,CAACjB,GAAG,EAAED,KAAK,CAAC,CAAC,CAAC;EAEjI,OAAOS,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ import React, { useEffect, useState } from 'react';
4
+ import { extractHiddenProperties, extractSecrets } from './utils';
5
+ import { getVariants } from './variants';
6
+ import { UnistylesListener } from './listener';
7
+ import { UnistylesRegistry } from './registry';
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ const getStyles = value => {
10
+ const secrets = extractSecrets(value);
11
+ if (secrets.length === 0) {
12
+ return undefined;
13
+ }
14
+ return secrets.reduce((acc, {
15
+ __uni__stylesheet,
16
+ __uni__key,
17
+ __uni__args = [],
18
+ __uni__variants
19
+ }) => {
20
+ const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
21
+ const style = newComputedStylesheet[__uni__key];
22
+ const resultHidden = typeof style === 'function' ? style(...__uni__args) : style;
23
+ const result = extractHiddenProperties(resultHidden);
24
+ const {
25
+ variants
26
+ } = Object.fromEntries(getVariants({
27
+ variants: result
28
+ }, __uni__variants));
29
+ const resultWithVariants = {
30
+ ...result,
31
+ ...variants
32
+ };
33
+ return {
34
+ ...acc,
35
+ ...resultWithVariants
36
+ };
37
+ }, {});
38
+ };
39
+ export const createUnistylesComponent = Component => props => {
40
+ const passedStyles = props.style ?? {};
41
+ const [style, setStyle] = useState(getStyles(passedStyles));
42
+ useEffect(() => {
43
+ const newStyles = getStyles(passedStyles);
44
+ const dependencies = newStyles?.['uni__dependencies'] ?? [];
45
+ const dispose = UnistylesListener.addListeners(dependencies, () => setStyle(getStyles(passedStyles)));
46
+ setStyle(newStyles);
47
+ return dispose;
48
+ }, [passedStyles]);
49
+ return /*#__PURE__*/_jsx(Component, {
50
+ ...props,
51
+ style: style
52
+ });
53
+ };
54
+ //# sourceMappingURL=createUnistylesComponent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","useEffect","useState","extractHiddenProperties","extractSecrets","getVariants","UnistylesListener","UnistylesRegistry","jsx","_jsx","getStyles","value","secrets","length","undefined","reduce","acc","__uni__stylesheet","__uni__key","__uni__args","__uni__variants","newComputedStylesheet","getComputedStylesheet","style","resultHidden","result","variants","Object","fromEntries","resultWithVariants","createUnistylesComponent","Component","props","passedStyles","setStyle","newStyles","dependencies","dispose","addListeners"],"sourceRoot":"../../../src","sources":["web/createUnistylesComponent.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,uBAAuB,EAAEC,cAAc,QAAQ,SAAS;AACjE,SAASC,WAAW,QAAQ,YAAY;AACxC,SAASC,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,iBAAiB,QAAQ,YAAY;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAE9C,MAAMC,SAAS,GAAIC,KAA0B,IAAK;EAC9C,MAAMC,OAAO,GAAGR,cAAc,CAACO,KAAK,CAAC;EAErC,IAAIC,OAAO,CAACC,MAAM,KAAK,CAAC,EAAE;IACtB,OAAOC,SAAS;EACpB;EAEA,OAAOF,OAAO,CAACG,MAAM,CAAC,CAACC,GAAG,EAAE;IAAEC,iBAAiB;IAAEC,UAAU;IAAEC,WAAW,GAAG,EAAE;IAAEC;EAAgB,CAAC,KAAK;IACjG,MAAMC,qBAAqB,GAAGd,iBAAiB,CAACe,qBAAqB,CAACL,iBAAiB,CAAC;IACxF,MAAMM,KAAK,GAAGF,qBAAqB,CAACH,UAAU,CAAC;IAC/C,MAAMM,YAAY,GAAG,OAAOD,KAAK,KAAK,UAAU,GAC1CA,KAAK,CAAC,GAAGJ,WAAW,CAAC,GACrBI,KAAK;IACX,MAAME,MAAM,GAAGtB,uBAAuB,CAACqB,YAAY,CAAC;IACpD,MAAM;MAAEE;IAAS,CAAC,GAAGC,MAAM,CAACC,WAAW,CAACvB,WAAW,CAAC;MAAEqB,QAAQ,EAAED;IAAO,CAAC,EAAEL,eAAgB,CAAC,CAAC;IAC5F,MAAMS,kBAAkB,GAAG;MACvB,GAAGJ,MAAM;MACT,GAAGC;IACP,CAAC;IAED,OAAO;MACH,GAAGV,GAAG;MACN,GAAGa;IACP,CAAC;EACL,CAAC,EAAE,CAAC,CAAwB,CAAC;AACjC,CAAC;AAED,OAAO,MAAMC,wBAAwB,GAA2BC,SAAsC,IAAMC,KAAa,IAAK;EAC1H,MAAMC,YAAY,GAAID,KAAK,CAA6CT,KAAK,IAAI,CAAC,CAAC;EACnF,MAAM,CAACA,KAAK,EAAEW,QAAQ,CAAC,GAAGhC,QAAQ,CAACQ,SAAS,CAACuB,YAAY,CAAC,CAAC;EAE3DhC,SAAS,CAAC,MAAM;IACZ,MAAMkC,SAAS,GAAGzB,SAAS,CAACuB,YAAY,CAAC;IACzC,MAAMG,YAAY,GAAGD,SAAS,GAAG,mBAAmB,CAAC,IAAI,EAAE;IAC3D,MAAME,OAAO,GAAG/B,iBAAiB,CAACgC,YAAY,CAACF,YAAY,EAAE,MAAMF,QAAQ,CAACxB,SAAS,CAACuB,YAAY,CAAC,CAAC,CAAC;IAErGC,QAAQ,CAACC,SAAS,CAAC;IAEnB,OAAOE,OAAO;EAClB,CAAC,EAAE,CAACJ,YAAY,CAAC,CAAC;EAElB,oBACIxB,IAAA,CAACsB,SAAS;IAAA,GACFC,KAAK;IACTT,KAAK,EAAEA;EAAM,CAChB,CAAC;AAEV,CAAC","ignoreList":[]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ import { create } from './create';
4
+ import { UnistylesState } from './state';
5
+ import { deepMergeObjects } from './utils';
6
+ export const StyleSheet = {
7
+ configure: UnistylesState.init,
8
+ create,
9
+ absoluteFill: {
10
+ position: 'absolute',
11
+ left: 0,
12
+ top: 0,
13
+ right: 0,
14
+ bottom: 0
15
+ },
16
+ compose: (a, b) => deepMergeObjects(a, b),
17
+ flatten: (...styles) => deepMergeObjects(...styles),
18
+ hairlineWidth: 1
19
+ };
20
+ export { UnistylesRuntime } from './runtime';
21
+ export { UnistylesShadowRegistry } from './shadowRegistry';
22
+ export * from './mock';
23
+
24
+ // TODO: Work on SSR
25
+ export const getSSRUnistyles = () => [];
26
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["create","UnistylesState","deepMergeObjects","StyleSheet","configure","init","absoluteFill","position","left","top","right","bottom","compose","a","b","flatten","styles","hairlineWidth","UnistylesRuntime","UnistylesShadowRegistry","getSSRUnistyles"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,gBAAgB,QAAQ,SAAS;AAE1C,OAAO,MAAMC,UAAU,GAAG;EACtBC,SAAS,EAAEH,cAAc,CAACI,IAAI;EAC9BL,MAAM;EACNM,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,KAAKZ,gBAAgB,CAACW,CAAC,EAAEC,CAAC,CAAC;EACzDC,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAKd,gBAAgB,CAAC,GAAGc,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAED,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,cAAc,QAAQ;;AAEtB;AACA,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAM,EAAE","ignoreList":[]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ export { UnistylesListener } from './listener';
4
+ export { listenToDependencies } from './listenToDependencies';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistylesListener","listenToDependencies"],"sourceRoot":"../../../../src","sources":["web/listener/index.ts"],"mappings":";;AAAA,SAASA,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,oBAAoB,QAAQ,wBAAwB","ignoreList":[]}
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ import { UnistylesListener } from './listener';
4
+ import { keyInObject } from '../utils';
5
+ import { UnistylesRegistry } from '../registry';
6
+ export const listenToDependencies = ({
7
+ key,
8
+ className,
9
+ unistyles,
10
+ args = [],
11
+ stylesheet
12
+ }) => {
13
+ const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(stylesheet);
14
+ const _value = keyInObject(newComputedStylesheet, key) ? newComputedStylesheet[key] : undefined;
15
+ if (!_value) {
16
+ return;
17
+ }
18
+ const value = typeof _value === 'function' ? _value(...args) : _value;
19
+ const dependencies = 'uni__dependencies' in value ? value['uni__dependencies'] : [];
20
+ if (dependencies.length === 0) {
21
+ return;
22
+ }
23
+ return UnistylesListener.addListeners(dependencies, () => {
24
+ const newComputedStylesheet = UnistylesRegistry.getComputedStylesheet(stylesheet);
25
+ if (!keyInObject(newComputedStylesheet, key)) {
26
+ return;
27
+ }
28
+ const value = newComputedStylesheet[key];
29
+ const result = typeof value === 'function' ? value(...args) : value;
30
+ UnistylesRegistry.updateStyles(unistyles, result, className);
31
+ });
32
+ };
33
+ //# sourceMappingURL=listenToDependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistylesListener","keyInObject","UnistylesRegistry","listenToDependencies","key","className","unistyles","args","stylesheet","newComputedStylesheet","getComputedStylesheet","_value","undefined","value","dependencies","length","addListeners","result","updateStyles"],"sourceRoot":"../../../../src","sources":["web/listener/listenToDependencies.ts"],"mappings":";;AAGA,SAASA,iBAAiB,QAAQ,YAAY;AAC9C,SAASC,WAAW,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esRuntime } from '../runtime';
5
+ class UnistylesListenerBuilder {
6
+ isInitialized = false;
7
+ listeners = Array.from({
8
+ length: Object.keys(UnistyleDependency).length / 2
9
+ }, () => new Set());
10
+ emitChange = dependency => {
11
+ this.listeners[dependency]?.forEach(listener => listener());
12
+ };
13
+ initListeners = () => {
14
+ if (this.isInitialized) {
15
+ return;
16
+ }
17
+ this.isInitialized = true;
18
+ UnistylesRuntime.darkMedia?.addEventListener('change', () => this.emitChange(UnistyleDependency.ColorScheme));
19
+ UnistylesRuntime.lightMedia?.addEventListener('change', () => this.emitChange(UnistyleDependency.ColorScheme));
20
+ window.addEventListener('orientationchange', () => this.emitChange(UnistyleDependency.Orientation));
21
+ window.addEventListener('resize', () => this.emitChange(UnistyleDependency.Dimensions));
22
+ };
23
+ addListeners = (dependencies, listener) => {
24
+ dependencies.forEach(dependency => this.listeners[dependency]?.add(listener));
25
+ return () => {
26
+ dependencies.forEach(dependency => this.listeners[dependency]?.delete(listener));
27
+ };
28
+ };
29
+ }
30
+ export const UnistylesListener = new UnistylesListenerBuilder();
31
+ //# sourceMappingURL=listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["UnistyleDependency","UnistylesRuntime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","Set","emitChange","dependency","forEach","listener","initListeners","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","UnistylesListener"],"sourceRoot":"../../../../src","sources":["web/listener/listener.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,4BAA4B;AAC/D,SAASC,gBAAgB,QAAQ,YAAY;AAE7C,MAAMC,wBAAwB,CAAC;EACnBC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACT,kBAAkB,CAAC,CAACO,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAIG,GAAG,CAAe,CAAC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= {
4
+ width: 0,
5
+ height: 0,
6
+ setStyle: () => {},
7
+ setHidden: () => {},
8
+ setBackgroundColor: () => {},
9
+ equals: () => true,
10
+ toString: () => 'StatusBar',
11
+ __type: 'web',
12
+ name: 'StatusBar'
13
+ };
14
+ export const NavigationBar = {
15
+ width: 0,
16
+ height: 0,
17
+ setHidden: () => {},
18
+ setBackgroundColor: () => {},
19
+ equals: () => true,
20
+ toString: () => 'NavigationBar',
21
+ __type: 'web',
22
+ name: 'NavigationBar'
23
+ };
24
+ //# sourceMappingURL=mock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StatusBar","width","height","setStyle","setHidden","setBackgroundColor","equals","toString","__type","name","NavigationBar"],"sourceRoot":"../../../src","sources":["web/mock.ts"],"mappings":";;AAGA,OAAO,MAAMA,SAAwB,GAAG;EACpCC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClBC,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC5BC,MAAM,EAAEA,CAAA,KAAM,IAAI;EAClBC,QAAQ,EAAEA,CAAA,KAAM,WAAW;EAC3BC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE;AACV,CAAC;AAED,OAAO,MAAMC,aAAgC,GAAG;EAC5CT,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTE,SAAS,EAAEA,CAAA,KAAM,CAAC,CAAC;EACnBC,kBAAkB,EAAEA,CAAA,KAAM,CAAC,CAAC;EAC5BC,MAAM,EAAEA,CAAA,KAAM,IAAI;EAClBC,QAAQ,EAAEA,CAAA,KAAM,eAAe;EAC/BC,MAAM,EAAE,KAAK;EACbC,IAAI,EAAE;AACV,CAAC","ignoreList":[]}