react-native-unistyles 3.0.0-alpha.1 → 3.0.0-alpha.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (264) hide show
  1. package/Unistyles.podspec +33 -0
  2. package/cxx/common/Constants.h +1 -0
  3. package/cxx/common/Helpers.h +92 -0
  4. package/cxx/core/HostStyle.cpp +18 -12
  5. package/cxx/core/HostStyle.h +3 -0
  6. package/cxx/core/StyleSheet.h +0 -1
  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 +25 -7
  12. package/cxx/core/UnistylesCommitHook.cpp +8 -7
  13. package/cxx/core/UnistylesCommitHook.h +6 -1
  14. package/cxx/core/UnistylesCommitShadowNode.h +13 -0
  15. package/cxx/core/UnistylesMountHook.cpp +40 -0
  16. package/cxx/core/UnistylesMountHook.h +30 -0
  17. package/cxx/core/UnistylesRegistry.cpp +44 -75
  18. package/cxx/core/UnistylesRegistry.h +10 -11
  19. package/cxx/core/UnistylesState.cpp +4 -4
  20. package/cxx/hybridObjects/HybridShadowRegistry.cpp +13 -6
  21. package/cxx/hybridObjects/HybridStyleSheet.cpp +35 -39
  22. package/cxx/hybridObjects/HybridStyleSheet.h +9 -6
  23. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +34 -15
  24. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
  25. package/cxx/parser/Parser.cpp +87 -165
  26. package/cxx/parser/Parser.h +8 -14
  27. package/cxx/shadowTree/ShadowLeafUpdate.h +1 -1
  28. package/cxx/shadowTree/ShadowTreeManager.cpp +3 -8
  29. package/ios/UnistylesModuleOnLoad.h +2 -0
  30. package/ios/UnistylesModuleOnLoad.mm +8 -1
  31. package/lib/commonjs/specs/NavigtionBar/index.js +1 -1
  32. package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
  33. package/lib/commonjs/specs/ShadowRegistry/index.js +3 -3
  34. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  35. package/lib/commonjs/specs/StatusBar/index.js +1 -1
  36. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  37. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  38. package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
  39. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  40. package/lib/commonjs/specs/index.web.js +1 -1
  41. package/lib/commonjs/web/convert/boxShadow.js +77 -0
  42. package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
  43. package/lib/commonjs/web/convert/breakpoint.js +25 -0
  44. package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
  45. package/lib/commonjs/web/convert/index.js +76 -0
  46. package/lib/commonjs/web/convert/index.js.map +1 -0
  47. package/lib/commonjs/web/convert/module.d.js +2 -0
  48. package/lib/commonjs/web/convert/module.d.js.map +1 -0
  49. package/lib/commonjs/web/convert/shadow.js +68 -0
  50. package/lib/commonjs/web/convert/shadow.js.map +1 -0
  51. package/lib/commonjs/web/convert/style.js +89 -0
  52. package/lib/commonjs/web/convert/style.js.map +1 -0
  53. package/lib/commonjs/web/convert/textShadow.js +73 -0
  54. package/lib/commonjs/web/convert/textShadow.js.map +1 -0
  55. package/lib/commonjs/web/convert/transform.js +72 -0
  56. package/lib/commonjs/web/convert/transform.js.map +1 -0
  57. package/lib/commonjs/web/convert/types.js +9 -0
  58. package/lib/commonjs/web/convert/types.js.map +1 -0
  59. package/lib/commonjs/web/convert/utils.js +55 -0
  60. package/lib/commonjs/web/convert/utils.js.map +1 -0
  61. package/lib/commonjs/web/create.js +89 -0
  62. package/lib/commonjs/web/create.js.map +1 -0
  63. package/lib/commonjs/web/index.js +51 -0
  64. package/lib/commonjs/web/index.js.map +1 -0
  65. package/lib/commonjs/web/listener/index.js +13 -0
  66. package/lib/commonjs/web/listener/index.js.map +1 -0
  67. package/lib/commonjs/web/listener/listener.js +36 -0
  68. package/lib/commonjs/web/listener/listener.js.map +1 -0
  69. package/lib/commonjs/web/mock.js +37 -0
  70. package/lib/commonjs/web/mock.js.map +1 -0
  71. package/lib/commonjs/web/mq.js +23 -0
  72. package/lib/commonjs/web/mq.js.map +1 -0
  73. package/lib/commonjs/web/pseudo.js +11 -0
  74. package/lib/commonjs/web/pseudo.js.map +1 -0
  75. package/lib/commonjs/web/registry.js +37 -0
  76. package/lib/commonjs/web/registry.js.map +1 -0
  77. package/lib/commonjs/web/runtime.js +164 -0
  78. package/lib/commonjs/web/runtime.js.map +1 -0
  79. package/lib/commonjs/web/state.js +121 -0
  80. package/lib/commonjs/web/state.js.map +1 -0
  81. package/lib/commonjs/web/utils.js +78 -0
  82. package/lib/commonjs/web/utils.js.map +1 -0
  83. package/lib/commonjs/web/variants/getVariants.js +39 -0
  84. package/lib/commonjs/web/variants/getVariants.js.map +1 -0
  85. package/lib/commonjs/web/variants/index.js +28 -0
  86. package/lib/commonjs/web/variants/index.js.map +1 -0
  87. package/lib/commonjs/web/variants/useVariants.js +75 -0
  88. package/lib/commonjs/web/variants/useVariants.js.map +1 -0
  89. package/lib/module/specs/NavigtionBar/index.js +1 -1
  90. package/lib/module/specs/NavigtionBar/index.js.map +1 -1
  91. package/lib/module/specs/ShadowRegistry/index.js +3 -3
  92. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  93. package/lib/module/specs/StatusBar/index.js +1 -1
  94. package/lib/module/specs/StatusBar/index.js.map +1 -1
  95. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  96. package/lib/module/specs/UnistylesRuntime/index.js +1 -1
  97. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  98. package/lib/module/specs/index.web.js +1 -1
  99. package/lib/module/specs/index.web.js.map +1 -1
  100. package/lib/module/web/convert/boxShadow.js +72 -0
  101. package/lib/module/web/convert/boxShadow.js.map +1 -0
  102. package/lib/module/web/convert/breakpoint.js +20 -0
  103. package/lib/module/web/convert/breakpoint.js.map +1 -0
  104. package/lib/module/web/convert/index.js +71 -0
  105. package/lib/module/web/convert/index.js.map +1 -0
  106. package/lib/module/web/convert/module.d.js +2 -0
  107. package/lib/module/web/convert/module.d.js.map +1 -0
  108. package/lib/module/web/convert/shadow.js +63 -0
  109. package/lib/module/web/convert/shadow.js.map +1 -0
  110. package/lib/module/web/convert/style.js +84 -0
  111. package/lib/module/web/convert/style.js.map +1 -0
  112. package/lib/module/web/convert/textShadow.js +68 -0
  113. package/lib/module/web/convert/textShadow.js.map +1 -0
  114. package/lib/module/web/convert/transform.js +67 -0
  115. package/lib/module/web/convert/transform.js.map +1 -0
  116. package/lib/module/web/convert/types.js +5 -0
  117. package/lib/module/web/convert/types.js.map +1 -0
  118. package/lib/module/web/convert/utils.js +43 -0
  119. package/lib/module/web/convert/utils.js.map +1 -0
  120. package/lib/module/web/create.js +84 -0
  121. package/lib/module/web/create.js.map +1 -0
  122. package/lib/module/web/index.js +24 -0
  123. package/lib/module/web/index.js.map +1 -0
  124. package/lib/module/web/listener/index.js +4 -0
  125. package/lib/module/web/listener/index.js.map +1 -0
  126. package/lib/module/web/listener/listener.js +31 -0
  127. package/lib/module/web/listener/listener.js.map +1 -0
  128. package/lib/module/web/mock.js +33 -0
  129. package/lib/module/web/mock.js.map +1 -0
  130. package/lib/module/web/mq.js +17 -0
  131. package/lib/module/web/mq.js.map +1 -0
  132. package/lib/module/web/pseudo.js +6 -0
  133. package/lib/module/web/pseudo.js.map +1 -0
  134. package/lib/module/web/registry.js +33 -0
  135. package/lib/module/web/registry.js.map +1 -0
  136. package/lib/module/web/runtime.js +160 -0
  137. package/lib/module/web/runtime.js.map +1 -0
  138. package/lib/module/web/state.js +117 -0
  139. package/lib/module/web/state.js.map +1 -0
  140. package/lib/module/web/utils.js +65 -0
  141. package/lib/module/web/utils.js.map +1 -0
  142. package/lib/module/web/variants/getVariants.js +34 -0
  143. package/lib/module/web/variants/getVariants.js.map +1 -0
  144. package/lib/module/web/variants/index.js +5 -0
  145. package/lib/module/web/variants/index.js.map +1 -0
  146. package/lib/module/web/variants/useVariants.js +70 -0
  147. package/lib/module/web/variants/useVariants.js.map +1 -0
  148. package/lib/typescript/example/App.d.ts.map +1 -1
  149. package/lib/typescript/example/Typography.d.ts +12 -0
  150. package/lib/typescript/example/Typography.d.ts.map +1 -0
  151. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
  152. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  153. package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -1
  154. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  155. package/lib/typescript/src/specs/index.web.d.ts +1 -1
  156. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  157. package/lib/typescript/src/types/stylesheet.d.ts +1 -1
  158. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  159. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
  160. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
  161. package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
  162. package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
  163. package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
  164. package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
  165. package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
  166. package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
  167. package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
  168. package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
  169. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
  170. package/lib/typescript/{web → src/web}/create.d.ts +11 -11
  171. package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
  172. package/lib/typescript/{web → src/web}/index.d.ts +12 -12
  173. package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
  174. package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
  175. package/lib/typescript/{web → src/web}/listener/listener.d.ts +1 -1
  176. package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
  177. package/lib/typescript/{web → src/web}/mock.d.ts +2 -2
  178. package/lib/typescript/src/web/mock.d.ts.map +1 -0
  179. package/lib/typescript/src/web/mq.d.ts.map +1 -0
  180. package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
  181. package/lib/typescript/{web → src/web}/registry.d.ts +1 -1
  182. package/lib/typescript/src/web/registry.d.ts.map +1 -0
  183. package/lib/typescript/{web → src/web}/runtime.d.ts +6 -6
  184. package/lib/typescript/src/web/runtime.d.ts.map +1 -0
  185. package/lib/typescript/{web → src/web}/state.d.ts +4 -4
  186. package/lib/typescript/src/web/state.d.ts.map +1 -0
  187. package/lib/typescript/{web → src/web}/utils.d.ts +5 -3
  188. package/lib/typescript/src/web/utils.d.ts.map +1 -0
  189. package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
  190. package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
  191. package/lib/typescript/src/web/variants/index.d.ts +3 -0
  192. package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
  193. package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
  194. package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
  195. package/package.json +2 -2
  196. package/plugin/__tests__/dependencies.spec.js +195 -107
  197. package/plugin/__tests__/ref.spec.js +537 -179
  198. package/plugin/__tests__/stylesheet.spec.js +174 -63
  199. package/plugin/index.js +68 -23
  200. package/plugin/ref.js +74 -12
  201. package/plugin/style.js +57 -24
  202. package/plugin/stylesheet.js +44 -1
  203. package/plugin/variants.js +33 -0
  204. package/src/specs/NavigtionBar/index.ts +1 -1
  205. package/src/specs/ShadowRegistry/index.ts +5 -5
  206. package/src/specs/StatusBar/index.ts +1 -1
  207. package/src/specs/StyleSheet/index.ts +3 -1
  208. package/src/specs/UnistylesRuntime/index.ts +1 -1
  209. package/src/specs/index.web.ts +1 -1
  210. package/src/types/stylesheet.ts +1 -1
  211. package/{web → src/web}/convert/breakpoint.ts +1 -1
  212. package/{web → src/web}/convert/index.ts +1 -1
  213. package/{web → src/web}/convert/types.ts +1 -1
  214. package/{web → src/web}/create.ts +36 -33
  215. package/{web → src/web}/listener/listener.ts +1 -1
  216. package/{web → src/web}/mock.ts +2 -2
  217. package/{web → src/web}/registry.ts +1 -1
  218. package/{web → src/web}/runtime.ts +4 -4
  219. package/{web → src/web}/state.ts +5 -5
  220. package/{web → src/web}/utils.ts +5 -5
  221. package/src/web/variants/getVariants.ts +42 -0
  222. package/src/web/variants/index.ts +2 -0
  223. package/{web → src/web/variants}/useVariants.ts +24 -44
  224. package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
  225. package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
  226. package/lib/typescript/web/convert/index.d.ts.map +0 -1
  227. package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
  228. package/lib/typescript/web/convert/style.d.ts.map +0 -1
  229. package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
  230. package/lib/typescript/web/convert/transform.d.ts.map +0 -1
  231. package/lib/typescript/web/convert/types.d.ts.map +0 -1
  232. package/lib/typescript/web/convert/utils.d.ts.map +0 -1
  233. package/lib/typescript/web/listener/index.d.ts.map +0 -1
  234. package/lib/typescript/web/listener/listener.d.ts.map +0 -1
  235. package/lib/typescript/web/mock.d.ts.map +0 -1
  236. package/lib/typescript/web/mq.d.ts.map +0 -1
  237. package/lib/typescript/web/pseudo.d.ts.map +0 -1
  238. package/lib/typescript/web/registry.d.ts.map +0 -1
  239. package/lib/typescript/web/runtime.d.ts.map +0 -1
  240. package/lib/typescript/web/state.d.ts.map +0 -1
  241. package/lib/typescript/web/useVariants.d.ts +0 -3
  242. package/lib/typescript/web/useVariants.d.ts.map +0 -1
  243. package/lib/typescript/web/utils.d.ts.map +0 -1
  244. /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
  245. /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
  246. /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
  247. /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
  248. /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
  249. /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
  250. /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
  251. /package/lib/typescript/{web → src/web}/listener/index.d.ts +0 -0
  252. /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
  253. /package/lib/typescript/{web → src/web}/pseudo.d.ts +0 -0
  254. /package/{web → src/web}/convert/boxShadow.ts +0 -0
  255. /package/{web → src/web}/convert/module.d.ts +0 -0
  256. /package/{web → src/web}/convert/shadow.ts +0 -0
  257. /package/{web → src/web}/convert/style.ts +0 -0
  258. /package/{web → src/web}/convert/textShadow.ts +0 -0
  259. /package/{web → src/web}/convert/transform.ts +0 -0
  260. /package/{web → src/web}/convert/utils.ts +0 -0
  261. /package/{web → src/web}/index.ts +0 -0
  262. /package/{web → src/web}/listener/index.ts +0 -0
  263. /package/{web → src/web}/mq.ts +0 -0
  264. /package/{web → src/web}/pseudo.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","_types","e","__esModule","default","isTransform","key","value","Array","isArray","exports","isTextShadow","TEXT_SHADOW_STYLES","includes","isBoxShadow","BOX_SHADOW_STYLES","normalizeNumericValue","normalizeColor","color","opacity","integer","normalizeColors","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","extractShadowValue","breakpoint","styles","width","height"],"sourceRoot":"../../../../src","sources":["web/convert/utils.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAmG,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAHnG;AACA;;AAIO,MAAM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AAG,CAAC,CAAC;IAE/B,OAAO,QAAQT,CAAC,IAAIC,CAAC,IAAIC,CAAC,IAAKC,CAAC,GAAG,GAAG,GAAIV,OAAO,GAAG;EACxD;EAEA,OAAOD,KAAK;AAChB,CAAC;AAAAR,OAAA,CAAAO,cAAA,GAAAA,cAAA;AAEM,MAAMoB,kBAAkB,GAAGA,CAA6B/B,GAAS,EAAEgC,UAAkB,EAAEC,MAAW,KAAsB;EAC3H,MAAMhC,KAAK,GAAGgC,MAAM,CAACjC,GAAG,CAAC;EAEzB,IAAIA,GAAG,KAAK,kBAAkB,IAAIA,GAAG,KAAK,cAAc,EAAE;IACtD,MAAM;MAAEkC,KAAK;MAAEC;IAAO,CAAC,GAAGlC,KAAK;IAE/B,OAAO;MACHiC,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,OAAOlC,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAAC+B,UAAU,CAAC,GAAG/B,KAAK;AAChE,CAAC;AAAAG,OAAA,CAAA2B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.create = void 0;
