react-native-unistyles 3.0.0-alpha.23 → 3.0.0-alpha.25

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. package/cxx/common/Helpers.h +10 -0
  2. package/cxx/core/UnistylesState.cpp +13 -1
  3. package/cxx/core/UnistylesState.h +2 -1
  4. package/cxx/hybridObjects/HybridStyleSheet.cpp +38 -5
  5. package/cxx/hybridObjects/HybridStyleSheet.h +3 -0
  6. package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +23 -3
  7. package/cxx/hybridObjects/HybridUnistylesRuntime.h +5 -0
  8. package/cxx/parser/Parser.cpp +1 -1
  9. package/ios/Equatable.swift +2 -1
  10. package/ios/NativePlatform+ios.swift +6 -1
  11. package/ios/NativePlatformListener+ios.swift +19 -19
  12. package/lib/commonjs/core/index.js +20 -0
  13. package/lib/commonjs/core/index.js.map +1 -0
  14. package/lib/commonjs/core/useBreakpoint.js +22 -0
  15. package/lib/commonjs/core/useBreakpoint.js.map +1 -0
  16. package/lib/commonjs/core/useBreakpoint.native.js +24 -0
  17. package/lib/commonjs/core/useBreakpoint.native.js.map +1 -0
  18. package/lib/commonjs/core/useTheme.js +22 -0
  19. package/lib/commonjs/core/useTheme.js.map +1 -0
  20. package/lib/commonjs/core/useTheme.native.js +24 -0
  21. package/lib/commonjs/core/useTheme.native.js.map +1 -0
  22. package/lib/commonjs/index.js +16 -1
  23. package/lib/commonjs/index.js.map +1 -1
  24. package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  25. package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
  26. package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
  27. package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
  28. package/lib/commonjs/specs/index.js +7 -0
  29. package/lib/commonjs/specs/index.js.map +1 -1
  30. package/lib/commonjs/web/runtime.js +13 -9
  31. package/lib/commonjs/web/runtime.js.map +1 -1
  32. package/lib/module/core/index.js +5 -0
  33. package/lib/module/core/index.js.map +1 -0
  34. package/lib/module/core/useBreakpoint.js +17 -0
  35. package/lib/module/core/useBreakpoint.js.map +1 -0
  36. package/lib/module/core/useBreakpoint.native.js +19 -0
  37. package/lib/module/core/useBreakpoint.native.js.map +1 -0
  38. package/lib/module/core/useTheme.js +17 -0
  39. package/lib/module/core/useTheme.js.map +1 -0
  40. package/lib/module/core/useTheme.native.js +19 -0
  41. package/lib/module/core/useTheme.native.js.map +1 -0
  42. package/lib/module/index.js +1 -0
  43. package/lib/module/index.js.map +1 -1
  44. package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
  45. package/lib/module/specs/NavigtionBar/index.js.map +1 -1
  46. package/lib/module/specs/StatusBar/index.js.map +1 -1
  47. package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
  48. package/lib/module/specs/index.js +2 -1
  49. package/lib/module/specs/index.js.map +1 -1
  50. package/lib/module/web/runtime.js +13 -9
  51. package/lib/module/web/runtime.js.map +1 -1
  52. package/lib/typescript/example/App.d.ts.map +1 -1
  53. package/lib/typescript/example/Typography.d.ts +28 -5
  54. package/lib/typescript/example/Typography.d.ts.map +1 -1
  55. package/lib/typescript/src/core/index.d.ts +3 -0
  56. package/lib/typescript/src/core/index.d.ts.map +1 -0
  57. package/lib/typescript/src/core/useBreakpoint.d.ts +2 -0
  58. package/lib/typescript/src/core/useBreakpoint.d.ts.map +1 -0
  59. package/lib/typescript/src/core/useBreakpoint.native.d.ts +2 -0
  60. package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +1 -0
  61. package/lib/typescript/src/core/useTheme.d.ts +41 -0
  62. package/lib/typescript/src/core/useTheme.d.ts.map +1 -0
  63. package/lib/typescript/src/core/useTheme.native.d.ts +41 -0
  64. package/lib/typescript/src/core/useTheme.native.d.ts.map +1 -0
  65. package/lib/typescript/src/index.d.ts +2 -0
  66. package/lib/typescript/src/index.d.ts.map +1 -1
  67. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +2 -1
  68. package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
  69. package/lib/typescript/src/specs/NavigtionBar/index.d.ts +5 -0
  70. package/lib/typescript/src/specs/NavigtionBar/index.d.ts.map +1 -1
  71. package/lib/typescript/src/specs/StatusBar/index.d.ts +5 -0
  72. package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
  73. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +2 -0
  74. package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
  75. package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -1
  76. package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
  77. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +0 -1
  78. package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
  79. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +3 -1
  80. package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
  81. package/lib/typescript/src/specs/index.d.ts +4 -2
  82. package/lib/typescript/src/specs/index.d.ts.map +1 -1
  83. package/lib/typescript/src/types/index.d.ts +1 -1
  84. package/lib/typescript/src/types/index.d.ts.map +1 -1
  85. package/lib/typescript/src/types/variants.d.ts +3 -0
  86. package/lib/typescript/src/types/variants.d.ts.map +1 -1
  87. package/lib/typescript/src/web/runtime.d.ts +1 -0
  88. package/lib/typescript/src/web/runtime.d.ts.map +1 -1
  89. package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +8 -6
  90. package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +2 -1
  91. package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +2 -2
  92. package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +16 -5
  93. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -0
  94. package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +6 -3
  95. package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +10 -9
  96. package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +9 -8
  97. package/package.json +1 -1
  98. package/plugin/common.js +3 -1
  99. package/plugin/stylesheet.js +2 -1
  100. package/src/core/index.ts +2 -0
  101. package/src/core/useBreakpoint.native.ts +21 -0
  102. package/src/core/useBreakpoint.ts +18 -0
  103. package/src/core/useTheme.native.ts +21 -0
  104. package/src/core/useTheme.ts +18 -0
  105. package/src/index.ts +3 -0
  106. package/src/specs/NativePlatform/NativePlatform.nitro.ts +2 -1
  107. package/src/specs/NavigtionBar/index.ts +5 -0
  108. package/src/specs/StatusBar/index.ts +5 -0
  109. package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +3 -0
  110. package/src/specs/StyleSheet/index.ts +1 -1
  111. package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +0 -1
  112. package/src/specs/UnistylesRuntime/index.ts +3 -1
  113. package/src/specs/index.ts +6 -2
  114. package/src/types/index.ts +1 -1
  115. package/src/types/variants.ts +6 -0
  116. package/src/web/runtime.ts +17 -12
