react-native-unistyles 3.0.0-alpha.34 → 3.0.0-alpha.36

Sign up to get free protection for your applications and to get access to all the features.
Files changed (208) hide show
  1. package/android/CMakeLists.txt +31 -36
  2. package/android/build.gradle +2 -1
  3. package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
  4. package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
  5. package/android/src/main/cxx/cpp-adapter.cpp +8 -86
  6. package/android/src/main/java/com/unistyles/NativePlatform.kt +184 -0
  7. package/android/src/main/java/com/unistyles/UnistylesModule+insets.kt +8 -0
  8. package/android/src/main/java/com/unistyles/UnistylesModule.kt +47 -0
  9. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
  10. package/cxx/NativePlatform.h +11 -0
  11. package/cxx/common/Helpers.h +1 -1
  12. package/cxx/core/Unistyle.h +1 -1
  13. package/cxx/core/UnistylesRegistry.h +1 -1
  14. package/cxx/hybridObjects/HybridNavigationBar.h +3 -3
  15. package/cxx/hybridObjects/HybridStatusBar.h +3 -3
  16. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -4
  17. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -2
  18. package/lib/commonjs/components/useMedia.js.map +1 -1
  19. package/lib/commonjs/components/useMedia.web.js +43 -0
  20. package/lib/commonjs/components/useMedia.web.js.map +1 -0
  21. package/lib/commonjs/core/createUnistylesComponent.js +57 -4
  22. package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
  23. package/lib/commonjs/core/createUnistylesComponent.native.js +6 -5
  24. package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
  25. package/lib/commonjs/specs/ShadowRegistry/index.js +5 -0
  26. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  27. package/lib/commonjs/web/convert/index.js +16 -11
  28. package/lib/commonjs/web/convert/index.js.map +1 -1
  29. package/lib/commonjs/web/convert/object/boxShadow.js +58 -0
  30. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
  31. package/lib/commonjs/web/convert/object/filter.js +42 -0
  32. package/lib/commonjs/web/convert/object/filter.js.map +1 -0
  33. package/lib/commonjs/web/convert/object/index.js +39 -0
  34. package/lib/commonjs/web/convert/object/index.js.map +1 -0
  35. package/lib/commonjs/web/convert/object/objectStyle.js +55 -0
  36. package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
  37. package/lib/commonjs/web/convert/object/transform.js +27 -0
  38. package/lib/commonjs/web/convert/object/transform.js.map +1 -0
  39. package/lib/commonjs/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
  40. package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
  41. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
  42. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  43. package/lib/commonjs/web/convert/shadow/index.js +28 -0
  44. package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
  45. package/lib/commonjs/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
  46. package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
  47. package/lib/commonjs/web/convert/utils.js +7 -3
  48. package/lib/commonjs/web/convert/utils.js.map +1 -1
  49. package/lib/commonjs/web/listener.js +10 -0
  50. package/lib/commonjs/web/listener.js.map +1 -1
  51. package/lib/commonjs/web/registry.js +13 -26
  52. package/lib/commonjs/web/registry.js.map +1 -1
  53. package/lib/commonjs/web/runtime.js +3 -0
  54. package/lib/commonjs/web/runtime.js.map +1 -1
  55. package/lib/commonjs/web/shadowRegistry.js +79 -39
  56. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  57. package/lib/commonjs/web/utils/common.js +3 -33
  58. package/lib/commonjs/web/utils/common.js.map +1 -1
  59. package/lib/commonjs/web/utils/unistyle.js +4 -1
  60. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  61. package/lib/module/components/useMedia.js.map +1 -1
  62. package/lib/module/components/useMedia.web.js +38 -0
  63. package/lib/module/components/useMedia.web.js.map +1 -0
  64. package/lib/module/core/createUnistylesComponent.js +55 -3
  65. package/lib/module/core/createUnistylesComponent.js.map +1 -1
  66. package/lib/module/core/createUnistylesComponent.native.js +6 -5
  67. package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
  68. package/lib/module/specs/ShadowRegistry/index.js +5 -0
  69. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  70. package/lib/module/web/convert/index.js +14 -9
  71. package/lib/module/web/convert/index.js.map +1 -1
  72. package/lib/module/web/convert/object/boxShadow.js +53 -0
  73. package/lib/module/web/convert/object/boxShadow.js.map +1 -0
  74. package/lib/module/web/convert/object/filter.js +37 -0
  75. package/lib/module/web/convert/object/filter.js.map +1 -0
  76. package/lib/module/web/convert/object/index.js +6 -0
  77. package/lib/module/web/convert/object/index.js.map +1 -0
  78. package/lib/module/web/convert/object/objectStyle.js +50 -0
  79. package/lib/module/web/convert/object/objectStyle.js.map +1 -0
  80. package/lib/module/web/convert/object/transform.js +22 -0
  81. package/lib/module/web/convert/object/transform.js.map +1 -0
  82. package/lib/module/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
  83. package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
  84. package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
  85. package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  86. package/lib/module/web/convert/shadow/index.js +5 -0
  87. package/lib/module/web/convert/shadow/index.js.map +1 -0
  88. package/lib/module/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
  89. package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
  90. package/lib/module/web/convert/utils.js +4 -2
  91. package/lib/module/web/convert/utils.js.map +1 -1
  92. package/lib/module/web/listener.js +10 -0
  93. package/lib/module/web/listener.js.map +1 -1
  94. package/lib/module/web/registry.js +14 -27
  95. package/lib/module/web/registry.js.map +1 -1
  96. package/lib/module/web/runtime.js +3 -0
  97. package/lib/module/web/runtime.js.map +1 -1
  98. package/lib/module/web/shadowRegistry.js +80 -40
  99. package/lib/module/web/shadowRegistry.js.map +1 -1
  100. package/lib/module/web/utils/common.js +1 -31
  101. package/lib/module/web/utils/common.js.map +1 -1
  102. package/lib/module/web/utils/unistyle.js +4 -1
  103. package/lib/module/web/utils/unistyle.js.map +1 -1
  104. package/lib/typescript/src/components/useMedia.web.d.ts +6 -0
  105. package/lib/typescript/src/components/useMedia.web.d.ts.map +1 -0
  106. package/lib/typescript/src/core/createUnistylesComponent.d.ts +4 -3
  107. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
  108. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +4 -3
  109. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
  110. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  111. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +3 -0
  112. package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
  113. package/lib/typescript/src/types/common.d.ts +1 -0
  114. package/lib/typescript/src/types/common.d.ts.map +1 -1
  115. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  116. package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
  117. package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
  118. package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
  119. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
  120. package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
  121. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
  122. package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
  123. package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
  124. package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
  125. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
  126. package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
  127. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
  128. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
  129. package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
  130. package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
  131. package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
  132. package/lib/typescript/src/web/convert/types.d.ts +7 -1
  133. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  134. package/lib/typescript/src/web/convert/utils.d.ts +8 -4
  135. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  136. package/lib/typescript/src/web/create.d.ts +8 -8
  137. package/lib/typescript/src/web/index.d.ts +8 -8
  138. package/lib/typescript/src/web/listener.d.ts +2 -0
  139. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  140. package/lib/typescript/src/web/registry.d.ts +5 -9
  141. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  142. package/lib/typescript/src/web/runtime.d.ts +1 -0
  143. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  144. package/lib/typescript/src/web/shadowRegistry.d.ts +4 -1
  145. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  146. package/lib/typescript/src/web/utils/common.d.ts +1 -6
  147. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  148. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  149. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -0
  150. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
  151. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void.kt +1 -0
  152. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency_.kt +1 -0
  153. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
  154. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +1 -0
  155. package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
  156. package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
  157. package/package.json +3 -3
  158. package/src/components/useMedia.ts +1 -1
  159. package/src/components/useMedia.web.ts +47 -0
  160. package/src/core/createUnistylesComponent.native.tsx +12 -10
  161. package/src/core/createUnistylesComponent.tsx +72 -6
  162. package/src/specs/ShadowRegistry/index.ts +5 -0
  163. package/src/specs/ShadowRegistry/types.ts +4 -1
  164. package/src/types/common.ts +1 -0
  165. package/src/web/convert/index.ts +16 -9
  166. package/src/web/convert/object/boxShadow.ts +54 -0
  167. package/src/web/convert/object/filter.ts +39 -0
  168. package/src/web/convert/object/index.ts +3 -0
  169. package/src/web/convert/object/objectStyle.ts +68 -0
  170. package/src/web/convert/object/transform.ts +24 -0
  171. package/src/web/convert/{boxShadow.ts → shadow/boxShadow.ts} +9 -30
  172. package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
  173. package/src/web/convert/shadow/index.ts +2 -0
  174. package/src/web/convert/{textShadow.ts → shadow/textShadow.ts} +9 -29
  175. package/src/web/convert/types.ts +8 -1
  176. package/src/web/convert/utils.ts +11 -5
  177. package/src/web/listener.ts +10 -0
  178. package/src/web/registry.ts +10 -31
  179. package/src/web/runtime.ts +4 -0
  180. package/src/web/shadowRegistry.ts +85 -46
  181. package/src/web/utils/common.ts +1 -37
  182. package/src/web/utils/unistyle.ts +5 -1
  183. package/android/src/main/cxx/helpers.cpp +0 -105
  184. package/android/src/main/cxx/helpers.h +0 -16
  185. package/android/src/main/cxx/platform.cpp +0 -170
  186. package/android/src/main/cxx/platform.h +0 -20
  187. package/lib/commonjs/web/convert/boxShadow.js.map +0 -1
  188. package/lib/commonjs/web/convert/shadow.js +0 -68
  189. package/lib/commonjs/web/convert/shadow.js.map +0 -1
  190. package/lib/commonjs/web/convert/textShadow.js.map +0 -1
  191. package/lib/commonjs/web/convert/transform.js +0 -72
  192. package/lib/commonjs/web/convert/transform.js.map +0 -1
  193. package/lib/module/web/convert/boxShadow.js.map +0 -1
  194. package/lib/module/web/convert/shadow.js +0 -63
  195. package/lib/module/web/convert/shadow.js.map +0 -1
  196. package/lib/module/web/convert/textShadow.js.map +0 -1
  197. package/lib/module/web/convert/transform.js +0 -67
  198. package/lib/module/web/convert/transform.js.map +0 -1
  199. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +0 -1
  200. package/lib/typescript/src/web/convert/shadow.d.ts +0 -2
  201. package/lib/typescript/src/web/convert/shadow.d.ts.map +0 -1
  202. package/lib/typescript/src/web/convert/textShadow.d.ts.map +0 -1
  203. package/lib/typescript/src/web/convert/transform.d.ts +0 -4
  204. package/lib/typescript/src/web/convert/transform.d.ts.map +0 -1
  205. package/src/web/convert/shadow.ts +0 -68
  206. package/src/web/convert/transform.ts +0 -88
  207. /package/lib/typescript/src/web/convert/{boxShadow.d.ts → shadow/boxShadow.d.ts} +0 -0
  208. /package/lib/typescript/src/web/convert/{textShadow.d.ts → shadow/textShadow.d.ts} +0 -0
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getTransformStyle = void 0;
7
+ var _objectStyle = require("./objectStyle");
8
+ var _utils = require("../utils");
9
+ const normalizeTransform = (key, value) => {
10
+ if (key.includes('scale')) {
11
+ return value;
12
+ }
13
+ if (typeof value === 'number') {
14
+ return (0, _utils.normalizeNumericValue)(value);
15
+ }
16
+ return value;
17
+ };
18
+ const getTransformStyle = transforms => (0, _objectStyle.getObjectStyle)(transforms, 'transform', (key, value) => {
19
+ switch (key) {
20
+ case 'matrix':
21
+ return `${key}(${value.join(',')})`;
22
+ default:
23
+ return `${key}(${normalizeTransform(key, value)})`;
24
+ }
25
+ });
26
+ exports.getTransformStyle = getTransformStyle;
27
+ //# sourceMappingURL=transform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_objectStyle","require","_utils","normalizeTransform","key","value","includes","normalizeNumericValue","getTransformStyle","transforms","getObjectStyle","join","exports"],"sourceRoot":"../../../../../src","sources":["web/convert/object/transform.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAGA,MAAME,kBAAkB,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAAK;EACpD,IAAID,GAAG,CAACE,QAAQ,CAAC,OAAO,CAAC,EAAE;IACvB,OAAOD,KAAK;EAChB;EAEA,IAAI,OAAOA,KAAK,KAAK,QAAQ,EAAE;IAC3B,OAAO,IAAAE,4BAAqB,EAACF,KAAK,CAAC;EACvC;EAEA,OAAOA,KAAK;AAChB,CAAC;AAEM,MAAMG,iBAAiB,GAAIC,UAAkC,IAAK,IAAAC,2BAAc,EAACD,UAAU,EAAE,WAAW,EAAE,CAACL,GAAG,EAAEC,KAAK,KAAK;EAC7H,QAAOD,GAAG;IACN,KAAK,QAAQ;MACT,OAAO,GAAGA,GAAG,IAAKC,KAAK,CAAmBM,IAAI,CAAC,GAAG,CAAC,GAAG;IAC1D;MACI,OAAO,GAAGP,GAAG,IAAID,kBAAkB,CAACC,GAAG,EAAEC,KAAK,CAAC,GAAG;EAC1D;AACJ,CAAC,CAAC;AAAAO,OAAA,CAAAJ,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -4,40 +4,25 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getBoxShadowStyle = void 0;
7
- var _utils = require("../utils");
8
- var _shadow = require("./shadow");
9
- var _types = require("./types");
10
- var _utils2 = require("./utils");
7
+ var _utils = require("../../utils");
8
+ var _types = require("../types");
9
+ var _utils2 = require("../utils");
10
+ var _getShadowBreakpoints = require("./getShadowBreakpoints");
11
11
  const createBoxShadowValue = style => {
12
- // at this point every prop is present
13
12
  const {
14
13
  shadowColor,
15
14
  shadowOffset,
16
15
  shadowOpacity,
17
16
  shadowRadius
18
17
  } = style;
19
- const offsetX = (0, _utils2.normalizeNumericValue)(shadowOffset.width);
20
- const offsetY = (0, _utils2.normalizeNumericValue)(shadowOffset.height);
21
- const radius = (0, _utils2.normalizeNumericValue)(shadowRadius);
22
- const color = (0, _utils2.normalizeColor)(shadowColor, shadowOpacity);
18
+ const offsetX = (0, _utils2.normalizeNumericValue)(shadowOffset?.width ?? 0);
19
+ const offsetY = (0, _utils2.normalizeNumericValue)(shadowOffset?.height ?? 0);
20
+ const radius = (0, _utils2.normalizeNumericValue)(shadowRadius ?? 0);
21
+ const color = (0, _utils2.normalizeColor)(shadowColor ?? '#000000', shadowOpacity ?? 1);
23
22
  return `${offsetX} ${offsetY} ${radius} ${color}`;
24
23
  };
