@niibase/uniwind 1.6.4 → 1.7.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 +36 -0
- package/dist/common/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/common/{css → bundler/artifacts/css}/themes.js +1 -1
- package/dist/common/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +1 -2
- package/dist/common/bundler/config.js +69 -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 +63 -0
- package/dist/common/bundler/css-processor/var.js +20 -0
- package/dist/common/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
- package/dist/common/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/common/bundler/logger.js +41 -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 +3 -3
- package/dist/common/core/listener.js +10 -10
- package/dist/common/core/native/runtime.js +7 -3
- package/dist/common/core/native/store.js +3 -4
- 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/useCSSVariable.js +6 -2
- package/dist/common/hooks/useUniwind.js +2 -2
- package/dist/metro/index.cjs +14 -24
- package/dist/metro/index.d.ts +2 -0
- package/dist/metro/index.mjs +7 -17
- package/dist/metro/{metro-transformer.cjs → transformer.cjs} +294 -174
- package/dist/metro/{metro-transformer.mjs → transformer.mjs} +236 -116
- 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 +1 -1
- package/dist/module/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +3 -4
- package/dist/module/bundler/config.d.ts +16 -0
- package/dist/module/bundler/config.js +69 -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 +24 -0
- package/dist/{shared/uniwind.PtWWxxnh.mjs → module/bundler/css-processor/utils.js} +11 -15
- 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 +5 -5
- 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 +11 -0
- package/dist/module/bundler/logger.js +34 -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 +2 -2
- 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/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 +1 -1
- package/dist/module/core/listener.d.ts +1 -1
- package/dist/module/core/listener.js +1 -1
- package/dist/module/core/native/runtime.js +5 -1
- package/dist/module/core/native/store.d.ts +2 -2
- package/dist/module/core/native/store.js +1 -2
- package/dist/module/core/types.d.ts +6 -3
- 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/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.CFiAZ3D-.cjs} +307 -217
- package/dist/shared/{uniwind.BGiqYvxb.mjs → uniwind.u-s1XVU8.mjs} +299 -214
- package/dist/vite/index.cjs +12 -22
- package/dist/vite/index.mjs +9 -19
- package/package.json +1 -1
- package/src/{metro → bundler/adapters/metro}/index.d.ts +2 -0
- package/src/bundler/adapters/metro/index.ts +1 -0
- package/src/{metro/withUniwindConfig.ts → bundler/adapters/metro/metro.ts} +7 -22
- package/src/{metro/metro-css-patches.ts → bundler/adapters/metro/patches.ts} +2 -1
- package/src/{metro → bundler/adapters/metro}/resolvers.ts +8 -8
- package/src/bundler/adapters/metro/transformer.ts +85 -0
- package/src/{vite → bundler/adapters/vite}/vite.ts +10 -28
- 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 +1 -1
- package/src/{utils/buildDtsFile.ts → bundler/artifacts/dts.ts} +3 -4
- package/src/bundler/config.ts +84 -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 +33 -14
- package/src/{metro/processor → bundler/css-processor}/animation.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/color.ts +4 -3
- package/src/{metro/processor → bundler/css-processor}/css.ts +17 -9
- 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 +13 -11
- 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 +1 -1
- package/src/{metro/processor → bundler/css-processor}/var.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/function-visitor.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/rule-visitor.ts +6 -5
- package/src/{css-visitor → bundler/css-visitor}/visitor.ts +4 -3
- 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 +3 -3
- package/src/core/config/config.ts +2 -2
- package/src/core/listener.ts +1 -1
- package/src/core/native/runtime.ts +7 -2
- package/src/core/native/store.ts +3 -4
- package/src/core/types.ts +6 -3
- 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 +1 -1
- 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/types.ts +0 -23
- package/src/utils/stringifyThemes.ts +0 -1
- package/src/vite/index.d.ts +0 -9
- /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/{metro/utils/common.ts → bundler/css-processor/utils.ts} +0 -0
- /package/src/{css-visitor → bundler/css-visitor}/index.ts +0 -0
- /package/src/{metro → bundler}/logger.ts +0 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MQ = void 0;
|
|
7
|
+
var _consts = require("@/common/consts");
|
|
8
|
+
class MQ {
|
|
9
|
+
constructor(Processor) {
|
|
10
|
+
this.Processor = Processor;
|
|
11
|
+
}
|
|
12
|
+
processMediaQueries(mediaQueries) {
|
|
13
|
+
const mq = this.getInitialMediaQueryResolver();
|
|
14
|
+
for (const mediaQuery of mediaQueries) {
|
|
15
|
+
const {
|
|
16
|
+
condition,
|
|
17
|
+
mediaType
|
|
18
|
+
} = mediaQuery;
|
|
19
|
+
if ([_consts.Platform.Android, _consts.Platform.iOS, _consts.Platform.Native, _consts.Platform.AndroidTV, _consts.Platform.AppleTV, _consts.Platform.TV].includes(mediaType)) {
|
|
20
|
+
mq.platform = mediaType;
|
|
21
|
+
continue;
|
|
22
|
+
}
|
|
23
|
+
if (condition) this.processCondition(condition, mq);
|
|
24
|
+
}
|
|
25
|
+
return mq;
|
|
26
|
+
}
|
|
27
|
+
processCondition(condition, mq) {
|
|
28
|
+
if (condition.type === "operation") {
|
|
29
|
+
condition.conditions.forEach(nestedCondition => {
|
|
30
|
+
this.processCondition(nestedCondition, mq);
|
|
31
|
+
});
|
|
32
|
+
} else if (condition.type === "feature") {
|
|
33
|
+
if (condition.value.type === "range") {
|
|
34
|
+
this.processWidthMediaQuery(condition.value, mq);
|
|
35
|
+
}
|
|
36
|
+
if (condition.value.type === "plain") {
|
|
37
|
+
this.processPlainMediaQuery(condition.value, mq);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
processWidthMediaQuery(query, mq) {
|
|
42
|
+
const {
|
|
43
|
+
operator,
|
|
44
|
+
value
|
|
45
|
+
} = query;
|
|
46
|
+
const result = this.Processor.CSS.processValue(value);
|
|
47
|
+
if (operator === "greater-than-equal" || operator === "greater-than") {
|
|
48
|
+
mq.minWidth = result;
|
|
49
|
+
}
|
|
50
|
+
if (operator === "less-than-equal" || operator === "less-than") {
|
|
51
|
+
mq.maxWidth = result;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
processPlainMediaQuery(query, mq) {
|
|
55
|
+
const {
|
|
56
|
+
value,
|
|
57
|
+
name
|
|
58
|
+
} = query;
|
|
59
|
+
switch (name) {
|
|
60
|
+
case "orientation":
|
|
61
|
+
mq.orientation = value.value;
|
|
62
|
+
break;
|
|
63
|
+
case "prefers-color-scheme":
|
|
64
|
+
mq.colorScheme = value.value;
|
|
65
|
+
break;
|
|
66
|
+
default:
|
|
67
|
+
break;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
getInitialMediaQueryResolver() {
|
|
71
|
+
return {
|
|
72
|
+
minWidth: 0,
|
|
73
|
+
maxWidth: Number.MAX_VALUE,
|
|
74
|
+
platform: null,
|
|
75
|
+
rtl: null,
|
|
76
|
+
important: false,
|
|
77
|
+
colorScheme: null,
|
|
78
|
+
orientation: null,
|
|
79
|
+
theme: null,
|
|
80
|
+
active: null,
|
|
81
|
+
focus: null,
|
|
82
|
+
disabled: null,
|
|
83
|
+
dataAttributes: null
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.MQ = MQ;
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ProcessorBuilder = void 0;
|
|
7
|
+
var _consts = require("@/common/consts");
|
|
8
|
+
var _lightningcss = require("lightningcss");
|
|
9
|
+
var _transforms = require("../../core/native/parsers/transforms");
|
|
10
|
+
var _color = require("./color");
|
|
11
|
+
var _css = require("./css");
|
|
12
|
+
var _functions = require("./functions");
|
|
13
|
+
var _mq = require("./mq");
|
|
14
|
+
var _rn = require("./rn");
|
|
15
|
+
var _units = require("./units");
|
|
16
|
+
var _var = require("./var");
|
|
17
|
+
class ProcessorBuilder {
|
|
18
|
+
constructor(bundlerConfig) {
|
|
19
|
+
this.bundlerConfig = bundlerConfig;
|
|
20
|
+
this.vars["--uniwind-em"] = this.bundlerConfig.polyfills?.rem ?? 16;
|
|
21
|
+
}
|
|
22
|
+
stylesheets = {};
|
|
23
|
+
vars = {};
|
|
24
|
+
scopedVars = {};
|
|
25
|
+
keyframes = {};
|
|
26
|
+
CSS = new _css.CSS(this);
|
|
27
|
+
RN = new _rn.RN(this);
|
|
28
|
+
Var = new _var.Var(this);
|
|
29
|
+
MQ = new _mq.MQ(this);
|
|
30
|
+
Color = new _color.Color(this);
|
|
31
|
+
Units = new _units.Units(this);
|
|
32
|
+
Functions = new _functions.Functions(this);
|
|
33
|
+
meta = {};
|
|
34
|
+
varsWithMediaQueries = {};
|
|
35
|
+
pendingVarReferences = /* @__PURE__ */new Map();
|
|
36
|
+
declarationConfig = this.getDeclarationConfig();
|
|
37
|
+
transform(css) {
|
|
38
|
+
(0, _lightningcss.transform)({
|
|
39
|
+
filename: "tailwind.css",
|
|
40
|
+
code: Buffer.from(css),
|
|
41
|
+
visitor: {
|
|
42
|
+
StyleSheet: styleSheet => {
|
|
43
|
+
styleSheet.rules.forEach(rule => {
|
|
44
|
+
this.declarationConfig = this.getDeclarationConfig();
|
|
45
|
+
this.parseRuleRec(rule);
|
|
46
|
+
});
|
|
47
|
+
for (const [className, [varNames, animated]] of this.pendingVarReferences) {
|
|
48
|
+
if (animated && varNames.length === 1) {
|
|
49
|
+
const varName = varNames[0];
|
|
50
|
+
const varValue = this.vars[varName];
|
|
51
|
+
const styles = this.stylesheets[className]?.at(-2);
|
|
52
|
+
this.CSS.processAnimationVar(varValue, styles, v => {
|
|
53
|
+
this.vars[varName] = v;
|
|
54
|
+
});
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
for (const varName of varNames) {
|
|
58
|
+
const varStyles = this.varsWithMediaQueries[varName];
|
|
59
|
+
if (!varStyles || varStyles.length === 0) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
for (const varStyle of varStyles) {
|
|
63
|
+
this.stylesheets[className].push(varStyle);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
getDeclarationConfig() {
|
|
72
|
+
return {
|
|
73
|
+
className: null,
|
|
74
|
+
rtl: null,
|
|
75
|
+
mediaQueries: [],
|
|
76
|
+
root: false,
|
|
77
|
+
theme: null,
|
|
78
|
+
active: null,
|
|
79
|
+
focus: null,
|
|
80
|
+
disabled: null,
|
|
81
|
+
dataAttributes: null
|
|
82
|
+
};
|
|
83
|
+
}
|
|
84
|
+
hasMediaQuery(mq) {
|
|
85
|
+
return mq.minWidth !== 0 || mq.maxWidth !== Number.MAX_VALUE || mq.orientation !== null || mq.colorScheme !== null;
|
|
86
|
+
}
|
|
87
|
+
addDeclaration(declaration, important = false) {
|
|
88
|
+
const isVar = this.declarationConfig.root || this.declarationConfig.className === null;
|
|
89
|
+
const mq = this.MQ.processMediaQueries(this.declarationConfig.mediaQueries);
|
|
90
|
+
const {
|
|
91
|
+
property,
|
|
92
|
+
value
|
|
93
|
+
} = this.parseDeclaration(declaration);
|
|
94
|
+
const style = (() => {
|
|
95
|
+
if (!isVar) {
|
|
96
|
+
return this.stylesheets[this.declarationConfig.className]?.at(-1);
|
|
97
|
+
}
|
|
98
|
+
if (mq.platform !== null) {
|
|
99
|
+
const platformKey = `${_consts.UNIWIND_PLATFORM_VARIABLES}${mq.platform}`;
|
|
100
|
+
this.scopedVars[platformKey] ??= {};
|
|
101
|
+
return this.scopedVars[platformKey];
|
|
102
|
+
}
|
|
103
|
+
if (this.hasMediaQuery(mq)) {
|
|
104
|
+
this.varsWithMediaQueries[property] ??= [];
|
|
105
|
+
this.varsWithMediaQueries[property].push({});
|
|
106
|
+
return this.varsWithMediaQueries[property].at(-1);
|
|
107
|
+
}
|
|
108
|
+
if (this.declarationConfig.theme === null) {
|
|
109
|
+
return this.vars;
|
|
110
|
+
}
|
|
111
|
+
const themeKey = `${_consts.UNIWIND_THEME_VARIABLES}${this.declarationConfig.theme}`;
|
|
112
|
+
this.scopedVars[themeKey] ??= {};
|
|
113
|
+
return this.scopedVars[themeKey];
|
|
114
|
+
})();
|
|
115
|
+
if (!isVar || this.hasMediaQuery(mq)) {
|
|
116
|
+
Object.assign(style, mq);
|
|
117
|
+
style.importantProperties ??= [];
|
|
118
|
+
style.rtl = this.declarationConfig.rtl;
|
|
119
|
+
style.theme = mq.colorScheme ?? this.declarationConfig.theme;
|
|
120
|
+
style.maxWidth = mq.maxWidth;
|
|
121
|
+
style.minWidth = mq.minWidth;
|
|
122
|
+
style.orientation = mq.orientation;
|
|
123
|
+
style.active = this.declarationConfig.active;
|
|
124
|
+
style.focus = this.declarationConfig.focus;
|
|
125
|
+
style.disabled = this.declarationConfig.disabled;
|
|
126
|
+
style.dataAttributes = this.declarationConfig.dataAttributes;
|
|
127
|
+
this.meta.className = this.declarationConfig.className;
|
|
128
|
+
}
|
|
129
|
+
style[property] = value;
|
|
130
|
+
if (!isVar && important) {
|
|
131
|
+
style.importantProperties.push(property);
|
|
132
|
+
}
|
|
133
|
+
const match = typeof value === "string" ? value.match(/this\[`(.*?)`\]/) : null;
|
|
134
|
+
if (match && !isVar) {
|
|
135
|
+
const className = this.declarationConfig.className;
|
|
136
|
+
if (className === null) {
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
if (!this.pendingVarReferences.has(className)) {
|
|
140
|
+
this.pendingVarReferences.set(className, [[], property === "animation"]);
|
|
141
|
+
}
|
|
142
|
+
const classVars = this.pendingVarReferences.get(className);
|
|
143
|
+
const varName = match[1];
|
|
144
|
+
if (!classVars[0].includes(varName)) {
|
|
145
|
+
classVars[0].push(varName);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
parseKeyFrames(animationFrames) {
|
|
150
|
+
const [selectors, styles] = animationFrames;
|
|
151
|
+
const result = {};
|
|
152
|
+
for (let i = 0; i < selectors.length; i++) {
|
|
153
|
+
const selectorString = selectors[i];
|
|
154
|
+
const styleObj = styles[i];
|
|
155
|
+
const individualSelectors = typeof selectorString === "string" ? selectorString.split(",").map(s => s.trim()).filter(Boolean) : [selectorString];
|
|
156
|
+
const resolvedStyles = {};
|
|
157
|
+
for (const [property, value] of Object.entries(styleObj)) {
|
|
158
|
+
const resolved = this.RN.cssToRN(property, value);
|
|
159
|
+
for (const [resolvedProperty, resolvedValue] of resolved) {
|
|
160
|
+
resolvedStyles[resolvedProperty] = resolvedValue;
|
|
161
|
+
}
|
|
162
|
+
if (property === "transform") {
|
|
163
|
+
(0, _transforms.parseTransformsMutation)(resolvedStyles, true);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
for (const selector of individualSelectors) {
|
|
167
|
+
if (result[selector] !== void 0) {
|
|
168
|
+
result[selector] = {
|
|
169
|
+
...result[selector],
|
|
170
|
+
...resolvedStyles
|
|
171
|
+
};
|
|
172
|
+
} else {
|
|
173
|
+
result[selector] = {
|
|
174
|
+
...resolvedStyles
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return result;
|
|
180
|
+
}
|
|
181
|
+
parseDeclaration(declaration) {
|
|
182
|
+
const parseValue = (property, value) => {
|
|
183
|
+
if (property === "animation") {
|
|
184
|
+
return this.CSS.processAnimation(value);
|
|
185
|
+
}
|
|
186
|
+
return this.CSS.processValue(value, property);
|
|
187
|
+
};
|
|
188
|
+
if (declaration.property === "unparsed") {
|
|
189
|
+
const property = declaration.value.propertyId.property;
|
|
190
|
+
return {
|
|
191
|
+
property,
|
|
192
|
+
value: parseValue(property, declaration.value.value)
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
if (declaration.property === "custom") {
|
|
196
|
+
const property = declaration.value.name;
|
|
197
|
+
return {
|
|
198
|
+
property,
|
|
199
|
+
value: parseValue(property, declaration.value.value)
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
return {
|
|
203
|
+
property: declaration.property,
|
|
204
|
+
value: parseValue(declaration.property, declaration.value)
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
parseRuleRec(rule) {
|
|
208
|
+
if (this.declarationConfig.className !== null) {
|
|
209
|
+
const lastStyle = this.stylesheets[this.declarationConfig.className]?.at(-1);
|
|
210
|
+
if (lastStyle !== void 0 && Object.keys(lastStyle).length > 0) {
|
|
211
|
+
this.stylesheets[this.declarationConfig.className]?.push({});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (rule.type === "style") {
|
|
215
|
+
rule.value.selectors.forEach(selector => {
|
|
216
|
+
const [maybeClassNameSelector] = selector;
|
|
217
|
+
const newClassName = maybeClassNameSelector?.type === "class" ? maybeClassNameSelector.name : void 0;
|
|
218
|
+
if (newClassName !== void 0) {
|
|
219
|
+
this.declarationConfig.className = newClassName;
|
|
220
|
+
this.stylesheets[newClassName] ??= [];
|
|
221
|
+
this.stylesheets[newClassName].push({});
|
|
222
|
+
rule.value.declarations?.declarations?.forEach(declaration => this.addDeclaration(declaration));
|
|
223
|
+
rule.value.declarations?.importantDeclarations?.forEach(declaration => this.addDeclaration(declaration, true));
|
|
224
|
+
rule.value.rules?.forEach(rule2 => this.parseRuleRec(rule2));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
let rtl = null;
|
|
228
|
+
let theme = null;
|
|
229
|
+
let active = null;
|
|
230
|
+
let focus = null;
|
|
231
|
+
let disabled = null;
|
|
232
|
+
let dataAttributes = null;
|
|
233
|
+
selector.forEach(selector2 => {
|
|
234
|
+
if (selector2.type === "pseudo-class" && selector2.kind === "where") {
|
|
235
|
+
selector2.selectors.forEach(selector3 => {
|
|
236
|
+
selector3.forEach(selector4 => {
|
|
237
|
+
if (selector4.type === "class" && this.bundlerConfig.themes.includes(selector4.name)) {
|
|
238
|
+
theme = selector4.name;
|
|
239
|
+
}
|
|
240
|
+
if (selector4.type === "pseudo-class" && selector4.kind === "dir") {
|
|
241
|
+
rtl = selector4.direction === "rtl";
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
if (selector2.type === "pseudo-class" && selector2.kind === "active") {
|
|
247
|
+
active = true;
|
|
248
|
+
}
|
|
249
|
+
if (selector2.type === "pseudo-class" && selector2.kind === "focus") {
|
|
250
|
+
focus = true;
|
|
251
|
+
}
|
|
252
|
+
if (selector2.type === "pseudo-class" && selector2.kind === "disabled") {
|
|
253
|
+
disabled = true;
|
|
254
|
+
}
|
|
255
|
+
if (selector2.type === "attribute" && selector2.operation === null && selector2.name.startsWith("data-")) {
|
|
256
|
+
dataAttributes ??= {};
|
|
257
|
+
dataAttributes[selector2.name] = `"true"`;
|
|
258
|
+
}
|
|
259
|
+
if (selector2.type === "attribute" && selector2.operation?.operator === "equal" && selector2.name.startsWith("data-")) {
|
|
260
|
+
dataAttributes ??= {};
|
|
261
|
+
dataAttributes[selector2.name] = `"${selector2.operation.value}"`;
|
|
262
|
+
}
|
|
263
|
+
});
|
|
264
|
+
if ([rtl, theme, active, focus, disabled, dataAttributes].some(Boolean)) {
|
|
265
|
+
this.declarationConfig.rtl = rtl;
|
|
266
|
+
this.declarationConfig.theme = theme;
|
|
267
|
+
this.declarationConfig.active = active;
|
|
268
|
+
this.declarationConfig.focus = focus;
|
|
269
|
+
this.declarationConfig.disabled = disabled;
|
|
270
|
+
this.declarationConfig.dataAttributes = dataAttributes;
|
|
271
|
+
rule.value.declarations?.declarations?.forEach(declaration => this.addDeclaration(declaration));
|
|
272
|
+
rule.value.declarations?.importantDeclarations?.forEach(declaration => this.addDeclaration(declaration, true));
|
|
273
|
+
rule.value.rules?.forEach(rule2 => this.parseRuleRec(rule2));
|
|
274
|
+
this.declarationConfig.rtl = null;
|
|
275
|
+
this.declarationConfig.theme = null;
|
|
276
|
+
this.declarationConfig.active = null;
|
|
277
|
+
this.declarationConfig.focus = null;
|
|
278
|
+
this.declarationConfig.disabled = null;
|
|
279
|
+
this.declarationConfig.dataAttributes = null;
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
selector.forEach(selectorToken => {
|
|
283
|
+
if (selectorToken.type === "pseudo-class" && selectorToken.kind === "root") {
|
|
284
|
+
this.declarationConfig.root = true;
|
|
285
|
+
rule.value.declarations?.declarations?.forEach(declaration => this.addDeclaration(declaration));
|
|
286
|
+
rule.value.declarations?.importantDeclarations?.forEach(declaration => this.addDeclaration(declaration, true));
|
|
287
|
+
rule.value.rules?.forEach(rule2 => this.parseRuleRec(rule2));
|
|
288
|
+
}
|
|
289
|
+
});
|
|
290
|
+
});
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
if (rule.type === "supports") {
|
|
294
|
+
rule.value.rules.forEach(rule2 => this.parseRuleRec(rule2));
|
|
295
|
+
return;
|
|
296
|
+
}
|
|
297
|
+
if (rule.type === "media") {
|
|
298
|
+
const {
|
|
299
|
+
mediaQueries
|
|
300
|
+
} = rule.value.query;
|
|
301
|
+
this.declarationConfig.mediaQueries.push(...mediaQueries);
|
|
302
|
+
rule.value.rules.forEach(rule2 => this.parseRuleRec(rule2));
|
|
303
|
+
this.declarationConfig = this.getDeclarationConfig();
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
if (rule.type === "keyframes") {
|
|
307
|
+
const keyframes = [[], []];
|
|
308
|
+
rule.value.keyframes.forEach(keyframe => {
|
|
309
|
+
const selectors = keyframe.selectors.map(selector => {
|
|
310
|
+
switch (selector.type) {
|
|
311
|
+
case "percentage":
|
|
312
|
+
return keyframe.selectors.length > 0 ? `${selector.value * 100}%` : selector.value;
|
|
313
|
+
case "from":
|
|
314
|
+
case "to":
|
|
315
|
+
return selector.type;
|
|
316
|
+
case "timeline-range-percentage":
|
|
317
|
+
return keyframe.selectors.length > 0 ? `${selector.value.percentage}%` : selector.value.percentage;
|
|
318
|
+
default:
|
|
319
|
+
return "";
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
keyframes[0].push(selectors.join(", "));
|
|
323
|
+
const keyframeStyle = {};
|
|
324
|
+
keyframe.declarations.declarations?.forEach(declaration => {
|
|
325
|
+
if (["custom", "unparsed"].includes(declaration.property)) {
|
|
326
|
+
const {
|
|
327
|
+
property,
|
|
328
|
+
value
|
|
329
|
+
} = this.parseDeclaration(declaration);
|
|
330
|
+
keyframeStyle[property] = value;
|
|
331
|
+
} else {
|
|
332
|
+
keyframeStyle[declaration.property] = !Array.isArray(declaration.value) || declaration.property.startsWith("animation-") ? this.CSS.processValue(declaration.value) : declaration.value.flatMap(value => this.CSS.processValue(value));
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
keyframes[1].push(keyframeStyle);
|
|
336
|
+
});
|
|
337
|
+
this.keyframes[rule.value.name.value] = this.parseKeyFrames(keyframes);
|
|
338
|
+
}
|
|
339
|
+
if (rule.type === "layer-block") {
|
|
340
|
+
rule.value.rules.forEach(rule2 => this.parseRuleRec(rule2));
|
|
341
|
+
return;
|
|
342
|
+
}
|
|
343
|
+
if (rule.type === "nested-declarations") {
|
|
344
|
+
rule.value.declarations.declarations?.forEach(declaration => this.addDeclaration(declaration));
|
|
345
|
+
rule.value.declarations.importantDeclarations?.forEach(declaration => this.addDeclaration(declaration, true));
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
if (rule.type === "property" && rule.value.initialValue) {
|
|
349
|
+
this.vars[rule.value.name] = this.CSS.processValue(rule.value.initialValue);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
exports.ProcessorBuilder = ProcessorBuilder;
|