@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,541 @@
|
|
|
1
|
+
import { OverflowKeyword } from 'lightningcss'
|
|
2
|
+
import { Logger } from '../logger'
|
|
3
|
+
import { DeclarationValues } from '../types'
|
|
4
|
+
import { deepEqual, isDefined, pipe, roundToPrecision, shouldBeSerialized } from '../utils'
|
|
5
|
+
import type { ProcessorBuilder } from './processor'
|
|
6
|
+
|
|
7
|
+
export class CSS {
|
|
8
|
+
private readonly logger = new Logger('CSS')
|
|
9
|
+
|
|
10
|
+
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
11
|
+
|
|
12
|
+
processValue(declarationValue: DeclarationValues): any {
|
|
13
|
+
const processedValue = this.getProcessedValue(declarationValue)
|
|
14
|
+
|
|
15
|
+
if (typeof processedValue === 'string') {
|
|
16
|
+
return this.makeSafeForSerialization(processedValue)
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
if (Array.isArray(processedValue)) {
|
|
20
|
+
return processedValue.map(value => {
|
|
21
|
+
if (typeof value === 'string') {
|
|
22
|
+
return this.makeSafeForSerialization(value)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return value
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (typeof processedValue === 'object' && processedValue !== null) {
|
|
30
|
+
return Object.fromEntries(
|
|
31
|
+
Object.entries(processedValue).map(([key, value]) => {
|
|
32
|
+
if (typeof value === 'string') {
|
|
33
|
+
return [
|
|
34
|
+
key,
|
|
35
|
+
this.makeSafeForSerialization(value),
|
|
36
|
+
]
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return [
|
|
40
|
+
key,
|
|
41
|
+
value,
|
|
42
|
+
]
|
|
43
|
+
}),
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return processedValue
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
private getProcessedValue(declarationValue: DeclarationValues): any {
|
|
51
|
+
if (typeof declarationValue !== 'object') {
|
|
52
|
+
return declarationValue
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (('type' in declarationValue)) {
|
|
56
|
+
switch (declarationValue.type) {
|
|
57
|
+
case 'function':
|
|
58
|
+
return this.Processor.Functions.processFunction(declarationValue.value)
|
|
59
|
+
case 'var':
|
|
60
|
+
return this.Processor.Var.processVar(declarationValue.value)
|
|
61
|
+
case 'number':
|
|
62
|
+
return declarationValue.value
|
|
63
|
+
case 'token':
|
|
64
|
+
return this.processValue(declarationValue.value)
|
|
65
|
+
case 'length':
|
|
66
|
+
return this.Processor.Units.processAnyLength(declarationValue.value)
|
|
67
|
+
case 'color':
|
|
68
|
+
return this.Processor.Color.processColor(declarationValue.value)
|
|
69
|
+
case 'integer':
|
|
70
|
+
return declarationValue.value
|
|
71
|
+
case 'comma':
|
|
72
|
+
return ', '
|
|
73
|
+
case 'dimension':
|
|
74
|
+
case 'value':
|
|
75
|
+
case 'length-percentage':
|
|
76
|
+
return this.Processor.Units.processLength(declarationValue.value)
|
|
77
|
+
case 'translate': {
|
|
78
|
+
const [translateX, translateY] = declarationValue.value.map(x => this.processValue(x))
|
|
79
|
+
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
translateX,
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
translateY,
|
|
86
|
+
},
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
case 'translateX':
|
|
90
|
+
return {
|
|
91
|
+
translateX: this.Processor.Units.processLength(declarationValue.value),
|
|
92
|
+
}
|
|
93
|
+
case 'translateY':
|
|
94
|
+
return {
|
|
95
|
+
translateY: this.Processor.Units.processLength(declarationValue.value),
|
|
96
|
+
}
|
|
97
|
+
case 'translateZ': {
|
|
98
|
+
return {
|
|
99
|
+
translateZ: this.processValue(declarationValue.value),
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
case 'rotate':
|
|
103
|
+
return {
|
|
104
|
+
rotate: `${declarationValue.value.value}${declarationValue.value.type}`,
|
|
105
|
+
}
|
|
106
|
+
case 'rotateX':
|
|
107
|
+
return {
|
|
108
|
+
rotateX: `${declarationValue.value.value}${declarationValue.value.type}`,
|
|
109
|
+
}
|
|
110
|
+
case 'rotateY':
|
|
111
|
+
return {
|
|
112
|
+
rotateY: `${declarationValue.value.value}${declarationValue.value.type}`,
|
|
113
|
+
}
|
|
114
|
+
case 'rotateZ':
|
|
115
|
+
return {
|
|
116
|
+
rotateZ: `${declarationValue.value.value}${declarationValue.value.type}`,
|
|
117
|
+
}
|
|
118
|
+
case 'scale': {
|
|
119
|
+
const [scaleX, scaleY] = declarationValue.value.map(x => this.processValue(x))
|
|
120
|
+
|
|
121
|
+
if (scaleX === scaleY) {
|
|
122
|
+
return {
|
|
123
|
+
scale: scaleX,
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return [
|
|
128
|
+
{
|
|
129
|
+
scaleX,
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
scaleY,
|
|
133
|
+
},
|
|
134
|
+
]
|
|
135
|
+
}
|
|
136
|
+
case 'scaleX':
|
|
137
|
+
return {
|
|
138
|
+
scaleX: this.processValue(declarationValue.value),
|
|
139
|
+
}
|
|
140
|
+
case 'scaleY':
|
|
141
|
+
return {
|
|
142
|
+
scaleY: this.processValue(declarationValue.value),
|
|
143
|
+
}
|
|
144
|
+
case 'scaleZ':
|
|
145
|
+
return {
|
|
146
|
+
scaleZ: this.processValue(declarationValue.value),
|
|
147
|
+
}
|
|
148
|
+
case 'percentage':
|
|
149
|
+
return `${declarationValue.value * 100}%`
|
|
150
|
+
case 'token-list':
|
|
151
|
+
return declarationValue.value.reduce((acc, token) => {
|
|
152
|
+
const tokenValue = this.processValue(token)
|
|
153
|
+
|
|
154
|
+
return acc + tokenValue
|
|
155
|
+
}, '')
|
|
156
|
+
case 'rgb':
|
|
157
|
+
case 'oklab':
|
|
158
|
+
case 'oklch':
|
|
159
|
+
case 'hsl':
|
|
160
|
+
case 'hwb':
|
|
161
|
+
case 'lab':
|
|
162
|
+
case 'lch':
|
|
163
|
+
case 'srgb':
|
|
164
|
+
return this.Processor.Color.processColor(declarationValue)
|
|
165
|
+
case 'delim':
|
|
166
|
+
return ` ${declarationValue.value} `
|
|
167
|
+
case 'ident':
|
|
168
|
+
if (this.Processor.Color.isColor(declarationValue.value)) {
|
|
169
|
+
return this.Processor.Color.processColor(declarationValue.value)
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
if (declarationValue.value === 'currentcolor') {
|
|
173
|
+
return 'this["currentColor"]'
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return declarationValue.value
|
|
177
|
+
case 'env':
|
|
178
|
+
if (declarationValue.value.name.type === 'ua' && declarationValue.value.name.value.startsWith('safe-area-inset-')) {
|
|
179
|
+
const inset = declarationValue.value.name.value.replace('safe-area-inset-', '')
|
|
180
|
+
|
|
181
|
+
return `rt.insets.${inset}`
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
this.logUnsupported(`Unsupported env value - ${JSON.stringify(declarationValue.value)}`)
|
|
185
|
+
|
|
186
|
+
return undefined
|
|
187
|
+
case 'time': {
|
|
188
|
+
const unit = declarationValue.value.type === 'milliseconds' ? 'ms' : 's'
|
|
189
|
+
|
|
190
|
+
return `${declarationValue.value.value}${unit}`
|
|
191
|
+
}
|
|
192
|
+
case 'cubic-bezier': {
|
|
193
|
+
const bezier = [
|
|
194
|
+
declarationValue.x1,
|
|
195
|
+
declarationValue.y1,
|
|
196
|
+
declarationValue.x2,
|
|
197
|
+
declarationValue.y2,
|
|
198
|
+
]
|
|
199
|
+
|
|
200
|
+
return `rt.cubicBezier(${bezier.join(',')})`
|
|
201
|
+
}
|
|
202
|
+
case 'seconds':
|
|
203
|
+
return `${declarationValue.value}s`
|
|
204
|
+
case 'milliseconds':
|
|
205
|
+
return `${declarationValue.value}ms`
|
|
206
|
+
case 'pair':
|
|
207
|
+
return declarationValue.inside.type
|
|
208
|
+
case 'currentcolor':
|
|
209
|
+
return 'this["currentColor"]'
|
|
210
|
+
case 'calc':
|
|
211
|
+
return this.Processor.Functions.processCalc(declarationValue.value)
|
|
212
|
+
case 'min':
|
|
213
|
+
case 'max':
|
|
214
|
+
case 'abs':
|
|
215
|
+
return this.Processor.Functions.processMathFunction(declarationValue.type, declarationValue.value)
|
|
216
|
+
case 'keyword':
|
|
217
|
+
if ('value' in declarationValue) {
|
|
218
|
+
return declarationValue.value
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
this.logUnsupported(`Unsupported keyword value - ${JSON.stringify(declarationValue)}`)
|
|
222
|
+
|
|
223
|
+
return undefined
|
|
224
|
+
case 'min-max':
|
|
225
|
+
case 'track-breadth':
|
|
226
|
+
return declarationValue.type
|
|
227
|
+
case 'explicit':
|
|
228
|
+
return `${this.processValue(declarationValue.width)} ${this.processValue(declarationValue.height)}`
|
|
229
|
+
case 'angle':
|
|
230
|
+
return `${declarationValue.value.value}${declarationValue.value.type}`
|
|
231
|
+
case 'gradient':
|
|
232
|
+
if (declarationValue.value.type === 'linear') {
|
|
233
|
+
const direction = String(this.processValue(declarationValue.value.direction))
|
|
234
|
+
|
|
235
|
+
return [
|
|
236
|
+
direction.includes('deg') ? direction : `to ${direction}`,
|
|
237
|
+
...declarationValue.value.items.map(item => this.processValue(item)),
|
|
238
|
+
].join(', ')
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
return undefined
|
|
242
|
+
case 'color-stop':
|
|
243
|
+
return [
|
|
244
|
+
this.Processor.Color.processColor(declarationValue.color),
|
|
245
|
+
declarationValue.position ? this.processValue(declarationValue.position) : null,
|
|
246
|
+
].filter(isDefined).join(' ')
|
|
247
|
+
case 'side':
|
|
248
|
+
return declarationValue.side
|
|
249
|
+
case 'absolute':
|
|
250
|
+
if ('value' in declarationValue) {
|
|
251
|
+
return typeof declarationValue.value === 'string'
|
|
252
|
+
? declarationValue.value
|
|
253
|
+
: this.processValue(declarationValue.value)
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return declarationValue.type
|
|
257
|
+
case 'hash':
|
|
258
|
+
return `#${declarationValue.value}`
|
|
259
|
+
case 'line-style':
|
|
260
|
+
return declarationValue.value
|
|
261
|
+
case 'parenthesis-block':
|
|
262
|
+
return '('
|
|
263
|
+
case 'close-parenthesis':
|
|
264
|
+
return ')'
|
|
265
|
+
case 'light-dark':
|
|
266
|
+
return `rt.lightDark( ${this.processValue(declarationValue.light)}, ${this.processValue(declarationValue.dark)} )`
|
|
267
|
+
case 'unresolved-color':
|
|
268
|
+
return this.getProcessedValue(declarationValue.value)
|
|
269
|
+
case 'track-list':
|
|
270
|
+
case 'sticky':
|
|
271
|
+
case 'fit-content':
|
|
272
|
+
case 'shape':
|
|
273
|
+
return undefined
|
|
274
|
+
case 'weight':
|
|
275
|
+
case 'horizontal':
|
|
276
|
+
case 'vertical':
|
|
277
|
+
case 'white-space':
|
|
278
|
+
case 'string':
|
|
279
|
+
case 'self-position':
|
|
280
|
+
case 'content-distribution':
|
|
281
|
+
case 'content-position':
|
|
282
|
+
return declarationValue.value
|
|
283
|
+
case 'baseline-position':
|
|
284
|
+
return 'baseline'
|
|
285
|
+
default:
|
|
286
|
+
// CSS string properties like absolute, relative, italic, etc.
|
|
287
|
+
if (Object.keys(declarationValue).length === 1) {
|
|
288
|
+
return declarationValue.type
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
this.logUnsupported(`Unsupported value type - ${JSON.stringify(declarationValue.type)}`)
|
|
292
|
+
|
|
293
|
+
return undefined
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
if ('top' in declarationValue) {
|
|
298
|
+
return {
|
|
299
|
+
top: this.processValue(declarationValue.top),
|
|
300
|
+
right: this.processValue(declarationValue.right),
|
|
301
|
+
bottom: this.processValue(declarationValue.bottom),
|
|
302
|
+
left: this.processValue(declarationValue.left),
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
if ('topLeft' in declarationValue) {
|
|
307
|
+
return {
|
|
308
|
+
topLeft: this.processValue(declarationValue.topLeft),
|
|
309
|
+
topRight: this.processValue(declarationValue.topRight),
|
|
310
|
+
bottomLeft: this.processValue(declarationValue.bottomLeft),
|
|
311
|
+
bottomRight: this.processValue(declarationValue.bottomRight),
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
if ('grow' in declarationValue) {
|
|
316
|
+
return {
|
|
317
|
+
flexGrow: declarationValue.grow,
|
|
318
|
+
flexShrink: declarationValue.shrink,
|
|
319
|
+
flexBasis: this.processValue(declarationValue.basis),
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
if (Array.isArray(declarationValue)) {
|
|
324
|
+
if (declarationValue.length === 1) {
|
|
325
|
+
return this.processValue(declarationValue[0]!)
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
return this.addComaBetweenTokens(declarationValue).reduce<string | number>((acc, value, index, array) => {
|
|
329
|
+
if (typeof value === 'object') {
|
|
330
|
+
const nextValue = array.at(index + 1)
|
|
331
|
+
|
|
332
|
+
// Remove duplicates
|
|
333
|
+
if (deepEqual(value, nextValue)) {
|
|
334
|
+
return acc
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const result = this.processValue(value)
|
|
338
|
+
|
|
339
|
+
return acc === '' && typeof result === 'number'
|
|
340
|
+
? result
|
|
341
|
+
: acc + result
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
return acc + value
|
|
345
|
+
}, '')
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
if ('property' in declarationValue) {
|
|
349
|
+
const property = typeof declarationValue.property === 'string'
|
|
350
|
+
? declarationValue.property
|
|
351
|
+
: declarationValue.property.property
|
|
352
|
+
|
|
353
|
+
return `${property},`
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
if ('case' in declarationValue) {
|
|
357
|
+
return declarationValue.case
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
if ('angle' in declarationValue) {
|
|
361
|
+
const angles = pipe([
|
|
362
|
+
['rotateX', declarationValue.x * declarationValue.angle.value],
|
|
363
|
+
['rotateY', declarationValue.y * declarationValue.angle.value],
|
|
364
|
+
['rotateZ', declarationValue.z * declarationValue.angle.value],
|
|
365
|
+
])(
|
|
366
|
+
x => x.filter(([, value]) => value !== 0),
|
|
367
|
+
x => x.map(([key, value]) => [key, `${value}${declarationValue.angle.type}`]),
|
|
368
|
+
Object.fromEntries,
|
|
369
|
+
)
|
|
370
|
+
|
|
371
|
+
return angles
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
if (this.isOverflow(declarationValue)) {
|
|
375
|
+
if (declarationValue.x === declarationValue.y) {
|
|
376
|
+
return {
|
|
377
|
+
overflow: declarationValue.x,
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return {
|
|
382
|
+
overflowX: declarationValue.x,
|
|
383
|
+
overflowY: declarationValue.y,
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if ('auto' in declarationValue) {
|
|
388
|
+
return declarationValue.ratio
|
|
389
|
+
? `${declarationValue.ratio[0]}/${declarationValue.ratio[1]}`
|
|
390
|
+
: 'auto'
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
if ('x' in declarationValue && 'y' in declarationValue) {
|
|
394
|
+
return {
|
|
395
|
+
x: this.processValue(declarationValue.x),
|
|
396
|
+
y: this.processValue(declarationValue.y),
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
// Shadows
|
|
401
|
+
if ('xOffset' in declarationValue) {
|
|
402
|
+
return [
|
|
403
|
+
'inset' in declarationValue && declarationValue.inset ? 'inset' : undefined,
|
|
404
|
+
this.processValue(declarationValue.xOffset),
|
|
405
|
+
this.processValue(declarationValue.yOffset),
|
|
406
|
+
this.processValue(declarationValue.blur),
|
|
407
|
+
this.processValue(declarationValue.spread),
|
|
408
|
+
this.processValue(declarationValue.color),
|
|
409
|
+
].filter(isDefined).join(' ')
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
if ('blockStart' in declarationValue) {
|
|
413
|
+
const startValue = this.processValue(declarationValue.blockStart)
|
|
414
|
+
const endValue = this.processValue(declarationValue.blockEnd)
|
|
415
|
+
|
|
416
|
+
return {
|
|
417
|
+
start: startValue,
|
|
418
|
+
end: endValue,
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
if ('inlineStart' in declarationValue) {
|
|
423
|
+
const startValue = this.processValue(declarationValue.inlineStart)
|
|
424
|
+
const endValue = this.processValue(declarationValue.inlineEnd)
|
|
425
|
+
|
|
426
|
+
return {
|
|
427
|
+
start: startValue,
|
|
428
|
+
end: endValue,
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
if ('start' in declarationValue) {
|
|
433
|
+
const startValue = this.processValue(declarationValue.start)
|
|
434
|
+
const endValue = this.processValue(declarationValue.end)
|
|
435
|
+
|
|
436
|
+
return {
|
|
437
|
+
start: startValue,
|
|
438
|
+
end: endValue,
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
if ('row' in declarationValue) {
|
|
443
|
+
return {
|
|
444
|
+
row: this.processValue(declarationValue.row),
|
|
445
|
+
column: this.processValue(declarationValue.column),
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
if ('keyword' in declarationValue) {
|
|
450
|
+
return declarationValue.keyword === 'auto' || declarationValue.keyword === 'pointer'
|
|
451
|
+
? declarationValue.keyword
|
|
452
|
+
: 'auto'
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
if ('style' in declarationValue && 'width' in declarationValue) {
|
|
456
|
+
return {
|
|
457
|
+
style: this.processValue(declarationValue.style),
|
|
458
|
+
width: declarationValue.width.type === 'length'
|
|
459
|
+
? this.processValue(declarationValue.width.value)
|
|
460
|
+
: undefined,
|
|
461
|
+
color: this.Processor.Color.processColor(declarationValue.color),
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
if ('duration' in declarationValue) {
|
|
466
|
+
return [
|
|
467
|
+
this.processValue(declarationValue.name),
|
|
468
|
+
this.processValue(declarationValue.duration),
|
|
469
|
+
this.processValue(declarationValue.timingFunction),
|
|
470
|
+
this.processValue(declarationValue.delay),
|
|
471
|
+
this.processValue(declarationValue.iterationCount),
|
|
472
|
+
declarationValue.direction,
|
|
473
|
+
declarationValue.fillMode,
|
|
474
|
+
declarationValue.playState,
|
|
475
|
+
this.processValue(declarationValue.timeline),
|
|
476
|
+
].filter(Boolean).join(' ')
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`)
|
|
480
|
+
|
|
481
|
+
return undefined
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
private isOverflow(value: any): value is { x: OverflowKeyword; y: OverflowKeyword } {
|
|
485
|
+
return typeof value === 'object' && 'x' in value && ['hidden', 'visible'].includes(value.x)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Between some tokens there isn't a comma but it should be.
|
|
490
|
+
* For example this applies to Array of shadows
|
|
491
|
+
*/
|
|
492
|
+
private addComaBetweenTokens(values: Array<DeclarationValues>) {
|
|
493
|
+
return values.reduce<Array<any>>((acc, value, index, array) => {
|
|
494
|
+
const next = array.at(index + 1)
|
|
495
|
+
|
|
496
|
+
acc.push(value)
|
|
497
|
+
|
|
498
|
+
if (next === undefined) {
|
|
499
|
+
return acc
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
if (typeof next === 'object' && 'type' in next && next.type === 'token' && next.value.type === 'comma') {
|
|
503
|
+
return acc
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
if (!(typeof value === 'object' && 'xOffset' in value && 'blur' in value)) {
|
|
507
|
+
return acc
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
acc.push({
|
|
511
|
+
type: 'token',
|
|
512
|
+
value: {
|
|
513
|
+
type: 'comma',
|
|
514
|
+
},
|
|
515
|
+
})
|
|
516
|
+
|
|
517
|
+
return acc
|
|
518
|
+
}, [])
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
private logUnsupported(message: string) {
|
|
522
|
+
this.logger.warn(
|
|
523
|
+
[
|
|
524
|
+
message,
|
|
525
|
+
this.Processor.meta.className !== undefined ? `for className ${this.Processor.meta.className}` : null,
|
|
526
|
+
].filter(Boolean).join(' '),
|
|
527
|
+
)
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
private makeSafeForSerialization(value: string) {
|
|
531
|
+
if (shouldBeSerialized(value)) {
|
|
532
|
+
return value
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (value.endsWith('%')) {
|
|
536
|
+
return `"${roundToPrecision(parseFloat(value), 2)}%"`
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return `"${value}"`
|
|
540
|
+
}
|
|
541
|
+
}
|