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

Sign up to get free protection for your applications and to get access to all the features.
Files changed (262) hide show
  1. package/Unistyles.podspec +33 -0
  2. package/cxx/common/Constants.h +1 -0
  3. package/cxx/common/Helpers.h +92 -0
  4. package/cxx/core/HostStyle.cpp +18 -12
  5. package/cxx/core/HostStyle.h +3 -0
  6. package/cxx/core/StyleSheet.h +0 -1
  7. package/cxx/core/StyleSheetRegistry.cpp +10 -13
  8. package/cxx/core/StyleSheetRegistry.h +4 -4
  9. package/cxx/core/Unistyle.h +0 -6
  10. package/cxx/core/UnistyleData.h +23 -0
  11. package/cxx/core/UnistyleWrapper.h +6 -6
  12. package/cxx/core/UnistylesCommitHook.cpp +8 -7
  13. package/cxx/core/UnistylesCommitHook.h +6 -1
  14. package/cxx/core/UnistylesCommitShadowNode.h +13 -0
  15. package/cxx/core/UnistylesMountHook.cpp +40 -0
  16. package/cxx/core/UnistylesMountHook.h +30 -0
  17. package/cxx/core/UnistylesRegistry.cpp +42 -56
  18. package/cxx/core/UnistylesRegistry.h +10 -8
  19. package/cxx/core/UnistylesState.cpp +4 -4
  20. package/cxx/hybridObjects/HybridShadowRegistry.cpp +8 -1
  21. package/cxx/hybridObjects/HybridStyleSheet.cpp +35 -39
  22. package/cxx/hybridObjects/HybridStyleSheet.h +9 -6
  23. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +34 -15
  24. package/cxx/hybridObjects/HybridUnistylesRuntime.h +2 -0
  25. package/cxx/parser/Parser.cpp +65 -137
  26. package/cxx/parser/Parser.h +8 -14
  27. package/ios/UnistylesModuleOnLoad.h +2 -0
  28. package/ios/UnistylesModuleOnLoad.mm +8 -1
  29. package/lib/commonjs/specs/NavigtionBar/index.js +1 -1
  30. package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
  31. package/lib/commonjs/specs/ShadowRegistry/index.js +2 -2
  32. package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
  33. package/lib/commonjs/specs/StatusBar/index.js +1 -1
  34. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  35. package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
  36. package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
  37. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  38. package/lib/commonjs/specs/index.web.js +1 -1
  39. package/lib/commonjs/web/convert/boxShadow.js +77 -0
  40. package/lib/commonjs/web/convert/boxShadow.js.map +1 -0
  41. package/lib/commonjs/web/convert/breakpoint.js +25 -0
  42. package/lib/commonjs/web/convert/breakpoint.js.map +1 -0
  43. package/lib/commonjs/web/convert/index.js +76 -0
  44. package/lib/commonjs/web/convert/index.js.map +1 -0
  45. package/lib/commonjs/web/convert/module.d.js +2 -0
  46. package/lib/commonjs/web/convert/module.d.js.map +1 -0
  47. package/lib/commonjs/web/convert/shadow.js +68 -0
  48. package/lib/commonjs/web/convert/shadow.js.map +1 -0
  49. package/lib/commonjs/web/convert/style.js +89 -0
  50. package/lib/commonjs/web/convert/style.js.map +1 -0
  51. package/lib/commonjs/web/convert/textShadow.js +73 -0
  52. package/lib/commonjs/web/convert/textShadow.js.map +1 -0
  53. package/lib/commonjs/web/convert/transform.js +72 -0
  54. package/lib/commonjs/web/convert/transform.js.map +1 -0
  55. package/lib/commonjs/web/convert/types.js +9 -0
  56. package/lib/commonjs/web/convert/types.js.map +1 -0
  57. package/lib/commonjs/web/convert/utils.js +55 -0
  58. package/lib/commonjs/web/convert/utils.js.map +1 -0
  59. package/lib/commonjs/web/create.js +89 -0
  60. package/lib/commonjs/web/create.js.map +1 -0
  61. package/lib/commonjs/web/index.js +51 -0
  62. package/lib/commonjs/web/index.js.map +1 -0
  63. package/lib/commonjs/web/listener/index.js +13 -0
  64. package/lib/commonjs/web/listener/index.js.map +1 -0
  65. package/lib/commonjs/web/listener/listener.js +36 -0
  66. package/lib/commonjs/web/listener/listener.js.map +1 -0
  67. package/lib/commonjs/web/mock.js +37 -0
  68. package/lib/commonjs/web/mock.js.map +1 -0
  69. package/lib/commonjs/web/mq.js +23 -0
  70. package/lib/commonjs/web/mq.js.map +1 -0
  71. package/lib/commonjs/web/pseudo.js +11 -0
  72. package/lib/commonjs/web/pseudo.js.map +1 -0
  73. package/lib/commonjs/web/registry.js +37 -0
  74. package/lib/commonjs/web/registry.js.map +1 -0
  75. package/lib/commonjs/web/runtime.js +164 -0
  76. package/lib/commonjs/web/runtime.js.map +1 -0
  77. package/lib/commonjs/web/state.js +121 -0
  78. package/lib/commonjs/web/state.js.map +1 -0
  79. package/lib/commonjs/web/utils.js +78 -0
  80. package/lib/commonjs/web/utils.js.map +1 -0
  81. package/lib/commonjs/web/variants/getVariants.js +39 -0
  82. package/lib/commonjs/web/variants/getVariants.js.map +1 -0
  83. package/lib/commonjs/web/variants/index.js +28 -0
  84. package/lib/commonjs/web/variants/index.js.map +1 -0
  85. package/lib/commonjs/web/variants/useVariants.js +75 -0
  86. package/lib/commonjs/web/variants/useVariants.js.map +1 -0
  87. package/lib/module/specs/NavigtionBar/index.js +1 -1
  88. package/lib/module/specs/NavigtionBar/index.js.map +1 -1
  89. package/lib/module/specs/ShadowRegistry/index.js +2 -2
  90. package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
  91. package/lib/module/specs/StatusBar/index.js +1 -1
  92. package/lib/module/specs/StatusBar/index.js.map +1 -1
  93. package/lib/module/specs/StyleSheet/index.js.map +1 -1
  94. package/lib/module/specs/UnistylesRuntime/index.js +1 -1
  95. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  96. package/lib/module/specs/index.web.js +1 -1
  97. package/lib/module/specs/index.web.js.map +1 -1
  98. package/lib/module/web/convert/boxShadow.js +72 -0
  99. package/lib/module/web/convert/boxShadow.js.map +1 -0
  100. package/lib/module/web/convert/breakpoint.js +20 -0
  101. package/lib/module/web/convert/breakpoint.js.map +1 -0
  102. package/lib/module/web/convert/index.js +71 -0
  103. package/lib/module/web/convert/index.js.map +1 -0
  104. package/lib/module/web/convert/module.d.js +2 -0
  105. package/lib/module/web/convert/module.d.js.map +1 -0
  106. package/lib/module/web/convert/shadow.js +63 -0
  107. package/lib/module/web/convert/shadow.js.map +1 -0
  108. package/lib/module/web/convert/style.js +84 -0
  109. package/lib/module/web/convert/style.js.map +1 -0
  110. package/lib/module/web/convert/textShadow.js +68 -0
  111. package/lib/module/web/convert/textShadow.js.map +1 -0
  112. package/lib/module/web/convert/transform.js +67 -0
  113. package/lib/module/web/convert/transform.js.map +1 -0
  114. package/lib/module/web/convert/types.js +5 -0
  115. package/lib/module/web/convert/types.js.map +1 -0
  116. package/lib/module/web/convert/utils.js +43 -0
  117. package/lib/module/web/convert/utils.js.map +1 -0
  118. package/lib/module/web/create.js +84 -0
  119. package/lib/module/web/create.js.map +1 -0
  120. package/lib/module/web/index.js +24 -0
  121. package/lib/module/web/index.js.map +1 -0
  122. package/lib/module/web/listener/index.js +4 -0
  123. package/lib/module/web/listener/index.js.map +1 -0
  124. package/lib/module/web/listener/listener.js +31 -0
  125. package/lib/module/web/listener/listener.js.map +1 -0
  126. package/lib/module/web/mock.js +33 -0
  127. package/lib/module/web/mock.js.map +1 -0
  128. package/lib/module/web/mq.js +17 -0
  129. package/lib/module/web/mq.js.map +1 -0
  130. package/lib/module/web/pseudo.js +6 -0
  131. package/lib/module/web/pseudo.js.map +1 -0
  132. package/lib/module/web/registry.js +33 -0
  133. package/lib/module/web/registry.js.map +1 -0
  134. package/lib/module/web/runtime.js +160 -0
  135. package/lib/module/web/runtime.js.map +1 -0
  136. package/lib/module/web/state.js +117 -0
  137. package/lib/module/web/state.js.map +1 -0
  138. package/lib/module/web/utils.js +65 -0
  139. package/lib/module/web/utils.js.map +1 -0
  140. package/lib/module/web/variants/getVariants.js +34 -0
  141. package/lib/module/web/variants/getVariants.js.map +1 -0
  142. package/lib/module/web/variants/index.js +5 -0
  143. package/lib/module/web/variants/index.js.map +1 -0
  144. package/lib/module/web/variants/useVariants.js +70 -0
  145. package/lib/module/web/variants/useVariants.js.map +1 -0
  146. package/lib/typescript/example/App.d.ts.map +1 -1
  147. package/lib/typescript/example/Typography.d.ts +12 -0
  148. package/lib/typescript/example/Typography.d.ts.map +1 -0
  149. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +2 -2
  150. package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
  151. package/lib/typescript/src/specs/StyleSheet/index.d.ts +2 -1
  152. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  153. package/lib/typescript/src/specs/index.web.d.ts +1 -1
  154. package/lib/typescript/src/specs/index.web.d.ts.map +1 -1
  155. package/lib/typescript/src/types/stylesheet.d.ts +1 -1
  156. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  157. package/lib/typescript/src/web/convert/boxShadow.d.ts.map +1 -0
  158. package/lib/typescript/src/web/convert/breakpoint.d.ts.map +1 -0
  159. package/lib/typescript/{web → src/web}/convert/index.d.ts +1 -1
  160. package/lib/typescript/src/web/convert/index.d.ts.map +1 -0
  161. package/lib/typescript/src/web/convert/shadow.d.ts.map +1 -0
  162. package/lib/typescript/src/web/convert/style.d.ts.map +1 -0
  163. package/lib/typescript/src/web/convert/textShadow.d.ts.map +1 -0
  164. package/lib/typescript/src/web/convert/transform.d.ts.map +1 -0
  165. package/lib/typescript/{web → src/web}/convert/types.d.ts +1 -1
  166. package/lib/typescript/src/web/convert/types.d.ts.map +1 -0
  167. package/lib/typescript/src/web/convert/utils.d.ts.map +1 -0
  168. package/lib/typescript/{web → src/web}/create.d.ts +11 -11
  169. package/lib/typescript/{web → src/web}/create.d.ts.map +1 -1
  170. package/lib/typescript/{web → src/web}/index.d.ts +12 -12
  171. package/lib/typescript/{web → src/web}/index.d.ts.map +1 -1
  172. package/lib/typescript/src/web/listener/index.d.ts.map +1 -0
  173. package/lib/typescript/{web → src/web}/listener/listener.d.ts +1 -1
  174. package/lib/typescript/src/web/listener/listener.d.ts.map +1 -0
  175. package/lib/typescript/{web → src/web}/mock.d.ts +2 -2
  176. package/lib/typescript/src/web/mock.d.ts.map +1 -0
  177. package/lib/typescript/src/web/mq.d.ts.map +1 -0
  178. package/lib/typescript/src/web/pseudo.d.ts.map +1 -0
  179. package/lib/typescript/{web → src/web}/registry.d.ts +1 -1
  180. package/lib/typescript/src/web/registry.d.ts.map +1 -0
  181. package/lib/typescript/{web → src/web}/runtime.d.ts +6 -6
  182. package/lib/typescript/src/web/runtime.d.ts.map +1 -0
  183. package/lib/typescript/{web → src/web}/state.d.ts +4 -4
  184. package/lib/typescript/src/web/state.d.ts.map +1 -0
  185. package/lib/typescript/{web → src/web}/utils.d.ts +5 -3
  186. package/lib/typescript/src/web/utils.d.ts.map +1 -0
  187. package/lib/typescript/src/web/variants/getVariants.d.ts +3 -0
  188. package/lib/typescript/src/web/variants/getVariants.d.ts.map +1 -0
  189. package/lib/typescript/src/web/variants/index.d.ts +3 -0
  190. package/lib/typescript/src/web/variants/index.d.ts.map +1 -0
  191. package/lib/typescript/src/web/variants/useVariants.d.ts +3 -0
  192. package/lib/typescript/src/web/variants/useVariants.d.ts.map +1 -0
  193. package/package.json +2 -2
  194. package/plugin/__tests__/dependencies.spec.js +181 -103
  195. package/plugin/__tests__/ref.spec.js +335 -156
  196. package/plugin/__tests__/stylesheet.spec.js +148 -55
  197. package/plugin/index.js +31 -21
  198. package/plugin/ref.js +43 -11
  199. package/plugin/style.js +13 -24
  200. package/plugin/stylesheet.js +44 -1
  201. package/plugin/variants.js +33 -0
  202. package/src/specs/NavigtionBar/index.ts +1 -1
  203. package/src/specs/ShadowRegistry/index.ts +4 -4
  204. package/src/specs/StatusBar/index.ts +1 -1
  205. package/src/specs/StyleSheet/index.ts +3 -1
  206. package/src/specs/UnistylesRuntime/index.ts +1 -1
  207. package/src/specs/index.web.ts +1 -1
  208. package/src/types/stylesheet.ts +1 -1
  209. package/{web → src/web}/convert/breakpoint.ts +1 -1
  210. package/{web → src/web}/convert/index.ts +1 -1
  211. package/{web → src/web}/convert/types.ts +1 -1
  212. package/{web → src/web}/create.ts +36 -33
  213. package/{web → src/web}/listener/listener.ts +1 -1
  214. package/{web → src/web}/mock.ts +2 -2
  215. package/{web → src/web}/registry.ts +1 -1
  216. package/{web → src/web}/runtime.ts +4 -4
  217. package/{web → src/web}/state.ts +5 -5
  218. package/{web → src/web}/utils.ts +5 -5
  219. package/src/web/variants/getVariants.ts +42 -0
  220. package/src/web/variants/index.ts +2 -0
  221. package/{web → src/web/variants}/useVariants.ts +24 -44
  222. package/lib/typescript/web/convert/boxShadow.d.ts.map +0 -1
  223. package/lib/typescript/web/convert/breakpoint.d.ts.map +0 -1
  224. package/lib/typescript/web/convert/index.d.ts.map +0 -1
  225. package/lib/typescript/web/convert/shadow.d.ts.map +0 -1
  226. package/lib/typescript/web/convert/style.d.ts.map +0 -1
  227. package/lib/typescript/web/convert/textShadow.d.ts.map +0 -1
  228. package/lib/typescript/web/convert/transform.d.ts.map +0 -1
  229. package/lib/typescript/web/convert/types.d.ts.map +0 -1
  230. package/lib/typescript/web/convert/utils.d.ts.map +0 -1
  231. package/lib/typescript/web/listener/index.d.ts.map +0 -1
  232. package/lib/typescript/web/listener/listener.d.ts.map +0 -1
  233. package/lib/typescript/web/mock.d.ts.map +0 -1
  234. package/lib/typescript/web/mq.d.ts.map +0 -1
  235. package/lib/typescript/web/pseudo.d.ts.map +0 -1
  236. package/lib/typescript/web/registry.d.ts.map +0 -1
  237. package/lib/typescript/web/runtime.d.ts.map +0 -1
  238. package/lib/typescript/web/state.d.ts.map +0 -1
  239. package/lib/typescript/web/useVariants.d.ts +0 -3
  240. package/lib/typescript/web/useVariants.d.ts.map +0 -1
  241. package/lib/typescript/web/utils.d.ts.map +0 -1
  242. /package/lib/typescript/{web → src/web}/convert/boxShadow.d.ts +0 -0
  243. /package/lib/typescript/{web → src/web}/convert/breakpoint.d.ts +0 -0
  244. /package/lib/typescript/{web → src/web}/convert/shadow.d.ts +0 -0
  245. /package/lib/typescript/{web → src/web}/convert/style.d.ts +0 -0
  246. /package/lib/typescript/{web → src/web}/convert/textShadow.d.ts +0 -0
  247. /package/lib/typescript/{web → src/web}/convert/transform.d.ts +0 -0
  248. /package/lib/typescript/{web → src/web}/convert/utils.d.ts +0 -0
  249. /package/lib/typescript/{web → src/web}/listener/index.d.ts +0 -0
  250. /package/lib/typescript/{web → src/web}/mq.d.ts +0 -0
  251. /package/lib/typescript/{web → src/web}/pseudo.d.ts +0 -0
  252. /package/{web → src/web}/convert/boxShadow.ts +0 -0
  253. /package/{web → src/web}/convert/module.d.ts +0 -0
  254. /package/{web → src/web}/convert/shadow.ts +0 -0
  255. /package/{web → src/web}/convert/style.ts +0 -0
  256. /package/{web → src/web}/convert/textShadow.ts +0 -0
  257. /package/{web → src/web}/convert/transform.ts +0 -0
  258. /package/{web → src/web}/convert/utils.ts +0 -0
  259. /package/{web → src/web}/index.ts +0 -0
  260. /package/{web → src/web}/listener/index.ts +0 -0
  261. /package/{web → src/web}/mq.ts +0 -0
  262. /package/{web → src/web}/pseudo.ts +0 -0