@@ -2,14 +2,17 @@ import './TurboUnistyles'
2
2
 
3
3
  import { Runtime } from './UnistylesRuntime'
4
4
  import { StyleSheet } from './StyleSheet'
5
+ import type { UnistylesStyleSheet } from './StyleSheet'
5
6
  import { UnistylesShadowRegistry } from './ShadowRegistry'
6
7
  import type { UnistylesMiniRuntime } from './UnistylesRuntime'
7
8
  import { StatusBarStyle, ColorScheme, Orientation } from './types'
9
+ import { UnistyleDependency } from './NativePlatform'
8
10
 
9
11
  export {
10
12
  StatusBarStyle,
11
13
  ColorScheme,
12
- Orientation
14
+ Orientation,
15
+ UnistyleDependency
13
16
  }
14
17
 
15
18
  export {
@@ -19,5 +22,6 @@ export {
19
22
  }
20
23
 
21
24
  export type {
22
- UnistylesMiniRuntime
25
+ UnistylesMiniRuntime,
26
+ UnistylesStyleSheet
23
27
  }
@@ -17,5 +17,5 @@ export type {
17
17
  UnistyleImage
18
18
  } from './stylesheet'
19
19
  export type { ReactNativeStyleSheet } from './breakpoints'
20
- export type { ExtractVariantNames } from './variants'
20
+ export type { ExtractVariantNames, UnistylesVariants } from './variants'
21
21
  export { AndroidContentSizeCategory, IOSContentSizeCategory, WebContentSizeCategory } from './accessibility'
@@ -21,3 +21,9 @@ type ExtractSubVariantKeys<T> = T extends object
21
21
  type ExtractVariant<T> = T extends { variants: infer V }
22
22
  ? { [key in keyof V]?: ExtractSubVariantKeys<V[key]> }
23
23
  : T
24
+
25
+ export type UnistylesVariants<ST> = ST extends { useVariants: infer V }
26
+ ? V extends (variants: infer T) => void
27
+ ? T
28
+ : never
29
+ : never
@@ -67,17 +67,7 @@ class UnistylesRuntimeBuilder {
67
67
  }
68
68
 
69
69
  get theme() {
70
- if (!this.themeName) {
71
- throw new Error('🦄 No theme selected!')
72
- }
73
-
74
- const theme = UnistylesState.themes.get(this.themeName)
75
-
76
- if (!theme) {
77
- throw new Error(`🦄 Theme "${this.themeName}" is not registered!`)
78
- }
79
-
80
- return theme
70
+ return this.getTheme(this.themeName)
81
71
  }
82
72
 
83
73
  get pixelRatio() {
@@ -134,7 +124,8 @@ class UnistylesRuntimeBuilder {
134
124
  themeName: this.themeName,
135
125
  contentSizeCategory: this.contentSizeCategory,
136
126
  breakpoint: this.breakpoint,
137
- orientation: this.orientation,
127
+ isLandscape: this.orientation === Orientation.Landscape,
128
+ isPortrait: this.orientation === Orientation.Portrait,
138
129
  pixelRatio: this.pixelRatio,
139
130
  screen: this.screen,
140
131
  fontScale: this.fontScale,
@@ -191,6 +182,20 @@ class UnistylesRuntimeBuilder {
191
182
 
192
183
  UnistylesState.themes.set(themeName, updater(oldTheme))
193
184
  }
185
+
186
+ getTheme = (themeName = this.themeName) => {
187
+ if (!themeName) {
188
+ throw new Error('🦄 No theme selected!')
189
+ }
190
+
191
+ const theme = UnistylesState.themes.get(themeName)
192
+
193
+ if (!theme) {
194
+ throw new Error(`🦄 Theme "${this.themeName}" is not registered!`)
195
+ }
196
+
197
+ return theme
198
+ }
194
199
  }
195
200
 
196
201
  export const UnistylesRuntime = new UnistylesRuntimeBuilder()