@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,14 @@
|
|
|
1
|
+
import { TouchableWithoutFeedback as RNTouchableWithoutFeedback, TouchableWithoutFeedbackProps } from 'react-native'
|
|
2
|
+
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { toRNWClassName } from './rnw'
|
|
4
|
+
|
|
5
|
+
export const TouchableWithoutFeedback = copyComponentProperties(RNTouchableWithoutFeedback, (props: TouchableWithoutFeedbackProps) => {
|
|
6
|
+
return (
|
|
7
|
+
<RNTouchableWithoutFeedback
|
|
8
|
+
{...props}
|
|
9
|
+
style={[toRNWClassName(props.className), props.style]}
|
|
10
|
+
/>
|
|
11
|
+
)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export default TouchableWithoutFeedback
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { View as RNView, ViewProps } from 'react-native'
|
|
2
|
+
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { toRNWClassName } from './rnw'
|
|
4
|
+
|
|
5
|
+
export const View = copyComponentProperties(RNView, (props: ViewProps) => {
|
|
6
|
+
return (
|
|
7
|
+
<RNView
|
|
8
|
+
{...props}
|
|
9
|
+
style={[toRNWClassName(props.className), props.style]}
|
|
10
|
+
/>
|
|
11
|
+
)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
export default View
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { VirtualizedList as RNVirtualizedList, VirtualizedListProps } from 'react-native'
|
|
2
|
+
import { copyComponentProperties } from '../utils'
|
|
3
|
+
import { toRNWClassName } from './rnw'
|
|
4
|
+
|
|
5
|
+
export const VirtualizedList = copyComponentProperties(RNVirtualizedList, (props: VirtualizedListProps<unknown>) => {
|
|
6
|
+
return (
|
|
7
|
+
<RNVirtualizedList
|
|
8
|
+
{...props}
|
|
9
|
+
style={[toRNWClassName(props.className), props.style]}
|
|
10
|
+
contentContainerStyle={[toRNWClassName(props.contentContainerClassName), props.contentContainerStyle]}
|
|
11
|
+
ListFooterComponentStyle={[toRNWClassName(props.ListFooterComponentClassName), props.ListFooterComponentStyle]}
|
|
12
|
+
ListHeaderComponentStyle={[toRNWClassName(props.ListHeaderComponentClassName), props.ListHeaderComponentStyle]}
|
|
13
|
+
/>
|
|
14
|
+
)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
export default VirtualizedList
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export * from 'react-native'
|
|
2
|
+
export { ActivityIndicator } from './ActivityIndicator'
|
|
3
|
+
export { Button } from './Button'
|
|
4
|
+
export { FlatList } from './FlatList'
|
|
5
|
+
export { Image } from './Image'
|
|
6
|
+
export { ImageBackground } from './ImageBackground'
|
|
7
|
+
export { KeyboardAvoidingView } from './KeyboardAvoidingView'
|
|
8
|
+
export { Modal } from './Modal'
|
|
9
|
+
export { Pressable } from './Pressable'
|
|
10
|
+
export { RefreshControl } from './RefreshControl'
|
|
11
|
+
export { SafeAreaView } from './SafeAreaView'
|
|
12
|
+
export { ScrollView } from './ScrollView'
|
|
13
|
+
export { SectionList } from './SectionList'
|
|
14
|
+
export { Switch } from './Switch'
|
|
15
|
+
export { Text } from './Text'
|
|
16
|
+
export { TextInput } from './TextInput'
|
|
17
|
+
export { TouchableHighlight } from './TouchableHighlight'
|
|
18
|
+
export { TouchableNativeFeedback } from './TouchableNativeFeedback'
|
|
19
|
+
export { TouchableOpacity } from './TouchableOpacity'
|
|
20
|
+
export { TouchableWithoutFeedback } from './TouchableWithoutFeedback'
|
|
21
|
+
export { View } from './View'
|
|
22
|
+
export { VirtualizedList } from './VirtualizedList'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
// Will be replaced by metro resolver
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Uniwind } from '../../core'
|
|
2
|
+
import { UniwindListener } from '../../core/listener'
|
|
3
|
+
import { StyleDependency } from '../../types'
|
|
4
|
+
import './metro-injected'
|
|
5
|
+
|
|
6
|
+
const moveCssRulesToUtilitiesLayer = (sourceSheet: CSSStyleSheet) => {
|
|
7
|
+
const layerRuleIndex = sourceSheet.insertRule(
|
|
8
|
+
'@layer rnw {}',
|
|
9
|
+
0,
|
|
10
|
+
)
|
|
11
|
+
const layerRule = sourceSheet.cssRules[layerRuleIndex] as CSSGroupingRule
|
|
12
|
+
|
|
13
|
+
while (sourceSheet.cssRules.length > 1) {
|
|
14
|
+
const nextRule = sourceSheet.cssRules[1]!
|
|
15
|
+
|
|
16
|
+
layerRule.insertRule(nextRule.cssText, layerRule.cssRules.length)
|
|
17
|
+
sourceSheet.deleteRule(1)
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof window !== 'undefined' && typeof document !== 'undefined') {
|
|
22
|
+
const rnwStyleSheet = document.querySelector<HTMLStyleElement>('#react-native-stylesheet')
|
|
23
|
+
|
|
24
|
+
if (rnwStyleSheet?.sheet) {
|
|
25
|
+
moveCssRulesToUtilitiesLayer(rnwStyleSheet.sheet)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type UniwindWithThemes = {
|
|
30
|
+
themes: typeof Uniwind['themes']
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const addClassNameToRoot = () => {
|
|
34
|
+
if (typeof document === 'undefined') {
|
|
35
|
+
return
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const root = document.documentElement
|
|
39
|
+
;(Uniwind as unknown as UniwindWithThemes).themes.forEach(theme => root.classList.remove(theme))
|
|
40
|
+
root.classList.add(Uniwind.currentTheme)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
UniwindListener.subscribe(() => {
|
|
44
|
+
addClassNameToRoot()
|
|
45
|
+
}, [StyleDependency.Theme])
|
|
46
|
+
|
|
47
|
+
addClassNameToRoot()
|
|
48
|
+
|
|
49
|
+
export const toRNWClassName = (className?: string) =>
|
|
50
|
+
className !== undefined
|
|
51
|
+
? ({ $$css: true, tailwind: className }) as {}
|
|
52
|
+
: {}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Appearance, Insets, Platform } from 'react-native'
|
|
2
|
+
import { ColorScheme, StyleDependency } from '../../types'
|
|
3
|
+
import { UniwindListener } from '../listener'
|
|
4
|
+
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
5
|
+
|
|
6
|
+
const SYSTEM_THEME = 'system' as const
|
|
7
|
+
|
|
8
|
+
export class UniwindConfigBuilder {
|
|
9
|
+
protected themes = ['light', 'dark']
|
|
10
|
+
#hasAdaptiveThemes = true
|
|
11
|
+
#currentTheme = this.colorScheme as ThemeName
|
|
12
|
+
|
|
13
|
+
constructor() {
|
|
14
|
+
Appearance.addChangeListener(event => {
|
|
15
|
+
const colorScheme = event.colorScheme ?? ColorScheme.Light
|
|
16
|
+
const prevTheme = this.#currentTheme
|
|
17
|
+
|
|
18
|
+
if (this.#hasAdaptiveThemes && prevTheme !== colorScheme) {
|
|
19
|
+
this.#currentTheme = colorScheme
|
|
20
|
+
this.onThemeChange()
|
|
21
|
+
UniwindListener.notify([StyleDependency.Theme])
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get hasAdaptiveThemes() {
|
|
27
|
+
return this.#hasAdaptiveThemes
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
get currentTheme(): ThemeName {
|
|
31
|
+
return this.#currentTheme
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private get colorScheme() {
|
|
35
|
+
return Appearance.getColorScheme() ?? ColorScheme.Light
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
39
|
+
setTheme(theme: ThemeName | typeof SYSTEM_THEME) {
|
|
40
|
+
const prevTheme = this.#currentTheme
|
|
41
|
+
const prevHasAdaptiveThemes = this.#hasAdaptiveThemes
|
|
42
|
+
const isAdaptiveTheme = ['light', 'dark'].includes(theme)
|
|
43
|
+
|
|
44
|
+
try {
|
|
45
|
+
if (theme === SYSTEM_THEME) {
|
|
46
|
+
this.#hasAdaptiveThemes = true
|
|
47
|
+
this.#currentTheme = this.colorScheme
|
|
48
|
+
|
|
49
|
+
if (Platform.OS !== 'web') {
|
|
50
|
+
Appearance.setColorScheme(undefined)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!this.themes.includes(theme)) {
|
|
57
|
+
throw new Error(`Uniwind: You're trying to setTheme to '${theme}', but it was not registered.`)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.#hasAdaptiveThemes = false
|
|
61
|
+
this.#currentTheme = theme
|
|
62
|
+
|
|
63
|
+
if (Platform.OS !== 'web') {
|
|
64
|
+
Appearance.setColorScheme(isAdaptiveTheme ? this.#currentTheme as ColorScheme : undefined)
|
|
65
|
+
}
|
|
66
|
+
} finally {
|
|
67
|
+
if (prevTheme !== this.#currentTheme) {
|
|
68
|
+
this.onThemeChange()
|
|
69
|
+
UniwindListener.notify([StyleDependency.Theme])
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (prevHasAdaptiveThemes !== this.#hasAdaptiveThemes) {
|
|
73
|
+
UniwindListener.notify([StyleDependency.AdaptiveThemes])
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
updateCSSVariables(theme: ThemeName, variables: CSSVariables) {
|
|
79
|
+
// noop
|
|
80
|
+
theme
|
|
81
|
+
variables
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
updateInsets(insets: Insets) {
|
|
85
|
+
// noop
|
|
86
|
+
insets
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
protected __reinit(_: GenerateStyleSheetsCallback, themes: Array<string>) {
|
|
90
|
+
this.themes = themes
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected onThemeChange() {
|
|
94
|
+
// noop
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export const Uniwind = new UniwindConfigBuilder()
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { formatHex, formatHex8, parse } from 'culori'
|
|
2
|
+
import { Insets } from 'react-native'
|
|
3
|
+
import { StyleDependency } from '../../types'
|
|
4
|
+
import { UniwindListener } from '../listener'
|
|
5
|
+
import { Logger } from '../logger'
|
|
6
|
+
import { UniwindStore } from '../native'
|
|
7
|
+
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
8
|
+
import { UniwindConfigBuilder as UniwindConfigBuilderBase } from './config.common'
|
|
9
|
+
|
|
10
|
+
class UniwindConfigBuilder extends UniwindConfigBuilderBase {
|
|
11
|
+
constructor() {
|
|
12
|
+
super()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
__reinit(generateStyleSheetCallback: GenerateStyleSheetsCallback, themes: Array<string>) {
|
|
16
|
+
super.__reinit(generateStyleSheetCallback, themes)
|
|
17
|
+
UniwindStore.reinit(generateStyleSheetCallback)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
onThemeChange() {
|
|
21
|
+
UniwindStore.runtime.currentThemeName = this.currentTheme
|
|
22
|
+
UniwindStore.reinit()
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
updateCSSVariables(theme: ThemeName, variables: CSSVariables) {
|
|
26
|
+
Object.entries(variables).forEach(([varName, varValue]) => {
|
|
27
|
+
if (!varName.startsWith('--') && __DEV__) {
|
|
28
|
+
Logger.error(`CSS variable name must start with "--", instead got: ${varName}`)
|
|
29
|
+
|
|
30
|
+
return
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const getValue = () => {
|
|
34
|
+
if (typeof varValue === 'number') {
|
|
35
|
+
return varValue
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const parsedColor = parse(varValue)
|
|
39
|
+
|
|
40
|
+
if (parsedColor) {
|
|
41
|
+
return parsedColor.alpha === undefined || parsedColor.alpha === 1
|
|
42
|
+
? formatHex(parsedColor)
|
|
43
|
+
: formatHex8(parsedColor)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return varValue
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const value = getValue()
|
|
50
|
+
const runtimeThemeVariables = UniwindStore.runtimeThemeVariables.get(theme) ?? {}
|
|
51
|
+
|
|
52
|
+
Object.defineProperty(UniwindStore.vars, varName, {
|
|
53
|
+
configurable: true,
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: () => value,
|
|
56
|
+
})
|
|
57
|
+
Object.defineProperty(runtimeThemeVariables, varName, {
|
|
58
|
+
configurable: true,
|
|
59
|
+
enumerable: true,
|
|
60
|
+
get: () => value,
|
|
61
|
+
})
|
|
62
|
+
UniwindStore.runtimeThemeVariables.set(theme, runtimeThemeVariables)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
if (theme === this.currentTheme) {
|
|
66
|
+
UniwindListener.notify([StyleDependency.Variables])
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
updateInsets(insets: Insets) {
|
|
71
|
+
UniwindStore.runtime.insets.bottom = insets.bottom ?? 0
|
|
72
|
+
UniwindStore.runtime.insets.top = insets.top ?? 0
|
|
73
|
+
UniwindStore.runtime.insets.left = insets.left ?? 0
|
|
74
|
+
UniwindStore.runtime.insets.right = insets.right ?? 0
|
|
75
|
+
UniwindListener.notify([StyleDependency.Insets])
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const Uniwind = new UniwindConfigBuilder()
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { StyleDependency } from '../../types'
|
|
2
|
+
import { UniwindListener } from '../listener'
|
|
3
|
+
import { Logger } from '../logger'
|
|
4
|
+
import { CSSVariables, ThemeName } from '../types'
|
|
5
|
+
import { UniwindConfigBuilder as UniwindConfigBuilderBase } from './config.common'
|
|
6
|
+
|
|
7
|
+
class UniwindConfigBuilder extends UniwindConfigBuilderBase {
|
|
8
|
+
private runtimeCSSVariables = new Map<ThemeName, CSSVariables>()
|
|
9
|
+
|
|
10
|
+
constructor() {
|
|
11
|
+
super()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
onThemeChange() {
|
|
15
|
+
if (typeof document === 'undefined') {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
document.documentElement.removeAttribute('style')
|
|
20
|
+
|
|
21
|
+
const runtimeCSSVariables = this.runtimeCSSVariables.get(this.currentTheme)
|
|
22
|
+
|
|
23
|
+
if (!runtimeCSSVariables) {
|
|
24
|
+
return
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Object.entries(runtimeCSSVariables).forEach(([varName, varValue]) => {
|
|
28
|
+
this.applyCSSVariable(varName, varValue)
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
updateCSSVariables(theme: ThemeName, variables: CSSVariables) {
|
|
33
|
+
Object.entries(variables).forEach(([varName, varValue]) => {
|
|
34
|
+
if (!varName.startsWith('--') && __DEV__) {
|
|
35
|
+
Logger.error(`CSS variable name must start with "--", instead got: ${varName}`)
|
|
36
|
+
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const runtimeCSSVariables = this.runtimeCSSVariables.get(theme) ?? {}
|
|
41
|
+
|
|
42
|
+
runtimeCSSVariables[varName] = varValue
|
|
43
|
+
this.runtimeCSSVariables.set(theme, runtimeCSSVariables)
|
|
44
|
+
this.applyCSSVariable(varName, varValue)
|
|
45
|
+
})
|
|
46
|
+
|
|
47
|
+
if (theme === this.currentTheme) {
|
|
48
|
+
UniwindListener.notify([StyleDependency.Variables])
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private applyCSSVariable(varName: keyof CSSVariables, varValue: CSSVariables[keyof CSSVariables]) {
|
|
53
|
+
if (typeof document === 'undefined') {
|
|
54
|
+
return
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
document.documentElement.style.setProperty(
|
|
58
|
+
varName,
|
|
59
|
+
typeof varValue === 'number' ? `${varValue}px` : varValue,
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const Uniwind = new UniwindConfigBuilder()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './config'
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { StyleDependency } from '../types'
|
|
2
|
+
|
|
3
|
+
type SubscribeOptions = {
|
|
4
|
+
once?: boolean
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
class UniwindListenerBuilder {
|
|
8
|
+
private listeners = {
|
|
9
|
+
[StyleDependency.ColorScheme]: new Set<() => void>(),
|
|
10
|
+
[StyleDependency.Theme]: new Set<() => void>(),
|
|
11
|
+
[StyleDependency.Dimensions]: new Set<() => void>(),
|
|
12
|
+
[StyleDependency.Orientation]: new Set<() => void>(),
|
|
13
|
+
[StyleDependency.Insets]: new Set<() => void>(),
|
|
14
|
+
[StyleDependency.FontScale]: new Set<() => void>(),
|
|
15
|
+
[StyleDependency.Rtl]: new Set<() => void>(),
|
|
16
|
+
[StyleDependency.AdaptiveThemes]: new Set<() => void>(),
|
|
17
|
+
[StyleDependency.Variables]: new Set<() => void>(),
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
notify(dependencies: Array<StyleDependency>) {
|
|
21
|
+
dependencies.forEach(dep => {
|
|
22
|
+
this.listeners[dep].forEach(callback => callback())
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
notifyAll() {
|
|
27
|
+
Object.values(this.listeners).forEach(listenerSet => {
|
|
28
|
+
listenerSet.forEach(callback => callback())
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
subscribe(listener: () => void, dependencies: Array<StyleDependency>, options?: SubscribeOptions) {
|
|
33
|
+
const wrappedListeners = new Map<StyleDependency, () => void>()
|
|
34
|
+
|
|
35
|
+
const dispose = () => {
|
|
36
|
+
wrappedListeners.forEach((wrappedListener, dep) => {
|
|
37
|
+
this.listeners[dep].delete(wrappedListener)
|
|
38
|
+
})
|
|
39
|
+
wrappedListeners.clear()
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
dependencies.forEach(dep => {
|
|
43
|
+
const wrappedListener = () => {
|
|
44
|
+
listener()
|
|
45
|
+
|
|
46
|
+
if (options?.once) {
|
|
47
|
+
dispose()
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
wrappedListeners.set(dep, wrappedListener)
|
|
52
|
+
this.listeners[dep].add(wrappedListener)
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return dispose
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export const UniwindListener = new UniwindListenerBuilder()
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
export class Logger {
|
|
4
|
+
static log(message: string) {
|
|
5
|
+
console.log(`Uniwind - ${message}`)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
static error(message: string) {
|
|
9
|
+
console.error(`Uniwind - ${message}`)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
static warn(message: string) {
|
|
13
|
+
console.warn(`Uniwind - ${message}`)
|
|
14
|
+
}
|
|
15
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { formatHex, formatHex8, interpolate, parse } from 'culori'
|
|
2
|
+
import type { UniwindRuntime } from '../types'
|
|
3
|
+
|
|
4
|
+
export const colorMix = (color: string, weight: number | string, mixColor: string) => {
|
|
5
|
+
const parsedWeight = typeof weight === 'string'
|
|
6
|
+
? parseFloat(weight) / 100
|
|
7
|
+
: weight
|
|
8
|
+
|
|
9
|
+
// Change alpha
|
|
10
|
+
if (mixColor === '#00000000') {
|
|
11
|
+
const parsedColor = parse(color)
|
|
12
|
+
|
|
13
|
+
if (parsedColor === undefined) {
|
|
14
|
+
return color
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return formatHex8({
|
|
18
|
+
...parsedColor,
|
|
19
|
+
alpha: parsedWeight * (parsedColor.alpha ?? 1),
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
return formatHex(interpolate([mixColor, color])(parsedWeight))
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function lightDark(this: UniwindRuntime, light: string, dark: string) {
|
|
27
|
+
if (this.currentThemeName === 'dark') {
|
|
28
|
+
return dark
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return light
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export const cloneWithAccessors = <T extends object>(obj: T) => {
|
|
35
|
+
const proto = Object.getPrototypeOf(obj)
|
|
36
|
+
const clone = Object.create(proto)
|
|
37
|
+
|
|
38
|
+
Object.defineProperties(clone, Object.getOwnPropertyDescriptors(obj))
|
|
39
|
+
|
|
40
|
+
return clone
|
|
41
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { GradientValue } from 'react-native'
|
|
2
|
+
|
|
3
|
+
type InferFromReadonlyArray<T> = T extends ReadonlyArray<infer U> ? U : never
|
|
4
|
+
|
|
5
|
+
const gradientDirectionTokens = new Set(['to', 'top', 'right', 'bottom', 'left'])
|
|
6
|
+
|
|
7
|
+
export const resolveGradient = (value: string) => {
|
|
8
|
+
const tokens = value.split(', ')
|
|
9
|
+
const directionToken = tokens.find(token => token.includes('to') || token.includes('deg'))
|
|
10
|
+
const filtered = tokens.filter(token => token !== directionToken)
|
|
11
|
+
|
|
12
|
+
const colorStops = filtered.map(token => {
|
|
13
|
+
const [color, position] = token.split(' ')
|
|
14
|
+
|
|
15
|
+
return {
|
|
16
|
+
color: color!,
|
|
17
|
+
positions: position !== undefined ? [position] as unknown as Array<Array<string>> : undefined,
|
|
18
|
+
} satisfies InferFromReadonlyArray<GradientValue['colorStops']>
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
const direction = directionToken
|
|
22
|
+
?.split(' ')
|
|
23
|
+
.reduce((acc, token) => {
|
|
24
|
+
if (gradientDirectionTokens.has(token) || token.includes('deg')) {
|
|
25
|
+
return `${acc} ${token.replace(',', '')}`
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return acc
|
|
29
|
+
}, '')
|
|
30
|
+
.trim()
|
|
31
|
+
|
|
32
|
+
return [
|
|
33
|
+
{
|
|
34
|
+
colorStops,
|
|
35
|
+
type: 'linear-gradient',
|
|
36
|
+
direction,
|
|
37
|
+
},
|
|
38
|
+
] satisfies Array<GradientValue>
|
|
39
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const parseTextShadowMutation = (styles: Record<string, any>) => {
|
|
2
|
+
const tokens: Array<string> = styles.textShadow.replace(/,/g, '').split(' ')
|
|
3
|
+
|
|
4
|
+
if (tokens.length === 0) {
|
|
5
|
+
return
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
const color = tokens.find(token => token.startsWith('#')) ?? '#000000'
|
|
9
|
+
const offsets = tokens.filter(token => token !== color)
|
|
10
|
+
const [offsetX, offsetY, radius] = offsets
|
|
11
|
+
|
|
12
|
+
if (offsetX !== undefined && offsetY !== undefined) {
|
|
13
|
+
Object.defineProperty(styles, 'textShadowOffset', {
|
|
14
|
+
configurable: true,
|
|
15
|
+
enumerable: true,
|
|
16
|
+
value: {
|
|
17
|
+
width: Number(offsetX),
|
|
18
|
+
height: Number(offsetY),
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
delete styles.textShadow
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (radius !== undefined) {
|
|
25
|
+
Object.defineProperty(styles, 'textShadowRadius', {
|
|
26
|
+
configurable: true,
|
|
27
|
+
enumerable: true,
|
|
28
|
+
value: Number(radius),
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
Object.defineProperty(styles, 'textShadowColor', {
|
|
33
|
+
configurable: true,
|
|
34
|
+
enumerable: true,
|
|
35
|
+
value: color,
|
|
36
|
+
})
|
|
37
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/* eslint-disable max-depth */
|
|
2
|
+
const transforms = [
|
|
3
|
+
'translateX',
|
|
4
|
+
'translateY',
|
|
5
|
+
'translateZ',
|
|
6
|
+
'rotate',
|
|
7
|
+
'rotateX',
|
|
8
|
+
'rotateY',
|
|
9
|
+
'rotateZ',
|
|
10
|
+
'scale',
|
|
11
|
+
'scaleX',
|
|
12
|
+
'scaleY',
|
|
13
|
+
'scaleZ',
|
|
14
|
+
'skewX',
|
|
15
|
+
'skewY',
|
|
16
|
+
'perspective',
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
const processTransform = (transform: string, value: any) => {
|
|
20
|
+
if (transform.startsWith('scale') && typeof value === 'string') {
|
|
21
|
+
return parseFloat(value.replace('%', '')) / 100
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return value
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export const parseTransformsMutation = (styles: Record<string, any>) => {
|
|
28
|
+
const transformTokens = typeof styles.transform === 'string'
|
|
29
|
+
? styles.transform
|
|
30
|
+
.split(' ')
|
|
31
|
+
.filter(token => token !== 'undefined')
|
|
32
|
+
: []
|
|
33
|
+
|
|
34
|
+
const transformsResult = []
|
|
35
|
+
|
|
36
|
+
for (const transform of transforms) {
|
|
37
|
+
if (transformTokens.length > 0) {
|
|
38
|
+
// Transforms inside transform - transform: rotate(45deg);
|
|
39
|
+
for (const token of transformTokens) {
|
|
40
|
+
if (!token.startsWith(transform)) {
|
|
41
|
+
continue
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const transformValue = token.slice(transform.length + 1, -1)
|
|
45
|
+
|
|
46
|
+
transformsResult.push({ [transform]: processTransform(transform, transformValue) })
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Transforms outside of transform - { rotate: '45deg' }
|
|
51
|
+
if (styles[transform] !== undefined) {
|
|
52
|
+
transformsResult.push({ [transform]: processTransform(transform, styles[transform]) })
|
|
53
|
+
delete styles[transform]
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (transformsResult.length > 0) {
|
|
58
|
+
Object.defineProperty(styles, 'transform', {
|
|
59
|
+
configurable: true,
|
|
60
|
+
enumerable: true,
|
|
61
|
+
value: transformsResult,
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
}
|