@@ -78,7 +78,7 @@ pluginTester({
78
78
  <View
79
79
  style={styles.container}
80
80
  ref={ref => {
81
- UnistylesShadowRegistry.add(ref, styles.container)
81
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
82
82
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
83
83
  }}
84
84
  >
@@ -130,8 +130,8 @@ pluginTester({
130
130
  return (
131
131
  <View
132
132
  ref={_ref => {
133
- ref = _ref
134
- UnistylesShadowRegistry.add(_ref, styles.container)
133
+ ref.current = _ref
134
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
135
135
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
136
136
  }}
137
137
  style={styles.container}
@@ -141,11 +141,14 @@ pluginTester({
141
141
  )
142
142
  }
143
143
 
144
- const styles = StyleSheet.create({
145
- container: {
146
- backgroundColor: 'red'
147
- }
148
- })
144
+ const styles = StyleSheet.create(
145
+ {
146
+ container: {
147
+ backgroundColor: 'red'
148
+ }
149
+ },
150
+ 921918562
151
+ )
149
152
  `
150
153
  },
151
154
  {
@@ -155,13 +158,13 @@ pluginTester({
155
158
  import { StyleSheet } from 'react-native-unistyles'
156
159
 
157
160
  export const Example = () => {
158
- let myRef = useRef()
161
+ const myRef = useRef()
159
162
 
160
163
  return (
161
164
  <View
162
165
  ref={ref => {
163
166
  doSomething(ref)
164
- myRef = ref
167
+ myRef.current = ref
165
168
  }}
166
169
  style={styles.container}
167
170
  >
@@ -182,14 +185,14 @@ pluginTester({
182
185
  import { StyleSheet } from 'react-native-unistyles'
183
186
 
184
187
  export const Example = () => {
185
- let myRef = useRef()
188
+ const myRef = useRef()
186
189
 
187
190
  return (
188
191
  <View
189
192
  ref={ref => {
190
193
  doSomething(ref)
191
- myRef = ref
192
- UnistylesShadowRegistry.add(ref, styles.container)
194
+ myRef.current = ref
195
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
193
196
  return () => {
194
197
  UnistylesShadowRegistry.remove(ref, styles.container)
195
198
  }
@@ -201,11 +204,14 @@ pluginTester({
201
204
  )
202
205
  }
203
206
 
204
- const styles = StyleSheet.create({
205
- container: {
206
- backgroundColor: 'red'
207
- }
208
- })
207
+ const styles = StyleSheet.create(
208
+ {
209
+ container: {
210
+ backgroundColor: 'red'
211
+ }
212
+ },
213
+ 921918562
214
+ )
209
215
  `
210
216
  },
211
217
  {
@@ -215,13 +221,13 @@ pluginTester({
215
221
  import { StyleSheet } from 'react-native-unistyles'
216
222
 
217
223
  export const Example = () => {
218
- let myRef = React.useRef()
224
+ const myRef = React.useRef()
219
225
 
220
226
  return (
221
227
  <View
222
228
  ref={ref => {
223
229
  doSomething(ref)
224
- myRef = ref
230
+ myRef.current = ref
225
231
 
226
232
  return () => {
227
233
  customCleanup()
@@ -246,14 +252,14 @@ pluginTester({
246
252
  import { StyleSheet } from 'react-native-unistyles'
247
253
 
248
254
  export const Example = () => {
249
- let myRef = React.useRef()
255
+ const myRef = React.useRef()
250
256
 
251
257
  return (
252
258
  <View
253
259
  ref={ref => {
254
260
  doSomething(ref)
255
- myRef = ref
256
- UnistylesShadowRegistry.add(ref, styles.container)
261
+ myRef.current = ref
262
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, undefined)
257
263
  return () => {
258
264
  ;(() => {
259
265
  customCleanup()
@@ -268,11 +274,14 @@ pluginTester({
268
274
  )
269
275
  }
270
276
 
271
- const styles = StyleSheet.create({
272
- container: {
273
- backgroundColor: 'red'
274
- }
275
- })
277
+ const styles = StyleSheet.create(
278
+ {
279
+ container: {
280
+ backgroundColor: 'red'
281
+ }
282
+ },
283
+ 921918562
284
+ )
276
285
  `
277
286
  },
278
287
  {
@@ -282,10 +291,10 @@ pluginTester({
282
291
  import { StyleSheet } from 'react-native-unistyles'
283
292
 
284
293
  export const Example = () => {
285
- let myRef = React.useRef()
294
+ const myRef = React.useRef()
286
295
  const fn = ref => {
287
296
  doSomething(ref)
288
- myRef = ref
297
+ myRef.current = ref
289
298
 
290
299
  return () => {
291
300
  customCleanup2()
@@ -314,17 +323,17 @@ pluginTester({
314
323
  import { StyleSheet } from 'react-native-unistyles'
315
324
 
316
325
  export const Example = () => {
317
- let myRef = React.useRef()
326
+ const myRef = React.useRef()
318
327
  const fn = ref => {
319
328
  doSomething(ref)
320
- myRef = ref
329
+ myRef.current = ref
321
330
  }
322
331
 
323
332
  return (
324
333
  <View
325
334
  ref={_ref => {
326
335
  fn(_ref)
327
- UnistylesShadowRegistry.add(_ref, styles.container)
336
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
328
337
  return () => {
329
338
  ;(() => {
330
339
  customCleanup2()
@@ -339,11 +348,14 @@ pluginTester({
339
348
  )
340
349
  }
341
350
 
342
- const styles = StyleSheet.create({
343
- container: {
344
- backgroundColor: 'red'
345
- }
346
- })
351
+ const styles = StyleSheet.create(
352
+ {
353
+ container: {
354
+ backgroundColor: 'red'
355
+ }
356
+ },
357
+ 921918562
358
+ )
347
359
  `
348
360
  },
349
361
  {
@@ -353,10 +365,10 @@ pluginTester({
353
365
  import { StyleSheet } from 'react-native-unistyles'
354
366
 
355
367
  export const Example = () => {
356
- let myRef = React.useRef()
368
+ const myRef = React.useRef()
357
369
  function fn(ref) {
358
370
  doSomething(ref)
359
- myRef = ref
371
+ myRef.current = ref
360
372
 
361
373
  return () => {
362
374
  customCleanup2()
@@ -385,17 +397,17 @@ pluginTester({
385
397
  import { StyleSheet } from 'react-native-unistyles'
386
398
 
387
399
  export const Example = () => {
388
- let myRef = React.useRef()
400
+ const myRef = React.useRef()
389
401
  function fn(ref) {
390
402
  doSomething(ref)
391
- myRef = ref
403
+ myRef.current = ref
392
404
  }
393
405
 
394
406
  return (
395
407
  <View
396
408
  ref={_ref => {
397
409
  fn(_ref)
398
- UnistylesShadowRegistry.add(_ref, styles.container)
410
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
399
411
  return () => {
400
412
  ;(() => {
401
413
  customCleanup2()
@@ -410,11 +422,14 @@ pluginTester({
410
422
  )
411
423
  }
412
424
 
413
- const styles = StyleSheet.create({
414
- container: {
415
- backgroundColor: 'red'
416
- }
417
- })
425
+ const styles = StyleSheet.create(
426
+ {
427
+ container: {
428
+ backgroundColor: 'red'
429
+ }
430
+ },
431
+ 921918562
432
+ )
418
433
  `
419
434
  },
420
435
  {
@@ -424,7 +439,7 @@ pluginTester({
424
439
  import { StyleSheet } from 'react-native-unistyles'
425
440
 
426
441
  export const Example = () => {
427
- let myRef = useRef()
442
+ const myRef = useRef()
428
443
 
429
444
  return (
430
445
  <View
@@ -449,7 +464,7 @@ pluginTester({
449
464
  import { StyleSheet } from 'react-native-unistyles'
450
465
 
451
466
  export const Example = () => {
452
- let myRef = useRef()
467
+ const myRef = useRef()
453
468
 
454
469
  return (
455
470
  <View
@@ -463,11 +478,14 @@ pluginTester({
463
478
  )
464
479
  }
465
480
 
466
- const styles = StyleSheet.create({
467
- container: {
468
- backgroundColor: 'red'
469
- }
470
- })
481
+ const styles = StyleSheet.create(
482
+ {
483
+ container: {
484
+ backgroundColor: 'red'
485
+ }
486
+ },
487
+ 921918562
488
+ )
471
489
  `
472
490
  },
473
491
  {
@@ -477,7 +495,7 @@ pluginTester({
477
495
  import { StyleSheet } from 'react-native-unistyles'
478
496
 
479
497
  export const Example = () => {
480
- let myRef = useRef()
498
+ const myRef = useRef()
481
499
 
482
500
  return (
483
501
  <View
@@ -503,7 +521,7 @@ pluginTester({
503
521
  import { StyleSheet } from 'react-native-unistyles'
504
522
 
505
523
  export const Example = () => {
506
- let myRef = useRef()
524
+ const myRef = useRef()
507
525
 
508
526
  return (
509
527
  <View
@@ -518,11 +536,14 @@ pluginTester({
518
536
  )
519
537
  }
520
538
 
521
- const styles = StyleSheet.create({
522
- container: {
523
- backgroundColor: 'red'
524
- }
525
- })
539
+ const styles = StyleSheet.create(
540
+ {
541
+ container: {
542
+ backgroundColor: 'red'
543
+ }
544
+ },
545
+ 921918562
546
+ )
526
547
  `
527
548
  },
528
549
  {
@@ -532,7 +553,7 @@ pluginTester({
532
553
  import { StyleSheet } from 'react-native-unistyles'
533
554
 
534
555
  export const Example = () => {
535
- let myRef = useRef()
556
+ const myRef = useRef()
536
557
 
537
558
  return (
538
559
  <View
@@ -555,7 +576,7 @@ pluginTester({
555
576
  import { StyleSheet } from 'react-native-unistyles'
556
577
 
557
578
  export const Example = () => {
558
- let myRef = useRef()
579
+ const myRef = useRef()
559
580
 
560
581
  return (
561
582
  <View ref={myRef} style={[obj1, obj2]}>
@@ -564,11 +585,14 @@ pluginTester({
564
585
  )
565
586
  }
566
587
 
567
- const styles = StyleSheet.create({
568
- container: {
569
- backgroundColor: 'red'
570
- }
571
- })
588
+ const styles = StyleSheet.create(
589
+ {
590
+ container: {
591
+ backgroundColor: 'red'
592
+ }
593
+ },
594
+ 921918562
595
+ )
572
596
  `
573
597
  },
574
598
  {
@@ -578,7 +602,7 @@ pluginTester({
578
602
  import { StyleSheet } from 'react-native-unistyles'
579
603
 
580
604
  export const Example = () => {
581
- let myRef = useRef()
605
+ const myRef = useRef()
582
606
 
583
607
  return (
584
608
  <View
@@ -607,13 +631,13 @@ pluginTester({
607
631
  import { StyleSheet } from 'react-native-unistyles'
608
632
 
609
633
  export const Example = () => {
610
- let myRef = useRef()
634
+ const myRef = useRef()
611
635
 
612
636
  return (
613
637
  <View
614
638
  ref={_ref => {
615
- myRef = _ref
616
- UnistylesShadowRegistry.add(_ref, styles.container)
639
+ myRef.current = _ref
640
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
617
641
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
618
642
  }}
619
643
  style={{
@@ -628,11 +652,14 @@ pluginTester({
628
652
  )
629
653
  }
630
654
 
631
- const styles = StyleSheet.create({
632
- container: {
633
- backgroundColor: 'red'
634
- }
635
- })
655
+ const styles = StyleSheet.create(
656
+ {
657
+ container: {
658
+ backgroundColor: 'red'
659
+ }
660
+ },
661
+ 921918562
662
+ )
636
663
  `
637
664
  },
638
665
  {
@@ -642,7 +669,7 @@ pluginTester({
642
669
  import { StyleSheet } from 'react-native-unistyles'
643
670
 
644
671
  export const Example = () => {
645
- let myRef = useRef()
672
+ const myRef = useRef()
646
673
 
647
674
  return (
648
675
  <View
@@ -671,13 +698,13 @@ pluginTester({
671
698
  import { StyleSheet } from 'react-native-unistyles'
672
699
 
673
700
  export const Example = () => {
674
- let myRef = useRef()
701
+ const myRef = useRef()
675
702
 
676
703
  return (
677
704
  <View
678
705
  ref={_ref => {
679
- myRef = _ref
680
- UnistylesShadowRegistry.add(_ref, styles.container)
706
+ myRef.current = _ref
707
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
681
708
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
682
709
  }}
683
710
  style={[
@@ -692,11 +719,14 @@ pluginTester({
692
719
  )
693
720
  }
694
721
 
695
- const styles = StyleSheet.create({
696
- container: {
697
- backgroundColor: 'red'
698
- }
699
- })
722
+ const styles = StyleSheet.create(
723
+ {
724
+ container: {
725
+ backgroundColor: 'red'
726
+ }
727
+ },
728
+ 921918562
729
+ )
700
730
  `
701
731
  },
702
732
  {
@@ -706,7 +736,7 @@ pluginTester({
706
736
  import { StyleSheet } from 'react-native-unistyles'
707
737
 
708
738
  export const Example = () => {
709
- let myRef = useRef()
739
+ const myRef = useRef()
710
740
 
711
741
  return (
712
742
  <View
@@ -730,13 +760,13 @@ pluginTester({
730
760
  import { StyleSheet } from 'react-native-unistyles'
731
761
 
732
762
  export const Example = () => {
733
- let myRef = useRef()
763
+ const myRef = useRef()
734
764
 
735
765
  return (
736
766
  <View
737
767
  ref={_ref => {
738
- myRef = _ref
739
- UnistylesShadowRegistry.add(_ref, styles.container)
768
+ myRef.current = _ref
769
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, undefined)
740
770
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
741
771
  }}
742
772
  style={[styles.container]}
@@ -746,11 +776,14 @@ pluginTester({
746
776
  )
747
777
  }
748
778
 
749
- const styles = StyleSheet.create({
750
- container: {
751
- backgroundColor: 'red'
752
- }
753
- })
779
+ const styles = StyleSheet.create(
780
+ {
781
+ container: {
782
+ backgroundColor: 'red'
783
+ }
784
+ },
785
+ 921918562
786
+ )
754
787
  `
755
788
  },
756
789
  {
@@ -760,7 +793,7 @@ pluginTester({
760
793
  import { StyleSheet } from 'react-native-unistyles'
761
794
 
762
795
  export const Example = () => {
763
- let myRef = useRef()
796
+ const myRef = useRef()
764
797
 
765
798
  return (
766
799
  <View
@@ -786,27 +819,30 @@ pluginTester({
786
819
  import { StyleSheet } from 'react-native-unistyles'
787
820
 
788
821
  export const Example = () => {
789
- let myRef = useRef()
822
+ const myRef = useRef()
790
823
 
791
824
  return (
792
825
  <View
793
826
  ref={_ref => {
794
- myRef = _ref
795
- UnistylesShadowRegistry.add(_ref, styles.container)
827
+ myRef.current = _ref
828
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, [1, 2])
796
829
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
797
830
  }}
798
- style={[styles.container(1, 2, 1)]}
831
+ style={[styles.container(1, 2)]}
799
832
  >
800
833
  <Text>Hello world</Text>
801
834
  </View>
802
835
  )
803
836
  }
804
837
 
805
- const styles = StyleSheet.create({
806
- container: () => ({
807
- backgroundColor: 'red'
808
- })
809
- })
838
+ const styles = StyleSheet.create(
839
+ {
840
+ container: () => ({
841
+ backgroundColor: 'red'
842
+ })
843
+ },
844
+ 921918562
845
+ )
810
846
  `
811
847
  },
812
848
  {
@@ -816,7 +852,7 @@ pluginTester({
816
852
  import { StyleSheet } from 'react-native-unistyles'
817
853
 
818
854
  export const Example = () => {
819
- let myRef = useRef()
855
+ const myRef = useRef()
820
856
 
821
857
  return (
822
858
  <View
@@ -832,9 +868,9 @@ pluginTester({
832
868
  }
833
869
 
834
870
  const styles = StyleSheet.create({
835
- container: () => ({
871
+ container: {
836
872
  backgroundColor: 'red'
837
- })
873
+ }
838
874
  })
839
875
  `,
840
876
  output: `
@@ -843,40 +879,44 @@ pluginTester({
843
879
  import { StyleSheet } from 'react-native-unistyles'
844
880
 
845
881
  export const Example = () => {
846
- let myRef = useRef()
882
+ const myRef = useRef()
847
883
 
848
884
  return (
849
885
  <View
850
886
  ref={_ref => {
851
- myRef = _ref
852
- UnistylesShadowRegistry.add(_ref, styles.container)
887
+ myRef.current = _ref
888
+ UnistylesShadowRegistry.add(_ref, styles.container, undefined, [1, 2])
853
889
  return () => UnistylesShadowRegistry.remove(_ref, styles.container)
854
890
  }}
855
- style={{
856
- backgroundColor: 'red',
857
- ...styles.container(1, 2, 1)
858
- }}
891
+ style={{ backgroundColor: 'red', ...styles.container(1, 2) }}
859
892
  >
860
893
  <Text>Hello world</Text>
861
894
  </View>
862
895
  )
863
896
  }
864
897
 
865
- const styles = StyleSheet.create({
866
- container: () => ({
867
- backgroundColor: 'red'
868
- })
869
- })
898
+ const styles = StyleSheet.create(
899
+ {
900
+ container: {
901
+ backgroundColor: 'red'
902
+ }
903
+ },
904
+ 921918562
905
+ )
870
906
  `
871
907
  },
872
908
  {
873
- title: 'Should modify registry names if user changes name of member expression',
909
+ title: 'It should extract variants and pass them to ShadowReigstry',
874
910
  code: `
875
911
  import { useRef } from 'react'
876
912
  import { StyleSheet } from 'react-native-unistyles'
877
913
 
878
914
  export const Example = () => {
879
- let myRef = useRef()
915
+ const myRef = useRef()
916
+
917
+ styles.useVariants({
918
+ size: 'default'
919
+ })
880
920
 
881
921
  return (
882
922
  <View
@@ -890,7 +930,17 @@ pluginTester({
890
930
 
891
931
  const uhh = StyleSheet.create({
892
932
  dkk: () => ({
893
- backgroundColor: 'red'
933
+ backgroundColor: 'red',
934
+ variants: {
935
+ size: {
936
+ small: {
937
+ backgroundColor: 'blue'
938
+ },
939
+ default: {
940
+ backgroundColor: 'green'
941
+ }
942
+ }
943
+ }
894
944
  })
895
945
  })
896
946
  `,
@@ -900,52 +950,68 @@ pluginTester({
900
950
  import { StyleSheet } from 'react-native-unistyles'
901
951
 
902
952
  export const Example = () => {
903
- let myRef = useRef()
953
+ const myRef = useRef()
954
+ const __uni__variants = {
955
+ size: 'default'
956
+ }
957
+ styles.useVariants(__uni__variants)
904
958
 
905
959
  return (
906
960
  <View
907
961
  ref={_ref => {
908
- myRef = _ref
909
- UnistylesShadowRegistry.add(_ref, uhh.dkk)
962
+ myRef.current = _ref
963
+ UnistylesShadowRegistry.add(_ref, uhh.dkk, __uni__variants, [])
910
964
  return () => UnistylesShadowRegistry.remove(_ref, uhh.dkk)
911
965
  }}
912
- style={uhh.dkk(1)}
966
+ style={uhh.dkk()}
913
967
  >
914
968
  <Text>Hello world</Text>
915
969
  </View>
916
970
  )
917
971
  }
918
972
 
919
- const uhh = StyleSheet.create({
920
- dkk: () => ({
921
- backgroundColor: 'red'
922
- })
923
- })
973
+ const uhh = StyleSheet.create(
974
+ {
975
+ dkk: () => ({
976
+ backgroundColor: 'red',
977
+ variants: {
978
+ size: {
979
+ small: {
980
+ backgroundColor: 'blue'
981
+ },
982
+ default: {
983
+ backgroundColor: 'green'
984
+ }
985
+ }
986
+ },
987
+ uni__dependencies: [4]
988
+ })
989
+ },
990
+ 921918562
991
+ )
924
992
  `
925
993
  },
926
994
  {
927
- title: 'Should increment counter for web dynamic functions',
995
+ title: 'Should modify registry names if user changes name of member expression',
928
996
  code: `
929
997
  import { useRef } from 'react'
930
998
  import { StyleSheet } from 'react-native-unistyles'
931
999
 
932
1000
  export const Example = () => {
933
- let myRef = useRef()
1001
+ const myRef = useRef()
934
1002
 
935
1003
  return (
936
1004
  <View
937
1005
  ref={myRef}
938
- style={styles.container()}
1006
+ style={uhh.dkk()}
939
1007
  >
940
- <Text style={styles.container()}>
941
- Hello world
942
- </Text>
1008
+ <Text>Hello world</Text>
943
1009
  </View>
944
1010
  )
945
1011
  }
946
1012
 
947
- const styles = StyleSheet.create({
948
- container: () => ({
1013
+ const uhh = StyleSheet.create({
1014
+ dkk: () => ({
949
1015
  backgroundColor: 'red'
950
1016
  })
951
1017
  })
@@ -956,36 +1022,149 @@ pluginTester({
956
1022
  import { StyleSheet } from 'react-native-unistyles'
957
1023
 
958
1024
  export const Example = () => {
959
- let myRef = useRef()
1025
+ const myRef = useRef()
960
1026
 
961
1027
  return (
962
1028
  <View
963
1029
  ref={_ref => {
964
- myRef = _ref
965
- UnistylesShadowRegistry.add(_ref, styles.container)
966
- return () => UnistylesShadowRegistry.remove(_ref, styles.container)
1030
+ myRef.current = _ref
1031
+ UnistylesShadowRegistry.add(_ref, uhh.dkk, undefined, [])
1032
+ return () => UnistylesShadowRegistry.remove(_ref, uhh.dkk)
967
1033
  }}
968
- style={styles.container(1)}
1034
+ style={uhh.dkk()}
969
1035
  >
970
- <Text
971
- style={styles.container(2)}
1036
+ <Text>Hello world</Text>
1037
+ </View>
1038
+ )
1039
+ }
1040
+
1041
+ const uhh = StyleSheet.create(
1042
+ {
1043
+ dkk: () => ({
1044
+ backgroundColor: 'red'
1045
+ })
1046
+ },
1047
+ 921918562
1048
+ )
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)}
972
1082
  ref={ref => {
973
- UnistylesShadowRegistry.add(ref, styles.container)
1083
+ UnistylesShadowRegistry.add(ref, styles.container, undefined, [1, 5])
974
1084
  return () => UnistylesShadowRegistry.remove(ref, styles.container)
975
1085
  }}
976
- >
977
- Hello world
978
- </Text>
979
- </View>
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>
980
1126
  )
981
1127
  }
982
1128
 
983
1129
  const styles = StyleSheet.create({
984
- container: () => ({
985
- backgroundColor: 'red'
1130
+ container: (flex, gap) => ({
1131
+ flex,
1132
+ gap
986
1133
  })
987
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
+ )
988
1167
  `
989
- },
1168
+ }
990
1169
  ]
991
1170
  })