react-native-unistyles 3.0.0-beta.1 → 3.0.0-beta.2
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 +4 -4
- package/Unistyles.podspec +7 -1
- package/android/build.gradle +6 -0
- package/android/src/main/cxx/NativeUnistylesModule.cpp +2 -2
- package/cxx/common/Constants.h +2 -0
- package/cxx/core/HostStyle.cpp +12 -7
- package/cxx/core/HostStyle.h +5 -0
- package/cxx/core/UnistyleData.h +3 -3
- package/cxx/core/UnistyleWrapper.h +8 -8
- package/cxx/core/UnistylesRegistry.cpp +23 -30
- package/cxx/core/UnistylesRegistry.h +8 -2
- package/cxx/hybridObjects/HybridShadowRegistry.cpp +108 -12
- package/cxx/hybridObjects/HybridShadowRegistry.h +21 -2
- package/cxx/hybridObjects/HybridUnistylesRuntime.cpp +4 -0
- package/cxx/parser/Parser.cpp +182 -26
- package/cxx/parser/Parser.h +3 -1
- package/ios/UnistylesModuleOnLoad.mm +2 -2
- package/lib/commonjs/components/ScopedTheme.js +36 -0
- package/lib/commonjs/components/ScopedTheme.js.map +1 -0
- package/lib/commonjs/components/Variants.js +33 -0
- package/lib/commonjs/components/Variants.js.map +1 -0
- package/lib/commonjs/components/index.js +10 -3
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/components/native/ActivityIndicator.js +10 -0
- package/lib/commonjs/components/native/ActivityIndicator.js.map +1 -0
- package/lib/commonjs/components/native/FlatList.js +10 -0
- package/lib/commonjs/components/native/FlatList.js.map +1 -0
- package/lib/commonjs/components/native/Image.js +10 -0
- package/lib/commonjs/components/native/Image.js.map +1 -0
- package/lib/commonjs/components/native/ImageBackground.js +10 -0
- package/lib/commonjs/components/native/ImageBackground.js.map +1 -0
- package/lib/commonjs/components/native/KeyboardAvoidingView.js +10 -0
- package/lib/commonjs/components/native/KeyboardAvoidingView.js.map +1 -0
- package/lib/commonjs/components/{Pressable.web.js → native/Pressable.js} +26 -66
- package/lib/commonjs/components/native/Pressable.js.map +1 -0
- package/lib/commonjs/components/native/Pressable.native.js +48 -0
- package/lib/commonjs/components/native/Pressable.native.js.map +1 -0
- package/lib/commonjs/components/native/RefreshControl.js +10 -0
- package/lib/commonjs/components/native/RefreshControl.js.map +1 -0
- package/lib/commonjs/components/native/ScrollView.js +10 -0
- package/lib/commonjs/components/native/ScrollView.js.map +1 -0
- package/lib/commonjs/components/native/SectionList.js +10 -0
- package/lib/commonjs/components/native/SectionList.js.map +1 -0
- package/lib/commonjs/components/native/Switch.js +10 -0
- package/lib/commonjs/components/native/Switch.js.map +1 -0
- package/lib/commonjs/components/native/Text.js +10 -0
- package/lib/commonjs/components/native/Text.js.map +1 -0
- package/lib/commonjs/components/native/TextInput.js +10 -0
- package/lib/commonjs/components/native/TextInput.js.map +1 -0
- package/lib/commonjs/components/native/TouchableHighlight.js +10 -0
- package/lib/commonjs/components/native/TouchableHighlight.js.map +1 -0
- package/lib/commonjs/components/native/TouchableOpacity.js +10 -0
- package/lib/commonjs/components/native/TouchableOpacity.js.map +1 -0
- package/lib/commonjs/components/native/View.js +10 -0
- package/lib/commonjs/components/native/View.js.map +1 -0
- package/lib/commonjs/components/native/VirtualizedList.js +10 -0
- package/lib/commonjs/components/native/VirtualizedList.js.map +1 -0
- package/lib/commonjs/core/createUnistylesComponent.js +5 -68
- package/lib/commonjs/core/createUnistylesComponent.js.map +1 -1
- package/lib/commonjs/core/createUnistylesElement.js +16 -0
- package/lib/commonjs/core/createUnistylesElement.js.map +1 -0
- package/lib/commonjs/core/createUnistylesImageBackground.js +27 -0
- package/lib/commonjs/core/createUnistylesImageBackground.js.map +1 -0
- package/lib/commonjs/core/index.js +20 -6
- package/lib/commonjs/core/index.js.map +1 -1
- package/lib/commonjs/core/passForwardRef.js +27 -0
- package/lib/commonjs/core/passForwardRef.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/index.js +13 -0
- package/lib/commonjs/core/withUnistyles/index.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/types.js +8 -0
- package/lib/commonjs/core/withUnistyles/types.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/useDependencies.js +81 -0
- package/lib/commonjs/core/withUnistyles/useDependencies.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.js +88 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.js.map +1 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js +96 -0
- package/lib/commonjs/core/withUnistyles/withUnistyles.native.js.map +1 -0
- package/lib/commonjs/hooks/useMedia.js +17 -33
- package/lib/commonjs/hooks/useMedia.js.map +1 -1
- package/lib/commonjs/hooks/useMedia.native.js +60 -0
- package/lib/commonjs/hooks/useMedia.native.js.map +1 -0
- package/lib/commonjs/index.js +33 -16
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/specs/ShadowRegistry/index.js +3 -3
- package/lib/commonjs/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/commonjs/specs/index.js +14 -40
- package/lib/commonjs/specs/index.js.map +1 -1
- package/lib/commonjs/specs/index.native.js +54 -0
- package/lib/commonjs/specs/index.native.js.map +1 -0
- package/lib/commonjs/web/create.js +12 -33
- package/lib/commonjs/web/create.js.map +1 -1
- package/lib/commonjs/web/index.js.map +1 -1
- package/lib/commonjs/web/registry.js +10 -3
- package/lib/commonjs/web/registry.js.map +1 -1
- package/lib/commonjs/web/runtime.js +3 -1
- package/lib/commonjs/web/runtime.js.map +1 -1
- package/lib/commonjs/web/shadowRegistry.js +71 -64
- package/lib/commonjs/web/shadowRegistry.js.map +1 -1
- package/lib/commonjs/web/utils/unistyle.js +3 -3
- package/lib/commonjs/web/utils/unistyle.js.map +1 -1
- package/lib/module/components/ScopedTheme.js +29 -0
- package/lib/module/components/ScopedTheme.js.map +1 -0
- package/lib/module/components/Variants.js +26 -0
- package/lib/module/components/Variants.js.map +1 -0
- package/lib/module/components/index.js +2 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/components/native/ActivityIndicator.js +6 -0
- package/lib/module/components/native/ActivityIndicator.js.map +1 -0
- package/lib/module/components/native/FlatList.js +6 -0
- package/lib/module/components/native/FlatList.js.map +1 -0
- package/lib/module/components/native/Image.js +6 -0
- package/lib/module/components/native/Image.js.map +1 -0
- package/lib/module/components/native/ImageBackground.js +6 -0
- package/lib/module/components/native/ImageBackground.js.map +1 -0
- package/lib/module/components/native/KeyboardAvoidingView.js +6 -0
- package/lib/module/components/native/KeyboardAvoidingView.js.map +1 -0
- package/lib/module/components/native/Pressable.js +69 -0
- package/lib/module/components/native/Pressable.js.map +1 -0
- package/lib/module/components/native/Pressable.native.js +42 -0
- package/lib/module/components/native/Pressable.native.js.map +1 -0
- package/lib/module/components/native/RefreshControl.js +6 -0
- package/lib/module/components/native/RefreshControl.js.map +1 -0
- package/lib/module/components/native/ScrollView.js +6 -0
- package/lib/module/components/native/ScrollView.js.map +1 -0
- package/lib/module/components/native/SectionList.js +6 -0
- package/lib/module/components/native/SectionList.js.map +1 -0
- package/lib/module/components/native/Switch.js +6 -0
- package/lib/module/components/native/Switch.js.map +1 -0
- package/lib/module/components/native/Text.js +6 -0
- package/lib/module/components/native/Text.js.map +1 -0
- package/lib/module/components/native/TextInput.js +6 -0
- package/lib/module/components/native/TextInput.js.map +1 -0
- package/lib/module/components/native/TouchableHighlight.js +6 -0
- package/lib/module/components/native/TouchableHighlight.js.map +1 -0
- package/lib/module/components/native/TouchableOpacity.js +6 -0
- package/lib/module/components/native/TouchableOpacity.js.map +1 -0
- package/lib/module/components/native/View.js +6 -0
- package/lib/module/components/native/View.js.map +1 -0
- package/lib/module/components/native/VirtualizedList.js +6 -0
- package/lib/module/components/native/VirtualizedList.js.map +1 -0
- package/lib/module/core/createUnistylesComponent.js +5 -66
- package/lib/module/core/createUnistylesComponent.js.map +1 -1
- package/lib/module/core/createUnistylesElement.js +10 -0
- package/lib/module/core/createUnistylesElement.js.map +1 -0
- package/lib/module/core/createUnistylesImageBackground.js +21 -0
- package/lib/module/core/createUnistylesImageBackground.js.map +1 -0
- package/lib/module/core/index.js +4 -2
- package/lib/module/core/index.js.map +1 -1
- package/lib/module/core/passForwardRef.js +22 -0
- package/lib/module/core/passForwardRef.js.map +1 -0
- package/lib/module/core/withUnistyles/index.js +4 -0
- package/lib/module/core/withUnistyles/index.js.map +1 -0
- package/lib/module/core/withUnistyles/types.js +4 -0
- package/lib/module/core/withUnistyles/types.js.map +1 -0
- package/lib/module/core/withUnistyles/useDependencies.js +75 -0
- package/lib/module/core/withUnistyles/useDependencies.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.js +81 -0
- package/lib/module/core/withUnistyles/withUnistyles.js.map +1 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js +89 -0
- package/lib/module/core/withUnistyles/withUnistyles.native.js.map +1 -0
- package/lib/module/hooks/useMedia.js +19 -35
- package/lib/module/hooks/useMedia.js.map +1 -1
- package/lib/module/hooks/useMedia.native.js +55 -0
- package/lib/module/hooks/useMedia.native.js.map +1 -0
- package/lib/module/index.js +2 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/specs/ShadowRegistry/index.js +3 -3
- package/lib/module/specs/ShadowRegistry/index.js.map +1 -1
- package/lib/module/specs/index.js +2 -8
- package/lib/module/specs/index.js.map +1 -1
- package/lib/module/specs/index.native.js +11 -0
- package/lib/module/specs/index.native.js.map +1 -0
- package/lib/module/web/create.js +13 -34
- package/lib/module/web/create.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 +11 -4
- package/lib/module/web/registry.js.map +1 -1
- package/lib/module/web/runtime.js +3 -1
- package/lib/module/web/runtime.js.map +1 -1
- package/lib/module/web/shadowRegistry.js +70 -63
- package/lib/module/web/shadowRegistry.js.map +1 -1
- package/lib/module/web/utils/unistyle.js +1 -1
- package/lib/module/web/utils/unistyle.js.map +1 -1
- package/lib/typescript/src/components/ScopedTheme.d.ts +8 -0
- package/lib/typescript/src/components/ScopedTheme.d.ts.map +1 -0
- package/lib/typescript/src/components/Variants.d.ts +7 -0
- package/lib/typescript/src/components/Variants.d.ts.map +1 -0
- package/lib/typescript/src/components/index.d.ts +2 -1
- package/lib/typescript/src/components/index.d.ts.map +1 -1
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts +2 -0
- package/lib/typescript/src/components/native/ActivityIndicator.d.ts.map +1 -0
- package/lib/typescript/src/components/native/FlatList.d.ts +2 -0
- package/lib/typescript/src/components/native/FlatList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Image.d.ts +2 -0
- package/lib/typescript/src/components/native/Image.d.ts.map +1 -0
- package/lib/typescript/src/components/native/ImageBackground.d.ts +3 -0
- package/lib/typescript/src/components/native/ImageBackground.d.ts.map +1 -0
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts +2 -0
- package/lib/typescript/src/components/native/KeyboardAvoidingView.d.ts.map +1 -0
- package/lib/typescript/src/components/{Pressable.web.d.ts → native/Pressable.d.ts} +3 -2
- package/lib/typescript/src/components/native/Pressable.d.ts.map +1 -0
- package/lib/typescript/src/components/{Pressable.d.ts → native/Pressable.native.d.ts} +1 -3
- package/lib/typescript/src/components/native/Pressable.native.d.ts.map +1 -0
- package/lib/typescript/src/components/native/RefreshControl.d.ts +2 -0
- package/lib/typescript/src/components/native/RefreshControl.d.ts.map +1 -0
- package/lib/typescript/src/components/native/ScrollView.d.ts +2 -0
- package/lib/typescript/src/components/native/ScrollView.d.ts.map +1 -0
- package/lib/typescript/src/components/native/SectionList.d.ts +2 -0
- package/lib/typescript/src/components/native/SectionList.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Switch.d.ts +2 -0
- package/lib/typescript/src/components/native/Switch.d.ts.map +1 -0
- package/lib/typescript/src/components/native/Text.d.ts +2 -0
- package/lib/typescript/src/components/native/Text.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TextInput.d.ts +2 -0
- package/lib/typescript/src/components/native/TextInput.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts +2 -0
- package/lib/typescript/src/components/native/TouchableHighlight.d.ts.map +1 -0
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts +2 -0
- package/lib/typescript/src/components/native/TouchableOpacity.d.ts.map +1 -0
- package/lib/typescript/src/components/native/View.d.ts +2 -0
- package/lib/typescript/src/components/native/View.d.ts.map +1 -0
- package/lib/typescript/src/components/native/VirtualizedList.d.ts +2 -0
- package/lib/typescript/src/components/native/VirtualizedList.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesComponent.d.ts +9 -3
- package/lib/typescript/src/core/createUnistylesComponent.d.ts.map +1 -1
- package/lib/typescript/src/core/createUnistylesElement.d.ts +3 -0
- package/lib/typescript/src/core/createUnistylesElement.d.ts.map +1 -0
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts +4 -0
- package/lib/typescript/src/core/createUnistylesImageBackground.d.ts.map +1 -0
- package/lib/typescript/src/core/index.d.ts +4 -2
- package/lib/typescript/src/core/index.d.ts.map +1 -1
- package/lib/typescript/src/core/passForwardRef.d.ts +3 -0
- package/lib/typescript/src/core/passForwardRef.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/index.d.ts +2 -0
- package/lib/typescript/src/core/withUnistyles/index.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/types.d.ts +6 -0
- package/lib/typescript/src/core/withUnistyles/types.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts +13 -0
- package/lib/typescript/src/core/withUnistyles/useDependencies.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts +11 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.d.ts.map +1 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts +8 -0
- package/lib/typescript/src/core/withUnistyles/withUnistyles.native.d.ts.map +1 -0
- package/lib/typescript/src/hooks/useMedia.d.ts +1 -1
- package/lib/typescript/src/hooks/useMedia.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useMedia.native.d.ts +6 -0
- package/lib/typescript/src/hooks/useMedia.native.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -2
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts +7 -2
- package/lib/typescript/src/specs/ShadowRegistry/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts +17 -0
- package/lib/typescript/src/specs/ShadowRegistry/types.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.d.ts +3 -11
- package/lib/typescript/src/specs/index.d.ts.map +1 -1
- package/lib/typescript/src/specs/index.native.d.ts +12 -0
- package/lib/typescript/src/specs/index.native.d.ts.map +1 -0
- package/lib/typescript/src/web/create.d.ts +1 -1441
- package/lib/typescript/src/web/create.d.ts.map +1 -1
- package/lib/typescript/src/web/index.d.ts +2 -1441
- package/lib/typescript/src/web/index.d.ts.map +1 -1
- package/lib/typescript/src/web/registry.d.ts +2 -3
- package/lib/typescript/src/web/registry.d.ts.map +1 -1
- package/lib/typescript/src/web/runtime.d.ts.map +1 -1
- package/lib/typescript/src/web/shadowRegistry.d.ts +11 -3
- package/lib/typescript/src/web/shadowRegistry.d.ts.map +1 -1
- package/lib/typescript/src/web/utils/unistyle.d.ts +1 -2
- package/lib/typescript/src/web/utils/unistyle.d.ts.map +1 -1
- package/nitrogen/generated/ios/Unistyles-Swift-Cxx-Umbrella.hpp +3 -0
- package/package.json +4 -4
- package/plugin/common.js +4 -6
- package/plugin/import.js +63 -26
- package/plugin/index.js +48 -28
- package/plugin/ref.js +0 -234
- package/plugin/style.js +4 -317
- package/plugin/stylesheet.js +25 -10
- package/plugin/variants.js +54 -1
- package/src/components/ScopedTheme.tsx +32 -0
- package/src/components/Variants.tsx +29 -0
- package/src/components/index.ts +2 -1
- package/src/components/native/ActivityIndicator.tsx +4 -0
- package/src/components/native/FlatList.tsx +4 -0
- package/src/components/native/Image.tsx +4 -0
- package/src/components/native/ImageBackground.tsx +4 -0
- package/src/components/native/KeyboardAvoidingView.tsx +4 -0
- package/src/components/native/Pressable.native.tsx +55 -0
- package/src/components/native/Pressable.tsx +98 -0
- package/src/components/native/RefreshControl.tsx +4 -0
- package/src/components/native/ScrollView.tsx +4 -0
- package/src/components/native/SectionList.tsx +4 -0
- package/src/components/native/Switch.tsx +4 -0
- package/src/components/native/Text.tsx +4 -0
- package/src/components/native/TextInput.tsx +4 -0
- package/src/components/native/TouchableHighlight.tsx +4 -0
- package/src/components/native/TouchableOpacity.tsx +4 -0
- package/src/components/native/View.tsx +4 -0
- package/src/components/native/VirtualizedList.tsx +4 -0
- package/src/core/createUnistylesComponent.tsx +6 -76
- package/src/core/createUnistylesElement.tsx +9 -0
- package/src/core/createUnistylesImageBackground.tsx +24 -0
- package/src/core/index.ts +4 -2
- package/src/core/passForwardRef.ts +29 -0
- package/src/core/withUnistyles/index.ts +1 -0
- package/src/core/withUnistyles/types.ts +7 -0
- package/src/core/withUnistyles/useDependencies.ts +93 -0
- package/src/core/withUnistyles/withUnistyles.native.tsx +96 -0
- package/src/core/withUnistyles/withUnistyles.tsx +90 -0
- package/src/hooks/useMedia.native.ts +65 -0
- package/src/hooks/useMedia.ts +19 -36
- package/src/index.ts +2 -2
- package/src/specs/ShadowRegistry/index.ts +14 -5
- package/src/specs/ShadowRegistry/types.ts +18 -1
- package/src/specs/index.native.ts +27 -0
- package/src/specs/index.ts +3 -27
- package/src/web/create.ts +14 -32
- package/src/web/index.ts +3 -2
- package/src/web/registry.ts +15 -6
- package/src/web/runtime.ts +3 -1
- package/src/web/shadowRegistry.ts +66 -52
- package/src/web/utils/unistyle.ts +1 -2
- package/lib/commonjs/components/Pressable.js +0 -74
- package/lib/commonjs/components/Pressable.js.map +0 -1
- package/lib/commonjs/components/Pressable.web.js.map +0 -1
- package/lib/commonjs/core/createUnistylesComponent.native.js +0 -82
- package/lib/commonjs/core/createUnistylesComponent.native.js.map +0 -1
- package/lib/commonjs/core/getBoundArgs.js +0 -18
- package/lib/commonjs/core/getBoundArgs.js.map +0 -1
- package/lib/commonjs/core/getId.js +0 -9
- package/lib/commonjs/core/getId.js.map +0 -1
- package/lib/commonjs/hooks/useMedia.web.js +0 -43
- package/lib/commonjs/hooks/useMedia.web.js.map +0 -1
- package/lib/commonjs/specs/index.web.js +0 -17
- package/lib/commonjs/specs/index.web.js.map +0 -1
- package/lib/module/components/Pressable.js +0 -68
- package/lib/module/components/Pressable.js.map +0 -1
- package/lib/module/components/Pressable.web.js +0 -109
- package/lib/module/components/Pressable.web.js.map +0 -1
- package/lib/module/core/createUnistylesComponent.native.js +0 -75
- package/lib/module/core/createUnistylesComponent.native.js.map +0 -1
- package/lib/module/core/getBoundArgs.js +0 -13
- package/lib/module/core/getBoundArgs.js.map +0 -1
- package/lib/module/core/getId.js +0 -4
- package/lib/module/core/getId.js.map +0 -1
- package/lib/module/hooks/useMedia.web.js +0 -38
- package/lib/module/hooks/useMedia.web.js.map +0 -1
- package/lib/module/specs/index.web.js +0 -4
- package/lib/module/specs/index.web.js.map +0 -1
- package/lib/typescript/src/components/Pressable.d.ts.map +0 -1
- package/lib/typescript/src/components/Pressable.web.d.ts.map +0 -1
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts +0 -8
- package/lib/typescript/src/core/createUnistylesComponent.native.d.ts.map +0 -1
- package/lib/typescript/src/core/getBoundArgs.d.ts +0 -2
- package/lib/typescript/src/core/getBoundArgs.d.ts.map +0 -1
- package/lib/typescript/src/core/getId.d.ts +0 -2
- package/lib/typescript/src/core/getId.d.ts.map +0 -1
- package/lib/typescript/src/hooks/useMedia.web.d.ts +0 -6
- package/lib/typescript/src/hooks/useMedia.web.d.ts.map +0 -1
- package/lib/typescript/src/specs/index.web.d.ts +0 -2
- package/lib/typescript/src/specs/index.web.d.ts.map +0 -1
- package/src/components/Pressable.tsx +0 -89
- package/src/components/Pressable.web.tsx +0 -129
- package/src/core/createUnistylesComponent.native.tsx +0 -83
- package/src/core/getBoundArgs.ts +0 -15
- package/src/core/getId.ts +0 -1
- package/src/hooks/useMedia.web.ts +0 -47
- package/src/specs/index.web.ts +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/web/index.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,UAAU,CAAA;AAEzD,eAAO,MAAM,UAAU;;YAED,yBAAyB;;;;;;;;;;;;;;;iBAe9B,MAAM,KAAK,MAAM;yBACT,KAAK,CAAC,MAAM,CAAC;mBACd,MAAM;CAC7B,CAAA;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAA;AAC5C,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAA;AAC1D,cAAc,QAAQ,CAAA"}
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import type { UnistylesTheme, UnistylesValues } from '../types';
|
2
2
|
import type { StyleSheet, StyleSheetWithSuperPowers } from '../types/stylesheet';
|
3
|
-
import type { UnistyleDependency } from '../specs
|
4
|
-
import type { UnistylesMiniRuntime } from '../specs';
|
3
|
+
import type { UnistylesMiniRuntime, UnistyleDependency } from '../specs';
|
5
4
|
declare class UnistylesRegistryBuilder {
|
6
5
|
#private;
|
7
6
|
private readonly stylesheets;
|
@@ -9,7 +8,7 @@ declare class UnistylesRegistryBuilder {
|
|
9
8
|
private readonly disposeListenersMap;
|
10
9
|
private readonly dependenciesMap;
|
11
10
|
private get styleTag();
|
12
|
-
getComputedStylesheet: (stylesheet: StyleSheetWithSuperPowers<StyleSheet
|
11
|
+
getComputedStylesheet: (stylesheet: StyleSheetWithSuperPowers<StyleSheet>, scopedThemeName?: UnistylesTheme) => StyleSheet;
|
13
12
|
addDependenciesToStylesheet: (stylesheet: (theme: UnistylesTheme, miniRuntime: UnistylesMiniRuntime) => StyleSheet, dependencies: Array<UnistyleDependency>) => void;
|
14
13
|
add: (value: UnistylesValues) => {
|
15
14
|
hash: string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/web/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAKhF,OAAO,KAAK,EAAE,
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../src/web/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC/D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,qBAAqB,CAAA;AAKhF,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAA;AAWxE,cAAM,wBAAwB;;IAC1B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA+D;IAC3F,OAAO,CAAC,QAAQ,CAAC,aAAa,CAA0C;IAExE,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IACtE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAA4E;IAE5G,OAAO,KAAK,QAAQ,GAcnB;IAED,qBAAqB,eAAgB,yBAAyB,CAAC,UAAU,CAAC,oBAAoB,cAAc,gBA4B3G;IAED,2BAA2B,eAAgB,CAAC,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,oBAAoB,KAAK,UAAU,gBAAgB,KAAK,CAAC,kBAAkB,CAAC,UAe3J;IAED,GAAG,UAAW,eAAe;;;MAiB5B;IAED,WAAW,SAAU,MAAM,UAAU,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,UAwEvD;IAED,OAAO,CAAC,SAAS,CAmBhB;IAED,MAAM,UAAW,eAAe,UAmB/B;CACJ;AAED,eAAO,MAAM,iBAAiB,0BAAiC,CAAA"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../../src/web/runtime.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAC3F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAQjD,cAAM,uBAAuB;IACzB,UAAU,wBAAuB;IACjC,SAAS,wBAAsB;IAE/B,OAAO,CAAC,aAAa;IAYrB,OAAO,CAAC,YAAY;IAYpB,IAAI,WAAW,gBASd;IAED,IAAI,SAAS,cAMZ;IAED,IAAI,mBAAmB,2BAEtB;IAED,IAAI,WAAW,sCAEd;IAED,IAAI,UAAU,wDAEb;IAED,IAAI,WAAW,gBAMd;IAED,IAAI,KAAK,UAER;IAED,IAAI,UAAU,WAEb;IAED,IAAI,MAAM;;;MAYT;IAED,IAAI,SAAS,WAEZ;IAED,IAAI,MAAM;;;;;;MAQT;IAED,IAAI,SAAS,oDAEZ;IAED,IAAI,GAAG,YAEN;IAED,IAAI,iBAAiB,YAEpB;IAED,IAAI,aAAa,2DAEhB;IAED,IAAI,WAAW,IAAI,oBAAoB,CAuBtC;IAED,QAAQ,cAAe,YAAY,UAYlC;IAED,iBAAiB,cAAe,OAAO,UAQtC;IAED,0BAA0B,UAAW,MAAM,UAM1C;IAED,gBAAgB,aAAW;IAE3B,WAAW,cAAe,YAAY,WAAW,CAAC,YAAY,EAAE,QAAQ,KAAK,QAAQ,UAQpF;IAED,QAAQ,mCAQP;CACJ;AAED,eAAO,MAAM,gBAAgB,yBAAgC,CAAA"}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { UnistylesValues } from '../types';
|
1
|
+
import type { UnistylesTheme, UnistylesValues } from '../types';
|
2
2
|
type Style = UnistylesValues | ((...args: Array<any>) => UnistylesValues);
|
3
3
|
declare class UnistylesShadowRegistryBuilder {
|
4
4
|
name: string;
|
@@ -7,9 +7,17 @@ declare class UnistylesShadowRegistryBuilder {
|
|
7
7
|
toString: () => string;
|
8
8
|
dispose: () => void;
|
9
9
|
private resultsMap;
|
10
|
-
private hashMap;
|
11
10
|
private classNamesMap;
|
12
|
-
|
11
|
+
private selectedVariants;
|
12
|
+
private scopedTheme;
|
13
|
+
private disposeMap;
|
14
|
+
add: (ref: any, styles: Array<Style>) => string[] | undefined;
|
15
|
+
selectVariants: (variants?: Record<string, string | boolean | undefined>) => void;
|
16
|
+
setScopedTheme: (theme?: UnistylesTheme) => void;
|
17
|
+
getScopedTheme: () => undefined;
|
18
|
+
getVariants: () => {
|
19
|
+
[k: string]: string | boolean | undefined;
|
20
|
+
};
|
13
21
|
remove: () => void;
|
14
22
|
}
|
15
23
|
export declare const UnistylesShadowRegistry: UnistylesShadowRegistryBuilder;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;
|
1
|
+
{"version":3,"file":"shadowRegistry.d.ts","sourceRoot":"","sources":["../../../../src/web/shadowRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAO/D,KAAK,KAAK,GAAG,eAAe,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,KAAK,eAAe,CAAC,CAAA;AAEzE,cAAM,8BAA8B;IAEhC,IAAI,SAA4B;IAChC,MAAM,SAAQ;IACd,MAAM,gBAAa;IACnB,QAAQ,eAAkC;IAC1C,OAAO,aAAW;IAGlB,OAAO,CAAC,UAAU,CAA0C;IAC5D,OAAO,CAAC,aAAa,CAAwC;IAC7D,OAAO,CAAC,gBAAgB,CAAkD;IAC1E,OAAO,CAAC,WAAW,CAAwC;IAC3D,OAAO,CAAC,UAAU,CAAuC;IAEzD,GAAG,QAAS,GAAG,UAAU,KAAK,CAAC,KAAK,CAAC,0BAiHpC;IAED,cAAc,cAAe,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,UAUxE;IAED,cAAc,WAAY,cAAc,UAEvC;IAED,cAAc,kBAAyB;IAEvC,WAAW;;MAA4D;IAEvE,MAAM,aAAW;CACpB;AAED,eAAO,MAAM,uBAAuB,gCAAuC,CAAA"}
|
@@ -6,12 +6,11 @@ export type UnistyleSecrets = {
|
|
6
6
|
__uni__stylesheet: StyleSheetWithSuperPowers<StyleSheet>;
|
7
7
|
__uni__key: string;
|
8
8
|
__uni__refs: Set<HTMLElement>;
|
9
|
-
__uni__variants: Record<string, any>;
|
10
9
|
__uni__args?: Array<any>;
|
11
10
|
};
|
12
11
|
export declare const assignSecrets: <T>(object: T, secrets: UnistyleSecrets) => T;
|
13
12
|
export declare const extractSecrets: (object: any) => UnistyleSecrets | undefined;
|
14
|
-
export declare const
|
13
|
+
export declare const removeInlineStyles: (values: UnistylesValues) => {};
|
15
14
|
export declare const isInDocument: (element: HTMLElement) => boolean;
|
16
15
|
export declare const extractMediaQueryValue: (query: string) => number | undefined;
|
17
16
|
export declare const getMediaQuery: (query: string) => string;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKpG,eAAO,MAAM,aAAa,WAAY,WAAW,qBAQhD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;IAC7B,
|
1
|
+
{"version":3,"file":"unistyle.d.ts","sourceRoot":"","sources":["../../../../../src/web/utils/unistyle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAA;AACpE,OAAO,EAAE,WAAW,EAAe,MAAM,mBAAmB,CAAA;AAC5D,OAAO,KAAK,EAAE,UAAU,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAKpG,eAAO,MAAM,aAAa,WAAY,WAAW,qBAQhD,CAAA;AAED,MAAM,MAAM,eAAe,GAAG;IAC1B,iBAAiB,EAAE,yBAAyB,CAAC,UAAU,CAAC,CAAC;IACzD,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,GAAG,CAAC,WAAW,CAAC,CAAA;IAC7B,WAAW,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAA;CAC3B,CAAA;AAED,eAAO,MAAM,aAAa,GAAI,CAAC,UAAU,CAAC,WAAW,eAAe,MAKnE,CAAA;AAED,eAAO,MAAM,cAAc,WAAY,GAAG,gCAEzC,CAAA;AAED,eAAO,MAAM,kBAAkB,WAAY,eAAe,OAUzD,CAAA;AAED,eAAO,MAAM,YAAY,YAAa,WAAW,YAAoC,CAAA;AAErF,eAAO,MAAM,sBAAsB,UAAW,MAAM,uBAYnD,CAAA;AAED,eAAO,MAAM,aAAa,UAAW,MAAM,WAmB1C,CAAA;AAED,eAAO,MAAM,2BAA2B,UAAW,GAAG,yBAQrD,CAAA"}
|
@@ -54,6 +54,9 @@ namespace Unistyles { class HybridNativePlatformSpecCxx; }
|
|
54
54
|
// This header is generated by Xcode/Swift on every app build.
|
55
55
|
// If it cannot be found, make sure the Swift module's name (= podspec name) is actually "Unistyles".
|
56
56
|
#include "Unistyles-Swift.h"
|
57
|
+
// Same as above, but used when building with frameworks (`use_frameworks`)
|
58
|
+
#elif __has_include(<Unistyles/Unistyles-Swift.h>)
|
59
|
+
#include <Unistyles/Unistyles-Swift.h>
|
57
60
|
#else
|
58
61
|
#error Unistyles's autogenerated Swift header cannot be found! Make sure the Swift module's name (= podspec name) is actually "Unistyles", and try building the app first.
|
59
62
|
#endif
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "react-native-unistyles",
|
3
|
-
"version": "3.0.0-beta.
|
3
|
+
"version": "3.0.0-beta.2",
|
4
4
|
"description": "Level up your React Native StyleSheet",
|
5
5
|
"scripts": {
|
6
6
|
"test": "jest",
|
@@ -70,11 +70,11 @@
|
|
70
70
|
"husky": "9.1.7",
|
71
71
|
"jest": "29.7.0",
|
72
72
|
"metro-react-native-babel-preset": "0.77.0",
|
73
|
-
"nitro-codegen": "0.18.
|
73
|
+
"nitro-codegen": "0.18.2",
|
74
74
|
"react": "18.3.1",
|
75
75
|
"react-native": "0.76.3",
|
76
76
|
"react-native-builder-bob": "0.33.1",
|
77
|
-
"react-native-nitro-modules": "0.18.
|
77
|
+
"react-native-nitro-modules": "0.18.2",
|
78
78
|
"react-native-web": "0.19.13",
|
79
79
|
"react-test-renderer": "18.3.1",
|
80
80
|
"release-it": "17.6.0",
|
@@ -93,7 +93,7 @@
|
|
93
93
|
],
|
94
94
|
"packageManager": "yarn@3.6.1",
|
95
95
|
"engines": {
|
96
|
-
"node": ">=
|
96
|
+
"node": ">= 18.0.0"
|
97
97
|
},
|
98
98
|
"jest": {
|
99
99
|
"preset": "react-native",
|
package/plugin/common.js
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
function getIdentifierNameFromExpression(t, memberExpression) {
|
2
2
|
if (t.isMemberExpression(memberExpression)) {
|
3
3
|
if (memberExpression.computed) {
|
4
|
-
return
|
4
|
+
return [
|
5
|
+
getIdentifierNameFromExpression(t, memberExpression.property),
|
6
|
+
getIdentifierNameFromExpression(t, memberExpression.object)
|
7
|
+
].flat()
|
5
8
|
}
|
6
9
|
|
7
10
|
const object = memberExpression.object
|
@@ -15,11 +18,6 @@ function getIdentifierNameFromExpression(t, memberExpression) {
|
|
15
18
|
if (t.isMemberExpression(object)) {
|
16
19
|
return getIdentifierNameFromExpression(t, object).flat()
|
17
20
|
}
|
18
|
-
|
19
|
-
// If the object is a computed property, it may also be an Identifier
|
20
|
-
if (t.isMemberExpression(object) && t.isIdentifier(object.property)) {
|
21
|
-
return [object.object.name]
|
22
|
-
}
|
23
21
|
}
|
24
22
|
|
25
23
|
if (t.isBinaryExpression(memberExpression)) {
|
package/plugin/import.js
CHANGED
@@ -1,34 +1,71 @@
|
|
1
|
-
|
2
|
-
const
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
const rnImport = path.node.body.find(node => t.isImportDeclaration(node) && node.source.value === 'react-native')
|
17
|
-
|
18
|
-
if (rnImport) {
|
19
|
-
rnImport.specifiers = rnImport.specifiers.filter(specifier => specifier.local.name !== 'Pressable')
|
1
|
+
function addUnistylesImport(t, path, state) {
|
2
|
+
const localNames = Object.keys(state.reactNativeImports)
|
3
|
+
const names = Object.values(state.reactNativeImports)
|
4
|
+
const pairs = Object.entries(state.reactNativeImports)
|
5
|
+
const nodesToRemove = []
|
6
|
+
|
7
|
+
// remove rn-imports
|
8
|
+
path.node.body.forEach(node => {
|
9
|
+
// user might have multiple imports like import type, import
|
10
|
+
if (t.isImportDeclaration(node) && node.source.value === 'react-native') {
|
11
|
+
node.specifiers = node.specifiers.filter(specifier => !localNames.some(name => name === specifier.local.name))
|
12
|
+
|
13
|
+
if (node.specifiers.length === 0) {
|
14
|
+
nodesToRemove.push(node)
|
15
|
+
}
|
20
16
|
}
|
17
|
+
})
|
21
18
|
|
22
|
-
|
23
|
-
|
24
|
-
const
|
25
|
-
? unistylesImport.specifiers.find(specifier => specifier.imported.name === 'Pressable' && specifier.local.name !== "NativePressableReactNative")
|
26
|
-
: false
|
19
|
+
// remove RNWeb imports
|
20
|
+
names.forEach(name => {
|
21
|
+
const rnWebImport = path.node.body.find(node => t.isImportDeclaration(node) && node.source.value === `react-native-web/dist/exports/${name}`)
|
27
22
|
|
28
|
-
if (rnWebImport
|
23
|
+
if (rnWebImport) {
|
29
24
|
rnWebImport.specifiers = []
|
30
25
|
}
|
26
|
+
})
|
27
|
+
|
28
|
+
// import components from react-native-unistyles
|
29
|
+
pairs.forEach(([localName, name]) => {
|
30
|
+
const newImport = t.importDeclaration(
|
31
|
+
[t.importSpecifier(t.identifier(localName), t.identifier(name))],
|
32
|
+
t.stringLiteral(state.opts.isLocal
|
33
|
+
? state.file.opts.filename.split('react-native-unistyles').at(0).concat(`react-native-unistyles/src/components/native/${name}`)
|
34
|
+
: `react-native-unistyles/src/components/native/${name}`
|
35
|
+
)
|
36
|
+
)
|
37
|
+
|
38
|
+
path.node.body.unshift(newImport)
|
39
|
+
})
|
40
|
+
|
41
|
+
// import variants
|
42
|
+
if (state.file.hasVariants) {
|
43
|
+
const unistylesImport = path.node.body
|
44
|
+
.find(node => t.isImportDeclaration(node) && node.source.value === 'react-native-unistyles')
|
45
|
+
|
46
|
+
if (unistylesImport) {
|
47
|
+
// prevent duplications
|
48
|
+
if (!unistylesImport.specifiers.some(specifier => specifier.local.name === 'Variants')) {
|
49
|
+
unistylesImport.specifiers.push(t.importSpecifier(t.identifier('Variants'), t.identifier('Variants')))
|
50
|
+
}
|
51
|
+
} else {
|
52
|
+
// Add a new import declaration for "Variants" from "react-native-unistyles"
|
53
|
+
const newImport = t.importDeclaration(
|
54
|
+
[t.importSpecifier(t.identifier('Variants'), t.identifier('Variants'))],
|
55
|
+
t.stringLiteral('react-native-unistyles')
|
56
|
+
)
|
57
|
+
|
58
|
+
path.node.body.unshift(newImport)
|
59
|
+
}
|
31
60
|
}
|
32
61
|
|
33
|
-
|
62
|
+
// cleanup
|
63
|
+
nodesToRemove.forEach(node => path.node.body.splice(path.node.body.indexOf(node), 1))
|
64
|
+
}
|
65
|
+
|
66
|
+
const isInsideNodeModules = state => state.file.opts.filename.includes('node_modules')
|
67
|
+
|
68
|
+
module.exports = {
|
69
|
+
isInsideNodeModules,
|
70
|
+
addUnistylesImport
|
34
71
|
}
|
package/plugin/index.js
CHANGED
@@ -1,35 +1,41 @@
|
|
1
|
-
const addUnistylesImport = require('./import')
|
1
|
+
const { addUnistylesImport, isInsideNodeModules } = require('./import')
|
2
2
|
const { getStyleMetadata, getStyleAttribute, styleAttributeToArray, handlePressable } = require('./style')
|
3
|
-
const {
|
4
|
-
const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag,
|
5
|
-
const { isUsingVariants, extractVariants } = require('./variants')
|
3
|
+
const { hasStringRef } = require('./ref')
|
4
|
+
const { isUnistylesStyleSheet, analyzeDependencies, addStyleSheetTag, getUnistyles } = require('./stylesheet')
|
5
|
+
const { isUsingVariants, extractVariants, addJSXVariants } = require('./variants')
|
6
6
|
|
7
7
|
const reactNativeComponentNames = [
|
8
|
+
'ActivityIndicator',
|
8
9
|
'View',
|
9
10
|
'Text',
|
10
11
|
'Image',
|
11
12
|
'ImageBackground',
|
12
13
|
'KeyboardAvoidingView',
|
13
|
-
'Modal',
|
14
14
|
'Pressable',
|
15
15
|
'ScrollView',
|
16
16
|
'FlatList',
|
17
17
|
'SectionList',
|
18
18
|
'Switch',
|
19
|
-
'Text',
|
20
19
|
'TextInput',
|
20
|
+
'RefreshControl',
|
21
21
|
'TouchableHighlight',
|
22
22
|
'TouchableOpacity',
|
23
|
-
'TouchableWithoutFeedback',
|
24
23
|
'VirtualizedList'
|
25
24
|
]
|
26
25
|
|
26
|
+
// Modal - there is no exposed native handle
|
27
|
+
// TouchableWithoutFeedback - can't accept a ref
|
28
|
+
|
27
29
|
module.exports = function ({ types: t }) {
|
28
30
|
return {
|
29
31
|
name: 'babel-react-native-unistyles',
|
30
32
|
visitor: {
|
31
33
|
Program: {
|
32
34
|
enter(path, state) {
|
35
|
+
if (isInsideNodeModules(state)) {
|
36
|
+
return
|
37
|
+
}
|
38
|
+
|
33
39
|
state.file.hasAnyUnistyle = false
|
34
40
|
state.file.hasUnistylesImport = false
|
35
41
|
state.file.shouldIncludePressable = false
|
@@ -40,7 +46,7 @@ module.exports = function ({ types: t }) {
|
|
40
46
|
state.reactNativeImports = {}
|
41
47
|
},
|
42
48
|
exit(path, state) {
|
43
|
-
if (state.file.hasAnyUnistyle) {
|
49
|
+
if (state.file.hasAnyUnistyle || state.file.hasVariants) {
|
44
50
|
addUnistylesImport(t, path, state)
|
45
51
|
}
|
46
52
|
}
|
@@ -65,6 +71,10 @@ module.exports = function ({ types: t }) {
|
|
65
71
|
}
|
66
72
|
},
|
67
73
|
VariableDeclaration(path, state) {
|
74
|
+
if (isInsideNodeModules(state)) {
|
75
|
+
return
|
76
|
+
}
|
77
|
+
|
68
78
|
path.node.declarations.forEach((declaration) => {
|
69
79
|
if (t.isArrowFunctionExpression(declaration.init) || t.isFunctionExpression(declaration.init)) {
|
70
80
|
const componentName = declaration.id
|
@@ -78,6 +88,10 @@ module.exports = function ({ types: t }) {
|
|
78
88
|
})
|
79
89
|
},
|
80
90
|
ImportDeclaration(path, state) {
|
91
|
+
if (isInsideNodeModules(state)) {
|
92
|
+
return
|
93
|
+
}
|
94
|
+
|
81
95
|
const importSource = path.node.source.value
|
82
96
|
|
83
97
|
if (importSource.includes('react-native-unistyles')) {
|
@@ -97,7 +111,7 @@ module.exports = function ({ types: t }) {
|
|
97
111
|
}
|
98
112
|
|
99
113
|
if (specifier.imported && reactNativeComponentNames.includes(specifier.imported.name)) {
|
100
|
-
state.reactNativeImports[specifier.local.name] =
|
114
|
+
state.reactNativeImports[specifier.local.name] = specifier.imported.name
|
101
115
|
}
|
102
116
|
})
|
103
117
|
}
|
@@ -107,6 +121,10 @@ module.exports = function ({ types: t }) {
|
|
107
121
|
}
|
108
122
|
},
|
109
123
|
JSXElement(path, state) {
|
124
|
+
if (isInsideNodeModules(state)) {
|
125
|
+
return
|
126
|
+
}
|
127
|
+
|
110
128
|
if (state.file.isClassComponent) {
|
111
129
|
return
|
112
130
|
}
|
@@ -147,17 +165,15 @@ module.exports = function ({ types: t }) {
|
|
147
165
|
// to add import
|
148
166
|
state.file.hasAnyUnistyle = true
|
149
167
|
|
150
|
-
|
151
|
-
|
152
|
-
if (!refProp && hasStringRef(t, path)) {
|
168
|
+
if (hasStringRef(t, path)) {
|
153
169
|
throw new Error("Detected string based ref which is not supported by Unistyles.")
|
154
170
|
}
|
155
|
-
|
156
|
-
refProp
|
157
|
-
? overrideRef(t, path, refProp, metadata, state)
|
158
|
-
: addRef(t, path, metadata, state)
|
159
171
|
},
|
160
172
|
CallExpression(path, state) {
|
173
|
+
if (isInsideNodeModules(state)) {
|
174
|
+
return
|
175
|
+
}
|
176
|
+
|
161
177
|
if (isUsingVariants(t, path)) {
|
162
178
|
extractVariants(t, path, state)
|
163
179
|
}
|
@@ -174,13 +190,11 @@ module.exports = function ({ types: t }) {
|
|
174
190
|
if (t.isObjectExpression(arg)) {
|
175
191
|
arg.properties.forEach(property => {
|
176
192
|
if (t.isObjectProperty(property)) {
|
177
|
-
const
|
193
|
+
const propertyValues = getUnistyles(t, property)
|
178
194
|
|
179
|
-
|
180
|
-
|
181
|
-
}
|
182
|
-
|
183
|
-
analyzeDependencies(t, state, property.key.name, propertyValue)
|
195
|
+
propertyValues.forEach(propertyValue => {
|
196
|
+
analyzeDependencies(t, state, property.key.name, propertyValue)
|
197
|
+
})
|
184
198
|
}
|
185
199
|
})
|
186
200
|
}
|
@@ -204,17 +218,23 @@ module.exports = function ({ types: t }) {
|
|
204
218
|
if (t.isObjectExpression(body)) {
|
205
219
|
body.properties.forEach(property => {
|
206
220
|
if (t.isObjectProperty(property)) {
|
207
|
-
const
|
208
|
-
|
209
|
-
if (!propertyValue) {
|
210
|
-
return
|
211
|
-
}
|
221
|
+
const propertyValues = getUnistyles(t, property)
|
212
222
|
|
213
|
-
|
223
|
+
propertyValues.forEach(propertyValue => {
|
224
|
+
analyzeDependencies(t, state, property.key.name, propertyValue, themeLocalName, miniRuntimeLocalName)
|
225
|
+
})
|
214
226
|
}
|
215
227
|
})
|
216
228
|
}
|
217
229
|
}
|
230
|
+
},
|
231
|
+
ReturnStatement(path, state) {
|
232
|
+
// ignore nested returns in JSX elements
|
233
|
+
const hasJSXParent = path.findParent(p => p.isJSXElement())
|
234
|
+
|
235
|
+
if (!hasJSXParent && state.file.hasVariants) {
|
236
|
+
addJSXVariants(t, path, state)
|
237
|
+
}
|
218
238
|
}
|
219
239
|
}
|
220
240
|
}
|