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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (328) hide show
  1. package/Unistyles.podspec +3 -2
  2. package/cxx/common/Constants.h +3 -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 +58 -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/expo-example/app/(tabs)/_layout.d.ts +3 -0
  172. package/lib/typescript/expo-example/app/(tabs)/_layout.d.ts.map +1 -0
  173. package/lib/typescript/expo-example/app/(tabs)/explore.d.ts +3 -0
  174. package/lib/typescript/expo-example/app/(tabs)/explore.d.ts.map +1 -0
  175. package/lib/typescript/expo-example/app/(tabs)/index.d.ts +3 -0
  176. package/lib/typescript/expo-example/app/(tabs)/index.d.ts.map +1 -0
  177. package/lib/typescript/expo-example/app/+html.d.ts +4 -0
  178. package/lib/typescript/expo-example/app/+html.d.ts.map +1 -0
  179. package/lib/typescript/expo-example/app/+not-found.d.ts +3 -0
  180. package/lib/typescript/expo-example/app/+not-found.d.ts.map +1 -0
  181. package/lib/typescript/expo-example/app/_layout.d.ts +3 -0
  182. package/lib/typescript/expo-example/app/_layout.d.ts.map +1 -0
  183. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +3 -3
  184. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  185. package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -1
  186. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  187. package/lib/typescript/src/specs/index.web.d.ts +1 -1
  188. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  189. package/lib/typescript/src/types/stylesheet.d.ts +2 -2
  190. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  191. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
  192. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
  193. package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
  194. package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
  195. package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
  196. package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
  197. package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
  198. package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
  199. package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
  200. package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
  201. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
  202. package/lib/typescript/{web → src/web}/create.d.ts +11 -11
  203. package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
  204. package/lib/typescript/src/web/createUnistylesComponent.d.ts +3 -0
  205. package/lib/typescript/src/web/createUnistylesComponent.d.ts.map +1 -0
  206. package/lib/typescript/{web → src/web}/index.d.ts +14 -13
  207. package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
  208. package/lib/typescript/src/web/listener/index.d.ts +3 -0
  209. package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
  210. package/lib/typescript/src/web/listener/listenToDependencies.d.ts +12 -0
  211. package/lib/typescript/src/web/listener/listenToDependencies.d.ts.map +1 -0
  212. package/lib/typescript/{web → src/web}/listener/listener.d.ts +3 -2
  213. package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
  214. package/lib/typescript/src/web/mock.d.ts +5 -0
  215. package/lib/typescript/src/web/mock.d.ts.map +1 -0
  216. package/lib/typescript/src/web/mq.d.ts.map +1 -0
  217. package/lib/typescript/src/web/pseudo.d.ts +6 -0
  218. package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
  219. package/lib/typescript/src/web/registry.d.ts +15 -0
  220. package/lib/typescript/src/web/registry.d.ts.map +1 -0
  221. package/lib/typescript/{web → src/web}/runtime.d.ts +6 -7
  222. package/lib/typescript/src/web/runtime.d.ts.map +1 -0
  223. package/lib/typescript/src/web/shadowRegistry.d.ts +17 -0
  224. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -0
  225. package/lib/typescript/{web → src/web}/state.d.ts +4 -9
  226. package/lib/typescript/src/web/state.d.ts.map +1 -0
  227. package/lib/typescript/src/web/utils.d.ts +35 -0
  228. package/lib/typescript/src/web/utils.d.ts.map +1 -0
  229. package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
  230. package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
  231. package/lib/typescript/src/web/variants/index.d.ts +3 -0
  232. package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
  233. package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
  234. package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
  235. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -3
  236. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +8 -3
  237. package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +1 -1
  238. package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +1 -1
  239. package/nitrogen/generated/ios/swift/HybridNativePlatformSpecCxx.swift +14 -2
  240. package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +3 -0
  241. package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +3 -0
  242. package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +3 -0
  243. package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +3 -0
  244. package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +3 -0
  245. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -1
  246. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +4 -1
  247. package/package.json +3 -3
  248. package/plugin/__tests__/dependencies.spec.js +199 -111
  249. package/plugin/__tests__/ref.spec.js +638 -202
  250. package/plugin/__tests__/stylesheet.spec.js +182 -71
  251. package/plugin/index.js +110 -23
  252. package/plugin/ref.js +64 -13
  253. package/plugin/style.js +82 -22
  254. package/plugin/stylesheet.js +44 -1
  255. package/plugin/variants.js +33 -0
  256. package/src/index.ts +3 -0
  257. package/src/specs/NavigtionBar/index.ts +1 -1
  258. package/src/specs/ShadowRegistry/index.ts +10 -9
  259. package/src/specs/StatusBar/index.ts +1 -1
  260. package/src/specs/StyleSheet/index.ts +3 -1
  261. package/src/specs/UnistylesRuntime/index.ts +1 -1
  262. package/src/specs/index.web.ts +1 -1
  263. package/src/types/stylesheet.ts +2 -2
  264. package/{web → src/web}/convert/breakpoint.ts +1 -1
  265. package/{web → src/web}/convert/index.ts +2 -2
  266. package/{web → src/web}/convert/types.ts +1 -1
  267. package/src/web/create.ts +50 -0
  268. package/src/web/createUnistylesComponent.tsx +54 -0
  269. package/{web → src/web}/index.ts +3 -2
  270. package/src/web/listener/index.ts +2 -0
  271. package/src/web/listener/listenToDependencies.ts +45 -0
  272. package/{web → src/web}/listener/listener.ts +2 -2
  273. package/{web → src/web}/mock.ts +2 -12
  274. package/src/web/pseudo.ts +137 -0
  275. package/src/web/registry.ts +60 -0
  276. package/{web → src/web}/runtime.ts +4 -6
  277. package/src/web/shadowRegistry.ts +124 -0
  278. package/{web → src/web}/state.ts +5 -49
  279. package/{web → src/web}/utils.ts +91 -17
  280. package/src/web/variants/getVariants.ts +42 -0
  281. package/src/web/variants/index.ts +2 -0
  282. package/src/web/variants/useVariants.ts +65 -0
  283. package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
  284. package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
  285. package/lib/typescript/web/convert/index.d.ts.map +0 -1
  286. package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
  287. package/lib/typescript/web/convert/style.d.ts.map +0 -1
  288. package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
  289. package/lib/typescript/web/convert/transform.d.ts.map +0 -1
  290. package/lib/typescript/web/convert/types.d.ts.map +0 -1
  291. package/lib/typescript/web/convert/utils.d.ts.map +0 -1
  292. package/lib/typescript/web/listener/index.d.ts +0 -2
  293. package/lib/typescript/web/listener/index.d.ts.map +0 -1
  294. package/lib/typescript/web/listener/listener.d.ts.map +0 -1
  295. package/lib/typescript/web/mock.d.ts +0 -14
  296. package/lib/typescript/web/mock.d.ts.map +0 -1
  297. package/lib/typescript/web/mq.d.ts.map +0 -1
  298. package/lib/typescript/web/pseudo.d.ts +0 -4
  299. package/lib/typescript/web/pseudo.d.ts.map +0 -1
  300. package/lib/typescript/web/registry.d.ts +0 -12
  301. package/lib/typescript/web/registry.d.ts.map +0 -1
  302. package/lib/typescript/web/runtime.d.ts.map +0 -1
  303. package/lib/typescript/web/state.d.ts.map +0 -1
  304. package/lib/typescript/web/useVariants.d.ts +0 -3
  305. package/lib/typescript/web/useVariants.d.ts.map +0 -1
  306. package/lib/typescript/web/utils.d.ts +0 -18
  307. package/lib/typescript/web/utils.d.ts.map +0 -1
  308. package/web/create.ts +0 -102
  309. package/web/listener/index.ts +0 -1
  310. package/web/pseudo.ts +0 -11
  311. package/web/registry.ts +0 -41
  312. package/web/useVariants.ts +0 -99
  313. /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
  314. /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
  315. /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
  316. /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
  317. /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
  318. /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
  319. /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
  320. /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
  321. /package/{web → src/web}/convert/boxShadow.ts +0 -0
  322. /package/{web → src/web}/convert/module.d.ts +0 -0
  323. /package/{web → src/web}/convert/shadow.ts +0 -0
  324. /package/{web → src/web}/convert/style.ts +0 -0
  325. /package/{web → src/web}/convert/textShadow.ts +0 -0
  326. /package/{web → src/web}/convert/transform.ts +0 -0
  327. /package/{web → src/web}/convert/utils.ts +0 -0
  328. /package/{web → src/web}/mq.ts +0 -0
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.StatusBar = exports.NavigationBar = void 0;
7
+ const StatusBar = exports.StatusBar = {
8
+ width: 0,
9
+ height: 0,
10
+ setStyle: () => {},
11
+ setHidden: () => {},
12
+ setBackgroundColor: () => {},
13
+ equals: () => true,
14
+ toString: () => 'StatusBar',
15
+ __type: 'web',
16
+ name: 'StatusBar'
17
+ };
18
+ const NavigationBar = exports.NavigationBar = {
19
+ width: 0,
20
+ height: 0,
21
+ setHidden: () => {},
22
+ setBackgroundColor: () => {},
23
+ equals: () => true,
24
+ toString: () => 'NavigationBar',
25
+ __type: 'web',
26
+ name: 'NavigationBar'
27
+ };
28
+ //# sourceMappingURL=mock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StatusBar","exports","width","height","setStyle","setHidden","setBackgroundColor","equals","toString","__type","name","NavigationBar"],"sourceRoot":"../../../src","sources":["web/mock.ts"],"mappings":";;;;;;AAGO,MAAMA,SAAwB,GAAAC,OAAA,CAAAD,SAAA,GAAG;EACpCE,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;AAEM,MAAMC,aAAgC,GAAAV,OAAA,CAAAU,aAAA,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":[]}
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.parseMq = exports.isUnistylesMq = void 0;
7
+ const IS_UNISTYLES_REGEX = /:([hw])\[(\d+)(?:,\s*(\d+|Infinity))?]/;
8
+ const UNISTYLES_WIDTH_REGEX = /:(w)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
9
+ const UNISTYLES_HEIGHT_REGEX = /:(h)\[(\d+)(?:,\s*(\d+|Infinity))?]/;
10
+ const parseMq = mq => {
11
+ const [, width, fromW, toW] = UNISTYLES_WIDTH_REGEX.exec(mq) || [];
12
+ const [, height, fromH, toH] = UNISTYLES_HEIGHT_REGEX.exec(mq) || [];
13
+ return {
14
+ minWidth: !width || fromW === 'Infinity' ? undefined : Number(fromW),
15
+ maxWidth: !width || toW === 'Infinity' ? undefined : Number(toW),
16
+ minHeight: !height || fromH === 'Infinity' ? undefined : Number(fromH),
17
+ maxHeight: !height || toH === 'Infinity' ? undefined : Number(toH)
18
+ };
19
+ };
20
+ exports.parseMq = parseMq;
21
+ const isUnistylesMq = mq => IS_UNISTYLES_REGEX.test(mq);
22
+ exports.isUnistylesMq = isUnistylesMq;
23
+ //# sourceMappingURL=mq.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","parseMq","mq","width","fromW","toW","exec","height","fromH","toH","minWidth","undefined","Number","maxWidth","minHeight","maxHeight","exports","isUnistylesMq","test"],"sourceRoot":"../../../src","sources":["web/mq.ts"],"mappings":";;;;;;AAEA,MAAMA,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAE7D,MAAMC,OAAO,GAAIC,EAAU,IAAiB;EAC/C,MAAM,GAAGC,KAAK,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGN,qBAAqB,CAACO,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAClE,MAAM,GAAGK,MAAM,EAAEC,KAAK,EAAEC,GAAG,CAAC,GAAGT,sBAAsB,CAACM,IAAI,CAACJ,EAAE,CAAC,IAAI,EAAE;EAEpE,OAAO;IACHQ,QAAQ,EAAE,CAACP,KAAK,IAAIC,KAAK,KAAK,UAAU,GAAGO,SAAS,GAAGC,MAAM,CAACR,KAAK,CAAC;IACpES,QAAQ,EAAE,CAACV,KAAK,IAAIE,GAAG,KAAK,UAAU,GAAGM,SAAS,GAAGC,MAAM,CAACP,GAAG,CAAC;IAChES,SAAS,EAAE,CAACP,MAAM,IAAIC,KAAK,KAAK,UAAU,GAAGG,SAAS,GAAGC,MAAM,CAACJ,KAAK,CAAC;IACtEO,SAAS,EAAE,CAACR,MAAM,IAAIE,GAAG,KAAK,UAAU,GAAGE,SAAS,GAAGC,MAAM,CAACH,GAAG;EACrE,CAAC;AACL,CAAC;AAAAO,OAAA,CAAAf,OAAA,GAAAA,OAAA;AAEM,MAAMgB,aAAa,GAAIf,EAAU,IAAKJ,kBAAkB,CAACoB,IAAI,CAAChB,EAAE,CAAC;AAAAc,OAAA,CAAAC,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.pseudos = exports.isPseudo = void 0;
7
+ const pseudos = exports.pseudos = ['_-moz-broken', '_-moz-drag-over', '_-moz-first-node', '_-moz-handler-blocked', '_-moz-handler-crashed', '_-moz-handler-disabled', '_-moz-last-node', '_-moz-loading', '_-moz-locale-dir(ltr)', '_-moz-locale-dir(rtl)', '_-moz-only-whitespace', '_-moz-submit-invalid', '_-moz-suppressed', '_-moz-user-disabled', '_-moz-window-inactive', '_active', '_any-link', '_autofill', '_blank', '_buffering', '_checked', '_current', '_default', '_defined', '_dir(', '_disabled', '_empty', '_enabled', '_first', '_first-child', '_first-of-type', '_focus', '_focus-visible', '_focus-within', '_fullscreen', '_future', '_has(', '_host', '_host-context(', '_host(', '_hover', '_in-range', '_indeterminate', '_invalid', '_is(', '_lang(', '_last-child', '_last-of-type', '_left', '_link', '_local-link', '_modal', '_muted', '_not(', '_nth-child(', '_nth-last-child(', '_nth-last-of-type(', '_nth-of-type(', '_only-child', '_only-of-type', '_optional', '_out-of-range', '_past', '_paused', '_picture-in-picture', '_placeholder-shown', '_playing', '_popover-open', '_read-only', '_read-write', '_required', '_right', '_scope', '_seeking', '_stalled', '_state(', '_target', '_target-within', '_user-invalid', '_user-valid', '_valid', '_visited', '_volume-locked', '_where(', '_-moz-color-swatch', '_-moz-focus-inner', '_-moz-list-bullet', '_-moz-list-number', '_-moz-meter-bar', '_-moz-progress-bar', '_-moz-range-progress', '_-moz-range-thumb', '_-moz-range-track', '_-webkit-inner-spin-button', '_-webkit-meter-barDeprecated', '_-webkit-meter-even-less-good-value', '_-webkit-meter-inner-element', '_-webkit-meter-optimum-value', '_-webkit-meter-suboptimum-value', '_-webkit-progress-bar', '_-webkit-progress-inner-element', '_-webkit-progress-value', '_-webkit-scrollbar', '_-webkit-search-cancel-button', '_-webkit-search-results-button', '_-webkit-slider-runnable-track', '_-webkit-slider-thumb', '_after', '_backdrop', '_before', '_cue', '_file-selector-button', '_first-letter', '_first-line', '_grammar-error', '_highlight(', '_marker', '_part(', '_placeholder', '_selection', '_slotted(', '_spelling-error', '_target-text', '_view-transition', '_view-transition-group', '_view-transition-image-pair', '_view-transition-new', '_view-transition-old'];
8
+ const isPseudo = selector => pseudos.some(pseudo => selector.startsWith(pseudo));
9
+ exports.isPseudo = isPseudo;
10
+ //# sourceMappingURL=pseudo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["pseudos","exports","isPseudo","selector","some","pseudo","startsWith"],"sourceRoot":"../../../src","sources":["web/pseudo.ts"],"mappings":";;;;;;AAAO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,CACnB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,iBAAiB,EACjB,eAAe,EACf,uBAAuB,EACvB,uBAAuB,EACvB,uBAAuB,EACvB,sBAAsB,EACtB,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,SAAS,EACT,WAAW,EACX,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,UAAU,EACV,UAAU,EACV,UAAU,EACV,OAAO,EACP,WAAW,EACX,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,QAA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,GAAIC,QAAgB,IAAKH,OAAO,CAACI,IAAI,CAACC,MAAM,IAAIF,QAAQ,CAACG,UAAU,CAACD,MAAM,CAAC,CAAC;AAAAJ,OAAA,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesRegistry = void 0;
7
+ var _typestyle = require("typestyle");
8
+ var _convert = require("./convert");
9
+ var _runtime = require("./runtime");
10
+ var _utils = require("./utils");
11
+ var _listener = require("./listener");
12
+ class UnistylesRegistryBuilder {
13
+ stylesheets = new Map();
14
+ getComputedStylesheet = stylesheet => {
15
+ if (typeof stylesheet !== 'function') {
16
+ return stylesheet;
17
+ }
18
+ const computedStylesheet = this.stylesheets.get(stylesheet);
19
+ if (computedStylesheet) {
20
+ return computedStylesheet;
21
+ }
22
+ const createdStylesheet = stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime);
23
+ // @ts-expect-error uni__dependencies is hidden
24
+ const dependencies = Object.values(createdStylesheet).flatMap(value => (0, _utils.keyInObject)(value, 'uni__dependencies') ? value.uni__dependencies : []);
25
+ _listener.UnistylesListener.addListeners(dependencies, () => {
26
+ const newComputedStylesheet = stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime);
27
+ this.stylesheets.set(stylesheet, newComputedStylesheet);
28
+ });
29
+ this.stylesheets.set(stylesheet, createdStylesheet);
30
+ return createdStylesheet;
31
+ };
32
+ createStyles = (stylesheet, key) => {
33
+ const unistyles = (0, _typestyle.createTypeStyle)();
34
+ const typestyleStylesheet = (0, _convert.convertToTypeStyle)(stylesheet);
35
+ const className = unistyles.style({
36
+ $debugName: `${key}-${Math.random().toString(16).slice(10)}`
37
+ }, typestyleStylesheet);
38
+ return {
39
+ className,
40
+ unistyles
41
+ };
42
+ };
43
+ updateStyles = (unistyles, stylesheet, className) => {
44
+ const typestyleStylesheet = (0, _convert.convertToTypeStyle)(stylesheet);
45
+ unistyles.reinit();
46
+ unistyles.cssRule(`.${className}`, typestyleStylesheet);
47
+ };
48
+ }
49
+ const UnistylesRegistry = exports.UnistylesRegistry = new UnistylesRegistryBuilder();
50
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_typestyle","require","_convert","_runtime","_utils","_listener","UnistylesRegistryBuilder","stylesheets","Map","getComputedStylesheet","stylesheet","computedStylesheet","get","createdStylesheet","UnistylesRuntime","theme","miniRuntime","dependencies","Object","values","flatMap","value","keyInObject","uni__dependencies","UnistylesListener","addListeners","newComputedStylesheet","set","createStyles","key","unistyles","createTypeStyle","typestyleStylesheet","convertToTypeStyle","className","style","$debugName","Math","random","toString","slice","updateStyles","reinit","cssRule","UnistylesRegistry","exports"],"sourceRoot":"../../../src","sources":["web/registry.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AAEA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAEA,MAAMK,wBAAwB,CAAC;EACnBC,WAAW,GAAG,IAAIC,GAAG,CAAoD,CAAC;EAElFC,qBAAqB,GAAIC,UAAiD,IAAK;IAC3E,IAAI,OAAOA,UAAU,KAAK,UAAU,EAAE;MAClC,OAAOA,UAAU;IACrB;IAEA,MAAMC,kBAAkB,GAAG,IAAI,CAACJ,WAAW,CAACK,GAAG,CAACF,UAAU,CAAC;IAE3D,IAAIC,kBAAkB,EAAE;MACpB,OAAOA,kBAAkB;IAC7B;IAEA,MAAME,iBAAiB,GAAGH,UAAU,CAACI,yBAAgB,CAACC,KAAK,EAAED,yBAAgB,CAACE,WAAW,CAAC;IAC1F;IACA,MAAMC,YAAY,GAAGC,MAAM,CAACC,MAAM,CAACN,iBAAiB,CAAC,CAACO,OAAO,CAACC,KAAK,I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CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,163 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesRuntime = void 0;
7
+ var _NativePlatform = require("../specs/NativePlatform");
8
+ var _types = require("../specs/types");
9
+ var _types2 = require("../types");
10
+ var _listener = require("./listener");
11
+ var _mock = require("./mock");
12
+ var _state = require("./state");
13
+ var _utils = require("./utils");
14
+ class UnistylesRuntimeBuilder {
15
+ lightMedia = this.getLightMedia();
16
+ darkMedia = this.getDarkMedia();
17
+ getLightMedia() {
18
+ if ((0, _utils.isServer)()) {
19
+ return null;
20
+ }
21
+ if (!this.lightMedia) {
22
+ this.lightMedia = window.matchMedia('(prefers-color-scheme: light)');
23
+ }
24
+ return this.lightMedia;
25
+ }
26
+ getDarkMedia() {
27
+ if ((0, _utils.isServer)()) {
28
+ return null;
29
+ }
30
+ if (!this.darkMedia) {
31
+ this.darkMedia = window.matchMedia('(prefers-color-scheme: dark)');
32
+ }
33
+ return this.darkMedia;
34
+ }
35
+ get colorScheme() {
36
+ switch (true) {
37
+ case this.getLightMedia()?.matches:
38
+ return _types.ColorScheme.Light;
39
+ case this.getDarkMedia()?.matches:
40
+ return _types.ColorScheme.Dark;
41
+ default:
42
+ return _types.ColorScheme.Unspecified;
43
+ }
44
+ }
45
+ get themeName() {
46
+ return _state.UnistylesState.themeName;
47
+ }
48
+ get contentSizeCategory() {
49
+ return _types2.WebContentSizeCategory.Unspecified;
50
+ }
51
+ get breakpoint() {
52
+ return _state.UnistylesState.breakpoint;
53
+ }
54
+ get orientation() {
55
+ if ((0, _utils.isServer)()) {
56
+ return _types.Orientation.Portrait;
57
+ }
58
+ return screen.orientation.type.includes('portrait') ? _types.Orientation.Portrait : _types.Orientation.Landscape;
59
+ }
60
+ get theme() {
61
+ if (!this.themeName) {
62
+ throw new Error('🦄 No theme selected!');
63
+ }
64
+ const theme = _state.UnistylesState.themes.get(this.themeName);
65
+ if (!theme) {
66
+ throw new Error(`🦄 Theme "${this.themeName}" is not registered!`);
67
+ }
68
+ return theme;
69
+ }
70
+ get pixelRatio() {
71
+ return (0, _utils.isServer)() ? 1 : window.devicePixelRatio;
72
+ }
73
+ get screen() {
74
+ if ((0, _utils.isServer)()) {
75
+ return {
76
+ width: 0,
77
+ height: 0
78
+ };
79
+ }
80
+ return {
81
+ width: window.innerWidth,
82
+ height: window.innerHeight
83
+ };
84
+ }
85
+ get fontScale() {
86
+ return 1;
87
+ }
88
+ get insets() {
89
+ return {
90
+ top: 0,
91
+ bottom: 0,
92
+ left: 0,
93
+ right: 0,
94
+ ime: 0
95
+ };
96
+ }
97
+ get statusBar() {
98
+ return _mock.StatusBar;
99
+ }
100
+ get rtl() {
101
+ return (0, _utils.isServer)() ? true : document.documentElement.dir === 'rtl';
102
+ }
103
+ get hasAdaptiveThemes() {
104
+ return _state.UnistylesState.hasAdaptiveThemes;
105
+ }
106
+ get navigationBar() {
107
+ return _mock.NavigationBar;
108
+ }
109
+ get miniRuntime() {
110
+ return {
111
+ colorScheme: this.colorScheme,
112
+ themeName: this.themeName,
113
+ contentSizeCategory: this.contentSizeCategory,
114
+ breakpoint: this.breakpoint,
115
+ orientation: this.orientation,
116
+ pixelRatio: this.pixelRatio,
117
+ screen: this.screen,
118
+ fontScale: this.fontScale,
119
+ insets: this.insets,
120
+ statusBar: {
121
+ width: this.statusBar.width,
122
+ height: this.statusBar.height
123
+ },
124
+ navigationBar: {
125
+ width: this.navigationBar.width,
126
+ height: this.navigationBar.height
127
+ },
128
+ rtl: this.rtl,
129
+ hasAdaptiveThemes: this.hasAdaptiveThemes
130
+ };
131
+ }
132
+ setTheme = themeName => {
133
+ if (themeName === UnistylesRuntime.themeName) {
134
+ return;
135
+ }
136
+ _state.UnistylesState.themeName = themeName;
137
+ _listener.UnistylesListener.emitChange(_NativePlatform.UnistyleDependency.Theme);
138
+ _listener.UnistylesListener.emitChange(_NativePlatform.UnistyleDependency.ThemeName);
139
+ };
140
+ setAdaptiveThemes = isEnabled => {
141
+ _state.UnistylesState.hasAdaptiveThemes = isEnabled;
142
+ if (!isEnabled) {
143
+ return;
144
+ }
145
+ this.setTheme((0, _utils.schemeToTheme)(UnistylesRuntime.colorScheme));
146
+ };
147
+ setRootViewBackgroundColor = (hex, alpha) => {
148
+ if ((0, _utils.isServer)()) {
149
+ return;
150
+ }
151
+ document.documentElement.style.backgroundColor = alpha ? (0, _utils.hexToRGBA)(hex, alpha) : hex;
152
+ };
153
+ setImmersiveMode = () => {};
154
+ updateTheme = (themeName, updater) => {
155
+ const oldTheme = _state.UnistylesState.themes.get(themeName);
156
+ if (!oldTheme) {
157
+ throw new Error(`🦄 Theme "${themeName}" is not registered!`);
158
+ }
159
+ _state.UnistylesState.themes.set(themeName, updater(oldTheme));
160
+ };
161
+ }
162
+ const UnistylesRuntime = exports.UnistylesRuntime = new UnistylesRuntimeBuilder();
163
+ //# sourceMappingURL=runtime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_NativePlatform","require","_types","_types2","_listener","_mock","_state","_utils","UnistylesRuntimeBuilder","lightMedia","getLightMedia","darkMedia","getDarkMedia","isServer","window","matchMedia","colorScheme","matches","ColorScheme","Light","Dark","Unspecified","themeName","UnistylesState","contentSizeCategory","WebContentSizeCategory","breakpoint","orientation","Orientation","Portrait","screen","type","includes","Landscape","theme","Error","themes","get","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","StatusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","NavigationBar","miniRuntime","setTheme","UnistylesRuntime","UnistylesListener","emitChange","UnistyleDependency","Theme","ThemeName","setAdaptiveThemes","isEnabled","schemeToTheme","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","hexToRGBA","setImmersiveMode","updateTheme","updater","oldTheme","set","exports"],"sourceRoot":"../../../src","sources":["web/runtime.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;A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ports.UnistylesShadowRegistry = void 0;
7
+ var _listener = require("./listener");
8
+ var _registry = require("./registry");
9
+ var _utils = require("./utils");
10
+ var _variants2 = require("./variants");
11
+ class UnistylesShadowRegistryBuilder {
12
+ // MOCKS
13
+ name = 'UnistylesShadowRegistry';
14
+ __type = 'web';
15
+ equals = () => true;
16
+ toString = () => 'UnistylesShadowRegistry';
17
+ dispose = () => {};
18
+ // END MOCKS
19
+
20
+ webUnistylesMap = (0, _utils.createDoubleMap)();
21
+ disposeMap = (0, _utils.createDoubleMap)();
22
+ stylesMap = (0, _utils.createDoubleMap)();
23
+ add = (ref, _style, _variants, _args) => {
24
+ // Style is not provided
25
+ if (!_style) {
26
+ return;
27
+ }
28
+
29
+ // Array of styles
30
+ if (Array.isArray(_style)) {
31
+ _style.forEach(style => this.add(ref, style, _variants, _args));
32
+ return;
33
+ }
34
+
35
+ // Not a unistyle
36
+ if (!Object.keys(_style).some(key => key.startsWith('__uni__'))) {
37
+ return;
38
+ }
39
+
40
+ // Ref is unmounted, remove style tags from the document
41
+ if (ref === null) {
42
+ const secrets = (0, _utils.extractSecrets)(_style);
43
+ secrets.forEach(({
44
+ __uni__refs
45
+ }) => {
46
+ __uni__refs.forEach(ref => {
47
+ if ((0, _utils.isInDocument)(ref)) {
48
+ return;
49
+ }
50
+ this.remove(ref, _style);
51
+ });
52
+ });
53
+ return;
54
+ }
55
+
56
+ // Ref is not an HTMLElement
57
+ if (!(ref instanceof HTMLElement)) {
58
+ return;
59
+ }
60
+ (0, _utils.extractSecrets)(_style).forEach(secret => {
61
+ const {
62
+ __uni__key,
63
+ __uni__stylesheet,
64
+ __uni__refs,
65
+ __uni__variants,
66
+ __uni__args = []
67
+ } = secret;
68
+ const newComputedStylesheet = _registry.UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
69
+ const style = newComputedStylesheet[__uni__key];
70
+ const args = _args ?? __uni__args;
71
+ const resultHidden = typeof style === 'function' ? style(...args) : style;
72
+ const result = (0, _utils.extractHiddenProperties)(resultHidden);
73
+ const {
74
+ variants
75
+ } = Object.fromEntries((0, _variants2.getVariants)({
76
+ variants: result
77
+ }, _variants && Object.keys(_variants).length > 0 ? _variants : __uni__variants));
78
+ const resultWithVariants = {
79
+ ...result,
80
+ ...variants
81
+ };
82
+ const storedWebUnistyle = this.webUnistylesMap.get(ref, __uni__key);
83
+ const webUnistyle = storedWebUnistyle ?? _registry.UnistylesRegistry.createStyles(resultWithVariants, __uni__key);
84
+ this.webUnistylesMap.set(ref, __uni__key, webUnistyle);
85
+ this.disposeMap.get(ref, __uni__key)?.();
86
+ this.disposeMap.set(ref, __uni__key, (0, _listener.listenToDependencies)({
87
+ key: __uni__key,
88
+ stylesheet: __uni__stylesheet,
89
+ args,
90
+ className: webUnistyle.className,
91
+ unistyles: webUnistyle.unistyles
92
+ }));
93
+ if (!storedWebUnistyle) {
94
+ const styleTag = document.createElement('style');
95
+ const additionalClasses = resultWithVariants?._web?._classNames;
96
+ if (additionalClasses) {
97
+ ref.classList.add(...(Array.isArray(additionalClasses) ? additionalClasses : [additionalClasses]));
98
+ }
99
+ ref.classList.add(webUnistyle.className);
100
+ webUnistyle.unistyles.setStylesTarget(styleTag);
101
+ document.head.appendChild(styleTag);
102
+ __uni__refs.add(ref);
103
+ this.stylesMap.set(ref, __uni__key, styleTag);
104
+ }
105
+ if (storedWebUnistyle) {
106
+ _registry.UnistylesRegistry.updateStyles(webUnistyle.unistyles, resultWithVariants, webUnistyle.className);
107
+ }
108
+ });
109
+ };
110
+ remove = (ref, style) => {
111
+ (0, _utils.extractSecrets)(style).forEach(({
112
+ __uni__key
113
+ }) => {
114
+ this.webUnistylesMap.delete(ref, __uni__key);
115
+ this.disposeMap.get(ref, __uni__key)?.();
116
+ this.disposeMap.delete(ref, __uni__key);
117
+ this.stylesMap.get(ref, __uni__key)?.remove();
118
+ this.stylesMap.delete(ref, __uni__key);
119
+ });
120
+ };
121
+ }
122
+ const UnistylesShadowRegistry = exports.UnistylesShadowRegistry = new UnistylesShadowRegistryBuilder();
123
+ //# sourceMappingURL=shadowRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_listener","require","_registry","_utils","_variants2","UnistylesShadowRegistryBuilder","name","__type","equals","toString","dispose","webUnistylesMap","createDoubleMap","disposeMap","stylesMap","add","ref","_style","_variants","_args","Array","isArray","forEach","style","Object","keys","some","key","startsWith","secrets","extractSecrets","__uni__refs","isInDocument","remove","HTMLElement","secret","__uni__key","__uni__stylesheet","__uni__variants","__uni__args","newComputedStylesheet","UnistylesRegistry","getComputedStylesheet","args","resultHidden","result","extractHiddenProperties","variants","fromEntries","getVariants","length","resultWithVariants","storedWebUnistyle","get","webUnistyle","createStyles","set","listenToDependencies","stylesheet","className","unistyles","styleTag","document","createElement","additionalClasses","_web","_classNames","classList","setStylesTarget","head","appendChild","updateStyles","delete","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../src","sources":["web/shadowRegistry.ts"],"mappings":";;;;;;AACA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AAMA,MAAMI,8BAA8B,CAAC;EACjC;EACAC,IAAI,GAAG,yBAAyB;EAChCC,MAAM,GAAG,KAAK;EACdC,MAAM,GAAGA,CAAA,KAAM,IAAI;EACnBC,QAAQ,GAAGA,CAAA,KAAM,yBAAyB;EAC1CC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;EAClB;;EAEiBC,eAAe,GAAG,IAAAC,sBAAe,EAAmC,CAAC;EACrEC,UAAU,GAAG,IAAAD,sBAAe,EAAgD,CAAC;EAC7EE,SAAS,GAAG,IAAAF,sBAAe,EAAwC,CAAC;EAErFG,GAAG,GAAGA,CAACC,GAAQ,EAAEC,MAA6B,EAAEC,SAA+B,EAAEC,KAAkB,KAAK;IACpG;IACA,IAAI,CAACF,MAAM,EAAE;MACT;IACJ;;IAEA;IACA,IAAIG,KAAK,C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AD,uBAAA,GAAG,IAAIpE,8BAA8B,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesState = void 0;
7
+ var _runtime = require("./runtime");
8
+ var _utils = require("./utils");
9
+ var _listener = require("./listener");
10
+ var _NativePlatform = require("../specs/NativePlatform");
11
+ class UnistylesStateBuilder {
12
+ isSSR = (0, _utils.isServer)();
13
+ themes = new Map();
14
+ hasAdaptiveThemes = false;
15
+ init = config => {
16
+ this.initThemes(config.themes);
17
+ this.initBreakpoints(config.breakpoints);
18
+ this.initSettings(config.settings);
19
+ if (this.isSSR) {
20
+ return;
21
+ }
22
+ _listener.UnistylesListener.initListeners();
23
+ };
24
+ initThemes = (themes = {}) => {
25
+ Object.entries(themes).forEach(([themeName, theme]) => {
26
+ this.themes.set(themeName, theme);
27
+ });
28
+ };
29
+ initSettings = settings => {
30
+ this.hasAdaptiveThemes = settings?.adaptiveThemes ?? false;
31
+ const themeNames = Array.from(this.themes.keys());
32
+
33
+ // Single theme + no settings
34
+ if (!settings?.adaptiveThemes && !settings?.initialTheme && themeNames.length === 1) {
35
+ this.themeName = themeNames[0];
36
+ return;
37
+ }
38
+
39
+ // No settings
40
+ if (!settings?.adaptiveThemes && !settings?.initialTheme) {
41
+ throw new Error('🦄 You need to specify either "initialTheme" or "adaptiveThemes" in your config');
42
+ }
43
+
44
+ // Adaptive themes
45
+ if (settings.adaptiveThemes) {
46
+ this.themeName = (0, _utils.schemeToTheme)(_runtime.UnistylesRuntime.colorScheme);
47
+ return;
48
+ }
49
+
50
+ // Initial theme
51
+ this.themeName = typeof settings.initialTheme === 'function' ? settings.initialTheme() : settings.initialTheme;
52
+ };
53
+ initBreakpoints = (breakpoints = {}) => {
54
+ const breakpointsMap = new Map();
55
+ this.breakpoints = breakpoints;
56
+ Object.entries(breakpoints).sort(([, a], [, b]) => a - b).forEach(([breakpoint, value]) => {
57
+ if ((0, _utils.isServer)()) {
58
+ return;
59
+ }
60
+ const mediaQuery = window.matchMedia(`(min-width: ${value}px)`);
61
+ breakpointsMap.set(breakpoint, mediaQuery);
62
+ if (mediaQuery.matches) {
63
+ this.breakpoint = breakpoint;
64
+ }
65
+ mediaQuery.addEventListener('change', event => {
66
+ if (!event.matches) {
67
+ const [currentBreakpoint] = Array.from(breakpointsMap).find(([, mq]) => mq.matches) ?? [];
68
+ if (currentBreakpoint) {
69
+ this.breakpoint = currentBreakpoint;
70
+ _listener.UnistylesListener.emitChange(_NativePlatform.UnistyleDependency.Breakpoints);
71
+ }
72
+ return;
73
+ }
74
+ this.breakpoint = breakpoint;
75
+ _listener.UnistylesListener.emitChange(_NativePlatform.UnistyleDependency.Breakpoints);
76
+ });
77
+ });
78
+ };
79
+ }
80
+ const UnistylesState = exports.UnistylesState = new UnistylesStateBuilder();
81
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_runtime","require","_utils","_listener","_NativePlatform","UnistylesStateBuilder","isSSR","isServer","themes","Map","hasAdaptiveThemes","init","config","initThemes","initBreakpoints","breakpoints","initSettings","settings","UnistylesListener","initListeners","Object","entries","forEach","themeName","theme","set","adaptiveThemes","themeNames","Array","from","keys","initialTheme","length","Error","schemeToTheme","UnistylesRuntime","colorScheme","breakpointsMap","sort","a","b","breakpoint","value","mediaQuery","window","matchMedia","matches","addEventListener","event","currentBreakpoint","find","mq","emitChange","UnistyleDependency","Breakpoints","UnistylesState","exports"],"sourceRoot":"../../../src","sources":["web/state.ts"],"mappings":";;;;;;AAIA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,eAAA,GAAAH,OAAA;AAEA,MAAMI,qBAAqB,CAAC;EACPC,KAAK,GAAG,IAAAC,eAAQ,EAAC,CAAC;EAEnCC,MAAM,GAAG,IAAIC,GAAG,CAAyB,CAAC;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