react-native-unistyles 3.0.0-beta.5 → 3.0.0-beta.7
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/README.md +17 -2
- package/android/CMakeLists.txt +1 -1
- package/android/src/main/cxx/NativeUnistylesModule.cpp +1 -1
- package/android/src/main/java/com/unistyles/NativePlatform+android.kt +5 -2
- package/android/src/main/java/com/unistyles/NativePlatform+insets.kt +24 -1
- package/android/src/main/java/com/unistyles/NativePlatform+listener.kt +6 -1
- package/android/src/main/java/com/unistyles/UnistylesModule.kt +5 -4
- package/android/src/main/java/com/unistyles/UnistylesPackage.kt +6 -6
- package/components/native/Animated/package.json +5 -0
- package/components/native/NativeText/package.json +5 -0
- package/components/native/NativeView/package.json +5 -0
- package/cxx/core/HashGenerator.cpp +1 -1
- package/cxx/core/HostUnistyle.cpp +28 -4
- package/cxx/core/HostUnistyle.h +1 -0
- package/cxx/core/Unistyle.h +4 -0
- package/cxx/core/UnistyleWrapper.h +6 -6
- package/cxx/core/UnistylesRegistry.cpp +24 -3
- package/cxx/core/UnistylesRegistry.h +3 -0
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +7 -0
- package/cxx/hybridObjects/HybridStyleSheet.cpp +27 -2
- package/cxx/parser/Parser.cpp +13 -7
- package/ios/NativePlatform+ios.swift +16 -4
- package/ios/UnistylesModuleOnLoad.h +4 -4
- package/ios/UnistylesModuleOnLoad.mm +4 -8
- package/lib/commonjs/components/native/Animated.js +23 -0
- package/lib/commonjs/components/native/Animated.js.map +1 -0
- package/lib/commonjs/components/native/ImageBackground.js +6 -4
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/native/NativeText.js +13 -0
- package/lib/commonjs/components/native/NativeText.js.map +1 -0
- package/lib/commonjs/components/native/NativeText.native.js +18 -0
- package/lib/commonjs/components/native/NativeText.native.js.map +1 -0
- package/lib/commonjs/components/native/NativeView.js +9 -0
- package/lib/commonjs/components/native/NativeView.js.map +1 -0
- package/lib/commonjs/components/native/NativeView.native.js +20 -0
- package/lib/commonjs/components/native/NativeView.native.js.map +1 -0
- package/lib/commonjs/components/native/Pressable.js +1 -1
- package/lib/commonjs/components/native/Pressable.js.map +1 -1
- package/lib/commonjs/components/native/Pressable.native.js +18 -9
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +28 -24
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.native.js +37 -23
- package/lib/commonjs/core/createUnistylesElement.native.js.map +1 -1
- package/lib/commonjs/core/createUnistylesImageBackground.js +34 -30
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/commonjs/core/getClassname.js +1 -3
- package/lib/commonjs/core/getClassname.js.map +1 -1
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -2
- package/lib/commonjs/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/commonjs/core/warn.js +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +2 -2
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +5 -3
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +1 -1
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -1
- package/lib/commonjs/mq.js.map +1 -1
- package/lib/commonjs/server/getServerUnistyles.js +4 -2
- package/lib/commonjs/server/getServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js +1 -1
- package/lib/commonjs/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js +1 -1
- package/lib/commonjs/server/resetServerUnistyles.js.map +1 -1
- package/lib/commonjs/server/useServerUnistyles.js +2 -2
- package/lib/commonjs/server/useServerUnistyles.js.map +1 -1
- package/lib/commonjs/specs/StatusBar/index.js.map +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js +1 -1
- package/lib/commonjs/specs/StyleSheet/index.js.map +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js +1 -1
- package/lib/commonjs/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +3 -3
- package/lib/commonjs/specs/index.native.js.map +1 -1
- package/lib/commonjs/utils.js +16 -1
- package/lib/commonjs/utils.js.map +1 -1
- package/lib/commonjs/web/convert/index.js +4 -4
- package/lib/commonjs/web/convert/index.js.map +1 -1
- package/lib/commonjs/web/convert/object/boxShadow.js +4 -4
- package/lib/commonjs/web/convert/object/boxShadow.js.map +1 -1
- package/lib/commonjs/web/convert/object/filter.js +3 -3
- package/lib/commonjs/web/convert/object/filter.js.map +1 -1
- package/lib/commonjs/web/convert/object/transform.js +1 -1
- package/lib/commonjs/web/convert/object/transform.js.map +1 -1
- package/lib/commonjs/web/convert/utils.js.map +1 -1
- package/lib/commonjs/web/index.js +1 -1
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/registry.js +1 -1
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +1 -1
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/state.js +1 -1
- package/lib/commonjs/web/state.js.map +1 -1
- package/lib/commonjs/web/utils/common.js +1 -1
- package/lib/commonjs/web/utils/unistyle.js +10 -6
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/native/Animated.js +19 -0
- package/lib/module/components/native/Animated.js.map +1 -0
- package/lib/module/components/native/ImageBackground.js +5 -3
- package/lib/module/components/native/ImageBackground.js.map +1 -1
- package/lib/module/components/native/NativeText.js +4 -0
- package/lib/module/components/native/NativeText.js.map +1 -0
- package/lib/module/components/native/NativeText.native.js +15 -0
- package/lib/module/components/native/NativeText.native.js.map +1 -0
- package/lib/module/components/native/NativeView.js +5 -0
- package/lib/module/components/native/NativeView.js.map +1 -0
- package/lib/module/components/native/NativeView.native.js +17 -0
- package/lib/module/components/native/NativeView.native.js.map +1 -0
- package/lib/module/components/native/Pressable.js +1 -1
- package/lib/module/components/native/Pressable.js.map +1 -1
- package/lib/module/components/native/Pressable.native.js +19 -10
- package/lib/module/components/native/Pressable.native.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +28 -24
- package/lib/module/core/createUnistylesElement.js.map +1 -1
- package/lib/module/core/createUnistylesElement.native.js +38 -24
- package/lib/module/core/createUnistylesElement.native.js.map +1 -1
- package/lib/module/core/createUnistylesImageBackground.js +35 -31
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -1
- package/lib/module/core/getClassname.js +2 -4
- package/lib/module/core/getClassname.js.map +1 -1
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js +2 -2
- package/lib/module/core/useProxifiedUnistyles/useProxifiedUnistyles.js.map +1 -1
- package/lib/module/core/warn.js +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.js +2 -2
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -1
- package/lib/module/core/withUnistyles/withUnistyles.native.js +6 -4
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +1 -1
- package/lib/module/hooks/useMedia.native.js.map +1 -1
- package/lib/module/mq.js.map +1 -1
- package/lib/module/server/getServerUnistyles.js +4 -2
- package/lib/module/server/getServerUnistyles.js.map +1 -1
- package/lib/module/server/hydrateServerUnistyles.js +1 -1
- package/lib/module/server/hydrateServerUnistyles.js.map +1 -1
- package/lib/module/server/resetServerUnistyles.js +1 -1
- package/lib/module/server/resetServerUnistyles.js.map +1 -1
- package/lib/module/server/useServerUnistyles.js +2 -2
- package/lib/module/server/useServerUnistyles.js.map +1 -1
- package/lib/module/specs/StatusBar/index.js.map +1 -1
- package/lib/module/specs/StyleSheet/index.js +1 -1
- package/lib/module/specs/StyleSheet/index.js.map +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js +1 -1
- package/lib/module/specs/UnistylesRuntime/index.js.map +1 -1
- package/lib/module/specs/index.native.js +4 -4
- package/lib/module/specs/index.native.js.map +1 -1
- package/lib/module/utils.js +14 -0
- package/lib/module/utils.js.map +1 -1
- package/lib/module/web/convert/index.js +5 -5
- package/lib/module/web/convert/index.js.map +1 -1
- package/lib/module/web/convert/object/boxShadow.js +2 -2
- package/lib/module/web/convert/object/boxShadow.js.map +1 -1
- package/lib/module/web/convert/object/filter.js +3 -3
- package/lib/module/web/convert/object/filter.js.map +1 -1
- package/lib/module/web/convert/object/transform.js +1 -1
- package/lib/module/web/convert/object/transform.js.map +1 -1
- package/lib/module/web/convert/utils.js.map +1 -1
- package/lib/module/web/index.js +1 -1
- package/lib/module/web/index.js.map +1 -1
- package/lib/module/web/registry.js +1 -1
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +1 -1
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/state.js +1 -1
- package/lib/module/web/state.js.map +1 -1
- package/lib/module/web/utils/common.js +1 -1
- package/lib/module/web/utils/unistyle.js +10 -6
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts +1 -3
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Animated.d.ts +39 -0
- package/lib/typescript/src/components/native/Animated.d.ts.map +1 -0
- package/lib/typescript/src/components/native/FlatList.d.ts +1 -3
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Image.d.ts +1 -3
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.d.ts +1 -8
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts +1 -2
- package/lib/typescript/src/components/native/ImageBackground.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +1 -3
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/NativeText.d.ts +2 -0
- package/lib/typescript/src/components/native/NativeText.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeText.native.d.ts +2 -0
- package/lib/typescript/src/components/native/NativeText.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeView.d.ts +3 -0
- package/lib/typescript/src/components/native/NativeView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/NativeView.native.d.ts +3 -0
- package/lib/typescript/src/components/native/NativeView.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -1
- package/lib/typescript/src/components/native/RefreshControl.d.ts +1 -3
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ScrollView.d.ts +1 -3
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -1
- package/lib/typescript/src/components/native/SectionList.d.ts +1 -3
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Switch.d.ts +1 -3
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -1
- package/lib/typescript/src/components/native/Text.d.ts +1 -3
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TextInput.d.ts +1 -3
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts +1 -3
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -1
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts +1 -3
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -1
- package/lib/typescript/src/components/native/View.d.ts +1 -3
- package/lib/typescript/src/components/native/View.d.ts.map +1 -1
- package/lib/typescript/src/components/native/VirtualizedList.d.ts +1 -3
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts +1 -7
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts +1 -2
- package/lib/typescript/src/core/createUnistylesElement.native.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +2 -3
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -1
- package/lib/typescript/src/core/getClassname.d.ts +2 -2
- package/lib/typescript/src/core/getClassname.d.ts.map +1 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.d.ts +2 -1
- package/lib/typescript/src/core/useProxifiedUnistyles/useProxifiedUnistyles.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/mq.d.ts +1 -1
- package/lib/typescript/src/mq.d.ts.map +1 -1
- package/lib/typescript/src/server/getServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/hydrateServerUnistyles.d.ts.map +1 -1
- package/lib/typescript/src/server/useServerUnistyles.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/index.d.ts +2 -1
- package/lib/typescript/src/specs/StyleSheet/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.d.ts.map +1 -1
- package/lib/typescript/src/specs/UnistylesRuntime/index.d.ts +5 -5
- 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/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 +1 -1
- package/lib/typescript/src/types/core.d.ts.map +1 -1
- package/lib/typescript/src/types/stylesheet.d.ts +4 -4
- package/lib/typescript/src/types/stylesheet.d.ts.map +1 -1
- package/lib/typescript/src/utils.d.ts +1 -0
- package/lib/typescript/src/utils.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/transform.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/types.d.ts +1 -1
- package/lib/typescript/src/web/convert/types.d.ts.map +1 -1
- package/lib/typescript/src/web/convert/utils.d.ts +2 -2
- 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/index.d.ts +1 -1
- package/lib/typescript/src/web/index.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 +1 -1
- package/lib/typescript/src/web/state.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/android/c++/JHybridNativePlatformSpec.hpp +1 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/HybridNativePlatformSpec.kt +23 -39
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/unistyles/unistylesOnLoad.kt +35 -0
- package/nitrogen/generated/ios/Unistyles+autolinking.rb +2 -0
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Bridge.cpp +1 -1
- package/nitrogen/generated/ios/c++/HybridNativePlatformSpecSwift.hpp +3 -1
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec.swift +2 -3
- package/nitrogen/generated/ios/swift/HybridNativePlatformSpec_cxx.swift +18 -18
- package/nitrogen/generated/shared/c++/ColorScheme.hpp +1 -1
- package/nitrogen/generated/shared/c++/Dimensions.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridNativePlatformSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesNavigationBarSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesRuntimeSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesShadowRegistrySpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStatusBarSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/HybridUnistylesStyleSheetSpec.hpp +1 -1
- package/nitrogen/generated/shared/c++/Insets.hpp +1 -1
- package/nitrogen/generated/shared/c++/Orientation.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistyleDependency.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistylesCxxMiniRuntime.hpp +1 -1
- package/nitrogen/generated/shared/c++/UnistylesNativeMiniRuntime.hpp +1 -1
- package/package.json +16 -12
- package/plugin/consts.js +63 -0
- package/plugin/exotic.js +54 -0
- package/plugin/import.js +1 -1
- package/plugin/index.d.ts +84 -36
- package/plugin/index.js +48 -65
- package/plugin/stylesheet.js +454 -117
- package/plugin/variants.js +1 -1
- package/src/components/native/Animated.tsx +17 -0
- package/src/components/native/ImageBackground.tsx +7 -4
- package/src/components/native/NativeText.native.tsx +12 -0
- package/src/components/native/NativeText.tsx +1 -0
- package/src/components/native/NativeView.native.tsx +13 -0
- package/src/components/native/NativeView.tsx +3 -0
- package/src/components/native/Pressable.native.tsx +26 -13
- package/src/components/native/Pressable.tsx +1 -1
- package/src/core/createUnistylesElement.native.tsx +42 -27
- package/src/core/createUnistylesElement.tsx +36 -31
- package/src/core/createUnistylesImageBackground.tsx +39 -34
- package/src/core/getClassname.ts +5 -4
- package/src/core/useProxifiedUnistyles/useProxifiedUnistyles.ts +3 -3
- package/src/core/warn.ts +1 -1
- package/src/core/withUnistyles/withUnistyles.native.tsx +8 -6
- package/src/core/withUnistyles/withUnistyles.tsx +4 -4
- package/src/hooks/useMedia.native.ts +1 -1
- package/src/mq.ts +1 -1
- package/src/server/getServerUnistyles.tsx +3 -2
- package/src/server/hydrateServerUnistyles.ts +1 -1
- package/src/server/resetServerUnistyles.ts +1 -1
- package/src/server/useServerUnistyles.tsx +2 -2
- package/src/specs/StatusBar/index.ts +1 -1
- package/src/specs/StyleSheet/index.ts +5 -4
- package/src/specs/UnistylesRuntime/UnistylesRuntime.nitro.ts +1 -1
- package/src/specs/UnistylesRuntime/index.ts +5 -5
- package/src/specs/index.native.ts +4 -4
- package/src/types/breakpoints.ts +2 -2
- package/src/types/core.ts +1 -1
- package/src/types/stylesheet.ts +4 -4
- package/src/utils.ts +17 -0
- package/src/web/convert/index.ts +5 -5
- package/src/web/convert/object/boxShadow.ts +2 -2
- package/src/web/convert/object/filter.ts +3 -3
- package/src/web/convert/object/transform.ts +2 -2
- package/src/web/convert/types.ts +1 -1
- package/src/web/convert/utils.ts +2 -2
- package/src/web/create.ts +1 -1
- package/src/web/index.ts +3 -3
- package/src/web/registry.ts +2 -2
- package/src/web/runtime.ts +2 -2
- package/src/web/shadowRegistry.ts +2 -2
- package/src/web/state.ts +4 -4
- package/src/web/utils/common.ts +1 -1
- package/src/web/utils/unistyle.ts +13 -7
- package/plugin/common.js +0 -142
package/plugin/consts.js
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
const REACT_NATIVE_COMPONENT_NAMES = [
|
2
|
+
'ActivityIndicator',
|
3
|
+
'View',
|
4
|
+
'Text',
|
5
|
+
'Image',
|
6
|
+
'ImageBackground',
|
7
|
+
'KeyboardAvoidingView',
|
8
|
+
'Pressable',
|
9
|
+
'ScrollView',
|
10
|
+
'FlatList',
|
11
|
+
'SectionList',
|
12
|
+
'Switch',
|
13
|
+
'TextInput',
|
14
|
+
'RefreshControl',
|
15
|
+
'TouchableHighlight',
|
16
|
+
'TouchableOpacity',
|
17
|
+
'VirtualizedList',
|
18
|
+
'Animated'
|
19
|
+
// Modal - there is no exposed native handle
|
20
|
+
// TouchableWithoutFeedback - can't accept a ref
|
21
|
+
]
|
22
|
+
|
23
|
+
// auto replace RN imports to Unistyles imports under these paths
|
24
|
+
// our implementation simply borrows 'ref' to register it in ShadowRegistry
|
25
|
+
// so we won't affect anyone's implementation
|
26
|
+
const REPLACE_WITH_UNISTYLES_PATHS = [
|
27
|
+
'react-native-reanimated/src/component',
|
28
|
+
'react-native-gesture-handler/src/components'
|
29
|
+
]
|
30
|
+
|
31
|
+
// this is more powerful API as it allows to convert unmatched imports to Unistyles
|
32
|
+
// { path: string, imports: Array<{ name: string, isDefault: boolean, path: string, mapTo: string }> }
|
33
|
+
// path => node_modules path
|
34
|
+
// imports:
|
35
|
+
// name? <- target import name if isDefault is false
|
36
|
+
// isDefault <- is the import default?
|
37
|
+
// path <- path to the target import
|
38
|
+
// mapTo <- name of the Unistyles component
|
39
|
+
const REPLACE_WITH_UNISTYLES_EXOTIC_PATHS = []
|
40
|
+
|
41
|
+
// this list will additionally detect React Native direct imports
|
42
|
+
const NATIVE_COMPONENTS_PATHS = {
|
43
|
+
imports: [
|
44
|
+
{
|
45
|
+
name: 'NativeText',
|
46
|
+
isDefault: false,
|
47
|
+
path: 'react-native/Libraries/Text/TextNativeComponent',
|
48
|
+
mapTo: 'NativeText'
|
49
|
+
},
|
50
|
+
{
|
51
|
+
isDefault: true,
|
52
|
+
path: 'react-native/Libraries/Components/View/ViewNativeComponent',
|
53
|
+
mapTo: 'NativeView'
|
54
|
+
}
|
55
|
+
]
|
56
|
+
}
|
57
|
+
|
58
|
+
module.exports = {
|
59
|
+
NATIVE_COMPONENTS_PATHS,
|
60
|
+
REACT_NATIVE_COMPONENT_NAMES,
|
61
|
+
REPLACE_WITH_UNISTYLES_PATHS,
|
62
|
+
REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
|
63
|
+
}
|
package/plugin/exotic.js
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
function handleExoticImport(t, path, state, exoticImport) {
|
2
|
+
const specifiers = path.node.specifiers
|
3
|
+
const source = path.node.source
|
4
|
+
|
5
|
+
if (path.node.importKind !== 'value') {
|
6
|
+
return
|
7
|
+
}
|
8
|
+
|
9
|
+
specifiers.forEach(specifier => {
|
10
|
+
for (const rule of exoticImport.imports) {
|
11
|
+
const hasMatchingImportType = (!rule.isDefault && t.isImportSpecifier(specifier)) || (rule.isDefault && t.isImportDefaultSpecifier(specifier))
|
12
|
+
const hasMatchingImportName = rule.isDefault || (!rule.isDefault && rule.name === specifier.local.name)
|
13
|
+
const hasMatchingPath = rule.path === source.value
|
14
|
+
|
15
|
+
if (!hasMatchingImportType || !hasMatchingImportName || !hasMatchingPath) {
|
16
|
+
continue
|
17
|
+
}
|
18
|
+
|
19
|
+
if (t.isImportDefaultSpecifier(specifier)) {
|
20
|
+
const newImport = t.importDeclaration(
|
21
|
+
[t.importDefaultSpecifier(t.identifier(specifier.local.name))],
|
22
|
+
t.stringLiteral(state.opts.isLocal
|
23
|
+
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
|
24
|
+
: `react-native-unistyles/components/native/${rule.mapTo}`
|
25
|
+
)
|
26
|
+
)
|
27
|
+
|
28
|
+
path.replaceWith(newImport)
|
29
|
+
} else {
|
30
|
+
const newImport = t.importDeclaration(
|
31
|
+
[t.importSpecifier(t.identifier(rule.mapTo), t.identifier(rule.mapTo))],
|
32
|
+
t.stringLiteral(state.opts.isLocal
|
33
|
+
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${rule.mapTo}`)
|
34
|
+
: `react-native-unistyles/components/native/${rule.mapTo}`
|
35
|
+
)
|
36
|
+
)
|
37
|
+
|
38
|
+
path.node.specifiers = specifiers.filter(s => s !== specifier)
|
39
|
+
|
40
|
+
if (path.node.specifiers.length === 0) {
|
41
|
+
path.replaceWith(newImport)
|
42
|
+
} else {
|
43
|
+
path.insertBefore(newImport)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
return
|
48
|
+
}
|
49
|
+
})
|
50
|
+
}
|
51
|
+
|
52
|
+
module.exports = {
|
53
|
+
handleExoticImport
|
54
|
+
}
|
package/plugin/import.js
CHANGED
@@ -31,7 +31,7 @@ function addUnistylesImport(t, path, state) {
|
|
31
31
|
const newImport = t.importDeclaration(
|
32
32
|
[t.importSpecifier(t.identifier(localName), t.identifier(name))],
|
33
33
|
t.stringLiteral(state.opts.isLocal
|
34
|
-
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/components/native/${name}`)
|
34
|
+
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/src/components/native/${name}`)
|
35
35
|
: `react-native-unistyles/components/native/${name}`
|
36
36
|
)
|
37
37
|
)
|
package/plugin/index.d.ts
CHANGED
@@ -1,41 +1,89 @@
|
|
1
|
+
type RemapImport = {
|
2
|
+
name?: string,
|
3
|
+
isDefault: boolean,
|
4
|
+
path: string,
|
5
|
+
mapTo: string
|
6
|
+
}
|
7
|
+
|
8
|
+
type RemapConfig = {
|
9
|
+
path: string,
|
10
|
+
imports: Array<RemapImport>
|
11
|
+
}
|
12
|
+
|
1
13
|
export interface UnistylesPluginOptions {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
14
|
+
/**
|
15
|
+
* Example: "src" or "apps/mobile"
|
16
|
+
* Add this option if some of your components don't have `react-native-unistyles` import.
|
17
|
+
* Babel plugin will automatically process all files under this root.
|
18
|
+
*/
|
19
|
+
autoProcessRoot?: string,
|
20
|
+
|
21
|
+
/**
|
22
|
+
* Example: ['@codemask/styles']
|
23
|
+
* Enable this option if you want to process only files containing specific imports.
|
24
|
+
*/
|
25
|
+
autoProcessImports?: Array<string>,
|
26
|
+
|
27
|
+
/**
|
28
|
+
* Example: [{
|
29
|
+
* path: "node_modules/custom-library/components",
|
30
|
+
* imports: [
|
31
|
+
* {
|
32
|
+
* name: "NativeText",
|
33
|
+
* isDefault: false,
|
34
|
+
* path: "react-native/Libraries/Text/TextNativeComponent",
|
35
|
+
* mapTo: "NativeText"
|
36
|
+
* },
|
37
|
+
* {
|
38
|
+
* isDefault: true,
|
39
|
+
* path: "react-native/Libraries/Components/View/ViewNativeComponent",
|
40
|
+
* mapTo: "NativeView"
|
41
|
+
* }
|
42
|
+
* ]
|
43
|
+
* }]
|
44
|
+
*
|
45
|
+
* Will map:
|
46
|
+
* import { NativeText } from "react-native/Libraries/Text/TextNativeComponent"
|
47
|
+
* to Unistyles "NativeText"
|
48
|
+
*
|
49
|
+
* import View from "react-native/Libraries/Components/View/ViewNativeComponent"
|
50
|
+
* to Unistyles "NativeView"
|
51
|
+
*
|
52
|
+
* This is the most powerful way of remapping imports. If 3rd party library uses imports different from `react-native` we can remap them to `react-native-unistyles` factories.
|
53
|
+
* Internally we do that for raw RCTView and RCTText components.
|
54
|
+
*
|
55
|
+
* path -> must be within node_modules folder
|
56
|
+
* imports.name is Optional if library used export default
|
57
|
+
* imports.mapTo - name of the component from react-native-unistyles/src/components/native
|
58
|
+
*/
|
59
|
+
autoRemapImports?: Array<RemapConfig>,
|
60
|
+
|
61
|
+
/**
|
62
|
+
* Example: ['external-library/components']
|
63
|
+
* Enable this option to process some 3rd party components under `node_modules`.
|
64
|
+
* Under these paths we will replace `react-native` imports with `react-native-unistyles` factories that will borrow components refs [read more](https://www.unistyl.es/v3/other/babel-plugin#3-component-factory-borrowing-ref).
|
65
|
+
*
|
66
|
+
* Defaults to:
|
67
|
+
*
|
68
|
+
* ```ts
|
69
|
+
* ['react-native-reanimated/src/component', 'react-native-gesture-handler/src/components']
|
70
|
+
* ```
|
71
|
+
*/
|
72
|
+
autoProcessPaths?: Array<string>,
|
73
|
+
|
74
|
+
/**
|
75
|
+
* In order to list detected dependencies by the Babel plugin you can enable the `debug` flag.
|
76
|
+
* It will `console.log` name of the file and component with Unistyles dependencies.
|
77
|
+
*/
|
78
|
+
debug?: boolean,
|
79
|
+
|
80
|
+
/**
|
81
|
+
* Only applicable for Unistyles monorepo for
|
82
|
+
* path resolution, don't use it!
|
83
|
+
*/
|
84
|
+
isLocal?: boolean
|
37
85
|
}
|
38
86
|
|
39
87
|
export interface UnistylesPluginPass {
|
40
|
-
|
88
|
+
opts: UnistylesPluginOptions
|
41
89
|
}
|
package/plugin/index.js
CHANGED
@@ -1,36 +1,9 @@
|
|
1
1
|
const { addUnistylesImport, isInsideNodeModules } = require('./import')
|
2
2
|
const { hasStringRef } = require('./ref')
|
3
|
-
const { isUnistylesStyleSheet,
|
3
|
+
const { isUnistylesStyleSheet, addStyleSheetTag, isKindOfStyleSheet, getStylesDependenciesFromFunction, addDependencies, getStylesDependenciesFromObject } = require('./stylesheet')
|
4
4
|
const { extractVariants } = require('./variants')
|
5
|
-
|
6
|
-
const
|
7
|
-
'ActivityIndicator',
|
8
|
-
'View',
|
9
|
-
'Text',
|
10
|
-
'Image',
|
11
|
-
'ImageBackground',
|
12
|
-
'KeyboardAvoidingView',
|
13
|
-
'Pressable',
|
14
|
-
'ScrollView',
|
15
|
-
'FlatList',
|
16
|
-
'SectionList',
|
17
|
-
'Switch',
|
18
|
-
'TextInput',
|
19
|
-
'RefreshControl',
|
20
|
-
'TouchableHighlight',
|
21
|
-
'TouchableOpacity',
|
22
|
-
'VirtualizedList',
|
23
|
-
// Modal - there is no exposed native handle
|
24
|
-
// TouchableWithoutFeedback - can't accept a ref
|
25
|
-
]
|
26
|
-
|
27
|
-
// auto replace RN imports to Unistyles imports under these paths
|
28
|
-
// our implementation simply borrows 'ref' to register it in ShadowRegistry
|
29
|
-
// so we won't affect anyone's implementation
|
30
|
-
const REPLACE_WITH_UNISTYLES_PATHS = [
|
31
|
-
'react-native-reanimated/src/component',
|
32
|
-
'react-native-gesture-handler/src/components'
|
33
|
-
]
|
5
|
+
const { REACT_NATIVE_COMPONENT_NAMES, REPLACE_WITH_UNISTYLES_PATHS, REPLACE_WITH_UNISTYLES_EXOTIC_PATHS, NATIVE_COMPONENTS_PATHS } = require('./consts')
|
6
|
+
const { handleExoticImport } = require('./exotic')
|
34
7
|
|
35
8
|
module.exports = function ({ types: t }) {
|
36
9
|
return {
|
@@ -44,18 +17,21 @@ module.exports = function ({ types: t }) {
|
|
44
17
|
.some(path => state.filename.includes(path))
|
45
18
|
|
46
19
|
state.file.hasAnyUnistyle = false
|
20
|
+
state.file.hasUnistylesImport = false
|
47
21
|
state.file.hasVariants = false
|
48
22
|
state.file.styleSheetLocalName = ''
|
49
23
|
state.file.tagNumber = 0
|
50
24
|
state.reactNativeImports = {}
|
51
|
-
state.file.forceProcessing =
|
25
|
+
state.file.forceProcessing = state.opts.autoProcessRoot
|
26
|
+
? state.filename.includes(`${state.file.opts.root}/${state.opts.autoProcessRoot}/`)
|
27
|
+
: false
|
52
28
|
},
|
53
29
|
exit(path, state) {
|
54
30
|
if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
|
55
31
|
return
|
56
32
|
}
|
57
33
|
|
58
|
-
if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles) {
|
34
|
+
if (state.file.hasAnyUnistyle || state.file.hasVariants || state.file.replaceWithUnistyles || state.file.forceProcessing) {
|
59
35
|
addUnistylesImport(t, path, state)
|
60
36
|
}
|
61
37
|
}
|
@@ -105,6 +81,14 @@ module.exports = function ({ types: t }) {
|
|
105
81
|
},
|
106
82
|
/** @param {import('./index').UnistylesPluginPass} state */
|
107
83
|
ImportDeclaration(path, state) {
|
84
|
+
const exoticImport = REPLACE_WITH_UNISTYLES_EXOTIC_PATHS
|
85
|
+
.concat(state.opts.autoRemapImports ?? [])
|
86
|
+
.find(exotic => state.filename.includes(exotic.path))
|
87
|
+
|
88
|
+
if (exoticImport) {
|
89
|
+
return handleExoticImport(t, path, state, exoticImport)
|
90
|
+
}
|
91
|
+
|
108
92
|
if (isInsideNodeModules(state) && !state.file.replaceWithUnistyles) {
|
109
93
|
return
|
110
94
|
}
|
@@ -112,6 +96,8 @@ module.exports = function ({ types: t }) {
|
|
112
96
|
const importSource = path.node.source.value
|
113
97
|
|
114
98
|
if (importSource.includes('react-native-unistyles')) {
|
99
|
+
state.file.hasUnistylesImport = true
|
100
|
+
|
115
101
|
path.node.specifiers.forEach(specifier => {
|
116
102
|
if (specifier.imported && specifier.imported.name === 'StyleSheet') {
|
117
103
|
state.file.styleSheetLocalName = specifier.local.name
|
@@ -121,12 +107,16 @@ module.exports = function ({ types: t }) {
|
|
121
107
|
|
122
108
|
if (importSource === 'react-native') {
|
123
109
|
path.node.specifiers.forEach(specifier => {
|
124
|
-
if (specifier.imported &&
|
110
|
+
if (specifier.imported && REACT_NATIVE_COMPONENT_NAMES.includes(specifier.imported.name)) {
|
125
111
|
state.reactNativeImports[specifier.local.name] = specifier.imported.name
|
126
112
|
}
|
127
113
|
})
|
128
114
|
}
|
129
115
|
|
116
|
+
if (importSource.includes('react-native/Libraries')) {
|
117
|
+
handleExoticImport(t, path, state, NATIVE_COMPONENTS_PATHS)
|
118
|
+
}
|
119
|
+
|
130
120
|
if (!state.file.forceProcessing && Array.isArray(state.opts.autoProcessImports)) {
|
131
121
|
state.file.forceProcessing = state.opts.autoProcessImports.includes(importSource)
|
132
122
|
}
|
@@ -162,45 +152,38 @@ module.exports = function ({ types: t }) {
|
|
162
152
|
|
163
153
|
const arg = path.node.arguments[0]
|
164
154
|
|
165
|
-
// Object passed to StyleSheet.create
|
155
|
+
// Object passed to StyleSheet.create (may contain variants)
|
166
156
|
if (t.isObjectExpression(arg)) {
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
157
|
+
const detectedDependencies = getStylesDependenciesFromObject(t, path)
|
158
|
+
|
159
|
+
if (detectedDependencies) {
|
160
|
+
if (t.isObjectExpression(arg)) {
|
161
|
+
arg.properties.forEach(property => {
|
162
|
+
if (detectedDependencies.hasOwnProperty(property.key.name)) {
|
163
|
+
addDependencies(t, state, property.key.name, property, detectedDependencies[property.key.name])
|
164
|
+
}
|
173
165
|
})
|
174
166
|
}
|
175
|
-
}
|
167
|
+
}
|
176
168
|
}
|
177
169
|
|
178
170
|
// Function passed to StyleSheet.create (e.g., theme => ({ container: {} }))
|
179
171
|
if (t.isArrowFunctionExpression(arg) || t.isFunctionExpression(arg)) {
|
180
|
-
const
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
body.properties.forEach(property => {
|
196
|
-
if (t.isObjectProperty(property)) {
|
197
|
-
const propertyValues = getUnistyles(t, property)
|
198
|
-
|
199
|
-
propertyValues.forEach(propertyValue => {
|
200
|
-
analyzeDependencies(t, state, property.key.name, propertyValue, themeLocalName, miniRuntimeLocalName)
|
201
|
-
})
|
202
|
-
}
|
203
|
-
})
|
172
|
+
const detectedDependencies = getStylesDependenciesFromFunction(t, path)
|
173
|
+
|
174
|
+
if (detectedDependencies) {
|
175
|
+
const body = t.isBlockStatement(arg.body)
|
176
|
+
? arg.body.body.find(statement => t.isReturnStatement(statement)).argument
|
177
|
+
: arg.body
|
178
|
+
|
179
|
+
// Ensure the function body returns an object
|
180
|
+
if (t.isObjectExpression(body)) {
|
181
|
+
body.properties.forEach(property => {
|
182
|
+
if (detectedDependencies.hasOwnProperty(property.key.name)) {
|
183
|
+
addDependencies(t, state, property.key.name, property, detectedDependencies[property.key.name])
|
184
|
+
}
|
185
|
+
})
|
186
|
+
}
|
204
187
|
}
|
205
188
|
}
|
206
189
|
}
|