@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
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.RN = void 0;
|
|
7
|
+
var _consts = require("@/common/consts");
|
|
8
|
+
var _utils = require("@/common/utils");
|
|
9
|
+
var _utils2 = require("./utils");
|
|
10
|
+
const transitions = {
|
|
11
|
+
overlay: '"overlayColor"'
|
|
12
|
+
};
|
|
13
|
+
const cssToRNMap = {
|
|
14
|
+
backgroundSize: value => {
|
|
15
|
+
return {
|
|
16
|
+
resizeMode: value
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
transitionProperty: value => {
|
|
20
|
+
const properties = value.replace(/"/g, "").split(",").filter(token => token !== "" && !token.startsWith("--")).map(token => transitions[token.trim()] ?? `"${(0, _utils2.toCamelCase)(token.trim())}"`);
|
|
21
|
+
if (properties.length === 1 && ['"allowDiscrete"', '"normal"'].includes(properties[0])) {
|
|
22
|
+
const behavior = properties[0] === '"allowDiscrete"' ? "allow-discrete" : "normal";
|
|
23
|
+
return {
|
|
24
|
+
transitionBehavior: `"${behavior}"`
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
transitionProperty: properties
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
transitionDuration: value => {
|
|
32
|
+
return {
|
|
33
|
+
transitionDuration: value.includes('""') ? value.replace(/""/g, ",") : value
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
transitionTimingFunction: value => {
|
|
37
|
+
return {
|
|
38
|
+
transitionTimingFunction: value.includes('""') ? value.replace(/""/g, ",") : value
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
animation: value => {
|
|
42
|
+
if (Array.isArray(value)) {
|
|
43
|
+
const result = {};
|
|
44
|
+
for (const [key, val] of value) {
|
|
45
|
+
if (val === '"none"') {
|
|
46
|
+
continue;
|
|
47
|
+
}
|
|
48
|
+
const keyName = (0, _utils2.toCamelCase)(`animation-${key.replace(/^"|"$/g, "")}`);
|
|
49
|
+
if (key === "name") {
|
|
50
|
+
result[keyName] = typeof val === "string" ? val.split(",").map(v => v.startsWith('"') ? v : `"${v}"`) : val;
|
|
51
|
+
} else {
|
|
52
|
+
result[keyName] = val;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
animationName: value
|
|
59
|
+
};
|
|
60
|
+
},
|
|
61
|
+
flex: value => {
|
|
62
|
+
if (typeof value === "object") {
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
flex: value
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
overflow: value => {
|
|
70
|
+
if (typeof value === "object") {
|
|
71
|
+
return value;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
overflow: value
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
backdropFilter: () => ({}),
|
|
78
|
+
filter: value => ({
|
|
79
|
+
filter: value
|
|
80
|
+
}),
|
|
81
|
+
backgroundImage: value => ({
|
|
82
|
+
experimental_backgroundImage: value
|
|
83
|
+
}),
|
|
84
|
+
borderSpacing: () => ({}),
|
|
85
|
+
translate: value => {
|
|
86
|
+
if (typeof value === "object" && "x" in value && "y" in value) {
|
|
87
|
+
return {
|
|
88
|
+
translateX: value.x,
|
|
89
|
+
translateY: value.y
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
if (typeof value === "string") {
|
|
93
|
+
const [x, y] = value.split(" ");
|
|
94
|
+
return {
|
|
95
|
+
translateX: x,
|
|
96
|
+
translateY: y ?? x
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
return {};
|
|
100
|
+
},
|
|
101
|
+
rotate: value => {
|
|
102
|
+
if (typeof value === "object") {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
rotate: value
|
|
107
|
+
};
|
|
108
|
+
},
|
|
109
|
+
scale: value => {
|
|
110
|
+
if (typeof value === "object") {
|
|
111
|
+
return {
|
|
112
|
+
scaleX: value.x,
|
|
113
|
+
scaleY: value.y,
|
|
114
|
+
scaleZ: value.z
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
if (typeof value === "string") {
|
|
118
|
+
const [x, y, z] = value.split(" ");
|
|
119
|
+
return {
|
|
120
|
+
scaleX: x,
|
|
121
|
+
scaleY: y,
|
|
122
|
+
scaleZ: z
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
return {};
|
|
126
|
+
},
|
|
127
|
+
transform: value => {
|
|
128
|
+
if (typeof value === "string" || Array.isArray(value)) {
|
|
129
|
+
return {
|
|
130
|
+
transform: value
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
if (typeof value === "object") {
|
|
134
|
+
return Object.keys(value).length === 0 ? {
|
|
135
|
+
transform: []
|
|
136
|
+
} : value;
|
|
137
|
+
}
|
|
138
|
+
return {};
|
|
139
|
+
},
|
|
140
|
+
fontSize: value => {
|
|
141
|
+
return {
|
|
142
|
+
fontSize: value,
|
|
143
|
+
"--uniwind-em": value
|
|
144
|
+
};
|
|
145
|
+
},
|
|
146
|
+
borderInlineWidth: value => {
|
|
147
|
+
const borderWidth = typeof value === "object" ? Object.values(value)[0] : value;
|
|
148
|
+
return {
|
|
149
|
+
borderLeftWidth: borderWidth,
|
|
150
|
+
borderRightWidth: borderWidth
|
|
151
|
+
};
|
|
152
|
+
},
|
|
153
|
+
borderBlockWidth: value => {
|
|
154
|
+
const borderWidth = typeof value === "object" ? Object.values(value)[0] : value;
|
|
155
|
+
return {
|
|
156
|
+
borderTopWidth: borderWidth,
|
|
157
|
+
borderBottomWidth: borderWidth
|
|
158
|
+
};
|
|
159
|
+
},
|
|
160
|
+
borderInlineStyle: value => {
|
|
161
|
+
return {
|
|
162
|
+
borderStyle: value
|
|
163
|
+
};
|
|
164
|
+
},
|
|
165
|
+
borderBlockStyle: value => {
|
|
166
|
+
return {
|
|
167
|
+
borderStyle: value
|
|
168
|
+
};
|
|
169
|
+
},
|
|
170
|
+
borderStyle: value => {
|
|
171
|
+
const borderStyle = typeof value === "object" ? Object.values(value)[0] : value;
|
|
172
|
+
return {
|
|
173
|
+
borderStyle
|
|
174
|
+
};
|
|
175
|
+
},
|
|
176
|
+
transformOrigin: value => {
|
|
177
|
+
if (typeof value === "object") {
|
|
178
|
+
return {
|
|
179
|
+
transformOrigin: `${value.x} ${value.y}`
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
return {
|
|
183
|
+
transformOrigin: value
|
|
184
|
+
};
|
|
185
|
+
},
|
|
186
|
+
fontVariantNumeric: value => ({
|
|
187
|
+
fontVariant: value
|
|
188
|
+
}),
|
|
189
|
+
display: value => {
|
|
190
|
+
if (value === '"box"') {
|
|
191
|
+
return {
|
|
192
|
+
display: '"flex"'
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
return {
|
|
196
|
+
display: value
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
|
|
201
|
+
const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
|
|
202
|
+
const BORDER_RADIUS_KEYS = ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"];
|
|
203
|
+
const COMPONENT_RESPONSIVE_PROPS = /* @__PURE__ */new Set(["width", "height", "minWidth", "maxWidth", "minHeight", "maxHeight", "padding", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "paddingHorizontal", "paddingVertical", "paddingStart", "paddingEnd", "margin", "marginTop", "marginRight", "marginBottom", "marginLeft", "marginHorizontal", "marginVertical", "marginStart", "marginEnd", "top", "right", "bottom", "left", "gap", "rowGap", "columnGap", "borderWidth", "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth", "borderStartWidth", "borderEndWidth", "borderRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius", "borderTopStartRadius", "borderTopEndRadius", "borderBottomStartRadius", "borderBottomEndRadius", "flexBasis", "translateX", "translateY"]);
|
|
204
|
+
class RN {
|
|
205
|
+
constructor(Processor) {
|
|
206
|
+
this.Processor = Processor;
|
|
207
|
+
}
|
|
208
|
+
cssToRN(property, value) {
|
|
209
|
+
const transformedProperty = property.startsWith("--") ? property : (0, _utils2.pipe)(property)(_utils2.toCamelCase, x => {
|
|
210
|
+
if (x.includes("padding") || x.includes("margin")) {
|
|
211
|
+
return x.replace("InlineStart", "Start").replace("InlineEnd", "End").replace("Inline", "Horizontal").replace("Block", "Vertical");
|
|
212
|
+
}
|
|
213
|
+
if (x.includes("border")) {
|
|
214
|
+
return x.replace("InlineStart", "Start").replace("InlineEnd", "End");
|
|
215
|
+
}
|
|
216
|
+
return x;
|
|
217
|
+
});
|
|
218
|
+
const rn = this.transformProperty(transformedProperty, typeof value === "string" ? (0, _utils2.addMissingSpaces)(value) : value);
|
|
219
|
+
const joinedStyles = this.joinStyles(rn);
|
|
220
|
+
return Object.entries(joinedStyles).filter(([, value2]) => (0, _utils.isDefined)(value2)).map(([prop, val]) => [prop, this.makeResponsive(prop, val)]);
|
|
221
|
+
}
|
|
222
|
+
makeResponsive(property, value) {
|
|
223
|
+
const mode = this.Processor.bundlerConfig.polyfills?.responsive;
|
|
224
|
+
if (!mode) {
|
|
225
|
+
return value;
|
|
226
|
+
}
|
|
227
|
+
if (typeof value === "string") {
|
|
228
|
+
const rawValue = value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value;
|
|
229
|
+
if (rawValue.endsWith("%")) {
|
|
230
|
+
const numValue = parseFloat(rawValue);
|
|
231
|
+
if (!isNaN(numValue)) {
|
|
232
|
+
return `rt.makeResponsive(${numValue}, 100, true)`;
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
if (typeof value !== "number") {
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
const isTextMode = mode === true || mode === "text";
|
|
240
|
+
const isComponentMode = mode === true || mode === "components";
|
|
241
|
+
if (isTextMode && (property === "fontSize" || property === "--uniwind-em")) {
|
|
242
|
+
return `rt.makeResponsive(${value}, ${_consts.DEFAULT_SCREEN_HEIGHT}, true)`;
|
|
243
|
+
}
|
|
244
|
+
if (isComponentMode && COMPONENT_RESPONSIVE_PROPS.has(property)) {
|
|
245
|
+
return `rt.makeResponsive(${value}, ${_consts.DEFAULT_SCREEN_WIDTH})`;
|
|
246
|
+
}
|
|
247
|
+
return value;
|
|
248
|
+
}
|
|
249
|
+
transformProperty(property, value) {
|
|
250
|
+
if (property in cssToRNMap) {
|
|
251
|
+
return cssToRNMap[property](value);
|
|
252
|
+
}
|
|
253
|
+
if (typeof value === "object") {
|
|
254
|
+
const transformed = this.transformObjectProperty(property, value);
|
|
255
|
+
if (transformed) {
|
|
256
|
+
return transformed;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
[property]: value
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
transformObjectProperty(property, value) {
|
|
264
|
+
const properties = Object.keys(value);
|
|
265
|
+
const propertyEnd = property.includes("border") ? property.split("border").at(-1) ?? "" : "";
|
|
266
|
+
const transformedProperty = property.replace(propertyEnd, "");
|
|
267
|
+
const isSpacing = property.includes("margin") || property.includes("padding");
|
|
268
|
+
const wrapProperty = prop => `${transformedProperty}${prop}${propertyEnd}`;
|
|
269
|
+
if (properties.every(property2 => ["row", "column"].includes(property2))) {
|
|
270
|
+
return {
|
|
271
|
+
rowGap: value.row,
|
|
272
|
+
columnGap: value.column
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
if (properties.every(property2 => ["start", "end"].includes(property2))) {
|
|
276
|
+
if (isSpacing && property.includes("Horizontal")) {
|
|
277
|
+
return {
|
|
278
|
+
[`${property.replace("Horizontal", "Left")}`]: value.start,
|
|
279
|
+
[`${property.replace("Horizontal", "Right")}`]: value.end
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
if (isSpacing && property.includes("Vertical")) {
|
|
283
|
+
return {
|
|
284
|
+
[`${property.replace("Vertical", "Top")}`]: value.start,
|
|
285
|
+
[`${property.replace("Vertical", "Bottom")}`]: value.end
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
[wrapProperty("Start")]: value.start,
|
|
290
|
+
[wrapProperty("End")]: value.end
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
if (properties.every(property2 => ["top", "right", "bottom", "left"].includes(property2))) {
|
|
294
|
+
if (transformedProperty === "inset") {
|
|
295
|
+
const isEverySideSame = properties.every(property2 => value[property2] === value.top);
|
|
296
|
+
return isEverySideSame ? {
|
|
297
|
+
inset: value.top
|
|
298
|
+
} : value;
|
|
299
|
+
}
|
|
300
|
+
return {
|
|
301
|
+
[wrapProperty("Top")]: value.top,
|
|
302
|
+
[wrapProperty("Right")]: value.right,
|
|
303
|
+
[wrapProperty("Bottom")]: value.bottom,
|
|
304
|
+
[wrapProperty("Left")]: value.left
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
if (properties.every(property2 => ["topLeft", "topRight", "bottomRight", "bottomLeft"].includes(property2))) {
|
|
308
|
+
return {
|
|
309
|
+
[wrapProperty("TopLeft")]: value.topLeft,
|
|
310
|
+
[wrapProperty("TopRight")]: value.topRight,
|
|
311
|
+
[wrapProperty("BottomRight")]: value.bottomRight,
|
|
312
|
+
[wrapProperty("BottomLeft")]: value.bottomLeft
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
if (properties.every(property2 => ["style", "width", "color"].includes(property2))) {
|
|
316
|
+
return {
|
|
317
|
+
[wrapProperty("Style")]: value.style,
|
|
318
|
+
[wrapProperty("Width")]: value.width,
|
|
319
|
+
[wrapProperty("Color")]: value.color
|
|
320
|
+
};
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
// Used when they're multiple styles with the same value that could be joined
|
|
324
|
+
joinStyles(styles) {
|
|
325
|
+
const keys = Object.keys(styles);
|
|
326
|
+
if (BORDER_WIDTH_KEYS.every(key => keys.includes(key))) {
|
|
327
|
+
const borderWidth = styles.borderTopWidth;
|
|
328
|
+
if (BORDER_WIDTH_KEYS.every(key => styles[key] === borderWidth)) {
|
|
329
|
+
return {
|
|
330
|
+
...(0, _utils2.removeKeys)(styles, BORDER_WIDTH_KEYS),
|
|
331
|
+
borderWidth
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
if (BORDER_COLOR_KEYS.every(key => keys.includes(key))) {
|
|
336
|
+
const borderColor = styles.borderTopColor;
|
|
337
|
+
if (BORDER_COLOR_KEYS.every(key => styles[key] === borderColor)) {
|
|
338
|
+
return {
|
|
339
|
+
...(0, _utils2.removeKeys)(styles, BORDER_COLOR_KEYS),
|
|
340
|
+
borderColor
|
|
341
|
+
};
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
if (BORDER_RADIUS_KEYS.every(key => keys.includes(key))) {
|
|
345
|
+
const borderRadius = styles.borderTopLeftRadius;
|
|
346
|
+
if (BORDER_RADIUS_KEYS.every(key => styles[key] === borderRadius)) {
|
|
347
|
+
return {
|
|
348
|
+
...(0, _utils2.removeKeys)(styles, BORDER_RADIUS_KEYS),
|
|
349
|
+
borderRadius
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return styles;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
exports.RN = RN;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.serializeJSObject = exports.serialize = void 0;
|
|
7
|
+
var _logger = require("@/bundler/logger");
|
|
8
|
+
var _utils = require("./utils");
|
|
9
|
+
const parseStringValue = value => {
|
|
10
|
+
if ((0, _utils.isValidJSValue)(value)) {
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
if (value.startsWith("function")) {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
const tokens = (0, _utils.smartSplit)((0, _utils.addMissingSpaces)(value));
|
|
17
|
+
const parsedTokens = tokens.map(token => {
|
|
18
|
+
if (token.startsWith('"')) {
|
|
19
|
+
return token.replace(/"/g, "");
|
|
20
|
+
}
|
|
21
|
+
if (/^[a-z]+$/i.test(token.replace(/,/g, ""))) {
|
|
22
|
+
return token;
|
|
23
|
+
}
|
|
24
|
+
if ((0, _utils.isNumber)(token)) {
|
|
25
|
+
return token;
|
|
26
|
+
}
|
|
27
|
+
const endsWithComma = token.endsWith(",");
|
|
28
|
+
const expr = endsWithComma ? token.slice(0, -1) : token;
|
|
29
|
+
if (!(0, _utils.isValidJSValue)(expr)) {
|
|
30
|
+
return token;
|
|
31
|
+
}
|
|
32
|
+
return ["${", expr, "}", endsWithComma ? "," : ""].join("");
|
|
33
|
+
});
|
|
34
|
+
return ["`", parsedTokens.join(" "), "`"].join("");
|
|
35
|
+
};
|
|
36
|
+
const serialize = value => {
|
|
37
|
+
const typeOfValue = typeof value;
|
|
38
|
+
switch (typeOfValue) {
|
|
39
|
+
case "string":
|
|
40
|
+
return parseStringValue(value);
|
|
41
|
+
case "symbol":
|
|
42
|
+
return String(value);
|
|
43
|
+
case "number":
|
|
44
|
+
case "bigint":
|
|
45
|
+
return String((0, _utils.roundToPrecision)(value, 2));
|
|
46
|
+
case "boolean":
|
|
47
|
+
return value.toString();
|
|
48
|
+
case "object":
|
|
49
|
+
if (value === null) {
|
|
50
|
+
return "null";
|
|
51
|
+
}
|
|
52
|
+
if (Array.isArray(value)) {
|
|
53
|
+
return ["[", value.map(serialize).join(", "), "]"].join("");
|
|
54
|
+
}
|
|
55
|
+
return ["{", Object.entries(value).map(([key, val]) => {
|
|
56
|
+
const serializedKey = (0, _utils.isNumber)(key) ? key : `"${key}"`;
|
|
57
|
+
return `${serializedKey}: ${serialize(val)}`;
|
|
58
|
+
}).join(", "), "}"].join("");
|
|
59
|
+
case "undefined":
|
|
60
|
+
return "undefined";
|
|
61
|
+
case "function":
|
|
62
|
+
return "";
|
|
63
|
+
default:
|
|
64
|
+
typeOfValue;
|
|
65
|
+
return "";
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
exports.serialize = serialize;
|
|
69
|
+
const serializeJSObject = (obj, serializer) => {
|
|
70
|
+
const serializedObject = (0, _utils.pipe)(obj)(Object.entries, entries => entries.map(([key, value]) => serializer(key, serialize(value))), serializedValues => serializedValues.filter(serializedValue => {
|
|
71
|
+
try {
|
|
72
|
+
new Function(`function validateJS() { const obj = ({ ${serializedValue} }) }`);
|
|
73
|
+
return true;
|
|
74
|
+
} catch {
|
|
75
|
+
_logger.Logger.error(`Failed to serialize ${serializedValue} as a valid JS object entry. Skipping.`);
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
}), entries => entries.join(","), result => {
|
|
79
|
+
if (result === "") {
|
|
80
|
+
return "";
|
|
81
|
+
}
|
|
82
|
+
return `${result},`;
|
|
83
|
+
});
|
|
84
|
+
return serializedObject;
|
|
85
|
+
};
|
|
86
|
+
exports.serializeJSObject = serializeJSObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Units = void 0;
|
|
7
|
+
var _logger = require("../logger");
|
|
8
|
+
class Units {
|
|
9
|
+
constructor(Processor) {
|
|
10
|
+
this.Processor = Processor;
|
|
11
|
+
}
|
|
12
|
+
logger = new _logger.Logger("Units");
|
|
13
|
+
processLength(length) {
|
|
14
|
+
if (typeof length === "number") {
|
|
15
|
+
return length;
|
|
16
|
+
}
|
|
17
|
+
if ("unit" in length) {
|
|
18
|
+
switch (length.unit) {
|
|
19
|
+
case "px":
|
|
20
|
+
return this.replaceInfinity(length.value);
|
|
21
|
+
case "vw":
|
|
22
|
+
return `rt.screen.width * ${length.value / 100}`;
|
|
23
|
+
case "vh":
|
|
24
|
+
return `rt.screen.height * ${length.value / 100}`;
|
|
25
|
+
case "rem":
|
|
26
|
+
return length.value * this.Processor.vars["--uniwind-em"];
|
|
27
|
+
case "em":
|
|
28
|
+
return `vars["--uniwind-em"]?.(vars) * ${length.value}`;
|
|
29
|
+
default:
|
|
30
|
+
this.logger.warn(`Unsupported unit - ${length.unit}`);
|
|
31
|
+
return length.value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return this.Processor.CSS.processValue(length);
|
|
35
|
+
}
|
|
36
|
+
processAnyLength(length) {
|
|
37
|
+
if ("type" in length) {
|
|
38
|
+
switch (length.type) {
|
|
39
|
+
case "value":
|
|
40
|
+
case "dimension":
|
|
41
|
+
return this.processLength(length.value);
|
|
42
|
+
case "percentage":
|
|
43
|
+
return `${length.value * 100}%`;
|
|
44
|
+
default:
|
|
45
|
+
this.logger.warn(`Unsupported length type - ${length.type}`);
|
|
46
|
+
return length.value;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return this.processLength(length);
|
|
50
|
+
}
|
|
51
|
+
replaceInfinity(value) {
|
|
52
|
+
return value === Infinity ? 99999 : value;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
exports.Units = Units;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.toCamelCase = exports.smartSplit = exports.shouldBeSerialized = exports.roundToPrecision = exports.removeKeys = exports.pipe = exports.isValidJSValue = exports.isNumber = exports.deepEqual = exports.addMissingSpaces = void 0;
|
|
7
|
+
const toCamelCase = str => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
8
|
+
exports.toCamelCase = toCamelCase;
|
|
9
|
+
const pipe = data => (...fns) => fns.reduce((acc, fn) => fn(acc), data);
|
|
10
|
+
exports.pipe = pipe;
|
|
11
|
+
const isNumber = data => {
|
|
12
|
+
if (typeof data === "number") {
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
if (typeof data === "string" && data !== "") {
|
|
16
|
+
return !isNaN(Number(data));
|
|
17
|
+
}
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
exports.isNumber = isNumber;
|
|
21
|
+
const smartSplit = (str, separator = " ") => {
|
|
22
|
+
const escaper = "&&&";
|
|
23
|
+
return pipe(str)(x => x.replace(/\s\?\?\s/g, `${escaper}??${escaper}`), x => x.replace(/\s([+\-*/])\s/g, `${escaper}$1${escaper}`), x => x.split(separator), x => x.map(token => token.replace(new RegExp(escaper, "g"), " ")));
|
|
24
|
+
};
|
|
25
|
+
exports.smartSplit = smartSplit;
|
|
26
|
+
const addMissingSpaces = str => pipe(str)(x => x.trim(), x => x.replace(/\](?=\d)/g, "] "), x => x.replace(/\](?=")/g, "] "), x => x.replace(/\)(?=[^\s,])/g, ") "), x => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" '));
|
|
27
|
+
exports.addMissingSpaces = addMissingSpaces;
|
|
28
|
+
const isValidJSValue = jsValueString => {
|
|
29
|
+
try {
|
|
30
|
+
new Function(`const test = ${jsValueString}`);
|
|
31
|
+
return true;
|
|
32
|
+
} catch {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.isValidJSValue = isValidJSValue;
|
|
37
|
+
const shouldBeSerialized = value => {
|
|
38
|
+
if (value.includes("-")) {
|
|
39
|
+
return value.split("-").some(shouldBeSerialized);
|
|
40
|
+
}
|
|
41
|
+
return [isNumber(value), value.startsWith("vars["), value.startsWith("rt."), /[*/+-]/.test(value), value.includes('"'), value.includes(" "), value === "(", value === ")"].some(Boolean);
|
|
42
|
+
};
|
|
43
|
+
exports.shouldBeSerialized = shouldBeSerialized;
|
|
44
|
+
const roundToPrecision = (value, precision) => parseFloat(value.toFixed(precision));
|
|
45
|
+
exports.roundToPrecision = roundToPrecision;
|
|
46
|
+
const deepEqual = (a, b) => {
|
|
47
|
+
if (Object.is(a, b)) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const keysA = Object.keys(a);
|
|
54
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
return keysA.every(key => deepEqual(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key));
|
|
58
|
+
};
|
|
59
|
+
exports.deepEqual = deepEqual;
|
|
60
|
+
const removeKeys = (obj, keysToRemove) => Object.fromEntries(Object.entries(obj).filter(([key]) => !keysToRemove.includes(key)));
|
|
61
|
+
exports.removeKeys = removeKeys;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Var = void 0;
|
|
7
|
+
class Var {
|
|
8
|
+
constructor(Processor) {
|
|
9
|
+
this.Processor = Processor;
|
|
10
|
+
}
|
|
11
|
+
processVar(variable) {
|
|
12
|
+
const value = `vars[${JSON.stringify(variable.name.ident)}]?.(vars)`;
|
|
13
|
+
if (!variable.fallback || variable.fallback.length === 0) {
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
const fallback = this.Processor.CSS.processValue(variable.fallback);
|
|
17
|
+
return `${value} ?? ${fallback}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.Var = Var;
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.RuleVisitor = void 0;
|
|
7
7
|
class RuleVisitor {
|
|
8
|
-
constructor(
|
|
9
|
-
this.
|
|
8
|
+
constructor(bundlerConfig) {
|
|
9
|
+
this.bundlerConfig = bundlerConfig;
|
|
10
10
|
}
|
|
11
11
|
processedClassNames = /* @__PURE__ */new Set();
|
|
12
12
|
processedVariables = /* @__PURE__ */new Set();
|
|
@@ -63,7 +63,7 @@ class RuleVisitor {
|
|
|
63
63
|
if (whereSelector?.type !== "class") {
|
|
64
64
|
return styleRule;
|
|
65
65
|
}
|
|
66
|
-
const selectedVariant = this.themes.find(theme => whereSelector.name === theme);
|
|
66
|
+
const selectedVariant = this.bundlerConfig.themes.find(theme => whereSelector.name === theme);
|
|
67
67
|
if (selectedVariant === void 0 || this.processedVariables.has(selectedVariant)) {
|
|
68
68
|
return styleRule;
|
|
69
69
|
}
|
|
@@ -82,12 +82,12 @@ class RuleVisitor {
|
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
84
|
processClassStyle(styleRule, firstSelector) {
|
|
85
|
-
const selectedVariant = this.themes.find(theme => firstSelector.name.includes(`${theme}:`));
|
|
85
|
+
const selectedVariant = this.bundlerConfig.themes.find(theme => firstSelector.name.includes(`${theme}:`));
|
|
86
86
|
if (selectedVariant === void 0 || this.processedClassNames.has(firstSelector.name)) {
|
|
87
87
|
return;
|
|
88
88
|
}
|
|
89
89
|
this.processedClassNames.add(firstSelector.name);
|
|
90
|
-
return {
|
|
90
|
+
return this.removeNulls({
|
|
91
91
|
type: "scope",
|
|
92
92
|
value: {
|
|
93
93
|
loc: styleRule.value.loc,
|
|
@@ -96,12 +96,12 @@ class RuleVisitor {
|
|
|
96
96
|
type: "class",
|
|
97
97
|
name: selectedVariant
|
|
98
98
|
}]],
|
|
99
|
-
scopeEnd: this.themes.filter(theme => theme !== selectedVariant).map(theme => [{
|
|
99
|
+
scopeEnd: this.bundlerConfig.themes.filter(theme => theme !== selectedVariant).map(theme => [{
|
|
100
100
|
type: "class",
|
|
101
101
|
name: theme
|
|
102
102
|
}])
|
|
103
103
|
}
|
|
104
|
-
};
|
|
104
|
+
});
|
|
105
105
|
}
|
|
106
106
|
// Fixes lightningcss serialization bug
|
|
107
107
|
removeNulls(value) {
|
|
@@ -7,17 +7,16 @@ exports.UniwindCSSVisitor = void 0;
|
|
|
7
7
|
var _functionVisitor = require("./function-visitor");
|
|
8
8
|
var _ruleVisitor = require("./rule-visitor");
|
|
9
9
|
class UniwindCSSVisitor {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
Function;
|
|
11
|
+
Rule;
|
|
12
|
+
StyleSheet;
|
|
13
|
+
constructor(bundlerConfig) {
|
|
14
|
+
const ruleVisitor = new _ruleVisitor.RuleVisitor(bundlerConfig);
|
|
13
15
|
this.Function = new _functionVisitor.FunctionVisitor();
|
|
14
16
|
this.Rule = ruleVisitor;
|
|
15
17
|
this.StyleSheet = () => {
|
|
16
18
|
ruleVisitor.cleanup();
|
|
17
19
|
};
|
|
18
20
|
}
|
|
19
|
-
Function;
|
|
20
|
-
Rule;
|
|
21
|
-
StyleSheet;
|
|
22
21
|
}
|
|
23
22
|
exports.UniwindCSSVisitor = UniwindCSSVisitor;
|