react-native-unistyles 2.4.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. package/lib/commonjs/common.js +3 -1
  2. package/lib/commonjs/common.js.map +1 -1
  3. package/lib/commonjs/core/UnistyleRegistry.js +8 -4
  4. package/lib/commonjs/core/UnistyleRegistry.js.map +1 -1
  5. package/lib/commonjs/core/Unistyles.js +7 -0
  6. package/lib/commonjs/core/Unistyles.js.map +1 -1
  7. package/lib/commonjs/core/mocks/UnistylesMockedBridge.js +32 -0
  8. package/lib/commonjs/core/mocks/UnistylesMockedBridge.js.map +1 -0
  9. package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js +46 -0
  10. package/lib/commonjs/core/mocks/UnistylesMockedRegistry.js.map +1 -0
  11. package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js +77 -0
  12. package/lib/commonjs/core/mocks/UnistylesMockedRuntime.js.map +1 -0
  13. package/lib/commonjs/core/mocks/index.js +27 -0
  14. package/lib/commonjs/core/mocks/index.js.map +1 -0
  15. package/lib/commonjs/hooks/useUnistyles.js +2 -2
  16. package/lib/commonjs/hooks/useUnistyles.js.map +1 -1
  17. package/lib/commonjs/useStyles.js +1 -1
  18. package/lib/commonjs/useStyles.js.map +1 -1
  19. package/lib/module/common.js +2 -0
  20. package/lib/module/common.js.map +1 -1
  21. package/lib/module/core/UnistyleRegistry.js +9 -5
  22. package/lib/module/core/UnistyleRegistry.js.map +1 -1
  23. package/lib/module/core/Unistyles.js +8 -1
  24. package/lib/module/core/Unistyles.js.map +1 -1
  25. package/lib/module/core/mocks/UnistylesMockedBridge.js +25 -0
  26. package/lib/module/core/mocks/UnistylesMockedBridge.js.map +1 -0
  27. package/lib/module/core/mocks/UnistylesMockedRegistry.js +39 -0
  28. package/lib/module/core/mocks/UnistylesMockedRegistry.js.map +1 -0
  29. package/lib/module/core/mocks/UnistylesMockedRuntime.js +69 -0
  30. package/lib/module/core/mocks/UnistylesMockedRuntime.js.map +1 -0
  31. package/lib/module/core/mocks/index.js +4 -0
  32. package/lib/module/core/mocks/index.js.map +1 -0
  33. package/lib/module/hooks/useUnistyles.js +2 -2
  34. package/lib/module/hooks/useUnistyles.js.map +1 -1
  35. package/lib/module/useStyles.js +1 -1
  36. package/lib/module/useStyles.js.map +1 -1
  37. package/lib/typescript/src/common.d.ts +2 -0
  38. package/lib/typescript/src/common.d.ts.map +1 -1
  39. package/lib/typescript/src/core/UnistyleRegistry.d.ts.map +1 -1
  40. package/lib/typescript/src/core/Unistyles.d.ts.map +1 -1
  41. package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts +24 -0
  42. package/lib/typescript/src/core/mocks/UnistylesMockedBridge.d.ts.map +1 -0
  43. package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts +21 -0
  44. package/lib/typescript/src/core/mocks/UnistylesMockedRegistry.d.ts.map +1 -0
  45. package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts +41 -0
  46. package/lib/typescript/src/core/mocks/UnistylesMockedRuntime.d.ts.map +1 -0
  47. package/lib/typescript/src/core/mocks/index.d.ts +4 -0
  48. package/lib/typescript/src/core/mocks/index.d.ts.map +1 -0
  49. package/lib/typescript/src/hooks/useUnistyles.d.ts +1 -1
  50. package/lib/typescript/src/types/breakpoints.d.ts +2 -1
  51. package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
  52. package/lib/typescript/src/types/stylesheet.d.ts +2 -1
  53. package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
  54. package/package.json +1 -1
  55. package/src/common.ts +2 -0
  56. package/src/core/UnistyleRegistry.ts +11 -5
  57. package/src/core/Unistyles.ts +10 -1
  58. package/src/core/mocks/UnistylesMockedBridge.ts +26 -0
  59. package/src/core/mocks/UnistylesMockedRegistry.ts +47 -0
  60. package/src/core/mocks/UnistylesMockedRuntime.ts +92 -0
  61. package/src/core/mocks/index.ts +3 -0
  62. package/src/hooks/useUnistyles.ts +2 -2
  63. package/src/types/breakpoints.ts +2 -1
  64. package/src/types/stylesheet.ts +2 -1
  65. package/src/useStyles.ts +1 -1
@@ -2,6 +2,7 @@ import type { ColorValue, OpaqueColorValue } from 'react-native'
2
2
  import type { UnistylesTheme } from '../types'
3
3
  import type { BreakpointsOrMediaQueries, ToDeepUnistyles } from './stylesheet'
4
4
  import type { TransformStyles } from './core'
5
+ import type { UnistylesRuntime } from '../core'
5
6
 
6
7
  type ExtractTransformArray<T> = T extends object
7
8
  ? { [K in keyof T]: ExtractBreakpoints<T[K]> }
@@ -56,6 +57,6 @@ type ParseStyleKeys<T> = T extends object
56
57
  ? { [K in keyof T]: ParseNestedObject<T[K]> }
57
58
  : never
58
59
 
59
- export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme) => infer R
60
+ export type ReactNativeStyleSheet<T> = T extends (theme: UnistylesTheme, runtime: UnistylesRuntime) => infer R
60
61
  ? ParseStyleKeys<R>
61
62
  : ParseStyleKeys<T>
@@ -1,6 +1,7 @@
1
1
  import type { ImageStyle, TextStyle, ViewStyle } from 'react-native'
2
2
  import type { ShadowOffset, TransformStyles, UnistylesTheme } from './core'
3
3
  import type { UnistylesBreakpoints } from '../global'
4
+ import type { UnistylesRuntime } from '../core'
4
5
 
5
6
  // these props are treated differently to nest breakpoints and media queries
6
7
  type NestedKeys = 'shadowOffset' | 'transform' | 'textShadowOffset'
@@ -46,4 +47,4 @@ export type StyleSheet = {
46
47
  [styleName: string]: UnistylesValues | ((...args: any) => UnistylesValues)
47
48
  }
48
49
 
49
- export type StyleSheetWithSuperPowers = ((theme: UnistylesTheme) => StyleSheet) | StyleSheet
50
+ export type StyleSheetWithSuperPowers = ((theme: UnistylesTheme, runtime: UnistylesRuntime) => StyleSheet) | StyleSheet
package/src/useStyles.ts CHANGED
@@ -26,7 +26,7 @@ export const useStyles = <ST extends StyleSheetWithSuperPowers>(
26
26
  const { theme, layout, plugins } = useUnistyles()
27
27
  const variants = useVariants(variantsMap)
28
28
  const parsedStyles = useMemo(() => typeof stylesheet === 'function'
29
- ? stylesheet(theme)
29
+ ? stylesheet(theme, unistyles.runtime)
30
30
  : stylesheet, [theme, stylesheet, layout])
31
31
 
32
32
  const dynamicStyleSheet = useMemo(() => Object