@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,28 +1,95 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const config = require('../shared/uniwind.BEqYiPBB.cjs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const
|
|
6
|
-
const consts = require('../shared/uniwind.B5q8hBGv.cjs');
|
|
7
|
-
const node = require('@tailwindcss/node');
|
|
8
|
-
const oxide = require('@tailwindcss/oxide');
|
|
5
|
+
const _package = require('../shared/uniwind.DJ5M1Q4q.cjs');
|
|
9
6
|
const lightningcss = require('lightningcss');
|
|
10
|
-
const stringifyThemes = require('../shared/uniwind.r2i22V6d.cjs');
|
|
11
7
|
const culori = require('culori');
|
|
8
|
+
const node = require('@tailwindcss/node');
|
|
9
|
+
const oxide = require('@tailwindcss/oxide');
|
|
10
|
+
const fs = require('fs');
|
|
12
11
|
|
|
13
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
14
13
|
|
|
15
|
-
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
16
14
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
15
|
+
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
16
|
+
|
|
17
|
+
const toCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
18
|
+
const pipe = (data) => ((...fns) => fns.reduce((acc, fn) => fn(acc), data));
|
|
19
|
+
const isNumber = (data) => {
|
|
20
|
+
if (typeof data === "number") {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
if (typeof data === "string" && data !== "") {
|
|
24
|
+
return !isNaN(Number(data));
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
};
|
|
28
|
+
const smartSplit = (str, separator = " ") => {
|
|
29
|
+
const escaper = "&&&";
|
|
30
|
+
return pipe(str)(
|
|
31
|
+
(x) => x.replace(/\s\?\?\s/g, `${escaper}??${escaper}`),
|
|
32
|
+
(x) => x.replace(/\s([+\-*/])\s/g, `${escaper}$1${escaper}`),
|
|
33
|
+
(x) => x.split(separator),
|
|
34
|
+
(x) => x.map((token) => token.replace(new RegExp(escaper, "g"), " "))
|
|
35
|
+
);
|
|
36
|
+
};
|
|
37
|
+
const addMissingSpaces = (str) => pipe(str)(
|
|
38
|
+
(x) => x.trim(),
|
|
39
|
+
(x) => x.replace(/\](?=\d)/g, "] "),
|
|
40
|
+
(x) => x.replace(/\](?=")/g, "] "),
|
|
41
|
+
(x) => x.replace(/\)(?=[^\s,])/g, ") "),
|
|
42
|
+
(x) => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" ')
|
|
43
|
+
);
|
|
44
|
+
const isValidJSValue = (jsValueString) => {
|
|
45
|
+
try {
|
|
46
|
+
new Function(`const test = ${jsValueString}`);
|
|
47
|
+
return true;
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const shouldBeSerialized = (value) => {
|
|
53
|
+
if (value.includes("-")) {
|
|
54
|
+
return value.split("-").some(shouldBeSerialized);
|
|
55
|
+
}
|
|
56
|
+
return [
|
|
57
|
+
isNumber(value),
|
|
58
|
+
value.startsWith("vars["),
|
|
59
|
+
value.startsWith("rt."),
|
|
60
|
+
/[*/+-]/.test(value),
|
|
61
|
+
value.includes('"'),
|
|
62
|
+
value.includes(" "),
|
|
63
|
+
value === "(",
|
|
64
|
+
value === ")"
|
|
65
|
+
].some(Boolean);
|
|
66
|
+
};
|
|
67
|
+
const roundToPrecision = (value, precision) => parseFloat(value.toFixed(precision));
|
|
68
|
+
const deepEqual = (a, b) => {
|
|
69
|
+
if (Object.is(a, b)) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const keysA = Object.keys(a);
|
|
76
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return keysA.every((key) => deepEqual(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key));
|
|
80
|
+
};
|
|
81
|
+
const removeKeys = (obj, keysToRemove) => Object.fromEntries(
|
|
82
|
+
Object.entries(obj).filter(([key]) => !keysToRemove.includes(key))
|
|
83
|
+
);
|
|
17
84
|
|
|
18
85
|
const parseStringValue = (value) => {
|
|
19
|
-
if (
|
|
86
|
+
if (isValidJSValue(value)) {
|
|
20
87
|
return value;
|
|
21
88
|
}
|
|
22
89
|
if (value.startsWith("function")) {
|
|
23
90
|
return value;
|
|
24
91
|
}
|
|
25
|
-
const tokens =
|
|
92
|
+
const tokens = smartSplit(addMissingSpaces(value));
|
|
26
93
|
const parsedTokens = tokens.map((token) => {
|
|
27
94
|
if (token.startsWith('"')) {
|
|
28
95
|
return token.replace(/"/g, "");
|
|
@@ -30,12 +97,12 @@ const parseStringValue = (value) => {
|
|
|
30
97
|
if (/^[a-z]+$/i.test(token.replace(/,/g, ""))) {
|
|
31
98
|
return token;
|
|
32
99
|
}
|
|
33
|
-
if (
|
|
100
|
+
if (isNumber(token)) {
|
|
34
101
|
return token;
|
|
35
102
|
}
|
|
36
103
|
const endsWithComma = token.endsWith(",");
|
|
37
104
|
const expr = endsWithComma ? token.slice(0, -1) : token;
|
|
38
|
-
if (!
|
|
105
|
+
if (!isValidJSValue(expr)) {
|
|
39
106
|
return token;
|
|
40
107
|
}
|
|
41
108
|
return [
|
|
@@ -60,7 +127,7 @@ const serialize = (value) => {
|
|
|
60
127
|
return String(value);
|
|
61
128
|
case "number":
|
|
62
129
|
case "bigint":
|
|
63
|
-
return String(
|
|
130
|
+
return String(roundToPrecision(value, 2));
|
|
64
131
|
case "boolean":
|
|
65
132
|
return value.toString();
|
|
66
133
|
case "object":
|
|
@@ -77,7 +144,7 @@ const serialize = (value) => {
|
|
|
77
144
|
return [
|
|
78
145
|
"{",
|
|
79
146
|
Object.entries(value).map(([key, val]) => {
|
|
80
|
-
const serializedKey =
|
|
147
|
+
const serializedKey = isNumber(key) ? key : `"${key}"`;
|
|
81
148
|
return `${serializedKey}: ${serialize(val)}`;
|
|
82
149
|
}).join(", "),
|
|
83
150
|
"}"
|
|
@@ -91,7 +158,7 @@ const serialize = (value) => {
|
|
|
91
158
|
}
|
|
92
159
|
};
|
|
93
160
|
const serializeJSObject = (obj, serializer) => {
|
|
94
|
-
const serializedObject =
|
|
161
|
+
const serializedObject = pipe(obj)(
|
|
95
162
|
Object.entries,
|
|
96
163
|
(entries) => entries.map(([key, value]) => serializer(key, serialize(value))),
|
|
97
164
|
(serializedValues) => serializedValues.filter((serializedValue) => {
|
|
@@ -99,7 +166,7 @@ const serializeJSObject = (obj, serializer) => {
|
|
|
99
166
|
new Function(`function validateJS() { const obj = ({ ${serializedValue} }) }`);
|
|
100
167
|
return true;
|
|
101
168
|
} catch {
|
|
102
|
-
|
|
169
|
+
config.Logger.error(`Failed to serialize ${serializedValue} as a valid JS object entry. Skipping.`);
|
|
103
170
|
return false;
|
|
104
171
|
}
|
|
105
172
|
}),
|
|
@@ -114,24 +181,9 @@ const serializeJSObject = (obj, serializer) => {
|
|
|
114
181
|
return serializedObject;
|
|
115
182
|
};
|
|
116
183
|
|
|
117
|
-
const isDefined = (value) => value !== void 0 && value !== null;
|
|
118
|
-
|
|
119
|
-
var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
|
|
120
|
-
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
121
|
-
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
122
|
-
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
123
|
-
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
124
|
-
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
125
|
-
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
126
|
-
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
127
|
-
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
128
|
-
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
129
|
-
return StyleDependency2;
|
|
130
|
-
})(StyleDependency || {});
|
|
131
|
-
|
|
132
184
|
const extractVarsFromString = (value) => {
|
|
133
|
-
const
|
|
134
|
-
return
|
|
185
|
+
const varsIndexes = [...value.matchAll(/vars\[/g)].map((m) => m.index);
|
|
186
|
+
return varsIndexes.map((index) => {
|
|
135
187
|
const afterIndex = value.slice(index + 5);
|
|
136
188
|
const closingIndex = afterIndex.indexOf("]");
|
|
137
189
|
const varName = afterIndex.slice(0, closingIndex);
|
|
@@ -147,6 +199,23 @@ const makeSafeForSerialization = (value) => {
|
|
|
147
199
|
}
|
|
148
200
|
return value;
|
|
149
201
|
};
|
|
202
|
+
const hasThemedVarDependency = (varName, Processor, visited = /* @__PURE__ */ new Set()) => {
|
|
203
|
+
if (visited.has(varName)) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
visited.add(varName);
|
|
207
|
+
const isScopedVar = Object.values(Processor.scopedVars).some((scopedVars) => varName in scopedVars);
|
|
208
|
+
if (isScopedVar) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
const globalVarValue = Processor.vars[varName];
|
|
212
|
+
if (typeof globalVarValue !== "string") {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return extractVarsFromString(globalVarValue).some((usedVarName) => {
|
|
216
|
+
return hasThemedVarDependency(usedVarName, Processor, visited);
|
|
217
|
+
});
|
|
218
|
+
};
|
|
150
219
|
const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
151
220
|
const stylesheetsEntries = Object.entries(Processor.stylesheets).map(([className, stylesPerMediaQuery]) => {
|
|
152
221
|
const styles = stylesPerMediaQuery.map((style, index) => {
|
|
@@ -166,10 +235,10 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
166
235
|
dataAttributes,
|
|
167
236
|
...rest
|
|
168
237
|
} = style;
|
|
169
|
-
const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function() { return ${serialize(value)} }`]);
|
|
238
|
+
const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function(vars) { return ${serialize(value)} }`]);
|
|
170
239
|
if (platform) {
|
|
171
|
-
const isTV = currentPlatform ===
|
|
172
|
-
const commonPlatform = isTV ?
|
|
240
|
+
const isTV = currentPlatform === config.Platform.AndroidTV || currentPlatform === config.Platform.AppleTV;
|
|
241
|
+
const commonPlatform = isTV ? config.Platform.TV : config.Platform.Native;
|
|
173
242
|
if (platform !== commonPlatform && platform !== currentPlatform) {
|
|
174
243
|
return null;
|
|
175
244
|
}
|
|
@@ -180,32 +249,27 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
180
249
|
const dependencies = [];
|
|
181
250
|
const stringifiedEntries = JSON.stringify(entries);
|
|
182
251
|
const usedVars = extractVarsFromString(stringifiedEntries);
|
|
183
|
-
const isUsingThemedVar = usedVars.some((usedVarName) =>
|
|
184
|
-
return Object.values(Processor.scopedVars).some((scopedVars) => {
|
|
185
|
-
const scopedVarsNames = Object.keys(scopedVars);
|
|
186
|
-
return scopedVarsNames.includes(usedVarName);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
252
|
+
const isUsingThemedVar = usedVars.some((usedVarName) => hasThemedVarDependency(usedVarName, Processor));
|
|
189
253
|
if (usedVars.length > 0) {
|
|
190
|
-
dependencies.push(StyleDependency.Variables);
|
|
254
|
+
dependencies.push(config.StyleDependency.Variables);
|
|
191
255
|
}
|
|
192
256
|
if (theme !== null || isUsingThemedVar || stringifiedEntries.includes("rt.lightDark")) {
|
|
193
|
-
dependencies.push(StyleDependency.Theme);
|
|
257
|
+
dependencies.push(config.StyleDependency.Theme);
|
|
194
258
|
}
|
|
195
259
|
if (orientation !== null) {
|
|
196
|
-
dependencies.push(StyleDependency.Orientation);
|
|
260
|
+
dependencies.push(config.StyleDependency.Orientation);
|
|
197
261
|
}
|
|
198
262
|
if (rtl !== null) {
|
|
199
|
-
dependencies.push(StyleDependency.Rtl);
|
|
263
|
+
dependencies.push(config.StyleDependency.Rtl);
|
|
200
264
|
}
|
|
201
|
-
if (Number(minWidth) !== 0 || Number(maxWidth) !== Number.MAX_VALUE || stringifiedEntries.includes("rt.screen")) {
|
|
202
|
-
dependencies.push(StyleDependency.Dimensions);
|
|
265
|
+
if (Number(minWidth) !== 0 || Number(maxWidth) !== Number.MAX_VALUE || stringifiedEntries.includes("rt.makeResponsive") || stringifiedEntries.includes("rt.screen")) {
|
|
266
|
+
dependencies.push(config.StyleDependency.Dimensions);
|
|
203
267
|
}
|
|
204
268
|
if (stringifiedEntries.includes("rt.insets")) {
|
|
205
|
-
dependencies.push(StyleDependency.Insets);
|
|
269
|
+
dependencies.push(config.StyleDependency.Insets);
|
|
206
270
|
}
|
|
207
271
|
if (stringifiedEntries.includes("rt.fontScale")) {
|
|
208
|
-
dependencies.push(StyleDependency.FontScale);
|
|
272
|
+
dependencies.push(config.StyleDependency.FontScale);
|
|
209
273
|
}
|
|
210
274
|
return {
|
|
211
275
|
entries,
|
|
@@ -222,7 +286,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
222
286
|
active,
|
|
223
287
|
focus,
|
|
224
288
|
disabled,
|
|
225
|
-
importantProperties: importantProperties?.map((property) => property.startsWith("--") ? property :
|
|
289
|
+
importantProperties: importantProperties?.map((property) => property.startsWith("--") ? property : toCamelCase(property)).map(makeSafeForSerialization) ?? [],
|
|
226
290
|
dataAttributes,
|
|
227
291
|
complexity: [
|
|
228
292
|
minWidth !== 0,
|
|
@@ -237,7 +301,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
237
301
|
].filter(Boolean).length
|
|
238
302
|
};
|
|
239
303
|
});
|
|
240
|
-
const filteredStyles = styles.filter(isDefined);
|
|
304
|
+
const filteredStyles = styles.filter(config.isDefined);
|
|
241
305
|
if (filteredStyles.length === 0) {
|
|
242
306
|
return null;
|
|
243
307
|
}
|
|
@@ -245,7 +309,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
245
309
|
className,
|
|
246
310
|
filteredStyles
|
|
247
311
|
];
|
|
248
|
-
}).filter(isDefined);
|
|
312
|
+
}).filter(config.isDefined);
|
|
249
313
|
const stylesheets = Object.fromEntries(stylesheetsEntries);
|
|
250
314
|
return stylesheets;
|
|
251
315
|
};
|
|
@@ -294,11 +358,7 @@ const parseTransformsMutation = (styles, preserve = false) => {
|
|
|
294
358
|
}
|
|
295
359
|
}
|
|
296
360
|
if (transformsResult.length > 0) {
|
|
297
|
-
|
|
298
|
-
configurable: true,
|
|
299
|
-
enumerable: true,
|
|
300
|
-
value: transformsResult
|
|
301
|
-
});
|
|
361
|
+
styles.transform = transformsResult;
|
|
302
362
|
}
|
|
303
363
|
};
|
|
304
364
|
|
|
@@ -308,7 +368,7 @@ class Color {
|
|
|
308
368
|
}
|
|
309
369
|
toRgb = culori.converter("rgb");
|
|
310
370
|
black = "#000000";
|
|
311
|
-
logger = new
|
|
371
|
+
logger = new config.Logger("Color");
|
|
312
372
|
processColor(color) {
|
|
313
373
|
if (typeof color === "string") {
|
|
314
374
|
const parsed = culori.parse(color);
|
|
@@ -325,10 +385,10 @@ class Color {
|
|
|
325
385
|
}
|
|
326
386
|
try {
|
|
327
387
|
if (color.type === "currentcolor") {
|
|
328
|
-
return '
|
|
388
|
+
return 'vars["currentColor"]?.(vars)';
|
|
329
389
|
}
|
|
330
390
|
if (color.type === "rgb" || color.type === "srgb") {
|
|
331
|
-
const alpha = typeof color.alpha === "number" ? color.alpha :
|
|
391
|
+
const alpha = typeof color.alpha === "number" ? color.alpha : pipe(color.alpha)(
|
|
332
392
|
(x) => this.Processor.CSS.processValue(x),
|
|
333
393
|
Number,
|
|
334
394
|
(x) => isNaN(x) ? 1 : x
|
|
@@ -469,7 +529,7 @@ const getProcessedAnimation = (declarationValue, getProcessedValue) => {
|
|
|
469
529
|
const valueTokens = segment.slice(colonIndex + 1);
|
|
470
530
|
const rawKey = tokensToText(keyTokens, getProcessedValue);
|
|
471
531
|
const value = parseValues(valueTokens, getProcessedValue);
|
|
472
|
-
const key =
|
|
532
|
+
const key = toCamelCase(rawKey);
|
|
473
533
|
result.push([key, value]);
|
|
474
534
|
}
|
|
475
535
|
return result;
|
|
@@ -479,9 +539,9 @@ class CSS {
|
|
|
479
539
|
constructor(Processor) {
|
|
480
540
|
this.Processor = Processor;
|
|
481
541
|
}
|
|
482
|
-
logger = new
|
|
483
|
-
processValue(declarationValue) {
|
|
484
|
-
const processedValue = this.getProcessedValue(declarationValue);
|
|
542
|
+
logger = new config.Logger("CSS");
|
|
543
|
+
processValue(declarationValue, declarationProperty) {
|
|
544
|
+
const processedValue = this.getProcessedValue(declarationValue, declarationProperty);
|
|
485
545
|
if (typeof processedValue === "string") {
|
|
486
546
|
return this.makeSafeForSerialization(processedValue);
|
|
487
547
|
}
|
|
@@ -520,7 +580,7 @@ class CSS {
|
|
|
520
580
|
if (token.type === "var") {
|
|
521
581
|
return this.Processor.Var.processVar(token.value);
|
|
522
582
|
}
|
|
523
|
-
return Object.entries(token).map(([key, value]) => [
|
|
583
|
+
return Object.entries(token).map(([key, value]) => [toCamelCase(key), this.processValue(value)]);
|
|
524
584
|
}
|
|
525
585
|
return getProcessedAnimation(
|
|
526
586
|
declarationValue,
|
|
@@ -544,7 +604,7 @@ class CSS {
|
|
|
544
604
|
this.processValue(filter.value.yOffset),
|
|
545
605
|
this.processValue(filter.value.blur),
|
|
546
606
|
this.processValue(filter.value.color)
|
|
547
|
-
].filter(isDefined);
|
|
607
|
+
].filter(config.isDefined);
|
|
548
608
|
return `drop-shadow(${parts.join(" ")})`;
|
|
549
609
|
}
|
|
550
610
|
const value = this.processValue(filter.value);
|
|
@@ -552,7 +612,7 @@ class CSS {
|
|
|
552
612
|
});
|
|
553
613
|
return filterStrings.join(" ");
|
|
554
614
|
}
|
|
555
|
-
getProcessedValue(declarationValue) {
|
|
615
|
+
getProcessedValue(declarationValue, declarationProperty) {
|
|
556
616
|
if (typeof declarationValue !== "object") {
|
|
557
617
|
return declarationValue;
|
|
558
618
|
}
|
|
@@ -707,7 +767,7 @@ class CSS {
|
|
|
707
767
|
return this.Processor.Color.processColor(declarationValue.value);
|
|
708
768
|
}
|
|
709
769
|
if (declarationValue.value === "currentcolor") {
|
|
710
|
-
return '
|
|
770
|
+
return 'vars["currentColor"]?.(vars)';
|
|
711
771
|
}
|
|
712
772
|
return declarationValue.value;
|
|
713
773
|
case "env":
|
|
@@ -744,7 +804,7 @@ class CSS {
|
|
|
744
804
|
case "pair":
|
|
745
805
|
return declarationValue.inside.type;
|
|
746
806
|
case "currentcolor":
|
|
747
|
-
return '
|
|
807
|
+
return 'vars["currentColor"]?.(vars)';
|
|
748
808
|
case "calc":
|
|
749
809
|
return this.Processor.Functions.processCalc(declarationValue.value);
|
|
750
810
|
case "min":
|
|
@@ -777,7 +837,7 @@ class CSS {
|
|
|
777
837
|
return [
|
|
778
838
|
this.Processor.Color.processColor(declarationValue.color),
|
|
779
839
|
declarationValue.position ? this.processValue(declarationValue.position) : null
|
|
780
|
-
].filter(isDefined).join(" ");
|
|
840
|
+
].filter(config.isDefined).join(" ");
|
|
781
841
|
case "side":
|
|
782
842
|
return declarationValue.side;
|
|
783
843
|
case "absolute":
|
|
@@ -837,11 +897,17 @@ class CSS {
|
|
|
837
897
|
};
|
|
838
898
|
}
|
|
839
899
|
if ("grow" in declarationValue) {
|
|
840
|
-
|
|
900
|
+
const parsedFlex = {
|
|
841
901
|
flexGrow: declarationValue.grow,
|
|
842
902
|
flexShrink: declarationValue.shrink,
|
|
843
903
|
flexBasis: this.processValue(declarationValue.basis)
|
|
844
904
|
};
|
|
905
|
+
if (declarationProperty === "flex" && parsedFlex.flexGrow === 1 && parsedFlex.flexShrink === 1 && parsedFlex.flexBasis === '"0%"') {
|
|
906
|
+
return {
|
|
907
|
+
flex: 1
|
|
908
|
+
};
|
|
909
|
+
}
|
|
910
|
+
return parsedFlex;
|
|
845
911
|
}
|
|
846
912
|
if (Array.isArray(declarationValue)) {
|
|
847
913
|
if (declarationValue.length === 1) {
|
|
@@ -856,7 +922,7 @@ class CSS {
|
|
|
856
922
|
return this.addComaBetweenTokens(declarationValue).reduce((acc, value, index, array) => {
|
|
857
923
|
if (typeof value === "object") {
|
|
858
924
|
const nextValue = array.at(index + 1);
|
|
859
|
-
if (
|
|
925
|
+
if (deepEqual(value, nextValue)) {
|
|
860
926
|
return acc;
|
|
861
927
|
}
|
|
862
928
|
const result = this.processValue(value);
|
|
@@ -873,7 +939,7 @@ class CSS {
|
|
|
873
939
|
return declarationValue.case;
|
|
874
940
|
}
|
|
875
941
|
if ("angle" in declarationValue) {
|
|
876
|
-
const angles =
|
|
942
|
+
const angles = pipe([
|
|
877
943
|
["rotateX", declarationValue.x * declarationValue.angle.value],
|
|
878
944
|
["rotateY", declarationValue.y * declarationValue.angle.value],
|
|
879
945
|
["rotateZ", declarationValue.z * declarationValue.angle.value]
|
|
@@ -912,7 +978,7 @@ class CSS {
|
|
|
912
978
|
this.processValue(declarationValue.blur),
|
|
913
979
|
this.processValue(declarationValue.spread),
|
|
914
980
|
this.processValue(declarationValue.color)
|
|
915
|
-
].filter(isDefined).join(" ");
|
|
981
|
+
].filter(config.isDefined).join(" ");
|
|
916
982
|
}
|
|
917
983
|
if ("blockStart" in declarationValue) {
|
|
918
984
|
const startValue = this.processValue(declarationValue.blockStart);
|
|
@@ -955,7 +1021,7 @@ class CSS {
|
|
|
955
1021
|
};
|
|
956
1022
|
}
|
|
957
1023
|
if ("duration" in declarationValue) {
|
|
958
|
-
return Object.entries(declarationValue).map(([key, value]) => [
|
|
1024
|
+
return Object.entries(declarationValue).map(([key, value]) => [toCamelCase(key), this.processValue(value)]);
|
|
959
1025
|
}
|
|
960
1026
|
this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`);
|
|
961
1027
|
return void 0;
|
|
@@ -1022,11 +1088,11 @@ class CSS {
|
|
|
1022
1088
|
);
|
|
1023
1089
|
}
|
|
1024
1090
|
makeSafeForSerialization(value) {
|
|
1025
|
-
if (
|
|
1091
|
+
if (shouldBeSerialized(value)) {
|
|
1026
1092
|
return value;
|
|
1027
1093
|
}
|
|
1028
1094
|
if (value.endsWith("%")) {
|
|
1029
|
-
return `"${
|
|
1095
|
+
return `"${roundToPrecision(parseFloat(value), 2)}%"`;
|
|
1030
1096
|
}
|
|
1031
1097
|
return `"${value}"`;
|
|
1032
1098
|
}
|
|
@@ -1036,7 +1102,7 @@ class Functions {
|
|
|
1036
1102
|
constructor(Processor) {
|
|
1037
1103
|
this.Processor = Processor;
|
|
1038
1104
|
}
|
|
1039
|
-
logger = new
|
|
1105
|
+
logger = new config.Logger("Functions");
|
|
1040
1106
|
processCalc(calc) {
|
|
1041
1107
|
switch (calc.type) {
|
|
1042
1108
|
case "sum": {
|
|
@@ -1061,27 +1127,27 @@ class Functions {
|
|
|
1061
1127
|
}
|
|
1062
1128
|
if (fn.name === "calc") {
|
|
1063
1129
|
const calc = this.Processor.CSS.processValue(fn.arguments);
|
|
1064
|
-
return
|
|
1130
|
+
return pipe(calc)(
|
|
1065
1131
|
String,
|
|
1066
1132
|
(x) => this.Processor.Functions.tryEval(x)
|
|
1067
1133
|
);
|
|
1068
1134
|
}
|
|
1069
1135
|
if (fn.name === "cubic-bezier") {
|
|
1070
|
-
const cubicArguments =
|
|
1136
|
+
const cubicArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
|
|
1071
1137
|
String,
|
|
1072
1138
|
(x) => x.replace(/,\s/g, ",")
|
|
1073
1139
|
);
|
|
1074
1140
|
return `rt.cubicBezier(${cubicArguments})`;
|
|
1075
1141
|
}
|
|
1076
1142
|
if (fn.name === "steps") {
|
|
1077
|
-
const stepsArguments =
|
|
1143
|
+
const stepsArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
|
|
1078
1144
|
String,
|
|
1079
1145
|
(x) => x.replace(/,\s/g, ",")
|
|
1080
1146
|
);
|
|
1081
1147
|
return `rt.steps(${stepsArguments})`;
|
|
1082
1148
|
}
|
|
1083
1149
|
if (fn.name === "linear") {
|
|
1084
|
-
const linearArguments =
|
|
1150
|
+
const linearArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
|
|
1085
1151
|
String,
|
|
1086
1152
|
(x) => x.replace(/,\s/g, ",")
|
|
1087
1153
|
);
|
|
@@ -1211,7 +1277,7 @@ class Functions {
|
|
|
1211
1277
|
}
|
|
1212
1278
|
processColorMix(fn) {
|
|
1213
1279
|
const tokens = fn.arguments.map(
|
|
1214
|
-
(arg) =>
|
|
1280
|
+
(arg) => pipe(arg)(
|
|
1215
1281
|
(x) => this.Processor.CSS.processValue(x),
|
|
1216
1282
|
String,
|
|
1217
1283
|
(x) => x.trim()
|
|
@@ -1230,12 +1296,12 @@ class MQ {
|
|
|
1230
1296
|
for (const mediaQuery of mediaQueries) {
|
|
1231
1297
|
const { condition, mediaType } = mediaQuery;
|
|
1232
1298
|
if ([
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1299
|
+
config.Platform.Android,
|
|
1300
|
+
config.Platform.iOS,
|
|
1301
|
+
config.Platform.Native,
|
|
1302
|
+
config.Platform.AndroidTV,
|
|
1303
|
+
config.Platform.AppleTV,
|
|
1304
|
+
config.Platform.TV
|
|
1239
1305
|
].includes(mediaType)) {
|
|
1240
1306
|
mq.platform = mediaType;
|
|
1241
1307
|
continue;
|
|
@@ -1305,7 +1371,7 @@ const cssToRNMap = {
|
|
|
1305
1371
|
};
|
|
1306
1372
|
},
|
|
1307
1373
|
transitionProperty: (value) => {
|
|
1308
|
-
const properties = value.replace(/"/g, "").split(",").filter((token) => token !== "" && !token.startsWith("--")).map((token) => transitions[token.trim()] ?? `"${
|
|
1374
|
+
const properties = value.replace(/"/g, "").split(",").filter((token) => token !== "" && !token.startsWith("--")).map((token) => transitions[token.trim()] ?? `"${toCamelCase(token.trim())}"`);
|
|
1309
1375
|
if (properties.length === 1 && ['"allowDiscrete"', '"normal"'].includes(properties[0])) {
|
|
1310
1376
|
const behavior = properties[0] === '"allowDiscrete"' ? "allow-discrete" : "normal";
|
|
1311
1377
|
return {
|
|
@@ -1333,7 +1399,7 @@ const cssToRNMap = {
|
|
|
1333
1399
|
if (val === '"none"') {
|
|
1334
1400
|
continue;
|
|
1335
1401
|
}
|
|
1336
|
-
const keyName =
|
|
1402
|
+
const keyName = toCamelCase(`animation-${key.replace(/^"|"$/g, "")}`);
|
|
1337
1403
|
if (key === "name") {
|
|
1338
1404
|
result[keyName] = typeof val === "string" ? val.split(",").map((v) => v.startsWith('"') ? v : `"${v}"`) : val;
|
|
1339
1405
|
} else {
|
|
@@ -1486,13 +1552,65 @@ const cssToRNMap = {
|
|
|
1486
1552
|
const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
|
|
1487
1553
|
const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
|
|
1488
1554
|
const BORDER_RADIUS_KEYS = ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"];
|
|
1555
|
+
const COMPONENT_RESPONSIVE_PROPS = /* @__PURE__ */ new Set([
|
|
1556
|
+
"width",
|
|
1557
|
+
"height",
|
|
1558
|
+
"minWidth",
|
|
1559
|
+
"maxWidth",
|
|
1560
|
+
"minHeight",
|
|
1561
|
+
"maxHeight",
|
|
1562
|
+
"padding",
|
|
1563
|
+
"paddingTop",
|
|
1564
|
+
"paddingRight",
|
|
1565
|
+
"paddingBottom",
|
|
1566
|
+
"paddingLeft",
|
|
1567
|
+
"paddingHorizontal",
|
|
1568
|
+
"paddingVertical",
|
|
1569
|
+
"paddingStart",
|
|
1570
|
+
"paddingEnd",
|
|
1571
|
+
"margin",
|
|
1572
|
+
"marginTop",
|
|
1573
|
+
"marginRight",
|
|
1574
|
+
"marginBottom",
|
|
1575
|
+
"marginLeft",
|
|
1576
|
+
"marginHorizontal",
|
|
1577
|
+
"marginVertical",
|
|
1578
|
+
"marginStart",
|
|
1579
|
+
"marginEnd",
|
|
1580
|
+
"top",
|
|
1581
|
+
"right",
|
|
1582
|
+
"bottom",
|
|
1583
|
+
"left",
|
|
1584
|
+
"gap",
|
|
1585
|
+
"rowGap",
|
|
1586
|
+
"columnGap",
|
|
1587
|
+
"borderWidth",
|
|
1588
|
+
"borderTopWidth",
|
|
1589
|
+
"borderRightWidth",
|
|
1590
|
+
"borderBottomWidth",
|
|
1591
|
+
"borderLeftWidth",
|
|
1592
|
+
"borderStartWidth",
|
|
1593
|
+
"borderEndWidth",
|
|
1594
|
+
"borderRadius",
|
|
1595
|
+
"borderTopLeftRadius",
|
|
1596
|
+
"borderTopRightRadius",
|
|
1597
|
+
"borderBottomLeftRadius",
|
|
1598
|
+
"borderBottomRightRadius",
|
|
1599
|
+
"borderTopStartRadius",
|
|
1600
|
+
"borderTopEndRadius",
|
|
1601
|
+
"borderBottomStartRadius",
|
|
1602
|
+
"borderBottomEndRadius",
|
|
1603
|
+
"flexBasis",
|
|
1604
|
+
"translateX",
|
|
1605
|
+
"translateY"
|
|
1606
|
+
]);
|
|
1489
1607
|
class RN {
|
|
1490
1608
|
constructor(Processor) {
|
|
1491
1609
|
this.Processor = Processor;
|
|
1492
1610
|
}
|
|
1493
1611
|
cssToRN(property, value) {
|
|
1494
|
-
const transformedProperty = property.startsWith("--") ? property :
|
|
1495
|
-
|
|
1612
|
+
const transformedProperty = property.startsWith("--") ? property : pipe(property)(
|
|
1613
|
+
toCamelCase,
|
|
1496
1614
|
(x) => {
|
|
1497
1615
|
if (x.includes("padding") || x.includes("margin")) {
|
|
1498
1616
|
return x.replace("InlineStart", "Start").replace("InlineEnd", "End").replace("Inline", "Horizontal").replace("Block", "Vertical");
|
|
@@ -1505,10 +1623,37 @@ class RN {
|
|
|
1505
1623
|
);
|
|
1506
1624
|
const rn = this.transformProperty(
|
|
1507
1625
|
transformedProperty,
|
|
1508
|
-
typeof value === "string" ?
|
|
1626
|
+
typeof value === "string" ? addMissingSpaces(value) : value
|
|
1509
1627
|
);
|
|
1510
1628
|
const joinedStyles = this.joinStyles(rn);
|
|
1511
|
-
return Object.entries(joinedStyles).filter(([, value2]) => isDefined(value2));
|
|
1629
|
+
return Object.entries(joinedStyles).filter(([, value2]) => config.isDefined(value2)).map(([prop, val]) => [prop, this.makeResponsive(prop, val)]);
|
|
1630
|
+
}
|
|
1631
|
+
makeResponsive(property, value) {
|
|
1632
|
+
const mode = this.Processor.bundlerConfig.polyfills?.responsive;
|
|
1633
|
+
if (!mode) {
|
|
1634
|
+
return value;
|
|
1635
|
+
}
|
|
1636
|
+
if (typeof value === "string") {
|
|
1637
|
+
const rawValue = value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value;
|
|
1638
|
+
if (rawValue.endsWith("%")) {
|
|
1639
|
+
const numValue = parseFloat(rawValue);
|
|
1640
|
+
if (!isNaN(numValue)) {
|
|
1641
|
+
return `rt.makeResponsive(${numValue}, 100, true)`;
|
|
1642
|
+
}
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
if (typeof value !== "number") {
|
|
1646
|
+
return value;
|
|
1647
|
+
}
|
|
1648
|
+
const isTextMode = mode === true || mode === "text";
|
|
1649
|
+
const isComponentMode = mode === true || mode === "components";
|
|
1650
|
+
if (isTextMode && (property === "fontSize" || property === "--uniwind-em")) {
|
|
1651
|
+
return `rt.makeResponsive(${value}, ${config.DEFAULT_SCREEN_HEIGHT}, true)`;
|
|
1652
|
+
}
|
|
1653
|
+
if (isComponentMode && COMPONENT_RESPONSIVE_PROPS.has(property)) {
|
|
1654
|
+
return `rt.makeResponsive(${value}, ${config.DEFAULT_SCREEN_WIDTH})`;
|
|
1655
|
+
}
|
|
1656
|
+
return value;
|
|
1512
1657
|
}
|
|
1513
1658
|
transformProperty(property, value) {
|
|
1514
1659
|
if (property in cssToRNMap) {
|
|
@@ -1589,7 +1734,7 @@ class RN {
|
|
|
1589
1734
|
const borderWidth = styles.borderTopWidth;
|
|
1590
1735
|
if (BORDER_WIDTH_KEYS.every((key) => styles[key] === borderWidth)) {
|
|
1591
1736
|
return {
|
|
1592
|
-
...
|
|
1737
|
+
...removeKeys(styles, BORDER_WIDTH_KEYS),
|
|
1593
1738
|
borderWidth
|
|
1594
1739
|
};
|
|
1595
1740
|
}
|
|
@@ -1598,7 +1743,7 @@ class RN {
|
|
|
1598
1743
|
const borderColor = styles.borderTopColor;
|
|
1599
1744
|
if (BORDER_COLOR_KEYS.every((key) => styles[key] === borderColor)) {
|
|
1600
1745
|
return {
|
|
1601
|
-
...
|
|
1746
|
+
...removeKeys(styles, BORDER_COLOR_KEYS),
|
|
1602
1747
|
borderColor
|
|
1603
1748
|
};
|
|
1604
1749
|
}
|
|
@@ -1607,7 +1752,7 @@ class RN {
|
|
|
1607
1752
|
const borderRadius = styles.borderTopLeftRadius;
|
|
1608
1753
|
if (BORDER_RADIUS_KEYS.every((key) => styles[key] === borderRadius)) {
|
|
1609
1754
|
return {
|
|
1610
|
-
...
|
|
1755
|
+
...removeKeys(styles, BORDER_RADIUS_KEYS),
|
|
1611
1756
|
borderRadius
|
|
1612
1757
|
};
|
|
1613
1758
|
}
|
|
@@ -1620,7 +1765,7 @@ class Units {
|
|
|
1620
1765
|
constructor(Processor) {
|
|
1621
1766
|
this.Processor = Processor;
|
|
1622
1767
|
}
|
|
1623
|
-
logger = new
|
|
1768
|
+
logger = new config.Logger("Units");
|
|
1624
1769
|
processLength(length) {
|
|
1625
1770
|
if (typeof length === "number") {
|
|
1626
1771
|
return length;
|
|
@@ -1636,7 +1781,7 @@ class Units {
|
|
|
1636
1781
|
case "rem":
|
|
1637
1782
|
return length.value * this.Processor.vars["--uniwind-em"];
|
|
1638
1783
|
case "em":
|
|
1639
|
-
return `
|
|
1784
|
+
return `vars["--uniwind-em"]?.(vars) * ${length.value}`;
|
|
1640
1785
|
default:
|
|
1641
1786
|
this.logger.warn(`Unsupported unit - ${length.unit}`);
|
|
1642
1787
|
return length.value;
|
|
@@ -1669,7 +1814,7 @@ class Var {
|
|
|
1669
1814
|
this.Processor = Processor;
|
|
1670
1815
|
}
|
|
1671
1816
|
processVar(variable) {
|
|
1672
|
-
const value = `
|
|
1817
|
+
const value = `vars[${JSON.stringify(variable.name.ident)}]?.(vars)`;
|
|
1673
1818
|
if (!variable.fallback || variable.fallback.length === 0) {
|
|
1674
1819
|
return value;
|
|
1675
1820
|
}
|
|
@@ -1679,10 +1824,9 @@ class Var {
|
|
|
1679
1824
|
}
|
|
1680
1825
|
|
|
1681
1826
|
class ProcessorBuilder {
|
|
1682
|
-
constructor(
|
|
1683
|
-
this.
|
|
1684
|
-
this.
|
|
1685
|
-
this.vars["--uniwind-em"] = polyfills?.rem ?? 16;
|
|
1827
|
+
constructor(bundlerConfig) {
|
|
1828
|
+
this.bundlerConfig = bundlerConfig;
|
|
1829
|
+
this.vars["--uniwind-em"] = this.bundlerConfig.polyfills?.rem ?? 16;
|
|
1686
1830
|
}
|
|
1687
1831
|
stylesheets = {};
|
|
1688
1832
|
vars = {};
|
|
@@ -1758,7 +1902,7 @@ class ProcessorBuilder {
|
|
|
1758
1902
|
return this.stylesheets[this.declarationConfig.className]?.at(-1);
|
|
1759
1903
|
}
|
|
1760
1904
|
if (mq.platform !== null) {
|
|
1761
|
-
const platformKey = `${
|
|
1905
|
+
const platformKey = `${config.UNIWIND_PLATFORM_VARIABLES}${mq.platform}`;
|
|
1762
1906
|
this.scopedVars[platformKey] ??= {};
|
|
1763
1907
|
return this.scopedVars[platformKey];
|
|
1764
1908
|
}
|
|
@@ -1770,7 +1914,7 @@ class ProcessorBuilder {
|
|
|
1770
1914
|
if (this.declarationConfig.theme === null) {
|
|
1771
1915
|
return this.vars;
|
|
1772
1916
|
}
|
|
1773
|
-
const themeKey = `${
|
|
1917
|
+
const themeKey = `${config.UNIWIND_THEME_VARIABLES}${this.declarationConfig.theme}`;
|
|
1774
1918
|
this.scopedVars[themeKey] ??= {};
|
|
1775
1919
|
return this.scopedVars[themeKey];
|
|
1776
1920
|
})();
|
|
@@ -1792,7 +1936,7 @@ class ProcessorBuilder {
|
|
|
1792
1936
|
if (!isVar && important) {
|
|
1793
1937
|
style.importantProperties.push(property);
|
|
1794
1938
|
}
|
|
1795
|
-
const match = typeof value === "string" ? value.match(/
|
|
1939
|
+
const match = typeof value === "string" ? value.match(/vars\["(.*?)"\]/) : null;
|
|
1796
1940
|
if (match && !isVar) {
|
|
1797
1941
|
const className = this.declarationConfig.className;
|
|
1798
1942
|
if (className === null) {
|
|
@@ -1843,7 +1987,7 @@ class ProcessorBuilder {
|
|
|
1843
1987
|
if (property === "animation") {
|
|
1844
1988
|
return this.CSS.processAnimation(value);
|
|
1845
1989
|
}
|
|
1846
|
-
return this.CSS.processValue(value);
|
|
1990
|
+
return this.CSS.processValue(value, property);
|
|
1847
1991
|
};
|
|
1848
1992
|
if (declaration.property === "unparsed") {
|
|
1849
1993
|
const property = declaration.value.propertyId.property;
|
|
@@ -1894,7 +2038,7 @@ class ProcessorBuilder {
|
|
|
1894
2038
|
if (selector2.type === "pseudo-class" && selector2.kind === "where") {
|
|
1895
2039
|
selector2.selectors.forEach((selector3) => {
|
|
1896
2040
|
selector3.forEach((selector4) => {
|
|
1897
|
-
if (selector4.type === "class" && this.themes.includes(selector4.name)) {
|
|
2041
|
+
if (selector4.type === "class" && this.bundlerConfig.themes.includes(selector4.name)) {
|
|
1898
2042
|
theme = selector4.name;
|
|
1899
2043
|
}
|
|
1900
2044
|
if (selector4.type === "pseudo-class" && selector4.kind === "dir") {
|
|
@@ -1922,12 +2066,12 @@ class ProcessorBuilder {
|
|
|
1922
2066
|
}
|
|
1923
2067
|
});
|
|
1924
2068
|
if ([rtl, theme, active, focus, disabled, dataAttributes].some(Boolean)) {
|
|
1925
|
-
this.declarationConfig.rtl
|
|
1926
|
-
this.declarationConfig.theme
|
|
1927
|
-
this.declarationConfig.active
|
|
1928
|
-
this.declarationConfig.focus
|
|
1929
|
-
this.declarationConfig.disabled
|
|
1930
|
-
this.declarationConfig.dataAttributes
|
|
2069
|
+
this.declarationConfig.rtl ??= rtl;
|
|
2070
|
+
this.declarationConfig.theme ??= theme;
|
|
2071
|
+
this.declarationConfig.active ??= active;
|
|
2072
|
+
this.declarationConfig.focus ??= focus;
|
|
2073
|
+
this.declarationConfig.disabled ??= disabled;
|
|
2074
|
+
this.declarationConfig.dataAttributes ??= dataAttributes;
|
|
1931
2075
|
rule.value.declarations?.declarations?.forEach((declaration) => this.addDeclaration(declaration));
|
|
1932
2076
|
rule.value.declarations?.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
|
|
1933
2077
|
rule.value.rules?.forEach((rule2) => this.parseRuleRec(rule2));
|
|
@@ -2006,52 +2150,29 @@ class ProcessorBuilder {
|
|
|
2006
2150
|
}
|
|
2007
2151
|
}
|
|
2008
2152
|
|
|
2009
|
-
const
|
|
2010
|
-
const
|
|
2011
|
-
base: path__default.dirname(cssPath),
|
|
2012
|
-
onDependency: () => void 0
|
|
2013
|
-
});
|
|
2014
|
-
const scanner = new oxide.Scanner({
|
|
2015
|
-
sources: [
|
|
2016
|
-
...compiler.sources,
|
|
2017
|
-
{
|
|
2018
|
-
negated: false,
|
|
2019
|
-
pattern: "**/*",
|
|
2020
|
-
base: path__default.dirname(cssPath)
|
|
2021
|
-
}
|
|
2022
|
-
]
|
|
2023
|
-
});
|
|
2024
|
-
const tailwindCSS = compiler.build(candidates ?? scanner.scan());
|
|
2025
|
-
if (platform === consts.Platform.Web) {
|
|
2026
|
-
return lightningcss.transform({
|
|
2027
|
-
code: Buffer.from(tailwindCSS),
|
|
2028
|
-
filename: "uniwind.css",
|
|
2029
|
-
visitor: new stringifyThemes.UniwindCSSVisitor(themes)
|
|
2030
|
-
}).code.toString();
|
|
2031
|
-
}
|
|
2032
|
-
const Processor = new ProcessorBuilder(themes, polyfills);
|
|
2033
|
-
stringifyThemes.Logger.debug = debug === true;
|
|
2153
|
+
const compileNativeCSS = (bundlerConfig, tailwindCSS) => {
|
|
2154
|
+
const Processor = new ProcessorBuilder(bundlerConfig);
|
|
2034
2155
|
Processor.transform(tailwindCSS);
|
|
2035
2156
|
const stylesheet = serializeJSObject(
|
|
2036
|
-
addMetaToStylesTemplate(Processor, platform),
|
|
2157
|
+
addMetaToStylesTemplate(Processor, bundlerConfig.platform),
|
|
2037
2158
|
(key, value) => `"${key}": ${value}`
|
|
2038
2159
|
);
|
|
2039
2160
|
const vars = serializeJSObject(
|
|
2040
2161
|
Processor.vars,
|
|
2162
|
+
(key, value) => `"${key}": vars => ${value}`
|
|
2163
|
+
);
|
|
2164
|
+
const keyframes = serializeJSObject(
|
|
2165
|
+
Processor.keyframes,
|
|
2041
2166
|
(key, value) => `get "${key}"() { return ${value} }`
|
|
2042
2167
|
);
|
|
2043
2168
|
const scopedVars = Object.fromEntries(
|
|
2044
2169
|
Object.entries(Processor.scopedVars).map(([scopedVarsName, scopedVars2]) => [
|
|
2045
2170
|
scopedVarsName,
|
|
2046
|
-
serializeJSObject(scopedVars2, (key, value) => `
|
|
2171
|
+
serializeJSObject(scopedVars2, (key, value) => `"${key}": vars => ${value}`)
|
|
2047
2172
|
])
|
|
2048
2173
|
);
|
|
2049
|
-
const keyframes = serializeJSObject(
|
|
2050
|
-
Processor.keyframes,
|
|
2051
|
-
(key, value) => `get "${key}"() { return ${value} }`
|
|
2052
|
-
);
|
|
2053
2174
|
const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
|
|
2054
|
-
const currentColorVar = `
|
|
2175
|
+
const currentColorVar = `currentColor: () => rt.colorScheme === 'dark' ? '#ffffff' : '#000000',`;
|
|
2055
2176
|
return [
|
|
2056
2177
|
"({",
|
|
2057
2178
|
`scopedVars: ({ ${serializedScopedVars} }),`,
|
|
@@ -2062,17 +2183,42 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
|
|
|
2062
2183
|
].join("");
|
|
2063
2184
|
};
|
|
2064
2185
|
|
|
2065
|
-
const
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2186
|
+
const compileTailwind = async (bundlerConfig) => {
|
|
2187
|
+
const css = await fs__default.promises.readFile(bundlerConfig.cssPath, "utf-8");
|
|
2188
|
+
const compiler = await node.compile(css, {
|
|
2189
|
+
base: path__default.dirname(bundlerConfig.cssPath),
|
|
2190
|
+
onDependency: () => void 0
|
|
2191
|
+
});
|
|
2192
|
+
const scanner = new oxide.Scanner({
|
|
2193
|
+
sources: [
|
|
2194
|
+
...compiler.sources,
|
|
2195
|
+
{
|
|
2196
|
+
negated: false,
|
|
2197
|
+
pattern: "**/*",
|
|
2198
|
+
base: path__default.dirname(bundlerConfig.cssPath)
|
|
2199
|
+
}
|
|
2200
|
+
]
|
|
2201
|
+
});
|
|
2202
|
+
return compiler.build(scanner.scan());
|
|
2074
2203
|
};
|
|
2075
2204
|
|
|
2205
|
+
const compileWebCSS = (bundlerConfig, tailwindCSS) => {
|
|
2206
|
+
return lightningcss.transform({
|
|
2207
|
+
code: Buffer.from(tailwindCSS),
|
|
2208
|
+
filename: "uniwind.css",
|
|
2209
|
+
visitor: bundlerConfig.cssVisitor
|
|
2210
|
+
}).code.toString();
|
|
2211
|
+
};
|
|
2212
|
+
|
|
2213
|
+
const compileCSS = async (bundlerConfig) => {
|
|
2214
|
+
const tailwindCSS = await compileTailwind(bundlerConfig);
|
|
2215
|
+
if (bundlerConfig.platform === config.Platform.Web) {
|
|
2216
|
+
return compileWebCSS(bundlerConfig, tailwindCSS);
|
|
2217
|
+
}
|
|
2218
|
+
return compileNativeCSS(bundlerConfig, tailwindCSS);
|
|
2219
|
+
};
|
|
2220
|
+
|
|
2221
|
+
const cssArtifactPath = path__default.resolve(__dirname, "../../uniwind.css");
|
|
2076
2222
|
let worker;
|
|
2077
2223
|
try {
|
|
2078
2224
|
try {
|
|
@@ -2084,64 +2230,34 @@ try {
|
|
|
2084
2230
|
} catch {
|
|
2085
2231
|
worker = require("metro-transform-worker");
|
|
2086
2232
|
}
|
|
2087
|
-
const transform = async (config, projectRoot, filePath, data, options) => {
|
|
2088
|
-
const isCss = options.type !== "asset" && path__default.join(process.cwd(), config.uniwind.cssEntryFile) === path__default.join(projectRoot, filePath);
|
|
2233
|
+
const transform = async (config$1, projectRoot, filePath, data, options) => {
|
|
2234
|
+
const isCss = options.type !== "asset" && path__default.join(process.cwd(), config$1.uniwind.cssEntryFile) === path__default.join(projectRoot, filePath);
|
|
2089
2235
|
if (filePath.endsWith("/components/web/metro-injected.js")) {
|
|
2090
|
-
const
|
|
2091
|
-
const injectedThemesCode2 = await injectThemes({
|
|
2092
|
-
input: cssPath2,
|
|
2093
|
-
themes: config.uniwind.themes,
|
|
2094
|
-
dtsPath: config.uniwind.dtsFile
|
|
2095
|
-
});
|
|
2236
|
+
const bundlerConfig2 = config.UniwindBundlerConfig.fromMetroConfig(config$1.uniwind, config.Platform.Web);
|
|
2096
2237
|
data = Buffer.from(
|
|
2097
2238
|
[
|
|
2098
|
-
`import { Uniwind } from '${
|
|
2099
|
-
`Uniwind.__reinit(() => ({}), ${
|
|
2239
|
+
`import { Uniwind } from '${_package.name}';`,
|
|
2240
|
+
`Uniwind.__reinit(() => ({}), ${bundlerConfig2.stringifiedThemes});`
|
|
2100
2241
|
].join(""),
|
|
2101
2242
|
"utf-8"
|
|
2102
2243
|
);
|
|
2103
2244
|
}
|
|
2104
2245
|
if (!isCss) {
|
|
2105
|
-
return worker.transform(config, projectRoot, filePath, data, options);
|
|
2246
|
+
return worker.transform(config$1, projectRoot, filePath, data, options);
|
|
2106
2247
|
}
|
|
2107
|
-
const
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
if (options.platform === consts.Platform.Android) {
|
|
2112
|
-
return consts.Platform.AndroidTV;
|
|
2113
|
-
}
|
|
2114
|
-
if (options.platform === consts.Platform.iOS) {
|
|
2115
|
-
return consts.Platform.AppleTV;
|
|
2116
|
-
}
|
|
2117
|
-
throw new Error(`Platform ${options.platform} not supported`);
|
|
2118
|
-
};
|
|
2119
|
-
const cssPath = path__default.join(process.cwd(), config.uniwind.cssEntryFile);
|
|
2120
|
-
const injectedThemesCode = await injectThemes({
|
|
2121
|
-
input: cssPath,
|
|
2122
|
-
themes: config.uniwind.themes,
|
|
2123
|
-
dtsPath: config.uniwind.dtsFile
|
|
2124
|
-
});
|
|
2125
|
-
const css = fs__default.readFileSync(cssPath, "utf-8");
|
|
2126
|
-
const platform = getPlatform();
|
|
2127
|
-
const virtualCode = await compileVirtual({
|
|
2128
|
-
css,
|
|
2129
|
-
platform,
|
|
2130
|
-
themes: config.uniwind.themes,
|
|
2131
|
-
polyfills: config.uniwind.polyfills,
|
|
2132
|
-
cssPath,
|
|
2133
|
-
debug: config.uniwind.debug
|
|
2134
|
-
});
|
|
2135
|
-
const isWeb = platform === consts.Platform.Web;
|
|
2248
|
+
const bundlerConfig = config.UniwindBundlerConfig.fromMetroConfig(config$1.uniwind, options.platform);
|
|
2249
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
2250
|
+
const virtualCode = await compileCSS(bundlerConfig);
|
|
2251
|
+
const isWeb = bundlerConfig.platform === config.Platform.Web;
|
|
2136
2252
|
data = Buffer.from(
|
|
2137
2253
|
isWeb ? virtualCode : [
|
|
2138
|
-
`const { Uniwind } = require('${
|
|
2139
|
-
`Uniwind.__reinit(rt => ${virtualCode}, ${
|
|
2254
|
+
`const { Uniwind } = require('${_package.name}');`,
|
|
2255
|
+
`Uniwind.__reinit(rt => ${virtualCode}, ${bundlerConfig.stringifiedThemes});`
|
|
2140
2256
|
].join(""),
|
|
2141
2257
|
"utf-8"
|
|
2142
2258
|
);
|
|
2143
2259
|
const transform2 = await worker.transform(
|
|
2144
|
-
config,
|
|
2260
|
+
config$1,
|
|
2145
2261
|
projectRoot,
|
|
2146
2262
|
`${filePath}${isWeb ? "" : ".js"}`,
|
|
2147
2263
|
data,
|