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
@@ -0,0 +1,81 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useDependencies = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
var _specs = require("../../specs");
|
9
|
+
var _NativePlatform = require("../../specs/NativePlatform");
|
10
|
+
// It's imported that way because of circular dependency
|
11
|
+
|
12
|
+
const RTDependencyMap = {
|
13
|
+
breakpoint: _NativePlatform.UnistyleDependency.Breakpoints,
|
14
|
+
colorScheme: _NativePlatform.UnistyleDependency.ColorScheme,
|
15
|
+
contentSizeCategory: _NativePlatform.UnistyleDependency.ContentSizeCategory,
|
16
|
+
hasAdaptiveThemes: _NativePlatform.UnistyleDependency.AdaptiveThemes,
|
17
|
+
insets: _NativePlatform.UnistyleDependency.Insets,
|
18
|
+
fontScale: _NativePlatform.UnistyleDependency.FontScale,
|
19
|
+
isLandscape: _NativePlatform.UnistyleDependency.Orientation,
|
20
|
+
isPortrait: _NativePlatform.UnistyleDependency.Orientation,
|
21
|
+
navigationBar: _NativePlatform.UnistyleDependency.NavigationBar,
|
22
|
+
screen: _NativePlatform.UnistyleDependency.Dimensions,
|
23
|
+
statusBar: _NativePlatform.UnistyleDependency.StatusBar,
|
24
|
+
pixelRatio: _NativePlatform.UnistyleDependency.PixelRatio,
|
25
|
+
themeName: _NativePlatform.UnistyleDependency.ThemeName
|
26
|
+
};
|
27
|
+
const useDependencies = listener => {
|
28
|
+
const scopedTheme = _specs.UnistylesShadowRegistry.getScopedTheme();
|
29
|
+
const [dependencies] = (0, _react.useState)(() => new Set());
|
30
|
+
const [theme, setTheme] = (0, _react.useState)(_specs.UnistylesRuntime.getTheme(scopedTheme));
|
31
|
+
const [_, runtimeChanged] = (0, _react.useReducer)(() => ({}), {});
|
32
|
+
const disposeRef = (0, _react.useRef)();
|
33
|
+
const reinitListener = () => {
|
34
|
+
disposeRef.current?.();
|
35
|
+
disposeRef.current = listener({
|
36
|
+
dependencies: Array.from(dependencies),
|
37
|
+
updateTheme: () => {
|
38
|
+
if (scopedTheme) {
|
39
|
+
return;
|
40
|
+
}
|
41
|
+
setTheme(_specs.UnistylesRuntime.getTheme(scopedTheme));
|
42
|
+
},
|
43
|
+
updateRuntime: () => runtimeChanged()
|
44
|
+
});
|
45
|
+
};
|
46
|
+
(0, _react.useEffect)(() => {
|
47
|
+
reinitListener();
|
48
|
+
return () => disposeRef.current?.();
|
49
|
+
}, [dependencies.size]);
|
50
|
+
return {
|
51
|
+
mappingsCallback: callback => {
|
52
|
+
const proxifiedTheme = new Proxy(theme, {
|
53
|
+
get: (target, prop) => {
|
54
|
+
dependencies.add(_NativePlatform.UnistyleDependency.Theme);
|
55
|
+
return target[prop];
|
56
|
+
}
|
57
|
+
});
|
58
|
+
const proxifiedRuntime = new Proxy(_specs.UnistylesRuntime.miniRuntime, {
|
59
|
+
get: (target, prop) => {
|
60
|
+
if (prop in RTDependencyMap) {
|
61
|
+
dependencies.add(RTDependencyMap[prop]);
|
62
|
+
}
|
63
|
+
return target[prop];
|
64
|
+
}
|
65
|
+
});
|
66
|
+
return callback(proxifiedTheme, proxifiedRuntime);
|
67
|
+
},
|
68
|
+
addDependencies: newDependencies => {
|
69
|
+
const dependenciesSize = dependencies.size;
|
70
|
+
newDependencies.forEach(dependency => {
|
71
|
+
dependencies.add(dependency);
|
72
|
+
});
|
73
|
+
if (dependenciesSize === dependencies.size) {
|
74
|
+
return;
|
75
|
+
}
|
76
|
+
reinitListener();
|
77
|
+
}
|
78
|
+
};
|
79
|
+
};
|
80
|
+
exports.useDependencies = useDependencies;
|
81
|
+
//# sourceMappingURL=useDependencies.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","_specs","_NativePlatform","RTDependencyMap","breakpoint","UnistyleDependency","Breakpoints","colorScheme","ColorScheme","contentSizeCategory","ContentSizeCategory","hasAdaptiveThemes","AdaptiveThemes","insets","Insets","fontScale","FontScale","isLandscape","Orientation","isPortrait","navigationBar","NavigationBar","screen","Dimensions","statusBar","StatusBar","pixelRatio","PixelRatio","themeName","ThemeName","useDependencies","listener","scopedTheme","UnistylesShadowRegistry","getScopedTheme","dependencies","useState","Set","theme","setTheme","UnistylesRuntime","getTheme","_","runtimeChanged","useReducer","disposeRef","useRef","reinitListener","current","Array","from","updateTheme","updateRuntime","useEffect","size","mappingsCallback","callback","proxifiedTheme","Proxy","get","target","prop","add","Theme","proxifiedRuntime","miniRuntime","addDependencies","newDependencies","dependenciesSize","forEach","dependency","exports"],"sourceRoot":"../../../../src","sources":["core/withUnistyles/useDependencies.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,eAAA,GAAAF,OAAA;AADA;;AAKA,MAAMG,eAAe,GAAG;EACpBC,UAAU,EAAEC,kCAAkB,CAACC,WAAW;EAC1CC,WAAW,EAAEF,kCAAkB,CAACG,WAAW;EAC3CC,mBAAmB,EAAEJ,kCAAkB,CAACK,mBAAmB;EAC3DC,iBAAiB,EAAEN,kCAAkB,CAACO,cAAc;EACpDC,MAAM,EAAER,kCAAkB,CAACS,MAAM;EACjCC,SAAS,EAAEV,kCAAkB,CAACW,SAAS;EACvCC,WAAW,EAAEZ,kCAAkB,CAACa,WAAW;EAC3CC,UAAU,EAAEd,kCAAkB,CAACa,WAAW;EAC1CE,aAAa,EAAEf,kCAAkB,CAACgB,aAAa;EAC/CC,MAAM,EAAEjB,kCAAkB,CAACkB,UAAU;EACrCC,SAAS,EAAEnB,kCAAkB,CAACoB,SAAS;EACvCC,UAAU,EAAErB,kCAAkB,CAACsB,UAAU;EACzCC,SAAS,EAAEvB,kCAAkB,CAACwB;AAClC,CAA2E;AAQpE,MAAMC,eAAe,GAAIC,QAAgD,IAAK;EACjF,MAAMC,WAAW,GA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C,IAAI,CAAC;QACvB;MACJ,CAAC,CAAC;MACF,MAAMG,gBAAgB,GAAG,IAAIN,KAAK,CAAClB,uBAAgB,CAACyB,WAAW,EAAE;QAC7DN,GAAG,EAAEA,CAACC,MAAM,EAAEC,IAAI,KAAK;UACnB,IAAIA,IAAI,IAAI1D,eAAe,EAAE;YACzBgC,YAAY,CAAC2B,GAAG,CAAC3D,eAAe,CAAC0D,IAAI,CAAiC,CAAC;UAC3E;UAEA,OAAOD,MAAM,CAACC,IAAI,CAAwB;QAC9C;MACJ,CAAC,CAAC;MAEF,OAAOL,QAAQ,CAACC,cAAc,EAAEO,gBAAgB,CAAC;IACrD,CAAC;IACDE,eAAe,EAAGC,eAA0C,IAAK;MAC7D,MAAMC,gBAAgB,GAAGjC,YAAY,CAACmB,IAAI;MAE1Ca,eAAe,CAACE,OAAO,CAACC,UAAU,IAAI;QAClCnC,YAAY,CAAC2B,GAAG,CAACQ,UAAU,CAAC;MAChC,CAAC,CAAC;MAEF,IAAIF,gBAAgB,KAAKjC,YAAY,CAACmB,IAAI,EAAE;QACxC;MACJ;MAEAP,cAAc,CAAC,CAAC;IACpB;EACJ,CAAC;AACL,CAAC;AAAAwB,OAAA,CAAAzC,eAAA,GAAAA,eAAA","ignoreList":[]}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.withUnistyles = void 0;
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
8
|
+
var _listener = require("../../web/listener");
|
9
|
+
var _web = require("../../web");
|
10
|
+
var _utils = require("../../web/utils");
|
11
|
+
var _utils2 = require("../../utils");
|
12
|
+
var _useDependencies = require("./useDependencies");
|
13
|
+
var _NativePlatform = require("../../specs/NativePlatform");
|
14
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
15
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
16
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
17
|
+
const useShadowRegistry = style => {
|
18
|
+
const [ref] = (0, _react.useState)(document.createElement('div'));
|
19
|
+
const oldClassNames = (0, _react.useRef)([]);
|
20
|
+
const classNames = (0, _react.useMemo)(() => {
|
21
|
+
if (!style) {
|
22
|
+
return [];
|
23
|
+
}
|
24
|
+
const newClassNames = _web.UnistylesShadowRegistry.add(ref, [style]) ?? [];
|
25
|
+
if ((0, _utils.equal)(oldClassNames.current, newClassNames)) {
|
26
|
+
return oldClassNames.current;
|
27
|
+
}
|
28
|
+
oldClassNames.current = newClassNames;
|
29
|
+
return newClassNames;
|
30
|
+
}, [style]);
|
31
|
+
(0, _react.useEffect)(() => () => {
|
32
|
+
// Remove styles on unmount
|
33
|
+
if (style) {
|
34
|
+
_web.UnistylesShadowRegistry.add(null, [style]);
|
35
|
+
}
|
36
|
+
});
|
37
|
+
return classNames;
|
38
|
+
};
|
39
|
+
|
40
|
+
// @ts-expect-error
|
41
|
+
|
42
|
+
// @ts-expect-error
|
43
|
+
|
44
|
+
const withUnistyles = (Component, mappings) => {
|
45
|
+
return /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
46
|
+
const narrowedProps = props;
|
47
|
+
const styleClassNames = useShadowRegistry(narrowedProps.style);
|
48
|
+
const contentContainerStyleClassNames = useShadowRegistry(narrowedProps.contentContainerStyle);
|
49
|
+
const {
|
50
|
+
mappingsCallback
|
51
|
+
} = (0, _useDependencies.useDependencies)(({
|
52
|
+
dependencies,
|
53
|
+
updateTheme,
|
54
|
+
updateRuntime
|
55
|
+
}) => {
|
56
|
+
const disposeTheme = _listener.UnistylesListener.addListeners(dependencies.filter(dependency => dependency === _NativePlatform.UnistyleDependency.Theme), updateTheme);
|
57
|
+
const disposeRuntime = _listener.UnistylesListener.addListeners(dependencies.filter(dependency => dependency !== _NativePlatform.UnistyleDependency.Theme), updateRuntime);
|
58
|
+
return () => {
|
59
|
+
disposeTheme();
|
60
|
+
disposeRuntime();
|
61
|
+
};
|
62
|
+
});
|
63
|
+
const mappingsProps = mappings ? mappingsCallback(mappings) : {};
|
64
|
+
const unistyleProps = narrowedProps.uniProps ? mappingsCallback(narrowedProps.uniProps) : {};
|
65
|
+
const combinedProps = {
|
66
|
+
...(0, _utils2.deepMergeObjects)(mappingsProps, unistyleProps, props),
|
67
|
+
...(narrowedProps.style ? {
|
68
|
+
style: {
|
69
|
+
$$css: true,
|
70
|
+
'unistyles': styleClassNames.join(' ')
|
71
|
+
}
|
72
|
+
} : {}),
|
73
|
+
...(narrowedProps.contentContainerStyle ? {
|
74
|
+
style: {
|
75
|
+
$$css: true,
|
76
|
+
'unistyles': contentContainerStyleClassNames.join(' ')
|
77
|
+
}
|
78
|
+
} : {})
|
79
|
+
};
|
80
|
+
const NativeComponent = Component;
|
81
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeComponent, {
|
82
|
+
...combinedProps,
|
83
|
+
ref: ref
|
84
|
+
});
|
85
|
+
});
|
86
|
+
};
|
87
|
+
exports.withUnistyles = withUnistyles;
|
88
|
+
//# sourceMappingURL=withUnistyles.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_listener","_web","_utils","_utils2","_useDependencies","_NativePlatform","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","useShadowRegistry","style","ref","useState","document","createElement","oldClassNames","useRef","classNames","useMemo","newClassNames","UnistylesShadowRegistry","add","equal","current","useEffect","withUnistyles","Component","mappings","forwardRef","props","narrowedProps","styleClassNames","contentContainerStyleClassNames","contentContainerStyle","mappingsCallback","useDependencies","dependencies","updateTheme","updateRuntime","disposeTheme","UnistylesListener","addListeners","filter","dependency","UnistyleDependency","Theme","disposeRuntime","mappingsProps","unistyleProps","uniProps","combinedProps","deepMergeObjects","$$css","join","NativeComponent","jsx","exports"],"sourceRoot":"../../../../src","sources":["core/withUnistyles/withUnistyles.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AAEA,IAAAK,gBAAA,GAAAL,OAAA;AACA,IAAAM,eAAA,GAAAN,OAAA;AAA+D,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAQ,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAV,wBAAAU,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MA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aAAa,EAAEnB,KAAK,CAAC;MACxD,IAAGC,aAAa,CAACpB,KAAK,GAAG;QACrBA,KAAK,EAAE;UACH0C,KAAK,EAAE,IAAI;UACX,WAAW,EAAErB,eAAe,CAACsB,IAAI,CAAC,GAAG;QACzC;MACJ,CAAC,GAAG,CAAC,CAAC;MACN,IAAGvB,aAAa,CAACG,qBAAqB,GAAG;QACrCvB,KAAK,EAAE;UACH0C,KAAK,EAAE,IAAI;UACX,WAAW,EAAEpB,+BAA+B,CAACqB,IAAI,CAAC,GAAG;QACzD;MACJ,CAAC,GAAG,CAAC,CAAC;IACV,CAAQ;IAER,MAAMC,eAAe,GAAG5B,SAA0B;IAElD,oBAAO,IAAAtC,WAAA,CAAAmE,GAAA,EAACD,eAAe;MAAA,GAAKJ,aAAa;MAAEvC,GAAG,EAAEA;IAAI,CAAE,CAAC;EAC3D,CAAC,CAAC;AACN,CAAC;AAAA6C,OAAA,CAAA/B,aAAA,GAAAA,aAAA","ignoreList":[]}
|
@@ -0,0 +1,96 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.withUnistyles = void 0;
|
7
|
+
var _react = _interopRequireWildcard(require("react"));
|
8
|
+
var _specs = require("../../specs");
|
9
|
+
var _utils = require("../../utils");
|
10
|
+
var _types = require("./types");
|
11
|
+
var _useDependencies = require("./useDependencies");
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
15
|
+
// @ts-expect-error
|
16
|
+
|
17
|
+
// @ts-expect-error
|
18
|
+
|
19
|
+
const withUnistyles = (Component, mappings) => {
|
20
|
+
return /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
|
21
|
+
const narrowedProps = props;
|
22
|
+
const stylesRef = (0, _react.useRef)({});
|
23
|
+
const isForcedRef = (0, _react.useRef)(false);
|
24
|
+
const NativeComponent = Component;
|
25
|
+
if (!isForcedRef.current) {
|
26
|
+
_types.SUPPORTED_STYLE_PROPS.forEach(propName => {
|
27
|
+
if (narrowedProps?.[propName]) {
|
28
|
+
if (Array.isArray(narrowedProps[propName])) {
|
29
|
+
console.error(`🦄 Unistyles: withUnistyles requires ${propName} to be an object. Please check props for component: ${NativeComponent.displayName}`);
|
30
|
+
}
|
31
|
+
|
32
|
+
// @ts-expect-error - this is hidden from TS
|
33
|
+
if (props[propName].__unistyles_name && !props[propName].__proto__?.getStyle) {
|
34
|
+
console.error(`🦄 Unistyles: withUnistyles received style that is not bound. You likely used the spread operator on a Unistyle style. Please check props for component: ${NativeComponent.displayName}`);
|
35
|
+
}
|
36
|
+
stylesRef.current = {
|
37
|
+
...stylesRef.current,
|
38
|
+
[propName]: narrowedProps[propName]
|
39
|
+
};
|
40
|
+
}
|
41
|
+
});
|
42
|
+
}
|
43
|
+
const {
|
44
|
+
mappingsCallback,
|
45
|
+
addDependencies
|
46
|
+
} = (0, _useDependencies.useDependencies)(({
|
47
|
+
dependencies,
|
48
|
+
updateTheme,
|
49
|
+
updateRuntime
|
50
|
+
}) => {
|
51
|
+
const listensToTheme = dependencies.includes(_specs.UnistyleDependency.Theme);
|
52
|
+
// @ts-expect-error - this is hidden from TS
|
53
|
+
const dispose = _specs.StyleSheet.addChangeListener(changedDependencies => {
|
54
|
+
if (listensToTheme && changedDependencies.includes(_specs.UnistyleDependency.Theme)) {
|
55
|
+
updateTheme();
|
56
|
+
}
|
57
|
+
if (changedDependencies.some(dependency => dependencies.includes(dependency))) {
|
58
|
+
_types.SUPPORTED_STYLE_PROPS.forEach(propName => {
|
59
|
+
if (narrowedProps?.[propName]) {
|
60
|
+
stylesRef.current = {
|
61
|
+
...stylesRef.current,
|
62
|
+
// @ts-expect-error - this is hidden from TS
|
63
|
+
[propName]: props[propName].__proto__?.getStyle?.() || props[propName]
|
64
|
+
};
|
65
|
+
isForcedRef.current = true;
|
66
|
+
}
|
67
|
+
});
|
68
|
+
updateRuntime();
|
69
|
+
}
|
70
|
+
});
|
71
|
+
return () => dispose();
|
72
|
+
});
|
73
|
+
(0, _react.useEffect)(() => {
|
74
|
+
const styleDependencies = narrowedProps.style?.__proto__.uni__dependencies ?? [];
|
75
|
+
const contentContainerStyleDependencies = narrowedProps.contentContainerStyle?.__proto__.uni__dependencies ?? [];
|
76
|
+
addDependencies([...styleDependencies, ...contentContainerStyleDependencies]);
|
77
|
+
}, [narrowedProps.style, narrowedProps.contentContainerStyle]);
|
78
|
+
const mappingProps = mappings ? mappingsCallback(mappings) : {};
|
79
|
+
const unistyleProps = narrowedProps.uniProps ? mappingsCallback(narrowedProps.uniProps) : {};
|
80
|
+
const finalProps = (0, _utils.deepMergeObjects)(mappingProps, unistyleProps, props);
|
81
|
+
|
82
|
+
// override with Unistyles styles
|
83
|
+
_types.SUPPORTED_STYLE_PROPS.forEach(propName => {
|
84
|
+
if (finalProps[propName]) {
|
85
|
+
finalProps[propName] = stylesRef.current[propName];
|
86
|
+
}
|
87
|
+
});
|
88
|
+
isForcedRef.current = false;
|
89
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(NativeComponent, {
|
90
|
+
...finalProps,
|
91
|
+
ref: ref
|
92
|
+
});
|
93
|
+
});
|
94
|
+
};
|
95
|
+
exports.withUnistyles = withUnistyles;
|
96
|
+
//# sourceMappingURL=withUnistyles.native.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_specs","_utils","_types","_useDependencies","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","withUnistyles","Component","mappings","forwardRef","props","ref","narrowedProps","stylesRef","useRef","isForcedRef","NativeComponent","current","SUPPORTED_STYLE_PROPS","forEach","propName","Array","isArray","console","error","displayName","__unistyles_name","getStyle","mappingsCallback","addDependencies","useDependencies","dependencies","updateTheme","updateRuntime","listensToTheme","includes","UnistyleDependency","Theme","dispose","StyleSheet","addChangeListener","changedDependencies","some","dependency","useEffect","styleDependencies","style","uni__dependencies","contentContainerStyleDependencies","contentContainerStyle","mappingProps","unistyleProps","uniProps","finalProps","deepMergeObjects","jsx","exports"],"sourceRoot":"../../../../src","sources":["core/withUnistyles/withUnistyles.native.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAEA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,MAAA,GAAAH,OAAA;AAEA,IAAAI,gBAAA,GAAAJ,OAAA;AAAmD,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAA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EA;IAAI,CAAE,CAAC;EAClE,CAAC,CAAC;AACN,CAAC;AAAA6C,OAAA,CAAAlD,aAAA,GAAAA,aAAA","ignoreList":[]}
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports.useMedia = void 0;
|
7
7
|
var _react = require("react");
|
8
|
-
var _specs = require("../specs");
|
9
8
|
var _mq = require("../mq");
|
10
9
|
const useMedia = config => {
|
11
|
-
const
|
10
|
+
const disposeRef = (0, _react.useRef)(() => {});
|
11
|
+
const [isVisible, setIsVisible] = (0, _react.useState)(() => {
|
12
12
|
const maybeMq = config.mq;
|
13
13
|
if (!(0, _mq.isUnistylesMq)(maybeMq)) {
|
14
14
|
console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`);
|
@@ -20,37 +20,21 @@ const useMedia = config => {
|
|
20
20
|
return false;
|
21
21
|
}
|
22
22
|
const {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
}
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
return true;
|
39
|
-
};
|
40
|
-
const [isVisible, setIsVisible] = (0, _react.useState)(computeIsVisible());
|
41
|
-
(0, _react.useEffect)(() => {
|
42
|
-
setIsVisible(computeIsVisible());
|
43
|
-
}, [config.mq]);
|
44
|
-
(0, _react.useLayoutEffect)(() => {
|
45
|
-
const removeChangeListener = _specs.StyleSheet.addChangeListener(dependencies => {
|
46
|
-
if (dependencies.includes(_specs.UnistyleDependency.Breakpoints)) {
|
47
|
-
setIsVisible(computeIsVisible());
|
48
|
-
}
|
49
|
-
});
|
50
|
-
return () => {
|
51
|
-
removeChangeListener();
|
52
|
-
};
|
53
|
-
}, [config.mq]);
|
23
|
+
minWidth,
|
24
|
+
maxWidth,
|
25
|
+
minHeight,
|
26
|
+
maxHeight
|
27
|
+
} = parsedMq;
|
28
|
+
const mediaQuery = [minWidth !== undefined ? `(min-width: ${minWidth}px)` : undefined, maxWidth !== undefined ? `(max-width: ${maxWidth}px)` : undefined, minHeight !== undefined ? `(min-height: ${minHeight}px)` : undefined, maxHeight !== undefined ? `(max-height: ${maxHeight}px)` : undefined].filter(Boolean).join(' and ');
|
29
|
+
const media = window.matchMedia(mediaQuery);
|
30
|
+
const handler = event => setIsVisible(event.matches);
|
31
|
+
media.addEventListener('change', handler);
|
32
|
+
disposeRef.current = () => media.removeEventListener('change', handler);
|
33
|
+
return media.matches;
|
34
|
+
});
|
35
|
+
|
36
|
+
// Unmount
|
37
|
+
(0, _react.useEffect)(() => () => disposeRef.current(), []);
|
54
38
|
return {
|
55
39
|
isVisible
|
56
40
|
};
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_react","require","
|
1
|
+
{"version":3,"names":["_react","require","_mq","useMedia","config","disposeRef","useRef","isVisible","setIsVisible","useState","maybeMq","mq","isUnistylesMq","console","error","parsedMq","parseMq","isValidMq","minWidth","maxWidth","minHeight","maxHeight","mediaQuery","undefined","filter","Boolean","join","media","window","matchMedia","handler","event","matches","addEventListener","current","removeEventListener","useEffect","exports"],"sourceRoot":"../../../src","sources":["hooks/useMedia.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,GAAA,GAAAD,OAAA;AAEO,MAAME,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,UAAU,GAAG,IAAAC,aAAM,EAAC,MAAM,CAAC,CAAC,CAAC;EACnC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAG,IAAAC,eAAQ,EAAC,MAAM;IAC7C,MAAMC,OAAO,GAAGN,MAAM,CAACO,EAAuB;IAE9C,IAAI,CAAC,IAAAC,iBAAa,EAACF,OAAO,CAAC,EAAE;MACzBG,OAAO,CAACC,KAAK,CAAC,sCAAsCJ,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMK,QAAQ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+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.useMedia = void 0;
|
7
|
+
var _react = require("react");
|
8
|
+
var _specs = require("../specs");
|
9
|
+
var _mq = require("../mq");
|
10
|
+
const useMedia = config => {
|
11
|
+
const computeIsVisible = () => {
|
12
|
+
const maybeMq = config.mq;
|
13
|
+
if (!(0, _mq.isUnistylesMq)(maybeMq)) {
|
14
|
+
console.error(`🦄 Unistyles: Received invalid mq: ${maybeMq}`);
|
15
|
+
return false;
|
16
|
+
}
|
17
|
+
const parsedMq = (0, _mq.parseMq)(maybeMq);
|
18
|
+
if (!(0, _mq.isValidMq)(parsedMq)) {
|
19
|
+
console.error(`🦄 Unistyles: Received invalid mq where min is greater than max: ${maybeMq}`);
|
20
|
+
return false;
|
21
|
+
}
|
22
|
+
const {
|
23
|
+
width,
|
24
|
+
height
|
25
|
+
} = _specs.UnistylesRuntime.screen;
|
26
|
+
if (parsedMq.minWidth !== undefined && width < parsedMq.minWidth) {
|
27
|
+
return false;
|
28
|
+
}
|
29
|
+
if (parsedMq.maxWidth !== undefined && width > parsedMq.maxWidth) {
|
30
|
+
return false;
|
31
|
+
}
|
32
|
+
if (parsedMq.minHeight !== undefined && height < parsedMq.minHeight) {
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
if (parsedMq.maxHeight !== undefined && height > parsedMq.maxHeight) {
|
36
|
+
return false;
|
37
|
+
}
|
38
|
+
return true;
|
39
|
+
};
|
40
|
+
const [isVisible, setIsVisible] = (0, _react.useState)(computeIsVisible());
|
41
|
+
(0, _react.useEffect)(() => {
|
42
|
+
setIsVisible(computeIsVisible());
|
43
|
+
}, [config.mq]);
|
44
|
+
(0, _react.useLayoutEffect)(() => {
|
45
|
+
// @ts-expect-error - this is hidden from TS
|
46
|
+
const removeChangeListener = _specs.StyleSheet.addChangeListener(dependencies => {
|
47
|
+
if (dependencies.includes(_specs.UnistyleDependency.Breakpoints)) {
|
48
|
+
setIsVisible(computeIsVisible());
|
49
|
+
}
|
50
|
+
});
|
51
|
+
return () => {
|
52
|
+
removeChangeListener();
|
53
|
+
};
|
54
|
+
}, [config.mq]);
|
55
|
+
return {
|
56
|
+
isVisible
|
57
|
+
};
|
58
|
+
};
|
59
|
+
exports.useMedia = useMedia;
|
60
|
+
//# sourceMappingURL=useMedia.native.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"names":["_react","require","_specs","_mq","useMedia","config","computeIsVisible","maybeMq","mq","isUnistylesMq","console","error","parsedMq","parseMq","isValidMq","width","height","UnistylesRuntime","screen","minWidth","undefined","maxWidth","minHeight","maxHeight","isVisible","setIsVisible","useState","useEffect","useLayoutEffect","removeChangeListener","StyleSheet","addChangeListener","dependencies","includes","UnistyleDependency","Breakpoints","exports"],"sourceRoot":"../../../src","sources":["hooks/useMedia.native.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,GAAA,GAAAF,OAAA;AAEO,MAAMG,QAAQ,GAAIC,MAAsB,IAAK;EAChD,MAAMC,gBAAgB,GAAGA,CAAA,KAAe;IACpC,MAAMC,OAAO,GAAGF,MAAM,CAACG,EAAuB;IAE9C,IAAI,CAAC,IAAAC,iBAAa,EAACF,OAAO,CAAC,EAAE;MACzBG,OAAO,CAACC,KAAK,CAAC,sCAAsCJ,OAAO,EAAE,CAAC;MAE9D,OAAO,KAAK;IAChB;IAEA,MAAMK,QAAQ,GAAG,IAAAC,WAAO,EAACN,OAAO,CAAC;IAEjC,IAAI,CAAC,IAAAO,aAAS,EAACF,QAAQ,CAAC,EAAE;MACtBF,OAAO,CAACC,KAAK,CAAC,oEAAoEJ,OAAO,EAAE,CAAC;MAE5F,OAAO,KAAK;IAChB;IAEA,MAAM;MAAEQ,KAAK;MAAEC;IAAO,CAAC,GAAGC,uBAAgB,CAACC,MAAM;IAEjD,IAAIN,QAAQ,CAACO,QAAQ,KAAKC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
6
|
var _exportNames = {
|
7
7
|
mq: true,
|
8
8
|
createUnistylesComponent: true,
|
9
|
-
|
9
|
+
withUnistyles: true,
|
10
|
+
Display: true,
|
11
|
+
Hide: true,
|
12
|
+
Variants: true,
|
13
|
+
ScopedTheme: true
|
10
14
|
};
|
11
|
-
Object.defineProperty(exports, "
|
15
|
+
Object.defineProperty(exports, "Display", {
|
12
16
|
enumerable: true,
|
13
17
|
get: function () {
|
14
|
-
return
|
18
|
+
return _components.Display;
|
19
|
+
}
|
20
|
+
});
|
21
|
+
Object.defineProperty(exports, "Hide", {
|
22
|
+
enumerable: true,
|
23
|
+
get: function () {
|
24
|
+
return _components.Hide;
|
25
|
+
}
|
26
|
+
});
|
27
|
+
Object.defineProperty(exports, "ScopedTheme", {
|
28
|
+
enumerable: true,
|
29
|
+
get: function () {
|
30
|
+
return _components.ScopedTheme;
|
31
|
+
}
|
32
|
+
});
|
33
|
+
Object.defineProperty(exports, "Variants", {
|
34
|
+
enumerable: true,
|
35
|
+
get: function () {
|
36
|
+
return _components.Variants;
|
15
37
|
}
|
16
38
|
});
|
17
|
-
Object.defineProperty(exports, "
|
39
|
+
Object.defineProperty(exports, "createUnistylesComponent", {
|
18
40
|
enumerable: true,
|
19
41
|
get: function () {
|
20
|
-
return _core.
|
42
|
+
return _core.createUnistylesComponent;
|
21
43
|
}
|
22
44
|
});
|
23
45
|
Object.defineProperty(exports, "mq", {
|
@@ -26,6 +48,12 @@ Object.defineProperty(exports, "mq", {
|
|
26
48
|
return _mq.mq;
|
27
49
|
}
|
28
50
|
});
|
51
|
+
Object.defineProperty(exports, "withUnistyles", {
|
52
|
+
enumerable: true,
|
53
|
+
get: function () {
|
54
|
+
return _core.withUnistyles;
|
55
|
+
}
|
56
|
+
});
|
29
57
|
var _specs = require("./specs");
|
30
58
|
Object.keys(_specs).forEach(function (key) {
|
31
59
|
if (key === "default" || key === "__esModule") return;
|
@@ -41,15 +69,4 @@ Object.keys(_specs).forEach(function (key) {
|
|
41
69
|
var _mq = require("./mq");
|
42
70
|
var _core = require("./core");
|
43
71
|
var _components = require("./components");
|
44
|
-
Object.keys(_components).forEach(function (key) {
|
45
|
-
if (key === "default" || key === "__esModule") return;
|
46
|
-
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
47
|
-
if (key in exports && exports[key] === _components[key]) return;
|
48
|
-
Object.defineProperty(exports, key, {
|
49
|
-
enumerable: true,
|
50
|
-
get: function () {
|
51
|
-
return _components[key];
|
52
|
-
}
|
53
|
-
});
|
54
|
-
});
|
55
72
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_specs","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_core","_components"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":"
|
1
|
+
{"version":3,"names":["_specs","require","Object","keys","forEach","key","prototype","hasOwnProperty","call","_exportNames","exports","defineProperty","enumerable","get","_mq","_core","_components"],"sourceRoot":"../../src","sources":["index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAAAC,MAAA,CAAAC,IAAA,CAAAH,MAAA,EAAAI,OAAA,WAAAC,GAAA;EAAA,IAAAA,GAAA,kBAAAA,GAAA;EAAA,IAAAH,MAAA,CAAAI,SAAA,CAAAC,cAAA,CAAAC,IAAA,CAAAC,YAAA,EAAAJ,GAAA;EAAA,IAAAA,GAAA,IAAAK,OAAA,IAAAA,OAAA,CAAAL,GAAA,MAAAL,MAAA,CAAAK,GAAA;EAAAH,MAAA,CAAAS,cAAA,CAAAD,OAAA,EAAAL,GAAA;IAAAO,UAAA;IAAAC,GAAA,WAAAA,CAAA;MAAA,OAAAb,MAAA,CAAAK,GAAA;IAAA;EAAA;AAAA;AACA,IAAAS,GAAA,GAAAb,OAAA;AAEA,IAAAc,KAAA,GAAAd,OAAA;AAEA,IAAAe,WAAA,GAAAf,OAAA","ignoreList":[]}
|
@@ -7,13 +7,13 @@ exports.UnistylesShadowRegistry = void 0;
|
|
7
7
|
var _reactNativeNitroModules = require("react-native-nitro-modules");
|
8
8
|
const HybridShadowRegistry = _reactNativeNitroModules.NitroModules.createHybridObject('UnistylesShadowRegistry');
|
9
9
|
const findShadowNodeForHandle = handle => {
|
10
|
-
const node = handle?.__internalInstanceHandle?.stateNode?.node ?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node;
|
10
|
+
const node = handle?.__internalInstanceHandle?.stateNode?.node ?? handle?.getScrollResponder?.()?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ?? handle?.getNativeScrollRef?.()?.__internalInstanceHandle?.stateNode?.node ?? handle?._viewRef?.__internalInstanceHandle?.stateNode?.node ?? handle?.viewRef?.current?.__internalInstanceHandle?.stateNode?.node ?? handle?._nativeRef?.__internalInstanceHandle?.stateNode?.node;
|
11
11
|
if (!node) {
|
12
12
|
throw new Error(`Unistyles: Could not find shadow node for one of your components of type ${handle?.__internalInstanceHandle?.elementType ?? 'unknown'}`);
|
13
13
|
}
|
14
14
|
return node;
|
15
15
|
};
|
16
|
-
HybridShadowRegistry.add = (handle, styles
|
16
|
+
HybridShadowRegistry.add = (handle, styles) => {
|
17
17
|
// virtualized nodes can be null
|
18
18
|
if (!handle || !styles || !Array.isArray(styles)) {
|
19
19
|
return;
|
@@ -21,7 +21,7 @@ HybridShadowRegistry.add = (handle, styles, variants, args, id) => {
|
|
21
21
|
|
22
22
|
// filter Reanimated styles and styles that are undefined
|
23
23
|
const filteredStyles = styles.filter(style => !style?.initial?.updater).filter(Boolean);
|
24
|
-
HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles
|
24
|
+
HybridShadowRegistry.link(findShadowNodeForHandle(handle), filteredStyles);
|
25
25
|
};
|
26
26
|
HybridShadowRegistry.remove = handle => {
|
27
27
|
if (!handle) {
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","
|
1
|
+
{"version":3,"names":["_reactNativeNitroModules","require","HybridShadowRegistry","NitroModules","createHybridObject","findShadowNodeForHandle","handle","node","__internalInstanceHandle","stateNode","getScrollResponder","getNativeScrollRef","_viewRef","viewRef","current","_nativeRef","Error","elementType","add","styles","Array","isArray","filteredStyles","filter","style","initial","updater","Boolean","link","remove","unlink","UnistylesShadowRegistry","exports"],"sourceRoot":"../../../../src","sources":["specs/ShadowRegistry/index.ts"],"mappings":";;;;;;AAAA,IAAAA,wBAAA,GAAAC,OAAA;AAmBA,MAAMC,oBAAoB,GAAGC,qCAAY,CAACC,kBAAkB,CAAiB,yBAAyB,CAAC;AAEvG,MAAMC,uBAAuB,GAAIC,MAAkB,IAAK;EACpD,MAAMC,IAAI,GAAGD,MAAM,EAAEE,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACvDD,MAAM,EAAEI,kBAAkB,GAAG,CAAC,EAAEC,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACjGD,MAAM,EAAEK,kBAAkB,GAAG,CAAC,EAAEH,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACzED,MAAM,EAAEM,QAAQ,EAAEJ,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IAC3DD,MAAM,EAAEO,OAAO,EAAEC,OAAO,EAAEN,wBAAwB,EAAEC,SAAS,EAAEF,IAAI,IACnED,MAAM,EAAES,UAAU,EAAEP,wBAAwB,EAAEC,SAAS,EAAEF,IAAI;EAEpE,IAAI,CAACA,IAAI,EAAE;IACP,MAAM,IAAIS,KAAK,CAAC,4EAA4EV,MAAM,EAAEE,wBAAwB,EAAES,WAAW,IAAI,SAAS,EAAE,CAAC;EAC7J;EAEA,OAAOV,IAAI;AACf,CAAC;AAEDL,oBAAoB,CAACgB,GAAG,GAAG,CAACZ,MAAM,EAAEa,MAAM,KAAK;EAC3C;EACA,IAAI,CAACb,MAAM,IAAI,CAACa,MAAM,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,MAAM,CAAC,EAAE;IAC9C;EACJ;;EAEA;EACA,MAAMG,cAAc,GAAGH,MAAM,CACxBI,MAAM,CAACC,KAAK,IAAI,CAACA,KAAK,EAAEC,OAAO,EAAEC,OAAO,CAAC,CACzCH,MAAM,CAACI,OAAO,CAAC;EAEpBzB,oBAAoB,CAAC0B,IAAI,CAACvB,uBAAuB,CAACC,MAAM,CAAC,EAAEgB,cAAc,CAAC;AAC9E,CAAC;AAEDpB,oBAAoB,CAAC2B,MAAM,GAAGvB,MAAM,IAAI;EACpC,IAAI,CAACA,MAAM,EAAE;IACT;EACJ;EAEAJ,oBAAoB,CAAC4B,MAAM,CAACzB,uBAAuB,CAACC,MAAM,CAAC,CAAC;AAChE,CAAC;AAQM,MAAMyB,uBAAuB,GAAAC,OAAA,CAAAD,uBAAA,GAAG7B,oBAA4D","ignoreList":[]}
|
@@ -3,52 +3,26 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
return _types.ColorScheme;
|
10
|
-
}
|
11
|
-
});
|
12
|
-
Object.defineProperty(exports, "Orientation", {
|
13
|
-
enumerable: true,
|
14
|
-
get: function () {
|
15
|
-
return _types.Orientation;
|
16
|
-
}
|
17
|
-
});
|
18
|
-
Object.defineProperty(exports, "StatusBarStyle", {
|
19
|
-
enumerable: true,
|
20
|
-
get: function () {
|
21
|
-
return _types.StatusBarStyle;
|
22
|
-
}
|
23
|
-
});
|
24
|
-
Object.defineProperty(exports, "StyleSheet", {
|
25
|
-
enumerable: true,
|
26
|
-
get: function () {
|
27
|
-
return _StyleSheet.StyleSheet;
|
28
|
-
}
|
29
|
-
});
|
6
|
+
var _exportNames = {
|
7
|
+
UnistyleDependency: true
|
8
|
+
};
|
30
9
|
Object.defineProperty(exports, "UnistyleDependency", {
|
31
10
|
enumerable: true,
|
32
11
|
get: function () {
|
33
12
|
return _NativePlatform.UnistyleDependency;
|
34
13
|
}
|
35
14
|
});
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
}
|
15
|
+
var _web = require("../web");
|
16
|
+
Object.keys(_web).forEach(function (key) {
|
17
|
+
if (key === "default" || key === "__esModule") return;
|
18
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
19
|
+
if (key in exports && exports[key] === _web[key]) return;
|
20
|
+
Object.defineProperty(exports, key, {
|
21
|
+
enumerable: true,
|
22
|
+
get: function () {
|
23
|
+
return _web[key];
|
24
|
+
}
|
25
|
+
});
|
47
26
|
});
|
48
|
-
require("./TurboUnistyles");
|
49
|
-
var _UnistylesRuntime = require("./UnistylesRuntime");
|
50
|
-
var _StyleSheet = require("./StyleSheet");
|
51
|
-
var _ShadowRegistry = require("./ShadowRegistry");
|
52
|
-
var _types = require("./types");
|
53
27
|
var _NativePlatform = require("./NativePlatform");
|
54
28
|
//# sourceMappingURL=index.js.map
|