7
+ var _registry = require("./registry");
8
+ var _utils = require("./utils");
9
+ var _runtime = require("./runtime");
10
+ var _variants = require("./variants");
11
+ var _listener = require("./listener");
12
+ const create = stylesheet => {
13
+ const computedStylesheet = typeof stylesheet === 'function' ? stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : stylesheet;
14
+ let lastlySelectedVariants = {};
15
+ const listenToDependencies = ({
16
+ key,
17
+ className,
18
+ unistyles,
19
+ value,
20
+ args = []
21
+ }) => {
22
+ const dependencies = 'uni__dependencies' in value ? value['uni__dependencies'] : [];
23
+ if (dependencies.length === 0) {
24
+ return;
25
+ }
26
+ return _listener.UnistylesListener.addListeners(dependencies, () => {
27
+ const newComputedStylesheet = typeof stylesheet === 'function' ? stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime) : stylesheet;
28
+ if (!(0, _utils.keyInObject)(newComputedStylesheet, key)) {
29
+ return;
30
+ }
31
+ const value = newComputedStylesheet[key];
32
+ const result = typeof value === 'function' ? value(...args) : value;
33
+ _registry.UnistylesRegistry.updateStyles(unistyles, result, className);
34
+ });
35
+ };
36
+ const styles = (0, _utils.reduceObject)(computedStylesheet, (value, key) => {
37
+ if (typeof value === 'function') {
38
+ const webUnistyleByRef = new Map();
39
+ const disposeByRef = new Map();
40
+ return (...args) => {
41
+ const [ref] = args.slice(-1);
42
+ const result = value(...args);
43
+ const variants = Object.fromEntries((0, _variants.getVariants)({
44
+ [key]: result
45
+ }, lastlySelectedVariants));
46
+ const resultWithVariants = {
47
+ ...result,
48
+ ...variants[key]
49
+ };
50
+ if (ref instanceof HTMLElement) {
51
+ const storedWebUnistyle = webUnistyleByRef.get(ref);
52
+ const webUnistyle = storedWebUnistyle ?? _registry.UnistylesRegistry.createStyles(resultWithVariants, key);
53
+ webUnistyleByRef.set(ref, webUnistyle);
54
+ disposeByRef.get(ref)?.();
55
+ disposeByRef.set(ref, listenToDependencies({
56
+ key,
57
+ value,
58
+ unistyles: webUnistyle.unistyles,
59
+ className: webUnistyle.className,
60
+ args
61
+ }));
62
+ ref.classList.add(webUnistyle.className);
63
+ if (storedWebUnistyle) {
64
+ _registry.UnistylesRegistry.updateStyles(webUnistyle.unistyles, resultWithVariants, webUnistyle.className);
65
+ }
66
+ return;
67
+ }
68
+ return (0, _utils.toReactNativeClassName)(null, resultWithVariants);
69
+ };
70
+ }
71
+ const {
72
+ className,
73
+ unistyles
74
+ } = _registry.UnistylesRegistry.createStyles(value, key);
75
+ listenToDependencies({
76
+ key,
77
+ value,
78
+ unistyles,
79
+ className
80
+ });
81
+ return (0, _utils.toReactNativeClassName)(className, value);
82
+ });
83
+ (0, _variants.createUseVariants)(styles, newVariants => {
84
+ lastlySelectedVariants = newVariants;
85
+ });
86
+ return styles;
87
+ };
88
+ exports.create = create;
89
+ //# sourceMappingURL=create.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_registry","require","_utils","_runtime","_variants","_listener","create","stylesheet","computedStylesheet","UnistylesRuntime","theme","miniRuntime","lastlySelectedVariants","listenToDependencies","key","className","unistyles","value","args","dependencies","length","UnistylesListener","addListeners","newComputedStylesheet","keyInObject","result","UnistylesRegistry","updateStyles","styles","reduceObject","webUnistyleByRef","Map","disposeByRef","ref","slice","variants","Object","fromEntries","getVariants","resultWithVariants","HTMLElement","storedWebUnistyle","get","webUnistyle","createStyles","set","classList","add","toReactNativeClassName","createUseVariants","newVariants","exports"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,SAAA,GAAAJ,OAAA;AAaO,MAAMK,MAAM,GAAIC,UAAiD,IAAK;EACzE,MAAMC,kBAAkB,GAAG,OAAOD,UAAU,KAAK,UAAU,GACrDA,UAAU,CAACE,yBAAgB,CAACC,KAAK,EAAED,yBAAgB,CAACE,WAAW,CAAC,GAChEJ,UAAU;EAChB,IAAIK,sBAA2C,GAAG,CAAC,CAAC;EAEpD,MAAMC,oBAAoB,GAAGA,CAAC;IAAEC,GAAG;IAAEC,SAAS;IAAEC,SAAS;IAAEC,KAAK;IAAEC,IAAI,GAAG;EAA+B,CAAC,KAAK;IAC1G,MAAMC,YAAY,GAAI,mBAAmB,IAAIF,KAAK,GAAGA,KAAK,CAAC,mBAAmB,CAAC,GAAG,EAAgC;IAElH,IAAIE,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B,MAAM;AACjB,CAAC;AAAAuB,OAAA,CAAA7C,MAAA,GAAAA,MAAA","ignoreList":[]}
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ StyleSheet: true,
8
+ getSSRUnistyles: true,
9
+ UnistylesRuntime: true
10
+ };
11
+ exports.StyleSheet = void 0;
12
+ Object.defineProperty(exports, "UnistylesRuntime", {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _runtime.UnistylesRuntime;
16
+ }
17
+ });
18
+ exports.getSSRUnistyles = void 0;
19
+ var _create = require("./create");
20
+ var _runtime = require("./runtime");
21
+ var _state = require("./state");
22
+ var _utils = require("./utils");
23
+ var _mock = require("./mock");
24
+ Object.keys(_mock).forEach(function (key) {
25
+ if (key === "default" || key === "__esModule") return;
26
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
27
+ if (key in exports && exports[key] === _mock[key]) return;
28
+ Object.defineProperty(exports, key, {
29
+ enumerable: true,
30
+ get: function () {
31
+ return _mock[key];
32
+ }
33
+ });
34
+ });
35
+ const StyleSheet = exports.StyleSheet = {
36
+ configure: _state.UnistylesState.init,
37
+ create: _create.create,
38
+ absoluteFill: {
39
+ position: 'absolute',
40
+ left: 0,
41
+ top: 0,
42
+ right: 0,
43
+ bottom: 0
44
+ },
45
+ compose: (a, b) => (0, _utils.deepMergeObjects)(a, b),
46
+ flatten: (...styles) => (0, _utils.deepMergeObjects)(...styles),
47
+ hairlineWidth: 1
48
+ };
49
+ const getSSRUnistyles = () => _runtime.UnistylesRuntime.getSSRUnistyles();
50
+ exports.getSSRUnistyles = getSSRUnistyles;
51
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_create","require","_runtime","_state","_utils","_mock","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","StyleSheet","configure","UnistylesState","init","create","absoluteFill","position","left","top","right","bottom","compose","a","b","deepMergeObjects","flatten","styles","hairlineWidth","getSSRUnistyles","UnistylesRuntime"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;AAAA,IAAAA,OAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAkBA,IAAAI,KAAA,GAAAJ,OAAA;AAAAK,MAAA,CAAAC,IAAA,CAAAF,KAAA,EAAAG,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAJ,KAAA,CAAAI,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAZ,KAAA,CAAAI,GAAA;IAAA;EAAA;AAAA;AAhBO,MAAMS,UAAU,GAAAJ,OAAA,CAAAI,UAAA,GAAG;EACtBC,SAAS,EAAEC,qBAAc,CAACC,IAAI;EAC9BC,MAAM,EAANA,cAAM;EACNC,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAK,IAAAC,uBAAgB,EAACF,CAAC,EAAEC,CAAC,CAAC;EACzDE,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAK,IAAAF,uBAAgB,EAAC,GAAGE,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAKM,MAAMC,eAAe,GAAGA,CAAA,KAAMC,yBAAgB,CAACD,eAAe,CAAC,CAAC;AAAAtB,OAAA,CAAAsB,eAAA,GAAAA,eAAA","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ Object.defineProperty(exports, "UnistylesListener", {
7
+ enumerable: true,
8
+ get: function () {
9
+ return _listener.UnistylesListener;
10
+ }
11
+ });
12
+ var _listener = require("./listener");
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_listener","require"],"sourceRoot":"../../../../src","sources":["web/listener/index.ts"],"mappings":";;;;;;;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesListenerBuilder = exports.UnistylesListener = void 0;
7
+ var _NativePlatform = require("../../specs/NativePlatform");
8
+ var _runtime = require("../runtime");
9
+ class UnistylesListenerBuilder {
10
+ isInitialized = false;
11
+ listeners = Array.from({
12
+ length: Object.keys(_NativePlatform.UnistyleDependency).length / 2
13
+ }, () => new Set());
14
+ emitChange = dependency => {
15
+ this.listeners[dependency]?.forEach(listener => listener());
16
+ };
17
+ initListeners = () => {
18
+ if (this.isInitialized) {
19
+ return;
20
+ }
21
+ this.isInitialized = true;
22
+ _runtime.UnistylesRuntime.darkMedia?.addEventListener('change', () => this.emitChange(_NativePlatform.UnistyleDependency.ColorScheme));
23
+ _runtime.UnistylesRuntime.lightMedia?.addEventListener('change', () => this.emitChange(_NativePlatform.UnistyleDependency.ColorScheme));
24
+ window.addEventListener('orientationchange', () => this.emitChange(_NativePlatform.UnistyleDependency.Orientation));
25
+ window.addEventListener('resize', () => this.emitChange(_NativePlatform.UnistyleDependency.Dimensions));
26
+ };
27
+ addListeners = (dependencies, listener) => {
28
+ dependencies.forEach(dependency => this.listeners[dependency]?.add(listener));
29
+ return () => {
30
+ dependencies.forEach(dependency => this.listeners[dependency]?.delete(listener));
31
+ };
32
+ };
33
+ }
34
+ exports.UnistylesListenerBuilder = UnistylesListenerBuilder;
35
+ const UnistylesListener = exports.UnistylesListener = new UnistylesListenerBuilder();
36
+ //# sourceMappingURL=listener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","exports","UnistylesListener"],"sourceRoot":"../../../../src","sources":["web/listener/listener.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,wBAAwB,CAAC;EAC1BC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,kCAAkB,CAAC,CAACH,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAII,GAAG,CAAe,CAAC,CAAC;EAErHC,UAAU,GAAIC,UAA8B,IAAK;IAC7C,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEC,OAAO,CAACC,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC;EAC/D,CAAC;EAEDC,aAAa,GAAGA,CAAA,KAAM;IAClB,IAAI,IAAI,CAACb,aAAa,EAAE;MACpB;IACJ;IAEA,IAAI,CAACA,aAAa,GAAG,IAAI;IACzBc,yBAAgB,CAACC,SAAS,EAAEC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACU,WAAW,CAAC,CAAC;IAC7GH,yBAAgB,CAACI,UAAU,EAAEF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACU,WAAW,CAAC,CAAC;IAC9GE,MAAM,CAACH,gBAAgB,CAAC,mBAAmB,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACa,WAAW,CAAC,CAAC;IACnGD,MAAM,CAACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACc,UAAU,CAAC,CAAC;EAC3F,CAAC;EAEDC,YAAY,GAAGA,CAACC,YAAuC,EAAEX,QAAsB,KAAK;IAChFW,YAAY,CAACZ,OAAO,CAACD,UAAU,IAAI,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEc,GAAG,CAACZ,QAAQ,CAAC,CAAC;IAE7E,OAAO,MAAM;MACTW,YAAY,CAACZ,OAAO,CAACD,UAAU,IAAI,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEe,MAAM,CAACb,QAAQ,CAAC,CAAC;IACpF,CAAC;EACL,CAAC;AACL;AAACc,OAAA,CAAA3B,wBAAA,GAAAA,wBAAA;AAEM,MAAM4B,iBAAiB,GAAAD,OAAA,CAAAC,iBAAA,GAAG,IAAI5B,wBAAwB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesShadowRegistry = 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
+ const UnistylesShadowRegistry = exports.UnistylesShadowRegistry = {
29
+ name: 'UnistylesShadowRegistry',
30
+ __type: 'web',
31
+ equals: () => true,
32
+ toString: () => 'UnistylesShadowRegistry',
33
+ dispose: () => {},
34
+ add: () => {},
35
+ remove: () => {}
36
+ };
37
+ //# sourceMappingURL=mock.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["StatusBar","exports","width","height","setStyle","setHidden","setBackgroundColor","equals","toString","__type","name","NavigationBar","UnistylesShadowRegistry","dispose","add","remove"],"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;AAEM,MAAME,uBAAuB,GAAAX,OAAA,CAAAW,uBAAA,GAAG;EACnCF,IAAI,EAAE,yBAAyB;EAC/BD,MAAM,EAAE,KAAK;EACbF,MAAM,EAAEA,CAAA,KAAM,IAAI;EAClBC,QAAQ,EAAEA,CAAA,KAAM,yBAAyB;EACzCK,OAAO,EAAEA,CAAA,KAAM,CAAC,CAAC;EACjBC,GAAG,EAAEA,CAAA,KAAM,CAAC,CAAC;EACbC,MAAM,EAAEA,CAAA,KAAM,CAAC;AACnB,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,11 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.pseudos = exports.isPseudo = void 0;
7
+ // TODO: Add complete list of pseudo selectors
8
+ const pseudos = exports.pseudos = ['_hover', '_css', '_before', '_after'];
9
+ const isPseudo = selector => pseudos.includes(selector);
10
+ exports.isPseudo = isPseudo;
11
+ //# sourceMappingURL=pseudo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["pseudos","exports","isPseudo","selector","includes"],"sourceRoot":"../../../src","sources":["web/pseudo.ts"],"mappings":";;;;;;AAAA;AACO,MAAMA,OAAO,GAAAC,OAAA,CAAAD,OAAA,GAAG,CACnB,QAAQ,EACR,MAAM,EACN,SAAS,EACT,QAAQ,CACF;AAEH,MAAME,QAAQ,GAAIC,QAAgB,IAAKH,OAAO,CAACI,QAAQ,CAACD,QAAkB,CAAC;AAAAF,OAAA,CAAAC,QAAA,GAAAA,QAAA","ignoreList":[]}
@@ -0,0 +1,37 @@
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 _state = require("./state");
10
+ class UnistylesRegistryBuilder {
11
+ createStyles = (stylesheet, key) => {
12
+ const stylesTag = _state.UnistylesState.createTag();
13
+ const unistyles = (0, _typestyle.createTypeStyle)(stylesTag);
14
+ const typestyleStylesheet = (0, _convert.convertToTypeStyle)(stylesheet);
15
+ const className = unistyles.style({
16
+ $debugName: String(key)
17
+ }, typestyleStylesheet);
18
+ if (stylesheet._web?._css) {
19
+ const customClassName = Array.isArray(stylesheet._web._css) ? stylesheet._web._css.join(' ') : stylesheet._web._css;
20
+ return {
21
+ className: `${className} ${customClassName}`,
22
+ unistyles
23
+ };
24
+ }
25
+ return {
26
+ className,
27
+ unistyles
28
+ };
29
+ };
30
+ updateStyles = (unistyles, stylesheet, className) => {
31
+ const typestyleStylesheet = (0, _convert.convertToTypeStyle)(stylesheet);
32
+ unistyles.reinit();
33
+ unistyles.cssRule(`.${className}`, typestyleStylesheet);
34
+ };
35
+ }
36
+ const UnistylesRegistry = exports.UnistylesRegistry = new UnistylesRegistryBuilder();
37
+ //# sourceMappingURL=registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_typestyle","require","_convert","_state","UnistylesRegistryBuilder","createStyles","stylesheet","key","stylesTag","UnistylesState","createTag","unistyles","createTypeStyle","typestyleStylesheet","convertToTypeStyle","className","style","$debugName","String","_web","_css","customClassName","Array","isArray","join","updateStyles","reinit","cssRule","UnistylesRegistry","exports"],"sourceRoot":"../../../src","sources":["web/registry.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAEA,MAAMG,wBAAwB,CAAC;EAC3BC,YAAY,GAAGA,CAACC,UAA2B,EAAEC,GAAoB,KAAK;IAClE,MAAMC,SAAS,GAAGC,qBAAc,CAACC,SAAS,CAAC,CAAC;IAC5C,MAAMC,SAAS,GAAG,IAAAC,0BAAe,EAACJ,SAAS,CAAC;IAC5C,MAAMK,mBAAmB,GAAG,IAAAC,2BAAkB,EAACR,UAAU,CAAC;IAE1D,MAAMS,SAAS,GAAGJ,SAAS,CAACK,KAAK,CAAC;MAC9BC,UAAU,EAAEC,MAAM,CAACX,GAAG;IAC1B,CAAC,EAAEM,mBAAmB,CAAC;IAEvB,IAAIP,UAAU,CAACa,IAAI,EAAEC,IAAI,EAAE;MACvB,MAAMC,eAAe,GAAGC,KAAK,CAACC,OAAO,CAACjB,UAAU,CAACa,IAAI,CAACC,IAAI,CAAC,GACrDd,UAAU,CAACa,IAAI,CAACC,IAAI,CAACI,IAAI,CAAC,GAAG,CAAC,GAC9BlB,UAAU,CAACa,IAAI,CAACC,IAAI;MAE1B,OAAO;QACHL,SAAS,EAAE,GAAGA,SAAS,IAAIM,eAAe,EAAE;QAC5CV;MACJ,CAAC;IACL;IAEA,OAAO;MACHI,SAAS;MACTJ;IACJ,CAAC;EACL,CAAC;EAEDc,YAAY,GAAGA,CAACd,SAAoB,EAAEL,UAA2B,EAAES,SAAiB,KAAK;IACrF,MAAMF,mBAAmB,GAAG,IAAAC,2BAAkB,EAACR,UAAU,CAAC;IAE1DK,SAAS,CAACe,MAAM,CAAC,CAAC;IAClBf,SAAS,CAACgB,OAAO,CAAC,IAAIZ,SAAS,EAAE,EAAEF,mBAAmB,CAAC;EAC3D,CAAC;AACL;AAEO,MAAMe,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAIxB,wBAAwB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,164 @@
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
+ getSSRUnistyles = () => _state.UnistylesState.tags;
162
+ }
163
+ const UnistylesRuntime = exports.UnistylesRuntime = new UnistylesRuntimeBuilder();
164
+ //# 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","getSSRUnistyles","tags","exports"],"sourceRoot":"../../../src","sources":["web/runtime.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAEA,MAAMO,uBAAuB,CAAC;EAC1BC,UAAU,GAAG,IAAI,CAACC,aAAa,CAAC,CAAC;EACjCC,SAAS,GAAG,IAAI,CAACC,YAAY,CAAC,CAAC;EAEvBF,aAAaA,CAAA,EAA0B;IAC3C,IAAI,IAAAG,eAAQ,EAAC,CAAC,EAAE;MACZ,OAAO,IAAI;IACf;IAEA,IAAI,CAAC,IAAI,CAACJ,UAAU,EAAE;MAClB,IAAI,CAACA,UAAU,GAAGK,MAAM,CAACC,UAAU,CAAC,+BAA+B,CAAC;IACxE;IAEA,OAAO,IAAI,CAACN,UAAU;EAC1B;EAEQG,YAAYA,CAAA,EAA0B;IAC1C,IAAI,IAAAC,eAAQ,EAAC,CAAC,EAAE;MACZ,OAAO,IAAI;IACf;IAEA,IAAI,CAAC,IAAI,CAACF,SAAS,EAAE;MACjB,IAAI,CAACA,SAAS,GAAGG,MAAM,CAACC,UAAU,CAAC,8BAA8B,CAAC;IACtE;IAEA,OAAO,IAAI,CAACJ,SAAS;EACzB;EAEA,IAAIK,WAAWA,CAAA,EAAG;IACd,QAAQ,IAAI;MACR,KAAK,IAAI,CAACN,aAAa,CAAC,CAAC,EAAEO,OAAO;QAC9B,OAAOC,kBAAW,CAACC,KAAK;MAC5B,KAAK,IAAI,CAACP,YAAY,CAAC,CAAC,EAAEK,OAA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,CAAC,CAAC;EAC3D,CAAC;EAEDE,eAAe,GAAGA,CAAA,KAAM3D,qBAAc,CAAC4D,IAAI;AAC/C;AAEO,MAAMrB,gBAAgB,GAAAsB,OAAA,CAAAtB,gBAAA,GAAG,IAAItD,uBAAuB,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,121 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.UnistylesState = void 0;
7
+ var _react = require("react");
8
+ var _runtime = require("./runtime");
9
+ var _utils = require("./utils");
10
+ var _listener = require("./listener");
11
+ var _NativePlatform = require("../specs/NativePlatform");
12
+ class UnistylesStateBuilder {
13
+ isSSR = (0, _utils.isServer)();
14
+ tags = [];
15
+ themes = new Map();
16
+ hasAdaptiveThemes = false;
17
+ init = config => {
18
+ this.initThemes(config.themes);
19
+ this.initBreakpoints(config.breakpoints);
20
+ this.initSettings(config.settings);
21
+ if (this.isSSR) {
22
+ return;
23
+ }
24
+ _listener.UnistylesListener.initListeners();
25
+ };
26
+ initThemes = (themes = {}) => {
27
+ Object.entries(themes).forEach(([themeName, theme]) => {
28
+ this.themes.set(themeName, theme);
29
+ });
30
+ };
31
+ initSettings = settings => {
32
+ this.hasAdaptiveThemes = settings?.adaptiveThemes ?? false;
33
+ const themeNames = Array.from(this.themes.keys());
34
+
35
+ // Single theme + no settings
36
+ if (!settings?.adaptiveThemes && !settings?.initialTheme && themeNames.length === 1) {
37
+ this.themeName = themeNames[0];
38
+ return;
39
+ }
40
+
41
+ // No settings
42
+ if (!settings?.adaptiveThemes && !settings?.initialTheme) {
43
+ throw new Error('🦄 You need to specify either "initialTheme" or "adaptiveThemes" in your config');
44
+ }
45
+
46
+ // Adaptive themes
47
+ if (settings.adaptiveThemes) {
48
+ this.themeName = (0, _utils.schemeToTheme)(_runtime.UnistylesRuntime.colorScheme);
49
+ return;
50
+ }
51
+
52
+ // Initial theme
53
+ this.themeName = typeof settings.initialTheme === 'function' ? settings.initialTheme() : settings.initialTheme;
54
+ };
55
+ initBreakpoints = (breakpoints = {}) => {
56
+ const breakpointsMap = new Map();
57
+ this.breakpoints = breakpoints;
58
+ Object.entries(breakpoints).sort(([, a], [, b]) => a - b).forEach(([breakpoint, value]) => {
59
+ if ((0, _utils.isServer)()) {
60
+ return;
61
+ }
62
+ const mediaQuery = window.matchMedia(`(min-width: ${value}px)`);
63
+ breakpointsMap.set(breakpoint, mediaQuery);
64
+ if (mediaQuery.matches) {
65
+ this.breakpoint = breakpoint;
66
+ }
67
+ mediaQuery.addEventListener('change', event => {
68
+ if (!event.matches) {
69
+ const [currentBreakpoint] = Array.from(breakpointsMap).find(([, mq]) => mq.matches) ?? [];
70
+ if (currentBreakpoint) {
71
+ this.breakpoint = currentBreakpoint;
72
+ _listener.UnistylesListener.emitChange(_NativePlatform.UnistyleDependency.Breakpoints);
73
+ }
74
+ return;
75
+ }
76
+ this.breakpoint = breakpoint;
77
+ _listener.UnistylesListener.emitChange(_NativePlatform.UnistyleDependency.Breakpoints);
78
+ });
79
+ });
80
+ };
81
+ createTag() {
82
+ if (!this.isSSR) {
83
+ const tag = document.createElement('style');
84
+ document.head.appendChild(tag);
85
+ return tag;
86
+ }
87
+ const tagRef = new Proxy(/*#__PURE__*/(0, _react.createRef)(), {
88
+ set: (target, prop, value) => {
89
+ // When ref is assigned
90
+ if ('textContent' in value) {
91
+ value.textContent = tag.textContent;
92
+ }
93
+ return Reflect.set(target, prop, value);
94
+ }
95
+ });
96
+ const tagElement = /*#__PURE__*/(0, _react.createElement)('style', {
97
+ ref: tagRef,
98
+ key: this.tags.length
99
+ }, '');
100
+ const tag = new Proxy({
101
+ textContent: ''
102
+ }, {
103
+ set: (target, prop, value) => {
104
+ if (prop !== 'textContent') {
105
+ return false;
106
+ }
107
+
108
+ // When css is updated
109
+ target.textContent = value;
110
+ if (tagRef.current) {
111
+ tagRef.current.textContent = value;
112
+ }
113
+ return true;
114
+ }
115
+ });
116
+ this.tags.push(tagElement);
117
+ return tag;
118
+ }
119
+ }
120
+ const UnistylesState = exports.UnistylesState = new UnistylesStateBuilder();
121
+ //# sourceMappingURL=state.js.map