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.
- package/cxx/common/Helpers.h +10 -0
- package/cxx/core/UnistylesState.cpp +13 -1
- package/cxx/core/UnistylesState.h +2 -1
- package/cxx/hybridObjects/HybridStyleSheet.cpp +38 -5
- package/cxx/hybridObjects/HybridStyleSheet.h +3 -0
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +23 -3
- package/cxx/hybridObjects/HybridUnistylesRuntime.h +5 -0
- package/cxx/parser/Parser.cpp +1 -1
- package/ios/Equatable.swift +2 -1
- package/ios/NativePlatform+ios.swift +6 -1
- package/ios/NativePlatformListener+ios.swift +19 -19
- package/lib/commonjs/core/index.js +20 -0
- package/lib/commonjs/core/index.js.map +1 -0
- package/lib/commonjs/core/useBreakpoint.js +22 -0
- package/lib/commonjs/core/useBreakpoint.js.map +1 -0
- package/lib/commonjs/core/useBreakpoint.native.js +24 -0
- package/lib/commonjs/core/useBreakpoint.native.js.map +1 -0
- package/lib/commonjs/core/useTheme.js +22 -0
- package/lib/commonjs/core/useTheme.js.map +1 -0
- package/lib/commonjs/core/useTheme.native.js +24 -0
- package/lib/commonjs/core/useTheme.native.js.map +1 -0
- package/lib/commonjs/index.js +16 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/commonjs/specs/NavigtionBar/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.js +7 -0
- package/lib/commonjs/specs/index.js.map +1 -1
- package/lib/commonjs/web/runtime.js +13 -9
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/module/core/index.js +5 -0
- package/lib/module/core/index.js.map +1 -0
- package/lib/module/core/useBreakpoint.js +17 -0
- package/lib/module/core/useBreakpoint.js.map +1 -0
- package/lib/module/core/useBreakpoint.native.js +19 -0
- package/lib/module/core/useBreakpoint.native.js.map +1 -0
- package/lib/module/core/useTheme.js +17 -0
- package/lib/module/core/useTheme.js.map +1 -0
- package/lib/module/core/useTheme.native.js +19 -0
- package/lib/module/core/useTheme.native.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/NavigtionBar/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.js +2 -1
- package/lib/module/specs/index.js.map +1 -1
- package/lib/module/web/runtime.js +13 -9
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/typescript/example/App.d.ts.map +1 -1
- package/lib/typescript/example/Typography.d.ts +28 -5
- package/lib/typescript/example/Typography.d.ts.map +1 -1
- package/lib/typescript/src/core/index.d.ts +3 -0
- package/lib/typescript/src/core/index.d.ts.map +1 -0
- package/lib/typescript/src/core/useBreakpoint.d.ts +2 -0
- package/lib/typescript/src/core/useBreakpoint.d.ts.map +1 -0
- package/lib/typescript/src/core/useBreakpoint.native.d.ts +2 -0
- package/lib/typescript/src/core/useBreakpoint.native.d.ts.map +1 -0
- package/lib/typescript/src/core/useTheme.d.ts +41 -0
- package/lib/typescript/src/core/useTheme.d.ts.map +1 -0
- package/lib/typescript/src/core/useTheme.native.d.ts +41 -0
- package/lib/typescript/src/core/useTheme.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts +2 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/NavigtionBar/index.d.ts +5 -0
- package/lib/typescript/src/specs/NavigtionBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts +5 -0
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +2 -0
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +0 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +3 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.d.ts +4 -2
- package/lib/typescript/src/specs/index.d.ts.map +1 -1
- package/lib/typescript/src/types/index.d.ts +1 -1
- package/lib/typescript/src/types/index.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts +3 -0
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +1 -0
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JUnistylesNativeMiniRuntime.hpp +8 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/UnistylesNativeMiniRuntime.kt +2 -1
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.hpp +2 -2
- package/nitrogen/generated/ios/swift/UnistylesNativeMiniRuntime.swift +16 -5
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +6 -3
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +10 -9
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +9 -8
- package/package.json +1 -1
- package/plugin/common.js +3 -1
- package/plugin/stylesheet.js +2 -1
- package/src/core/index.ts +2 -0
- package/src/core/useBreakpoint.native.ts +21 -0
- package/src/core/useBreakpoint.ts +18 -0
- package/src/core/useTheme.native.ts +21 -0
- package/src/core/useTheme.ts +18 -0
- package/src/index.ts +3 -0
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +2 -1
- package/src/specs/NavigtionBar/index.ts +5 -0
- package/src/specs/StatusBar/index.ts +5 -0
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +3 -0
- package/src/specs/StyleSheet/index.ts +1 -1
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +0 -1
- package/src/specs/UnistylesRuntime/index.ts +3 -1
- package/src/specs/index.ts +6 -2
- package/src/types/index.ts +1 -1
- package/src/types/variants.ts +6 -0
- package/src/web/runtime.ts +17 -12
package/src/specs/index.ts
CHANGED
@@ -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
|
}
|
package/src/types/index.ts
CHANGED
@@ -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'
|
package/src/types/variants.ts
CHANGED
@@ -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
|
package/src/web/runtime.ts
CHANGED
@@ -67,17 +67,7 @@ class UnistylesRuntimeBuilder {
|
|
67
67
|
}
|
68
68
|
|
69
69
|
get theme() {
|
70
|
-
|
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
|
-
|
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()
|