react-native-unistyles 3.0.0-alpha.41 → 3.0.0-alpha.43

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. package/README.md +7 -1
  2. package/cxx/common/Constants.h +0 -1
  3. package/cxx/core/UnistylesRegistry.cpp +10 -4
  4. package/cxx/core/UnistylesRegistry.h +1 -1
  5. package/cxx/hybridObjects/HybridShadowRegistry.cpp +2 -2
  6. package/cxx/parser/Parser.cpp +7 -22
  7. package/cxx/parser/Parser.h +0 -1
  8. package/lib/commonjs/components/Display.js +2 -2
  9. package/lib/commonjs/components/Display.js.map +1 -1
  10. package/lib/commonjs/components/Hide.js +2 -2
  11. package/lib/commonjs/components/Hide.js.map +1 -1
  12. package/lib/commonjs/components/Pressable.js +82 -0
  13. package/lib/commonjs/components/Pressable.js.map +1 -0
  14. package/lib/commonjs/components/Pressable.web.js +97 -0
  15. package/lib/commonjs/components/Pressable.web.js.map +1 -0
  16. package/lib/commonjs/components/index.js +7 -0
  17. package/lib/commonjs/components/index.js.map +1 -1
  18. package/lib/commonjs/core/getBoundArgs.js +18 -0
  19. package/lib/commonjs/core/getBoundArgs.js.map +1 -0
  20. package/lib/commonjs/core/getId.js +9 -0
  21. package/lib/commonjs/core/getId.js.map +1 -0
  22. package/lib/commonjs/core/index.js +14 -0
  23. package/lib/commonjs/core/index.js.map +1 -1
  24. package/lib/commonjs/hooks/index.js +13 -0
  25. package/lib/commonjs/hooks/index.js.map +1 -0
  26. package/lib/commonjs/hooks/useMedia.js.map +1 -0
  27. package/lib/commonjs/hooks/useMedia.web.js.map +1 -0
  28. package/lib/commonjs/index.js +8 -1
  29. package/lib/commonjs/index.js.map +1 -1
  30. package/lib/commonjs/mq.js +6 -6
  31. package/lib/commonjs/mq.js.map +1 -1
  32. package/lib/commonjs/specs/ShadowRegistry/index.js +3 -4
  33. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  34. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  35. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
  36. package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
  37. package/lib/commonjs/specs/index.web.js +0 -7
  38. package/lib/commonjs/specs/index.web.js.map +1 -1
  39. package/lib/commonjs/utils.js +1 -1
  40. package/lib/commonjs/utils.js.map +1 -1
  41. package/lib/commonjs/web/convert/types.js.map +1 -1
  42. package/lib/commonjs/web/convert/utils.js +1 -1
  43. package/lib/commonjs/web/convert/utils.js.map +1 -1
  44. package/lib/commonjs/web/create.js +10 -2
  45. package/lib/commonjs/web/create.js.map +1 -1
  46. package/lib/commonjs/web/index.js +7 -5
  47. package/lib/commonjs/web/index.js.map +1 -1
  48. package/lib/commonjs/web/listener.js.map +1 -1
  49. package/lib/commonjs/web/runtime.js +7 -7
  50. package/lib/commonjs/web/runtime.js.map +1 -1
  51. package/lib/commonjs/web/shadowRegistry.js +1 -1
  52. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  53. package/lib/commonjs/web/state.js +23 -16
  54. package/lib/commonjs/web/state.js.map +1 -1
  55. package/lib/commonjs/web/utils/common.js +3 -3
  56. package/lib/commonjs/web/utils/common.js.map +1 -1
  57. package/lib/commonjs/web/utils/unistyle.js +2 -4
  58. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  59. package/lib/commonjs/web/{variants/getVariants.js → variants.js} +3 -3
  60. package/lib/commonjs/web/variants.js.map +1 -0
  61. package/lib/module/components/Display.js +1 -1
  62. package/lib/module/components/Display.js.map +1 -1
  63. package/lib/module/components/Hide.js +1 -1
  64. package/lib/module/components/Hide.js.map +1 -1
  65. package/lib/module/components/Pressable.js +76 -0
  66. package/lib/module/components/Pressable.js.map +1 -0
  67. package/lib/module/components/Pressable.web.js +91 -0
  68. package/lib/module/components/Pressable.web.js.map +1 -0
  69. package/lib/module/components/index.js +1 -0
  70. package/lib/module/components/index.js.map +1 -1
  71. package/lib/module/core/getBoundArgs.js +13 -0
  72. package/lib/module/core/getBoundArgs.js.map +1 -0
  73. package/lib/module/core/getId.js +4 -0
  74. package/lib/module/core/getId.js.map +1 -0
  75. package/lib/module/core/index.js +2 -0
  76. package/lib/module/core/index.js.map +1 -1
  77. package/lib/module/hooks/index.js +4 -0
  78. package/lib/module/hooks/index.js.map +1 -0
  79. package/lib/module/hooks/useMedia.js.map +1 -0
  80. package/lib/module/hooks/useMedia.web.js.map +1 -0
  81. package/lib/module/index.js +1 -1
  82. package/lib/module/index.js.map +1 -1
  83. package/lib/module/mq.js +6 -6
  84. package/lib/module/mq.js.map +1 -1
  85. package/lib/module/specs/ShadowRegistry/index.js +3 -4
  86. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  87. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  88. package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js +1 -2
  89. package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
  90. package/lib/module/specs/index.web.js +0 -1
  91. package/lib/module/specs/index.web.js.map +1 -1
  92. package/lib/module/utils.js +1 -1
  93. package/lib/module/utils.js.map +1 -1
  94. package/lib/module/web/convert/types.js.map +1 -1
  95. package/lib/module/web/convert/utils.js +1 -1
  96. package/lib/module/web/convert/utils.js.map +1 -1
  97. package/lib/module/web/create.js +12 -4
  98. package/lib/module/web/create.js.map +1 -1
  99. package/lib/module/web/index.js +7 -3
  100. package/lib/module/web/index.js.map +1 -1
  101. package/lib/module/web/listener.js.map +1 -1
  102. package/lib/module/web/runtime.js +8 -8
  103. package/lib/module/web/runtime.js.map +1 -1
  104. package/lib/module/web/shadowRegistry.js +1 -1
  105. package/lib/module/web/shadowRegistry.js.map +1 -1
  106. package/lib/module/web/state.js +24 -17
  107. package/lib/module/web/state.js.map +1 -1
  108. package/lib/module/web/utils/common.js +1 -1
  109. package/lib/module/web/utils/common.js.map +1 -1
  110. package/lib/module/web/utils/unistyle.js +1 -2
  111. package/lib/module/web/utils/unistyle.js.map +1 -1
  112. package/lib/module/web/{variants/getVariants.js → variants.js} +3 -3
  113. package/lib/module/web/variants.js.map +1 -0
  114. package/lib/typescript/src/components/Pressable.d.ts +7 -0
  115. package/lib/typescript/src/components/Pressable.d.ts.map +1 -0
  116. package/lib/typescript/src/components/Pressable.web.d.ts +13 -0
  117. package/lib/typescript/src/components/Pressable.web.d.ts.map +1 -0
  118. package/lib/typescript/src/components/index.d.ts +1 -0
  119. package/lib/typescript/src/components/index.d.ts.map +1 -1
  120. package/lib/typescript/src/core/getBoundArgs.d.ts +2 -0
  121. package/lib/typescript/src/core/getBoundArgs.d.ts.map +1 -0
  122. package/lib/typescript/src/core/getId.d.ts +2 -0
  123. package/lib/typescript/src/core/getId.d.ts.map +1 -0
  124. package/lib/typescript/src/core/index.d.ts +2 -0
  125. package/lib/typescript/src/core/index.d.ts.map +1 -1
  126. package/lib/typescript/src/hooks/index.d.ts +2 -0
  127. package/lib/typescript/src/hooks/index.d.ts.map +1 -0
  128. package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -0
  129. package/lib/typescript/src/hooks/useMedia.web.d.ts.map +1 -0
  130. package/lib/typescript/src/index.d.ts +1 -1
  131. package/lib/typescript/src/index.d.ts.map +1 -1
  132. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +1 -1
  133. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
  134. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
  135. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  136. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +1 -0
  137. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  138. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +1 -1
  139. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
  140. package/lib/typescript/src/specs/StyleSheet/index.d.ts +3 -2
  141. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  142. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +1 -1
  143. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  144. package/lib/typescript/src/specs/index.web.d.ts +0 -2
  145. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  146. package/lib/typescript/src/types/common.d.ts +1 -0
  147. package/lib/typescript/src/types/common.d.ts.map +1 -1
  148. package/lib/typescript/src/types/index.d.ts +1 -1
  149. package/lib/typescript/src/types/index.d.ts.map +1 -1
  150. package/lib/typescript/src/web/convert/types.d.ts +1 -1
  151. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  152. package/lib/typescript/src/web/create.d.ts +1 -1
  153. package/lib/typescript/src/web/create.d.ts.map +1 -1
  154. package/lib/typescript/src/web/index.d.ts +8 -2
  155. package/lib/typescript/src/web/index.d.ts.map +1 -1
  156. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  157. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  158. package/lib/typescript/src/web/state.d.ts.map +1 -1
  159. package/lib/typescript/src/web/utils/common.d.ts +1 -1
  160. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  161. package/lib/typescript/src/web/utils/unistyle.d.ts +0 -1
  162. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  163. package/lib/typescript/src/web/{variants/getVariants.d.ts → variants.d.ts} +2 -2
  164. package/lib/typescript/src/web/variants.d.ts.map +1 -0
  165. package/package.json +12 -16
  166. package/plugin/common.js +1 -4
  167. package/plugin/import.js +29 -3
  168. package/plugin/index.js +18 -8
  169. package/plugin/ref.js +15 -75
  170. package/plugin/style.js +251 -88
  171. package/src/components/Display.tsx +1 -1
  172. package/src/components/Hide.tsx +1 -1
  173. package/src/components/Pressable.tsx +101 -0
  174. package/src/components/Pressable.web.tsx +103 -0
  175. package/src/components/index.ts +1 -0
  176. package/src/core/getBoundArgs.ts +15 -0
  177. package/src/core/getId.ts +1 -0
  178. package/src/core/index.ts +2 -0
  179. package/src/hooks/index.ts +1 -0
  180. package/src/index.ts +1 -1
  181. package/src/mq.ts +6 -6
  182. package/src/specs/NativePlatform/NativePlatform.nitro.ts +1 -1
  183. package/src/specs/ShadowRegistry/index.ts +5 -6
  184. package/src/specs/ShadowRegistry/types.ts +2 -1
  185. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +1 -1
  186. package/src/specs/StyleSheet/index.ts +3 -2
  187. package/src/specs/TurboUnistyles/NativeTurboUnistyles.ts +1 -2
  188. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
  189. package/src/specs/UnistylesRuntime/index.ts +1 -1
  190. package/src/specs/index.web.ts +0 -4
  191. package/src/types/common.ts +1 -0
  192. package/src/types/index.ts +1 -1
  193. package/src/utils.ts +1 -1
  194. package/src/web/convert/types.ts +1 -1
  195. package/src/web/convert/utils.ts +2 -2
  196. package/src/web/create.ts +13 -4
  197. package/src/web/index.ts +7 -3
  198. package/src/web/listener.ts +2 -0
  199. package/src/web/registry.ts +1 -1
  200. package/src/web/runtime.ts +9 -9
  201. package/src/web/shadowRegistry.ts +3 -3
  202. package/src/web/state.ts +36 -17
  203. package/src/web/utils/common.ts +1 -1
  204. package/src/web/utils/unistyle.ts +3 -9
  205. package/src/web/{variants/getVariants.ts → variants.ts} +3 -3
  206. package/lib/commonjs/components/useMedia.js.map +0 -1
  207. package/lib/commonjs/components/useMedia.web.js.map +0 -1
  208. package/lib/commonjs/web/variants/getVariants.js.map +0 -1
  209. package/lib/commonjs/web/variants/index.js +0 -28
  210. package/lib/commonjs/web/variants/index.js.map +0 -1
  211. package/lib/commonjs/web/variants/useVariants.js +0 -59
  212. package/lib/commonjs/web/variants/useVariants.js.map +0 -1
  213. package/lib/module/components/useMedia.js.map +0 -1
  214. package/lib/module/components/useMedia.web.js.map +0 -1
  215. package/lib/module/web/variants/getVariants.js.map +0 -1
  216. package/lib/module/web/variants/index.js +0 -5
  217. package/lib/module/web/variants/index.js.map +0 -1
  218. package/lib/module/web/variants/useVariants.js +0 -54
  219. package/lib/module/web/variants/useVariants.js.map +0 -1
  220. package/lib/typescript/src/components/useMedia.d.ts.map +0 -1
  221. package/lib/typescript/src/components/useMedia.web.d.ts.map +0 -1
  222. package/lib/typescript/src/web/variants/getVariants.d.ts.map +0 -1
  223. package/lib/typescript/src/web/variants/index.d.ts +0 -3
  224. package/lib/typescript/src/web/variants/index.d.ts.map +0 -1
  225. package/lib/typescript/src/web/variants/useVariants.d.ts +0 -3
  226. package/lib/typescript/src/web/variants/useVariants.d.ts.map +0 -1
  227. package/src/web/variants/index.ts +0 -2
  228. package/src/web/variants/useVariants.ts +0 -65
  229. /package/lib/commonjs/{components → hooks}/useMedia.js +0 -0
  230. /package/lib/commonjs/{components → hooks}/useMedia.web.js +0 -0
  231. /package/lib/module/{components → hooks}/useMedia.js +0 -0
  232. /package/lib/module/{components → hooks}/useMedia.web.js +0 -0
  233. /package/lib/typescript/src/{components → hooks}/useMedia.d.ts +0 -0
  234. /package/lib/typescript/src/{components → hooks}/useMedia.web.d.ts +0 -0
  235. /package/src/{components → hooks}/useMedia.ts +0 -0
  236. /package/src/{components → hooks}/useMedia.web.ts +0 -0
