react-native-unistyles 3.0.0-alpha.7 → 3.0.0-alpha.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (218) hide show
  1. package/cxx/common/Helpers.h +58 -0
  2. package/cxx/core/Unistyle.h +0 -6
  3. package/cxx/core/UnistyleData.h +3 -2
  4. package/cxx/core/UnistyleWrapper.h +6 -6
  5. package/cxx/core/UnistylesRegistry.cpp +11 -10
  6. package/cxx/core/UnistylesRegistry.h +4 -3
  7. package/cxx/hybridObjects/HybridShadowRegistry.cpp +4 -2
  8. package/cxx/parser/Parser.cpp +24 -78
  9. package/cxx/parser/Parser.h +1 -2
  10. package/lib/commonjs/specs/ShadowRegistry/index.js +2 -2
  11. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  12. package/lib/commonjs/specs/index.web.js +1 -1
  13. package/lib/commonjs/web/convert/boxShadow.js +77 -0
  14. package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
  15. package/lib/commonjs/web/convert/breakpoint.js +25 -0
  16. package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
  17. package/lib/commonjs/web/convert/index.js +76 -0
  18. package/lib/commonjs/web/convert/index.js.map +1 -0
  19. package/lib/commonjs/web/convert/module.d.js +2 -0
  20. package/lib/commonjs/web/convert/module.d.js.map +1 -0
  21. package/lib/commonjs/web/convert/shadow.js +68 -0
  22. package/lib/commonjs/web/convert/shadow.js.map +1 -0
  23. package/lib/commonjs/web/convert/style.js +89 -0
  24. package/lib/commonjs/web/convert/style.js.map +1 -0
  25. package/lib/commonjs/web/convert/textShadow.js +73 -0
  26. package/lib/commonjs/web/convert/textShadow.js.map +1 -0
  27. package/lib/commonjs/web/convert/transform.js +72 -0
  28. package/lib/commonjs/web/convert/transform.js.map +1 -0
  29. package/lib/commonjs/web/convert/types.js +9 -0
  30. package/lib/commonjs/web/convert/types.js.map +1 -0
  31. package/lib/commonjs/web/convert/utils.js +55 -0
  32. package/lib/commonjs/web/convert/utils.js.map +1 -0
  33. package/lib/commonjs/web/create.js +89 -0
  34. package/lib/commonjs/web/create.js.map +1 -0
  35. package/lib/commonjs/web/index.js +51 -0
  36. package/lib/commonjs/web/index.js.map +1 -0
  37. package/lib/commonjs/web/listener/index.js +13 -0
  38. package/lib/commonjs/web/listener/index.js.map +1 -0
  39. package/lib/commonjs/web/listener/listener.js +36 -0
  40. package/lib/commonjs/web/listener/listener.js.map +1 -0
  41. package/lib/commonjs/web/mock.js +37 -0
  42. package/lib/commonjs/web/mock.js.map +1 -0
  43. package/lib/commonjs/web/mq.js +23 -0
  44. package/lib/commonjs/web/mq.js.map +1 -0
  45. package/lib/commonjs/web/pseudo.js +11 -0
  46. package/lib/commonjs/web/pseudo.js.map +1 -0
  47. package/lib/commonjs/web/registry.js +37 -0
  48. package/lib/commonjs/web/registry.js.map +1 -0
  49. package/lib/commonjs/web/runtime.js +164 -0
  50. package/lib/commonjs/web/runtime.js.map +1 -0
  51. package/lib/commonjs/web/state.js +121 -0
  52. package/lib/commonjs/web/state.js.map +1 -0
  53. package/lib/commonjs/web/utils.js +78 -0
  54. package/lib/commonjs/web/utils.js.map +1 -0
  55. package/lib/commonjs/web/variants/getVariants.js +39 -0
  56. package/lib/commonjs/web/variants/getVariants.js.map +1 -0
  57. package/lib/commonjs/web/variants/index.js +28 -0
  58. package/lib/commonjs/web/variants/index.js.map +1 -0
  59. package/lib/commonjs/web/variants/useVariants.js +75 -0
  60. package/lib/commonjs/web/variants/useVariants.js.map +1 -0
  61. package/lib/module/specs/ShadowRegistry/index.js +2 -2
  62. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  63. package/lib/module/specs/index.web.js +1 -1
  64. package/lib/module/specs/index.web.js.map +1 -1
  65. package/lib/module/web/convert/boxShadow.js +72 -0
  66. package/lib/module/web/convert/boxShadow.js.map +1 -0
  67. package/lib/module/web/convert/breakpoint.js +20 -0
  68. package/lib/module/web/convert/breakpoint.js.map +1 -0
  69. package/lib/module/web/convert/index.js +71 -0
  70. package/lib/module/web/convert/index.js.map +1 -0
  71. package/lib/module/web/convert/module.d.js +2 -0
  72. package/lib/module/web/convert/module.d.js.map +1 -0
  73. package/lib/module/web/convert/shadow.js +63 -0
  74. package/lib/module/web/convert/shadow.js.map +1 -0
  75. package/lib/module/web/convert/style.js +84 -0
  76. package/lib/module/web/convert/style.js.map +1 -0
  77. package/lib/module/web/convert/textShadow.js +68 -0
  78. package/lib/module/web/convert/textShadow.js.map +1 -0
  79. package/lib/module/web/convert/transform.js +67 -0
  80. package/lib/module/web/convert/transform.js.map +1 -0
  81. package/lib/module/web/convert/types.js +5 -0
  82. package/lib/module/web/convert/types.js.map +1 -0
  83. package/lib/module/web/convert/utils.js +43 -0
  84. package/lib/module/web/convert/utils.js.map +1 -0
  85. package/lib/module/web/create.js +84 -0
  86. package/lib/module/web/create.js.map +1 -0
  87. package/lib/module/web/index.js +24 -0
  88. package/lib/module/web/index.js.map +1 -0
  89. package/lib/module/web/listener/index.js +4 -0
  90. package/lib/module/web/listener/index.js.map +1 -0
  91. package/lib/module/web/listener/listener.js +31 -0
  92. package/lib/module/web/listener/listener.js.map +1 -0
  93. package/lib/module/web/mock.js +33 -0
  94. package/lib/module/web/mock.js.map +1 -0
  95. package/lib/module/web/mq.js +17 -0
  96. package/lib/module/web/mq.js.map +1 -0
  97. package/lib/module/web/pseudo.js +6 -0
  98. package/lib/module/web/pseudo.js.map +1 -0
  99. package/lib/module/web/registry.js +33 -0
  100. package/lib/module/web/registry.js.map +1 -0
  101. package/lib/module/web/runtime.js +160 -0
  102. package/lib/module/web/runtime.js.map +1 -0
  103. package/lib/module/web/state.js +117 -0
  104. package/lib/module/web/state.js.map +1 -0
  105. package/lib/module/web/utils.js +65 -0
  106. package/lib/module/web/utils.js.map +1 -0
  107. package/lib/module/web/variants/getVariants.js +34 -0
  108. package/lib/module/web/variants/getVariants.js.map +1 -0
  109. package/lib/module/web/variants/index.js +5 -0
  110. package/lib/module/web/variants/index.js.map +1 -0
  111. package/lib/module/web/variants/useVariants.js +70 -0
  112. package/lib/module/web/variants/useVariants.js.map +1 -0
  113. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
  114. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  115. package/lib/typescript/src/specs/index.web.d.ts +1 -1
  116. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  117. package/lib/typescript/src/types/stylesheet.d.ts +1 -1
  118. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  119. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
  120. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
  121. package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
  122. package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
  123. package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
  124. package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
  125. package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
  126. package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
  127. package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
  128. package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
  129. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
  130. package/lib/typescript/{web → src/web}/create.d.ts +11 -11
  131. package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
  132. package/lib/typescript/{web → src/web}/index.d.ts +12 -12
  133. package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
  134. package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
  135. package/lib/typescript/{web → src/web}/listener/listener.d.ts +1 -1
  136. package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
  137. package/lib/typescript/{web → src/web}/mock.d.ts +2 -2
  138. package/lib/typescript/src/web/mock.d.ts.map +1 -0
  139. package/lib/typescript/src/web/mq.d.ts.map +1 -0
  140. package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
  141. package/lib/typescript/{web → src/web}/registry.d.ts +1 -1
  142. package/lib/typescript/src/web/registry.d.ts.map +1 -0
  143. package/lib/typescript/{web → src/web}/runtime.d.ts +6 -6
  144. package/lib/typescript/src/web/runtime.d.ts.map +1 -0
  145. package/lib/typescript/{web → src/web}/state.d.ts +4 -4
  146. package/lib/typescript/src/web/state.d.ts.map +1 -0
  147. package/lib/typescript/{web → src/web}/utils.d.ts +5 -3
  148. package/lib/typescript/src/web/utils.d.ts.map +1 -0
  149. package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
  150. package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
  151. package/lib/typescript/src/web/variants/index.d.ts +3 -0
  152. package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
  153. package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
  154. package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
  155. package/package.json +1 -1
  156. package/plugin/__tests__/dependencies.spec.js +5 -5
  157. package/plugin/__tests__/ref.spec.js +132 -17
  158. package/plugin/__tests__/stylesheet.spec.js +9 -9
  159. package/plugin/index.js +12 -13
  160. package/plugin/ref.js +18 -14
  161. package/plugin/style.js +13 -7
  162. package/src/specs/ShadowRegistry/index.ts +4 -4
  163. package/src/specs/index.web.ts +1 -1
  164. package/src/types/stylesheet.ts +1 -1
  165. package/{web → src/web}/convert/breakpoint.ts +1 -1
  166. package/{web → src/web}/convert/index.ts +1 -1
  167. package/{web → src/web}/convert/types.ts +1 -1
  168. package/{web → src/web}/create.ts +36 -33
  169. package/{web → src/web}/listener/listener.ts +1 -1
  170. package/{web → src/web}/mock.ts +2 -2
  171. package/{web → src/web}/registry.ts +1 -1
  172. package/{web → src/web}/runtime.ts +4 -4
  173. package/{web → src/web}/state.ts +5 -5
  174. package/{web → src/web}/utils.ts +5 -5
  175. package/src/web/variants/getVariants.ts +42 -0
  176. package/src/web/variants/index.ts +2 -0
  177. package/{web → src/web/variants}/useVariants.ts +24 -44
  178. package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
  179. package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
  180. package/lib/typescript/web/convert/index.d.ts.map +0 -1
  181. package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
  182. package/lib/typescript/web/convert/style.d.ts.map +0 -1
  183. package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
  184. package/lib/typescript/web/convert/transform.d.ts.map +0 -1
  185. package/lib/typescript/web/convert/types.d.ts.map +0 -1
  186. package/lib/typescript/web/convert/utils.d.ts.map +0 -1
  187. package/lib/typescript/web/listener/index.d.ts.map +0 -1
  188. package/lib/typescript/web/listener/listener.d.ts.map +0 -1
  189. package/lib/typescript/web/mock.d.ts.map +0 -1
  190. package/lib/typescript/web/mq.d.ts.map +0 -1
  191. package/lib/typescript/web/pseudo.d.ts.map +0 -1
  192. package/lib/typescript/web/registry.d.ts.map +0 -1
  193. package/lib/typescript/web/runtime.d.ts.map +0 -1
  194. package/lib/typescript/web/state.d.ts.map +0 -1
  195. package/lib/typescript/web/useVariants.d.ts +0 -3
  196. package/lib/typescript/web/useVariants.d.ts.map +0 -1
  197. package/lib/typescript/web/utils.d.ts.map +0 -1
  198. /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
  199. /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
  200. /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
  201. /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
  202. /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
  203. /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
  204. /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
  205. /package/lib/typescript/{web → src/web}/listener/index.d.ts +0 -0
  206. /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
  207. /package/lib/typescript/{web → src/web}/pseudo.d.ts +0 -0
  208. /package/{web → src/web}/convert/boxShadow.ts +0 -0
  209. /package/{web → src/web}/convert/module.d.ts +0 -0
  210. /package/{web → src/web}/convert/shadow.ts +0 -0
  211. /package/{web → src/web}/convert/style.ts +0 -0
  212. /package/{web → src/web}/convert/textShadow.ts +0 -0
  213. /package/{web → src/web}/convert/transform.ts +0 -0
  214. /package/{web → src/web}/convert/utils.ts +0 -0
  215. /package/{web → src/web}/index.ts +0 -0
  216. /package/{web → src/web}/listener/index.ts +0 -0
  217. /package/{web → src/web}/mq.ts +0 -0
  218. /package/{web → src/web}/pseudo.ts +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getVariants.d.ts","sourceRoot":"","sources":["../../../../../src/web/variants/getVariants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAWpE,eAAO,MAAM,WAAW,WAAY,qBAAqB,CAAC,UAAU,CAAC,oBAAoB,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,+BA8B3G,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './useVariants';
