@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,12 +1,79 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { L as Logger, P as Platform, S as StyleDependency, i as isDefined, D as DEFAULT_SCREEN_HEIGHT, a as DEFAULT_SCREEN_WIDTH, b as UNIWIND_PLATFORM_VARIABLES, c as UNIWIND_THEME_VARIABLES, U as UniwindBundlerConfig } from '../shared/uniwind.DgC4MT51.mjs';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
import { P as Platform, U as UNIWIND_PLATFORM_VARIABLES, a as UNIWIND_THEME_VARIABLES } from '../shared/uniwind.JSWK3vHl.mjs';
|
|
5
|
-
import { compile } from '@tailwindcss/node';
|
|
6
|
-
import { Scanner } from '@tailwindcss/oxide';
|
|
3
|
+
import { n as name } from '../shared/uniwind.CFAAUZ2t.mjs';
|
|
7
4
|
import { transform as transform$1 } from 'lightningcss';
|
|
8
|
-
import { L as Logger, U as UniwindCSSVisitor, s as stringifyThemes, b as buildDtsFile, a as buildCSS } from '../shared/uniwind.BGiqYvxb.mjs';
|
|
9
5
|
import { converter, parse, formatHex, formatHex8 } from 'culori';
|
|
6
|
+
import { compile } from '@tailwindcss/node';
|
|
7
|
+
import { Scanner } from '@tailwindcss/oxide';
|
|
8
|
+
import fs from 'fs';
|
|
9
|
+
|
|
10
|
+
const toCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
11
|
+
const pipe = (data) => ((...fns) => fns.reduce((acc, fn) => fn(acc), data));
|
|
12
|
+
const isNumber = (data) => {
|
|
13
|
+
if (typeof data === "number") {
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
if (typeof data === "string" && data !== "") {
|
|
17
|
+
return !isNaN(Number(data));
|
|
18
|
+
}
|
|
19
|
+
return false;
|
|
20
|
+
};
|
|
21
|
+
const smartSplit = (str, separator = " ") => {
|
|
22
|
+
const escaper = "&&&";
|
|
23
|
+
return pipe(str)(
|
|
24
|
+
(x) => x.replace(/\s\?\?\s/g, `${escaper}??${escaper}`),
|
|
25
|
+
(x) => x.replace(/\s([+\-*/])\s/g, `${escaper}$1${escaper}`),
|
|
26
|
+
(x) => x.split(separator),
|
|
27
|
+
(x) => x.map((token) => token.replace(new RegExp(escaper, "g"), " "))
|
|
28
|
+
);
|
|
29
|
+
};
|
|
30
|
+
const addMissingSpaces = (str) => pipe(str)(
|
|
31
|
+
(x) => x.trim(),
|
|
32
|
+
(x) => x.replace(/\](?=\d)/g, "] "),
|
|
33
|
+
(x) => x.replace(/\](?=")/g, "] "),
|
|
34
|
+
(x) => x.replace(/\)(?=[^\s,])/g, ") "),
|
|
35
|
+
(x) => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" ')
|
|
36
|
+
);
|
|
37
|
+
const isValidJSValue = (jsValueString) => {
|
|
38
|
+
try {
|
|
39
|
+
new Function(`const test = ${jsValueString}`);
|
|
40
|
+
return true;
|
|
41
|
+
} catch {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const shouldBeSerialized = (value) => {
|
|
46
|
+
if (value.includes("-")) {
|
|
47
|
+
return value.split("-").some(shouldBeSerialized);
|
|
48
|
+
}
|
|
49
|
+
return [
|
|
50
|
+
isNumber(value),
|
|
51
|
+
value.startsWith("vars["),
|
|
52
|
+
value.startsWith("rt."),
|
|
53
|
+
/[*/+-]/.test(value),
|
|
54
|
+
value.includes('"'),
|
|
55
|
+
value.includes(" "),
|
|
56
|
+
value === "(",
|
|
57
|
+
value === ")"
|
|
58
|
+
].some(Boolean);
|
|
59
|
+
};
|
|
60
|
+
const roundToPrecision = (value, precision) => parseFloat(value.toFixed(precision));
|
|
61
|
+
const deepEqual = (a, b) => {
|
|
62
|
+
if (Object.is(a, b)) {
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
65
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
const keysA = Object.keys(a);
|
|
69
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return keysA.every((key) => deepEqual(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key));
|
|
73
|
+
};
|
|
74
|
+
const removeKeys = (obj, keysToRemove) => Object.fromEntries(
|
|
75
|
+
Object.entries(obj).filter(([key]) => !keysToRemove.includes(key))
|
|
76
|
+
);
|
|
10
77
|
|
|
11
78
|
const parseStringValue = (value) => {
|
|
12
79
|
if (isValidJSValue(value)) {
|
|
@@ -107,24 +174,9 @@ const serializeJSObject = (obj, serializer) => {
|
|
|
107
174
|
return serializedObject;
|
|
108
175
|
};
|
|
109
176
|
|
|
110
|
-
const isDefined = (value) => value !== void 0 && value !== null;
|
|
111
|
-
|
|
112
|
-
var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
|
|
113
|
-
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
114
|
-
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
115
|
-
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
116
|
-
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
117
|
-
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
118
|
-
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
119
|
-
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
120
|
-
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
121
|
-
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
122
|
-
return StyleDependency2;
|
|
123
|
-
})(StyleDependency || {});
|
|
124
|
-
|
|
125
177
|
const extractVarsFromString = (value) => {
|
|
126
|
-
const
|
|
127
|
-
return
|
|
178
|
+
const varsIndexes = [...value.matchAll(/vars\[/g)].map((m) => m.index);
|
|
179
|
+
return varsIndexes.map((index) => {
|
|
128
180
|
const afterIndex = value.slice(index + 5);
|
|
129
181
|
const closingIndex = afterIndex.indexOf("]");
|
|
130
182
|
const varName = afterIndex.slice(0, closingIndex);
|
|
@@ -140,6 +192,23 @@ const makeSafeForSerialization = (value) => {
|
|
|
140
192
|
}
|
|
141
193
|
return value;
|
|
142
194
|
};
|
|
195
|
+
const hasThemedVarDependency = (varName, Processor, visited = /* @__PURE__ */ new Set()) => {
|
|
196
|
+
if (visited.has(varName)) {
|
|
197
|
+
return false;
|
|
198
|
+
}
|
|
199
|
+
visited.add(varName);
|
|
200
|
+
const isScopedVar = Object.values(Processor.scopedVars).some((scopedVars) => varName in scopedVars);
|
|
201
|
+
if (isScopedVar) {
|
|
202
|
+
return true;
|
|
203
|
+
}
|
|
204
|
+
const globalVarValue = Processor.vars[varName];
|
|
205
|
+
if (typeof globalVarValue !== "string") {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
return extractVarsFromString(globalVarValue).some((usedVarName) => {
|
|
209
|
+
return hasThemedVarDependency(usedVarName, Processor, visited);
|
|
210
|
+
});
|
|
211
|
+
};
|
|
143
212
|
const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
144
213
|
const stylesheetsEntries = Object.entries(Processor.stylesheets).map(([className, stylesPerMediaQuery]) => {
|
|
145
214
|
const styles = stylesPerMediaQuery.map((style, index) => {
|
|
@@ -159,7 +228,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
159
228
|
dataAttributes,
|
|
160
229
|
...rest
|
|
161
230
|
} = style;
|
|
162
|
-
const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function() { return ${serialize(value)} }`]);
|
|
231
|
+
const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function(vars) { return ${serialize(value)} }`]);
|
|
163
232
|
if (platform) {
|
|
164
233
|
const isTV = currentPlatform === Platform.AndroidTV || currentPlatform === Platform.AppleTV;
|
|
165
234
|
const commonPlatform = isTV ? Platform.TV : Platform.Native;
|
|
@@ -173,12 +242,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
173
242
|
const dependencies = [];
|
|
174
243
|
const stringifiedEntries = JSON.stringify(entries);
|
|
175
244
|
const usedVars = extractVarsFromString(stringifiedEntries);
|
|
176
|
-
const isUsingThemedVar = usedVars.some((usedVarName) =>
|
|
177
|
-
return Object.values(Processor.scopedVars).some((scopedVars) => {
|
|
178
|
-
const scopedVarsNames = Object.keys(scopedVars);
|
|
179
|
-
return scopedVarsNames.includes(usedVarName);
|
|
180
|
-
});
|
|
181
|
-
});
|
|
245
|
+
const isUsingThemedVar = usedVars.some((usedVarName) => hasThemedVarDependency(usedVarName, Processor));
|
|
182
246
|
if (usedVars.length > 0) {
|
|
183
247
|
dependencies.push(StyleDependency.Variables);
|
|
184
248
|
}
|
|
@@ -191,7 +255,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
191
255
|
if (rtl !== null) {
|
|
192
256
|
dependencies.push(StyleDependency.Rtl);
|
|
193
257
|
}
|
|
194
|
-
if (Number(minWidth) !== 0 || Number(maxWidth) !== Number.MAX_VALUE || stringifiedEntries.includes("rt.screen")) {
|
|
258
|
+
if (Number(minWidth) !== 0 || Number(maxWidth) !== Number.MAX_VALUE || stringifiedEntries.includes("rt.makeResponsive") || stringifiedEntries.includes("rt.screen")) {
|
|
195
259
|
dependencies.push(StyleDependency.Dimensions);
|
|
196
260
|
}
|
|
197
261
|
if (stringifiedEntries.includes("rt.insets")) {
|
|
@@ -215,7 +279,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
215
279
|
active,
|
|
216
280
|
focus,
|
|
217
281
|
disabled,
|
|
218
|
-
importantProperties: importantProperties?.map((property) => property.startsWith("--") ? property : toCamelCase).map(makeSafeForSerialization) ?? [],
|
|
282
|
+
importantProperties: importantProperties?.map((property) => property.startsWith("--") ? property : toCamelCase(property)).map(makeSafeForSerialization) ?? [],
|
|
219
283
|
dataAttributes,
|
|
220
284
|
complexity: [
|
|
221
285
|
minWidth !== 0,
|
|
@@ -287,11 +351,7 @@ const parseTransformsMutation = (styles, preserve = false) => {
|
|
|
287
351
|
}
|
|
288
352
|
}
|
|
289
353
|
if (transformsResult.length > 0) {
|
|
290
|
-
|
|
291
|
-
configurable: true,
|
|
292
|
-
enumerable: true,
|
|
293
|
-
value: transformsResult
|
|
294
|
-
});
|
|
354
|
+
styles.transform = transformsResult;
|
|
295
355
|
}
|
|
296
356
|
};
|
|
297
357
|
|
|
@@ -318,7 +378,7 @@ class Color {
|
|
|
318
378
|
}
|
|
319
379
|
try {
|
|
320
380
|
if (color.type === "currentcolor") {
|
|
321
|
-
return '
|
|
381
|
+
return 'vars["currentColor"]?.(vars)';
|
|
322
382
|
}
|
|
323
383
|
if (color.type === "rgb" || color.type === "srgb") {
|
|
324
384
|
const alpha = typeof color.alpha === "number" ? color.alpha : pipe(color.alpha)(
|
|
@@ -473,8 +533,8 @@ class CSS {
|
|
|
473
533
|
this.Processor = Processor;
|
|
474
534
|
}
|
|
475
535
|
logger = new Logger("CSS");
|
|
476
|
-
processValue(declarationValue) {
|
|
477
|
-
const processedValue = this.getProcessedValue(declarationValue);
|
|
536
|
+
processValue(declarationValue, declarationProperty) {
|
|
537
|
+
const processedValue = this.getProcessedValue(declarationValue, declarationProperty);
|
|
478
538
|
if (typeof processedValue === "string") {
|
|
479
539
|
return this.makeSafeForSerialization(processedValue);
|
|
480
540
|
}
|
|
@@ -545,7 +605,7 @@ class CSS {
|
|
|
545
605
|
});
|
|
546
606
|
return filterStrings.join(" ");
|
|
547
607
|
}
|
|
548
|
-
getProcessedValue(declarationValue) {
|
|
608
|
+
getProcessedValue(declarationValue, declarationProperty) {
|
|
549
609
|
if (typeof declarationValue !== "object") {
|
|
550
610
|
return declarationValue;
|
|
551
611
|
}
|
|
@@ -700,7 +760,7 @@ class CSS {
|
|
|
700
760
|
return this.Processor.Color.processColor(declarationValue.value);
|
|
701
761
|
}
|
|
702
762
|
if (declarationValue.value === "currentcolor") {
|
|
703
|
-
return '
|
|
763
|
+
return 'vars["currentColor"]?.(vars)';
|
|
704
764
|
}
|
|
705
765
|
return declarationValue.value;
|
|
706
766
|
case "env":
|
|
@@ -737,7 +797,7 @@ class CSS {
|
|
|
737
797
|
case "pair":
|
|
738
798
|
return declarationValue.inside.type;
|
|
739
799
|
case "currentcolor":
|
|
740
|
-
return '
|
|
800
|
+
return 'vars["currentColor"]?.(vars)';
|
|
741
801
|
case "calc":
|
|
742
802
|
return this.Processor.Functions.processCalc(declarationValue.value);
|
|
743
803
|
case "min":
|
|
@@ -830,11 +890,17 @@ class CSS {
|
|
|
830
890
|
};
|
|
831
891
|
}
|
|
832
892
|
if ("grow" in declarationValue) {
|
|
833
|
-
|
|
893
|
+
const parsedFlex = {
|
|
834
894
|
flexGrow: declarationValue.grow,
|
|
835
895
|
flexShrink: declarationValue.shrink,
|
|
836
896
|
flexBasis: this.processValue(declarationValue.basis)
|
|
837
897
|
};
|
|
898
|
+
if (declarationProperty === "flex" && parsedFlex.flexGrow === 1 && parsedFlex.flexShrink === 1 && parsedFlex.flexBasis === '"0%"') {
|
|
899
|
+
return {
|
|
900
|
+
flex: 1
|
|
901
|
+
};
|
|
902
|
+
}
|
|
903
|
+
return parsedFlex;
|
|
838
904
|
}
|
|
839
905
|
if (Array.isArray(declarationValue)) {
|
|
840
906
|
if (declarationValue.length === 1) {
|
|
@@ -1479,6 +1545,58 @@ const cssToRNMap = {
|
|
|
1479
1545
|
const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
|
|
1480
1546
|
const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
|
|
1481
1547
|
const BORDER_RADIUS_KEYS = ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"];
|
|
1548
|
+
const COMPONENT_RESPONSIVE_PROPS = /* @__PURE__ */ new Set([
|
|
1549
|
+
"width",
|
|
1550
|
+
"height",
|
|
1551
|
+
"minWidth",
|
|
1552
|
+
"maxWidth",
|
|
1553
|
+
"minHeight",
|
|
1554
|
+
"maxHeight",
|
|
1555
|
+
"padding",
|
|
1556
|
+
"paddingTop",
|
|
1557
|
+
"paddingRight",
|
|
1558
|
+
"paddingBottom",
|
|
1559
|
+
"paddingLeft",
|
|
1560
|
+
"paddingHorizontal",
|
|
1561
|
+
"paddingVertical",
|
|
1562
|
+
"paddingStart",
|
|
1563
|
+
"paddingEnd",
|
|
1564
|
+
"margin",
|
|
1565
|
+
"marginTop",
|
|
1566
|
+
"marginRight",
|
|
1567
|
+
"marginBottom",
|
|
1568
|
+
"marginLeft",
|
|
1569
|
+
"marginHorizontal",
|
|
1570
|
+
"marginVertical",
|
|
1571
|
+
"marginStart",
|
|
1572
|
+
"marginEnd",
|
|
1573
|
+
"top",
|
|
1574
|
+
"right",
|
|
1575
|
+
"bottom",
|
|
1576
|
+
"left",
|
|
1577
|
+
"gap",
|
|
1578
|
+
"rowGap",
|
|
1579
|
+
"columnGap",
|
|
1580
|
+
"borderWidth",
|
|
1581
|
+
"borderTopWidth",
|
|
1582
|
+
"borderRightWidth",
|
|
1583
|
+
"borderBottomWidth",
|
|
1584
|
+
"borderLeftWidth",
|
|
1585
|
+
"borderStartWidth",
|
|
1586
|
+
"borderEndWidth",
|
|
1587
|
+
"borderRadius",
|
|
1588
|
+
"borderTopLeftRadius",
|
|
1589
|
+
"borderTopRightRadius",
|
|
1590
|
+
"borderBottomLeftRadius",
|
|
1591
|
+
"borderBottomRightRadius",
|
|
1592
|
+
"borderTopStartRadius",
|
|
1593
|
+
"borderTopEndRadius",
|
|
1594
|
+
"borderBottomStartRadius",
|
|
1595
|
+
"borderBottomEndRadius",
|
|
1596
|
+
"flexBasis",
|
|
1597
|
+
"translateX",
|
|
1598
|
+
"translateY"
|
|
1599
|
+
]);
|
|
1482
1600
|
class RN {
|
|
1483
1601
|
constructor(Processor) {
|
|
1484
1602
|
this.Processor = Processor;
|
|
@@ -1501,7 +1619,34 @@ class RN {
|
|
|
1501
1619
|
typeof value === "string" ? addMissingSpaces(value) : value
|
|
1502
1620
|
);
|
|
1503
1621
|
const joinedStyles = this.joinStyles(rn);
|
|
1504
|
-
return Object.entries(joinedStyles).filter(([, value2]) => isDefined(value2));
|
|
1622
|
+
return Object.entries(joinedStyles).filter(([, value2]) => isDefined(value2)).map(([prop, val]) => [prop, this.makeResponsive(prop, val)]);
|
|
1623
|
+
}
|
|
1624
|
+
makeResponsive(property, value) {
|
|
1625
|
+
const mode = this.Processor.bundlerConfig.polyfills?.responsive;
|
|
1626
|
+
if (!mode) {
|
|
1627
|
+
return value;
|
|
1628
|
+
}
|
|
1629
|
+
if (typeof value === "string") {
|
|
1630
|
+
const rawValue = value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value;
|
|
1631
|
+
if (rawValue.endsWith("%")) {
|
|
1632
|
+
const numValue = parseFloat(rawValue);
|
|
1633
|
+
if (!isNaN(numValue)) {
|
|
1634
|
+
return `rt.makeResponsive(${numValue}, 100, true)`;
|
|
1635
|
+
}
|
|
1636
|
+
}
|
|
1637
|
+
}
|
|
1638
|
+
if (typeof value !== "number") {
|
|
1639
|
+
return value;
|
|
1640
|
+
}
|
|
1641
|
+
const isTextMode = mode === true || mode === "text";
|
|
1642
|
+
const isComponentMode = mode === true || mode === "components";
|
|
1643
|
+
if (isTextMode && (property === "fontSize" || property === "--uniwind-em")) {
|
|
1644
|
+
return `rt.makeResponsive(${value}, ${DEFAULT_SCREEN_HEIGHT}, true)`;
|
|
1645
|
+
}
|
|
1646
|
+
if (isComponentMode && COMPONENT_RESPONSIVE_PROPS.has(property)) {
|
|
1647
|
+
return `rt.makeResponsive(${value}, ${DEFAULT_SCREEN_WIDTH})`;
|
|
1648
|
+
}
|
|
1649
|
+
return value;
|
|
1505
1650
|
}
|
|
1506
1651
|
transformProperty(property, value) {
|
|
1507
1652
|
if (property in cssToRNMap) {
|
|
@@ -1629,7 +1774,7 @@ class Units {
|
|
|
1629
1774
|
case "rem":
|
|
1630
1775
|
return length.value * this.Processor.vars["--uniwind-em"];
|
|
1631
1776
|
case "em":
|
|
1632
|
-
return `
|
|
1777
|
+
return `vars["--uniwind-em"]?.(vars) * ${length.value}`;
|
|
1633
1778
|
default:
|
|
1634
1779
|
this.logger.warn(`Unsupported unit - ${length.unit}`);
|
|
1635
1780
|
return length.value;
|
|
@@ -1662,7 +1807,7 @@ class Var {
|
|
|
1662
1807
|
this.Processor = Processor;
|
|
1663
1808
|
}
|
|
1664
1809
|
processVar(variable) {
|
|
1665
|
-
const value = `
|
|
1810
|
+
const value = `vars[${JSON.stringify(variable.name.ident)}]?.(vars)`;
|
|
1666
1811
|
if (!variable.fallback || variable.fallback.length === 0) {
|
|
1667
1812
|
return value;
|
|
1668
1813
|
}
|
|
@@ -1672,10 +1817,9 @@ class Var {
|
|
|
1672
1817
|
}
|
|
1673
1818
|
|
|
1674
1819
|
class ProcessorBuilder {
|
|
1675
|
-
constructor(
|
|
1676
|
-
this.
|
|
1677
|
-
this.
|
|
1678
|
-
this.vars["--uniwind-em"] = polyfills?.rem ?? 16;
|
|
1820
|
+
constructor(bundlerConfig) {
|
|
1821
|
+
this.bundlerConfig = bundlerConfig;
|
|
1822
|
+
this.vars["--uniwind-em"] = this.bundlerConfig.polyfills?.rem ?? 16;
|
|
1679
1823
|
}
|
|
1680
1824
|
stylesheets = {};
|
|
1681
1825
|
vars = {};
|
|
@@ -1785,7 +1929,7 @@ class ProcessorBuilder {
|
|
|
1785
1929
|
if (!isVar && important) {
|
|
1786
1930
|
style.importantProperties.push(property);
|
|
1787
1931
|
}
|
|
1788
|
-
const match = typeof value === "string" ? value.match(/
|
|
1932
|
+
const match = typeof value === "string" ? value.match(/vars\["(.*?)"\]/) : null;
|
|
1789
1933
|
if (match && !isVar) {
|
|
1790
1934
|
const className = this.declarationConfig.className;
|
|
1791
1935
|
if (className === null) {
|
|
@@ -1836,7 +1980,7 @@ class ProcessorBuilder {
|
|
|
1836
1980
|
if (property === "animation") {
|
|
1837
1981
|
return this.CSS.processAnimation(value);
|
|
1838
1982
|
}
|
|
1839
|
-
return this.CSS.processValue(value);
|
|
1983
|
+
return this.CSS.processValue(value, property);
|
|
1840
1984
|
};
|
|
1841
1985
|
if (declaration.property === "unparsed") {
|
|
1842
1986
|
const property = declaration.value.propertyId.property;
|
|
@@ -1887,7 +2031,7 @@ class ProcessorBuilder {
|
|
|
1887
2031
|
if (selector2.type === "pseudo-class" && selector2.kind === "where") {
|
|
1888
2032
|
selector2.selectors.forEach((selector3) => {
|
|
1889
2033
|
selector3.forEach((selector4) => {
|
|
1890
|
-
if (selector4.type === "class" && this.themes.includes(selector4.name)) {
|
|
2034
|
+
if (selector4.type === "class" && this.bundlerConfig.themes.includes(selector4.name)) {
|
|
1891
2035
|
theme = selector4.name;
|
|
1892
2036
|
}
|
|
1893
2037
|
if (selector4.type === "pseudo-class" && selector4.kind === "dir") {
|
|
@@ -1915,12 +2059,12 @@ class ProcessorBuilder {
|
|
|
1915
2059
|
}
|
|
1916
2060
|
});
|
|
1917
2061
|
if ([rtl, theme, active, focus, disabled, dataAttributes].some(Boolean)) {
|
|
1918
|
-
this.declarationConfig.rtl
|
|
1919
|
-
this.declarationConfig.theme
|
|
1920
|
-
this.declarationConfig.active
|
|
1921
|
-
this.declarationConfig.focus
|
|
1922
|
-
this.declarationConfig.disabled
|
|
1923
|
-
this.declarationConfig.dataAttributes
|
|
2062
|
+
this.declarationConfig.rtl ??= rtl;
|
|
2063
|
+
this.declarationConfig.theme ??= theme;
|
|
2064
|
+
this.declarationConfig.active ??= active;
|
|
2065
|
+
this.declarationConfig.focus ??= focus;
|
|
2066
|
+
this.declarationConfig.disabled ??= disabled;
|
|
2067
|
+
this.declarationConfig.dataAttributes ??= dataAttributes;
|
|
1924
2068
|
rule.value.declarations?.declarations?.forEach((declaration) => this.addDeclaration(declaration));
|
|
1925
2069
|
rule.value.declarations?.importantDeclarations?.forEach((declaration) => this.addDeclaration(declaration, true));
|
|
1926
2070
|
rule.value.rules?.forEach((rule2) => this.parseRuleRec(rule2));
|
|
@@ -1999,52 +2143,29 @@ class ProcessorBuilder {
|
|
|
1999
2143
|
}
|
|
2000
2144
|
}
|
|
2001
2145
|
|
|
2002
|
-
const
|
|
2003
|
-
const
|
|
2004
|
-
base: path.dirname(cssPath),
|
|
2005
|
-
onDependency: () => void 0
|
|
2006
|
-
});
|
|
2007
|
-
const scanner = new Scanner({
|
|
2008
|
-
sources: [
|
|
2009
|
-
...compiler.sources,
|
|
2010
|
-
{
|
|
2011
|
-
negated: false,
|
|
2012
|
-
pattern: "**/*",
|
|
2013
|
-
base: path.dirname(cssPath)
|
|
2014
|
-
}
|
|
2015
|
-
]
|
|
2016
|
-
});
|
|
2017
|
-
const tailwindCSS = compiler.build(candidates ?? scanner.scan());
|
|
2018
|
-
if (platform === Platform.Web) {
|
|
2019
|
-
return transform$1({
|
|
2020
|
-
code: Buffer.from(tailwindCSS),
|
|
2021
|
-
filename: "uniwind.css",
|
|
2022
|
-
visitor: new UniwindCSSVisitor(themes)
|
|
2023
|
-
}).code.toString();
|
|
2024
|
-
}
|
|
2025
|
-
const Processor = new ProcessorBuilder(themes, polyfills);
|
|
2026
|
-
Logger.debug = debug === true;
|
|
2146
|
+
const compileNativeCSS = (bundlerConfig, tailwindCSS) => {
|
|
2147
|
+
const Processor = new ProcessorBuilder(bundlerConfig);
|
|
2027
2148
|
Processor.transform(tailwindCSS);
|
|
2028
2149
|
const stylesheet = serializeJSObject(
|
|
2029
|
-
addMetaToStylesTemplate(Processor, platform),
|
|
2150
|
+
addMetaToStylesTemplate(Processor, bundlerConfig.platform),
|
|
2030
2151
|
(key, value) => `"${key}": ${value}`
|
|
2031
2152
|
);
|
|
2032
2153
|
const vars = serializeJSObject(
|
|
2033
2154
|
Processor.vars,
|
|
2155
|
+
(key, value) => `"${key}": vars => ${value}`
|
|
2156
|
+
);
|
|
2157
|
+
const keyframes = serializeJSObject(
|
|
2158
|
+
Processor.keyframes,
|
|
2034
2159
|
(key, value) => `get "${key}"() { return ${value} }`
|
|
2035
2160
|
);
|
|
2036
2161
|
const scopedVars = Object.fromEntries(
|
|
2037
2162
|
Object.entries(Processor.scopedVars).map(([scopedVarsName, scopedVars2]) => [
|
|
2038
2163
|
scopedVarsName,
|
|
2039
|
-
serializeJSObject(scopedVars2, (key, value) => `
|
|
2164
|
+
serializeJSObject(scopedVars2, (key, value) => `"${key}": vars => ${value}`)
|
|
2040
2165
|
])
|
|
2041
2166
|
);
|
|
2042
|
-
const keyframes = serializeJSObject(
|
|
2043
|
-
Processor.keyframes,
|
|
2044
|
-
(key, value) => `get "${key}"() { return ${value} }`
|
|
2045
|
-
);
|
|
2046
2167
|
const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
|
|
2047
|
-
const currentColorVar = `
|
|
2168
|
+
const currentColorVar = `currentColor: () => rt.colorScheme === 'dark' ? '#ffffff' : '#000000',`;
|
|
2048
2169
|
return [
|
|
2049
2170
|
"({",
|
|
2050
2171
|
`scopedVars: ({ ${serializedScopedVars} }),`,
|
|
@@ -2055,17 +2176,42 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
|
|
|
2055
2176
|
].join("");
|
|
2056
2177
|
};
|
|
2057
2178
|
|
|
2058
|
-
const
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2179
|
+
const compileTailwind = async (bundlerConfig) => {
|
|
2180
|
+
const css = await fs.promises.readFile(bundlerConfig.cssPath, "utf-8");
|
|
2181
|
+
const compiler = await compile(css, {
|
|
2182
|
+
base: path.dirname(bundlerConfig.cssPath),
|
|
2183
|
+
onDependency: () => void 0
|
|
2184
|
+
});
|
|
2185
|
+
const scanner = new Scanner({
|
|
2186
|
+
sources: [
|
|
2187
|
+
...compiler.sources,
|
|
2188
|
+
{
|
|
2189
|
+
negated: false,
|
|
2190
|
+
pattern: "**/*",
|
|
2191
|
+
base: path.dirname(bundlerConfig.cssPath)
|
|
2192
|
+
}
|
|
2193
|
+
]
|
|
2194
|
+
});
|
|
2195
|
+
return compiler.build(scanner.scan());
|
|
2067
2196
|
};
|
|
2068
2197
|
|
|
2198
|
+
const compileWebCSS = (bundlerConfig, tailwindCSS) => {
|
|
2199
|
+
return transform$1({
|
|
2200
|
+
code: Buffer.from(tailwindCSS),
|
|
2201
|
+
filename: "uniwind.css",
|
|
2202
|
+
visitor: bundlerConfig.cssVisitor
|
|
2203
|
+
}).code.toString();
|
|
2204
|
+
};
|
|
2205
|
+
|
|
2206
|
+
const compileCSS = async (bundlerConfig) => {
|
|
2207
|
+
const tailwindCSS = await compileTailwind(bundlerConfig);
|
|
2208
|
+
if (bundlerConfig.platform === Platform.Web) {
|
|
2209
|
+
return compileWebCSS(bundlerConfig, tailwindCSS);
|
|
2210
|
+
}
|
|
2211
|
+
return compileNativeCSS(bundlerConfig, tailwindCSS);
|
|
2212
|
+
};
|
|
2213
|
+
|
|
2214
|
+
const cssArtifactPath = path.resolve(__dirname, "../../uniwind.css");
|
|
2069
2215
|
let worker;
|
|
2070
2216
|
try {
|
|
2071
2217
|
try {
|
|
@@ -2080,16 +2226,11 @@ try {
|
|
|
2080
2226
|
const transform = async (config, projectRoot, filePath, data, options) => {
|
|
2081
2227
|
const isCss = options.type !== "asset" && path.join(process.cwd(), config.uniwind.cssEntryFile) === path.join(projectRoot, filePath);
|
|
2082
2228
|
if (filePath.endsWith("/components/web/metro-injected.js")) {
|
|
2083
|
-
const
|
|
2084
|
-
const injectedThemesCode2 = await injectThemes({
|
|
2085
|
-
input: cssPath2,
|
|
2086
|
-
themes: config.uniwind.themes,
|
|
2087
|
-
dtsPath: config.uniwind.dtsFile
|
|
2088
|
-
});
|
|
2229
|
+
const bundlerConfig2 = UniwindBundlerConfig.fromMetroConfig(config.uniwind, Platform.Web);
|
|
2089
2230
|
data = Buffer.from(
|
|
2090
2231
|
[
|
|
2091
2232
|
`import { Uniwind } from '${name}';`,
|
|
2092
|
-
`Uniwind.__reinit(() => ({}), ${
|
|
2233
|
+
`Uniwind.__reinit(() => ({}), ${bundlerConfig2.stringifiedThemes});`
|
|
2093
2234
|
].join(""),
|
|
2094
2235
|
"utf-8"
|
|
2095
2236
|
);
|
|
@@ -2097,39 +2238,14 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2097
2238
|
if (!isCss) {
|
|
2098
2239
|
return worker.transform(config, projectRoot, filePath, data, options);
|
|
2099
2240
|
}
|
|
2100
|
-
const
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
if (options.platform === Platform.Android) {
|
|
2105
|
-
return Platform.AndroidTV;
|
|
2106
|
-
}
|
|
2107
|
-
if (options.platform === Platform.iOS) {
|
|
2108
|
-
return Platform.AppleTV;
|
|
2109
|
-
}
|
|
2110
|
-
throw new Error(`Platform ${options.platform} not supported`);
|
|
2111
|
-
};
|
|
2112
|
-
const cssPath = path.join(process.cwd(), config.uniwind.cssEntryFile);
|
|
2113
|
-
const injectedThemesCode = await injectThemes({
|
|
2114
|
-
input: cssPath,
|
|
2115
|
-
themes: config.uniwind.themes,
|
|
2116
|
-
dtsPath: config.uniwind.dtsFile
|
|
2117
|
-
});
|
|
2118
|
-
const css = fs.readFileSync(cssPath, "utf-8");
|
|
2119
|
-
const platform = getPlatform();
|
|
2120
|
-
const virtualCode = await compileVirtual({
|
|
2121
|
-
css,
|
|
2122
|
-
platform,
|
|
2123
|
-
themes: config.uniwind.themes,
|
|
2124
|
-
polyfills: config.uniwind.polyfills,
|
|
2125
|
-
cssPath,
|
|
2126
|
-
debug: config.uniwind.debug
|
|
2127
|
-
});
|
|
2128
|
-
const isWeb = platform === Platform.Web;
|
|
2241
|
+
const bundlerConfig = UniwindBundlerConfig.fromMetroConfig(config.uniwind, options.platform);
|
|
2242
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
2243
|
+
const virtualCode = await compileCSS(bundlerConfig);
|
|
2244
|
+
const isWeb = bundlerConfig.platform === Platform.Web;
|
|
2129
2245
|
data = Buffer.from(
|
|
2130
2246
|
isWeb ? virtualCode : [
|
|
2131
2247
|
`const { Uniwind } = require('${name}');`,
|
|
2132
|
-
`Uniwind.__reinit(rt => ${virtualCode}, ${
|
|
2248
|
+
`Uniwind.__reinit(rt => ${virtualCode}, ${bundlerConfig.stringifiedThemes});`
|
|
2133
2249
|
].join(""),
|
|
2134
2250
|
"utf-8"
|
|
2135
2251
|
);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const buildCSS: (themes: Array<string>, input: string) => Promise<void>;
|
|
1
|
+
export declare const buildCSS: (themes: Array<string>, input: string, cssFilePath: string) => Promise<void>;
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import path from "path";
|
|
3
2
|
import { EXTRA_UTILITIES_CSS } from "./extraUtilities.js";
|
|
4
3
|
import { INSETS_CSS } from "./insets.js";
|
|
5
4
|
import { OVERWRITE_CSS } from "./overwrite.js";
|
|
6
5
|
import { generateCSSForThemes } from "./themes.js";
|
|
7
6
|
import { VARIANTS_CSS } from "./variants.js";
|
|
8
|
-
const
|
|
9
|
-
export const buildCSS = async (themes, input) => {
|
|
7
|
+
export const buildCSS = async (themes, input, cssFilePath) => {
|
|
10
8
|
const themesCSS = await generateCSSForThemes(themes, input);
|
|
11
|
-
const cssFilePath = path.join(dirname, "../../uniwind.css");
|
|
12
9
|
const oldCSSFile = fs.existsSync(cssFilePath) ? fs.readFileSync(cssFilePath, "utf-8") : "";
|
|
13
10
|
const newCssFile = [
|
|
14
11
|
VARIANTS_CSS,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { Logger } from "@/bundler/logger";
|
|
1
2
|
import { compile } from "@tailwindcss/node";
|
|
2
3
|
import fs from "fs";
|
|
3
4
|
import { transform } from "lightningcss";
|
|
4
5
|
import path from "path";
|
|
5
|
-
import { Logger } from "../metro/logger";
|
|
6
6
|
const readFileSafe = (filePath) => {
|
|
7
7
|
try {
|
|
8
8
|
return fs.readFileSync(filePath, "utf-8");
|
|
@@ -49,6 +49,9 @@ export const generateCSSForThemes = async (themes, input) => {
|
|
|
49
49
|
}
|
|
50
50
|
const importUrls = /* @__PURE__ */ new Set();
|
|
51
51
|
const importsCSS = dependencies.filter((dependency) => {
|
|
52
|
+
if (dependency.type !== "import") {
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
52
55
|
if (dependency.url.startsWith(".")) {
|
|
53
56
|
importUrls.add(path.resolve(path.dirname(cssPath), dependency.url));
|
|
54
57
|
return false;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import fs from "fs";
|
|
2
|
-
import { name } from "../../package.json";
|
|
3
2
|
export const buildDtsFile = (dtsPath, stringifiedThemes) => {
|
|
4
3
|
const oldDtsContent = fs.existsSync(dtsPath) ? fs.readFileSync(dtsPath, "utf-8") : "";
|
|
5
4
|
const dtsContent = [
|
|
6
|
-
`// NOTE: This file is generated by
|
|
7
|
-
`/// <reference types="
|
|
5
|
+
`// NOTE: This file is generated by uniwind and it should not be edited manually.`,
|
|
6
|
+
`/// <reference types="uniwind/types" />`,
|
|
8
7
|
"",
|
|
9
|
-
`declare module '
|
|
8
|
+
`declare module 'uniwind' {`,
|
|
10
9
|
` export interface UniwindConfig {`,
|
|
11
10
|
` themes: readonly ${stringifiedThemes}`,
|
|
12
11
|
` }`,
|