@@ -0,0 +1,76 @@
1
+ "use strict";
2
+
3
+ import React, { forwardRef, useRef } from 'react';
4
+ import { Pressable as NativePressableReactNative } from 'react-native';
5
+ import { UnistylesShadowRegistry } from '../specs';
6
+ import { getId } from '../core';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ export const Pressable = /*#__PURE__*/forwardRef(({
9
+ variants,
10
+ style,
11
+ rawStyle,
12
+ ...props
13
+ }, passedRef) => {
14
+ const storedRef = useRef();
15
+ return /*#__PURE__*/_jsx(NativePressableReactNative, {
16
+ ...props,
17
+ ref: ref => {
18
+ storedRef.current = ref;
19
+ const styleResult = typeof style === 'function' ? style({
20
+ pressed: false
21
+ }) : style;
22
+ const fnArgs = typeof styleResult === 'function'
23
+ // @ts-expect-error - this is hidden from TS
24
+ ? styleResult.getBoundArgs() : Array.isArray(styleResult) ? styleResult
25
+ // @ts-expect-error - this is hidden from TS
26
+ .map(style => typeof style === 'function' ? style.getBoundArgs() : []) : [];
27
+ if (typeof passedRef === 'object' && passedRef !== null) {
28
+ passedRef.current = ref;
29
+ }
30
+ const returnFn = typeof passedRef === 'function' ? passedRef(ref) : () => {};
31
+ const unistyles = (rawStyle ?? []).map((style, index) => {
32
+ if (fnArgs[index]) {
33
+ return style;
34
+ }
35
+ return undefined;
36
+ }).filter(Boolean);
37
+
38
+ // @ts-expect-error - this is hidden from TS
39
+ UnistylesShadowRegistry.add(ref, unistyles, variants, [...fnArgs]);
40
+ return () => {
41
+ // @ts-expect-error - this is hidden from TS
42
+ UnistylesShadowRegistry.remove(ref);
43
+ if (typeof returnFn === 'function') {
44
+ returnFn();
45
+ }
46
+ };
47
+ },
48
+ style: state => {
49
+ const styleResult = typeof style === 'function' ? style(state) : style;
50
+ const fnArgs = typeof styleResult === 'function'
51
+ // @ts-expect-error - this is hidden from TS
52
+ ? styleResult.getBoundArgs() : Array.isArray(styleResult) ? styleResult
53
+ // @ts-expect-error - this is hidden from TS
54
+ .map(style => typeof style === 'function' ? style.getBoundArgs() : []) : [];
55
+ const pressId = getId();
56
+ const unistyles = (rawStyle ?? []).map((style, index) => {
57
+ if (fnArgs[index]) {
58
+ return style;
59
+ }
60
+ return undefined;
61
+ }).filter(Boolean);
62
+ if (storedRef.current) {
63
+ // @ts-expect-error - this is hidden from TS
64
+ UnistylesShadowRegistry.remove(storedRef.current);
65
+ // @ts-expect-error - this is hidden from TS
66
+ UnistylesShadowRegistry.add(storedRef.current, unistyles, variants, [...fnArgs], pressId);
67
+ }
68
+ return typeof styleResult === 'function'
69
+ // @ts-expect-error - this is hidden from TS
70
+ ? styleResult(pressId) : Array.isArray(styleResult)
71
+ // @ts-expect-error - this is hidden from TS
72
+ ? styleResult.map(style => typeof style === 'function' ? style(pressId) : style) : styleResult;
73
+ }
74
+ });
75
+ });
76
+ //# sourceMappingURL=Pressable.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","useRef","Pressable","NativePressableReactNative","UnistylesShadowRegistry","getId","jsx","_jsx","variants","style","rawStyle","props","passedRef","storedRef","ref","current","styleResult","pressed","fnArgs","getBoundArgs","Array","isArray","map","returnFn","unistyles","index","undefined","filter","Boolean","add","remove","state","pressId"],"sourceRoot":"../../../src","sources":["components/Pressable.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,MAAM,QAAQ,OAAO;AACjD,SAASC,SAAS,IAAIC,0BAA0B,QAAQ,cAAc;AAEtE,SAASC,uBAAuB,QAAQ,UAAU;AAClD,SAASC,KAAK,QAAQ,SAAS;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAO/B,OAAO,MAAML,SAAS,gBAAGF,UAAU,CAAuB,CAAC;EAAEQ,QAAQ;EAAEC,KAAK;EAAEC,QAAQ;EAAE,GAAGC;AAAM,CAAC,EAAEC,SAAS,KAAK;EAC9G,MAAMC,SAAS,GAAGZ,MAAM,CAAc,CAAC;EAEvC,oBACIM,IAAA,CAACJ,0BAA0B;IAAA,GACnBQ,KAAK;IACTG,GAAG,EAAEA,GAAG,IAAI;MACRD,SAAS,CAACE,OAAO,GAAGD,GAAG;MACvB,MAAME,WAAW,GAAG,OAAOP,KAAK,KAAK,UAAU,GACzCA,KAAK,CAAC;QAAEQ,OAAO,EAAE;MAAM,CAAC,CAAC,GACzBR,KAAK;MACX,MAAMS,MAAM,GAAG,OAAOF,WAAW,KAAK;MAClC;MAAA,EACEA,WAAW,CAACG,YAAY,CAAC,CAAC,GAC1BC,KAAK,CAACC,OAAO,CAACL,WAAW,CAAC,GACtBA;MACE;MAAA,CACCM,GAAG,CAACb,KAAK,IAAI,OAAOA,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACU,YAAY,CAAC,CAAC,GAAG,EAAE,CAAC,GACxE,EAAE;MAEZ,IAAI,OAAOP,SAAS,KAAK,QAAQ,IAAIA,SAAS,KAA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EgB,KAAK,KAAK;QACnB,IAAIP,MAAM,CAACO,KAAK,CAAC,EAAE;UACf,OAAOhB,KAAK;QAChB;QAEA,OAAOiB,SAAS;MACpB,CAAC,CAAC,CACDC,MAAM,CAACC,OAAO,CAAC;MAEpB,IAAIf,SAAS,CAACE,OAAO,EAAE;QACnB;QACAX,uBAAuB,CAAC0B,MAAM,CAACjB,SAAS,CAACE,OAAO,CAAC;QACjD;QACAX,uBAAuB,CAACyB,GAAG,CAAChB,SAAS,CAACE,OAAO,EAAES,SAAS,EAAEhB,QAAQ,EAAE,CAAC,GAAGU,MAAM,CAAC,EAAEc,OAAO,CAAC;MAC7F;MAEA,OAAO,OAAOhB,WAAW,KAAK;MAC1B;MAAA,EACEA,WAAW,CAACgB,OAAO,CAAC,GACpBZ,KAAK,CAACC,OAAO,CAACL,WAAW;MACvB;MAAA,EACEA,WAAW,CAACM,GAAG,CAACb,KAAK,IAAI,OAAOA,KAAK,KAAK,UAAU,GAAGA,KAAK,CAACuB,OAAO,CAAC,GAAGvB,KAAK,CAAC,GAC9EO,WAAW;IACzB;EAAE,CACL,CAAC;AAEV,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,91 @@
1
+ "use strict";
2
+
3
+ import React, { forwardRef, useEffect, useRef } from 'react';
4
+ import { Pressable as NativePressableReactNative } from 'react-native';
5
+ import { UnistylesShadowRegistry } from '../specs';
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ const initialState = {
8
+ pressed: false,
9
+ hovered: false,
10
+ focused: false
11
+ };
12
+ const events = {
13
+ 'pointerdown': {
14
+ pressed: true
15
+ },
16
+ 'pointerup': {
17
+ pressed: false
18
+ },
19
+ 'pointerenter': {
20
+ hovered: true
21
+ },
22
+ 'pointerleave': {
23
+ hovered: false
24
+ },
25
+ 'focus': {
26
+ focused: true
27
+ },
28
+ 'blur': {
29
+ focused: false
30
+ }
31
+ };
32
+ export const Pressable = /*#__PURE__*/forwardRef(({
33
+ variants,
34
+ style,
35
+ ...props
36
+ }, passedRef) => {
37
+ const storedRef = useRef();
38
+ const state = useRef(initialState);
39
+ const styleRef = useRef(style);
40
+ useEffect(() => {
41
+ styleRef.current = style;
42
+ }, [style]);
43
+ useEffect(() => {
44
+ const handler = newState => () => {
45
+ state.current = {
46
+ ...state.current,
47
+ ...newState
48
+ };
49
+ const styleResult = typeof styleRef.current === 'function' ? styleRef.current(state.current) : styleRef.current;
50
+ const fnArgs = typeof styleResult === 'function'
51
+ // @ts-expect-error - this is hidden from TS
52
+ ? styleResult.getBoundArgs() : [];
53
+ const extractedResult = typeof styleResult === 'function' ? styleResult() : styleResult;
54
+
55
+ // @ts-expect-error - this is hidden from TS
56
+ UnistylesShadowRegistry.add(storedRef.current, [extractedResult], variants, [fnArgs]);
57
+ };
58
+ if (!storedRef.current) {
59
+ return;
60
+ }
61
+
62
+ // ref on the web is dom element
63
+ const ref = storedRef.current;
64
+ Object.entries(events).forEach(([event, state]) => {
65
+ ref.addEventListener(event, handler(state));
66
+ });
67
+ return () => {
68
+ Object.entries(events).forEach(([event, state]) => {
69
+ ref.removeEventListener(event, handler(state));
70
+ });
71
+ };
72
+ }, []);
73
+ return /*#__PURE__*/_jsx(NativePressableReactNative, {
74
+ ...props,
75
+ ref: ref => {
76
+ storedRef.current = ref;
77
+ const styleResult = typeof style === 'function' ? style(initialState) : style;
78
+ const fnArgs = typeof styleResult === 'function'
79
+ // @ts-expect-error - this is hidden from TS
80
+ ? styleResult.getBoundArgs() : [];
81
+ const extractedResult = typeof styleResult === 'function' ? styleResult() : styleResult;
82
+ if (typeof passedRef === 'object' && passedRef !== null) {
83
+ passedRef.current = ref;
84
+ }
85
+
86
+ // @ts-expect-error - this is hidden from TS
87
+ UnistylesShadowRegistry.add(ref, [extractedResult], variants, [fnArgs]);
88
+ }
89
+ });
90
+ });
91
+ //# sourceMappingURL=Pressable.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["React","forwardRef","useEffect","useRef","Pressable","NativePressableReactNative","UnistylesShadowRegistry","jsx","_jsx","initialState","pressed","hovered","focused","events","variants","style","props","passedRef","storedRef","state","styleRef","current","handler","newState","styleResult","fnArgs","getBoundArgs","extractedResult","add","ref","Object","entries","forEach","event","addEventListener","removeEventListener"],"sourceRoot":"../../../src","sources":["components/Pressable.web.tsx"],"mappings":";;AAAA,OAAOA,KAAK,IAAIC,UAAU,EAAEC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAC5D,SAASC,SAAS,IAAIC,0BAA0B,QAAQ,cAAc;AAEtE,SAASC,uBAAuB,QAAQ,UAAU;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAalD,MAAMC,YAA+B,GAAG;EACpCC,OAAO,EAAE,KAAK;EACdC,OAAO,EAAE,KAAK;EACdC,OAAO,EAAE;AACb,CAAC;AAED,MAAMC,MAAM,GAAG;EACX,aAAa,EAAE;IAAEH,OAAO,EAAE;EAAK,CAAC;EAChC,WAAW,EAAE;IAAEA,OAAO,EAAE;EAAM,CAAC;EAC/B,cAAc,EAAE;IAAEC,OAAO,EAAE;EAAK,CAAC;EACjC,cAAc,EAAE;IAAEA,OAAO,EAAE;EAAM,CAAC;EAClC,OAAO,EAAE;IAAEC,OAAO,EAAE;EAAK,CAAC;EAC1B,MAAM,EAAE;IAAEA,OAAO,EAAE;EAAM;AAC7B,CAAkF;AAElF,OAAO,MAAMR,SAAS,gBAAGH,UAAU,CAAuB,CAAC;EAAEa,QAAQ;EAAEC,KAAK;EAAE,GAAGC;AAAM,CAAC,EAAEC,SAAS,KAAK;EACpG,MAAMC,SAAS,GAAGf,MAAM,CAAc,CAAC;EACvC,MAAMgB,KAAK,GAAGhB,MAAM,CAAoBM,YAAY,CAAC;EACrD,MAAMW,QAAQ,GAAGjB,MAAM,CAACY,KAAK,CAAC;EAE9Bb,SAAS,CAAC,MAAM;IACZkB,QAAQ,CAACC,OAAO,GAAGN,KAAK;EAC5B,CAAC,EAAE,CAACA,KAAK,CAAC,CAAC;EAEXb,SAAS,CAAC,MAAM;IACZ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ACnBW,KAAK;IACTa,GAAG,EAAEA,GAAG,IAAI;MACRX,SAAS,CAACG,OAAO,GAAGQ,GAAG;MACvB,MAAML,WAAW,GAAG,OAAOT,KAAK,KAAK,UAAU,GACzCA,KAAK,CAACN,YAAY,CAAC,GACnBM,KAAK;MACX,MAAMU,MAAM,GAAG,OAAOD,WAAW,KAAK;MAClC;MAAA,EACEA,WAAW,CAACE,YAAY,CAAC,CAAC,GAC1B,EAAE;MACR,MAAMC,eAAe,GAAG,OAAOH,WAAW,KAAK,UAAU,GAClDA,WAAW,CAAc,CAAC,GAC3BA,WAAW;MAEjB,IAAI,OAAOP,SAAS,KAAK,QAAQ,IAAIA,SAAS,KAAK,IAAI,EAAE;QACrDA,SAAS,CAACI,OAAO,GAAGQ,GAAG;MAC3B;;MAEA;MACAvB,uBAAuB,CAACsB,GAAG,CAACC,GAAG,EAAE,CAACF,eAAe,CAAC,EAAEb,QAAQ,EAAE,CAACW,MAAM,CAAC,CAAC;IAC3E;EAAE,CACL,CAAC;AAEV,CAAC,CAAC","ignoreList":[]}
@@ -2,4 +2,5 @@
2
2
 