2
+ export * from './getVariants';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/web/variants/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { ReactNativeStyleSheet, StyleSheet } from '../../types';
2
+ export declare const createUseVariants: (styles: ReactNativeStyleSheet<StyleSheet>, setSelectedVariants: (variants: Record<string, any>) => void) => void;
3
+ //# sourceMappingURL=useVariants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVariants.d.ts","sourceRoot":"","sources":["../../../../../src/web/variants/useVariants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAKpE,eAAO,MAAM,iBAAiB,WAAY,qBAAqB,CAAC,UAAU,CAAC,uBAAuB,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,IAAI,SAuExI,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-unistyles",
3
- "version": "3.0.0-alpha.7",
3
+ "version": "3.0.0-alpha.9",
4
4
  "description": "Level up your React Native StyleSheet",
5
5
  "scripts": {
6
6
  "test": "jest",
@@ -51,7 +51,7 @@ pluginTester({
51
51
  <View
52
52
  style={styles.container}
53
53
  ref={ref => {
54
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
54
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
55
55
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
56
56
  }}
57
57
  >
@@ -112,7 +112,7 @@ pluginTester({
112
112
  <View
113
113
  style={styles.container}
114
114
  ref={ref => {
115
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
115
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
116
116
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
117
117
  }}
118
118
  >
@@ -167,7 +167,7 @@ pluginTester({
167
167
  <View
168
168
  style={styles.container}
169
169
  ref={ref => {
170
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
170
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
171
171
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
172
172
  }}
173
173
  >
@@ -280,7 +280,7 @@ pluginTester({
280
280
  <View
281
281
  style={styles.container}
282
282
  ref={ref => {
283
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
283
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
284
284
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
285
285
  }}
286
286
  >
@@ -405,7 +405,7 @@ pluginTester({
405
405
  <View
406
406
  style={styles.container}
407
407
  ref={ref => {
408
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
408
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
409
409
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
410
410
  }}
411
411
  >
@@ -78,7 +78,7 @@ pluginTester({
78
78
  <View
79
79
  style={styles.container}
80
80
  ref={ref => {
81
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
81
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
82
82
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
83
83
  }}
84
84
  >
@@ -131,7 +131,7 @@ pluginTester({
131
131
  <View
132
132
  ref={_ref => {
133
133
  ref.current = _ref
134
- UnistylesShadowRegistry.add(_ref, styles.container, undefined)
134
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
135
135
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
136
136
  }}
137
137
  style={styles.container}
@@ -192,7 +192,7 @@ pluginTester({
192
192
  ref={ref => {
193
193
  doSomething(ref)
194
194
  myRef.current = ref
195
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
195
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
196
196
  return () => {
197
197
  UnistylesShadowRegistry.remove(ref, styles.container)
198
198
  }
@@ -259,7 +259,7 @@ pluginTester({
259
259
  ref={ref => {
260
260
  doSomething(ref)
261
261
  myRef.current = ref
262
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
262
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
263
263
  return () => {
264
264
  ;(() => {
265
265
  customCleanup()
@@ -333,7 +333,7 @@ pluginTester({
333
333
  <View
334
334
  ref={_ref => {
335
335
  fn(_ref)
336
- UnistylesShadowRegistry.add(_ref, styles.container, undefined)
336
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
337
337
  return () => {
338
338
  ;(() => {
339
339
  customCleanup2()
@@ -407,7 +407,7 @@ pluginTester({
407
407
  <View
408
408
  ref={_ref => {
409
409
  fn(_ref)
410
- UnistylesShadowRegistry.add(_ref, styles.container, undefined)
410
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
411
411
  return () => {
412
412
  ;(() => {
413
413
  customCleanup2()
@@ -637,7 +637,7 @@ pluginTester({
637
637
  <View
638
638
  ref={_ref => {
639
639
  myRef.current = _ref
640
- UnistylesShadowRegistry.add(_ref, styles.container, undefined)
640
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
641
641
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
642
642
  }}
643
643
  style={{
@@ -704,7 +704,7 @@ pluginTester({
704
704
  <View
705
705
  ref={_ref => {
706
706
  myRef.current = _ref
707
- UnistylesShadowRegistry.add(_ref, styles.container, undefined)
707
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
708
708
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
709
709
  }}
710
710
  style={[
@@ -766,7 +766,7 @@ pluginTester({
766
766
  <View
767
767
  ref={_ref => {
768
768
  myRef.current = _ref
769
- UnistylesShadowRegistry.add(_ref, styles.container, undefined)
769
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
770
770
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
771
771
  }}
772
772
  style={[styles.container]}
@@ -825,7 +825,7 @@ pluginTester({
825
825
  <View
826
826
  ref={_ref => {
827
827
  myRef.current = _ref
828
- UnistylesShadowRegistry.add(_ref, styles.container, undefined)
828
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, [1, 2])
829
829
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
830
830
  }}
831
831
  style={[styles.container(1, 2)]}
@@ -885,13 +885,10 @@ pluginTester({
885
885
  <View
886
886
  ref={_ref => {
887
887
  myRef.current = _ref
888
- UnistylesShadowRegistry.add(_ref, styles.container, undefined)
888
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, [1, 2])
889
889
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
890
890
  }}
891
- style={{
892
- backgroundColor: 'red',
893
- ...styles.container(1, 2)
894
- }}
891
+ style={{ backgroundColor: 'red', ...styles.container(1, 2) }}
895
892
  >
896
893
  <Text>Hello world</Text>
897
894
  </View>
@@ -963,7 +960,7 @@ pluginTester({
963
960
  <View
964
961
  ref={_ref => {
965
962
  myRef.current = _ref
966
- UnistylesShadowRegistry.add(_ref, uhh.dkk, __uni__variants)
963
+ UnistylesShadowRegistry.add(_ref, uhh.dkk, __uni__variants, [])
967
964
  return () => UnistylesShadowRegistry.remove(_ref, uhh.dkk)
968
965
  }}
969
966
  style={uhh.dkk()}
@@ -1031,7 +1028,7 @@ pluginTester({
1031
1028
  <View
1032
1029
  ref={_ref => {
1033
1030
  myRef.current = _ref
1034
- UnistylesShadowRegistry.add(_ref, uhh.dkk, undefined)
1031
+ UnistylesShadowRegistry.add(_ref, uhh.dkk, undefined, [])
1035
1032
  return () => UnistylesShadowRegistry.remove(_ref, uhh.dkk)
1036
1033
  }}
1037
1034
  style={uhh.dkk()}
@@ -1050,6 +1047,124 @@ pluginTester({
1050
1047
  921918562
1051
1048
  )
1052
1049
  `
1050
+ },
1051
+ {
1052
+ title: 'Should pass ref for dynamic functions to bind it to shadow node',
1053
+ code: `
1054
+ import { StyleSheet } from 'react-native-unistyles'
1055
+
1056
+ export const Example = () => {
1057
+ return (
1058
+ <React.Fragment>
1059
+ <View style={styles.container(1, 5)} />
1060
+ <View style={styles.container(2, 6)} />
1061
+ <View style={styles.container(5, 1)} />
1062
+ </React.Fragment>
1063
+ )
1064
+ }
1065
+
1066
+ const styles = StyleSheet.create({
1067
+ container: (flex, gap) => ({
1068
+ flex,
1069
+ gap
1070
+ })
1071
+ })
1072
+ `,
1073
+ output: `
1074
+ import { UnistylesShadowRegistry } from 'react-native-unistyles'
1075
+ import { StyleSheet } from 'react-native-unistyles'
1076
+
1077
+ export const Example = () => {
1078
+ return (
1079
+ <React.Fragment>
1080
+ <View
1081
+ style={styles.container(1, 5)}
1082
+ ref={ref => {
1083
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, [1, 5])
1084
+ return () => UnistylesShadowRegistry.remove(ref, styles.container)
1085
+ }}
1086
+ />
1087
+ <View
1088
+ style={styles.container(2, 6)}
1089
+ ref={ref => {
1090
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, [2, 6])
1091
+ return () => UnistylesShadowRegistry.remove(ref, styles.container)
1092
+ }}
1093
+ />
1094
+ <View
1095
+ style={styles.container(5, 1)}
1096
+ ref={ref => {
1097
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, [5, 1])
1098
+ return () => UnistylesShadowRegistry.remove(ref, styles.container)
1099
+ }}
1100
+ />
1101
+ </React.Fragment>
1102
+ )
1103
+ }
1104
+
1105
+ const styles = StyleSheet.create(
1106
+ {
1107
+ container: (flex, gap) => ({
1108
+ flex,
1109
+ gap
1110
+ })
1111
+ },
1112
+ 921918562
1113
+ )
1114
+ `
1115
+ },
1116
+ {
1117
+ title: 'Should pass refs for dynamic functions',
1118
+ code: `
1119
+ import { StyleSheet } from 'react-native-unistyles'
1120
+
1121
+ export const Example = () => {
1122
+ return (
1123
+ <React.Fragment>
1124
+ <View style={[styles.container(1, 5), styles.container2(1, 6)]} />
1125
+ </React.Fragment>
1126
+ )
1127
+ }
1128
+
1129
+ const styles = StyleSheet.create({
1130
+ container: (flex, gap) => ({
1131
+ flex,
1132
+ gap
1133
+ })
1134
+ })
1135
+ `,
1136
+ output: `
1137
+ import { UnistylesShadowRegistry } from 'react-native-unistyles'
1138
+ import { StyleSheet } from 'react-native-unistyles'
1139
+
1140
+ export const Example = () => {
1141
+ return (
1142
+ <React.Fragment>
1143
+ <View
1144
+ style={[styles.container(1, 5), styles.container2(1, 6)]}
1145
+ ref={ref => {
1146
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, [1, 5])
1147
+ UnistylesShadowRegistry.add(ref, styles.container2, undefined, [1, 6])
1148
+ return () => {
1149
+ ;(() => UnistylesShadowRegistry.remove(ref, styles.container))()
1150
+ UnistylesShadowRegistry.remove(ref, styles.container2)
1151
+ }
1152
+ }}
1153
+ />
1154
+ </React.Fragment>
1155
+ )
1156
+ }
1157
+
1158
+ const styles = StyleSheet.create(
1159
+ {
1160
+ container: (flex, gap) => ({
1161
+ flex,
1162
+ gap
1163
+ })
1164
+ },
1165
+ 921918562
1166
+ )
1167
+ `
1053
1168
  }
1054
1169
  ]
1055
1170
  })
@@ -41,7 +41,7 @@ pluginTester({
41
41
  <View
42
42
  style={styles.container}
43
43
  ref={ref => {
44
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
44
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
45
45
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
46
46
  }}
47
47
  >
@@ -88,7 +88,7 @@ pluginTester({
88
88
  <View
89
89
  style={styles.container}
90
90
  ref={ref => {
91
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
91
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
92
92
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
93
93
  }}
94
94
  >
@@ -136,7 +136,7 @@ pluginTester({
136
136
  <View
137
137
  style={styles.container}
138
138
  ref={ref => {
139
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
139
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
140
140
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
141
141
  }}
142
142
  >
@@ -185,7 +185,7 @@ pluginTester({
185
185
  <View
186
186
  style={styles.container}
187
187
  ref={ref => {
188
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
188
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
189
189
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
190
190
  }}
191
191
  >
@@ -235,7 +235,7 @@ pluginTester({
235
235
  <View
236
236
  style={styles.container}
237
237
  ref={ref => {
238
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
238
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
239
239
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
240
240
  }}
241
241
  >
@@ -286,7 +286,7 @@ pluginTester({
286
286
  <View
287
287
  style={styles.container}
288
288
  ref={ref => {
289
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
289
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
290
290
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
291
291
  }}
292
292
  >
@@ -338,7 +338,7 @@ pluginTester({
338
338
  <View
339
339
  style={styles.container}
340
340
  ref={ref => {
341
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
341
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
342
342
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
343
343
  }}
344
344
  >
@@ -392,7 +392,7 @@ pluginTester({
392
392
  <View
393
393
  style={styles.container}
394
394
  ref={ref => {
395
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
395
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
396
396
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
397
397
  }}
398
398
  >
@@ -454,7 +454,7 @@ pluginTester({
454
454
  <View
455
455
  style={styles.container}
456
456
  ref={ref => {
457
- UnistylesShadowRegistry.add(ref, styles.container, undefined)
457
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
458
458
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
459
459
  }}
460
460
  >
package/plugin/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const addShadowRegistryImport = require('./import')
2
- const { getStyleObjectPath, getStyleAttribute } = require('./style')
2
+ const { getStyleMetadata, getStyleAttribute } = require('./style')
3
3
  const { getRefProp, addRef, overrideRef, hasStringRef } = require('./ref')
4
4
  const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyle } = require('./stylesheet')
5
5
  const { isUsingVariants, extractVariants } = require('./variants')
@@ -46,28 +46,27 @@ module.exports = function ({ types: t }) {
46
46
  return
47
47
  }
48
48
 
49
- const stylePath = getStyleObjectPath(t, styleAttr.value.expression)
49
+ const metadata = getStyleMetadata(t, styleAttr.value.expression)
50
50
 
51
51
  // style prop is not using object expression
52
- if (stylePath.length !== 2) {
52
+ if (metadata.length === 0) {
53
53
  return
54
54
  }
55
55
 
56
56
  // to add import
57
57
  state.file.hasAnyUnistyle = true
58
58
 
59
- const refProp = getRefProp(t, path)
59
+ metadata.forEach(meta => {
60
+ const refProp = getRefProp(t, path)
60
61
 
61
- if (!refProp && hasStringRef(t, path)) {
62
- throw new Error("Detected string based ref which is not supported by Unistyles.")
63
- }
64
-
65
- const styleObj = stylePath[0]
66
- const styleProp = stylePath[1]
62
+ if (!refProp && hasStringRef(t, path)) {
63
+ throw new Error("Detected string based ref which is not supported by Unistyles.")
64
+ }
67
65
 
68
- refProp
69
- ? overrideRef(t, path, refProp, styleObj, styleProp, state)
70
- : addRef(t, path, styleObj, styleProp, state)
66
+ refProp
67
+ ? overrideRef(t, path, refProp, meta, state)
68
+ : addRef(t, path, meta, state)
69
+ })
71
70
  },
72
71
  CallExpression(path, state) {
73
72
  if (isUsingVariants(t, path)) {
package/plugin/ref.js CHANGED
@@ -14,7 +14,7 @@ function hasStringRef(t, path) {
14
14
  )
15
15
  }
16
16
 
17
- function addRef(t, path, styleObj, styleProp, state) {
17
+ function addRef(t, path, metadata, state) {
18
18
  const hasVariants = state.file.hasVariants
19
19
 
20
20
  const newRefFunction = t.arrowFunctionExpression(
@@ -25,8 +25,9 @@ function addRef(t, path, styleObj, styleProp, state) {
25
25
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
26
26
  [
27
27
  t.identifier('ref'),
28
- t.memberExpression(t.identifier(styleObj), t.identifier(styleProp)),
29
- t.identifier(hasVariants ? '__uni__variants' : 'undefined')
28
+ t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp)),
29
+ t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
30
+ metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
30
31
  ]
31
32
  )
32
33
  ),
@@ -34,7 +35,7 @@ function addRef(t, path, styleObj, styleProp, state) {
34
35
  t.arrowFunctionExpression([],
35
36
  t.callExpression(
36
37
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('remove')),
37
- [t.identifier('ref'), t.memberExpression(t.identifier(styleObj), t.identifier(styleProp))]
38
+ [t.identifier('ref'), t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))]
38
39
  )
39
40
  )
40
41
  )
@@ -49,7 +50,7 @@ function addRef(t, path, styleObj, styleProp, state) {
49
50
  path.node.openingElement.attributes.push(newRefProp)
50
51
  }
51
52
 
52
- function overrideRef(t, path, refProp, styleObj, styleProp, state) {
53
+ function overrideRef(t, path, refProp, metadata, state) {
53
54
  const hasVariants = state.file.hasVariants
54
55
  const uniqueRefName = path.scope.generateUidIdentifier('ref').name
55
56
  const isIdentifier = t.isIdentifier(refProp.value.expression)
@@ -74,8 +75,9 @@ function overrideRef(t, path, refProp, styleObj, styleProp, state) {
74
75
 
75
76
  [
76
77
  t.identifier(uniqueRefName),
77
- t.memberExpression(t.identifier(styleObj), t.identifier(styleProp)),
78
- t.identifier(hasVariants ? '__uni__variants' : 'undefined')
78
+ t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp)),
79
+ t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
80
+ metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
79
81
  ]
80
82
  )
81
83
  ),
@@ -83,7 +85,7 @@ function overrideRef(t, path, refProp, styleObj, styleProp, state) {
83
85
  t.arrowFunctionExpression([],
84
86
  t.callExpression(
85
87
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('remove')),
86
- [t.identifier(uniqueRefName), t.memberExpression(t.identifier(styleObj), t.identifier(styleProp))]
88
+ [t.identifier(uniqueRefName), t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))]
87
89
  )
88
90
  )
89
91
  )
@@ -113,8 +115,9 @@ function overrideRef(t, path, refProp, styleObj, styleProp, state) {
113
115
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
114
116
  [
115
117
  t.identifier('ref'),
116
- t.memberExpression(t.identifier(styleObj), t.identifier(styleProp)),
117
- t.identifier(hasVariants ? '__uni__variants' : 'undefined')
118
+ t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp)),
119
+ t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
120
+ metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
118
121
  ]
119
122
  )
120
123
  ),
@@ -129,7 +132,7 @@ function overrideRef(t, path, refProp, styleObj, styleProp, state) {
129
132
  t.expressionStatement(
130
133
  t.callExpression(
131
134
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('remove')),
132
- [t.identifier('ref'), t.memberExpression(t.identifier(styleObj), t.identifier(styleProp))]
135
+ [t.identifier('ref'), t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))]
133
136
  )
134
137
  )
135
138
  ]))
@@ -172,8 +175,9 @@ function overrideRef(t, path, refProp, styleObj, styleProp, state) {
172
175
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('add')),
173
176
  [
174
177
  t.identifier(uniqueRefName),
175
- t.memberExpression(t.identifier(styleObj), t.identifier(styleProp)),
176
- t.identifier(hasVariants ? '__uni__variants' : 'undefined')
178
+ t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp)),
179
+ t.identifier(hasVariants ? '__uni__variants' : 'undefined'),
180
+ metadata.dynamicFunction ? t.arrayExpression(metadata.dynamicFunction.arguments) : t.identifier('undefined')
177
181
  ]
178
182
  )
179
183
  ),
@@ -187,7 +191,7 @@ function overrideRef(t, path, refProp, styleObj, styleProp, state) {
187
191
  t.expressionStatement(
188
192
  t.callExpression(
189
193
  t.memberExpression(t.identifier('UnistylesShadowRegistry'), t.identifier('remove')),
190
- [t.identifier(uniqueRefName), t.memberExpression(t.identifier(styleObj), t.identifier(styleProp))]
194
+ [t.identifier(uniqueRefName), t.memberExpression(t.identifier(metadata.styleObj), t.identifier(metadata.styleProp))]
191
195
  )
192
196
  )
193
197
  ]))
package/plugin/style.js CHANGED
@@ -1,27 +1,33 @@
1
- function getStyleObjectPath(t, node) {
1
+ function getStyleMetadata(t, node, dynamicFunction = null) {
2
2
  // {styles.container}
3
3
  if (t.isMemberExpression(node)) {
4
- return [node.object.name, node.property.name]
4
+ return [
5
+ {
6
+ styleObj: node.object.name,
7
+ styleProp: node.property.name,
8
+ dynamicFunction
9
+ }
10
+ ]
5
11
  }
6
12
 
7
13
  // [styles.container]
8
14
  if (t.isArrayExpression(node)) {
9
- return node.elements.flatMap(element => getStyleObjectPath(t, element))
15
+ return node.elements.flatMap(element => getStyleMetadata(t, element))
10
16
  }
11
17
 
12
18
  // [...styles.container]
13
19
  if (t.isSpreadElement(node)) {
14
- return getStyleObjectPath(t, node.argument)
20
+ return getStyleMetadata(t, node.argument)
15
21
  }
16
22
 
17
23
  // {{ ...styles.container }}
18
24
  if (t.isObjectExpression(node)) {
19
- return node.properties.flatMap(prop => getStyleObjectPath(t, prop.argument))
25
+ return node.properties.flatMap(prop => getStyleMetadata(t, prop.argument))
20
26
  }
21
27
 
22
28
  // {styles.container(arg1, arg2)}
23
29
  if (t.isCallExpression(node)) {
24
- return getStyleObjectPath(t, node.callee)
30
+ return getStyleMetadata(t, node.callee, node)
25
31
  }
26
32
 
27
33
  return []
@@ -36,6 +42,6 @@ function getStyleAttribute(t, path) {
36
42
  }
37
43
 
38
44
  module.exports = {
39
- getStyleObjectPath,
45
+ getStyleMetadata,
40
46
  getStyleAttribute
41
47
  }
@@ -4,10 +4,10 @@ import type { ShadowNode, Unistyle, ViewHandle } from './types'
4
4
 
5
5
  interface ShadowRegistry extends UnistylesShadowRegistrySpec {
6
6
  // Babel API
7
- add(handle?: ViewHandle, style?: Unistyle, variants?: Record<string, string | boolean>): void,
7
+ add(handle?: ViewHandle, style?: Unistyle, variants?: Record<string, string | boolean>, args?: Array<any>): void,
8
8
  remove(handle?: ViewHandle, style?: Unistyle): void,
9
9
  // JSI
10
- link(node: ShadowNode, style: Unistyle, variants?: Record<string, string | boolean>): void,
10
+ link(node: ShadowNode, style: Unistyle, variants?: Record<string, string | boolean>, args?: Array<any>): void,
11
11
  unlink(node: ShadowNode, style: Unistyle): void
12
12
  }
13
13
 
@@ -26,12 +26,12 @@ const findShadowNodeForHandle = (handle: ViewHandle) => {
26
26
  return node
27
27
  }
28
28
 
29
- HybridShadowRegistry.add = (handle, style, variants) => {
29
+ HybridShadowRegistry.add = (handle, style, variants, args) => {
30
30
  if (!handle || !style?.__unid) {
31
31
  return
32
32
  }
33
33
 
34
- HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {})
34
+ HybridShadowRegistry.link(findShadowNodeForHandle(handle), style, variants ?? {}, args ?? [])
35
35
  }
36
36
 
37
37
  HybridShadowRegistry.remove = (handle, style) => {
@@ -2,4 +2,4 @@ import type { ReactElement } from 'react'
2
2
 
3
3
  export const getSSRUnistyles = () => [] as Array<ReactElement>
4
4
 
5
- export * from '../../web'
5
+ export * from '../web'
@@ -5,7 +5,7 @@ import type { UnistylesMiniRuntime } from '../specs'
5
5
  import type { ReactNativeStyleSheet } from './breakpoints'
6
6
  import type { ExtractVariantNames } from './variants'
7
7
  import type { CSSProperties } from 'react'
8
- import type { Pseudo } from '../../web/pseudo'
8
+ import type { Pseudo } from '../web/pseudo'
9
9
 
10
10
  // these props are treated differently to nest breakpoints and media queries
11
11
  type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset'
@@ -2,7 +2,7 @@ import type { MediaQuery } from 'typestyle/lib/types'
2
2
  import { UnistylesState } from '../state'
3
3
  import { keyInObject } from '../utils'
4
4
  import { isUnistylesMq, parseMq } from '../mq'
5
- import { Orientation } from '../../src/specs/types'
5
+ import { Orientation } from '../../specs/types'
6
6
 
7
7
  export const convertBreakpoint = (breakpoint: string): MediaQuery => {
8
8
  if (Object.values(Orientation).includes(breakpoint as Orientation)) {