react-native-unistyles 3.0.24 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/cxx/NativeUnistylesModule.cpp +7 -4
- package/android/src/main/cxx/NativeUnistylesModule.h +9 -3
- package/android/src/main/cxx/cpp-adapter.cpp +1 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +22 -4
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +1 -0
- package/cxx/core/StyleSheetRegistry.cpp +11 -11
- package/cxx/core/StyleSheetRegistry.h +4 -4
- package/cxx/core/UnistylesRegistry.cpp +27 -14
- package/cxx/core/UnistylesRegistry.h +4 -1
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +5 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +2 -14
- package/cxx/hybridObjects/HybridStyleSheet.h +0 -2
- package/ios/UnistylesModuleOnLoad.mm +10 -2
- package/lib/commonjs/components/AdaptiveTheme.js +1 -1
- package/lib/commonjs/components/AdaptiveTheme.js.map +1 -1
- package/lib/commonjs/components/ApplyScopedTheme.js.map +1 -1
- package/lib/commonjs/components/Display.js.map +1 -1
- package/lib/commonjs/components/Hide.js.map +1 -1
- package/lib/commonjs/components/NamedTheme.js +2 -2
- package/lib/commonjs/components/NamedTheme.js.map +1 -1
- package/lib/commonjs/components/ScopedTheme.js.map +1 -1
- package/lib/commonjs/components/native/ActivityIndicator.js.map +1 -1
- package/lib/commonjs/components/native/Animated.js.map +1 -1
- package/lib/commonjs/components/native/FlatList.js.map +1 -1
- package/lib/commonjs/components/native/Image.js.map +1 -1
- package/lib/commonjs/components/native/Image.native.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/ImageBackground.native.js.map +1 -1
- package/lib/commonjs/components/native/KeyboardAvoidingView.js.map +1 -1
- package/lib/commonjs/components/native/NativeText.native.js.map +1 -1
- package/lib/commonjs/components/native/NativeView.native.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/components/native/RefreshControl.js.map +1 -1
- package/lib/commonjs/components/native/SafeAreaView.js.map +1 -1
- package/lib/commonjs/components/native/ScrollView.js.map +1 -1
- package/lib/commonjs/components/native/SectionList.js.map +1 -1
- package/lib/commonjs/components/native/Switch.js.map +1 -1
- package/lib/commonjs/components/native/Text.js.map +1 -1
- package/lib/commonjs/components/native/TextInput.js.map +1 -1
- package/lib/commonjs/components/native/TouchableHighlight.js.map +1 -1
- package/lib/commonjs/components/native/TouchableOpacity.js.map +1 -1
- package/lib/commonjs/components/native/View.js.map +1 -1
- package/lib/commonjs/components/native/VirtualizedList.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/parseBoxShadow.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js +0 -1
- package/lib/commonjs/core/useProxifiedUnistyles/listener.native.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/useUnistyles.js.map +1 -1
- package/lib/commonjs/core/warn.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +3 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +6 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +0 -1
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
- package/lib/commonjs/index.js +6 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mocks.js +28 -8
- package/lib/commonjs/mocks.js.map +1 -1
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.js.map +1 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js +0 -1
- package/lib/commonjs/reanimated/useAnimatedTheme.native.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useAnimatedVariantColor.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.js.map +1 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js +0 -1
- package/lib/commonjs/reanimated/variant/useUpdateVariantColor.native.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +9 -5
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +1 -1
- package/lib/commonjs/specs/index.native.js.map +1 -1
- package/lib/commonjs/specs/types.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/commonjs/types/stylesheet.js.map +1 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/convert/object/objectStyle.js.map +1 -1
- package/lib/commonjs/web/convert/object/transform.js.map +1 -1
- package/lib/commonjs/web/convert/pseudo.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/getShadowBreakpoints.js.map +1 -1
- package/lib/commonjs/web/convert/shadow/textShadow.js.map +1 -1
- package/lib/commonjs/web/convert/types.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/create.js +1 -5
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/css/core.js.map +1 -1
- package/lib/commonjs/web/css/state.js.map +1 -1
- package/lib/commonjs/web/css/utils.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -0
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/listener.js +29 -8
- package/lib/commonjs/web/listener.js.map +1 -1
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +1 -2
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +3 -3
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js.map +1 -1
- package/lib/commonjs/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +2 -0
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/commonjs/web/variants.js.map +1 -1
- package/lib/commonjs/web-only/getWebProps.js.map +1 -1
- package/lib/commonjs/web-only/index.js.map +1 -1
- package/lib/module/components/AdaptiveTheme.js +1 -1
- package/lib/module/components/AdaptiveTheme.js.map +1 -1
- package/lib/module/components/ApplyScopedTheme.js.map +1 -1
- package/lib/module/components/Display.js.map +1 -1
- package/lib/module/components/Hide.js.map +1 -1
- package/lib/module/components/NamedTheme.js +2 -2
- package/lib/module/components/NamedTheme.js.map +1 -1
- package/lib/module/components/ScopedTheme.js.map +1 -1
- package/lib/module/components/native/ActivityIndicator.js.map +1 -1
- package/lib/module/components/native/Animated.js.map +1 -1
- package/lib/module/components/native/FlatList.js.map +1 -1
- package/lib/module/components/native/Image.js.map +1 -1
- package/lib/module/components/native/Image.native.js.map +1 -1
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/ImageBackground.native.js.map +1 -1
- package/lib/module/components/native/KeyboardAvoidingView.js.map +1 -1
- package/lib/module/components/native/NativeText.native.js.map +1 -1
- package/lib/module/components/native/NativeView.native.js.map +1 -1
- package/lib/module/components/native/Pressable.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/components/native/RefreshControl.js.map +1 -1
- package/lib/module/components/native/SafeAreaView.js.map +1 -1
- package/lib/module/components/native/ScrollView.js.map +1 -1
- package/lib/module/components/native/SectionList.js.map +1 -1
- package/lib/module/components/native/Switch.js.map +1 -1
- package/lib/module/components/native/Text.js.map +1 -1
- package/lib/module/components/native/TextInput.js.map +1 -1
- package/lib/module/components/native/TouchableHighlight.js.map +1 -1
- package/lib/module/components/native/TouchableOpacity.js.map +1 -1
- package/lib/module/components/native/View.js.map +1 -1
- package/lib/module/components/native/VirtualizedList.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/getClassname.js.map +1 -1
- package/lib/module/core/parseBoxShadow.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/listener.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/listener.native.js +0 -1
- package/lib/module/core/useProxifiedUnistyles/listener.native.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/useUnistyles.js.map +1 -1
- package/lib/module/core/warn.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.js +3 -1
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +6 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/hooks/useMedia.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +0 -1
- package/lib/module/hooks/useMedia.native.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mocks.js +28 -8
- package/lib/module/mocks.js.map +1 -1
- package/lib/module/mq.js.map +1 -1
- package/lib/module/reanimated/useAnimatedTheme.js.map +1 -1
- package/lib/module/reanimated/useAnimatedTheme.native.js +0 -1
- package/lib/module/reanimated/useAnimatedTheme.native.js.map +1 -1
- package/lib/module/reanimated/variant/useAnimatedVariantColor.js.map +1 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.js.map +1 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js +0 -1
- package/lib/module/reanimated/variant/useUpdateVariantColor.native.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/server/useServerUnistyles.js.map +1 -1
- package/lib/module/specs/NativePlatform/NativePlatform.nitro.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +9 -5
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/TurboUnistyles/NativeTurboUnistyles.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.native.js +1 -1
- package/lib/module/specs/index.native.js.map +1 -1
- package/lib/module/specs/types.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/module/types/stylesheet.js.map +1 -1
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js.map +1 -1
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/convert/object/objectStyle.js.map +1 -1
- package/lib/module/web/convert/object/transform.js.map +1 -1
- package/lib/module/web/convert/pseudo.js.map +1 -1
- package/lib/module/web/convert/shadow/boxShadow.js.map +1 -1
- package/lib/module/web/convert/shadow/getShadowBreakpoints.js.map +1 -1
- package/lib/module/web/convert/shadow/textShadow.js.map +1 -1
- package/lib/module/web/convert/types.js.map +1 -1
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/create.js +2 -6
- package/lib/module/web/create.js.map +1 -1
- package/lib/module/web/css/core.js.map +1 -1
- package/lib/module/web/css/state.js.map +1 -1
- package/lib/module/web/css/utils.js.map +1 -1
- package/lib/module/web/index.js +1 -0
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/listener.js +29 -8
- package/lib/module/web/listener.js.map +1 -1
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +1 -2
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +3 -3
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/common.js.map +1 -1
- package/lib/module/web/utils/createUnistylesRef.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +2 -0
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/module/web/variants.js.map +1 -1
- package/lib/module/web-only/getWebProps.js.map +1 -1
- package/lib/module/web-only/index.js.map +1 -1
- package/lib/typescript/src/__tests__/mocks.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/mocks.spec.d.ts.map +1 -0
- package/lib/typescript/src/__tests__/web-listener.spec.d.ts +2 -0
- package/lib/typescript/src/__tests__/web-listener.spec.d.ts.map +1 -0
- package/lib/typescript/src/components/AdaptiveTheme.d.ts +1 -1
- package/lib/typescript/src/components/AdaptiveTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/ApplyScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/Display.d.ts.map +1 -1
- package/lib/typescript/src/components/Hide.d.ts.map +1 -1
- package/lib/typescript/src/components/NamedTheme.d.ts +1 -1
- package/lib/typescript/src/components/NamedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -1
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts +1 -1
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SafeAreaView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
- package/lib/typescript/src/components/native/View.d.ts.map +1 -1
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/parseBoxShadow.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/listener.native.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/types.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/useUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/types.d.ts +1 -1
- package/lib/typescript/src/core/withUnistyles/types.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -1
- package/lib/typescript/src/global.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useAnimatedTheme.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/useAnimatedTheme.native.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/types.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useAnimatedVariantColor.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.d.ts.map +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts +1 -1
- package/lib/typescript/src/reanimated/variant/useUpdateVariantColor.native.d.ts.map +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/types.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativePlatform/NativePlatform.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +4 -5
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/UnistylesStatusBar.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts +1 -1
- package/lib/typescript/src/specs/StatusBar/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts +0 -1
- package/lib/typescript/src/specs/StyleSheet/UnistylesStyleSheet.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts +3 -3
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.native.d.ts +4 -4
- package/lib/typescript/src/specs/index.native.d.ts.map +1 -1
- package/lib/typescript/src/specs/types.d.ts.map +1 -1
- package/lib/typescript/src/types/breakpoints.d.ts +2 -2
- package/lib/typescript/src/types/breakpoints.d.ts.map +1 -1
- package/lib/typescript/src/types/core.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/stylesheet.d.ts +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/types/variants.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/index.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/boxShadow.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/filter.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/objectStyle.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/object/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/pseudo.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/types.d.ts +2 -2
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/create.d.ts +1 -1
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/css/core.d.ts.map +1 -1
- package/lib/typescript/src/web/css/state.d.ts.map +1 -1
- package/lib/typescript/src/web/css/utils.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/listener.d.ts +5 -1
- package/lib/typescript/src/web/listener.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +1 -1
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/types.d.ts +1 -1
- package/lib/typescript/src/web/types.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/common.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/createUnistylesRef.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/lib/typescript/src/web/variants.d.ts.map +1 -1
- package/lib/typescript/src/web-only/getWebProps.d.ts.map +1 -1
- package/lib/typescript/src/web-only/index.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.cpp +36 -42
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +19 -22
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +15 -18
- package/nitrogen/generated/android/unistylesOnLoad.cpp +14 -9
- package/nitrogen/generated/android/unistylesOnLoad.hpp +13 -4
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.cpp +0 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +0 -1
- package/package.json +43 -44
- package/plugin/index.d.ts +34 -28
- package/plugin/index.js +113 -103
- package/repack-plugin/index.d.ts +2 -2
- package/src/components/AdaptiveTheme.tsx +8 -12
- package/src/components/ApplyScopedTheme.tsx +2 -0
- package/src/components/Display.tsx +2 -3
- package/src/components/Hide.tsx +2 -3
- package/src/components/NamedTheme.tsx +9 -14
- package/src/components/ScopedTheme.tsx +22 -27
- package/src/components/native/ActivityIndicator.tsx +1 -0
- package/src/components/native/Animated.tsx +2 -1
- package/src/components/native/FlatList.tsx +1 -0
- package/src/components/native/Image.native.tsx +1 -0
- package/src/components/native/Image.tsx +11 -7
- package/src/components/native/ImageBackground.native.tsx +1 -0
- package/src/components/native/ImageBackground.tsx +11 -7
- package/src/components/native/KeyboardAvoidingView.tsx +1 -0
- package/src/components/native/NativeText.native.tsx +3 -1
- package/src/components/native/NativeView.native.tsx +3 -1
- package/src/components/native/Pressable.native.tsx +8 -8
- package/src/components/native/Pressable.tsx +25 -20
- package/src/components/native/RefreshControl.tsx +1 -0
- package/src/components/native/SafeAreaView.tsx +1 -0
- package/src/components/native/ScrollView.tsx +1 -0
- package/src/components/native/SectionList.tsx +1 -0
- package/src/components/native/Switch.tsx +1 -0
- package/src/components/native/Text.tsx +1 -0
- package/src/components/native/TextInput.tsx +1 -0
- package/src/components/native/TouchableHighlight.tsx +1 -0
- package/src/components/native/TouchableOpacity.tsx +1 -0
- package/src/components/native/View.tsx +1 -0
- package/src/components/native/VirtualizedList.tsx +1 -0
- package/src/core/createUnistylesElement.native.tsx +4 -2
- package/src/core/createUnistylesElement.tsx +14 -17
- package/src/core/createUnistylesImageBackground.tsx +6 -4
- package/src/core/getClassname.ts +4 -11
- package/src/core/parseBoxShadow.ts +11 -24
- package/src/core/passForwardRef.ts +1 -1
- package/src/core/useProxifiedUnistyles/listener.native.ts +3 -3
- package/src/core/useProxifiedUnistyles/listener.ts +10 -3
- package/src/core/useProxifiedUnistyles/types.ts +2 -2
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +13 -9
- package/src/core/useUnistyles.ts +2 -1
- package/src/core/warn.ts +4 -4
- package/src/core/withUnistyles/types.ts +7 -4
- package/src/core/withUnistyles/withUnistyles.native.tsx +53 -44
- package/src/core/withUnistyles/withUnistyles.tsx +30 -24
- package/src/global.ts +2 -2
- package/src/hooks/useMedia.native.ts +2 -2
- package/src/hooks/useMedia.ts +6 -3
- package/src/index.ts +1 -0
- package/src/mocks.ts +74 -49
- package/src/mq.ts +23 -15
- package/src/reanimated/useAnimatedTheme.native.ts +4 -3
- package/src/reanimated/useAnimatedTheme.ts +6 -2
- package/src/reanimated/variant/types.ts +11 -10
- package/src/reanimated/variant/useAnimatedVariantColor.ts +7 -7
- package/src/reanimated/variant/useUpdateVariantColor.native.ts +10 -6
- package/src/reanimated/variant/useUpdateVariantColor.ts +21 -21
- package/src/server/getServerUnistyles.tsx +11 -4
- package/src/server/index.ts +0 -1
- package/src/server/types.ts +1 -1
- package/src/server/useServerUnistyles.tsx +4 -1
- package/src/specs/NativePlatform/NativePlatform.nitro.ts +30 -27
- package/src/specs/NavigtionBar/UnistylesNavigationBar.nitro.ts +3 -3
- package/src/specs/ShadowRegistry/ShadowRegistry.nitro.ts +1 -1
- package/src/specs/ShadowRegistry/index.ts +35 -29
- package/src/specs/ShadowRegistry/types.ts +9 -10
- package/src/specs/StatusBar/UnistylesStatusBar.nitro.ts +4 -4
- package/src/specs/StatusBar/index.ts +5 -5
- package/src/specs/StyleSheet/UnistylesStyleSheet.nitro.ts +2 -2
- package/src/specs/StyleSheet/index.ts +32 -27
- package/src/specs/TurboUnistyles/NativeTurboUnistyles.ts +1 -0
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +26 -25
- package/src/specs/UnistylesRuntime/index.ts +20 -20
- package/src/specs/index.native.ts +6 -18
- package/src/specs/types.ts +9 -8
- package/src/types/accessibility.ts +2 -2
- package/src/types/breakpoints.ts +61 -59
- package/src/types/core.ts +17 -17
- package/src/types/index.ts +2 -9
- package/src/types/stylesheet.ts +27 -19
- package/src/types/variants.ts +3 -11
- package/src/utils.ts +16 -16
- package/src/web/convert/index.ts +6 -2
- package/src/web/convert/object/boxShadow.ts +23 -18
- package/src/web/convert/object/filter.ts +30 -13
- package/src/web/convert/object/objectStyle.ts +33 -23
- package/src/web/convert/object/transform.ts +10 -8
- package/src/web/convert/pseudo.ts +2 -2
- package/src/web/convert/shadow/boxShadow.ts +6 -6
- package/src/web/convert/shadow/getShadowBreakpoints.ts +4 -4
- package/src/web/convert/shadow/textShadow.ts +6 -6
- package/src/web/convert/style.ts +25 -25
- package/src/web/convert/types.ts +4 -3
- package/src/web/convert/utils.ts +20 -10
- package/src/web/create.ts +29 -20
- package/src/web/css/core.ts +2 -1
- package/src/web/css/state.ts +11 -8
- package/src/web/css/utils.ts +2 -1
- package/src/web/index.ts +7 -4
- package/src/web/listener.ts +61 -18
- package/src/web/mock.ts +2 -2
- package/src/web/registry.ts +17 -10
- package/src/web/runtime.ts +23 -17
- package/src/web/shadowRegistry.ts +26 -24
- package/src/web/state.ts +23 -16
- package/src/web/types.ts +5 -5
- package/src/web/utils/common.ts +7 -9
- package/src/web/utils/createUnistylesRef.ts +18 -14
- package/src/web/utils/unistyle.ts +53 -34
- package/src/web/variants.ts +19 -11
- package/src/web-only/getWebProps.ts +5 -6
- package/src/web-only/index.ts +0 -1
- package/LICENSE +0 -20
- package/README.md +0 -178
- package/lib/typescript/plugin/src/consts.d.ts +0 -17
- package/lib/typescript/plugin/src/consts.d.ts.map +0 -1
- package/lib/typescript/repack-plugin/src/index.d.ts +0 -18
- package/lib/typescript/repack-plugin/src/index.d.ts.map +0 -1
- package/lib/typescript/repack-plugin/src/loader.d.ts +0 -9
- package/lib/typescript/repack-plugin/src/loader.d.ts.map +0 -1
package/src/web/runtime.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { UnistyleDependency } from '../specs/NativePlatform'
|
|
2
1
|
import type { UnistylesMiniRuntime } from '../specs/UnistylesRuntime'
|
|
2
|
+
import type { UnistylesServices } from './types'
|
|
3
|
+
|
|
4
|
+
import { UnistyleDependency } from '../specs/NativePlatform'
|
|
3
5
|
import { type AppTheme, type AppThemeName, ColorScheme, Orientation } from '../specs/types'
|
|
4
6
|
import { type UnistylesTheme, WebContentSizeCategory } from '../types'
|
|
5
7
|
import { NavigationBar, StatusBar } from './mock'
|
|
6
|
-
import type { UnistylesServices } from './types'
|
|
7
8
|
import { convertTheme, error, isServer, schemeToTheme } from './utils'
|
|
8
9
|
|
|
9
10
|
export class UnistylesRuntime {
|
|
@@ -102,13 +103,13 @@ export class UnistylesRuntime {
|
|
|
102
103
|
if (isServer()) {
|
|
103
104
|
return {
|
|
104
105
|
width: 0,
|
|
105
|
-
height: 0
|
|
106
|
+
height: 0,
|
|
106
107
|
}
|
|
107
108
|
}
|
|
108
109
|
|
|
109
110
|
return {
|
|
110
111
|
width: window.innerWidth,
|
|
111
|
-
height: window.innerHeight
|
|
112
|
+
height: window.innerHeight,
|
|
112
113
|
}
|
|
113
114
|
}
|
|
114
115
|
|
|
@@ -122,7 +123,7 @@ export class UnistylesRuntime {
|
|
|
122
123
|
bottom: 0,
|
|
123
124
|
left: 0,
|
|
124
125
|
right: 0,
|
|
125
|
-
ime: 0
|
|
126
|
+
ime: 0,
|
|
126
127
|
}
|
|
127
128
|
}
|
|
128
129
|
|
|
@@ -156,14 +157,14 @@ export class UnistylesRuntime {
|
|
|
156
157
|
insets: this.insets,
|
|
157
158
|
statusBar: {
|
|
158
159
|
width: this.statusBar.width,
|
|
159
|
-
height: this.statusBar.height
|
|
160
|
+
height: this.statusBar.height,
|
|
160
161
|
},
|
|
161
162
|
navigationBar: {
|
|
162
163
|
width: this.navigationBar.width,
|
|
163
164
|
height: this.navigationBar.height,
|
|
164
165
|
},
|
|
165
166
|
rtl: this.rtl,
|
|
166
|
-
hasAdaptiveThemes: this.hasAdaptiveThemes
|
|
167
|
+
hasAdaptiveThemes: this.hasAdaptiveThemes,
|
|
167
168
|
}
|
|
168
169
|
}
|
|
169
170
|
|
|
@@ -179,8 +180,7 @@ export class UnistylesRuntime {
|
|
|
179
180
|
const oldTheme = this.services.state.themeName
|
|
180
181
|
|
|
181
182
|
this.services.state.themeName = themeName
|
|
182
|
-
this.services.listener.
|
|
183
|
-
this.services.listener.emitChange(UnistyleDependency.ThemeName)
|
|
183
|
+
this.services.listener.emitChanges([UnistyleDependency.Theme, UnistyleDependency.ThemeName])
|
|
184
184
|
|
|
185
185
|
if (!isServer() && !this.services.state.hasAdaptiveThemes && this.services.state.CSSVars) {
|
|
186
186
|
this.rootElement?.classList.remove(oldTheme ?? '')
|
|
@@ -232,9 +232,11 @@ export class UnistylesRuntime {
|
|
|
232
232
|
if (this.services.state.CSSVars) {
|
|
233
233
|
this.services.state.cssThemes.set(
|
|
234
234
|
themeName,
|
|
235
|
-
Object.fromEntries(
|
|
236
|
-
|
|
237
|
-
|
|
235
|
+
Object.fromEntries(
|
|
236
|
+
Object.entries(newTheme).map(([key, value]) => {
|
|
237
|
+
return convertTheme(key, value)
|
|
238
|
+
}),
|
|
239
|
+
) as UnistylesTheme,
|
|
238
240
|
)
|
|
239
241
|
this.services.registry.css.addTheme(themeName, newTheme)
|
|
240
242
|
this.services.registry.css.recreate()
|
|
@@ -247,16 +249,20 @@ export class UnistylesRuntime {
|
|
|
247
249
|
if (!hasSomeThemes) {
|
|
248
250
|
return new Proxy({} as UnistylesTheme, {
|
|
249
251
|
get: () => {
|
|
250
|
-
throw error(
|
|
251
|
-
|
|
252
|
+
throw error(
|
|
253
|
+
'One of your stylesheets is trying to get the theme, but no theme has been selected yet. Did you forget to call StyleSheet.configure? If you called it, make sure you did so before any StyleSheet.create.',
|
|
254
|
+
)
|
|
255
|
+
},
|
|
252
256
|
})
|
|
253
257
|
}
|
|
254
258
|
|
|
255
259
|
if (!themeName) {
|
|
256
260
|
return new Proxy({} as UnistylesTheme, {
|
|
257
261
|
get: () => {
|
|
258
|
-
throw error(
|
|
259
|
-
|
|
262
|
+
throw error(
|
|
263
|
+
'One of your stylesheets is trying to get the theme, but no theme has been selected yet. Did you forget to select an initial theme?',
|
|
264
|
+
)
|
|
265
|
+
},
|
|
260
266
|
})
|
|
261
267
|
}
|
|
262
268
|
|
|
@@ -268,7 +274,7 @@ export class UnistylesRuntime {
|
|
|
268
274
|
return new Proxy({} as UnistylesTheme, {
|
|
269
275
|
get: () => {
|
|
270
276
|
throw error(`You're trying to get theme "${themeName}" but it wasn't registered.`)
|
|
271
|
-
}
|
|
277
|
+
},
|
|
272
278
|
})
|
|
273
279
|
}
|
|
274
280
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { UnistyleDependency } from '../specs/NativePlatform/NativePlatform.nitro'
|
|
2
1
|
import type { UnistylesTheme, UnistylesValues } from '../types'
|
|
3
|
-
import { deepMergeObjects } from '../utils'
|
|
4
2
|
import type { UniGeneratedStyle, UnistylesServices } from './types'
|
|
3
|
+
|
|
4
|
+
import { UnistyleDependency } from '../specs/NativePlatform/NativePlatform.nitro'
|
|
5
|
+
import { deepMergeObjects } from '../utils'
|
|
5
6
|
import { extractSecrets, extractUnistyleDependencies, isGeneratedUnistyle, isServer } from './utils'
|
|
6
7
|
import { getVariants } from './variants'
|
|
7
8
|
|
|
@@ -36,7 +37,7 @@ export class UnistylesShadowRegistry {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
const getParsedStyles = () => {
|
|
39
|
-
const allStyles = unistyles.map(unistyle => {
|
|
40
|
+
const allStyles = unistyles.map((unistyle) => {
|
|
40
41
|
const secrets = extractSecrets(unistyle)
|
|
41
42
|
|
|
42
43
|
// Regular style
|
|
@@ -50,11 +51,12 @@ export class UnistylesShadowRegistry {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
const { __uni__key, __uni__stylesheet, __uni__args = [], __stylesheetVariants: variants } = secrets
|
|
53
|
-
const newComputedStylesheet = this.services.registry.getComputedStylesheet(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
const newComputedStylesheet = this.services.registry.getComputedStylesheet(
|
|
55
|
+
__uni__stylesheet,
|
|
56
|
+
scopedTheme,
|
|
57
|
+
)
|
|
58
|
+
const style = newComputedStylesheet[__uni__key] as UnistylesValues | ((...args: any) => UnistylesValues)
|
|
59
|
+
const result = typeof style === 'function' ? style(...__uni__args) : style
|
|
58
60
|
const variantsResult = getVariants(result, variants)
|
|
59
61
|
const resultWithVariants = deepMergeObjects(result, variantsResult)
|
|
60
62
|
const dependencies = extractUnistyleDependencies(resultWithVariants)
|
|
@@ -66,7 +68,7 @@ export class UnistylesShadowRegistry {
|
|
|
66
68
|
|
|
67
69
|
return {
|
|
68
70
|
...resultWithVariants,
|
|
69
|
-
...resultWithVariants._web
|
|
71
|
+
...resultWithVariants._web,
|
|
70
72
|
} as UnistylesValues
|
|
71
73
|
})
|
|
72
74
|
|
|
@@ -81,18 +83,19 @@ export class UnistylesShadowRegistry {
|
|
|
81
83
|
const injectedClassName = Array.isArray(injectedClassNames) ? injectedClassNames.join(' ') : injectedClassNames
|
|
82
84
|
const dependencies = extractUnistyleDependencies(parsedStyles)
|
|
83
85
|
const filteredDependencies = this.services.state.CSSVars
|
|
84
|
-
? dependencies.filter(dependency => dependency !== UnistyleDependency.Theme)
|
|
86
|
+
? dependencies.filter((dependency) => dependency !== UnistyleDependency.Theme)
|
|
85
87
|
: dependencies
|
|
86
88
|
|
|
87
89
|
if (!existingHash) {
|
|
88
|
-
this.disposeMap.set(
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
this.disposeMap.set(
|
|
91
|
+
hash,
|
|
92
|
+
this.services.listener.addListeners(filteredDependencies, () => {
|
|
93
|
+
this.services.registry.applyStyles(hash, getParsedStyles())
|
|
94
|
+
}),
|
|
95
|
+
)
|
|
91
96
|
}
|
|
92
97
|
|
|
93
|
-
const hashClassname = forChild
|
|
94
|
-
? hash.replace(' > *', '')
|
|
95
|
-
: hash
|
|
98
|
+
const hashClassname = forChild ? hash.replace(' > *', '') : hash
|
|
96
99
|
|
|
97
100
|
return { injectedClassName, hash: hashClassname, parsedStyles }
|
|
98
101
|
}
|
|
@@ -108,15 +111,14 @@ export class UnistylesShadowRegistry {
|
|
|
108
111
|
return
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
this.services.registry.remove(ref, hash)
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
}
|
|
114
|
+
this.services.registry.remove(ref, hash).then((removed) => {
|
|
115
|
+
if (!removed) {
|
|
116
|
+
return
|
|
117
|
+
}
|
|
116
118
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
this.disposeMap.get(hash)?.()
|
|
120
|
+
this.disposeMap.delete(hash)
|
|
121
|
+
})
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
flush = () => {}
|
package/src/web/state.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import type { UnistylesBreakpoints, UnistylesThemes } from '../global'
|
|
2
|
-
import { UnistyleDependency } from '../specs/NativePlatform'
|
|
3
2
|
import type { UnistylesConfig } from '../specs/StyleSheet'
|
|
4
3
|
import type { AppBreakpoint, AppTheme, AppThemeName } from '../specs/types'
|
|
5
4
|
import type { UnistylesTheme } from '../types'
|
|
6
5
|
import type { UnionToIntersection } from '../types'
|
|
7
6
|
import type { UnistylesServices } from './types'
|
|
7
|
+
|
|
8
|
+
import { UnistyleDependency } from '../specs/NativePlatform'
|
|
8
9
|
import { convertTheme, error, isServer, schemeToTheme } from './utils'
|
|
9
10
|
|
|
10
|
-
type RemoveNevers<T> = { [K in keyof T as T[K] extends
|
|
11
|
+
type RemoveNevers<T> = { [K in keyof T as T[K] extends never | undefined ? never : K]: T[K] }
|
|
11
12
|
type UnistylesSettings = Partial<UnionToIntersection<RemoveNevers<Required<UnistylesConfig>['settings']>>>
|
|
12
13
|
|
|
13
14
|
export class UnistylesState {
|
|
@@ -21,9 +22,10 @@ export class UnistylesState {
|
|
|
21
22
|
private _config: UnistylesConfig = {}
|
|
22
23
|
|
|
23
24
|
get breakpoint() {
|
|
24
|
-
const [currentBreakpoint] =
|
|
25
|
-
.
|
|
26
|
-
|
|
25
|
+
const [currentBreakpoint] =
|
|
26
|
+
Array.from(this.matchingBreakpoints)
|
|
27
|
+
.reverse()
|
|
28
|
+
.find(([_key, value]) => value) ?? []
|
|
27
29
|
|
|
28
30
|
return currentBreakpoint as AppBreakpoint | undefined
|
|
29
31
|
}
|
|
@@ -72,9 +74,11 @@ export class UnistylesState {
|
|
|
72
74
|
this.services.registry.css.addTheme(themeName, theme)
|
|
73
75
|
this.cssThemes.set(
|
|
74
76
|
themeName,
|
|
75
|
-
Object.fromEntries(
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
Object.fromEntries(
|
|
78
|
+
Object.entries(theme).map(([key, value]) => {
|
|
79
|
+
return convertTheme(key, value)
|
|
80
|
+
}),
|
|
81
|
+
) as UnistylesTheme,
|
|
78
82
|
)
|
|
79
83
|
}
|
|
80
84
|
})
|
|
@@ -84,13 +88,17 @@ export class UnistylesState {
|
|
|
84
88
|
this.hasAdaptiveThemes = settings?.adaptiveThemes ?? false
|
|
85
89
|
|
|
86
90
|
if (settings?.initialTheme && settings.adaptiveThemes) {
|
|
87
|
-
throw error(
|
|
91
|
+
throw error(
|
|
92
|
+
"You're trying to set initial theme and enable adaptiveThemes, but these options are mutually exclusive.",
|
|
93
|
+
)
|
|
88
94
|
}
|
|
89
95
|
|
|
90
96
|
// Adaptive themes
|
|
91
97
|
if (settings?.adaptiveThemes) {
|
|
92
98
|
if (!this.themes.get('light') || !this.themes.get('dark')) {
|
|
93
|
-
throw error(
|
|
99
|
+
throw error(
|
|
100
|
+
`You're trying to enable adaptiveThemes, but you didn't register both 'light' and 'dark' themes.`,
|
|
101
|
+
)
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
this.themeName = schemeToTheme(this.services.runtime.colorScheme) as AppThemeName
|
|
@@ -99,9 +107,8 @@ export class UnistylesState {
|
|
|
99
107
|
}
|
|
100
108
|
|
|
101
109
|
if (settings?.initialTheme) {
|
|
102
|
-
const initialTheme =
|
|
103
|
-
? settings.initialTheme()
|
|
104
|
-
: settings.initialTheme
|
|
110
|
+
const initialTheme =
|
|
111
|
+
typeof settings.initialTheme === 'function' ? settings.initialTheme() : settings.initialTheme
|
|
105
112
|
|
|
106
113
|
if (!this.themes.get(initialTheme)) {
|
|
107
114
|
throw error(`You're trying to select theme "${initialTheme}" but it wasn't registered.`)
|
|
@@ -126,11 +133,11 @@ export class UnistylesState {
|
|
|
126
133
|
const breakpointsEntries = Object.entries(breakpoints)
|
|
127
134
|
|
|
128
135
|
if (breakpointsEntries.length === 0) {
|
|
129
|
-
throw error(
|
|
136
|
+
throw error("StyleSheet.configure's breakpoints can't be empty.")
|
|
130
137
|
}
|
|
131
138
|
|
|
132
139
|
if (breakpointsEntries?.[0]?.[1] !== 0) {
|
|
133
|
-
throw error(
|
|
140
|
+
throw error("StyleSheet.configure's first breakpoint must start from 0.")
|
|
134
141
|
}
|
|
135
142
|
|
|
136
143
|
breakpointsEntries
|
|
@@ -143,7 +150,7 @@ export class UnistylesState {
|
|
|
143
150
|
const mediaQuery = window.matchMedia(`(min-width: ${value}px)`)
|
|
144
151
|
this.matchingBreakpoints.set(breakpoint, mediaQuery.matches)
|
|
145
152
|
|
|
146
|
-
mediaQuery.addEventListener('change', event => {
|
|
153
|
+
mediaQuery.addEventListener('change', (event) => {
|
|
147
154
|
this.matchingBreakpoints.set(breakpoint, event.matches)
|
|
148
155
|
this.services.listener.emitChange(UnistyleDependency.Breakpoints)
|
|
149
156
|
})
|
package/src/web/types.ts
CHANGED
|
@@ -6,15 +6,15 @@ import type { UnistylesShadowRegistry } from './shadowRegistry'
|
|
|
6
6
|
import type { UnistylesState } from './state'
|
|
7
7
|
|
|
8
8
|
export type UnistylesServices = {
|
|
9
|
-
runtime: UnistylesRuntime
|
|
10
|
-
registry: UnistylesRegistry
|
|
11
|
-
shadowRegistry: UnistylesShadowRegistry
|
|
12
|
-
state: UnistylesState
|
|
9
|
+
runtime: UnistylesRuntime
|
|
10
|
+
registry: UnistylesRegistry
|
|
11
|
+
shadowRegistry: UnistylesShadowRegistry
|
|
12
|
+
state: UnistylesState
|
|
13
13
|
listener: UnistylesListener
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export const UNI_GENERATED_KEYS = ['$$css', 'hash', 'injectedClassName'] as const
|
|
17
|
-
export type UniGeneratedKey = typeof UNI_GENERATED_KEYS[number]
|
|
17
|
+
export type UniGeneratedKey = (typeof UNI_GENERATED_KEYS)[number]
|
|
18
18
|
|
|
19
19
|
export type UniGeneratedStyle = Record<UniGeneratedKey, string> & {
|
|
20
20
|
parsedStyles?: UnistylesValues
|
package/src/web/utils/common.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
export const reduceObject = <TObj extends Record<string, any>, TReducer>(
|
|
2
2
|
obj: TObj,
|
|
3
3
|
reducer: (value: TObj[keyof TObj], key: keyof TObj) => TReducer,
|
|
4
|
-
) =>
|
|
4
|
+
) =>
|
|
5
|
+
Object.fromEntries(Object.entries(obj).map(([key, value]) => [key, reducer(value as TObj[keyof TObj], key)])) as {
|
|
6
|
+
[K in keyof TObj]: TReducer
|
|
7
|
+
}
|
|
5
8
|
|
|
6
9
|
export const keyInObject = <T extends Record<string, any>>(obj: T, key: PropertyKey): key is keyof T => key in obj
|
|
7
10
|
|
|
@@ -14,12 +17,7 @@ export const equal = <T>(a: T, b: T) => {
|
|
|
14
17
|
return true
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
if (
|
|
18
|
-
typeof a !== 'object'
|
|
19
|
-
|| a === null
|
|
20
|
-
|| typeof b !== 'object'
|
|
21
|
-
|| b === null
|
|
22
|
-
) {
|
|
20
|
+
if (typeof a !== 'object' || a === null || typeof b !== 'object' || b === null) {
|
|
23
21
|
return false
|
|
24
22
|
}
|
|
25
23
|
|
|
@@ -29,7 +27,7 @@ export const equal = <T>(a: T, b: T) => {
|
|
|
29
27
|
return false
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
return keysA.every(key => Object.is(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key))
|
|
30
|
+
return keysA.every((key) => Object.is(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key))
|
|
33
31
|
}
|
|
34
32
|
|
|
35
33
|
export const hyphenate = (propertyName: string) => propertyName.replace(/[A-Z]/g, (m: string) => `-${m.toLowerCase()}`)
|
|
@@ -40,7 +38,7 @@ export const serialize = (obj: string | number | object): string => {
|
|
|
40
38
|
}
|
|
41
39
|
|
|
42
40
|
const sortedKeys = Object.keys(obj).sort()
|
|
43
|
-
const sortedKeyValuePairs = sortedKeys.map(key => `${key}:${serialize(obj[key as keyof typeof obj])}`)
|
|
41
|
+
const sortedKeyValuePairs = sortedKeys.map((key) => `${key}:${serialize(obj[key as keyof typeof obj])}`)
|
|
44
42
|
|
|
45
43
|
return `{${sortedKeyValuePairs.join(',')}}`
|
|
46
44
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type React from 'react'
|
|
2
|
+
|
|
2
3
|
import type { Nullable, UnistylesValues } from '../../types'
|
|
4
|
+
|
|
3
5
|
import * as unistyles from '../services'
|
|
4
6
|
import { isServer } from './common'
|
|
5
7
|
|
|
@@ -7,27 +9,29 @@ type Styles = readonly [
|
|
|
7
9
|
{
|
|
8
10
|
hash: string
|
|
9
11
|
},
|
|
10
|
-
Array<UnistylesValues
|
|
12
|
+
Array<UnistylesValues>,
|
|
11
13
|
]
|
|
12
14
|
|
|
13
15
|
export const createUnistylesRef = <T>(styles?: Styles, forwardedRef?: React.ForwardedRef<T>) => {
|
|
14
16
|
const storedRef = { current: null as Nullable<T> }
|
|
15
17
|
const [classNames] = styles ?? []
|
|
16
18
|
|
|
17
|
-
return isServer()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
return isServer()
|
|
20
|
+
? undefined
|
|
21
|
+
: (ref: Nullable<T>) => {
|
|
22
|
+
if (!ref) {
|
|
23
|
+
unistyles.services.shadowRegistry.remove(storedRef, classNames?.hash)
|
|
24
|
+
}
|
|
21
25
|
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
storedRef.current = ref
|
|
27
|
+
unistyles.services.shadowRegistry.add(ref, classNames?.hash)
|
|
24
28
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
if (typeof forwardedRef === 'function') {
|
|
30
|
+
return forwardedRef(ref)
|
|
31
|
+
}
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
if (forwardedRef) {
|
|
34
|
+
forwardedRef.current = ref
|
|
35
|
+
}
|
|
36
|
+
}
|
|
33
37
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { Animated } from 'react-native'
|
|
2
|
+
|
|
2
3
|
import type { UnistylesBreakpoints } from '../../global'
|
|
3
4
|
import type { UnistyleDependency } from '../../specs/NativePlatform/NativePlatform.nitro'
|
|
4
|
-
import { ColorScheme, Orientation } from '../../specs/types'
|
|
5
5
|
import type { StyleSheet, StyleSheetWithSuperPowers, UnistylesValues } from '../../types/stylesheet'
|
|
6
|
-
import { isDefined, isUnistylesMq, parseMq } from '../../utils'
|
|
7
6
|
import type { UnistylesRuntime } from '../runtime'
|
|
7
|
+
|
|
8
|
+
import { ColorScheme, Orientation } from '../../specs/types'
|
|
9
|
+
import { isDefined, isUnistylesMq, parseMq } from '../../utils'
|
|
8
10
|
import * as unistyles from '../services'
|
|
9
11
|
import { UNI_GENERATED_KEYS, type UniGeneratedKey, type UniGeneratedStyle } from '../types'
|
|
10
12
|
import { hyphenate, keyInObject, reduceObject } from './common'
|
|
@@ -20,9 +22,9 @@ export const schemeToTheme = (scheme: ColorScheme) => {
|
|
|
20
22
|
}
|
|
21
23
|
|
|
22
24
|
export type UnistyleSecrets = {
|
|
23
|
-
__uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet
|
|
24
|
-
__uni__key: string
|
|
25
|
-
__uni__args?: Array<any
|
|
25
|
+
__uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>
|
|
26
|
+
__uni__key: string
|
|
27
|
+
__uni__args?: Array<any>
|
|
26
28
|
__stylesheetVariants: Record<string, string | boolean | undefined>
|
|
27
29
|
}
|
|
28
30
|
|
|
@@ -32,10 +34,11 @@ export const assignSecrets = <T>(object: T, secrets: UnistyleSecrets) => {
|
|
|
32
34
|
// @ts-expect-error assign hidden secrets
|
|
33
35
|
object[`unistyles_${secretsId}`] = {}
|
|
34
36
|
// @ts-expect-error assign hidden secrets
|
|
35
|
-
|
|
37
|
+
// prettier-ignore
|
|
38
|
+
Object.defineProperties(object[`unistyles_${secretsId}`], reduceObject(secrets, (secret) => ({
|
|
36
39
|
value: secret,
|
|
37
40
|
enumerable: false,
|
|
38
|
-
configurable: true
|
|
41
|
+
configurable: true,
|
|
39
42
|
})))
|
|
40
43
|
|
|
41
44
|
return object
|
|
@@ -52,17 +55,20 @@ export const extractSecrets = (object: any) => {
|
|
|
52
55
|
return undefined
|
|
53
56
|
}
|
|
54
57
|
|
|
55
|
-
return reduceObject(Object.getOwnPropertyDescriptors(secrets), secret => secret.value)
|
|
58
|
+
return reduceObject(Object.getOwnPropertyDescriptors(secrets), (secret) => secret.value)
|
|
56
59
|
}
|
|
57
60
|
|
|
58
61
|
export const removeInlineStyles = (values: UnistylesValues) => {
|
|
59
62
|
const returnValue = {}
|
|
60
63
|
|
|
61
|
-
Object.defineProperties(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
Object.defineProperties(
|
|
65
|
+
returnValue,
|
|
66
|
+
reduceObject(values, (value) => ({
|
|
67
|
+
value,
|
|
68
|
+
enumerable: false,
|
|
69
|
+
configurable: true,
|
|
70
|
+
})),
|
|
71
|
+
)
|
|
66
72
|
|
|
67
73
|
return returnValue
|
|
68
74
|
}
|
|
@@ -79,21 +85,25 @@ export const getMediaQuery = (query: string, allBreakpoints: Array<string>) => {
|
|
|
79
85
|
minWidth ? `(min-width: ${minWidth}px)` : undefined,
|
|
80
86
|
maxWidth ? `(max-width: ${maxWidth}px)` : undefined,
|
|
81
87
|
minHeight ? `(min-height: ${minHeight}px)` : undefined,
|
|
82
|
-
maxHeight ? `(max-height: ${maxHeight}px)` : undefined
|
|
83
|
-
]
|
|
88
|
+
maxHeight ? `(max-height: ${maxHeight}px)` : undefined,
|
|
89
|
+
]
|
|
90
|
+
.filter(Boolean)
|
|
91
|
+
.join(' and ')
|
|
84
92
|
return `@media ${queries}`
|
|
85
93
|
}
|
|
86
94
|
|
|
87
95
|
const breakpointValue = unistyles.services.runtime.breakpoints[query as keyof UnistylesBreakpoints] ?? 0
|
|
88
96
|
const nextBreakpoint = allBreakpoints
|
|
89
97
|
.filter((b): b is keyof UnistylesBreakpoints => b in unistyles.services.runtime.breakpoints)
|
|
90
|
-
.map(b => unistyles.services.runtime.breakpoints[b] as number)
|
|
98
|
+
.map((b) => unistyles.services.runtime.breakpoints[b] as number)
|
|
91
99
|
.sort((a, b) => a - b)
|
|
92
|
-
.find(b => b > breakpointValue)
|
|
100
|
+
.find((b) => b > breakpointValue)
|
|
93
101
|
const queries = [
|
|
94
102
|
`(min-width: ${breakpointValue}px)`,
|
|
95
103
|
nextBreakpoint ? `(max-width: ${nextBreakpoint - 1}px)` : undefined,
|
|
96
|
-
]
|
|
104
|
+
]
|
|
105
|
+
.filter(Boolean)
|
|
106
|
+
.join(' and ')
|
|
97
107
|
|
|
98
108
|
return `@media ${queries}`
|
|
99
109
|
}
|
|
@@ -103,22 +113,20 @@ export const extractUnistyleDependencies = (value: any) => {
|
|
|
103
113
|
return []
|
|
104
114
|
}
|
|
105
115
|
|
|
106
|
-
const dependencies: Array<UnistyleDependency> = keyInObject(value, 'uni__dependencies')
|
|
116
|
+
const dependencies: Array<UnistyleDependency> = keyInObject(value, 'uni__dependencies')
|
|
117
|
+
? value.uni__dependencies
|
|
118
|
+
: []
|
|
107
119
|
|
|
108
120
|
return Array.isArray(dependencies) ? dependencies : []
|
|
109
121
|
}
|
|
110
122
|
|
|
111
123
|
export const checkForProp = (value: any, prop: string): boolean => {
|
|
112
124
|
if (Array.isArray(value)) {
|
|
113
|
-
return value.some(nestedValue => checkForProp(nestedValue, prop))
|
|
125
|
+
return value.some((nestedValue) => checkForProp(nestedValue, prop))
|
|
114
126
|
}
|
|
115
127
|
|
|
116
128
|
if (typeof value === 'object' && value !== null) {
|
|
117
|
-
return keyInObject(value, prop)
|
|
118
|
-
? true
|
|
119
|
-
: keyInObject(value, '_web')
|
|
120
|
-
? checkForProp(value._web, prop)
|
|
121
|
-
: false
|
|
129
|
+
return keyInObject(value, prop) ? true : keyInObject(value, '_web') ? checkForProp(value._web, prop) : false
|
|
122
130
|
}
|
|
123
131
|
|
|
124
132
|
return false
|
|
@@ -134,9 +142,8 @@ export const checkForAnimated = (value: any): boolean => {
|
|
|
134
142
|
const secrets = extractSecrets(value)
|
|
135
143
|
|
|
136
144
|
// @ts-expect-error React Native Web exports Animated.AnimatedNode as Animated.Node
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
secrets && Object.keys(secrets).length === 0
|
|
145
|
+
// prettier-ignore
|
|
146
|
+
return value instanceof Animated.Node || objectValues.length > 0 && objectValues.some(checkForAnimated) || secrets && Object.keys(secrets).length === 0
|
|
140
147
|
}
|
|
141
148
|
|
|
142
149
|
return false
|
|
@@ -145,12 +152,19 @@ export const checkForAnimated = (value: any): boolean => {
|
|
|
145
152
|
export const isGeneratedUnistyle = (value: Record<string, any>): value is UniGeneratedStyle => {
|
|
146
153
|
const keys = Object.keys(value)
|
|
147
154
|
|
|
148
|
-
return keys.length > 0 && keys.every(key => UNI_GENERATED_KEYS.includes(key as UniGeneratedKey))
|
|
155
|
+
return keys.length > 0 && keys.every((key) => UNI_GENERATED_KEYS.includes(key as UniGeneratedKey))
|
|
149
156
|
}
|
|
150
157
|
|
|
151
158
|
export const convertTheme = (key: string, value: any, prev = '-'): [string, any] => {
|
|
152
159
|
if (typeof value === 'object' && value !== null) {
|
|
153
|
-
return [
|
|
160
|
+
return [
|
|
161
|
+
key,
|
|
162
|
+
Object.fromEntries(
|
|
163
|
+
Object.entries(value).map(([nestedKey, nestedValue]) =>
|
|
164
|
+
convertTheme(nestedKey, nestedValue, `${prev}-${key}`),
|
|
165
|
+
),
|
|
166
|
+
),
|
|
167
|
+
]
|
|
154
168
|
}
|
|
155
169
|
|
|
156
170
|
if (typeof value === 'string') {
|
|
@@ -160,7 +174,10 @@ export const convertTheme = (key: string, value: any, prev = '-'): [string, any]
|
|
|
160
174
|
return [key, value]
|
|
161
175
|
}
|
|
162
176
|
|
|
163
|
-
export const getClosestBreakpointValue = <T>(
|
|
177
|
+
export const getClosestBreakpointValue = <T>(
|
|
178
|
+
runtime: UnistylesRuntime,
|
|
179
|
+
values: Partial<Record<keyof UnistylesBreakpoints, T>>,
|
|
180
|
+
) => {
|
|
164
181
|
const breakpoints = runtime.breakpoints
|
|
165
182
|
const breakpointValues = Object.entries(values)
|
|
166
183
|
// Filter out non-breakpoint values
|
|
@@ -168,9 +185,11 @@ export const getClosestBreakpointValue = <T>(runtime: UnistylesRuntime, values:
|
|
|
168
185
|
// Sort in descending order
|
|
169
186
|
.sort(([a], [b]) => (breakpoints[b] ?? 0) - (breakpoints[a] ?? 0))
|
|
170
187
|
// Get breakpoint value with highest priority
|
|
171
|
-
const [_, currentBreakpointValue] =
|
|
172
|
-
|
|
173
|
-
|
|
188
|
+
const [_, currentBreakpointValue] =
|
|
189
|
+
breakpointValues.find(
|
|
190
|
+
([key]) =>
|
|
191
|
+
isDefined(runtime.breakpoint) && (breakpoints[key] ?? 0) <= (breakpoints[runtime.breakpoint] ?? 0),
|
|
192
|
+
) ?? []
|
|
174
193
|
|
|
175
194
|
return currentBreakpointValue
|
|
176
195
|
}
|
package/src/web/variants.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import type { UnistylesValues } from '../types'
|
|
2
|
+
|
|
2
3
|
import { deepMergeObjects } from '../utils'
|
|
3
4
|
import { keyInObject } from './utils'
|
|
4
5
|
|
|
5
6
|
type StylesWithVariants = {
|
|
6
|
-
variants: Record<string, string | boolean | undefined
|
|
7
|
-
compoundVariants?: Array<
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
variants: Record<string, string | boolean | undefined>
|
|
8
|
+
compoundVariants?: Array<
|
|
9
|
+
Record<string, string | boolean | undefined> & {
|
|
10
|
+
styles: Record<string, any>
|
|
11
|
+
}
|
|
12
|
+
>
|
|
10
13
|
}
|
|
11
14
|
const hasVariants = (value: any): value is StylesWithVariants => {
|
|
12
15
|
return keyInObject(value, 'variants')
|
|
@@ -28,15 +31,20 @@ export const getVariants = (styles: UnistylesValues, selectedVariants: Record<st
|
|
|
28
31
|
return selectedVariantStyles
|
|
29
32
|
})
|
|
30
33
|
|
|
31
|
-
const compoundVariantStyles =
|
|
32
|
-
|
|
34
|
+
const compoundVariantStyles =
|
|
35
|
+
styles.compoundVariants?.flatMap((compoundVariant) => {
|
|
36
|
+
const { styles, ...conditions } = compoundVariant
|
|
33
37
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
38
|
+
if (
|
|
39
|
+
Object.entries(conditions).some(
|
|
40
|
+
([variant, value]) => String(selectedVariants[variant]) !== String(value),
|
|
41
|
+
)
|
|
42
|
+
) {
|
|
43
|
+
return []
|
|
44
|
+
}
|
|
37
45
|
|
|
38
|
-
|
|
39
|
-
|
|
46
|
+
return styles
|
|
47
|
+
}) ?? []
|
|
40
48
|
|
|
41
49
|
return deepMergeObjects(...variantStyles, ...compoundVariantStyles)
|
|
42
50
|
}
|