3
3
  export { Hide } from './Hide';
4
4
  export { Display } from './Display';
5
+ export { Pressable } from './Pressable';
5
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["Hide","Display"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,QAAQ;AAC7B,SAASC,OAAO,QAAQ,WAAW","ignoreList":[]}
1
+ {"version":3,"names":["Hide","Display","Pressable"],"sourceRoot":"../../../src","sources":["components/index.ts"],"mappings":";;AAAA,SAASA,IAAI,QAAQ,QAAQ;AAC7B,SAASC,OAAO,QAAQ,WAAW;AACnC,SAASC,SAAS,QAAQ,aAAa","ignoreList":[]}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+
3
+ export const getBoundArgs = fn => {
4
+ const boundArgs = [];
5
+ fn.bind = (thisArg, ...args) => {
6
+ boundArgs.push(...args);
7
+ const newFn = Function.prototype.bind.apply(fn, [thisArg, ...args]);
8
+ newFn.getBoundArgs = () => boundArgs;
9
+ return newFn;
10
+ };
11
+ return fn;
12
+ };
13
+ //# sourceMappingURL=getBoundArgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getBoundArgs","fn","boundArgs","bind","thisArg","args","push","newFn","Function","prototype","apply"],"sourceRoot":"../../../src","sources":["core/getBoundArgs.ts"],"mappings":";;AAAA,OAAO,MAAMA,YAAY,GAAIC,EAAY,IAAK;EAC1C,MAAMC,SAAS,GAAG,EAAgB;EAElCD,EAAE,CAACE,IAAI,GAAG,CAACC,OAAO,EAAE,GAAGC,IAAI,KAAK;IAC5BH,SAAS,CAACI,IAAI,CAAC,GAAGD,IAAI,CAAC;IAEvB,MAAME,KAAK,GAAGC,QAAQ,CAACC,SAAS,CAACN,IAAI,CAACO,KAAK,CAACT,EAAE,EAAE,CAACG,OAAO,EAAE,GAAGC,IAAI,CAAC,CAAC;IAEnEE,KAAK,CAACP,YAAY,GAAG,MAAME,SAAS;IAEpC,OAAOK,KAAK;EAChB,CAAC;EAED,OAAON,EAAE;AACb,CAAC","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export const getId = () => `${Math.random().toString(36).substring(2, 9)}`;
4
+ //# sourceMappingURL=getId.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getId","Math","random","toString","substring"],"sourceRoot":"../../../src","sources":["core/getId.ts"],"mappings":";;AAAA,OAAO,MAAMA,KAAK,GAAGA,CAAA,KAAM,GAAGC,IAAI,CAACC,MAAM,CAAC,CAAC,CAACC,QAAQ,CAAC,EAAE,CAAC,CAACC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE","ignoreList":[]}
@@ -1,4 +1,6 @@
1
1
  "use strict";
2
2
 
3
3
  export { createUnistylesComponent } from './createUnistylesComponent';
4
+ export { getBoundArgs } from './getBoundArgs';
5
+ export { getId } from './getId';
4
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["createUnistylesComponent"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":";;AAAA,SAASA,wBAAwB,QAAQ,4BAA4B","ignoreList":[]}
1
+ {"version":3,"names":["createUnistylesComponent","getBoundArgs","getId"],"sourceRoot":"../../../src","sources":["core/index.ts"],"mappings":";;AAAA,SAASA,wBAAwB,QAAQ,4BAA4B;AACrE,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASC,KAAK,QAAQ,SAAS","ignoreList":[]}
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+
3
+ export { useMedia } from './useMedia';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useMedia"],"sourceRoot":"../../../src","sources":["hooks/index.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,YAAY","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useLayoutEffect","useState","StyleSheet","UnistyleDependency","UnistylesRuntime","isValidMq","parseMq","isUnistylesMq","useMedia","config","computeIsVisible","maybeMq","mq","console","error","parsedMq","width","height","screen","minWidth","undefined","maxWidth","minHeight","maxHeight","isVisible","setIsVisible","removeChangeListener","addChangeListener","dependencies","includes","Breakpoints"],"sourceRoot":"../../../src","sources":["hooks/useMedia.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,eAAe,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,SAASC,UAAU,EAAEC,kBAAkB,EAAEC,gBAAgB,QAAkC,UAAU;AACrG,SAASC,SAAS,EAAEC,OAAO,EAAEC,aAAa,QAAQ,OAAO;AAEzD,OAAO,MAAMC,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,gBAAgB,GAAGA,CAAA,KAAe;IACpC,MAAMC,OAAO,GAAGF,MAAM,CAACG,EAAuB;IAE9C,IAAI,CAACL,aAAa,CAACI,OAAO,CAAC,EAAE;MACzBE,OAAO,CAACC,KAAK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,CAACf,gBAAgB,CAAC,CAAC,CAAC;MACpC;IACJ,CAAC,CAAC;IAEF,OAAO,MAAM;MACTgB,oBAAoB,CAAC,CAAC;IAC1B,CAAC;EACL,CAAC,EAAE,CAACjB,MAAM,CAACG,EAAE,CAAC,CAAC;EAEf,OAAO;IACHY;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -0,0 +1 @@
1
+ {"version":3,"names":["useEffect","useRef","useState","isUnistylesMq","isValidMq","parseMq","useMedia","config","disposeRef","isVisible","setIsVisible","maybeMq","mq","console","error","parsedMq","minWidth","maxWidth","minHeight","maxHeight","mediaQuery","undefined","filter","Boolean","join","media","window","matchMedia","handler","event","matches","addEventListener","current","removeEventListener"],"sourceRoot":"../../../src","sources":["hooks/useMedia.web.ts"],"mappings":";;AAAA,SAASA,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO;AACnD,SAASC,aAAa,EAAEC,SAAS,EAAEC,OAAO,QAAQ,OAAO;AAEzD,OAAO,MAAMC,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,UAAU,GAAGP,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;EACnC,MAAM,CAACQ,SAAS,EAAEC,YAAY,CAAC,GAAGR,QAAQ,CAAC,MAAM;IAC7C,MAAMS,OAAO,GAAGJ,MAAM,CAACK,EAAuB;IAE9C,IAAI,CAACT,aAAa,CAACQ,OAAO,CAAC,EAAE;MACzBE,OAAO,CAACC,KAAK,CAAC,sCAAsCH,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMI,QAAQ,GAAGV,OAAO,CAACM,OAAO,CAAC;IAEjC,IAAI,CAACP,SAAS,CAACW,QAAQ,CAAC,EAAE;MACtBF,OAAO,CAACC,KAAK,CAAC,oEAAoEH,OAAO,EAAE,CAAC;MAE5F,OAAO,KAAK;IAChB;IAEA,MAAM;MAAEK,QAAQ;MAAEC,QAAQ;MAAEC,SAAS;MAAEC;IAAU,CAAC,GAAGJ,QAAQ;IAE7D,MAAMK,UAAU,GAAG,CACfJ,QAAQ,KAAKK,SAAS,GAAG,eAAeL,QAAQ,KAAK,GAAGK,SAAS,EACjEJ,QAAQ,KAAKI,SAAS,GAAG,eAAeJ,QAAQ,KAAK,GAAGI,SAAS,EACjEH,SAAS,KAAKG,SAAS,GAAG,gBAAgBH,SAAS,KAAK,GAAGG,SAAS,EACpEF,SAAS,KAAKE,SAAS,GAAG,gBAAgBF,SAAS,KAAK,GAAGE,SAAS,CACvE,CAACC,MAAM,CAACC,OAAO,CAAC,CAACC,IAAI,CAAC,OAAO,CAAC;IAE/B,MAAMC,KAAK,GAAGC,MAAM,CAACC,UAAU,CAACP,UAAU,CAAC;IAC3C,MAAMQ,OAAO,GAAIC,KAA0B,IAAKnB,YAAY,CAACmB,KAAK,CAACC,OAAO,CAAC;IAE3EL,KAAK,CAACM,gBAAgB,CAAC,QAAQ,EAAEH,OAAO,CAAC;IACzCpB,UAAU,CAACwB,OAAO,GAAG,MAAMP,KAAK,CAACQ,mBAAmB,CAAC,QAAQ,EAAEL,OAAO,CAAC;IAEvE,OAAOH,KAAK,CAACK,OAAO;EACxB,CAAC,CAAC;;EAEF;EACA9B,SAAS,CAAC,MAAM,MAAMQ,UAAU,CAACwB,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC;EAE/C,OAAO;IACHvB;EACJ,CAAC;AACL,CAAC","ignoreList":[]}
@@ -2,6 +2,6 @@
2
2
 
3
3
  export * from './specs';
4
4
  export { mq } from './mq';
5
- export { createUnistylesComponent } from './core';
5
+ export { createUnistylesComponent, getBoundArgs } from './core';
6
6
  export * from './components';
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["mq","createUnistylesComponent"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,SAAS;AACvB,SAASA,EAAE,QAAQ,MAAM;AAEzB,SAASC,wBAAwB,QAAQ,QAAQ;AAEjD,cAAc,cAAc","ignoreList":[]}
1
+ {"version":3,"names":["mq","createUnistylesComponent","getBoundArgs"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;AAAA,cAAc,SAAS;AACvB,SAASA,EAAE,QAAQ,MAAM;AAEzB,SAASC,wBAAwB,EAAEC,YAAY,QAAQ,QAAQ;AAE/D,cAAc,cAAc","ignoreList":[]}
package/lib/module/mq.js CHANGED
@@ -21,17 +21,17 @@ const getMQValue = value => {
21
21
  */
22
22
  export const mq = {
23
23
  only: {
24
- width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
25
- height: (hMin = 0, hMax = Infinity) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
24
+ width: (wMin = 0, wMax = Number.POSITIVE_INFINITY) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]`,
25
+ height: (hMin = 0, hMax = Number.POSITIVE_INFINITY) => `:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
26
26
  },
27
- width: (wMin = 0, wMax = Infinity) => ({
27
+ width: (wMin = 0, wMax = Number.POSITIVE_INFINITY) => ({
28
28
  and: {
29
- height: (hMin = 0, hMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
29
+ height: (hMin = 0, hMax = Number.POSITIVE_INFINITY) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
30
30
  }
31
31
  }),
32
- height: (hMin = 0, hMax = Infinity) => ({
32
+ height: (hMin = 0, hMax = Number.POSITIVE_INFINITY) => ({
33
33
  and: {
34
- width: (wMin = 0, wMax = Infinity) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
34
+ width: (wMin = 0, wMax = Number.POSITIVE_INFINITY) => `:w[${getMQValue(wMin)}, ${getMQValue(wMax)}]:h[${getMQValue(hMin)}, ${getMQValue(hMax)}]`
35
35
  }
36
36
  })
37
37
  };
@@ -1 +1 @@
1
- {"version":3,"names":["UnistylesRuntime","IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","getMQValue","value","breakpoints","mq","only","width","wMin","wMax","Infinity","height","hMin","hMax","and","parseMq","fromW","toW","exec","fromH","toH","minWidth","undefined","Number","maxWidth","minHeight","maxHeight","isUnistylesMq","test","isValidMq","parsedMQ","isWidthValid","isHeightValid"],"sourceRoot":"../../src","sources":["mq.ts"],"mappings":";;AAEA,SAASA,gBAAgB,QAAQ,SAAS;AAE1C,MAAMC,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAqBpE,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,MAAMC,WAAW,GAAGN,gBAAgB,CAACM,WAAW;EAEhD,OAAOA,WAAW,CAACD,KAAK,CAAC,IAAI,CAAC;AAClC,CAAC;;AAED;AACA;AACA;AACA;AACA,OAAO,MAAME,EAAa,GAAG;EACzBC,IAAI,EAAE;IACFC,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,KAAM,MAAMR,UAAU,CAACM,IAAI,CAAC,KAAKN,UAAU,CAACO,IAAI,CAAC,GAAyB;IACvIE,MAAM,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGH,QAAQ,KAAM,MAAMR,UAAU,CAACU,IAAI,CAAC,KAAKV,UAAU,CAACW,IAAI,CAAC;EACnH,CAAC;EACDN,KAAK,EAAEA,CAACC,IAAuB,GAAG,CAAC,EAAEC,IAAa,GAAGC,QAAQ,MAAM;IAC/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GAAGE,SAAS,GAAGC,MAAM,CAACH,GAAG;EACrE,CAAC;AACL,CAAC;AAED,OAAO,MAAMO,aAAa,GAAItB,EAAU,IAAKN,kBAAkB,CAAC6B,IAAI,CAACvB,EAAE,CAAC;AAExE,OAAO,MAAMwB,SAAS,GAAIC,QAAoC,IAAK;EAC/D,MAAMC,YAAY,GAAGD,QAAQ,CAACT,QAAQ,KAAKC,SAAS,IAAIQ,QAAQ,CAACN,QAAQ,KAAKF,SAAS,IAAIQ,QAAQ,CAACT,QAAQ,IAAIS,QAAQ,CAACN,QAAQ;EACjI,MAAMQ,aAAa,GAAGF,QAAQ,CAACL,SAAS,KAAKH,SAAS,IAAIQ,QAAQ,CAACJ,SAAS,KAAKJ,SAAS,IAAIQ,QAAQ,CAACL,SAAS,IAAIK,QAAQ,CAACJ,SAAS;EAEtI,OAAOK,YAAY,IAAIC,aAAa;AACxC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["UnistylesRuntime","IS_UNISTYLES_REGEX","UNISTYLES_WIDTH_REGEX","UNISTYLES_HEIGHT_REGEX","getMQValue","value","breakpoints","mq","only","width","wMin","wMax","Number","POSITIVE_INFINITY","height","hMin","hMax","and","parseMq","fromW","toW","exec","fromH","toH","minWidth","undefined","maxWidth","minHeight","maxHeight","isUnistylesMq","test","isValidMq","parsedMQ","isWidthValid","isHeightValid"],"sourceRoot":"../../src","sources":["mq.ts"],"mappings":";;AAEA,SAASA,gBAAgB,QAAQ,SAAS;AAE1C,MAAMC,kBAAkB,GAAG,wCAAwC;AACnE,MAAMC,qBAAqB,GAAG,qCAAqC;AACnE,MAAMC,sBAAsB,GAAG,qCAAqC;AAqBpE,MAAMC,UAAU,GAAIC,KAAwB,IAAK;EAC7C,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAOA,KAAK;EAChB;EAEA,IAAIA,KAAK,KAAK,IAAI,EAAE;IAChB,OAAO,CAAC;EACZ;EAEA,MAAMC,WAAW,GAAGN,gBAAgB,C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adowReg
5
5
  const findShadowNodeForHandle = handle => {
6
6
  const node = handle?.__internalInstanceHandle?.stateNode?.node ?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node;
7
7
  if (!node) {
8
- // todo extend log with file name / component name
9
- throw new Error('Could not find shadow node for one of your components');
8
+ throw new Error(`Unistyles: Could not find shadow node for one of your components of type ${handle?.__internalInstanceHandle?.elementType ?? 'unknown'}`);
10
9
  }
11
10
  return node;
12
11
  };
13
- HybridShadowRegistry.add = (handle, styles, variants, args, uniquePressableId) => {
12
+ HybridShadowRegistry.add = (handle, styles, variants, args, id) => {
14
13
  // virtualized nodes can be null
15
14
  if (!handle || !styles || !Array.isArray(styles)) {
16
15
  return;
@@ -18,7 +17,7 @@ HybridShadowRegistry.add = (handle, styles, variants, args, uniquePressableId) =
18
17
 
19
18
  // filter Reanimated styles and styles that are undefined
20
19
  const filteredStyles = styles.filter(style => !style?.initial?.updater).filter(Boolean);
21
- HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles, variants ?? {}, args ?? [], uniquePressableId);
20
+ HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles, variants ?? {}, args ?? [], id);
22
21
  };
23
22
  HybridShadowRegistry.remove = handle => {
24
23
  if (!handle) {
@@ -1 +1 @@
1
- {"version":3,"names":["NitroModules","HybridShadowRegistry","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","add","styles","variants","args","uniquePressableId","Array","isArray","filteredStyles","filter","style","initial","updater","Boolean","link","remove","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAazD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBA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adowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","Error","elementType","add","styles","variants","args","id","Array","isArray","filteredStyles","filter","style","initial","updater","Boolean","link","remove","unlink","UnistylesShadowRegistry"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AAazD,MAAMC,oBAAoB,GAAGD,YAAY,CAACE,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEhF,IAAI,CAACA,IAAI,EAAE;IACP,MAAM,IAAIK,KAAK,CAAC,4EAA4EN,MAAM,EAAEE,wBAAwB,EAAEK,WAAW,IAAI,SAAS,EAAE,CAAC;EAC7J;EAEA,OAAON,IAAI;AACf,CAAC;AAEDJ,oBAAoB,CAACW,GAAG,GAAG,CAACR,MAAM,EAAES,MAAM,EAAEC,QAAQ,EAAEC,IAAI,EAAEC,EAAE,KAAK;EAC/D;EACA,IAAI,CAACZ,MAAM,IAAI,CAACS,MAAM,IAAI,CAACI,KAAK,CAACC,OAAO,CAACL,MAAM,CAAC,EAAE;IAC9C;EACJ;;EAEA;EACA,MAAMM,cAAc,GAAGN,MAAM,CACxBO,MAAM,CAACC,KAAK,IAAI,CAACA,KAAK,EAAEC,OAAO,EAAEC,OAAO,CAAC,CACzCH,MAAM,CAACI,OAAO,CAAC;EAEpBvB,oBAAoB,CAACwB,IAAI,CAACtB,uBAAuB,CAACC,MAAM,CAAC,EAAEe,cAAc,EAAEL,QAAQ,IAAI,CAAC,CAAC,EAAEC,IAAI,IAAI,EAAE,EAAEC,EAAE,CAAC;AAC9G,CAAC;AAEDf,oBAAoB,CAACyB,MAAM,GAAGtB,MAAM,IAAI;EACpC,IAAI,CAACA,MAAM,EAAE;IACT;EACJ;EAEAH,oBAAoB,CAAC0B,MAAM,CAACxB,uBAAuB,CAACC,MAAM,CAAC,CAAC;AAChE,CAAC;AAQD,OAAO,MAAMwB,uBAAuB,GAAG3B,oBAA4D","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["NitroModules","processColor","StyleSheet","NativeStyleSheet","HybridUnistylesStyleSheet","createHybridObject","absoluteFillObject","absoluteFill","flatten","compose","jsMethods","init"],"sourceRoot":"../../../../src","sources":["specs/StyleSheet/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AACzD,SAASC,YAAY,EAAEC,UAAU,IAAIC,gBAAgB,QAAQ,cAAc;AAgC3E,MAAMC,yBAAyB,GAAGJ,YAAY,CACzCK,kBAAkB,CAAsB,qBAAqB,CAAC;AAEnED,yBAAyB,CAACE,kBAAkB,GAAGH,gBAAgB,CAACG,kBAAkB;AAClFF,yBAAyB,CAACG,YAAY,GAAGJ,gBAAgB,CAACI,YAAY;AACtEH,yBAAyB,CAACI,OAAO,GAAGL,gBAAgB,CAACK,OAAO;AAC5DJ,yBAAyB,CAACK,OAAO,GAAGN,gBAAgB,CAACM,OAAO;AAC5DL,yBAAyB,CAACM,SAAS,GAAG;EAClCT;AACJ,CAAC;AAEDG,yBAAyB,CAACO,IAAI,CAAC,CAAC;AAIhC,OAAO,MAAMT,UAAU,GAAGE,yBAAsE","ignoreList":[]}
1
+ {"version":3,"names":["NitroModules","processColor","StyleSheet","NativeStyleSheet","HybridUnistylesStyleSheet","createHybridObject","absoluteFillObject","absoluteFill","flatten","compose","jsMethods","init"],"sourceRoot":"../../../../src","sources":["specs/StyleSheet/index.ts"],"mappings":";;AAAA,SAASA,YAAY,QAAQ,4BAA4B;AACzD,SAASC,YAAY,EAAEC,UAAU,IAAIC,gBAAgB,QAAQ,cAAc;AAiC3E,MAAMC,yBAAyB,GAAGJ,YAAY,CACzCK,kBAAkB,CAAsB,qBAAqB,CAAC;AAEnED,yBAAyB,CAACE,kBAAkB,GAAGH,gBAAgB,CAACG,kBAAkB;AAClFF,yBAAyB,CAACG,YAAY,GAAGJ,gBAAgB,CAACI,YAAY;AACtEH,yBAAyB,CAACI,OAAO,GAAGL,gBAAgB,CAACK,OAAO;AAC5DJ,yBAAyB,CAACK,OAAO,GAAGN,gBAAgB,CAACM,OAAO;AAC5DL,yBAAyB,CAACM,SAAS,GAAG;EAClCT;AACJ,CAAC;AAEDG,yBAAyB,CAACO,IAAI,CAAC,CAAC;AAIhC,OAAO,MAAMT,UAAU,GAAGE,yBAAsE","ignoreList":[]}
@@ -2,8 +2,7 @@
2
2
 
3
3
  import { TurboModuleRegistry } from 'react-native';
4
4
 
5
- // this is empty spec for TurboModule that is required to hook
6
- // Unistyles to Fabric
5
+ // this is empty spec for TurboModule that is required to hook Unistyles to Fabric
7
6
 
8
7
  TurboModuleRegistry.get('Unistyles');
9
8
  //# sourceMappingURL=NativeTurboUnistyles.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["TurboModuleRegistry","get"],"sourceRoot":"../../../../src","sources":["specs/TurboUnistyles/NativeTurboUnistyles.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAElD;AACA;;AAGAA,mBAAmB,CAACC,GAAG,CAAO,WAAW,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["TurboModuleRegistry","get"],"sourceRoot":"../../../../src","sources":["specs/TurboUnistyles/NativeTurboUnistyles.ts"],"mappings":";;AACA,SAASA,mBAAmB,QAAQ,cAAc;;AAElD;;AAGAA,mBAAmB,CAACC,GAAG,CAAO,WAAW,CAAC","ignoreList":[]}
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
2
 
3
- export const getSSRUnistyles = () => [];
4
3
  export * from '../web';
5
4
  //# sourceMappingURL=index.web.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["getSSRUnistyles"],"sourceRoot":"../../../src","sources":["specs/index.web.ts"],"mappings":";;AAEA,OAAO,MAAMA,eAAe,GAAGA,CAAA,KAAM,EAAyB;AAE9D,cAAc,QAAQ","ignoreList":[]}
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["specs/index.web.ts"],"mappings":";;AAAA,cAAc,QAAQ","ignoreList":[]}
@@ -6,7 +6,7 @@ export const deepMergeObjects = (...sources) => {
6
6
  Object.keys(source).forEach(key => {
7
7
  const sourceValue = source[key];
8
8
  const targetValue = target[key];
9
- if (Object(sourceValue) == sourceValue && Object(targetValue) === targetValue) {
9
+ if (Object(sourceValue) === sourceValue && Object(targetValue) === targetValue) {
10
10
  // @ts-expect-error - can't assign to generic
11
11
  target[key] = deepMergeObjects(targetValue, sourceValue);
12
12
  return;
@@ -1 +1 @@
1
- {"version":3,"names":["deepMergeObjects","sources","target","forEach","source","Object","keys","key","sourceValue","targetValue"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA,OAAO,MAAMA,gBAAgB,GAAGA,CAAqC,GAAGC,OAAiB,KAAK;EAC1F,MAAMC,MAAM,GAAG,CAAC,CAAM;EAEtBD,OAAO,CAACE,OAAO,CAACC,MAAM,IAAI;IACtBC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACD,OAAO,CAACI,GAAG,IAAI;MAC/B,MAAMC,WAAW,GAAGJ,MAAM,CAACG,GAAG,CAAC;MAC/B,MAAME,WAAW,GAAGP,MAAM,CAACK,GAAG,CAAC;MAE/B,IAAIF,MAAM,CAACG,WAAW,CAAC,IAAIA,WAAW,IAAIH,MAAM,CAACI,WAAW,CAAC,KAAKA,WAAW,EAAE;QAC3E;QACAP,MAAM,CAACK,GAAG,CAAC,GAAGP,gBAAgB,CAACS,WAAW,EAAED,WAAW,CAAC;QAExD;MACJ;;MAEA;MACAN,MAAM,CAACK,GAAG,CAAC,GAAGC,WAAW;IAC7B,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAON,MAAM;AACjB,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["deepMergeObjects","sources","target","forEach","source","Object","keys","key","sourceValue","targetValue"],"sourceRoot":"../../src","sources":["utils.ts"],"mappings":";;AAAA,OAAO,MAAMA,gBAAgB,GAAGA,CAAqC,GAAGC,OAAiB,KAAK;EAC1F,MAAMC,MAAM,GAAG,CAAC,CAAM;EAEtBD,OAAO,CAACE,OAAO,CAACC,MAAM,IAAI;IACtBC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACD,OAAO,CAACI,GAAG,IAAI;MAC/B,MAAMC,WAAW,GAAGJ,MAAM,CAACG,GAAG,CAAC;MAC/B,MAAME,WAAW,GAAGP,MAAM,CAACK,GAAG,CAAC;MAE/B,IAAIF,MAAM,CAACG,WAAW,CAAC,KAAKA,WAAW,IAAIH,MAAM,CAACI,WAAW,CAAC,KAAKA,WAAW,EAAE;QAC5E;QACAP,MAAM,CAACK,GAAG,CAAC,GAAGP,gBAAgB,CAACS,WAAW,EAAED,WAAW,CAAC;QAExD;MACJ;;MAEA;MACAN,MAAM,CAACK,GAAG,CAAC,GAAGC,WAAW;IAC7B,CAAC,CAAC;EACN,CAAC,CAAC;EAEF,OAAON,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["TEXT_SHADOW_STYLES","BOX_SHADOW_STYLES"],"sourceRoot":"../../../../src","sources":["web/convert/types.ts"],"mappings":";;AAKA,OAAO,MAAMA,kBAAkB,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,CAAU;AAItG,OAAO,MAAMC,iBAAiB,GAAG,CAAC,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAU","ignoreList":[]}
1
+ {"version":3,"names":["TEXT_SHADOW_STYLES","BOX_SHADOW_STYLES"],"sourceRoot":"../../../../src","sources":["web/convert/types.ts"],"mappings":";;AAMA,OAAO,MAAMA,kBAAkB,GAAG,CAAC,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,CAAU;AAItG,OAAO,MAAMC,iBAAiB,GAAG,CAAC,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,CAAU","ignoreList":[]}
@@ -23,7 +23,7 @@ export const normalizeColor = (color, opacity = 1) => {
23
23
  }
24
24
  const hex = integer.toString(16).padStart(8, '0');
25
25
  if (hex.length === 8) {
26
- const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => parseInt(x, 16)).filter(num => !isNaN(num));
26
+ const [r = 0, g = 0, b = 0, a = 1] = hex.split(/(?=(?:..)*$)/).map(x => Number.parseInt(x, 16)).filter(num => !Number.isNaN(num));
27
27
  return `rgba(${r},${g},${b},${a / 255 * opacity})`;
28
28
  }
29
29
  return color;
@@ -1 +1 @@
1
- {"version":3,"names":["normalizeColors","BOX_SHADOW_STYLES","TEXT_SHADOW_STYLES","isTransform","key","value","Array","isArray","isTextShadow","includes","isShadow","isFilter","isBoxShadow","normalizeNumericValue","normalizeColor","color","opacity","integer","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","extractShadowValue","breakpoint","styles","width","height"],"sourceRoot":"../../../../src","sources":["web/convert/utils.ts"],"mappings":";;AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAC5D,SAASC,iBAAiB,EAAEC,kBAAkB,QAA0D,SAAS;AAIjH,OAAO,MAAMC,WAAW,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAAsCD,GAAG,KAAK,WAAW,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAEpI,OAAO,MAAMG,YAAY,GAAIJ,GAAW,IAAKF,kBAAkB,CAACO,QAAQ,CAACL,GAAwC,CAAC;AAElH,OAAO,MAAMM,QAAQ,GAAIN,GAAW,IAAKH,iBAAiB,CAACQ,QAAQ,CAACL,GAAuC,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,OAAOD,KAAK;AAChB,CAAC;AAED,OAAO,MAAMkB,kBAAkB,GAAGA,CAA6B7B,GAAS,EAAE8B,UAAkB,EAAEC,MAAW,KAAsB;EAC3H,MAAM9B,KAAK,GAAG8B,MAAM,CAAC/B,GAAG,CAAC;EAEzB,IAAIA,GAAG,KAAK,kBAAkB,IAAIA,GAAG,KAAK,cAAc,EAAE;IACtD,MAAM;MAAEgC,KAAK;MAAEC;IAAO,CAAC,GAAGhC,KAAK;IAE/B,OAAO;MACH+B,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,OAAOhC,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAAC6B,UAAU,CAAC,GAAG7B,KAAK;AAChE,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["normalizeColors","BOX_SHADOW_STYLES","TEXT_SHADOW_STYLES","isTransform","key","value","Array","isArray","isTextShadow","includes","isShadow","isFilter","isBoxShadow","normalizeNumericValue","normalizeColor","color","opacity","integer","hex","toString","padStart","length","r","g","b","a","split","map","x","Number","parseInt","filter","num","isNaN","extractShadowValue","breakpoint","styles","width","height"],"sourceRoot":"../../../../src","sources":["web/convert/utils.ts"],"mappings":";;AAAA;AACA;AACA,OAAOA,eAAe,MAAM,gCAAgC;AAC5D,SAASC,iBAAiB,EAAEC,kBAAkB,QAA0D,SAAS;AAIjH,OAAO,MAAMC,WAAW,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAAsCD,GAAG,KAAK,WAAW,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAEpI,OAAO,MAAMG,YAAY,GAAIJ,GAAW,IAAKF,kBAAkB,CAACO,QAAQ,CAACL,GAAwC,CAAC;AAElH,OAAO,MAAMM,QAAQ,GAAIN,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AAC,IAAIC,CAAC,IAAKC,CAAC,GAAG,GAAG,GAAIT,OAAO,GAAG;EACxD;EAEA,OAAOD,KAAK;AAChB,CAAC;AAED,OAAO,MAAMmB,kBAAkB,GAAGA,CAA6B9B,GAAS,EAAE+B,UAAkB,EAAEC,MAAW,KAAsB;EAC3H,MAAM/B,KAAK,GAAG+B,MAAM,CAAChC,GAAG,CAAC;EAEzB,IAAIA,GAAG,KAAK,kBAAkB,IAAIA,GAAG,KAAK,cAAc,EAAE;IACtD,MAAM;MAAEiC,KAAK;MAAEC;IAAO,CAAC,GAAGjC,KAAK;IAE/B,OAAO;MACHgC,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,OAAOjC,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAAC8B,UAAU,CAAC,GAAG9B,KAAK;AAChE,CAAC","ignoreList":[]}
@@ -1,10 +1,13 @@
1
1
  "use strict";
2
2
 
3
- import { assignSecrets, reduceObject, getStyles } from './utils';
3
+ import { assignSecrets, reduceObject, getStyles, error } from './utils';
4
4
  import { deepMergeObjects } from '../utils';
5
5
  import { UnistylesRuntime } from './runtime';
6
- import { createUseVariants, getVariants } from './variants';
7
- export const create = stylesheet => {
6
+ import { getVariants } from './variants';
7
+ export const create = (stylesheet, id) => {
8
+ if (!id) {
9
+ throw error('Unistyles is not initialized correctly. Please add babel plugin to your babel config.');
10
+ }
8
11
  const computedStylesheet = typeof stylesheet === 'function' ? stylesheet(UnistylesRuntime.theme, UnistylesRuntime.miniRuntime) : stylesheet;
9
12
  const selectedVariants = new Map();
10
13
  const copyVariants = () => Object.fromEntries(selectedVariants.entries());
@@ -38,7 +41,12 @@ export const create = stylesheet => {
38
41
  });
39
42
 
40
43
  // Inject useVariants hook to styles
41
- createUseVariants(styles, newVariants => Object.entries(newVariants).forEach(([key, value]) => selectedVariants.set(key, value)));
44
+ Object.defineProperty(styles, 'useVariants', {
45
+ value: variants => {
46
+ Object.entries(variants).forEach(([key, value]) => selectedVariants.set(key, value));
47
+ },
48
+ configurable: false
49
+ });
42
50
  return styles;
43
51
  };
44
52
  //# sourceMappingURL=create.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["assignSecrets","reduceObject","getStyles","deepMergeObjects","UnistylesRuntime","createUseVariants","getVariants","create","stylesheet","computedStylesheet","theme","miniRuntime","selectedVariants","Map","copyVariants","Object","fromEntries","entries","addSecrets","value","key","args","__uni__key","__uni__refs","Set","__uni__stylesheet","__uni__args","__uni__variants","styles","_key","String","dynamicStyle","result","variants","resultWithVariants","newVariants","forEach","set"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;AAEA,SAASA,aAAa,EAAEC,YAAY,EAAEC,SAAS,QAAQ,SAAS;AAChE,SAASC,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,iBAAiB,EAAEC,WAAW,QAAQ,YAAY;AAE3D,OAAO,MAAMC,MAAM,GAAIC,UAAiD,IAAK;EACzE,MAAMC,kBAAkB,GAAG,OAAOD,UAAU,KAAK,UAAU,GACrDA,UAAU,CAACJ,gBAAgB,CAACM,KAAK,EAAEN,gBAAgB,CAACO,WAAW,CAAC,GAChEH,UAAU;EAChB,MAAMI,gBAAgB,GAAG,IAAIC,GAAG,CAAc,CAAC;EAE/C,MAAMC,YAAY,GAAGA,CAAA,KAAMC,MAAM,CAACC,WAAW,CAACJ,gBAAgB,CAACK,OAAO,CAAC,CAAC,CAAC;EACzE,MAAMC,UAAU,GAAGA,CAACC,KAAU,EAAEC,GAAW,EAAEC,IAAiB,KAAKrB,aAAa,CAACmB,KAAK,EAAE;IACpFG,UAAU,EAAEF,GAAG;IACfG,WAAW,EAAE,IAAIC,GAAG,CAAC,CAAC;IACtBC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ects","UnistylesRuntime","getVariants","create","stylesheet","id","computedStylesheet","theme","miniRuntime","selectedVariants","Map","copyVariants","Object","fromEntries","entries","addSecrets","value","key","args","__uni__key","__uni__refs","Set","__uni__stylesheet","__uni__args","__uni__variants","styles","_key","String","dynamicStyle","result","variants","resultWithVariants","defineProperty","forEach","set","configurable"],"sourceRoot":"../../../src","sources":["web/create.ts"],"mappings":";;AAEA,SAASA,aAAa,EAAEC,YAAY,EAAEC,SAAS,EAAEC,KAAK,QAAQ,SAAS;AACvE,SAASC,gBAAgB,QAAQ,UAAU;AAC3C,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,WAAW,QAAQ,YAAY;AAExC,OAAO,MAAMC,MAAM,GAAGA,CAACC,UAAiD,EAAEC,EAAW,KAAK;EACtF,IAAI,CAACA,EAAE,EAAE;IACL,MAAMN,KAAK,CAAC,uFAAuF,CAAC;EACxG;EAEA,MAAMO,kBAAkB,GAAG,OAAOF,UAAU,KAAK,UAAU,GACrDA,UAAU,CAACH,gBAAgB,CAACM,KAAK,EAAEN,gBAAgB,CAACO,WAAW,CAAC,GAChEJ,UAAU;EAChB,MAAMK,gBAAgB,GAAG,IAAIC,GAAG,CAAc,CAAC;EAE/C,MAAMC,YAAY,GAAGA,CAAA,KAAMC,MAAM,CAACC,WAAW,CAACJ,gBAAgB,CAACK,OAAO,CAAC,CAAC,CAAC;EACzE,MAAMC,UAAU,GAAGA,CAACC,KAAU,EAAEC,GAAW,EAAEC,IAAiB,KAAKtB,aAAa,CAACoB,KAAK,EAAE;IACpFG,UAAU,EAAEF,GAAG;IACfG,WAAW,EAAE,IAAIC,GAAG,CAAC,CAAC;IACtBC,iBAAiB,EAAElB,UAAU;IAC7BmB,WAAW,EAAEL,IAAI;IACjBM,eAAe,EAAEb,YAAY,CAAC;EAClC,CAAC,CAAC;EAEF,MAAMc,MAAM,GAAG5B,YAAY,CAACS,kBAAkB,EAAE,CAACU,KAAK,EAAEU,IAAI,KAAK;IAC7D,MAAMT,GAAG,GAAGU,MAAM,CAACD,IAAI,CAAC;IAExB,IAAI,OAAOV,KAAK,KAAK,UAAU,EAAE;MAC7B,MAAMY,YAAY,GAAGA,CAAC,GAAGV,IAAgB,KAAK;QAC1C,MAAMW,MAAM,GAAGb,KAAK,CAAC,GAAGE,IAAI,CAAC;QAC7B,MAAMY,QAAQ,GAAGlB,MAAM,CAACC,WAAW,CAACX,WAAW,CAAC;UAAE,CAACe,GAAG,GAAGY;QAAO,CAAC,EAAuClB,YAAY,CAAC,CAAC,CAAC,CAAC;QACxH,MAAMoB,kBAAkB,GAAG/B,gBAAgB,CAAC6B,MAAM,EAAEC,QAAQ,CAACb,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;;QAExE;QACA,OAAOF,UAAU,CAACjB,SAAS,CAACiC,kBAAkB,CAAC,EAAEd,GAAG,EAAEC,IAAI,CAAC;MAC/D,CAAC;;MAED;MACA,OAAOH,UAAU,CAACa,YAAY,EAAEX,GAAG,CAAC;IACxC;;IAEA;IACA,OAAOF,UAAU,CAACjB,SAAS,CAACkB,KAAK,CAAC,EAAEC,GAAG,CAAC;EAC5C,CAAC,CAAsC;;EAEvC;EACAL,MAAM,CAACoB,cAAc,CAACP,MAAM,EAAE,aAAa,EAAE;IACzCT,KAAK,EAAGc,QAA0C,IAAK;MACnDlB,MAAM,CAACE,OAAO,CAACgB,QAAQ,CAAC,CAACG,OAAO,CAAC,CAAC,CAAChB,GAAG,EAAED,KAAK,CAAC,KAAKP,gBAAgB,CAACyB,GAAG,CAACjB,GAAG,EAAED,KAAK,CAAC,CAAC;IACxF,CAAC;IACDmB,YAAY,EAAE;EAClB,CAAC,CAAC;EAEF,OAAOV,MAAM;AACjB,CAAC","ignoreList":[]}
@@ -13,6 +13,13 @@ export const StyleSheet = {
13
13
  right: 0,
14
14
  bottom: 0
15
15
  },
16
+ absoluteFillObject: {
17
+ position: 'absolute',
18
+ left: 0,
19
+ top: 0,
20
+ right: 0,
21
+ bottom: 0
22
+ },
16
23
  compose: (a, b) => deepMergeObjects(a, b),
17
24
  flatten: (...styles) => deepMergeObjects(...styles),
18
25
  hairlineWidth: 1
@@ -20,7 +27,4 @@ export const StyleSheet = {
20
27
  export { UnistylesRuntime } from './runtime';
21
28
  export { UnistylesShadowRegistry } from './shadowRegistry';
22
29
  export * from './mock';
23
-
24
- // TODO: Work on SSR
25
- export const getSSRUnistyles = () => [];
26
30
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["create","UnistylesState","deepMergeObjects","StyleSheet","configure","init","absoluteFill","position","left","top","right","bottom","compose","a","b","flatten","styles","hairlineWidth","UnistylesRuntime","UnistylesShadowRegistry","getSSRUnistyles"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,gBAAgB,QAAQ,UAAU;AAE3C,OAAO,MAAMC,UAAU,GAAG;EACtBC,SAAS,EAAEH,cAAc,CAACI,IAAI;EAC9BL,MAAM;EACNM,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAKZ,gBAAgB,CAACW,CAAC,EAAEC,CAAC,CAAC;EACzDC,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAKd,gBAAgB,CAAC,GAAGc,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAED,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,cAAc,QAAQ;;AAEtB;AACA,OAAO,MAAMC,eAAe,GAAGA,CAAA,KAAM,EAAE","ignoreList":[]}
1
+ {"version":3,"names":["create","UnistylesState","deepMergeObjects","StyleSheet","configure","init","absoluteFill","position","left","top","right","bottom","absoluteFillObject","compose","a","b","flatten","styles","hairlineWidth","UnistylesRuntime","UnistylesShadowRegistry"],"sourceRoot":"../../../src","sources":["web/index.ts"],"mappings":";;AAAA,SAASA,MAAM,QAAQ,UAAU;AACjC,SAASC,cAAc,QAAQ,SAAS;AACxC,SAASC,gBAAgB,QAAQ,UAAU;AAE3C,OAAO,MAAMC,UAAU,GAAG;EACtBC,SAAS,EAAEH,cAAc,CAACI,IAAI;EAC9BL,MAAM;EACNM,YAAY,EAAE;IACVC,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDC,kBAAkB,EAAE;IAChBL,QAAQ,EAAE,UAAU;IACpBC,IAAI,EAAE,CAAC;IACPC,GAAG,EAAE,CAAC;IACNC,KAAK,EAAE,CAAC;IACRC,MAAM,EAAE;EACZ,CAAC;EACDE,OAAO,EAAEA,CAACC,CAAS,EAAEC,CAAS,KAAKb,gBAAgB,CAACY,CAAC,EAAEC,CAAC,CAAC;EACzDC,OAAO,EAAEA,CAAC,GAAGC,MAAqB,KAAKf,gBAAgB,CAAC,GAAGe,MAAM,CAAC;EAClEC,aAAa,EAAE;AACnB,CAAC;AAED,SAASC,gBAAgB,QAAQ,WAAW;AAC5C,SAASC,uBAAuB,QAAQ,kBAAkB;AAC1D,cAAc,QAAQ","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"names":["UnistyleDependency","UnistylesRuntime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","Set","stylesheetListeners","emitChange","dependency","forEach","listener","initListeners","darkMedia","addEventListener","event","matches","ColorScheme","hasAdaptiveThemes","Theme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","addStylesheetListeners","UnistylesListener"],"sourceRoot":"../../../src","sources":["web/listener.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,yBAAyB;AAC5D,SA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names":["UnistyleDependency","UnistylesRuntime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","Set","stylesheetListeners","emitChange","dependency","forEach","listener","initListeners","darkMedia","addEventListener","event","matches","ColorScheme","hasAdaptiveThemes","Theme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","addStylesheetListeners","UnistylesListener"],"sourceRoot":"../../../src","sources":["web/listener.ts"],"mappings":";;AAAA,SAASA,kBAAkB,QAAQ,yBAAyB;AAC5D,SAASC,gBAAgB,QAAQ,WAAW;AAE5C,MAAMC,wBAAwB,CAAC;EACnBC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACT,kBAAkB,CAAC,CAACO,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAIG,GAAG,CAAe,CAAC,CAAC;EAC7GC,mBAAmB,GAAGN,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACT,kBAAkB,CAAC,CAACO,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAIG,GAAG,CAAe,CAAC,CAAC;EAE/HE,UAAU,GAAIC,UAA8B,IAAK;IAC7C,IAAI,CAACF,mBAAmB,CAACE,UAAU,CAAC,EAAEC,OAAO,CAACC,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC;IACrE,IAAI,CAACX,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;IAEzBF,gBAAgB,CAACgB,SAAS,EAAEC,gBAAgB,CAAC,QAAQ,EAAEC,KAAK,IAAI;MAC5D,IAAI,CAACA,KAAK,CAACC,OAAO,E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UAAU,CAAC,EAAEiB,GAAG,CAACf,QAAQ,CAAC,CAAC;IAEvF,OAAO,MAAM;MACTc,YAAY,CAACf,OAAO,CAACD,UAAU,IAAI,IAAI,CAACF,mBAAmB,CAACE,UAAU,CAAC,EAAEkB,MAAM,CAAChB,QAAQ,CAAC,CAAC;IAC9F,CAAC;EACL,CAAC;AACL;AAEA,OAAO,MAAMkB,iBAAiB,GAAG,IAAI/B,wBAAwB,CAAC,CAAC","ignoreList":[]}
@@ -6,7 +6,7 @@ import { WebContentSizeCategory } from '../types';
6
6
  import { UnistylesListener } from './listener';
7
7
  import { NavigationBar, StatusBar } from './mock';
8
8
  import { UnistylesState } from './state';
9
- import { isServer, schemeToTheme } from './utils';
9
+ import { error, isServer, schemeToTheme } from './utils';
10
10
  class UnistylesRuntimeBuilder {
11
11
  lightMedia = this.getLightMedia();
12
12
  darkMedia = this.getDarkMedia();
@@ -126,6 +126,9 @@ class UnistylesRuntimeBuilder {
126
126
  };
127
127
  }
128
128
  setTheme = themeName => {
129
+ if (this.hasAdaptiveThemes) {
130
+ throw error(`You're trying to set theme to: '${themeName}', but adaptiveThemes are enabled.`);
131
+ }
129
132
  if (themeName === UnistylesRuntime.themeName) {
130
133
  return;
131
134
  }
@@ -150,17 +153,14 @@ class UnistylesRuntimeBuilder {
150
153
  updateTheme = (themeName, updater) => {
151
154
  const oldTheme = UnistylesState.themes.get(themeName);
152
155
  if (!oldTheme) {
153
- throw new Error(`🦄 Theme "${themeName}" is not registered!`);
156
+ throw error(`Unistyles: You're trying to update theme "${themeName}" but it wasn't registered.`);
154
157
  }
155
158
  UnistylesState.themes.set(themeName, updater(oldTheme));
156
159
  };
157
160
  getTheme = (themeName = this.themeName) => {
158
- if (!themeName) {
159
- throw new Error('🦄 No theme selected!');
160
- }
161
- const theme = UnistylesState.themes.get(themeName);
162
- if (!theme) {
163
- throw new Error(`🦄 Theme "${this.themeName}" is not registered!`);
161
+ const theme = UnistylesState.themes.get(themeName ?? '');
162
+ if (!themeName || !theme) {
163
+ throw error(`You're trying to get theme "${themeName}" but it wasn't registered.`);
164
164
  }
165
165
  return theme;
166
166
  };