25
24
  const getBoxShadowStyle = styles => {
26
- const missingStyles = _types.BOX_SHADOW_STYLES.filter(key => !(key in styles));
27
- if (missingStyles.length) {
28
- (0, _utils.warn)(`can't apply box shadow as you miss these properties: ${missingStyles.join(', ')}`);
29
- return {};
30
- }
31
- const breakpointsSet = new Set();
32
- try {
33
- (0, _shadow.validateShadow)(_types.BOX_SHADOW_STYLES, styles, breakpointsSet);
34
- } catch (error) {
35
- if (typeof error === 'string') {
36
- (0, _utils.warn)(error);
37
- }
38
- return {};
39
- }
40
- const breakpoints = Array.from(breakpointsSet);
25
+ const breakpoints = (0, _getShadowBreakpoints.getShadowBreakpoints)(_types.BOX_SHADOW_STYLES, styles);
41
26
 
42
27
  // If no breakpoints were used return styles without media queries
43
28
  if (breakpoints.length === 0) {
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","_types","_utils2","_getShadowBreakpoints","createBoxShadowValue","style","shadowColor","shadowOffset","shadowOpacity","shadowRadius","offsetX","normalizeNumericValue","width","offsetY","height","radius","color","normalizeColor","getBoxShadowStyle","styles","breakpoints","getShadowBreakpoints","BOX_SHADOW_STYLES","length","boxShadow","breakpointStyles","map","breakpoint","extractShadowValue","opacity","deepMergeObjects","exports"],"sourceRoot":"../../../../../src","sources":["web/convert/shadow/boxShadow.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAA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rE,MAAMU,OAAO,GAAG,IAAAD,0BAAkB,EAAC,eAAe,EAAED,UAAU,EAAER,MAAM,CAAC;IAEvE,OAAO;MACH,CAACQ,UAAU,GAAG;QACVH,SAAS,EAAEpB,oBAAoB,CAAC;UAC5BE,WAAW,EAAEU,KAAK;UAClBT,YAAY,EAAE;YACVK,KAAK;YACLE;UACJ,CAAC;UACDL,YAAY,EAAEM,MAAM;UACpBP,aAAa,EAAEqB;QACnB,CAAC;MACL;IACJ,CAAC;EACL,CAAC,CAAC;;EAEF;EACA,OAAO,IAAAC,uBAAgB,EAAC,GAAGL,gBAAgB,CAAC;AAChD,CAAC;AAAAM,OAAA,CAAAb,iBAAA,GAAAA,iBAAA","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getShadowBreakpoints = void 0;
7
+ const getShadowBreakpoints = (shadowProperties, styles) => {
8
+ const breakpoints = new Set();
9
+ shadowProperties.forEach(key => {
10
+ const value = styles[key];
11
+ if (typeof value !== 'object') {
12
+ return;
13
+ }
14
+ if (key === 'shadowOffset' || key === 'textShadowOffset') {
15
+ const {
16
+ width,
17
+ height
18
+ } = value;
19
+
20
+ // If shadowOffset.width has breakpoints
21
+ if (typeof width === 'object') {
22
+ Object.keys(width).forEach(breakpoint => breakpoints.add(breakpoint));
23
+ }
24
+
25
+ // If shadowOffset.height has breakpoints
26
+ if (typeof height === 'object') {
27
+ Object.keys(height).forEach(breakpoint => breakpoints.add(breakpoint));
28
+ }
29
+ return;
30
+ }
31
+
32
+ // Collect regular breakpoints
33
+ Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint));
34
+ });
35
+ return Array.from(breakpoints);
36
+ };
37
+ exports.getShadowBreakpoints = getShadowBreakpoints;
38
+ //# sourceMappingURL=getShadowBreakpoints.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["getShadowBreakpoints","shadowProperties","styles","breakpoints","Set","forEach","key","value","width","height","Object","keys","breakpoint","add","Array","from","exports"],"sourceRoot":"../../../../../src","sources":["web/convert/shadow/getShadowBreakpoints.ts"],"mappings":";;;;;;AAEO,MAAMA,oBAAoB,GAAGA,CAACC,gBAAuC,EAAEC,MAA2B,KAAK;EAC1G,MAAMC,WAAW,GAAG,IAAIC,GAAG,CAAS,CAAC;EAErCH,gBAAgB,CAACI,OAAO,CAACC,GAAG,IAAI;IAC5B,MAAMC,KAAK,GAAGL,MAAM,CAACI,GAAG,CAAC;IAEzB,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;MAC3B;IACJ;IAEA,IAAID,GAAG,KAAK,cAAc,IAAIA,GAAG,KAAK,kBAAkB,EAAE;MACtD,MAAM;QAAEE,KAAK;QAAEC;MAAO,CAAC,GAAGF,KAAqB;;MAE/C;MACA,IAAI,OAAOC,KAAK,KAAK,QAAQ,EAAE;QAC3BE,MAAM,CAACC,IAAI,CAACH,KAAK,CAAC,CAACH,OAAO,CAACO,UAAU,IAAIT,WAAW,CAACU,GAAG,CAACD,UAAU,CAAC,CAAC;MACzE;;MAEA;MACA,IAAI,OAAOH,MAAM,KAAK,QAAQ,EAAE;QAC5BC,MAAM,CAACC,IAAI,CAACF,MAAM,CAAC,CAACJ,OAAO,CAACO,UAAU,IAAIT,WAAW,CAACU,GAAG,CAACD,UAAU,CAAC,CAAC;MAC1E;MAEA;IACJ;;IAEA;IACAF,MAAM,CAACC,IAAI,CAACJ,KAAK,CAAC,CAACF,OAAO,CAACO,UAAU,IAAIT,WAAW,CAACU,GAAG,CAACD,UAAU,CAAC,CAAC;EACzE,CAAC,CAAC;EAEF,OAAOE,KAAK,CAACC,IAAI,CAACZ,WAAW,CAAC;AAClC,CAAC;AAAAa,OAAA,CAAAhB,oBAAA,GAAAA,oBAAA","ignoreList":[]}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _boxShadow = require("./boxShadow");
7
+ Object.keys(_boxShadow).forEach(function (key) {
8
+ if (key === "default" || key === "__esModule") return;
9
+ if (key in exports && exports[key] === _boxShadow[key]) return;
10
+ Object.defineProperty(exports, key, {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _boxShadow[key];
14
+ }
15
+ });
16
+ });
17
+ var _textShadow = require("./textShadow");
18
+ Object.keys(_textShadow).forEach(function (key) {
19
+ if (key === "default" || key === "__esModule") return;
20
+ if (key in exports && exports[key] === _textShadow[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _textShadow[key];
25
+ }
26
+ });
27
+ });
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_boxShadow","require","Object","keys","forEach","key","exports","defineProperty","enumerable","get","_textShadow"],"sourceRoot":"../../../../../src","sources":["web/convert/shadow/index.ts"],"mappings":";;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,UAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAL,UAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAT,UAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAK,WAAA,GAAAT,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAO,WAAA,EAAAN,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAA,GAAA,IAAAC,OAAA,IAAAA,OAAA,CAAAD,GAAA,MAAAK,WAAA,CAAAL,GAAA;EAAAH,MAAA,CAAAK,cAAA,CAAAD,OAAA,EAAAD,GAAA;IAAAG,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAC,WAAA,CAAAL,GAAA;IAAA;EAAA;AAAA","ignoreList":[]}
@@ -4,38 +4,24 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getTextShadowStyle = void 0;
7
- var _utils = require("../utils");
8
- var _shadow = require("./shadow");
9
- var _types = require("./types");
10
- var _utils2 = require("./utils");
7
+ var _utils = require("../../utils");
8
+ var _types = require("../types");
9
+ var _utils2 = require("../utils");
10
+ var _getShadowBreakpoints = require("./getShadowBreakpoints");
11
11
  const createTextShadowValue = style => {
12
12
  const {
13
13
  textShadowColor,
14
14
  textShadowOffset,
15
15
  textShadowRadius
16
16
  } = style;
17
- const offsetX = (0, _utils2.normalizeNumericValue)(textShadowOffset.width);
18
- const offsetY = (0, _utils2.normalizeNumericValue)(textShadowOffset.height);
19
- const radius = (0, _utils2.normalizeNumericValue)(textShadowRadius);
20
- const color = (0, _utils2.normalizeColor)(textShadowColor);
17
+ const offsetX = (0, _utils2.normalizeNumericValue)(textShadowOffset?.width ?? 0);
18
+ const offsetY = (0, _utils2.normalizeNumericValue)(textShadowOffset?.height ?? 0);
19
+ const radius = (0, _utils2.normalizeNumericValue)(textShadowRadius ?? 0);
20
+ const color = (0, _utils2.normalizeColor)(textShadowColor ?? '#000000');
21
21
  return `${offsetX} ${offsetY} ${radius} ${color}`;
22
22
  };
