react-native-unistyles 3.0.0-alpha.35 → 3.0.0-alpha.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) hide show
  1. package/Unistyles.podspec +1 -1
  2. package/android/CMakeLists.txt +19 -36
  3. package/android/build.gradle +2 -1
  4. package/android/src/main/cxx/NativeUnistylesModule.cpp +71 -0
  5. package/android/src/main/cxx/NativeUnistylesModule.h +42 -0
  6. package/android/src/main/cxx/cpp-adapter.cpp +8 -86
  7. package/android/src/main/java/com/unistyles/Equatable.kt +61 -0
  8. package/android/src/main/java/com/unistyles/NativePlatform+android.kt +302 -0
  9. package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +148 -0
  10. package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +54 -0
  11. package/android/src/main/java/com/unistyles/UnistylesModule.kt +51 -0
  12. package/android/src/main/java/com/unistyles/UnistylesPackage.kt +16 -14
  13. package/cxx/NativePlatform.h +11 -0
  14. package/cxx/common/Helpers.h +1 -1
  15. package/cxx/core/Unistyle.h +1 -1
  16. package/cxx/core/UnistyleData.h +1 -1
  17. package/cxx/core/UnistyleWrapper.h +1 -2
  18. package/cxx/core/UnistylesCommitHook.cpp +1 -1
  19. package/cxx/core/UnistylesMountHook.cpp +1 -1
  20. package/cxx/core/UnistylesRegistry.cpp +4 -13
  21. package/cxx/core/UnistylesRegistry.h +2 -3
  22. package/cxx/core/UnistylesState.cpp +10 -7
  23. package/cxx/hybridObjects/HybridNavigationBar.h +3 -3
  24. package/cxx/hybridObjects/HybridStatusBar.h +3 -3
  25. package/cxx/hybridObjects/HybridStyleSheet.cpp +21 -18
  26. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -8
  27. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -3
  28. package/cxx/parser/Parser.cpp +3 -27
  29. package/cxx/parser/Parser.h +2 -3
  30. package/cxx/shadowTree/ShadowTrafficController.h +9 -5
  31. package/cxx/shadowTree/ShadowTreeManager.cpp +10 -5
  32. package/cxx/shadowTree/ShadowTreeManager.h +1 -1
  33. package/lib/commonjs/components/useMedia.js.map +1 -1
  34. package/lib/commonjs/components/useMedia.web.js +43 -0
  35. package/lib/commonjs/components/useMedia.web.js.map +1 -0
  36. package/lib/commonjs/core/createUnistylesComponent.js +57 -4
  37. package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
  38. package/lib/commonjs/core/createUnistylesComponent.native.js +6 -5
  39. package/lib/commonjs/core/createUnistylesComponent.native.js.map +1 -1
  40. package/lib/commonjs/web/convert/index.js +16 -11
  41. package/lib/commonjs/web/convert/index.js.map +1 -1
  42. package/lib/commonjs/web/convert/object/boxShadow.js +58 -0
  43. package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -0
  44. package/lib/commonjs/web/convert/object/filter.js +42 -0
  45. package/lib/commonjs/web/convert/object/filter.js.map +1 -0
  46. package/lib/commonjs/web/convert/object/index.js +39 -0
  47. package/lib/commonjs/web/convert/object/index.js.map +1 -0
  48. package/lib/commonjs/web/convert/object/objectStyle.js +55 -0
  49. package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -0
  50. package/lib/commonjs/web/convert/object/transform.js +27 -0
  51. package/lib/commonjs/web/convert/object/transform.js.map +1 -0
  52. package/lib/commonjs/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
  53. package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -0
  54. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js +38 -0
  55. package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  56. package/lib/commonjs/web/convert/shadow/index.js +28 -0
  57. package/lib/commonjs/web/convert/shadow/index.js.map +1 -0
  58. package/lib/commonjs/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
  59. package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -0
  60. package/lib/commonjs/web/convert/utils.js +7 -3
  61. package/lib/commonjs/web/convert/utils.js.map +1 -1
  62. package/lib/commonjs/web/listener.js +10 -0
  63. package/lib/commonjs/web/listener.js.map +1 -1
  64. package/lib/commonjs/web/registry.js +13 -26
  65. package/lib/commonjs/web/registry.js.map +1 -1
  66. package/lib/commonjs/web/runtime.js +3 -0
  67. package/lib/commonjs/web/runtime.js.map +1 -1
  68. package/lib/commonjs/web/shadowRegistry.js +79 -39
  69. package/lib/commonjs/web/shadowRegistry.js.map +1 -1
  70. package/lib/commonjs/web/utils/common.js +3 -33
  71. package/lib/commonjs/web/utils/common.js.map +1 -1
  72. package/lib/commonjs/web/utils/unistyle.js +4 -1
  73. package/lib/commonjs/web/utils/unistyle.js.map +1 -1
  74. package/lib/module/components/useMedia.js.map +1 -1
  75. package/lib/module/components/useMedia.web.js +38 -0
  76. package/lib/module/components/useMedia.web.js.map +1 -0
  77. package/lib/module/core/createUnistylesComponent.js +55 -3
  78. package/lib/module/core/createUnistylesComponent.js.map +1 -1
  79. package/lib/module/core/createUnistylesComponent.native.js +6 -5
  80. package/lib/module/core/createUnistylesComponent.native.js.map +1 -1
  81. package/lib/module/web/convert/index.js +14 -9
  82. package/lib/module/web/convert/index.js.map +1 -1
  83. package/lib/module/web/convert/object/boxShadow.js +53 -0
  84. package/lib/module/web/convert/object/boxShadow.js.map +1 -0
  85. package/lib/module/web/convert/object/filter.js +37 -0
  86. package/lib/module/web/convert/object/filter.js.map +1 -0
  87. package/lib/module/web/convert/object/index.js +6 -0
  88. package/lib/module/web/convert/object/index.js.map +1 -0
  89. package/lib/module/web/convert/object/objectStyle.js +50 -0
  90. package/lib/module/web/convert/object/objectStyle.js.map +1 -0
  91. package/lib/module/web/convert/object/transform.js +22 -0
  92. package/lib/module/web/convert/object/transform.js.map +1 -0
  93. package/lib/module/web/convert/{boxShadow.js → shadow/boxShadow.js} +9 -24
  94. package/lib/module/web/convert/shadow/boxShadow.js.map +1 -0
  95. package/lib/module/web/convert/shadow/getShadowBreakpoints.js +33 -0
  96. package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -0
  97. package/lib/module/web/convert/shadow/index.js +5 -0
  98. package/lib/module/web/convert/shadow/index.js.map +1 -0
  99. package/lib/module/web/convert/{textShadow.js → shadow/textShadow.js} +9 -23
  100. package/lib/module/web/convert/shadow/textShadow.js.map +1 -0
  101. package/lib/module/web/convert/utils.js +4 -2
  102. package/lib/module/web/convert/utils.js.map +1 -1
  103. package/lib/module/web/listener.js +10 -0
  104. package/lib/module/web/listener.js.map +1 -1
  105. package/lib/module/web/registry.js +14 -27
  106. package/lib/module/web/registry.js.map +1 -1
  107. package/lib/module/web/runtime.js +3 -0
  108. package/lib/module/web/runtime.js.map +1 -1
  109. package/lib/module/web/shadowRegistry.js +80 -40
  110. package/lib/module/web/shadowRegistry.js.map +1 -1
  111. package/lib/module/web/utils/common.js +1 -31
  112. package/lib/module/web/utils/common.js.map +1 -1
  113. package/lib/module/web/utils/unistyle.js +4 -1
  114. package/lib/module/web/utils/unistyle.js.map +1 -1
  115. package/lib/typescript/src/components/useMedia.web.d.ts +6 -0
  116. package/lib/typescript/src/components/useMedia.web.d.ts.map +1 -0
  117. package/lib/typescript/src/core/createUnistylesComponent.d.ts +4 -3
  118. package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
  119. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +4 -3
  120. package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +1 -1
  121. package/lib/typescript/src/types/common.d.ts +1 -0
  122. package/lib/typescript/src/types/common.d.ts.map +1 -1
  123. package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
  124. package/lib/typescript/src/web/convert/object/boxShadow.d.ts +9 -0
  125. package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -0
  126. package/lib/typescript/src/web/convert/object/filter.d.ts +3 -0
  127. package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -0
  128. package/lib/typescript/src/web/convert/object/index.d.ts +4 -0
  129. package/lib/typescript/src/web/convert/object/index.d.ts.map +1 -0
  130. package/lib/typescript/src/web/convert/object/objectStyle.d.ts +5 -0
  131. package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -0
  132. package/lib/typescript/src/web/convert/object/transform.d.ts +3 -0
  133. package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -0
  134. package/lib/typescript/src/web/convert/shadow/boxShadow.d.ts.map +1 -0
  135. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts +2 -0
  136. package/lib/typescript/src/web/convert/shadow/getShadowBreakpoints.d.ts.map +1 -0
  137. package/lib/typescript/src/web/convert/shadow/index.d.ts +3 -0
  138. package/lib/typescript/src/web/convert/shadow/index.d.ts.map +1 -0
  139. package/lib/typescript/src/web/convert/shadow/textShadow.d.ts.map +1 -0
  140. package/lib/typescript/src/web/convert/types.d.ts +7 -1
  141. package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
  142. package/lib/typescript/src/web/convert/utils.d.ts +8 -4
  143. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
  144. package/lib/typescript/src/web/create.d.ts +8 -8
  145. package/lib/typescript/src/web/index.d.ts +8 -8
  146. package/lib/typescript/src/web/listener.d.ts +2 -0
  147. package/lib/typescript/src/web/listener.d.ts.map +1 -1
  148. package/lib/typescript/src/web/registry.d.ts +5 -9
  149. package/lib/typescript/src/web/registry.d.ts.map +1 -1
  150. package/lib/typescript/src/web/runtime.d.ts +1 -0
  151. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  152. package/lib/typescript/src/web/shadowRegistry.d.ts +4 -1
  153. package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
  154. package/lib/typescript/src/web/utils/common.d.ts +1 -6
  155. package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
  156. package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
  157. package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +6 -0
  158. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Dimensions.kt +1 -0
  159. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void.kt +1 -0
  160. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Func_void_std__vector_UnistyleDependency_.kt +1 -0
  161. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/Insets.kt +1 -0
  162. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +1 -0
  163. package/nitrogen/generated/android/unistyles+autolinking.gradle +2 -0
  164. package/nitrogen/generated/ios/Unistyles+autolinking.rb +1 -1
  165. package/package.json +3 -3
  166. package/src/components/useMedia.ts +1 -1
  167. package/src/components/useMedia.web.ts +47 -0
  168. package/src/core/createUnistylesComponent.native.tsx +12 -10
  169. package/src/core/createUnistylesComponent.tsx +72 -6
  170. package/src/types/common.ts +1 -0
  171. package/src/web/convert/index.ts +16 -9
  172. package/src/web/convert/object/boxShadow.ts +54 -0
  173. package/src/web/convert/object/filter.ts +39 -0
  174. package/src/web/convert/object/index.ts +3 -0
  175. package/src/web/convert/object/objectStyle.ts +68 -0
  176. package/src/web/convert/object/transform.ts +24 -0
  177. package/src/web/convert/{boxShadow.ts → shadow/boxShadow.ts} +9 -30
  178. package/src/web/convert/shadow/getShadowBreakpoints.ts +34 -0
  179. package/src/web/convert/shadow/index.ts +2 -0
  180. package/src/web/convert/{textShadow.ts → shadow/textShadow.ts} +9 -29
  181. package/src/web/convert/types.ts +8 -1
  182. package/src/web/convert/utils.ts +11 -5
  183. package/src/web/listener.ts +10 -0
  184. package/src/web/registry.ts +10 -31
  185. package/src/web/runtime.ts +4 -0
  186. package/src/web/shadowRegistry.ts +85 -46
  187. package/src/web/utils/common.ts +1 -37
  188. package/src/web/utils/unistyle.ts +5 -1
  189. package/android/src/main/cxx/helpers.cpp +0 -105
  190. package/android/src/main/cxx/helpers.h +0 -16
  191. package/android/src/main/cxx/platform.cpp +0 -170
  192. package/android/src/main/cxx/platform.h +0 -20
  193. package/lib/commonjs/web/convert/boxShadow.js.map +0 -1
  194. package/lib/commonjs/web/convert/shadow.js +0 -68
  195. package/lib/commonjs/web/convert/shadow.js.map +0 -1
  196. package/lib/commonjs/web/convert/textShadow.js.map +0 -1
  197. package/lib/commonjs/web/convert/transform.js +0 -72
  198. package/lib/commonjs/web/convert/transform.js.map +0 -1
  199. package/lib/module/web/convert/boxShadow.js.map +0 -1
  200. package/lib/module/web/convert/shadow.js +0 -63
  201. package/lib/module/web/convert/shadow.js.map +0 -1
  202. package/lib/module/web/convert/textShadow.js.map +0 -1
  203. package/lib/module/web/convert/transform.js +0 -67
  204. package/lib/module/web/convert/transform.js.map +0 -1
  205. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +0 -1
  206. package/lib/typescript/src/web/convert/shadow.d.ts +0 -2
  207. package/lib/typescript/src/web/convert/shadow.d.ts.map +0 -1
  208. package/lib/typescript/src/web/convert/textShadow.d.ts.map +0 -1
  209. package/lib/typescript/src/web/convert/transform.d.ts +0 -4
  210. package/lib/typescript/src/web/convert/transform.d.ts.map +0 -1
  211. package/src/web/convert/shadow.ts +0 -68
  212. package/src/web/convert/transform.ts +0 -88
  213. /package/lib/typescript/src/web/convert/{boxShadow.d.ts → shadow/boxShadow.d.ts} +0 -0
  214. /package/lib/typescript/src/web/convert/{textShadow.d.ts → shadow/textShadow.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../src/web/listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,cAAM,wBAAwB;IAC1B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,SAAS,CAAoG;IAErH,UAAU,eAAgB,kBAAkB,UAE3C;IAED,aAAa,aAUZ;IAED,YAAY,iBAAkB,KAAK,CAAC,kBAAkB,CAAC,YAAY,YAAY,gBAM9E;CACJ;AAED,eAAO,MAAM,iBAAiB,0BAAiC,CAAA"}
1
+ {"version":3,"file":"listener.d.ts","sourceRoot":"","sources":["../../../../src/web/listener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AAG5D,cAAM,wBAAwB;IAC1B,OAAO,CAAC,aAAa,CAAQ;IAC7B,OAAO,CAAC,SAAS,CAAoG;IACrH,OAAO,CAAC,mBAAmB,CAAoG;IAE/H,UAAU,eAAgB,kBAAkB,UAG3C;IAED,aAAa,aAUZ;IAED,YAAY,iBAAkB,KAAK,CAAC,kBAAkB,CAAC,YAAY,YAAY,gBAM9E;IAED,sBAAsB,iBAAkB,KAAK,CAAC,kBAAkB,CAAC,YAAY,YAAY,gBAMxF;CACJ;AAED,eAAO,MAAM,iBAAiB,0BAAiC,CAAA"}
@@ -2,13 +2,6 @@ import type { UnistylesTheme, UnistylesValues } from '../types';
2
2
  import type { StyleSheet, StyleSheetWithSuperPowers } from '../types/stylesheet';
3
3
  import type { UnistyleDependency } from '../specs/NativePlatform';
4
4
  import type { UnistylesMiniRuntime } from '../specs';
5
- type AddProps = {
6
- value: UnistylesValues;
7
- stylesheet: StyleSheetWithSuperPowers<StyleSheet>;
8
- key: string;
9
- args: Array<any>;
10
- variants: Record<string, any>;
11
- };
12
5
  declare class UnistylesRegistryBuilder {
13
6
  #private;
14
7
  private readonly stylesheets;
@@ -18,8 +11,11 @@ declare class UnistylesRegistryBuilder {
18
11
  private get styleTag();
19
12
  getComputedStylesheet: (stylesheet: StyleSheetWithSuperPowers<StyleSheet>) => StyleSheet;
20
13
  addDependenciesToStylesheet: (stylesheet: (theme: UnistylesTheme, miniRuntime: UnistylesMiniRuntime) => StyleSheet, dependencies: Array<UnistyleDependency>) => void;
21
- add: ({ key, value, stylesheet, args, variants }: AddProps) => string;
22
- private applyStyles;
14
+ add: (value: UnistylesValues) => {
15
+ hash: string;
16
+ existingHash: boolean;
17
+ };
18
+ applyStyles: (hash: string, styles: Record<string, any>) => void;
23
19
  private applyRule;
24
20
  remove: (value: UnistylesValues) => void;
25
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/web/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAKhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAGpD,KAAK,QAAQ,GAAG;IACZ,KAAK,EAAE,eAAe,CAAC;IACvB,UAAU,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IAClD,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAChC,CAAA;AAWD,cAAM,wBAAwB;;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+D;IAC3F,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IAExE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4E;IAE5G,OAAO,KAAK,QAAQ,GAcnB;IAED,qBAAqB,eAAgB,yBAAyB,CAAC,UAAU,CAAC,gBAkBzE;IAED,2BAA2B,eAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,KAAK,UAAU,gBAAgB,KAAK,CAAC,kBAAkB,CAAC,UAe3J;IAED,GAAG,+CAAgD,QAAQ,YAiC1D;IAED,OAAO,CAAC,WAAW,CAwElB;IAED,OAAO,CAAC,SAAS,CAmBhB;IAED,MAAM,UAAW,eAAe,UAe/B;CACJ;AAED,eAAO,MAAM,iBAAiB,0BAAiC,CAAA"}
1
+ {"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/web/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAKhF,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAA;AACjE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAWpD,cAAM,wBAAwB;;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+D;IAC3F,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IAExE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4E;IAE5G,OAAO,KAAK,QAAQ,GAcnB;IAED,qBAAqB,eAAgB,yBAAyB,CAAC,UAAU,CAAC,gBAkBzE;IAED,2BAA2B,eAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,KAAK,UAAU,gBAAgB,KAAK,CAAC,kBAAkB,CAAC,UAe3J;IAED,GAAG,UAAW,eAAe;;;MAiB5B;IAED,WAAW,SAAU,MAAM,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAwEvD;IAED,OAAO,CAAC,SAAS,CAmBhB;IAED,MAAM,UAAW,eAAe,UAmB/B;CACJ;AAED,eAAO,MAAM,iBAAiB,0BAAiC,CAAA"}
@@ -9,6 +9,7 @@ declare class UnistylesRuntimeBuilder {
9
9
  get colorScheme(): ColorScheme;
10
10
  get themeName(): undefined;
11
11
  get contentSizeCategory(): WebContentSizeCategory;
12
+ get breakpoints(): import("..").UnistylesBreakpoints;
12
13
  get breakpoint(): keyof import("..").UnistylesBreakpoints | undefined;
13
14
  get orientation(): Orientation;
14
15
  get theme(): never;
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAMjD,cAAM,uBAAuB;IACzB,UAAU,wBAAuB;IACjC,SAAS,wBAAsB;IAE/B,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,YAAY;IAYpB,IAAI,WAAW,gBASd;IAED,IAAI,SAAS,cAEZ;IAED,IAAI,mBAAmB,2BAEtB;IAED,IAAI,UAAU,wDAEb;IAED,IAAI,WAAW,gBAMd;IAED,IAAI,KAAK,UAER;IAED,IAAI,UAAU,WAEb;IAED,IAAI,MAAM;;;MAYT;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,MAAM;;;;;;MAQT;IAED,IAAI,SAAS,oDAEZ;IAED,IAAI,GAAG,YAEN;IAED,IAAI,iBAAiB,YAEpB;IAED,IAAI,aAAa,2DAEhB;IAED,IAAI,WAAW,IAAI,oBAAoB,CAuBtC;IAED,QAAQ,cAAe,YAAY,UAQlC;IAED,iBAAiB,cAAe,OAAO,UAQtC;IAED,0BAA0B,QAAS,MAAM,UAAU,MAAM,UAMxD;IAED,gBAAgB,aAAW;IAE3B,WAAW,cAAe,YAAY,WAAW,CAAC,YAAY,EAAE,QAAQ,KAAK,QAAQ,UAQpF;IAED,QAAQ,mCAYP;CACJ;AAED,eAAO,MAAM,gBAAgB,yBAAgC,CAAA"}
1
+ {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAMjD,cAAM,uBAAuB;IACzB,UAAU,wBAAuB;IACjC,SAAS,wBAAsB;IAE/B,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,YAAY;IAYpB,IAAI,WAAW,gBASd;IAED,IAAI,SAAS,cAEZ;IAED,IAAI,mBAAmB,2BAEtB;IAED,IAAI,WAAW,sCAEd;IAED,IAAI,UAAU,wDAEb;IAED,IAAI,WAAW,gBAMd;IAED,IAAI,KAAK,UAER;IAED,IAAI,UAAU,WAEb;IAED,IAAI,MAAM;;;MAYT;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,MAAM;;;;;;MAQT;IAED,IAAI,SAAS,oDAEZ;IAED,IAAI,GAAG,YAEN;IAED,IAAI,iBAAiB,YAEpB;IAED,IAAI,aAAa,2DAEhB;IAED,IAAI,WAAW,IAAI,oBAAoB,CAuBtC;IAED,QAAQ,cAAe,YAAY,UAQlC;IAED,iBAAiB,cAAe,OAAO,UAQtC;IAED,0BAA0B,QAAS,MAAM,UAAU,MAAM,UAMxD;IAED,gBAAgB,aAAW;IAE3B,WAAW,cAAe,YAAY,WAAW,CAAC,YAAY,EAAE,QAAQ,KAAK,QAAQ,UAQpF;IAED,QAAQ,mCAYP;CACJ;AAED,eAAO,MAAM,gBAAgB,yBAAgC,CAAA"}
@@ -7,8 +7,11 @@ declare class UnistylesShadowRegistryBuilder {
7
7
  toString: () => string;
8
8
  dispose: () => void;
9
9
  private resultsMap;
10
+ private hashMap;
10
11
  private classNamesMap;
11
- add: (ref: any, _style?: Style | Array<Style>, _variants?: Record<string, any>, _args?: Array<any>) => void;
12
+ private timeoutMap;
13
+ private queuedResultMap;
14
+ add: (ref: any, _style?: Style | Array<Style>, _variants?: Record<string, any>, _args?: Array<any>) => Promise<string[]>;
12
15
  remove: () => void;
13
16
  }
14
17
  export declare const UnistylesShadowRegistry: UnistylesShadowRegistryBuilder;
@@ -1 +1 @@
1
- {"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAK/C,KAAK,KAAK,GAAG,eAAe,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,eAAe,CAAC,CAAA;AAEzE,cAAM,8BAA8B;IAEhC,IAAI,SAA4B;IAChC,MAAM,SAAQ;IACd,MAAM,gBAAa;IACnB,QAAQ,eAAkC;IAC1C,OAAO,aAAW;IAGlB,OAAO,CAAC,UAAU,CAA0D;IAC5E,OAAO,CAAC,aAAa,CAAwD;IAE7E,GAAG,QAAS,GAAG,WAAW,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,KAAK,CAAC,GAAG,CAAC,UAgGlG;IAED,MAAM,aAAW;CACpB;AAED,eAAO,MAAM,uBAAuB,gCAAuC,CAAA"}
1
+ {"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAO/C,KAAK,KAAK,GAAG,eAAe,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,eAAe,CAAC,CAAA;AAEzE,cAAM,8BAA8B;IAEhC,IAAI,SAA4B;IAChC,MAAM,SAAQ;IACd,MAAM,gBAAa;IACnB,QAAQ,eAAkC;IAC1C,OAAO,aAAW;IAGlB,OAAO,CAAC,UAAU,CAA0C;IAC5D,OAAO,CAAC,OAAO,CAAiC;IAChD,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,UAAU,CAAyC;IAC3D,OAAO,CAAC,eAAe,CAA8C;IAErE,GAAG,QAAS,GAAG,WAAW,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,cAAc,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAAU,KAAK,CAAC,GAAG,CAAC,uBAkIjG;IAEF,MAAM,aAAW;CACpB;AAED,eAAO,MAAM,uBAAuB,gCAAuC,CAAA"}
@@ -8,10 +8,5 @@ export declare const deepMergeObjects: <T extends Record<PropertyKey, any>>(...s
8
8
  export declare const warn: (message: string) => void;
9
9
  export declare const equal: <T>(a: T, b: T) => boolean;
10
10
  export declare const generateHash: (value: any) => string;
11
- export declare const createDoubleMap: <TKey, TSecondKey, TValue>() => {
12
- get: (key: TKey, secondKey: TSecondKey) => TValue | undefined;
13
- set: (key: TKey, secondKey: TSecondKey, value: TValue) => void;
14
- delete: (key: TKey, secondKey: TSecondKey) => void;
15
- forEach: (callback: (key: TKey, secondKey: TSecondKey, value: TValue) => void) => void;
16
- };
11
+ export declare const hyphenate: (propertyName: string) => string;
17
12
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,OAC9D,IAAI,WACA,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,IAAI,KAAK,QAAQ,KACmD,GAAG,CAAe,IAAV,MAAM,IAAI,GAAG,QAAQ,GAAE,CAAA;AAErJ,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,WAAW,KAAG,GAAG,IAAI,MAAM,CAAe,CAAA;AAElH,eAAO,MAAM,QAAQ,eAAsC,CAAA;AAE3D;;EAEE;AACF,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,MAqBxF,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,SAA2D,CAAA;AAE/F,eAAO,MAAM,KAAK,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAqBlC,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,GAAG,WAQtC,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,IAAI,EAAE,UAAU,EAAE,MAAM;eAIrC,IAAI,aAAa,UAAU;eAS3B,IAAI,aAAa,UAAU,SAAS,MAAM;kBAMvC,IAAI,aAAa,UAAU;wBASrB,CAAC,GAAG,EAAE,IAAI,EAAE,SAAS,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI;CAQpF,CAAA"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,QAAQ,OAC9D,IAAI,WACA,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,GAAG,EAAE,MAAM,IAAI,KAAK,QAAQ,KACmD,GAAG,CAAe,IAAV,MAAM,IAAI,GAAG,QAAQ,GAAE,CAAA;AAErJ,eAAO,MAAM,WAAW,GAAI,CAAC,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAAO,CAAC,OAAO,WAAW,KAAG,GAAG,IAAI,MAAM,CAAe,CAAA;AAElH,eAAO,MAAM,QAAQ,eAAsC,CAAA;AAE3D;;EAEE;AACF,eAAO,MAAM,gBAAgB,GAAI,CAAC,SAAS,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,cAAc,KAAK,CAAC,CAAC,CAAC,MAqBxF,CAAA;AAED,eAAO,MAAM,IAAI,YAAa,MAAM,SAA2D,CAAA;AAE/F,eAAO,MAAM,KAAK,GAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAqBlC,CAAA;AAED,eAAO,MAAM,YAAY,UAAW,GAAG,WAQtC,CAAA;AAED,eAAO,MAAM,SAAS,iBAAkB,MAAM,WAAyE,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKpG,eAAO,MAAM,aAAa,WAAY,WAAW,KAAG,MAQnD,CAAA;AAED,eAAO,MAAM,SAAS,QAAS,MAAM,WAAW,MAAM,WAM5B,CAAA;AAE1B,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAKnE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG,sBAUzC,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,eAAe,OAUhD,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,WAAW,YAAoC,CAAA;AAErF,eAAO,MAAM,sBAAsB,UAAW,MAAM,uBAUnD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAmB1C,CAAA;AAED,eAAO,MAAM,2BAA2B,UAAW,GAAG,yBAIrD,CAAA"}
1
+ {"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKpG,eAAO,MAAM,aAAa,WAAY,WAAW,KAAG,MAQnD,CAAA;AAED,eAAO,MAAM,SAAS,QAAS,MAAM,WAAW,MAAM,WAM5B,CAAA;AAE1B,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;IAC7B,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;IACpC,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAKnE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG,sBAUzC,CAAA;AAED,eAAO,MAAM,SAAS,WAAY,eAAe,OAUhD,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,WAAW,YAAoC,CAAA;AAErF,eAAO,MAAM,sBAAsB,UAAW,MAAM,uBAUnD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAmB1C,CAAA;AAED,eAAO,MAAM,2BAA2B,UAAW,GAAG,yBAQrD,CAAA"}
@@ -31,6 +31,12 @@ namespace margelo::nitro::unistyles {
31
31
  HybridObject(HybridNativePlatformSpec::TAG),
32
32
  _javaPart(jni::make_global(jThis)) {}
33
33
 
34
+ public:
35
+ virtual ~JHybridNativePlatformSpec() {
36
+ // Hermes GC can destroy JS objects on a non-JNI Thread.
37
+ jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
38
+ }
39
+
34
40
  public:
35
41
  size_t getExternalMemorySize() noexcept override;
36
42
 
@@ -9,6 +9,7 @@ package com.margelo.nitro.unistyles
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
12
13
 
13
14
  /**
14
15
  * Represents the JavaScript object/struct "Dimensions".
@@ -10,6 +10,7 @@ package com.margelo.nitro.unistyles
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.*
13
14
  import dalvik.annotation.optimization.FastNative
14
15
 
15
16
  /**
@@ -10,6 +10,7 @@ package com.margelo.nitro.unistyles
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.jni.HybridData
12
12
  import com.facebook.proguard.annotations.DoNotStrip
13
+ import com.margelo.nitro.core.*
13
14
  import dalvik.annotation.optimization.FastNative
14
15
 
15
16
  /**
@@ -9,6 +9,7 @@ package com.margelo.nitro.unistyles
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
12
13
 
13
14
  /**
14
15
  * Represents the JavaScript object/struct "Insets".
@@ -9,6 +9,7 @@ package com.margelo.nitro.unistyles
9
9
 
10
10
  import androidx.annotation.Keep
11
11
  import com.facebook.proguard.annotations.DoNotStrip
12
+ import com.margelo.nitro.core.*
12
13
 
13
14
  /**
14
15
  * Represents the JavaScript object/struct "UnistylesNativeMiniRuntime".
@@ -13,6 +13,8 @@
13
13
  /// apply from: '../nitrogen/generated/android/unistyles+autolinking.gradle'
14
14
  /// ```
15
15
 
16
+ logger.warn("[NitroModules] 🔥 unistyles is boosted by nitro!")
17
+
16
18
  android {
17
19
  sourceSets {
18
20
  main {
@@ -20,7 +20,7 @@
20
20
  # ```
21
21
 
22
22
  def add_nitrogen_files(spec)
23
- Pod::UI.puts "[NitroModules] Adding Unistyles specs..."
23
+ Pod::UI.puts "[NitroModules] 🔥 Unistyles is boosted by nitro!"
24
24
 
25
25
  spec.dependency "NitroModules"
26
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-alpha.35",
3
+ "version": "3.0.0-alpha.37",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -74,11 +74,11 @@
74
74
  "husky": "9.1.6",
75
75
  "jest": "29.7.0",
76
76
  "metro-react-native-babel-preset": "0.77.0",
77
- "nitro-codegen": "0.14.0",
77
+ "nitro-codegen": "0.16.2",
78
78
  "react": "18.3.1",
79
79
  "react-native": "0.76.0",
80
80
  "react-native-builder-bob": "0.30.2",
81
- "react-native-nitro-modules": "0.14.0",
81
+ "react-native-nitro-modules": "0.16.2",
82
82
  "react-test-renderer": "18.3.1",
83
83
  "release-it": "17.10.0",
84
84
  "typescript": "5.6.3"
@@ -12,7 +12,7 @@ export const useMedia = (config: { mq: symbol }) => {
12
12
  return false
13
13
  }
14
14
 
15
- const parsedMq = parseMq(maybeMq)
15
+ const parsedMq = parseMq(maybeMq)
16
16
 
17
17
  if (!isValidMq(parsedMq)) {
18
18
  console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`)
@@ -0,0 +1,47 @@
1
+ import { useEffect, useRef, useState } from 'react'
2
+ import { isUnistylesMq, isValidMq, parseMq } from '../mq'
3
+
4
+ export const useMedia = (config: { mq: symbol }) => {
5
+ const disposeRef = useRef(() => {})
6
+ const [isVisible, setIsVisible] = useState(() => {
7
+ const maybeMq = config.mq as unknown as string
8
+
9
+ if (!isUnistylesMq(maybeMq)) {
10
+ console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`)
11
+
12
+ return false
13
+ }
14
+
15
+ const parsedMq = parseMq(maybeMq)
16
+
17
+ if (!isValidMq(parsedMq)) {
18
+ console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`)
19
+
20
+ return false
21
+ }
22
+
23
+ const { minWidth, maxWidth, minHeight, maxHeight } = parsedMq
24
+
25
+ const mediaQuery = [
26
+ minWidth !== undefined ? `(min-width: ${minWidth}px)` : undefined,
27
+ maxWidth !== undefined ? `(max-width: ${maxWidth}px)` : undefined,
28
+ minHeight !== undefined ? `(min-height: ${minHeight}px)` : undefined,
29
+ maxHeight !== undefined ? `(max-height: ${maxHeight}px)` : undefined
30
+ ].filter(Boolean).join(' and ')
31
+
32
+ const media = window.matchMedia(mediaQuery)
33
+ const handler = (event: MediaQueryListEvent) => setIsVisible(event.matches)
34
+
35
+ media.addEventListener('change', handler)
36
+ disposeRef.current = () => media.removeEventListener('change', handler)
37
+
38
+ return media.matches
39
+ })
40
+
41
+ // Unmount
42
+ useEffect(() => () => disposeRef.current(), [])
43
+
44
+ return {
45
+ isVisible
46
+ }
47
+ }
@@ -1,13 +1,13 @@
1
- import React, { type ComponentProps, type ComponentType, useEffect, useRef, useState } from 'react'
1
+ import React, { type ComponentType, useEffect, useRef, useState } from 'react'
2
2
  import type { UnistylesTheme } from '../types'
3
3
  import { StyleSheet, UnistyleDependency, UnistylesRuntime, type UnistylesStyleSheet } from '../specs'
4
-
5
- type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<Omit<ComponentProps<T>, typeof SUPPORTED_STYLE_PROPS[number]>>
4
+ import type { PartialBy } from '../types/common'
6
5
 
7
6
  const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
7
+ type SupportedStyleProps = typeof SUPPORTED_STYLE_PROPS[number]
8
8
 
9
- export const createUnistylesComponent = <T extends ComponentType<any>>(Component: T, mappings: Mappings<T> = () => ({})) => {
10
- return (props: ComponentProps<T>) => {
9
+ export const createUnistylesComponent =<TProps extends Record<string, any>, TMappings extends Partial<Omit<TProps, SupportedStyleProps>>>(Component: ComponentType<TProps>, mappings?: (theme: UnistylesTheme) => TMappings) => {
10
+ return (props: PartialBy<TProps, keyof TMappings | SupportedStyleProps>) => {
11
11
  const [theme, setTheme] = useState<UnistylesTheme>(UnistylesRuntime.getTheme())
12
12
  const [, setRt] = useState(0)
13
13
  const stylesRef = useRef<Record<string, any>>({})
@@ -20,6 +20,7 @@ export const createUnistylesComponent = <T extends ComponentType<any>>(Component
20
20
  console.error(`🦄 Unistyles: createUnistylesComponent requires ${propName} to be an object. Please check props for component: ${Component.displayName}`)
21
21
  }
22
22
 
23
+ // @ts-expect-error - this is hidden from TS
23
24
  if (props[propName].__unistyles_name && !props[propName].__proto__?.getStyle) {
24
25
  console.error(`🦄 Unistyles: createUnistylesComponent received style that is not bound. You likely used the spread operator on a Unistyle style. Please check props for component: ${Component.displayName}`)
25
26
  }
@@ -34,7 +35,7 @@ export const createUnistylesComponent = <T extends ComponentType<any>>(Component
34
35
 
35
36
  useEffect(() => {
36
37
  const removeChangeListener = (StyleSheet as UnistylesStyleSheet).addChangeListener(dependencies => {
37
- const componentDependencies = (props.style?.__proto__.uni__dependencies || mappings(theme).style?.__proto__.uni__dependencies) as Array<UnistyleDependency>
38
+ const componentDependencies = (props.style?.__proto__.uni__dependencies || mappings?.(theme).style?.__proto__.uni__dependencies) as Array<UnistyleDependency>
38
39
 
39
40
  if (dependencies.includes(UnistyleDependency.Theme) && (!componentDependencies ||componentDependencies.includes(UnistyleDependency.Theme))) {
40
41
  setTheme(UnistylesRuntime.getTheme())
@@ -44,6 +45,7 @@ export const createUnistylesComponent = <T extends ComponentType<any>>(Component
44
45
  if (props?.[propName]) {
45
46
  stylesRef.current = {
46
47
  ...stylesRef.current,
48
+ // @ts-expect-error - this is hidden from TS
47
49
  [propName]: props[propName].__proto__?.getStyle() || props[propName]
48
50
  }
49
51
  }
@@ -62,16 +64,16 @@ export const createUnistylesComponent = <T extends ComponentType<any>>(Component
62
64
  }
63
65
  }, [])
64
66
 
65
- const mergedProps = { ...mappings(theme) } as ComponentProps<T>
67
+ const mergedProps = mappings?.(theme) as Record<string, any> ?? {}
66
68
 
67
69
  Object.keys(props).forEach(key => {
68
70
  if (key in mergedProps) {
69
- mergedProps[key] = Object.assign(props[key], mergedProps[key])
71
+ mergedProps[key] = Object.assign(props[key as keyof typeof props], mergedProps[key])
70
72
 
71
73
  return
72
74
  }
73
75
 
74
- mergedProps[key] = props[key]
76
+ mergedProps[key] = props[key as keyof typeof props]
75
77
  })
76
78
 
77
79
  // override with Unistyles styles
@@ -83,6 +85,6 @@ export const createUnistylesComponent = <T extends ComponentType<any>>(Component
83
85
 
84
86
  isForcedRef.current = false
85
87
 
86
- return <Component {...mergedProps} />
88
+ return <Component {...mergedProps as TProps} />
87
89
  }
88
90
  }
@@ -1,12 +1,78 @@
1
- import React, { type ComponentProps, type ComponentType } from 'react'
1
+ import React, { useEffect, useState, type ComponentType } from 'react'
2
2
  import type { UnistylesTheme } from '../types'
3
-
4
- type Mappings<T extends ComponentType<any>> = (theme: UnistylesTheme) => Partial<Omit<ComponentProps<T>, typeof SUPPORTED_STYLE_PROPS[number]>>
3
+ import { UnistylesRuntime } from '../specs'
4
+ import { UnistyleDependency } from '../specs/NativePlatform'
5
+ import type { PartialBy } from '../types/common'
6
+ import { UnistylesListener } from '../web/listener'
7
+ import { UnistylesShadowRegistry } from '../web'
8
+ import { equal } from '../web/utils'
5
9
 
6
10
  const SUPPORTED_STYLE_PROPS = ['style', 'contentContainerStyle'] as const
11
+ const ALL_DEPENDENCIES = Object.values(UnistyleDependency).filter((dependency): dependency is UnistyleDependency => typeof dependency === 'number')
12
+
13
+ type SupportedStyleProps = typeof SUPPORTED_STYLE_PROPS[number]
14
+
15
+ const useShadowRegistry = (style?: Record<string, any>) => {
16
+ const [classNames, setClassNames] = useState<Array<string>>([])
17
+ const [ref] = useState(document.createElement('div'))
18
+
19
+ if (style) {
20
+ UnistylesShadowRegistry
21
+ .add(ref, style)
22
+ .then(newClassNames => {
23
+ if (equal(classNames, newClassNames)) {
24
+ return
25
+ }
26
+
27
+ setClassNames(newClassNames)
28
+ })
29
+ }
30
+
31
+ useEffect(() => () => {
32
+ // Remove styles on unmount
33
+ UnistylesShadowRegistry.add(null, style)
34
+ })
35
+
36
+ return classNames
37
+ }
38
+
39
+ export const createUnistylesComponent = <TProps extends Record<string, any>, TMappings extends Partial<Omit<TProps, SupportedStyleProps>>>(Component: ComponentType<TProps>, mappings?: (theme: UnistylesTheme) => TMappings) => {
40
+ return (props: PartialBy<TProps, keyof TMappings | SupportedStyleProps>) => {
41
+ const [mappingsProps, setMappingsProps] = useState(mappings?.(UnistylesRuntime.getTheme()))
42
+ const styleClassNames = useShadowRegistry(props.style)
43
+ const contentContainerStyleClassNames = useShadowRegistry(props.contentContainerStyle)
44
+
45
+ useEffect(() => {
46
+ const disposeMappings = UnistylesListener.addListeners(ALL_DEPENDENCIES, () => {
47
+ if (!mappings) {
48
+ disposeMappings()
49
+
50
+ return
51
+ }
52
+
53
+ return setMappingsProps(mappings(UnistylesRuntime.getTheme()))
54
+ })
55
+
56
+ return () => disposeMappings()
57
+ }, [mappingsProps, props.style])
58
+
59
+ const combinedProps = {
60
+ ...mappingsProps,
61
+ ...props,
62
+ ...props.style ? {
63
+ style: {
64
+ $$css: true,
65
+ 'unistyles': styleClassNames.join(' ')
66
+ },
67
+ } : {},
68
+ ...props.contentContainerStyle ? {
69
+ style: {
70
+ $$css: true,
71
+ 'unistyles': contentContainerStyleClassNames.join(' ')
72
+ },
73
+ } : {},
74
+ } as unknown as TProps
7
75
 
8
- export const createUnistylesComponent = <T extends ComponentType<any>>(Component: T, _: Mappings<T> = () => ({})) => {
9
- return (props: ComponentProps<T>) => {
10
- return <Component {...props} />
76
+ return <Component {...combinedProps} />
11
77
  }
12
78
  }
@@ -1,3 +1,4 @@
1
1
  export type Optional<T> = T | undefined
2
2
  export type Nullable<T> = T | null
3
3
  export type SafeReturnType<T> = T extends (...args: any) => infer R ? R : T
4
+ export type PartialBy<T, K> = Omit<T, K & keyof T> & Partial<Pick<T, K & keyof T>>
@@ -2,16 +2,15 @@ import type { UnistylesValues } from '../../types'
2
2
  import { isPseudo } from './pseudo'
3
3
  import { getStyle } from './style'
4
4
  import { deepMergeObjects } from '../utils'
5
- import { getTransformStyle } from './transform'
6
- import { isBoxShadow, isTextShadow, isTransform } from './utils'
7
- import { getTextShadowStyle } from './textShadow'
8
- import { getBoxShadowStyle } from './boxShadow'
5
+ import { getTransformStyle, getBoxShadow, getFilterStyle } from './object'
6
+ import { isShadow, isFilter, isTextShadow, isTransform, isBoxShadow } from './utils'
7
+ import { getTextShadowStyle, getBoxShadowStyle } from './shadow'
9
8
 
10
9
  export const convertUnistyles = (value: UnistylesValues) => {
11
10
  // Flag to mark if textShadow is already created
12
11
  let hasTextShadow = false
13
12
  // Flag to mark if boxShadow is already created
14
- let hasBoxShadow = false
13
+ let hasShadow = false
15
14
 
16
15
  const stylesArray = Object.entries({
17
16
  ...value,
@@ -40,17 +39,25 @@ export const convertUnistyles = (value: UnistylesValues) => {
40
39
  return getTextShadowStyle(value)
41
40
  }
42
41
 
43
- // Box shadow
44
- if (isBoxShadow(unistylesKey)) {
45
- if (hasBoxShadow) {
42
+ // RN shadows
43
+ if (isShadow(unistylesKey)) {
44
+ if (hasShadow) {
46
45
  return []
47
46
  }
48
47
 
49
- hasBoxShadow = true
48
+ hasShadow = true
50
49
 
51
50
  return getBoxShadowStyle(value)
52
51
  }
53
52
 
53
+ if (isFilter(unistylesKey, unistylesValue)) {
54
+ return getFilterStyle(unistylesValue)
55
+ }
56
+
57
+ if (isBoxShadow(unistylesKey, unistylesValue)) {
58
+ return getBoxShadow(unistylesValue)
59
+ }
60
+
54
61
  // Transforms
55
62
  if (isTransform(unistylesKey, unistylesValue)) {
56
63
  return getTransformStyle(unistylesValue)
@@ -0,0 +1,54 @@
1
+ import type { BoxShadowValue } from 'react-native'
2
+ import { normalizeNumericValue } from '../utils'
3
+ import { deepMergeObjects, keyInObject } from '../../utils'
4
+
5
+ const createBoxShadowValue = (style: BoxShadowValue) => {
6
+ const { offsetX, offsetY, blurRadius = 0, spreadDistance = 0, color = '#000', inset } = style
7
+
8
+ return `${inset ? 'inset ' : ''}${normalizeNumericValue(offsetX)} ${normalizeNumericValue(offsetY)} ${normalizeNumericValue(blurRadius as number)} ${normalizeNumericValue(spreadDistance as number)} ${color}`
9
+ }
10
+
11
+ export const getBoxShadow = (boxShadow: Array<BoxShadowValue>) => {
12
+ const breakpoints = new Set<string>()
13
+ boxShadow.forEach(shadow => {
14
+ const [key] = Object.keys(shadow)
15
+ const value = shadow[key as keyof BoxShadowValue]
16
+
17
+ // Breakpoints
18
+ if (typeof value === 'object') {
19
+ Object.keys(value).forEach(breakpoint => breakpoints.add(breakpoint))
20
+ }
21
+ })
22
+
23
+ if (breakpoints.size === 0) {
24
+ const boxShadowStyle = Object.fromEntries(boxShadow.map(shadow => {
25
+ const [key] = Object.keys(shadow)
26
+ return [key, shadow[key as keyof BoxShadowValue]]
27
+ }))
28
+
29
+ return {
30
+ boxShadow: createBoxShadowValue(boxShadowStyle)
31
+ }
32
+ }
33
+
34
+ const breakpointStyles = Array.from(breakpoints).map(breakpoint => {
35
+ const styles = Object.fromEntries(boxShadow.map(shadow => {
36
+ const [key] = Object.keys(shadow)
37
+ const value = shadow[key as keyof BoxShadowValue]
38
+
39
+ if (typeof value === 'object' && keyInObject(value, breakpoint)) {
40
+ return [key, value[breakpoint]]
41
+ }
42
+
43
+ return [key, value]
44
+ }))
45
+
46
+ return {
47
+ [breakpoint]: {
48
+ boxShadow: createBoxShadowValue(styles)
49
+ }
50
+ }
51
+ })
52
+
53
+ return deepMergeObjects(...breakpointStyles)
54
+ }
@@ -0,0 +1,39 @@
1
+ import type { DropShadowValue } from 'react-native'
2
+ import { hyphenate } from '../../utils'
3
+ import type { Filters } from '../types'
4
+ import { getObjectStyle } from './objectStyle'
5
+ import { normalizeColor, normalizeNumericValue } from '../utils'
6
+ import { UnistylesRuntime } from '../../runtime'
7
+ import { isUnistylesMq } from '../../../mq'
8
+
9
+ const getDropShadowStyle = (dropShadow: DropShadowValue) => {
10
+ const { offsetX = 0, offsetY = 0, standardDeviation = 0, color = '#000' } = dropShadow
11
+
12
+ return `${normalizeColor(String(color))} ${normalizeNumericValue(offsetX)} ${normalizeNumericValue(offsetY)} ${normalizeNumericValue(standardDeviation)}`
13
+ }
14
+
15
+ export const getFilterStyle = (filters: Array<Filters>) => {
16
+ const restFilters = filters.filter(filter => Object.keys(filter)[0] !== 'dropShadow')
17
+ const dropShadow = (() => {
18
+ const dropShadowValue = filters.find(filter => Object.keys(filter)[0] === 'dropShadow')?.dropShadow as Record<string, any>
19
+
20
+ if (typeof dropShadowValue !== 'object') {
21
+ return []
22
+ }
23
+
24
+ const breakpoints = Object.keys(dropShadowValue).filter(key => Object.keys(UnistylesRuntime.breakpoints).includes(key) || isUnistylesMq(key))
25
+ const breakpointsDropShadow = Object.fromEntries(breakpoints.map(breakpoint => [breakpoint, getDropShadowStyle(dropShadowValue[breakpoint])]))
26
+
27
+ if (breakpoints.length === 0) {
28
+ return [{
29
+ dropShadow: getDropShadowStyle(dropShadowValue as DropShadowValue)
30
+ }]
31
+ }
32
+
33
+ return [{
34
+ dropShadow: breakpointsDropShadow
35
+ }]
36
+ })()
37
+
38
+ return getObjectStyle([...restFilters, ...dropShadow], 'filter', (key, value) => `${hyphenate(key)}(${normalizeNumericValue(value as number | string)})`)
39
+ }
@@ -0,0 +1,3 @@
1
+ export * from './transform'
2
+ export * from './boxShadow'
3
+ export * from './filter'