@niibase/uniwind 1.6.4 → 1.8.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/CHANGELOG.md +71 -0
- package/dist/cli/index.cjs +91 -0
- package/dist/cli/index.mjs +84 -0
- package/dist/common/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/common/{css → bundler/artifacts/css}/themes.js +4 -1
- package/dist/common/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +1 -2
- package/dist/common/bundler/cli/index.js +76 -0
- package/dist/common/bundler/config.js +75 -0
- package/dist/common/bundler/css-compiler/compileCSS.js +18 -0
- package/dist/common/bundler/css-compiler/compileNativeCSS.js +19 -0
- package/dist/common/bundler/css-compiler/compileTailwind.js +27 -0
- package/dist/common/bundler/css-compiler/compileWebCSS.js +15 -0
- package/dist/common/{vite → bundler/css-compiler}/index.js +4 -4
- package/dist/common/bundler/css-processor/addMetaToStylesTemplate.js +130 -0
- package/dist/common/bundler/css-processor/animation.js +112 -0
- package/dist/common/bundler/css-processor/color.js +66 -0
- package/dist/common/bundler/css-processor/css.js +510 -0
- package/dist/common/bundler/css-processor/functions.js +145 -0
- package/dist/common/bundler/css-processor/index.js +38 -0
- package/dist/common/bundler/css-processor/mq.js +87 -0
- package/dist/common/bundler/css-processor/processor.js +353 -0
- package/dist/common/bundler/css-processor/rn.js +356 -0
- package/dist/common/bundler/css-processor/serialize.js +86 -0
- package/dist/common/bundler/css-processor/types.js +1 -0
- package/dist/common/bundler/css-processor/units.js +55 -0
- package/dist/common/bundler/css-processor/utils.js +61 -0
- package/dist/common/bundler/css-processor/var.js +20 -0
- package/dist/common/{css-visitor → bundler/css-visitor}/rule-visitor.js +7 -7
- package/dist/common/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/common/bundler/logger.js +44 -0
- package/dist/common/bundler/types.js +1 -0
- package/dist/common/common/consts.js +26 -2
- package/dist/common/components/web/rnw.js +2 -2
- package/dist/common/core/config/config.common.js +9 -9
- package/dist/common/core/config/config.js +2 -2
- package/dist/common/core/config/config.native.js +4 -8
- package/dist/common/core/listener.js +10 -10
- package/dist/common/core/native/native-utils.js +1 -8
- package/dist/common/core/native/parsers/textShadow.js +6 -18
- package/dist/common/core/native/parsers/transforms.js +1 -5
- package/dist/common/core/native/runtime.js +7 -3
- package/dist/common/core/native/store.js +22 -69
- package/dist/common/core/web/cssListener.js +2 -2
- package/dist/common/hoc/withUniwind.js +5 -5
- package/dist/common/hoc/withUniwind.native.js +5 -5
- package/dist/common/hooks/useCSSVariable/getVariableValue.native.js +4 -1
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +6 -2
- package/dist/common/hooks/useUniwind.js +2 -2
- package/dist/metro/index.cjs +40 -34
- package/dist/metro/index.d.ts +2 -0
- package/dist/metro/index.mjs +28 -22
- package/dist/metro/{metro-transformer.cjs → transformer.cjs} +316 -200
- package/dist/metro/{metro-transformer.mjs → transformer.mjs} +254 -138
- package/dist/module/{css → bundler/artifacts/css}/index.d.ts +1 -1
- package/dist/module/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/module/{css → bundler/artifacts/css}/themes.js +4 -1
- package/dist/module/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +3 -4
- package/dist/module/bundler/cli/index.d.ts +2 -0
- package/dist/module/bundler/cli/index.js +81 -0
- package/dist/module/bundler/config.d.ts +17 -0
- package/dist/module/bundler/config.js +77 -0
- package/dist/module/bundler/css-compiler/compileCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileCSS.js +11 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.js +33 -0
- package/dist/module/bundler/css-compiler/compileTailwind.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileTailwind.js +22 -0
- package/dist/module/bundler/css-compiler/compileWebCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileWebCSS.js +8 -0
- package/dist/module/bundler/css-compiler/index.d.ts +1 -0
- package/dist/module/bundler/css-compiler/index.js +1 -0
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.d.ts +3 -0
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.js +136 -0
- package/dist/module/bundler/css-processor/animation.d.ts +6 -0
- package/dist/module/bundler/css-processor/animation.js +112 -0
- package/dist/module/bundler/css-processor/color.d.ts +12 -0
- package/dist/module/bundler/css-processor/color.js +63 -0
- package/dist/module/bundler/css-processor/css.d.ts +23 -0
- package/dist/module/bundler/css-processor/css.js +566 -0
- package/dist/module/bundler/css-processor/functions.d.ts +12 -0
- package/dist/module/bundler/css-processor/functions.js +190 -0
- package/dist/module/bundler/css-processor/index.d.ts +3 -0
- package/dist/module/bundler/css-processor/index.js +3 -0
- package/dist/module/bundler/css-processor/mq.d.ts +12 -0
- package/dist/module/bundler/css-processor/mq.js +78 -0
- package/dist/module/bundler/css-processor/processor.d.ts +36 -0
- package/dist/module/bundler/css-processor/processor.js +336 -0
- package/dist/module/bundler/css-processor/rn.d.ts +10 -0
- package/dist/module/bundler/css-processor/rn.js +400 -0
- package/dist/module/bundler/css-processor/serialize.d.ts +2 -0
- package/dist/module/bundler/css-processor/serialize.js +101 -0
- package/dist/module/bundler/css-processor/types.d.ts +28 -0
- package/dist/module/bundler/css-processor/types.js +0 -0
- package/dist/module/bundler/css-processor/units.d.ts +10 -0
- package/dist/module/bundler/css-processor/units.js +48 -0
- package/dist/module/bundler/css-processor/utils.d.ts +23 -0
- package/dist/{shared/uniwind.PtWWxxnh.mjs → module/bundler/css-processor/utils.js} +12 -18
- package/dist/module/bundler/css-processor/var.d.ts +7 -0
- package/dist/module/bundler/css-processor/var.js +13 -0
- package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.d.ts +1 -1
- package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.d.ts +4 -3
- package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.js +7 -7
- package/dist/module/{css-visitor → bundler/css-visitor}/visitor.d.ts +3 -3
- package/dist/module/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/module/bundler/logger.d.ts +12 -0
- package/dist/module/bundler/logger.js +37 -0
- package/dist/module/bundler/types.d.ts +15 -0
- package/dist/module/bundler/types.js +0 -0
- package/dist/module/common/consts.d.ts +21 -0
- package/dist/module/common/consts.js +24 -0
- package/dist/module/components/ScopedTheme/ScopedTheme.native.d.ts +1 -1
- package/dist/module/components/native/Pressable.d.ts +1 -1
- package/dist/module/components/native/TouchableHighlight.d.ts +1 -1
- package/dist/module/components/native/TouchableOpacity.d.ts +1 -1
- package/dist/module/components/native/useAccentColor.d.ts +1 -1
- package/dist/module/components/native/useStyle.d.ts +3 -3
- package/dist/module/components/react-native-gesture-handler/native/BaseButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/BorderlessButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/DrawerLayoutAndroid.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/FlatList.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Pressable.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/PureNativeButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RawButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RectButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RefreshControl.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/ScrollView.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Switch.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Text.d.ts +4 -1
- package/dist/module/components/react-native-gesture-handler/native/TextInput.d.ts +1 -1
- package/dist/module/components/web/Pressable.d.ts +1 -1
- package/dist/module/components/web/TouchableHighlight.d.ts +1 -1
- package/dist/module/components/web/TouchableOpacity.d.ts +1 -1
- package/dist/module/components/web/rnw.js +1 -1
- package/dist/module/core/config/config.common.d.ts +6 -7
- package/dist/module/core/config/config.common.js +2 -2
- package/dist/module/core/config/config.d.ts +1 -1
- package/dist/module/core/config/config.js +1 -1
- package/dist/module/core/config/config.native.d.ts +2 -2
- package/dist/module/core/config/config.native.js +2 -6
- package/dist/module/core/listener.d.ts +1 -1
- package/dist/module/core/listener.js +1 -1
- package/dist/module/core/native/native-utils.d.ts +0 -1
- package/dist/module/core/native/native-utils.js +0 -6
- package/dist/module/core/native/parsers/textShadow.js +6 -18
- package/dist/module/core/native/parsers/transforms.js +1 -5
- package/dist/module/core/native/runtime.js +5 -1
- package/dist/module/core/native/store.d.ts +3 -3
- package/dist/module/core/native/store.js +22 -65
- package/dist/module/core/types.d.ts +12 -7
- package/dist/module/core/web/cssListener.js +1 -1
- package/dist/module/core/web/getWebStyles.d.ts +1 -1
- package/dist/module/hoc/types.d.ts +2 -2
- package/dist/module/hoc/withUniwind.d.ts +1 -1
- package/dist/module/hoc/withUniwind.js +5 -5
- package/dist/module/hoc/withUniwind.native.d.ts +1 -1
- package/dist/module/hoc/withUniwind.native.js +5 -5
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.js +4 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +5 -1
- package/dist/module/hooks/useResolveClassNames.d.ts +1 -1
- package/dist/module/hooks/useUniwind.d.ts +1 -1
- package/dist/module/hooks/useUniwind.js +1 -1
- package/dist/module/index.d.ts +1 -2
- package/dist/shared/{uniwind.r2i22V6d.cjs → uniwind.BEqYiPBB.cjs} +319 -217
- package/dist/shared/uniwind.CFAAUZ2t.mjs +3 -0
- package/dist/shared/uniwind.DJ5M1Q4q.cjs +5 -0
- package/dist/shared/{uniwind.BGiqYvxb.mjs → uniwind.DgC4MT51.mjs} +312 -214
- package/dist/vite/index.cjs +82 -59
- package/dist/vite/index.mjs +80 -58
- package/package.json +37 -21
- package/src/{metro → bundler/adapters/metro}/index.d.ts +2 -0
- package/src/bundler/adapters/metro/index.ts +1 -0
- package/src/bundler/adapters/metro/metro.ts +67 -0
- package/src/{metro/metro-css-patches.ts → bundler/adapters/metro/patches.ts} +3 -2
- package/src/{metro → bundler/adapters/metro}/resolvers.ts +8 -8
- package/src/bundler/adapters/metro/transformer.ts +85 -0
- package/src/bundler/adapters/vite/vite.ts +148 -0
- package/src/{css → bundler/artifacts/css}/extraUtilities.ts +1 -1
- package/src/{css → bundler/artifacts/css}/index.ts +1 -5
- package/src/{css → bundler/artifacts/css}/themes.ts +7 -2
- package/src/{utils/buildDtsFile.ts → bundler/artifacts/dts.ts} +3 -4
- package/src/bundler/cli/index.ts +105 -0
- package/src/bundler/config.ts +94 -0
- package/src/bundler/css-compiler/compileCSS.ts +15 -0
- package/src/bundler/css-compiler/compileNativeCSS.ts +41 -0
- package/src/bundler/css-compiler/compileTailwind.ts +25 -0
- package/src/bundler/css-compiler/compileWebCSS.ts +10 -0
- package/src/bundler/css-compiler/index.ts +1 -0
- package/src/{metro → bundler/css-processor}/addMetaToStylesTemplate.ts +36 -17
- package/src/{metro/processor → bundler/css-processor}/animation.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/color.ts +5 -4
- package/src/{metro/processor → bundler/css-processor}/css.ts +19 -11
- package/src/{metro/processor → bundler/css-processor}/functions.ts +2 -2
- package/src/bundler/css-processor/index.ts +3 -0
- package/src/{metro/processor → bundler/css-processor}/mq.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/processor.ts +20 -18
- package/src/{metro/processor → bundler/css-processor}/rn.ts +96 -3
- package/src/{metro/utils → bundler/css-processor}/serialize.ts +2 -2
- package/src/{metro → bundler/css-processor}/types.ts +3 -17
- package/src/{metro/processor → bundler/css-processor}/units.ts +2 -2
- package/src/{metro/utils/common.ts → bundler/css-processor/utils.ts} +2 -5
- package/src/{metro/processor → bundler/css-processor}/var.ts +2 -2
- package/src/{css-visitor → bundler/css-visitor}/function-visitor.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/rule-visitor.ts +8 -7
- package/src/{css-visitor → bundler/css-visitor}/visitor.ts +4 -3
- package/src/{metro → bundler}/logger.ts +4 -0
- package/src/bundler/types.ts +17 -0
- package/src/common/consts.ts +25 -0
- package/src/components/ScopedTheme/ScopedTheme.native.tsx +1 -1
- package/src/components/native/ActivityIndicator.tsx +2 -1
- package/src/components/native/Button.tsx +2 -1
- package/src/components/native/FlatList.tsx +2 -1
- package/src/components/native/Image.tsx +2 -1
- package/src/components/native/ImageBackground.tsx +2 -1
- package/src/components/native/InputAccessoryView.tsx +3 -2
- package/src/components/native/KeyboardAvoidingView.tsx +2 -1
- package/src/components/native/Modal.tsx +2 -1
- package/src/components/native/Pressable.tsx +1 -1
- package/src/components/native/RefreshControl.tsx +2 -1
- package/src/components/native/SafeAreaView.tsx +2 -1
- package/src/components/native/ScrollView.tsx +2 -1
- package/src/components/native/SectionList.tsx +2 -1
- package/src/components/native/Switch.tsx +3 -2
- package/src/components/native/Text.tsx +3 -2
- package/src/components/native/TextInput.tsx +3 -2
- package/src/components/native/TouchableHighlight.tsx +3 -2
- package/src/components/native/TouchableNativeFeedback.tsx +3 -2
- package/src/components/native/TouchableOpacity.tsx +3 -2
- package/src/components/native/TouchableWithoutFeedback.tsx +3 -2
- package/src/components/native/View.tsx +2 -1
- package/src/components/native/VirtualizedList.tsx +2 -1
- package/src/components/native/useAccentColor.ts +1 -1
- package/src/components/native/useStyle.ts +2 -2
- package/src/components/react-native-gesture-handler/native/BaseButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/BorderlessButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/DrawerLayoutAndroid.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/FlatList.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/GestureHandlerRootView.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/Pressable.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/PureNativeButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RawButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RectButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/ScrollView.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/Switch.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/Text.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TextInput.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableNativeFeedback.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableOpacity.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableWithoutFeedback.tsx +2 -2
- package/src/components/web/ActivityIndicator.tsx +2 -1
- package/src/components/web/Button.tsx +2 -1
- package/src/components/web/FlatList.tsx +2 -1
- package/src/components/web/Image.tsx +2 -1
- package/src/components/web/ImageBackground.tsx +2 -1
- package/src/components/web/KeyboardAvoidingView.tsx +2 -1
- package/src/components/web/Modal.tsx +2 -1
- package/src/components/web/Pressable.tsx +2 -1
- package/src/components/web/RefreshControl.tsx +2 -1
- package/src/components/web/SafeAreaView.tsx +2 -1
- package/src/components/web/ScrollView.tsx +2 -1
- package/src/components/web/SectionList.tsx +2 -1
- package/src/components/web/Switch.tsx +2 -1
- package/src/components/web/Text.tsx +2 -1
- package/src/components/web/TextInput.tsx +2 -1
- package/src/components/web/TouchableHighlight.tsx +2 -1
- package/src/components/web/TouchableOpacity.tsx +2 -1
- package/src/components/web/TouchableWithoutFeedback.tsx +2 -1
- package/src/components/web/View.tsx +2 -1
- package/src/components/web/VirtualizedList.tsx +2 -1
- package/src/components/web/rnw.ts +1 -1
- package/src/core/config/config.common.ts +11 -9
- package/src/core/config/config.native.ts +4 -8
- package/src/core/config/config.ts +2 -2
- package/src/core/listener.ts +1 -1
- package/src/core/native/native-utils.ts +0 -9
- package/src/core/native/parsers/textShadow.ts +6 -18
- package/src/core/native/parsers/transforms.ts +1 -5
- package/src/core/native/runtime.ts +6 -1
- package/src/core/native/store.ts +26 -69
- package/src/core/types.ts +13 -7
- package/src/core/web/cssListener.ts +1 -1
- package/src/core/web/getWebStyles.ts +1 -1
- package/src/hoc/types.ts +2 -2
- package/src/hoc/withUniwind.native.tsx +4 -3
- package/src/hoc/withUniwind.tsx +3 -2
- package/src/hooks/useCSSVariable/getVariableValue.native.ts +6 -3
- package/src/hooks/useCSSVariable/useCSSVariable.ts +8 -2
- package/src/hooks/useResolveClassNames.ts +1 -1
- package/src/hooks/useUniwind.ts +2 -2
- package/src/index.ts +1 -2
- package/dist/common/types.js +0 -28
- package/dist/common/utils/stringifyThemes.js +0 -8
- package/dist/common/vite/vite.js +0 -95
- package/dist/module/types.d.ts +0 -21
- package/dist/module/types.js +0 -22
- package/dist/module/utils/stringifyThemes.d.ts +0 -1
- package/dist/module/utils/stringifyThemes.js +0 -1
- package/dist/module/vite/index.d.ts +0 -9
- package/dist/module/vite/index.js +0 -1
- package/dist/module/vite/vite.d.ts +0 -8
- package/dist/module/vite/vite.js +0 -98
- package/dist/shared/uniwind.B5q8hBGv.cjs +0 -18
- package/dist/shared/uniwind.Cv73KtI-.cjs +0 -86
- package/dist/shared/uniwind.JSWK3vHl.mjs +0 -14
- package/src/metro/compileVirtual.ts +0 -85
- package/src/metro/index.ts +0 -1
- package/src/metro/injectThemes.ts +0 -23
- package/src/metro/metro-transformer.ts +0 -116
- package/src/metro/processor/index.ts +0 -1
- package/src/metro/utils/index.ts +0 -2
- package/src/metro/withUniwindConfig.ts +0 -61
- package/src/types.ts +0 -23
- package/src/utils/stringifyThemes.ts +0 -1
- package/src/vite/index.d.ts +0 -9
- package/src/vite/vite.ts +0 -113
- /package/dist/common/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/insets.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/overwrite.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/variants.js +0 -0
- /package/dist/common/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
- /package/dist/common/{css-visitor → bundler/css-visitor}/index.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/insets.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/insets.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/overwrite.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/overwrite.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/themes.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/variants.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/variants.js +0 -0
- /package/dist/module/{utils/buildDtsFile.d.ts → bundler/artifacts/dts.d.ts} +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/index.d.ts +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/index.js +0 -0
- /package/{dist/common → src/bundler/adapters}/vite/index.d.ts +0 -0
- /package/src/{vite → bundler/adapters/vite}/index.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/insets.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/overwrite.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/variants.ts +0 -0
- /package/src/{css-visitor → bundler/css-visitor}/index.ts +0 -0
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { Platform } from '
|
|
2
|
-
import { isDefined } from '
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { StyleSheetTemplate } from './types'
|
|
6
|
-
import {
|
|
1
|
+
import { Platform, StyleDependency } from '@/common/consts'
|
|
2
|
+
import { isDefined } from '@/common/utils'
|
|
3
|
+
import type { ProcessorBuilder } from './processor'
|
|
4
|
+
import { serialize } from './serialize'
|
|
5
|
+
import type { StyleSheetTemplate } from './types'
|
|
6
|
+
import { toCamelCase } from './utils'
|
|
7
7
|
|
|
8
8
|
const extractVarsFromString = (value: string) => {
|
|
9
|
-
const
|
|
9
|
+
const varsIndexes = [...value.matchAll(/vars\[/g)].map(m => m.index)
|
|
10
10
|
|
|
11
|
-
return
|
|
11
|
+
return varsIndexes.map(index => {
|
|
12
12
|
const afterIndex = value.slice(index + 5)
|
|
13
13
|
const closingIndex = afterIndex.indexOf(']')
|
|
14
14
|
const varName = afterIndex.slice(0, closingIndex)
|
|
@@ -29,6 +29,30 @@ const makeSafeForSerialization = (value: any) => {
|
|
|
29
29
|
return value
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
+
const hasThemedVarDependency = (varName: string, Processor: ProcessorBuilder, visited = new Set<string>()): boolean => {
|
|
33
|
+
if (visited.has(varName)) {
|
|
34
|
+
return false
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
visited.add(varName)
|
|
38
|
+
|
|
39
|
+
const isScopedVar = Object.values(Processor.scopedVars).some(scopedVars => varName in scopedVars)
|
|
40
|
+
|
|
41
|
+
if (isScopedVar) {
|
|
42
|
+
return true
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const globalVarValue = Processor.vars[varName]
|
|
46
|
+
|
|
47
|
+
if (typeof globalVarValue !== 'string') {
|
|
48
|
+
return false
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return extractVarsFromString(globalVarValue).some(usedVarName => {
|
|
52
|
+
return hasThemedVarDependency(usedVarName, Processor, visited)
|
|
53
|
+
})
|
|
54
|
+
}
|
|
55
|
+
|
|
32
56
|
export const addMetaToStylesTemplate = (Processor: ProcessorBuilder, currentPlatform: Platform) => {
|
|
33
57
|
const stylesheetsEntries = Object.entries(Processor.stylesheets as StyleSheetTemplate)
|
|
34
58
|
.map(([className, stylesPerMediaQuery]) => {
|
|
@@ -52,7 +76,7 @@ export const addMetaToStylesTemplate = (Processor: ProcessorBuilder, currentPlat
|
|
|
52
76
|
|
|
53
77
|
const entries = Object.entries(rest)
|
|
54
78
|
.flatMap(([property, value]) => Processor.RN.cssToRN(property, value))
|
|
55
|
-
.map(([property, value]) => [`"${property}"`, `function() { return ${serialize(value)} }`])
|
|
79
|
+
.map(([property, value]) => [`"${property}"`, `function(vars) { return ${serialize(value)} }`])
|
|
56
80
|
|
|
57
81
|
if (platform) {
|
|
58
82
|
const isTV = currentPlatform === Platform.AndroidTV || currentPlatform === Platform.AppleTV
|
|
@@ -70,13 +94,7 @@ export const addMetaToStylesTemplate = (Processor: ProcessorBuilder, currentPlat
|
|
|
70
94
|
const dependencies: Array<StyleDependency> = []
|
|
71
95
|
const stringifiedEntries = JSON.stringify(entries)
|
|
72
96
|
const usedVars = extractVarsFromString(stringifiedEntries)
|
|
73
|
-
const isUsingThemedVar = usedVars.some(usedVarName =>
|
|
74
|
-
return Object.values(Processor.scopedVars).some(scopedVars => {
|
|
75
|
-
const scopedVarsNames = Object.keys(scopedVars)
|
|
76
|
-
|
|
77
|
-
return scopedVarsNames.includes(usedVarName)
|
|
78
|
-
})
|
|
79
|
-
})
|
|
97
|
+
const isUsingThemedVar = usedVars.some(usedVarName => hasThemedVarDependency(usedVarName, Processor))
|
|
80
98
|
|
|
81
99
|
if (usedVars.length > 0) {
|
|
82
100
|
dependencies.push(StyleDependency.Variables)
|
|
@@ -97,6 +115,7 @@ export const addMetaToStylesTemplate = (Processor: ProcessorBuilder, currentPlat
|
|
|
97
115
|
if (
|
|
98
116
|
Number(minWidth) !== 0
|
|
99
117
|
|| Number(maxWidth) !== Number.MAX_VALUE
|
|
118
|
+
|| stringifiedEntries.includes('rt.makeResponsive')
|
|
100
119
|
|| stringifiedEntries.includes('rt.screen')
|
|
101
120
|
) {
|
|
102
121
|
dependencies.push(StyleDependency.Dimensions)
|
|
@@ -126,7 +145,7 @@ export const addMetaToStylesTemplate = (Processor: ProcessorBuilder, currentPlat
|
|
|
126
145
|
focus,
|
|
127
146
|
disabled,
|
|
128
147
|
importantProperties: importantProperties
|
|
129
|
-
?.map(property => property.startsWith('--') ? property : toCamelCase)
|
|
148
|
+
?.map(property => property.startsWith('--') ? property : toCamelCase(property))
|
|
130
149
|
.map(makeSafeForSerialization) ?? [],
|
|
131
150
|
dataAttributes,
|
|
132
151
|
complexity: [
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { TokenOrValue } from 'lightningcss'
|
|
2
|
-
import type { DeclarationValues } from '../types'
|
|
3
|
-
import { toCamelCase } from '../utils'
|
|
4
2
|
|
|
5
|
-
import {
|
|
3
|
+
import type {
|
|
6
4
|
CSSAnimationDelay,
|
|
7
5
|
} from 'react-native-reanimated'
|
|
8
|
-
import { ParametrizedTimingFunction } from 'react-native-reanimated/lib/typescript/css/easing'
|
|
6
|
+
import type { ParametrizedTimingFunction } from 'react-native-reanimated/lib/typescript/css/easing'
|
|
7
|
+
import type { DeclarationValues } from './types'
|
|
8
|
+
import { toCamelCase } from './utils'
|
|
9
9
|
|
|
10
10
|
type GetProcessedValue = (value: DeclarationValues) => any
|
|
11
11
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Color as ColorType
|
|
2
|
-
import {
|
|
1
|
+
import type { Color as ColorType } from 'culori'
|
|
2
|
+
import { converter, formatHex, formatHex8, parse } from 'culori'
|
|
3
|
+
import type { CssColor, UnresolvedColor } from 'lightningcss'
|
|
3
4
|
import { Logger } from '../logger'
|
|
4
|
-
import { pipe } from '../utils'
|
|
5
5
|
import type { ProcessorBuilder } from './processor'
|
|
6
|
+
import { pipe } from './utils'
|
|
6
7
|
|
|
7
8
|
export class Color {
|
|
8
9
|
private toRgb = converter('rgb')
|
|
@@ -36,7 +37,7 @@ export class Color {
|
|
|
36
37
|
|
|
37
38
|
try {
|
|
38
39
|
if (color.type === 'currentcolor') {
|
|
39
|
-
return '
|
|
40
|
+
return 'vars["currentColor"]?.(vars)'
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
if (color.type === 'rgb' || color.type === 'srgb') {
|
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { isDefined } from '../../common/utils'
|
|
3
|
+
import { isDefined } from '@/common/utils'
|
|
4
|
+
import type { Animation, Filter, OverflowKeyword, TokenOrValue } from 'lightningcss'
|
|
6
5
|
import { Logger } from '../logger'
|
|
7
|
-
import { DeclarationValues } from '../types'
|
|
8
|
-
import { deepEqual, pipe, roundToPrecision, shouldBeSerialized, toCamelCase } from '../utils'
|
|
9
6
|
import { getProcessedAnimation, getProcessedVarAnimation } from './animation'
|
|
10
7
|
import type { ProcessorBuilder } from './processor'
|
|
8
|
+
import type { DeclarationProperty, DeclarationValues } from './types'
|
|
9
|
+
import { deepEqual, pipe, roundToPrecision, shouldBeSerialized, toCamelCase } from './utils'
|
|
11
10
|
|
|
12
11
|
export class CSS {
|
|
13
12
|
private readonly logger = new Logger('CSS')
|
|
14
13
|
|
|
15
14
|
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
16
15
|
|
|
17
|
-
processValue(declarationValue: DeclarationValues): any {
|
|
18
|
-
const processedValue = this.getProcessedValue(declarationValue)
|
|
16
|
+
processValue(declarationValue: DeclarationValues, declarationProperty?: DeclarationProperty): any {
|
|
17
|
+
const processedValue = this.getProcessedValue(declarationValue, declarationProperty)
|
|
19
18
|
|
|
20
19
|
if (typeof processedValue === 'string') {
|
|
21
20
|
return this.makeSafeForSerialization(processedValue)
|
|
@@ -106,7 +105,7 @@ export class CSS {
|
|
|
106
105
|
return filterStrings.join(' ')
|
|
107
106
|
}
|
|
108
107
|
|
|
109
|
-
private getProcessedValue(declarationValue: DeclarationValues): any {
|
|
108
|
+
private getProcessedValue(declarationValue: DeclarationValues, declarationProperty?: DeclarationProperty): any {
|
|
110
109
|
if (typeof declarationValue !== 'object') {
|
|
111
110
|
return declarationValue
|
|
112
111
|
}
|
|
@@ -274,7 +273,7 @@ export class CSS {
|
|
|
274
273
|
}
|
|
275
274
|
|
|
276
275
|
if (declarationValue.value === 'currentcolor') {
|
|
277
|
-
return '
|
|
276
|
+
return 'vars["currentColor"]?.(vars)'
|
|
278
277
|
}
|
|
279
278
|
|
|
280
279
|
return declarationValue.value
|
|
@@ -318,7 +317,7 @@ export class CSS {
|
|
|
318
317
|
case 'pair':
|
|
319
318
|
return declarationValue.inside.type
|
|
320
319
|
case 'currentcolor':
|
|
321
|
-
return '
|
|
320
|
+
return 'vars["currentColor"]?.(vars)'
|
|
322
321
|
case 'calc':
|
|
323
322
|
return this.Processor.Functions.processCalc(declarationValue.value)
|
|
324
323
|
case 'min':
|
|
@@ -424,11 +423,20 @@ export class CSS {
|
|
|
424
423
|
}
|
|
425
424
|
|
|
426
425
|
if ('grow' in declarationValue) {
|
|
427
|
-
|
|
426
|
+
const parsedFlex = {
|
|
428
427
|
flexGrow: declarationValue.grow,
|
|
429
428
|
flexShrink: declarationValue.shrink,
|
|
430
429
|
flexBasis: this.processValue(declarationValue.basis),
|
|
431
430
|
}
|
|
431
|
+
|
|
432
|
+
// CSS `flex: 1` is a shorthand for `flex-grow: 1; flex-shrink: 1; flex-basis: 0%` but for native we just want flex: 1
|
|
433
|
+
if (declarationProperty === 'flex' && parsedFlex.flexGrow === 1 && parsedFlex.flexShrink === 1 && parsedFlex.flexBasis === '"0%"') {
|
|
434
|
+
return {
|
|
435
|
+
flex: 1,
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
return parsedFlex
|
|
432
440
|
}
|
|
433
441
|
|
|
434
442
|
if (Array.isArray(declarationValue)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { CalcFor_DimensionPercentageFor_LengthValue, CalcFor_Length, CssColor, Function as FunctionType } from 'lightningcss'
|
|
1
|
+
import type { CalcFor_DimensionPercentageFor_LengthValue, CalcFor_Length, CssColor, Function as FunctionType } from 'lightningcss'
|
|
2
2
|
import { Logger } from '../logger'
|
|
3
|
-
import { pipe } from '../utils'
|
|
4
3
|
import type { ProcessorBuilder } from './processor'
|
|
4
|
+
import { pipe } from './utils'
|
|
5
5
|
|
|
6
6
|
export class Functions {
|
|
7
7
|
private readonly logger = new Logger('Functions')
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Platform } from '
|
|
3
|
-
import {
|
|
4
|
-
import { MediaQueryResolver } from '../types'
|
|
1
|
+
import type { ColorScheme, Orientation } from '@/common/consts'
|
|
2
|
+
import { Platform } from '@/common/consts'
|
|
3
|
+
import type { MediaCondition, MediaQuery, QueryFeatureFor_MediaFeatureId } from 'lightningcss'
|
|
5
4
|
import type { ProcessorBuilder } from './processor'
|
|
5
|
+
import type { MediaQueryResolver } from './types'
|
|
6
6
|
|
|
7
7
|
export class MQ {
|
|
8
8
|
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { UNIWIND_PLATFORM_VARIABLES, UNIWIND_THEME_VARIABLES } from '@/common/consts'
|
|
2
|
+
import type { Declaration, MediaQuery, Rule } from 'lightningcss'
|
|
3
|
+
import { transform } from 'lightningcss'
|
|
4
|
+
import type { CSSAnimationKeyframes } from 'react-native-reanimated'
|
|
4
5
|
import { parseTransformsMutation } from '../../core/native/parsers/transforms'
|
|
5
|
-
import {
|
|
6
|
+
import type { UniwindBundlerConfig } from '../config'
|
|
6
7
|
import { Color } from './color'
|
|
7
8
|
import { CSS } from './css'
|
|
8
9
|
import { Functions } from './functions'
|
|
9
10
|
import { MQ } from './mq'
|
|
10
11
|
import { RN } from './rn'
|
|
12
|
+
import type { AnimationFrame, DeclarationProperty, MediaQueryResolver, ProcessMetaValues } from './types'
|
|
11
13
|
import { Units } from './units'
|
|
12
14
|
import { Var } from './var'
|
|
13
15
|
|
|
@@ -29,8 +31,8 @@ export class ProcessorBuilder {
|
|
|
29
31
|
private pendingVarReferences = new Map<string, [Array<string>, boolean]>()
|
|
30
32
|
private declarationConfig = this.getDeclarationConfig()
|
|
31
33
|
|
|
32
|
-
constructor(
|
|
33
|
-
this.vars['--uniwind-em'] = polyfills?.rem ?? 16
|
|
34
|
+
constructor(public readonly bundlerConfig: UniwindBundlerConfig) {
|
|
35
|
+
this.vars['--uniwind-em'] = this.bundlerConfig.polyfills?.rem ?? 16
|
|
34
36
|
}
|
|
35
37
|
|
|
36
38
|
transform(css: string) {
|
|
@@ -143,7 +145,7 @@ export class ProcessorBuilder {
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
// Track variable references for later processing (even if media queries don't exist yet)
|
|
146
|
-
const match = typeof value === 'string' ? value.match(/
|
|
148
|
+
const match = typeof value === 'string' ? value.match(/vars\["(.*?)"\]/) : null
|
|
147
149
|
|
|
148
150
|
if (match && !isVar) {
|
|
149
151
|
const className = this.declarationConfig.className
|
|
@@ -209,16 +211,16 @@ export class ProcessorBuilder {
|
|
|
209
211
|
}
|
|
210
212
|
|
|
211
213
|
private parseDeclaration(declaration: Declaration) {
|
|
212
|
-
const parseValue = (property:
|
|
214
|
+
const parseValue = (property: DeclarationProperty, value: any) => {
|
|
213
215
|
if (property === 'animation') {
|
|
214
216
|
return this.CSS.processAnimation(value)
|
|
215
217
|
}
|
|
216
218
|
|
|
217
|
-
return this.CSS.processValue(value)
|
|
219
|
+
return this.CSS.processValue(value, property)
|
|
218
220
|
}
|
|
219
221
|
|
|
220
222
|
if (declaration.property === 'unparsed') {
|
|
221
|
-
const property = declaration.value.propertyId.property
|
|
223
|
+
const property = declaration.value.propertyId.property as DeclarationProperty
|
|
222
224
|
|
|
223
225
|
return {
|
|
224
226
|
property,
|
|
@@ -227,7 +229,7 @@ export class ProcessorBuilder {
|
|
|
227
229
|
}
|
|
228
230
|
|
|
229
231
|
if (declaration.property === 'custom') {
|
|
230
|
-
const property = declaration.value.name
|
|
232
|
+
const property = declaration.value.name as DeclarationProperty
|
|
231
233
|
|
|
232
234
|
return {
|
|
233
235
|
property,
|
|
@@ -278,7 +280,7 @@ export class ProcessorBuilder {
|
|
|
278
280
|
if (selector.type === 'pseudo-class' && selector.kind === 'where') {
|
|
279
281
|
selector.selectors.forEach(selector => {
|
|
280
282
|
selector.forEach(selector => {
|
|
281
|
-
if (selector.type === 'class' && this.themes.includes(selector.name)) {
|
|
283
|
+
if (selector.type === 'class' && this.bundlerConfig.themes.includes(selector.name)) {
|
|
282
284
|
theme = selector.name
|
|
283
285
|
}
|
|
284
286
|
|
|
@@ -315,12 +317,12 @@ export class ProcessorBuilder {
|
|
|
315
317
|
})
|
|
316
318
|
|
|
317
319
|
if ([rtl, theme, active, focus, disabled, dataAttributes].some(Boolean)) {
|
|
318
|
-
this.declarationConfig.rtl
|
|
319
|
-
this.declarationConfig.theme
|
|
320
|
-
this.declarationConfig.active
|
|
321
|
-
this.declarationConfig.focus
|
|
322
|
-
this.declarationConfig.disabled
|
|
323
|
-
this.declarationConfig.dataAttributes
|
|
320
|
+
this.declarationConfig.rtl ??= rtl
|
|
321
|
+
this.declarationConfig.theme ??= theme
|
|
322
|
+
this.declarationConfig.active ??= active
|
|
323
|
+
this.declarationConfig.focus ??= focus
|
|
324
|
+
this.declarationConfig.disabled ??= disabled
|
|
325
|
+
this.declarationConfig.dataAttributes ??= dataAttributes
|
|
324
326
|
|
|
325
327
|
rule.value.declarations?.declarations?.forEach(declaration => this.addDeclaration(declaration))
|
|
326
328
|
rule.value.declarations?.importantDeclarations?.forEach(declaration => this.addDeclaration(declaration, true))
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { DEFAULT_SCREEN_HEIGHT, DEFAULT_SCREEN_WIDTH } from '@/common/consts'
|
|
2
|
+
import { isDefined } from '@/common/utils'
|
|
3
3
|
import type { ProcessorBuilder } from './processor'
|
|
4
|
+
import { addMissingSpaces, pipe, removeKeys, toCamelCase } from './utils'
|
|
4
5
|
|
|
5
6
|
const transitions: Record<string, any> = { overlay: '"overlayColor"' }
|
|
6
7
|
|
|
@@ -233,6 +234,59 @@ const BORDER_WIDTH_KEYS = ['borderTopWidth', 'borderRightWidth', 'borderBottomWi
|
|
|
233
234
|
const BORDER_COLOR_KEYS = ['borderTopColor', 'borderRightColor', 'borderBottomColor', 'borderLeftColor']
|
|
234
235
|
const BORDER_RADIUS_KEYS = ['borderTopLeftRadius', 'borderTopRightRadius', 'borderBottomLeftRadius', 'borderBottomRightRadius']
|
|
235
236
|
|
|
237
|
+
const COMPONENT_RESPONSIVE_PROPS = new Set([
|
|
238
|
+
'width',
|
|
239
|
+
'height',
|
|
240
|
+
'minWidth',
|
|
241
|
+
'maxWidth',
|
|
242
|
+
'minHeight',
|
|
243
|
+
'maxHeight',
|
|
244
|
+
'padding',
|
|
245
|
+
'paddingTop',
|
|
246
|
+
'paddingRight',
|
|
247
|
+
'paddingBottom',
|
|
248
|
+
'paddingLeft',
|
|
249
|
+
'paddingHorizontal',
|
|
250
|
+
'paddingVertical',
|
|
251
|
+
'paddingStart',
|
|
252
|
+
'paddingEnd',
|
|
253
|
+
'margin',
|
|
254
|
+
'marginTop',
|
|
255
|
+
'marginRight',
|
|
256
|
+
'marginBottom',
|
|
257
|
+
'marginLeft',
|
|
258
|
+
'marginHorizontal',
|
|
259
|
+
'marginVertical',
|
|
260
|
+
'marginStart',
|
|
261
|
+
'marginEnd',
|
|
262
|
+
'top',
|
|
263
|
+
'right',
|
|
264
|
+
'bottom',
|
|
265
|
+
'left',
|
|
266
|
+
'gap',
|
|
267
|
+
'rowGap',
|
|
268
|
+
'columnGap',
|
|
269
|
+
'borderWidth',
|
|
270
|
+
'borderTopWidth',
|
|
271
|
+
'borderRightWidth',
|
|
272
|
+
'borderBottomWidth',
|
|
273
|
+
'borderLeftWidth',
|
|
274
|
+
'borderStartWidth',
|
|
275
|
+
'borderEndWidth',
|
|
276
|
+
'borderRadius',
|
|
277
|
+
'borderTopLeftRadius',
|
|
278
|
+
'borderTopRightRadius',
|
|
279
|
+
'borderBottomLeftRadius',
|
|
280
|
+
'borderBottomRightRadius',
|
|
281
|
+
'borderTopStartRadius',
|
|
282
|
+
'borderTopEndRadius',
|
|
283
|
+
'borderBottomStartRadius',
|
|
284
|
+
'borderBottomEndRadius',
|
|
285
|
+
'flexBasis',
|
|
286
|
+
'translateX',
|
|
287
|
+
'translateY',
|
|
288
|
+
])
|
|
289
|
+
|
|
236
290
|
export class RN {
|
|
237
291
|
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
238
292
|
|
|
@@ -266,7 +320,46 @@ export class RN {
|
|
|
266
320
|
)
|
|
267
321
|
const joinedStyles = this.joinStyles(rn)
|
|
268
322
|
|
|
269
|
-
return Object.entries(joinedStyles)
|
|
323
|
+
return Object.entries(joinedStyles)
|
|
324
|
+
.filter(([, value]) => isDefined(value))
|
|
325
|
+
.map(([prop, val]) => [prop, this.makeResponsive(prop, val)]) as Array<[string, any]>
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
private makeResponsive(property: string, value: any): any {
|
|
329
|
+
const mode = this.Processor.bundlerConfig.polyfills?.responsive
|
|
330
|
+
|
|
331
|
+
if (!mode) {
|
|
332
|
+
return value
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
if (typeof value === 'string') {
|
|
336
|
+
const rawValue = value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value
|
|
337
|
+
|
|
338
|
+
if (rawValue.endsWith('%')) {
|
|
339
|
+
const numValue = parseFloat(rawValue)
|
|
340
|
+
|
|
341
|
+
if (!isNaN(numValue)) {
|
|
342
|
+
return `rt.makeResponsive(${numValue}, 100, true)`
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
if (typeof value !== 'number') {
|
|
348
|
+
return value
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
const isTextMode = mode === true || mode === 'text'
|
|
352
|
+
const isComponentMode = mode === true || mode === 'components'
|
|
353
|
+
|
|
354
|
+
if (isTextMode && (property === 'fontSize' || property === '--uniwind-em')) {
|
|
355
|
+
return `rt.makeResponsive(${value}, ${DEFAULT_SCREEN_HEIGHT}, true)`
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (isComponentMode && COMPONENT_RESPONSIVE_PROPS.has(property)) {
|
|
359
|
+
return `rt.makeResponsive(${value}, ${DEFAULT_SCREEN_WIDTH})`
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
return value
|
|
270
363
|
}
|
|
271
364
|
|
|
272
365
|
private transformProperty(property: string, value: any) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Logger } from '
|
|
2
|
-
import { addMissingSpaces, isNumber, isValidJSValue, pipe, roundToPrecision, smartSplit } from './
|
|
1
|
+
import { Logger } from '@/bundler/logger'
|
|
2
|
+
import { addMissingSpaces, isNumber, isValidJSValue, pipe, roundToPrecision, smartSplit } from './utils'
|
|
3
3
|
|
|
4
4
|
const parseStringValue = (value: string) => {
|
|
5
5
|
if (isValidJSValue(value)) {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ColorScheme, Orientation, Platform } from '@/common/consts'
|
|
1
2
|
import type {
|
|
2
3
|
AbsoluteFontWeight,
|
|
3
4
|
Declaration,
|
|
@@ -11,23 +12,6 @@ import type {
|
|
|
11
12
|
TokenOrValue,
|
|
12
13
|
UnresolvedColor,
|
|
13
14
|
} from 'lightningcss'
|
|
14
|
-
import { Platform } from '../common/consts'
|
|
15
|
-
import { ColorScheme, Orientation } from '../types'
|
|
16
|
-
|
|
17
|
-
export type Polyfills = {
|
|
18
|
-
rem?: number
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type UniwindConfig = {
|
|
22
|
-
cssEntryFile: string
|
|
23
|
-
themes: Array<string>
|
|
24
|
-
extraThemes?: Array<string>
|
|
25
|
-
extraComponents?: Record<string, string>
|
|
26
|
-
dtsFile?: string
|
|
27
|
-
polyfills?: Polyfills
|
|
28
|
-
debug?: boolean
|
|
29
|
-
isTV?: boolean
|
|
30
|
-
}
|
|
31
15
|
|
|
32
16
|
export type MediaQueryResolver = {
|
|
33
17
|
maxWidth: number | null
|
|
@@ -62,6 +46,8 @@ export type DeclarationValues =
|
|
|
62
46
|
| AbsoluteFontWeight
|
|
63
47
|
| UnresolvedColor
|
|
64
48
|
|
|
49
|
+
export type DeclarationProperty = Declaration['property']
|
|
50
|
+
|
|
65
51
|
export type ProcessMetaValues = {
|
|
66
52
|
className?: string | null
|
|
67
53
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DimensionPercentageFor_LengthValue, Length, LengthValue } from 'lightningcss'
|
|
1
|
+
import type { DimensionPercentageFor_LengthValue, Length, LengthValue } from 'lightningcss'
|
|
2
2
|
import { Logger } from '../logger'
|
|
3
3
|
import type { ProcessorBuilder } from './processor'
|
|
4
4
|
|
|
@@ -23,7 +23,7 @@ export class Units {
|
|
|
23
23
|
case 'rem':
|
|
24
24
|
return length.value * this.Processor.vars['--uniwind-em']
|
|
25
25
|
case 'em':
|
|
26
|
-
return `
|
|
26
|
+
return `vars["--uniwind-em"]?.(vars) * ${length.value}`
|
|
27
27
|
default:
|
|
28
28
|
this.logger.warn(`Unsupported unit - ${length.unit}`)
|
|
29
29
|
|
|
@@ -41,15 +41,12 @@ export const smartSplit = (str: string, separator = ' ' as string | RegExp) => {
|
|
|
41
41
|
export const addMissingSpaces = (str: string) =>
|
|
42
42
|
pipe(str)(
|
|
43
43
|
x => x.trim(),
|
|
44
|
-
x => x.replace(/([^ {])this/g, '$1 this'),
|
|
45
44
|
x => x.replace(/\](?=\d)/g, '] '),
|
|
46
45
|
x => x.replace(/\](?=")/g, '] '),
|
|
47
|
-
x => x.replace(/\)(
|
|
46
|
+
x => x.replace(/\)(?=[^\s,])/g, ') '),
|
|
48
47
|
x => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" '),
|
|
49
48
|
)
|
|
50
49
|
|
|
51
|
-
export const uniq = <T>(arr: Array<T>) => Array.from(new Set(arr))
|
|
52
|
-
|
|
53
50
|
export const isValidJSValue = (jsValueString: string) => {
|
|
54
51
|
try {
|
|
55
52
|
new Function(`const test = ${jsValueString}`)
|
|
@@ -67,7 +64,7 @@ export const shouldBeSerialized = (value: string) => {
|
|
|
67
64
|
|
|
68
65
|
return [
|
|
69
66
|
isNumber(value),
|
|
70
|
-
value.startsWith('
|
|
67
|
+
value.startsWith('vars['),
|
|
71
68
|
value.startsWith('rt.'),
|
|
72
69
|
/[*/+-]/.test(value),
|
|
73
70
|
value.includes('"'),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Variable } from 'lightningcss'
|
|
1
|
+
import type { Variable } from 'lightningcss'
|
|
2
2
|
import type { ProcessorBuilder } from './processor'
|
|
3
3
|
|
|
4
4
|
export class Var {
|
|
5
5
|
constructor(private readonly Processor: ProcessorBuilder) {}
|
|
6
6
|
|
|
7
7
|
processVar(variable: Variable): string {
|
|
8
|
-
const value = `
|
|
8
|
+
const value = `vars[${JSON.stringify(variable.name.ident)}]?.(vars)`
|
|
9
9
|
|
|
10
10
|
if (!variable.fallback || variable.fallback.length === 0) {
|
|
11
11
|
return value
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ReturnedDeclaration, ReturnedMediaQuery, ReturnedRule, Rule, SelectorComponent } from 'lightningcss'
|
|
1
|
+
import type { ReturnedDeclaration, ReturnedMediaQuery, ReturnedRule, Rule, SelectorComponent } from 'lightningcss'
|
|
2
|
+
import type { UniwindBundlerConfig } from '../config'
|
|
2
3
|
|
|
3
4
|
type LightningRuleVisitor = Rule<ReturnedDeclaration, ReturnedMediaQuery>
|
|
4
5
|
type LightningRuleVisitors = Partial<
|
|
@@ -12,7 +13,7 @@ export class RuleVisitor implements LightningRuleVisitors {
|
|
|
12
13
|
processedVariables = new Set<string>()
|
|
13
14
|
currentLayerName = ''
|
|
14
15
|
|
|
15
|
-
constructor(private readonly
|
|
16
|
+
constructor(private readonly bundlerConfig: UniwindBundlerConfig) {}
|
|
16
17
|
|
|
17
18
|
'layer-block' = (layer: Extract<LightningRuleVisitor, { type: 'layer-block' }>) => {
|
|
18
19
|
this.currentLayerName = layer.value.name?.join('') ?? ''
|
|
@@ -86,7 +87,7 @@ export class RuleVisitor implements LightningRuleVisitors {
|
|
|
86
87
|
return styleRule
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
const selectedVariant = this.themes.find(theme => whereSelector.name === theme)
|
|
90
|
+
const selectedVariant = this.bundlerConfig.themes.find(theme => whereSelector.name === theme)
|
|
90
91
|
|
|
91
92
|
if (selectedVariant === undefined || this.processedVariables.has(selectedVariant)) {
|
|
92
93
|
return styleRule
|
|
@@ -109,7 +110,7 @@ export class RuleVisitor implements LightningRuleVisitors {
|
|
|
109
110
|
styleRule: Extract<LightningRuleVisitor, { type: 'style' }>,
|
|
110
111
|
firstSelector: Extract<SelectorComponent, { type: 'class' }>,
|
|
111
112
|
): ReturnedRule | void {
|
|
112
|
-
const selectedVariant = this.themes.find(theme => firstSelector.name.includes(`${theme}:`))
|
|
113
|
+
const selectedVariant = this.bundlerConfig.themes.find(theme => firstSelector.name.includes(`${theme}:`))
|
|
113
114
|
|
|
114
115
|
if (selectedVariant === undefined || this.processedClassNames.has(firstSelector.name)) {
|
|
115
116
|
return
|
|
@@ -117,17 +118,17 @@ export class RuleVisitor implements LightningRuleVisitors {
|
|
|
117
118
|
|
|
118
119
|
this.processedClassNames.add(firstSelector.name)
|
|
119
120
|
|
|
120
|
-
return {
|
|
121
|
+
return this.removeNulls({
|
|
121
122
|
type: 'scope',
|
|
122
123
|
value: {
|
|
123
124
|
loc: styleRule.value.loc,
|
|
124
125
|
rules: [styleRule],
|
|
125
126
|
scopeStart: [[{ type: 'class', name: selectedVariant }]],
|
|
126
|
-
scopeEnd: this.themes
|
|
127
|
+
scopeEnd: this.bundlerConfig.themes
|
|
127
128
|
.filter(theme => theme !== selectedVariant)
|
|
128
129
|
.map(theme => [{ type: 'class', name: theme }]),
|
|
129
130
|
},
|
|
130
|
-
}
|
|
131
|
+
}) as ReturnedRule
|
|
131
132
|
}
|
|
132
133
|
|
|
133
134
|
// Fixes lightningcss serialization bug
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { CustomAtRules, Visitor } from 'lightningcss'
|
|
1
|
+
import type { CustomAtRules, Visitor } from 'lightningcss'
|
|
2
|
+
import type { UniwindBundlerConfig } from '../config'
|
|
2
3
|
import { FunctionVisitor } from './function-visitor'
|
|
3
4
|
import { RuleVisitor } from './rule-visitor'
|
|
4
5
|
|
|
@@ -7,8 +8,8 @@ export class UniwindCSSVisitor implements Visitor<CustomAtRules> {
|
|
|
7
8
|
Rule: Visitor<CustomAtRules>['Rule']
|
|
8
9
|
StyleSheet: Visitor<CustomAtRules>['StyleSheet']
|
|
9
10
|
|
|
10
|
-
constructor(
|
|
11
|
-
const ruleVisitor = new RuleVisitor(
|
|
11
|
+
constructor(bundlerConfig: UniwindBundlerConfig) {
|
|
12
|
+
const ruleVisitor = new RuleVisitor(bundlerConfig)
|
|
12
13
|
|
|
13
14
|
this.Function = new FunctionVisitor()
|
|
14
15
|
this.Rule = ruleVisitor
|
|
@@ -16,6 +16,10 @@ export class Logger {
|
|
|
16
16
|
console.log(`${blue}Uniwind ${meta}- ${message}${reset}`)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
static info(message: string) {
|
|
20
|
+
console.log(`${blue}[Uniwind] ${message}${reset}`)
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
static error(message: string, meta = '') {
|
|
20
24
|
console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`)
|
|
21
25
|
}
|