23
23
  const getTextShadowStyle = styles => {
24
- const missingStyles = _types.TEXT_SHADOW_STYLES.filter(key => !(key in styles));
25
- if (missingStyles.length) {
26
- (0, _utils.warn)(`can't apply text shadow as you miss these properties: ${missingStyles.join(', ')}`);
27
- return {};
28
- }
29
- const breakpointsSet = new Set();
30
- try {
31
- (0, _shadow.validateShadow)(_types.TEXT_SHADOW_STYLES, styles, breakpointsSet);
32
- } catch (error) {
33
- if (typeof error === 'string') {
34
- (0, _utils.warn)(error);
35
- }
36
- return {};
37
- }
38
- const breakpoints = Array.from(breakpointsSet);
24
+ const breakpoints = (0, _getShadowBreakpoints.getShadowBreakpoints)(_types.TEXT_SHADOW_STYLES, styles);
39
25
 
40
26
  // If no breakpoints were used return styles without media queries
41
27
  if (breakpoints.length === 0) {
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_utils","require","_types","_utils2","_getShadowBreakpoints","createTextShadowValue","style","textShadowColor","textShadowOffset","textShadowRadius","offsetX","normalizeNumericValue","width","offsetY","height","radius","color","normalizeColor","getTextShadowStyle","styles","breakpoints","getShadowBreakpoints","TEXT_SHADOW_STYLES","length","textShadow","breakpointStyles","map","breakpoint","extractShadowValue","deepMergeObjects","exports"],"sourceRoot":"../../../../../src","sources":["web/convert/shadow/textShadow.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,qBAAA,GAAAH,OAAA;AAEA,MAAMI,qBAAqB,GAAIC,KAAiB,IAAK;EACjD,MAAM;IAAEC,eAAe;IAAEC,gBAAgB;IAAEC;EAAiB,CAAC,GAAGH,KAAK;EACrE,MAAMI,OAAO,GAAG,IAAAC,6BAAqB,EAACH,gBAAgB,EAAEI,KAAK,IAAI,CAAC,CAAC;EACnE,MAAMC,OAAO,GAAG,IAAAF,6BAAqB,EAACH,gBAAgB,EAAEM,MAAM,IAAI,CAAC,CAAC;EACpE,MAAMC,MAAM,GAAG,IAAAJ,6BAAqB,EAACF,gBAAgB,IAAI,CAAC,CAAC;EAC3D,MAAMO,KAAK,GAAG,IAAAC,sBAAc,EAAEV,eAAe,IAAI,SAAoB,CAAC;EAEtE,OAAO,GAAGG,OAAO,IAAIG,OAAO,IAAIE,MAAM,IAAIC,KAAK,EAAE;AACrD,CAAC;AAEM,MAAME,kBAAkB,GAAIC,MAA2B,IAAK;EAC/D,MAAMC,WAAW,GAAG,IAAAC,0CAAoB,EAACC,yBAAkB,EAAEH,MAAM,CAAC;;EAEpE;EACA,IAAIC,WAAW,CAACG,MAAM,KAAK,CAAC,EAAE;IAC1B,OAAO;MACHC,UAAU,EAAEnB,qBAAqB,CAACc,MAAoB;IAC1D,CAAC;EACL;;EAEA;EACA,MAAMM,gBAAgB,GAAGL,WAAW,CAACM,GAAG,CAACC,UAAU,IAAI;IACnD,MAAMX,KAAK,GAAG,IAAAY,0BAAkB,EAAC,iBAAiB,EAAED,UAAU,EAAER,MAAM,CAAC;IACvE,MAAM;MAAEP,KAAK;MAAEE;IAAO,CAAC,GAAG,IAAAc,0BAAkB,EAAC,kBAAkB,EAAED,UAAU,EAAER,MAAM,CAAC;IACpF,MAAMJ,MAAM,GAAG,IAAAa,0BAAkB,EAAC,kBAAkB,EAAED,UAAU,EAAER,MAAM,CAAC;IAEzE,OAAO;MACH,CAACQ,UAAU,GAAG;QACVH,UAAU,EAAEnB,qBAAqB,CAAC;UAC9BE,eAAe,EAAES,KAAK;UACtBR,gBAAgB,EAAE;YACdI,KAAK;YACLE;UACJ,CAAC;UACDL,gBAAgB,EAAEM;QACtB,CAAC;MACL;IACJ,CAAC;EACL,CAAC,CAAC;;EAEF;EACA,OAAO,IAAAc,uBAAgB,EAAC,GAAGJ,gBAAgB,CAAC;AAChD,CAAC;AAAAK,OAAA,CAAAZ,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.normalizeNumericValue = exports.normalizeColor = exports.isTransform = exports.isTextShadow = exports.isBoxShadow = exports.extractShadowValue = void 0;
6
+ exports.normalizeNumericValue = exports.normalizeColor = exports.isTransform = exports.isTextShadow = exports.isShadow = exports.isFilter = exports.isBoxShadow = exports.extractShadowValue = void 0;
7
7
  var _normalizeColors = _interopRequireDefault(require("@react-native/normalize-colors"));
8
8
  var _types = require("./types");
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -14,9 +14,13 @@ const isTransform = (key, value) => key === 'transform' && Array.isArray(value);
14
14
  exports.isTransform = isTransform;
15
15
  const isTextShadow = key => _types.TEXT_SHADOW_STYLES.includes(key);
16
16
  exports.isTextShadow = isTextShadow;
17
- const isBoxShadow = key => _types.BOX_SHADOW_STYLES.includes(key);
17
+ const isShadow = key => _types.BOX_SHADOW_STYLES.includes(key);
18
+ exports.isShadow = isShadow;
19
+ const isFilter = (key, value) => key === 'filter' && Array.isArray(value);
20
+ exports.isFilter = isFilter;
21
+ const isBoxShadow = (key, value) => key === 'boxShadow' && Array.isArray(value);
18
22
  exports.isBoxShadow = isBoxShadow;
19
- const normalizeNumericValue = value => value ? `${value}px` : value;
23
+ const normalizeNumericValue = value => value && typeof value === 'number' ? `${value}px` : value;
20
24
  exports.normalizeNumericValue = normalizeNumericValue;
21
25
  const normalizeColor = (color, opacity = 1) => {
22
26
  // If the opacity is 1 there's no need to normalize the color
@@ -1 +1 @@
1
- {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","_types","e","__esModule","default","isTransform","key","value","Array","isArray","exports","isTextShadow","TEXT_SHADOW_STYLES","includes","isBoxShadow","BOX_SHADOW_STYLES","normalizeNumericValue","normalizeColor","color","opacity","integer","normalizeColors","hex","toString","padStart","length","r","g","b","a","split","map","x","parseInt","filter","num","isNaN","extractShadowValue","breakpoint","styles","width","height"],"sourceRoot":"../../../../src","sources":["web/convert/utils.ts"],"mappings":";;;;;;AAEA,IAAAA,gBAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAmG,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAHnG;AACA;;AAIO,MAAMG,WAAW,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAA0CD,GAAG,KAAK,WAAW,IAAIE,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC;AAAAG,OAAA,CAAAL,WAAA,GAAAA,WAAA;AAEjI,MAAMM,YAAY,GAAIL,GAAW,IAAKM,yBAAk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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":[]}
1
+ {"version":3,"names":["_normalizeColors","_interopRequireDefault","require","_types","e","__esModule","default","isTransform","key","value","Array","isArray","exports","isTextShadow","TEXT_SHADOW_STYLES","includes","isShadow","BOX_SHADOW_STYLES","isFilter","isBoxShadow","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;AAAiH,SAAAD,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAHjH;AACA;;AAMO,MAAMG,WAAW,GAAGA,CAACC,GAAW,EAAEC,KAAU,KAAsCD,GAAG,KAAK,WAAW,IAAIE,KAAK,CAACC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,CAACC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,EAAEC,CAAC,GAAG,CAAC,CAAC,GAAGP,GAAG,CACnCQ,KAAK,CAAC,cAAc,CAAC,CACrBC,GAAG,CAACC,CAAC,IAAIC,QAAQ,CAACD,CAAC,EAAE,EAAE,CAAC,CAAC,CACzBE,MAAM,CAACC,GAAG,IAAI,CAACC,KAAK,CAACD,GAAG,CAAC,CAAC;IAE/B,OAAO,QAAQT,CAAC,IAAIC,CAAC,IAAIC,CAAC,IAAKC,CAAC,GAAG,GAAG,GAAIV,OAAO,GAAG;EACxD;EAEA,OAAOD,KAAK;AAChB,CAAC;AAAAV,OAAA,CAAAS,cAAA,GAAAA,cAAA;AAEM,MAAMoB,kBAAkB,GAAGA,CAA6BjC,GAAS,EAAEkC,UAAkB,EAAEC,MAAW,KAAsB;EAC3H,MAAMlC,KAAK,GAAGkC,MAAM,CAACnC,GAAG,CAAC;EAEzB,IAAIA,GAAG,KAAK,kBAAkB,IAAIA,GAAG,KAAK,cAAc,EAAE;IACtD,MAAM;MAAEoC,KAAK;MAAEC;IAAO,CAAC,GAAGpC,KAAK;IAE/B,OAAO;MACHmC,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,OAAOpC,KAAK,KAAK,QAAQ,GAAGA,KAAK,CAACiC,UAAU,CAAC,GAAGjC,KAAK;AAChE,CAAC;AAAAG,OAAA,CAAA6B,kBAAA,GAAAA,kBAAA","ignoreList":[]}
@@ -11,7 +11,11 @@ class UnistylesListenerBuilder {
11
11
  listeners = Array.from({
12
12
  length: Object.keys(_NativePlatform.UnistyleDependency).length / 2
13
13
  }, () => new Set());
14
+ stylesheetListeners = Array.from({
15
+ length: Object.keys(_NativePlatform.UnistyleDependency).length / 2
16
+ }, () => new Set());
14
17
  emitChange = dependency => {
18
+ this.stylesheetListeners[dependency]?.forEach(listener => listener());
15
19
  this.listeners[dependency]?.forEach(listener => listener());
16
20
  };
17
21
  initListeners = () => {
@@ -30,6 +34,12 @@ class UnistylesListenerBuilder {
30
34
  dependencies.forEach(dependency => this.listeners[dependency]?.delete(listener));
31
35
  };
32
36
  };
37
+ addStylesheetListeners = (dependencies, listener) => {
38
+ dependencies.forEach(dependency => this.stylesheetListeners[dependency]?.add(listener));
39
+ return () => {
40
+ dependencies.forEach(dependency => this.stylesheetListeners[dependency]?.delete(listener));
41
+ };
42
+ };
33
43
  }
34
44
  const UnistylesListener = exports.UnistylesListener = new UnistylesListenerBuilder();
35
45
  //# sourceMappingURL=listener.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","UnistylesListener","exports"],"sourceRoot":"../../../src","sources":["web/listener.ts"],"mappings":";;;;;;AAAA,IAAAA,eAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEA,MAAME,wBAAwB,CAAC;EACnBC,aAAa,GAAG,KAAK;EACrBC,SAAS,GAAGC,KAAK,CAACC,IAAI,CAAC;IAAEC,MAAM,EAAEC,MAAM,CAACC,IAAI,CAACC,kCAAkB,CAAC,CAACH,MAAM,GAAG;EAAE,CAAC,EAAE,MAAM,IAAII,GAAG,CAAe,CAAC,CAAC;EAErHC,UAAU,GAAIC,UAA8B,IAAK;IAC7C,IAAI,CAACT,SAAS,CAACS,UAAU,CAAC,EAAEC,OAAO,CAACC,QAAQ,IAAIA,QAAQ,CAAC,CAAC,CAAC;EAC/D,CAAC;EAEDC,aAAa,GAAGA,CAAA,KAAM;IAClB,IAAI,IAAI,CAACb,aAAa,EAAE;MACpB;IACJ;IAEA,IAAI,CAACA,aAAa,GAAG,IAAI;IACzBc,yBAAgB,CAACC,SAAS,EAAEC,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,kCAAkB,CAACU,WAAW,CAAC,CAAC;IAC7GH,yBAAgB,CAACI,UAAU,EAAEF,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACF,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;AAEO,MAAMc,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAI3B,wBAAwB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_NativePlatform","require","_runtime","UnistylesListenerBuilder","isInitialized","listeners","Array","from","length","Object","keys","UnistyleDependency","Set","stylesheetListeners","emitChange","dependency","forEach","listener","initListeners","UnistylesRuntime","darkMedia","addEventListener","ColorScheme","lightMedia","window","Orientation","Dimensions","addListeners","dependencies","add","delete","addStyl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AU,CAACH,kCAAkB,CAACc,WAAW,CAAC,CAAC;IACnGD,MAAM,CAACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,IAAI,CAACP,UAAU,CAACH,kCAAkB,CAACe,UAAU,CAAC,CAAC;EAC3F,CAAC;EAEDC,YAAY,GAAGA,CAACC,YAAuC,EAAEX,QAAsB,KAAK;IAChFW,YAAY,CAACZ,OAAO,CAACD,UAAU,IAAI,IAAI,CAACV,SAAS,CAACU,UAAU,CAAC,EAAEc,GAAG,CAACZ,QAAQ,CAAC,CAAC;IAE7E,OAAO,MAAM;MACTW,YAAY,CAACZ,OAAO,CAACD,UAAU,IAAI,IAAI,CAACV,SAAS,CAACU,UAAU,CAAC,EAAEe,MAAM,CAACb,QAAQ,CAAC,CAAC;IACpF,CAAC;EACL,CAAC;EAEDc,sBAAsB,GAAGA,CAACH,YAAuC,EAAEX,QAAsB,KAAK;IAC1FW,YAAY,CAACZ,OAAO,CAACD,UAAU,IAAI,IAAI,CAACF,mBAAmB,CAACE,UAAU,CAAC,EAAEc,GAAG,CAACZ,QAAQ,CAAC,CAAC;IAEvF,OAAO,MAAM;MACTW,YAAY,CAACZ,OAAO,CAACD,UAAU,IAAI,IAAI,CAACF,mBAAmB,CAACE,UAAU,CAAC,EAAEe,MAAM,CAACb,QAAQ,CAAC,CAAC;IAC9F,CAAC;EACL,CAAC;AACL;AAEO,MAAMe,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAI7B,wBAAwB,CAAC,CAAC","ignoreList":[]}
@@ -8,7 +8,6 @@ var _runtime = require("./runtime");
8
8
  var _utils = require("./utils");
9
9
  var _listener = require("./listener");
10
10
  var _convert = require("./convert");
11
- var _variants = require("./variants");
12
11
  class UnistylesRegistryBuilder {
13
12
  stylesheets = new Map();
14
13
  stylesCounter = new Map();
@@ -44,46 +43,31 @@ class UnistylesRegistryBuilder {
44
43
  this.disposeListenersMap.get(stylesheet)?.();
45
44
  const dependenciesMap = this.dependenciesMap.get(stylesheet) ?? new Set(dependencies);
46
45
  dependencies.forEach(dependency => dependenciesMap.add(dependency));
47
- const dispose = _listener.UnistylesListener.addListeners(Array.from(dependenciesMap), () => {
46
+ const dispose = _listener.UnistylesListener.addStylesheetListeners(Array.from(dependenciesMap), () => {
48
47
  const newComputedStylesheet = stylesheet(_runtime.UnistylesRuntime.theme, _runtime.UnistylesRuntime.miniRuntime);
49
48
  this.stylesheets.set(stylesheet, newComputedStylesheet);
50
49
  });
51
50
  this.dependenciesMap.set(stylesheet, dependenciesMap);
52
51
  this.disposeListenersMap.set(stylesheet, dispose);
53
52
  };
54
- add = ({
55
- key,
56
- value,
57
- stylesheet,
58
- args,
59
- variants
60
- }) => {
53
+ add = value => {
61
54
  const hash = (0, _utils.generateHash)(value);
62
55
  const existingCounter = this.stylesCounter.get(hash);
63
56
  if (!existingCounter || existingCounter.size === 0) {
64
57
  const counter = new Set();
65
- const dependencies = (0, _utils.extractUnistyleDependencies)(value);
66
58
  counter.add(value);
67
59
  this.stylesCounter.set(hash, counter);
68
60
  this.applyStyles(hash, (0, _convert.convertUnistyles)(value));
69
- _listener.UnistylesListener.addListeners(dependencies, async () => {
70
- // Move this callback to the end of the event loop
71
- await Promise.resolve();
72
- const newComputedStyleSheet = this.getComputedStylesheet(stylesheet);
73
- const newValue = newComputedStyleSheet[key];
74
- const result = typeof newValue === 'function' ? newValue(...args) : newValue;
75
- const {
76
- variantsResult
77
- } = Object.fromEntries((0, _variants.getVariants)({
78
- variantsResult: result
79
- }, variants));
80
- const resultWithVariants = (0, _utils.deepMergeObjects)(result, variantsResult ?? {});
81
- this.applyStyles(hash, (0, _convert.convertUnistyles)(resultWithVariants));
82
- });
83
- return hash;
61
+ return {
62
+ hash,
63
+ existingHash: false
64
+ };
84
65
  }
85
66
  existingCounter.add(value);
86
- return hash;
67
+ return {
68
+ hash,
69
+ existingHash: true
70
+ };
87
71
  };
88
72
  applyStyles = (hash, styles) => {
89
73
  Object.entries(styles).forEach(([key, value]) => {
@@ -177,6 +161,9 @@ class UnistylesRegistryBuilder {
177
161
  existingStyles.delete(value);
178
162
  if (existingStyles.size === 0) {
179
163
  const ruleIndex = Array.from(this.styleTag.sheet?.cssRules ?? []).findIndex(rule => rule.cssText.includes(`.${hash}`));
164
+ if (ruleIndex === -1) {
165
+ return;
166
+ }
180
167
  this.styleTag.sheet?.deleteRule(ruleIndex);
181
168
  }
182
169
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_runtime","require","_utils","_listener","_convert","_variants","UnistylesRegistryBuilder","stylesheets","Map","stylesCounter","styleTag","disposeListenersMap","dependenciesMap","tag","newTag","document","createElement","id","head","appendChild","getComputedStylesheet","stylesheet","computedStylesheet","get","createdStylesheet","UnistylesRuntime","theme","miniRuntime","dependencies","Object","values","flatMap","value","extractUnistyleDependencies","addDependenciesToStylesheet","set","Set","forEach","dependency","add","dispose","UnistylesListener","addListeners","Array","from","newComputedStylesheet","key","args","variants","hash","generateHash","existingCounter","size","counter","applyStyles","convertUnistyles","Promise","resolve","newComputedStyleSheet","newValue","result","variantsResult","fromEntries","getVariants","resultWithVariants","deepMergeObjects","styles","entries","sheet","startsWith","mediaQuery","getMediaQuery","cssRules","queryRule","find","rule","CSSMediaRule","media","item","includes","mediaQueryValue","extractMediaQueryValue","ruleIndex","reduce","acc","ruleMediaQueryValue","conditionText","undefined","length","insertRule","mqKey","mqValue","applyRule","pseudoKey","pseudoValue","replace","CSSStyleRule","selectorText","keyInObject","style","remove","existingStyles","delete","findIndex","cssText","deleteRule","UnistylesRegistry","exports"],"sourceRoot":"../../../src","sources":["web/registry.ts"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAGA,IAAAI,SAAA,GAAAJ,OAAA;AAmBA,MAAMK,wBAAwB,CAAC;EACVC,WAAW,GAAG,IAAIC,GAAG,CAAoD,CAAC;EAC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IAAI,CAAC;IAC9D,CAAC,CAAC,IAAI,IAAI;IAEV,IAAI,CAAC0B,IAAI,EAAE;MACPA,IAAI,GAAGP,KAAK,CAACI,QAAQ,CAACM,IAAI,CAACV,KAAK,CAACqB,UAAU,CAAC,IAAIxC,IAAI,KAAK,CAAC,CAAC;IAC/D;IAEA,IAAI,EAAE0B,IAAI,YAAYqB,YAAY,CAAC,IAAI,CAAC,IAAAE,kBAAW,EAACvB,IAAI,CAACwB,KAAK,EAAErD,GAAG,CAAC,EAAE;MAClE;IACJ;IAEA6B,IAAI,CAACwB,KAAK,CAACrD,GAAG,CAAwC,GAAGd,KAAK;EAClE,CAAC;EAEDoE,MAAM,GAAIpE,KAAsB,IAAK;IACjC,MAAMiB,IAAI,GAAG,IAAAC,mBAAY,EAAClB,KAAK,CAAC;IAChC,MAAMqE,cAAc,GAAG,IAAI,CAAC5F,aAAa,CAACc,GAAG,CAAC0B,IAAI,CAAC;IAEnD,IAAI,CAACoD,cAAc,EAAE;MACjB;IACJ;IAEAA,cAAc,CAACC,MAAM,CAACtE,KAAK,CAAC;IAE5B,IAAIqE,cAAc,CAACjD,IAAI,KAAK,CAAC,EAAE;MAC3B,MAAM8B,SAAS,GAAGvC,KAAK,CAACC,IAAI,CAAC,IAAI,CAAClC,QAAQ,CAAC0D,KAAK,EAAEI,QAAQ,IAAI,EAAE,CAAC,CAAC+B,SAAS,CAAC5B,IAAI,IAAIA,IAAI,CAAC6B,OAAO,CAACzB,QAAQ,CAAC,IAAI9B,IAAI,EAAE,CAAC,CAAC;MAEtH,IAAI,CAACvC,QAAQ,CAAC0D,KAAK,EAAEqC,UAAU,CAACvB,SAAS,CAAC;IAC9C;EACJ,CAAC;AACL;AAEO,MAAMwB,iBAAiB,GAAAC,OAAA,CAAAD,iBAAA,GAAG,IAAIpG,wBAAwB,CAAC,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_runtime","require","_utils","_listener","_convert","UnistylesRegistryBuilder","stylesheets","Map","stylesCounter","styleTag","disposeListenersMap","dependenciesMap","tag","newTag","document","createElement","id","head","appendChild","getComputedStylesheet","stylesheet","computedStylesheet","get","createdStylesheet","UnistylesRuntime","theme","miniRuntime","dependencies","Object","values","flatMap","value","extractUnistyleDependencies","addDependenciesToStylesheet","set","Set","forEach","dependency","add","dispose","UnistylesListener","addStylesheetListeners","Array","from","newComputedStylesheet","hash","generateHash","existingCounter","size","counter","applyStyles","convertUnistyles","existingHash","styles","entries","key","sheet","startsWith","mediaQuery","getMediaQuery","cssRules","queryRule","find","rule","CSSMediaRule","media","item","includes","mediaQueryValue","extractMediaQueryValue","ruleIndex","reduce","acc","ruleMediaQueryValue","conditionText","undefined","length","insertRule","mqKey","mqValue","applyRule","pseudoKey","pseudoValue","replace","CSSStyleRule","selectorText","keyInObject","style","remove","existingStyles","delete","findIndex","cssText","deleteRule","UnistylesRegistry","exports"],"sourceRoot":"../../../src","sources":["web/registry.ts"],"mappings":";;;;;;AAEA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AAaA,MAAMI,wBAAwB,CAAC;EACVC,WAAW,GAAG,IAAIC,GAAG,CAAoD,CAAC;EAC1EC,aAAa,GAAG,IAAID,GAAG,CAA+B,CAAC;EACxE,CAACE,QAAQ,GAA4B,IAAI;EACxBC,mBAAmB,GAAG,IAAIH,GAAG,CAAuB,CAAC;EACrDI,eAAe,GAAG,IAAIJ,GAAG,CAAiE,CAAC;EAE5G,IAAYE,QAAQA,CAAA,EAAG;IACnB,MAAMG,GAAG,GAAG,IAAI,CAAC,CAACH,QAAQ;IAE1B,IAAI,CAACG,GAAG,EAAE;MACN,MAAMC,MAAM,GAAGC,QAAQ,CAACC,aAAa,CAAC,OAAO,CAAC;MAE9CF,MAAM,CAACG,EAAE,GAAG,eAAe;MAC3B,IAAI,CAAC,CAACP,QAAQ,GAAGI,MAAM;MACvBC,QAAQ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AwB,CAAC,CAAC","ignoreList":[]}
@@ -48,6 +48,9 @@ class UnistylesRuntimeBuilder {
48
48
  get contentSizeCategory() {
49
49
  return _types2.WebContentSizeCategory.Unspecified;
50
50
  }
51
+ get breakpoints() {
52
+ return _state.UnistylesState.breakpoints ?? {};
53
+ }
51
54
  get breakpoint() {
52
55
  return _state.UnistylesState.breakpoint;
53
56
  }
@@ -1 +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","getTheme","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","StatusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","NavigationBar","miniRuntime","isLandscape","isPortrait","setTheme","UnistylesRuntime","UnistylesListener","emitChange","UnistyleDependency","Theme","ThemeName","setAdaptiveThemes","isEnabled","schemeToTheme","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","hexToRGBA","setImmersiveMode","updateTheme","updater","oldTheme","themes","get","Error","set","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,CA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AAC,EAAE;MACZ;IACJ;IAEAuC,QAAQ,CAACC,eAAe,CAACqB,KAAK,CAACC,eAAe,GAAGF,KAAK,GAAG,IAAAG,gBAAS,EAACJ,GAAG,EAAEC,KAAK,CAAC,GAAGD,GAAG;EACxF,CAAC;EAEDK,gBAAgB,GAAGA,CAAA,KAAM,CAAC,CAAC;EAE3BC,WAAW,GAAGA,CAACxD,SAAuB,EAAEyD,OAA6C,KAAK;IACtF,MAAMC,QAAQ,GAAGzD,qBAAc,CAAC0D,MAAM,CAACC,GAAG,CAAC5D,SAAS,CAAC;IAErD,IAAI,CAAC0D,QAAQ,EAAE;MACX,MAAM,IAAIG,KAAK,CAAC,aAAa7D,SAAS,sBAAsB,CAAC;IACjE;IAEAC,qBAAc,CAAC0D,MAAM,CAACG,GAAG,CAAC9D,SAAS,EAAEyD,OAAO,CAACC,QAAQ,CAAC,CAAC;EAC3D,CAAC;EAED7C,QAAQ,GAAGA,CAACb,SAAS,GAAG,IAAI,CAACA,SAAS,KAAK;IACvC,IAAI,CAACA,SAAS,EAAE;MACZ,MAAM,IAAI6D,KAAK,CAAC,uBAAuB,CAAC;IAC5C;IAEA,MAAMjD,KAAK,GAAGX,qBAAc,CAAC0D,MAAM,CAACC,GAAG,CAAC5D,SAAS,CAAC;IAElD,IAAI,CAACY,KAAK,EAAE;MACR,MAAM,IAAIiD,KAAK,CAAC,aAAa,IAAI,CAAC7D,SAAS,sBAAsB,CAAC;IACtE;IAEA,OAAOY,KAAK;EAChB,CAAC;AACL;AAEO,MAAM4B,gBAAgB,GAAAuB,OAAA,CAAAvB,gBAAA,GAAG,IAAItD,uBAAuB,CAAC,CAAC","ignoreList":[]}
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","breakpoints","breakpoint","orientation","Orientation","Portrait","screen","type","includes","Landscape","theme","getTheme","pixelRatio","devicePixelRatio","width","height","innerWidth","innerHeight","fontScale","insets","top","bottom","left","right","ime","statusBar","StatusBar","rtl","document","documentElement","dir","hasAdaptiveThemes","navigationBar","NavigationBar","miniRuntime","isLandscape","isPortrait","setTheme","UnistylesRuntime","UnistylesListener","emitChange","UnistyleDependency","Theme","ThemeName","setAdaptiveThemes","isEnabled","schemeToTheme","setRootViewBackgroundColor","hex","alpha","style","backgroundColor","hexToRGBA","setImmersiveMode","updateTheme","updater","oldTheme","themes","get","Error","set","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,CAA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CAAC;IAErD,IAAI,CAAC2D,QAAQ,EAAE;MACX,MAAM,IAAIG,KAAK,CAAC,aAAa9D,SAAS,sBAAsB,CAAC;IACjE;IAEAC,qBAAc,CAAC2D,MAAM,CAACG,GAAG,CAAC/D,SAAS,EAAE0D,OAAO,CAACC,QAAQ,CAAC,CAAC;EAC3D,CAAC;EAED7C,QAAQ,GAAGA,CAACd,SAAS,GAAG,IAAI,CAACA,SAAS,KAAK;IACvC,IAAI,CAACA,SAAS,EAAE;MACZ,MAAM,IAAI8D,KAAK,CAAC,uBAAuB,CAAC;IAC5C;IAEA,MAAMjD,KAAK,GAAGZ,qBAAc,CAAC2D,MAAM,CAACC,GAAG,CAAC7D,SAAS,CAAC;IAElD,IAAI,CAACa,KAAK,EAAE;MACR,MAAM,IAAIiD,KAAK,CAAC,aAAa,IAAI,CAAC9D,SAAS,sBAAsB,CAAC;IACtE;IAEA,OAAOa,KAAK;EAChB,CAAC;AACL;AAEO,MAAM4B,gBAAgB,GAAAuB,OAAA,CAAAvB,gBAAA,GAAG,IAAIvD,uBAAuB,CAAC,CAAC","ignoreList":[]}
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.UnistylesShadowRegistry = void 0;
7
+ var _convert = require("./convert");
8
+ var _listener = require("./listener");
7
9
  var _registry = require("./registry");
8
10
  var _utils = require("./utils");
9
11
  var _variants2 = require("./variants");
@@ -16,9 +18,12 @@ class UnistylesShadowRegistryBuilder {
16
18
  dispose = () => {};
17
19
  // END MOCKS
18
20
 
19
- resultsMap = (0, _utils.createDoubleMap)();
20
- classNamesMap = (0, _utils.createDoubleMap)();
21
- add = (ref, _style, _variants, _args) => {
21
+ resultsMap = new Map();
22
+ hashMap = new Map();
23
+ classNamesMap = new Map();
24
+ timeoutMap = new Map();
25
+ queuedResultMap = new Map();
26
+ add = (ref, _style, _variants, _args) => new Promise(resolve => {
22
27
  // Style is not provided
23
28
  if (!_style) {
24
29
  return;
@@ -39,16 +44,15 @@ class UnistylesShadowRegistryBuilder {
39
44
  if (ref === null) {
40
45
  const secrets = (0, _utils.extractSecrets)(_style);
41
46
  secrets.forEach(({
42
- __uni__refs,
43
- __uni__key
47
+ __uni__refs
44
48
  }) => {
45
49
  __uni__refs.forEach(ref => {
46
50
  if ((0, _utils.isInDocument)(ref)) {
47
51
  return;
48
52
  }
49
- const oldResult = this.resultsMap.get(ref, __uni__key);
50
- this.resultsMap.delete(ref, __uni__key);
51
- this.classNamesMap.delete(ref, __uni__key);
53
+ const oldResult = this.resultsMap.get(ref);
54
+ this.resultsMap.delete(ref);
55
+ this.classNamesMap.delete(ref);
52
56
  if (oldResult) {
53
57
  _registry.UnistylesRegistry.remove(oldResult);
54
58
  }
@@ -80,42 +84,78 @@ class UnistylesShadowRegistryBuilder {
80
84
  variantsResult: result
81
85
  }, variants));
82
86
  const resultWithVariants = (0, _utils.deepMergeObjects)(result, variantsResult ?? {});
83
- const oldResult = this.resultsMap.get(ref, __uni__key);
84
87
 
85
- // If results are the same do nothing
86
- if ((0, _utils.equal)(oldResult, resultWithVariants)) {
87
- return;
88
- }
89
- const oldClassNames = this.classNamesMap.get(ref, __uni__key);
88
+ // Get stored result from queue
89
+ const storedResult = this.queuedResultMap.get(ref) ?? {};
90
+ // Merge stored result with new result
91
+ const newResult = (0, _utils.deepMergeObjects)(storedResult, resultWithVariants);
92
+ const timeout = this.timeoutMap.get(ref);
93
+
94
+ // Add callback to the queue and remove old one
95
+ this.queuedResultMap.set(ref, newResult);
96
+ clearTimeout(timeout);
97
+ this.timeoutMap.set(ref, setTimeout(() => {
98
+ const oldResult = this.resultsMap.get(ref);
99
+
100
+ // If results are the same do nothing
101
+ if ((0, _utils.equal)(oldResult, newResult)) {
102
+ return;
103
+ }
104
+ const oldClassNames = this.classNamesMap.get(ref);
105
+
106
+ // Remove old styles
107
+ if (oldResult) {
108
+ _registry.UnistylesRegistry.remove(oldResult);
109
+ }
110
+
111
+ // Remove old classnames from the ref
112
+ oldClassNames?.forEach(className => ref.classList.remove(className));
113
+ this.resultsMap.set(ref, newResult);
114
+ const {
115
+ hash,
116
+ existingHash
117
+ } = _registry.UnistylesRegistry.add(newResult);
118
+ const injectedClassNames = newResult?._web?._classNames ?? [];
119
+ const newClassNames = injectedClassNames.concat(hash);
120
+ const dependencies = (0, _utils.extractUnistyleDependencies)(newResult);
121
+ if (typeof __uni__stylesheet === 'function') {
122
+ // Add dependencies from dynamic styles to stylesheet
123
+ _registry.UnistylesRegistry.addDependenciesToStylesheet(__uni__stylesheet, dependencies);
124
+ }
125
+ __uni__refs.add(ref);
126
+ this.classNamesMap.set(ref, newClassNames);
127
+ // Add new classnames to the ref
128
+ ref.classList.add(...newClassNames);
129
+ resolve(newClassNames);
130
+
131
+ // If it is new hash add it to the map to use for the listener
132
+ if (!existingHash) {
133
+ this.hashMap.set(ref, hash);
134
+ }
135
+ }, 0));
90
136
 
91
- // Remove old styles
92
- if (oldResult) {
93
- _registry.UnistylesRegistry.remove(oldResult);
94
- }
137
+ // Listen for theme / runtime changes
138
+ const dispose = _listener.UnistylesListener.addListeners((0, _utils.extractUnistyleDependencies)(newResult), () => {
139
+ const hash = this.hashMap.get(ref);
95
140
 
96
- // Remove old classnames from the ref
97
- oldClassNames?.forEach(className => ref.classList.remove(className));
98
- this.resultsMap.set(ref, __uni__key, resultWithVariants);
99
- const className = _registry.UnistylesRegistry.add({
100
- key: __uni__key,
101
- args,
102
- stylesheet: __uni__stylesheet,
103
- value: resultWithVariants,
104
- variants
141
+ // Dispose listener if there is no hash
142
+ if (!hash) {
143
+ dispose();
144
+ return;
145
+ }
146
+ const newComputedStyleSheet = _registry.UnistylesRegistry.getComputedStylesheet(__uni__stylesheet);
147
+ const newValue = newComputedStyleSheet[__uni__key];
148
+ const result = typeof newValue === 'function' ? newValue(...args) : newValue;
149
+ const {
150
+ variantsResult
151
+ } = Object.fromEntries((0, _variants2.getVariants)({
152
+ variantsResult: result
153
+ }, variants));
154
+ const resultWithVariants = (0, _utils.deepMergeObjects)(result, variantsResult ?? {});
155
+ _registry.UnistylesRegistry.applyStyles(hash, (0, _convert.convertUnistyles)(resultWithVariants));
105
156
  });
106
- const injectedClassNames = resultWithVariants?._web?._classNames ?? [];
107
- const newClassNames = injectedClassNames.concat(className);
108
- const dependencies = (0, _utils.extractUnistyleDependencies)(resultWithVariants);
109
- if (typeof __uni__stylesheet === 'function') {
110
- // Add dependencies from dynamic styles to stylesheet
111
- _registry.UnistylesRegistry.addDependenciesToStylesheet(__uni__stylesheet, dependencies);
112
- }
113
- __uni__refs.add(ref);
114
- this.classNamesMap.set(ref, __uni__key, newClassNames);
115
- // Add new classnames to the ref
116
- ref.classList.add(...newClassNames);
117
157
  });
118
- };
158
+ });
119
159
  remove = () => {};
120
160
  }
121
161
  const UnistylesShadowRegistry = exports.UnistylesShadowRegistry = new UnistylesShadowRegistryBuilder();