@niibase/uniwind 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -0
- package/dist/common/components/index.js +314 -0
- package/dist/common/components/native/ActivityIndicator.js +21 -0
- package/dist/common/components/native/Button.js +18 -0
- package/dist/common/components/native/FlatList.js +30 -0
- package/dist/common/components/native/Image.js +21 -0
- package/dist/common/components/native/ImageBackground.js +23 -0
- package/dist/common/components/native/InputAccessoryView.js +21 -0
- package/dist/common/components/native/KeyboardAvoidingView.js +20 -0
- package/dist/common/components/native/Modal.js +21 -0
- package/dist/common/components/native/Pressable.js +29 -0
- package/dist/common/components/native/RefreshControl.js +27 -0
- package/dist/common/components/native/SafeAreaView.js +18 -0
- package/dist/common/components/native/ScrollView.js +23 -0
- package/dist/common/components/native/SectionList.js +27 -0
- package/dist/common/components/native/Switch.js +32 -0
- package/dist/common/components/native/Text.js +36 -0
- package/dist/common/components/native/TextInput.js +53 -0
- package/dist/common/components/native/TouchableHighlight.js +35 -0
- package/dist/common/components/native/TouchableNativeFeedback.js +32 -0
- package/dist/common/components/native/TouchableOpacity.js +32 -0
- package/dist/common/components/native/TouchableWithoutFeedback.js +32 -0
- package/dist/common/components/native/View.js +18 -0
- package/dist/common/components/native/VirtualizedList.js +27 -0
- package/dist/common/components/native/useStyle.js +29 -0
- package/dist/common/components/utils.js +18 -0
- package/dist/common/components/web/ActivityIndicator.js +20 -0
- package/dist/common/components/web/Button.js +18 -0
- package/dist/common/components/web/FlatList.js +22 -0
- package/dist/common/components/web/Image.js +20 -0
- package/dist/common/components/web/ImageBackground.js +21 -0
- package/dist/common/components/web/KeyboardAvoidingView.js +18 -0
- package/dist/common/components/web/Modal.js +17 -0
- package/dist/common/components/web/Pressable.js +17 -0
- package/dist/common/components/web/RefreshControl.js +17 -0
- package/dist/common/components/web/SafeAreaView.js +17 -0
- package/dist/common/components/web/ScrollView.js +18 -0
- package/dist/common/components/web/SectionList.js +20 -0
- package/dist/common/components/web/Switch.js +26 -0
- package/dist/common/components/web/Text.js +17 -0
- package/dist/common/components/web/TextInput.js +17 -0
- package/dist/common/components/web/TouchableHighlight.js +20 -0
- package/dist/common/components/web/TouchableNativeFeedback.js +13 -0
- package/dist/common/components/web/TouchableOpacity.js +17 -0
- package/dist/common/components/web/TouchableWithoutFeedback.js +17 -0
- package/dist/common/components/web/View.js +17 -0
- package/dist/common/components/web/VirtualizedList.js +20 -0
- package/dist/common/components/web/index.js +187 -0
- package/dist/common/components/web/metro-injected.js +1 -0
- package/dist/common/components/web/rnw.js +42 -0
- package/dist/common/core/config/config.common.js +80 -0
- package/dist/common/core/config/config.js +51 -0
- package/dist/common/core/config/config.native.js +67 -0
- package/dist/common/core/config/index.js +16 -0
- package/dist/common/core/index.js +16 -0
- package/dist/common/core/listener.js +51 -0
- package/dist/common/core/logger.js +18 -0
- package/dist/common/core/native/index.js +27 -0
- package/dist/common/core/native/native-utils.js +36 -0
- package/dist/common/core/native/parsers/boxShadow.js +10 -0
- package/dist/common/core/native/parsers/fontVariant.js +8 -0
- package/dist/common/core/native/parsers/gradient.js +31 -0
- package/dist/common/core/native/parsers/index.js +60 -0
- package/dist/common/core/native/parsers/textShadow.js +39 -0
- package/dist/common/core/native/parsers/transforms.js +44 -0
- package/dist/common/core/native/runtime.js +34 -0
- package/dist/common/core/native/store.js +181 -0
- package/dist/common/core/types.js +1 -0
- package/dist/common/core/web/cssListener.js +146 -0
- package/dist/common/core/web/formatColor.js +15 -0
- package/dist/common/core/web/getWebStyles.js +51 -0
- package/dist/common/core/web/index.js +49 -0
- package/dist/common/core/web/parseCSSValue.js +15 -0
- package/dist/common/css/index.js +26 -0
- package/dist/common/css/insets.js +64 -0
- package/dist/common/css/processFunctions.js +54 -0
- package/dist/common/css/themes.js +95 -0
- package/dist/common/css/variants.js +16 -0
- package/dist/common/hoc/index.js +16 -0
- package/dist/common/hoc/types.js +1 -0
- package/dist/common/hoc/withUniwind.js +95 -0
- package/dist/common/hoc/withUniwind.native.js +106 -0
- package/dist/common/hoc/withUniwindUtils.js +16 -0
- package/dist/common/hooks/index.js +49 -0
- package/dist/common/hooks/useCSSVariable/getVariableValue.js +19 -0
- package/dist/common/hooks/useCSSVariable/getVariableValue.native.js +9 -0
- package/dist/common/hooks/useCSSVariable/index.js +16 -0
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +58 -0
- package/dist/common/hooks/useResolveClassNames.js +22 -0
- package/dist/common/hooks/useResolveClassNames.native.js +29 -0
- package/dist/common/hooks/useUniwind.js +28 -0
- package/dist/common/hooks/useUniwindAccent.js +13 -0
- package/dist/common/hooks/useUniwindAccent.native.js +12 -0
- package/dist/common/index.js +38 -0
- package/dist/common/types.js +28 -0
- package/dist/common/utils/buildDtsFile.js +18 -0
- package/dist/common/utils/stringifyThemes.js +8 -0
- package/dist/common/vite/index.d.ts +9 -0
- package/dist/common/vite/index.js +16 -0
- package/dist/common/vite/vite.js +72 -0
- package/dist/metro/index.cjs +166 -0
- package/dist/metro/index.d.ts +15 -0
- package/dist/metro/index.mjs +158 -0
- package/dist/metro/metro-transformer.cjs +1565 -0
- package/dist/metro/metro-transformer.mjs +1558 -0
- package/dist/module/components/index.d.ts +0 -0
- package/dist/module/components/index.js +312 -0
- package/dist/module/components/native/ActivityIndicator.d.ts +3 -0
- package/dist/module/components/native/ActivityIndicator.js +18 -0
- package/dist/module/components/native/Button.d.ts +3 -0
- package/dist/module/components/native/Button.js +15 -0
- package/dist/module/components/native/FlatList.d.ts +3 -0
- package/dist/module/components/native/FlatList.js +27 -0
- package/dist/module/components/native/Image.d.ts +3 -0
- package/dist/module/components/native/Image.js +18 -0
- package/dist/module/components/native/ImageBackground.d.ts +3 -0
- package/dist/module/components/native/ImageBackground.js +20 -0
- package/dist/module/components/native/InputAccessoryView.d.ts +3 -0
- package/dist/module/components/native/InputAccessoryView.js +21 -0
- package/dist/module/components/native/KeyboardAvoidingView.d.ts +3 -0
- package/dist/module/components/native/KeyboardAvoidingView.js +17 -0
- package/dist/module/components/native/Modal.d.ts +3 -0
- package/dist/module/components/native/Modal.js +18 -0
- package/dist/module/components/native/Pressable.d.ts +3 -0
- package/dist/module/components/native/Pressable.js +29 -0
- package/dist/module/components/native/RefreshControl.d.ts +3 -0
- package/dist/module/components/native/RefreshControl.js +24 -0
- package/dist/module/components/native/SafeAreaView.d.ts +3 -0
- package/dist/module/components/native/SafeAreaView.js +15 -0
- package/dist/module/components/native/ScrollView.d.ts +3 -0
- package/dist/module/components/native/ScrollView.js +20 -0
- package/dist/module/components/native/SectionList.d.ts +3 -0
- package/dist/module/components/native/SectionList.js +24 -0
- package/dist/module/components/native/Switch.d.ts +3 -0
- package/dist/module/components/native/Switch.js +26 -0
- package/dist/module/components/native/Text.d.ts +3 -0
- package/dist/module/components/native/Text.js +33 -0
- package/dist/module/components/native/TextInput.d.ts +3 -0
- package/dist/module/components/native/TextInput.js +50 -0
- package/dist/module/components/native/TouchableHighlight.d.ts +3 -0
- package/dist/module/components/native/TouchableHighlight.js +32 -0
- package/dist/module/components/native/TouchableNativeFeedback.d.ts +3 -0
- package/dist/module/components/native/TouchableNativeFeedback.js +29 -0
- package/dist/module/components/native/TouchableOpacity.d.ts +3 -0
- package/dist/module/components/native/TouchableOpacity.js +29 -0
- package/dist/module/components/native/TouchableWithoutFeedback.d.ts +3 -0
- package/dist/module/components/native/TouchableWithoutFeedback.js +29 -0
- package/dist/module/components/native/View.d.ts +3 -0
- package/dist/module/components/native/View.js +15 -0
- package/dist/module/components/native/VirtualizedList.d.ts +3 -0
- package/dist/module/components/native/VirtualizedList.js +24 -0
- package/dist/module/components/native/useStyle.d.ts +2 -0
- package/dist/module/components/native/useStyle.js +22 -0
- package/dist/module/components/utils.d.ts +1 -0
- package/dist/module/components/utils.js +11 -0
- package/dist/module/components/web/ActivityIndicator.d.ts +3 -0
- package/dist/module/components/web/ActivityIndicator.js +17 -0
- package/dist/module/components/web/Button.d.ts +3 -0
- package/dist/module/components/web/Button.js +15 -0
- package/dist/module/components/web/FlatList.d.ts +3 -0
- package/dist/module/components/web/FlatList.js +19 -0
- package/dist/module/components/web/Image.d.ts +3 -0
- package/dist/module/components/web/Image.js +17 -0
- package/dist/module/components/web/ImageBackground.d.ts +3 -0
- package/dist/module/components/web/ImageBackground.js +18 -0
- package/dist/module/components/web/KeyboardAvoidingView.d.ts +3 -0
- package/dist/module/components/web/KeyboardAvoidingView.js +15 -0
- package/dist/module/components/web/Modal.d.ts +3 -0
- package/dist/module/components/web/Modal.js +14 -0
- package/dist/module/components/web/Pressable.d.ts +3 -0
- package/dist/module/components/web/Pressable.js +14 -0
- package/dist/module/components/web/RefreshControl.d.ts +3 -0
- package/dist/module/components/web/RefreshControl.js +14 -0
- package/dist/module/components/web/SafeAreaView.d.ts +3 -0
- package/dist/module/components/web/SafeAreaView.js +14 -0
- package/dist/module/components/web/ScrollView.d.ts +3 -0
- package/dist/module/components/web/ScrollView.js +15 -0
- package/dist/module/components/web/SectionList.d.ts +3 -0
- package/dist/module/components/web/SectionList.js +17 -0
- package/dist/module/components/web/Switch.d.ts +3 -0
- package/dist/module/components/web/Switch.js +20 -0
- package/dist/module/components/web/Text.d.ts +3 -0
- package/dist/module/components/web/Text.js +14 -0
- package/dist/module/components/web/TextInput.d.ts +3 -0
- package/dist/module/components/web/TextInput.js +14 -0
- package/dist/module/components/web/TouchableHighlight.d.ts +3 -0
- package/dist/module/components/web/TouchableHighlight.js +17 -0
- package/dist/module/components/web/TouchableNativeFeedback.d.ts +2 -0
- package/dist/module/components/web/TouchableNativeFeedback.js +2 -0
- package/dist/module/components/web/TouchableOpacity.d.ts +3 -0
- package/dist/module/components/web/TouchableOpacity.js +14 -0
- package/dist/module/components/web/TouchableWithoutFeedback.d.ts +3 -0
- package/dist/module/components/web/TouchableWithoutFeedback.js +14 -0
- package/dist/module/components/web/View.d.ts +3 -0
- package/dist/module/components/web/View.js +14 -0
- package/dist/module/components/web/VirtualizedList.d.ts +3 -0
- package/dist/module/components/web/VirtualizedList.js +17 -0
- package/dist/module/components/web/index.d.ts +22 -0
- package/dist/module/components/web/index.js +22 -0
- package/dist/module/components/web/metro-injected.d.ts +0 -0
- package/dist/module/components/web/metro-injected.js +0 -0
- package/dist/module/components/web/rnw.d.ts +2 -0
- package/dist/module/components/web/rnw.js +35 -0
- package/dist/module/core/config/config.common.d.ts +18 -0
- package/dist/module/core/config/config.common.js +74 -0
- package/dist/module/core/config/config.d.ts +11 -0
- package/dist/module/core/config/config.js +48 -0
- package/dist/module/core/config/config.native.d.ts +12 -0
- package/dist/module/core/config/config.native.js +61 -0
- package/dist/module/core/config/index.d.ts +1 -0
- package/dist/module/core/config/index.js +1 -0
- package/dist/module/core/index.d.ts +1 -0
- package/dist/module/core/index.js +1 -0
- package/dist/module/core/listener.d.ts +12 -0
- package/dist/module/core/listener.js +45 -0
- package/dist/module/core/logger.d.ts +5 -0
- package/dist/module/core/logger.js +11 -0
- package/dist/module/core/native/index.d.ts +2 -0
- package/dist/module/core/native/index.js +2 -0
- package/dist/module/core/native/native-utils.d.ts +4 -0
- package/dist/module/core/native/native-utils.js +27 -0
- package/dist/module/core/native/parsers/boxShadow.d.ts +1 -0
- package/dist/module/core/native/parsers/boxShadow.js +3 -0
- package/dist/module/core/native/parsers/fontVariant.d.ts +1 -0
- package/dist/module/core/native/parsers/fontVariant.js +1 -0
- package/dist/module/core/native/parsers/gradient.d.ts +8 -0
- package/dist/module/core/native/parsers/gradient.js +26 -0
- package/dist/module/core/native/parsers/index.d.ts +5 -0
- package/dist/module/core/native/parsers/index.js +5 -0
- package/dist/module/core/native/parsers/textShadow.d.ts +1 -0
- package/dist/module/core/native/parsers/textShadow.js +32 -0
- package/dist/module/core/native/parsers/transforms.d.ts +1 -0
- package/dist/module/core/native/parsers/transforms.js +48 -0
- package/dist/module/core/native/runtime.d.ts +2 -0
- package/dist/module/core/native/runtime.js +28 -0
- package/dist/module/core/native/store.d.ts +19 -0
- package/dist/module/core/native/store.js +172 -0
- package/dist/module/core/types.d.ts +73 -0
- package/dist/module/core/types.js +0 -0
- package/dist/module/core/web/cssListener.d.ts +19 -0
- package/dist/module/core/web/cssListener.js +137 -0
- package/dist/module/core/web/formatColor.d.ts +1 -0
- package/dist/module/core/web/formatColor.js +8 -0
- package/dist/module/core/web/getWebStyles.d.ts +2 -0
- package/dist/module/core/web/getWebStyles.js +49 -0
- package/dist/module/core/web/index.d.ts +4 -0
- package/dist/module/core/web/index.js +4 -0
- package/dist/module/core/web/parseCSSValue.d.ts +1 -0
- package/dist/module/core/web/parseCSSValue.js +8 -0
- package/dist/module/css/index.d.ts +1 -0
- package/dist/module/css/index.js +25 -0
- package/dist/module/css/insets.d.ts +1 -0
- package/dist/module/css/insets.js +63 -0
- package/dist/module/css/processFunctions.d.ts +2 -0
- package/dist/module/css/processFunctions.js +36 -0
- package/dist/module/css/themes.d.ts +1 -0
- package/dist/module/css/themes.js +97 -0
- package/dist/module/css/variants.d.ts +1 -0
- package/dist/module/css/variants.js +9 -0
- package/dist/module/hoc/index.d.ts +1 -0
- package/dist/module/hoc/index.js +1 -0
- package/dist/module/hoc/types.d.ts +27 -0
- package/dist/module/hoc/types.js +0 -0
- package/dist/module/hoc/withUniwind.d.ts +2 -0
- package/dist/module/hoc/withUniwind.js +76 -0
- package/dist/module/hoc/withUniwind.native.d.ts +2 -0
- package/dist/module/hoc/withUniwind.native.js +81 -0
- package/dist/module/hoc/withUniwindUtils.d.ts +5 -0
- package/dist/module/hoc/withUniwindUtils.js +5 -0
- package/dist/module/hooks/index.d.ts +4 -0
- package/dist/module/hooks/index.js +4 -0
- package/dist/module/hooks/useCSSVariable/getVariableValue.d.ts +1 -0
- package/dist/module/hooks/useCSSVariable/getVariableValue.js +12 -0
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -0
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.js +2 -0
- package/dist/module/hooks/useCSSVariable/index.d.ts +1 -0
- package/dist/module/hooks/useCSSVariable/index.js +1 -0
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +13 -0
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +56 -0
- package/dist/module/hooks/useResolveClassNames.d.ts +2 -0
- package/dist/module/hooks/useResolveClassNames.js +18 -0
- package/dist/module/hooks/useResolveClassNames.native.d.ts +2 -0
- package/dist/module/hooks/useResolveClassNames.native.js +22 -0
- package/dist/module/hooks/useUniwind.d.ts +5 -0
- package/dist/module/hooks/useUniwind.js +21 -0
- package/dist/module/hooks/useUniwindAccent.d.ts +1 -0
- package/dist/module/hooks/useUniwindAccent.js +6 -0
- package/dist/module/hooks/useUniwindAccent.native.d.ts +2 -0
- package/dist/module/hooks/useUniwindAccent.native.js +5 -0
- package/dist/module/index.d.ts +5 -0
- package/dist/module/index.js +3 -0
- package/dist/module/types.d.ts +21 -0
- package/dist/module/types.js +22 -0
- package/dist/module/utils/buildDtsFile.d.ts +1 -0
- package/dist/module/utils/buildDtsFile.js +22 -0
- package/dist/module/utils/stringifyThemes.d.ts +1 -0
- package/dist/module/utils/stringifyThemes.js +1 -0
- package/dist/module/vite/index.d.ts +9 -0
- package/dist/module/vite/index.js +1 -0
- package/dist/module/vite/vite.d.ts +8 -0
- package/dist/module/vite/vite.js +73 -0
- package/dist/shared/uniwind.BZIuaszw.cjs +11 -0
- package/dist/shared/uniwind.BgZDHdUR.cjs +81 -0
- package/dist/shared/uniwind.Bt3kqZo6.mjs +290 -0
- package/dist/shared/uniwind.CyoRUwOj.mjs +9 -0
- package/dist/shared/uniwind.D3fvrgEG.mjs +68 -0
- package/dist/shared/uniwind.D_6s2EM-.cjs +301 -0
- package/dist/vite/index.cjs +80 -0
- package/dist/vite/index.d.ts +9 -0
- package/dist/vite/index.mjs +74 -0
- package/metro/package.json +3 -0
- package/package.json +106 -0
- package/readme.md +71 -0
- package/src/components/index.ts +313 -0
- package/src/components/native/ActivityIndicator.tsx +19 -0
- package/src/components/native/Button.tsx +16 -0
- package/src/components/native/FlatList.tsx +28 -0
- package/src/components/native/Image.tsx +19 -0
- package/src/components/native/ImageBackground.tsx +21 -0
- package/src/components/native/InputAccessoryView.tsx +23 -0
- package/src/components/native/KeyboardAvoidingView.tsx +18 -0
- package/src/components/native/Modal.tsx +19 -0
- package/src/components/native/Pressable.tsx +31 -0
- package/src/components/native/RefreshControl.tsx +25 -0
- package/src/components/native/SafeAreaView.tsx +16 -0
- package/src/components/native/ScrollView.tsx +21 -0
- package/src/components/native/SectionList.tsx +25 -0
- package/src/components/native/Switch.tsx +28 -0
- package/src/components/native/Text.tsx +39 -0
- package/src/components/native/TextInput.tsx +52 -0
- package/src/components/native/TouchableHighlight.tsx +34 -0
- package/src/components/native/TouchableNativeFeedback.tsx +31 -0
- package/src/components/native/TouchableOpacity.tsx +31 -0
- package/src/components/native/TouchableWithoutFeedback.tsx +31 -0
- package/src/components/native/View.tsx +16 -0
- package/src/components/native/VirtualizedList.tsx +25 -0
- package/src/components/native/useStyle.ts +33 -0
- package/src/components/utils.ts +16 -0
- package/src/components/web/ActivityIndicator.tsx +18 -0
- package/src/components/web/Button.tsx +16 -0
- package/src/components/web/FlatList.tsx +20 -0
- package/src/components/web/Image.tsx +18 -0
- package/src/components/web/ImageBackground.tsx +19 -0
- package/src/components/web/KeyboardAvoidingView.tsx +15 -0
- package/src/components/web/Modal.tsx +14 -0
- package/src/components/web/Pressable.tsx +14 -0
- package/src/components/web/RefreshControl.tsx +14 -0
- package/src/components/web/SafeAreaView.tsx +14 -0
- package/src/components/web/ScrollView.tsx +15 -0
- package/src/components/web/SectionList.tsx +17 -0
- package/src/components/web/Switch.tsx +21 -0
- package/src/components/web/Text.tsx +14 -0
- package/src/components/web/TextInput.tsx +14 -0
- package/src/components/web/TouchableHighlight.tsx +18 -0
- package/src/components/web/TouchableNativeFeedback.tsx +2 -0
- package/src/components/web/TouchableOpacity.tsx +14 -0
- package/src/components/web/TouchableWithoutFeedback.tsx +14 -0
- package/src/components/web/View.tsx +14 -0
- package/src/components/web/VirtualizedList.tsx +17 -0
- package/src/components/web/index.ts +22 -0
- package/src/components/web/metro-injected.ts +1 -0
- package/src/components/web/rnw.ts +52 -0
- package/src/core/config/config.common.ts +98 -0
- package/src/core/config/config.native.ts +79 -0
- package/src/core/config/config.ts +64 -0
- package/src/core/config/index.ts +1 -0
- package/src/core/index.ts +1 -0
- package/src/core/listener.ts +59 -0
- package/src/core/logger.ts +15 -0
- package/src/core/native/index.ts +2 -0
- package/src/core/native/native-utils.ts +41 -0
- package/src/core/native/parsers/boxShadow.ts +7 -0
- package/src/core/native/parsers/fontVariant.ts +3 -0
- package/src/core/native/parsers/gradient.ts +39 -0
- package/src/core/native/parsers/index.ts +5 -0
- package/src/core/native/parsers/textShadow.ts +37 -0
- package/src/core/native/parsers/transforms.ts +64 -0
- package/src/core/native/runtime.ts +32 -0
- package/src/core/native/store.ts +238 -0
- package/src/core/types.ts +92 -0
- package/src/core/web/cssListener.ts +185 -0
- package/src/core/web/formatColor.ts +13 -0
- package/src/core/web/getWebStyles.ts +76 -0
- package/src/core/web/index.ts +4 -0
- package/src/core/web/parseCSSValue.ts +10 -0
- package/src/css/index.ts +32 -0
- package/src/css/insets.ts +73 -0
- package/src/css/processFunctions.ts +39 -0
- package/src/css/themes.ts +130 -0
- package/src/css/variants.ts +11 -0
- package/src/hoc/index.ts +1 -0
- package/src/hoc/types.ts +45 -0
- package/src/hoc/withUniwind.native.tsx +118 -0
- package/src/hoc/withUniwind.tsx +115 -0
- package/src/hoc/withUniwindUtils.ts +10 -0
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useCSSVariable/getVariableValue.native.ts +3 -0
- package/src/hooks/useCSSVariable/getVariableValue.ts +19 -0
- package/src/hooks/useCSSVariable/index.ts +1 -0
- package/src/hooks/useCSSVariable/useCSSVariable.ts +89 -0
- package/src/hooks/useResolveClassNames.native.ts +29 -0
- package/src/hooks/useResolveClassNames.ts +26 -0
- package/src/hooks/useUniwind.ts +26 -0
- package/src/hooks/useUniwindAccent.native.ts +8 -0
- package/src/hooks/useUniwindAccent.ts +10 -0
- package/src/index.ts +5 -0
- package/src/metro/addMetaToStylesTemplate.ts +152 -0
- package/src/metro/compileVirtual.ts +74 -0
- package/src/metro/index.d.ts +15 -0
- package/src/metro/index.ts +1 -0
- package/src/metro/injectThemes.ts +23 -0
- package/src/metro/logger.ts +44 -0
- package/src/metro/metro-css-patches.ts +57 -0
- package/src/metro/metro-transformer.ts +99 -0
- package/src/metro/polyfillWeb.ts +14 -0
- package/src/metro/processor/color.ts +76 -0
- package/src/metro/processor/css.ts +541 -0
- package/src/metro/processor/functions.ts +199 -0
- package/src/metro/processor/index.ts +1 -0
- package/src/metro/processor/mq.ts +82 -0
- package/src/metro/processor/processor.ts +249 -0
- package/src/metro/processor/rn.ts +277 -0
- package/src/metro/processor/units.ts +58 -0
- package/src/metro/processor/var.ts +18 -0
- package/src/metro/resolvers.ts +101 -0
- package/src/metro/types.ts +74 -0
- package/src/metro/utils/common.ts +103 -0
- package/src/metro/utils/index.ts +2 -0
- package/src/metro/utils/serialize.ts +116 -0
- package/src/metro/withUniwindConfig.ts +60 -0
- package/src/types.ts +24 -0
- package/src/utils/buildDtsFile.ts +27 -0
- package/src/utils/stringifyThemes.ts +1 -0
- package/src/vite/index.d.ts +9 -0
- package/src/vite/index.ts +1 -0
- package/src/vite/vite.ts +86 -0
- package/types.d.ts +109 -0
- package/uniwind.css +262 -0
- package/vite/package.json +3 -0
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useCSSVariable = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _listener = require("../../core/listener");
|
|
9
|
+
var _logger = require("../../core/logger");
|
|
10
|
+
var _types = require("../../types");
|
|
11
|
+
var _getVariableValue = require("./getVariableValue");
|
|
12
|
+
const getValue = name => Array.isArray(name) ? name.map(_getVariableValue.getVariableValue) : (0, _getVariableValue.getVariableValue)(name);
|
|
13
|
+
const arrayEquals = (a, b) => {
|
|
14
|
+
if (a.length !== b.length) {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
return a.every((value, index) => value === b[index]);
|
|
18
|
+
};
|
|
19
|
+
let warned = false;
|
|
20
|
+
const logDevError = name => {
|
|
21
|
+
warned = true;
|
|
22
|
+
_logger.Logger.warn(`We couldn't find your variable ${name}. Make sure it's used at least once in your className, or define it in a static theme as described in the docs: https://docs.uniwind.dev/api/use-css-variable`);
|
|
23
|
+
};
|
|
24
|
+
const useCSSVariable = name => {
|
|
25
|
+
const [value, setValue] = (0, _react.useState)(getValue(name));
|
|
26
|
+
const nameRef = (0, _react.useRef)(name);
|
|
27
|
+
(0, _react.useEffect)(() => {
|
|
28
|
+
if (Array.isArray(name) && Array.isArray(nameRef.current)) {
|
|
29
|
+
if (arrayEquals(name, nameRef.current)) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
setValue(getValue(name));
|
|
33
|
+
nameRef.current = name;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (name !== nameRef.current) {
|
|
37
|
+
setValue(getValue(name));
|
|
38
|
+
nameRef.current = name;
|
|
39
|
+
}
|
|
40
|
+
}, [name]);
|
|
41
|
+
(0, _react.useEffect)(() => {
|
|
42
|
+
const updateValue = () => setValue(getValue(nameRef.current));
|
|
43
|
+
const dispose = _listener.UniwindListener.subscribe(updateValue, [_types.StyleDependency.Theme, _types.StyleDependency.Variables]);
|
|
44
|
+
return dispose;
|
|
45
|
+
}, []);
|
|
46
|
+
if (Array.isArray(value)) {
|
|
47
|
+
value.forEach((val, index) => {
|
|
48
|
+
if (val === void 0 && __DEV__ && !warned) {
|
|
49
|
+
logDevError(name[index] ?? "");
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
if (value === void 0 && __DEV__ && !warned) {
|
|
54
|
+
logDevError(name);
|
|
55
|
+
}
|
|
56
|
+
return value;
|
|
57
|
+
};
|
|
58
|
+
exports.useCSSVariable = useCSSVariable;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useResolveClassNames = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _web = require("../core/web");
|
|
9
|
+
const emptyState = {};
|
|
10
|
+
const useResolveClassNames = className => {
|
|
11
|
+
const [styles, recreate] = (0, _react.useReducer)(() => className !== "" ? (0, _web.getWebStyles)(className) : emptyState, className !== "" ? (0, _web.getWebStyles)(className) : emptyState);
|
|
12
|
+
(0, _react.useEffect)(() => {
|
|
13
|
+
if (className === "") {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
recreate();
|
|
17
|
+
const dispose = _web.CSSListener.subscribeToClassName(className, recreate);
|
|
18
|
+
return dispose;
|
|
19
|
+
}, [className]);
|
|
20
|
+
return styles;
|
|
21
|
+
};
|
|
22
|
+
exports.useResolveClassNames = useResolveClassNames;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useResolveClassNames = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _listener = require("../core/listener");
|
|
9
|
+
var _native = require("../core/native");
|
|
10
|
+
const emptyState = {
|
|
11
|
+
styles: {},
|
|
12
|
+
dependencies: []
|
|
13
|
+
};
|
|
14
|
+
const useResolveClassNames = (className, state) => {
|
|
15
|
+
const [uniwindState, recreate] = (0, _react.useReducer)(() => className !== "" ? _native.UniwindStore.getStyles(className, state) : emptyState, className !== "" ? _native.UniwindStore.getStyles(className, state) : emptyState);
|
|
16
|
+
(0, _react.useEffect)(() => {
|
|
17
|
+
if (className !== "") {
|
|
18
|
+
recreate();
|
|
19
|
+
}
|
|
20
|
+
}, [className, state?.isDisabled, state?.isPressed, state?.isFocused]);
|
|
21
|
+
(0, _react.useEffect)(() => {
|
|
22
|
+
if (uniwindState.dependencies.length > 0) {
|
|
23
|
+
const dispose = _listener.UniwindListener.subscribe(recreate, uniwindState.dependencies);
|
|
24
|
+
return dispose;
|
|
25
|
+
}
|
|
26
|
+
}, [uniwindState.dependencies, className]);
|
|
27
|
+
return uniwindState.styles;
|
|
28
|
+
};
|
|
29
|
+
exports.useResolveClassNames = useResolveClassNames;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useUniwind = void 0;
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _core = require("../core");
|
|
9
|
+
var _listener = require("../core/listener");
|
|
10
|
+
var _types = require("../types");
|
|
11
|
+
const useUniwind = () => {
|
|
12
|
+
const [theme, setTheme] = (0, _react.useState)(_core.Uniwind.currentTheme);
|
|
13
|
+
const [hasAdaptiveThemes, setHasAdaptiveThemes] = (0, _react.useState)(_core.Uniwind.hasAdaptiveThemes);
|
|
14
|
+
(0, _react.useEffect)(() => {
|
|
15
|
+
const dispose = _listener.UniwindListener.subscribe(() => {
|
|
16
|
+
setTheme(_core.Uniwind.currentTheme);
|
|
17
|
+
setHasAdaptiveThemes(_core.Uniwind.hasAdaptiveThemes);
|
|
18
|
+
}, [_types.StyleDependency.Theme, _types.StyleDependency.AdaptiveThemes]);
|
|
19
|
+
return () => {
|
|
20
|
+
dispose();
|
|
21
|
+
};
|
|
22
|
+
}, []);
|
|
23
|
+
return {
|
|
24
|
+
theme,
|
|
25
|
+
hasAdaptiveThemes
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
exports.useUniwind = useUniwind;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useUniwindAccent = void 0;
|
|
7
|
+
var _formatColor = require("../core/web/formatColor");
|
|
8
|
+
var _useResolveClassNames = require("./useResolveClassNames");
|
|
9
|
+
const useUniwindAccent = className => {
|
|
10
|
+
const styles = (0, _useResolveClassNames.useResolveClassNames)(className ?? "");
|
|
11
|
+
return styles.accentColor !== void 0 ? (0, _formatColor.formatColor)(styles.accentColor) : void 0;
|
|
12
|
+
};
|
|
13
|
+
exports.useUniwindAccent = useUniwindAccent;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useUniwindAccent = void 0;
|
|
7
|
+
var _useResolveClassNames = require("./useResolveClassNames.native");
|
|
8
|
+
const useUniwindAccent = (className, state) => {
|
|
9
|
+
const styles = (0, _useResolveClassNames.useResolveClassNames)(className ?? "", state);
|
|
10
|
+
return styles.accentColor;
|
|
11
|
+
};
|
|
12
|
+
exports.useUniwindAccent = useUniwindAccent;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "Uniwind", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _core.Uniwind;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(exports, "useCSSVariable", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _hooks.useCSSVariable;
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
Object.defineProperty(exports, "useResolveClassNames", {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: function () {
|
|
21
|
+
return _hooks.useResolveClassNames;
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
Object.defineProperty(exports, "useUniwind", {
|
|
25
|
+
enumerable: true,
|
|
26
|
+
get: function () {
|
|
27
|
+
return _hooks.useUniwind;
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(exports, "withUniwind", {
|
|
31
|
+
enumerable: true,
|
|
32
|
+
get: function () {
|
|
33
|
+
return _hoc.withUniwind;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
var _core = require("./core");
|
|
37
|
+
var _hoc = require("./hoc");
|
|
38
|
+
var _hooks = require("./hooks");
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.StyleDependency = exports.Orientation = exports.ColorScheme = void 0;
|
|
7
|
+
var StyleDependency = exports.StyleDependency = /* @__PURE__ */(StyleDependency2 => {
|
|
8
|
+
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
9
|
+
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
10
|
+
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
11
|
+
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
12
|
+
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
13
|
+
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
14
|
+
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
15
|
+
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
16
|
+
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
17
|
+
return StyleDependency2;
|
|
18
|
+
})(StyleDependency || {});
|
|
19
|
+
var Orientation = exports.Orientation = /* @__PURE__ */(Orientation2 => {
|
|
20
|
+
Orientation2["Portrait"] = "portrait";
|
|
21
|
+
Orientation2["Landscape"] = "landscape";
|
|
22
|
+
return Orientation2;
|
|
23
|
+
})(Orientation || {});
|
|
24
|
+
var ColorScheme = exports.ColorScheme = /* @__PURE__ */(ColorScheme2 => {
|
|
25
|
+
ColorScheme2["Light"] = "light";
|
|
26
|
+
ColorScheme2["Dark"] = "dark";
|
|
27
|
+
return ColorScheme2;
|
|
28
|
+
})(ColorScheme || {});
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.buildDtsFile = void 0;
|
|
7
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
+
var _package = require("../../package.json");
|
|
9
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
|
+
const buildDtsFile = (dtsPath, stringifiedThemes) => {
|
|
11
|
+
const oldDtsContent = _fs.default.existsSync(dtsPath) ? _fs.default.readFileSync(dtsPath, "utf-8") : "";
|
|
12
|
+
const dtsContent = [`// NOTE: This file is generated by ${_package.name} and it should not be edited manually.`, `/// <reference types="${_package.name}/types" />`, "", `declare module '${_package.name}' {`, ` export interface UniwindConfig {`, ` themes: readonly ${stringifiedThemes}`, ` }`, `}`, "", `export {}`, ""].join("\n");
|
|
13
|
+
if (oldDtsContent === dtsContent) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
_fs.default.writeFileSync(dtsPath, dtsContent);
|
|
17
|
+
};
|
|
18
|
+
exports.buildDtsFile = buildDtsFile;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _vite = require("./vite");
|
|
7
|
+
Object.keys(_vite).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _vite[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _vite[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.uniwind = void 0;
|
|
7
|
+
var _node = require("@tailwindcss/node");
|
|
8
|
+
var _path = _interopRequireDefault(require("path"));
|
|
9
|
+
var _package = require("../../package.json");
|
|
10
|
+
var _css = require("../css");
|
|
11
|
+
var _processFunctions = require("../css/processFunctions");
|
|
12
|
+
var _utils = require("../metro/utils");
|
|
13
|
+
var _buildDtsFile = require("../utils/buildDtsFile");
|
|
14
|
+
var _stringifyThemes = require("../utils/stringifyThemes");
|
|
15
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
+
const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
17
|
+
const componentPath = _path.default.resolve(dirname, "../module/components/web/index.js");
|
|
18
|
+
const uniwind = ({
|
|
19
|
+
cssEntryFile,
|
|
20
|
+
extraThemes,
|
|
21
|
+
dtsFile = "uniwind-types.d.ts"
|
|
22
|
+
}) => {
|
|
23
|
+
const themes = (0, _utils.uniq)(["light", "dark", ...(extraThemes ?? [])]);
|
|
24
|
+
const stringifiedThemes = (0, _stringifyThemes.stringifyThemes)(themes);
|
|
25
|
+
return {
|
|
26
|
+
name: "uniwind",
|
|
27
|
+
config: () => ({
|
|
28
|
+
css: {
|
|
29
|
+
transformer: "lightningcss",
|
|
30
|
+
lightningcss: {
|
|
31
|
+
visitor: {
|
|
32
|
+
Function: _processFunctions.processFunctions
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
optimizeDeps: {
|
|
37
|
+
exclude: [_package.name, "react-native"]
|
|
38
|
+
},
|
|
39
|
+
resolve: {
|
|
40
|
+
alias: [{
|
|
41
|
+
find: /^react-native$/,
|
|
42
|
+
replacement: componentPath,
|
|
43
|
+
customResolver: {
|
|
44
|
+
resolveId(_, importer) {
|
|
45
|
+
if (importer !== void 0 && (0, _node.normalizePath)(importer).includes(`${_package.name}/dist`)) {
|
|
46
|
+
return this.resolve("react-native-web");
|
|
47
|
+
}
|
|
48
|
+
return componentPath;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}]
|
|
52
|
+
}
|
|
53
|
+
}),
|
|
54
|
+
transform: (code, id) => {
|
|
55
|
+
const normalizedId = (0, _node.normalizePath)(id);
|
|
56
|
+
if (normalizedId.includes(`${_package.name}/dist`) && normalizedId.includes("config/config.js")) {
|
|
57
|
+
return {
|
|
58
|
+
code: `${code}Uniwind.__reinit(() => ({}), ${stringifiedThemes})`
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
buildStart: async () => {
|
|
63
|
+
await (0, _css.buildCSS)(themes, cssEntryFile);
|
|
64
|
+
(0, _buildDtsFile.buildDtsFile)(dtsFile, stringifiedThemes);
|
|
65
|
+
},
|
|
66
|
+
generateBundle: async () => {
|
|
67
|
+
await (0, _css.buildCSS)(themes, cssEntryFile);
|
|
68
|
+
(0, _buildDtsFile.buildDtsFile)(dtsFile, stringifiedThemes);
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
exports.uniwind = uniwind;
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const FileStoreBase = require('metro-cache/private/stores/FileStore');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const node_path = require('node:path');
|
|
7
|
+
const common = require('../shared/uniwind.BgZDHdUR.cjs');
|
|
8
|
+
const types = require('../shared/uniwind.BZIuaszw.cjs');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
|
+
|
|
12
|
+
const FileStoreBase__default = /*#__PURE__*/_interopDefaultCompat(FileStoreBase);
|
|
13
|
+
const os__default = /*#__PURE__*/_interopDefaultCompat(os);
|
|
14
|
+
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
15
|
+
|
|
16
|
+
class FileStore extends FileStoreBase__default {
|
|
17
|
+
async set(key, value) {
|
|
18
|
+
if (value?.output?.[0]?.data?.css?.skipCache) {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
return super.set(key, value);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const cacheStore = new FileStore({
|
|
25
|
+
root: path__default.join(os__default.tmpdir(), "metro-cache")
|
|
26
|
+
});
|
|
27
|
+
const patchMetroGraphToSupportUncachedModules = () => {
|
|
28
|
+
const { Graph } = require("metro/private/DeltaBundler/Graph");
|
|
29
|
+
const original_traverseDependencies = Graph.prototype.traverseDependencies;
|
|
30
|
+
if (original_traverseDependencies.__patched) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
original_traverseDependencies.__patched = true;
|
|
34
|
+
function traverseDependencies(paths, options) {
|
|
35
|
+
this.dependencies.forEach((dependency) => {
|
|
36
|
+
if (dependency.output.find((file) => file.data.css?.skipCache === true) && !paths.includes(dependency.path)) {
|
|
37
|
+
dependency.unstable_transformResultKey = `${dependency.unstable_transformResultKey}.`;
|
|
38
|
+
paths.push(dependency.path);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
return original_traverseDependencies.call(this, paths, options);
|
|
42
|
+
}
|
|
43
|
+
Graph.prototype.traverseDependencies = traverseDependencies;
|
|
44
|
+
traverseDependencies.__patched = true;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const thisModuleDist = node_path.resolve(__dirname, "../../dist");
|
|
48
|
+
const thisModuleSrc = node_path.resolve(__dirname, "../../src");
|
|
49
|
+
const isFromThisModule = (filename) => filename.startsWith(thisModuleDist) || filename.startsWith(thisModuleSrc);
|
|
50
|
+
const SUPPORTED_COMPONENTS = [
|
|
51
|
+
"ActivityIndicator",
|
|
52
|
+
"Button",
|
|
53
|
+
"FlatList",
|
|
54
|
+
"Image",
|
|
55
|
+
"ImageBackground",
|
|
56
|
+
"InputAccessoryView",
|
|
57
|
+
"KeyboardAvoidingView",
|
|
58
|
+
"Modal",
|
|
59
|
+
"Pressable",
|
|
60
|
+
"RefreshControl",
|
|
61
|
+
"SafeAreaView",
|
|
62
|
+
"ScrollView",
|
|
63
|
+
"SectionList",
|
|
64
|
+
"Switch",
|
|
65
|
+
"Text",
|
|
66
|
+
"TextInput",
|
|
67
|
+
"TouchableHighlight",
|
|
68
|
+
"TouchableNativeFeedback",
|
|
69
|
+
"TouchableOpacity",
|
|
70
|
+
"TouchableWithoutFeedback",
|
|
71
|
+
"View",
|
|
72
|
+
"VirtualizedList"
|
|
73
|
+
];
|
|
74
|
+
const nativeResolver = ({
|
|
75
|
+
context,
|
|
76
|
+
moduleName,
|
|
77
|
+
platform,
|
|
78
|
+
resolver
|
|
79
|
+
}) => {
|
|
80
|
+
const resolution = resolver(context, moduleName, platform);
|
|
81
|
+
const isInternal = isFromThisModule(context.originModulePath);
|
|
82
|
+
const isReactNativeIndex = context.originModulePath.endsWith(
|
|
83
|
+
`react-native${node_path.sep}index.js`
|
|
84
|
+
);
|
|
85
|
+
if (isInternal || resolution.type !== "sourceFile" || isReactNativeIndex) {
|
|
86
|
+
return resolution;
|
|
87
|
+
}
|
|
88
|
+
if (moduleName === "react-native") {
|
|
89
|
+
return resolver(context, `${common.name}/components`, platform);
|
|
90
|
+
}
|
|
91
|
+
if (resolution.filePath.includes(`${node_path.sep}react-native${node_path.sep}Libraries${node_path.sep}`)) {
|
|
92
|
+
const filename = node_path.basename(resolution.filePath.split(node_path.sep).at(-1) ?? "");
|
|
93
|
+
const module = filename.split(".").at(0);
|
|
94
|
+
if (module !== void 0 && SUPPORTED_COMPONENTS.includes(module)) {
|
|
95
|
+
return resolver(context, `${common.name}/components/${module}`, platform);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return resolution;
|
|
99
|
+
};
|
|
100
|
+
const webResolver = ({
|
|
101
|
+
context,
|
|
102
|
+
moduleName,
|
|
103
|
+
platform,
|
|
104
|
+
resolver
|
|
105
|
+
}) => {
|
|
106
|
+
const resolution = resolver(context, moduleName, platform);
|
|
107
|
+
if (isFromThisModule(context.originModulePath) || resolution.type !== "sourceFile" || !resolution.filePath.includes(`${node_path.sep}react-native-web${node_path.sep}`)) {
|
|
108
|
+
return resolution;
|
|
109
|
+
}
|
|
110
|
+
const segments = resolution.filePath.split(node_path.sep);
|
|
111
|
+
const isIndex = segments.at(-1)?.startsWith("index.");
|
|
112
|
+
const module = segments.at(-2);
|
|
113
|
+
if (!isIndex || module === void 0 || !SUPPORTED_COMPONENTS.includes(module) || context.originModulePath.endsWith(`${module}${node_path.sep}index.js`)) {
|
|
114
|
+
return resolution;
|
|
115
|
+
}
|
|
116
|
+
return resolver(context, `${common.name}/components/${module}`, platform);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const withUniwindConfig = (config, uniwindConfig) => {
|
|
120
|
+
uniwindConfig.themes = common.uniq([
|
|
121
|
+
"light",
|
|
122
|
+
"dark",
|
|
123
|
+
...uniwindConfig.extraThemes ?? []
|
|
124
|
+
]);
|
|
125
|
+
patchMetroGraphToSupportUncachedModules();
|
|
126
|
+
if (typeof uniwindConfig === "undefined") {
|
|
127
|
+
throw new Error("Uniwind: You need to pass second parameter to withUniwindConfig");
|
|
128
|
+
}
|
|
129
|
+
if (typeof uniwindConfig.cssEntryFile === "undefined") {
|
|
130
|
+
throw new Error(
|
|
131
|
+
'Uniwind: You need to pass css css entry file to withUniwindConfig, e.g. withUniwindConfig(config, { cssEntryFile: "./global.css" })'
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
...config,
|
|
136
|
+
cacheStores: [cacheStore],
|
|
137
|
+
transformerPath: require.resolve("./metro-transformer.cjs"),
|
|
138
|
+
transformer: {
|
|
139
|
+
...config.transformer,
|
|
140
|
+
uniwind: uniwindConfig
|
|
141
|
+
},
|
|
142
|
+
resolver: {
|
|
143
|
+
...config.resolver,
|
|
144
|
+
sourceExts: [
|
|
145
|
+
...config.resolver?.sourceExts ?? [],
|
|
146
|
+
"css"
|
|
147
|
+
],
|
|
148
|
+
assetExts: config.resolver?.assetExts?.filter(
|
|
149
|
+
(ext) => ext !== "css"
|
|
150
|
+
),
|
|
151
|
+
resolveRequest: (context, moduleName, platform) => {
|
|
152
|
+
const resolver = config.resolver?.resolveRequest ?? context.resolveRequest;
|
|
153
|
+
const platformResolver = platform === types.Platform.Web ? webResolver : nativeResolver;
|
|
154
|
+
const resolved = platformResolver({
|
|
155
|
+
context,
|
|
156
|
+
moduleName,
|
|
157
|
+
platform,
|
|
158
|
+
resolver
|
|
159
|
+
});
|
|
160
|
+
return resolved;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
|
|
166
|
+
exports.withUniwindConfig = withUniwindConfig;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MetroConfig } from 'metro-config'
|
|
2
|
+
|
|
3
|
+
type Polyfills = {
|
|
4
|
+
rem?: number
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
type UniwindConfig = {
|
|
8
|
+
cssEntryFile: string
|
|
9
|
+
extraThemes?: Array<string>
|
|
10
|
+
dtsFile?: string
|
|
11
|
+
polyfills?: Polyfills
|
|
12
|
+
debug?: boolean
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export declare function withUniwindConfig(config: MetroConfig, options: UniwindConfig): MetroConfig
|