@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,510 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.CSS = void 0;
|
|
7
|
+
var _utils = require("@/common/utils");
|
|
8
|
+
var _logger = require("../logger");
|
|
9
|
+
var _animation = require("./animation");
|
|
10
|
+
var _utils2 = require("./utils");
|
|
11
|
+
class CSS {
|
|
12
|
+
constructor(Processor) {
|
|
13
|
+
this.Processor = Processor;
|
|
14
|
+
}
|
|
15
|
+
logger = new _logger.Logger("CSS");
|
|
16
|
+
processValue(declarationValue, declarationProperty) {
|
|
17
|
+
const processedValue = this.getProcessedValue(declarationValue, declarationProperty);
|
|
18
|
+
if (typeof processedValue === "string") {
|
|
19
|
+
return this.makeSafeForSerialization(processedValue);
|
|
20
|
+
}
|
|
21
|
+
if (Array.isArray(processedValue)) {
|
|
22
|
+
return processedValue.map(value => {
|
|
23
|
+
if (typeof value === "string") {
|
|
24
|
+
return this.makeSafeForSerialization(value);
|
|
25
|
+
}
|
|
26
|
+
return value;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (typeof processedValue === "object" && processedValue !== null) {
|
|
30
|
+
return Object.fromEntries(Object.entries(processedValue).map(([key, value]) => {
|
|
31
|
+
if (typeof value === "string") {
|
|
32
|
+
return [key, this.makeSafeForSerialization(value)];
|
|
33
|
+
}
|
|
34
|
+
return [key, value];
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
return processedValue;
|
|
38
|
+
}
|
|
39
|
+
processAnimation(declarationValue) {
|
|
40
|
+
if (declarationValue.length === 0) {
|
|
41
|
+
return [];
|
|
42
|
+
}
|
|
43
|
+
if (declarationValue.length === 1) {
|
|
44
|
+
const token = declarationValue[0];
|
|
45
|
+
if (token.type === "var") {
|
|
46
|
+
return this.Processor.Var.processVar(token.value);
|
|
47
|
+
}
|
|
48
|
+
return Object.entries(token).map(([key, value]) => [(0, _utils2.toCamelCase)(key), this.processValue(value)]);
|
|
49
|
+
}
|
|
50
|
+
return (0, _animation.getProcessedAnimation)(declarationValue, this.getProcessedValue.bind(this));
|
|
51
|
+
}
|
|
52
|
+
processAnimationVar(declarationValue, styles, updateVar) {
|
|
53
|
+
(0, _animation.getProcessedVarAnimation)(declarationValue, styles, updateVar);
|
|
54
|
+
}
|
|
55
|
+
processFilters(filters) {
|
|
56
|
+
const filterStrings = filters.map(filter => {
|
|
57
|
+
if (filter.type === "hue-rotate") {
|
|
58
|
+
return `hue-rotate(${filter.value.value}${filter.value.type})`;
|
|
59
|
+
}
|
|
60
|
+
if (filter.type === "url") {
|
|
61
|
+
return `url(${filter.value.url})`;
|
|
62
|
+
}
|
|
63
|
+
if (filter.type === "drop-shadow") {
|
|
64
|
+
const parts = [this.processValue(filter.value.xOffset), this.processValue(filter.value.yOffset), this.processValue(filter.value.blur), this.processValue(filter.value.color)].filter(_utils.isDefined);
|
|
65
|
+
return `drop-shadow(${parts.join(" ")})`;
|
|
66
|
+
}
|
|
67
|
+
const value = this.processValue(filter.value);
|
|
68
|
+
return `${filter.type}(${value})`;
|
|
69
|
+
});
|
|
70
|
+
return filterStrings.join(" ");
|
|
71
|
+
}
|
|
72
|
+
getProcessedValue(declarationValue, declarationProperty) {
|
|
73
|
+
if (typeof declarationValue !== "object") {
|
|
74
|
+
return declarationValue;
|
|
75
|
+
}
|
|
76
|
+
if ("type" in declarationValue) {
|
|
77
|
+
switch (declarationValue.type) {
|
|
78
|
+
case "function":
|
|
79
|
+
return this.Processor.Functions.processFunction(declarationValue.value);
|
|
80
|
+
case "var":
|
|
81
|
+
return this.Processor.Var.processVar(declarationValue.value);
|
|
82
|
+
case "number":
|
|
83
|
+
case "integer":
|
|
84
|
+
return declarationValue.value;
|
|
85
|
+
case "token":
|
|
86
|
+
return this.processValue(declarationValue.value);
|
|
87
|
+
case "length":
|
|
88
|
+
return this.Processor.Units.processAnyLength(declarationValue.value);
|
|
89
|
+
case "color":
|
|
90
|
+
return this.Processor.Color.processColor(declarationValue.value);
|
|
91
|
+
case "comma":
|
|
92
|
+
return ", ";
|
|
93
|
+
case "dimension":
|
|
94
|
+
case "value":
|
|
95
|
+
case "length-percentage":
|
|
96
|
+
return this.Processor.Units.processLength(declarationValue.value);
|
|
97
|
+
case "translate":
|
|
98
|
+
{
|
|
99
|
+
const [translateX, translateY] = declarationValue.value.map(x => this.processValue(x));
|
|
100
|
+
return [{
|
|
101
|
+
translateX
|
|
102
|
+
}, {
|
|
103
|
+
translateY
|
|
104
|
+
}];
|
|
105
|
+
}
|
|
106
|
+
case "translateX":
|
|
107
|
+
return {
|
|
108
|
+
translateX: this.Processor.Units.processLength(declarationValue.value)
|
|
109
|
+
};
|
|
110
|
+
case "translateY":
|
|
111
|
+
return {
|
|
112
|
+
translateY: this.Processor.Units.processLength(declarationValue.value)
|
|
113
|
+
};
|
|
114
|
+
case "translateZ":
|
|
115
|
+
{
|
|
116
|
+
return {
|
|
117
|
+
translateZ: this.processValue(declarationValue.value)
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
case "translate3d":
|
|
121
|
+
{
|
|
122
|
+
const [translateX, translateY] = declarationValue.value.map(x => this.processValue(x));
|
|
123
|
+
return [{
|
|
124
|
+
translateX
|
|
125
|
+
}, {
|
|
126
|
+
translateY
|
|
127
|
+
}];
|
|
128
|
+
}
|
|
129
|
+
case "rotate":
|
|
130
|
+
return {
|
|
131
|
+
rotate: `${declarationValue.value.value}${declarationValue.value.type}`
|
|
132
|
+
};
|
|
133
|
+
case "rotateX":
|
|
134
|
+
return {
|
|
135
|
+
rotateX: `${declarationValue.value.value}${declarationValue.value.type}`
|
|
136
|
+
};
|
|
137
|
+
case "rotateY":
|
|
138
|
+
return {
|
|
139
|
+
rotateY: `${declarationValue.value.value}${declarationValue.value.type}`
|
|
140
|
+
};
|
|
141
|
+
case "rotateZ":
|
|
142
|
+
return {
|
|
143
|
+
rotateZ: `${declarationValue.value.value}${declarationValue.value.type}`
|
|
144
|
+
};
|
|
145
|
+
case "rotate3d":
|
|
146
|
+
{
|
|
147
|
+
const [x, y, z, angle] = declarationValue.value;
|
|
148
|
+
const v = angle.value;
|
|
149
|
+
const t = angle.type;
|
|
150
|
+
return {
|
|
151
|
+
rotateX: `${x * v}${t}`,
|
|
152
|
+
rotateY: `${y * v}${t}`,
|
|
153
|
+
rotateZ: `${z * v}${t}`
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
case "scale":
|
|
157
|
+
{
|
|
158
|
+
const [scaleX, scaleY] = declarationValue.value.map(x => this.processValue(x));
|
|
159
|
+
if (scaleX === scaleY) {
|
|
160
|
+
return {
|
|
161
|
+
scale: scaleX
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
return [{
|
|
165
|
+
scaleX
|
|
166
|
+
}, {
|
|
167
|
+
scaleY
|
|
168
|
+
}];
|
|
169
|
+
}
|
|
170
|
+
case "scaleX":
|
|
171
|
+
return {
|
|
172
|
+
scaleX: this.processValue(declarationValue.value)
|
|
173
|
+
};
|
|
174
|
+
case "scaleY":
|
|
175
|
+
return {
|
|
176
|
+
scaleY: this.processValue(declarationValue.value)
|
|
177
|
+
};
|
|
178
|
+
case "scaleZ":
|
|
179
|
+
return {
|
|
180
|
+
scaleZ: this.processValue(declarationValue.value)
|
|
181
|
+
};
|
|
182
|
+
case "scale3d":
|
|
183
|
+
{
|
|
184
|
+
const [scaleX, scaleY] = declarationValue.value.map(x => this.processValue(x));
|
|
185
|
+
return [{
|
|
186
|
+
scaleX
|
|
187
|
+
}, {
|
|
188
|
+
scaleY
|
|
189
|
+
}];
|
|
190
|
+
}
|
|
191
|
+
case "skew":
|
|
192
|
+
{
|
|
193
|
+
const [skewX, skewY] = declarationValue.value.map(x => `"${x.value}${x.type}"`);
|
|
194
|
+
return [{
|
|
195
|
+
skewX
|
|
196
|
+
}, {
|
|
197
|
+
skewY
|
|
198
|
+
}];
|
|
199
|
+
}
|
|
200
|
+
case "filters":
|
|
201
|
+
return this.processFilters(declarationValue.value);
|
|
202
|
+
case "percentage":
|
|
203
|
+
return `${declarationValue.value * 100}%`;
|
|
204
|
+
case "token-list":
|
|
205
|
+
return declarationValue.value.reduce((acc, token) => {
|
|
206
|
+
const tokenValue = this.processValue(token);
|
|
207
|
+
return acc + tokenValue;
|
|
208
|
+
}, "");
|
|
209
|
+
case "rgb":
|
|
210
|
+
case "oklab":
|
|
211
|
+
case "oklch":
|
|
212
|
+
case "hsl":
|
|
213
|
+
case "hwb":
|
|
214
|
+
case "lab":
|
|
215
|
+
case "lch":
|
|
216
|
+
case "srgb":
|
|
217
|
+
return this.Processor.Color.processColor(declarationValue);
|
|
218
|
+
case "delim":
|
|
219
|
+
if (declarationValue.value === ".") {
|
|
220
|
+
return ".";
|
|
221
|
+
}
|
|
222
|
+
if (declarationValue.value === "|") {
|
|
223
|
+
return "|";
|
|
224
|
+
}
|
|
225
|
+
return ` ${declarationValue.value} `;
|
|
226
|
+
case "ident":
|
|
227
|
+
if (this.Processor.Color.isColor(declarationValue.value)) {
|
|
228
|
+
return this.Processor.Color.processColor(declarationValue.value);
|
|
229
|
+
}
|
|
230
|
+
if (declarationValue.value === "currentcolor") {
|
|
231
|
+
return 'this["currentColor"]';
|
|
232
|
+
}
|
|
233
|
+
return declarationValue.value;
|
|
234
|
+
case "env":
|
|
235
|
+
if (declarationValue.value.name.type === "ua" && declarationValue.value.name.value.startsWith("safe-area-inset-")) {
|
|
236
|
+
const inset = declarationValue.value.name.value.replace("safe-area-inset-", "");
|
|
237
|
+
return `rt.insets.${inset}`;
|
|
238
|
+
}
|
|
239
|
+
this.logUnsupported(`Unsupported env value - ${JSON.stringify(declarationValue.value)}`);
|
|
240
|
+
return void 0;
|
|
241
|
+
case "time":
|
|
242
|
+
{
|
|
243
|
+
const unit = declarationValue.value.type === "milliseconds" ? "ms" : "s";
|
|
244
|
+
return `${declarationValue.value.value}${unit}`;
|
|
245
|
+
}
|
|
246
|
+
case "cubic-bezier":
|
|
247
|
+
{
|
|
248
|
+
const bezier = [declarationValue.x1, declarationValue.y1, declarationValue.x2, declarationValue.y2];
|
|
249
|
+
return `rt.cubicBezier(${bezier.join(",")})`;
|
|
250
|
+
}
|
|
251
|
+
case "steps":
|
|
252
|
+
{
|
|
253
|
+
const steps = [declarationValue.count, declarationValue.position ? `"${declarationValue.position.type}"` : void 0];
|
|
254
|
+
return `rt.steps(${steps.join(",")})`;
|
|
255
|
+
}
|
|
256
|
+
case "seconds":
|
|
257
|
+
return `${declarationValue.value}s`;
|
|
258
|
+
case "milliseconds":
|
|
259
|
+
return `${declarationValue.value}ms`;
|
|
260
|
+
case "pair":
|
|
261
|
+
return declarationValue.inside.type;
|
|
262
|
+
case "currentcolor":
|
|
263
|
+
return 'this["currentColor"]';
|
|
264
|
+
case "calc":
|
|
265
|
+
return this.Processor.Functions.processCalc(declarationValue.value);
|
|
266
|
+
case "min":
|
|
267
|
+
case "max":
|
|
268
|
+
case "abs":
|
|
269
|
+
return this.Processor.Functions.processMathFunction(declarationValue.type, declarationValue.value);
|
|
270
|
+
case "keyword":
|
|
271
|
+
if ("value" in declarationValue) {
|
|
272
|
+
return declarationValue.value;
|
|
273
|
+
}
|
|
274
|
+
this.logUnsupported(`Unsupported keyword value - ${JSON.stringify(declarationValue)}`);
|
|
275
|
+
return void 0;
|
|
276
|
+
case "min-max":
|
|
277
|
+
case "track-breadth":
|
|
278
|
+
return declarationValue.type;
|
|
279
|
+
case "explicit":
|
|
280
|
+
return `${this.processValue(declarationValue.width)} ${this.processValue(declarationValue.height)}`;
|
|
281
|
+
case "angle":
|
|
282
|
+
return `${declarationValue.value.value}${declarationValue.value.type}`;
|
|
283
|
+
case "gradient":
|
|
284
|
+
if (declarationValue.value.type === "linear") {
|
|
285
|
+
const direction = String(this.processValue(declarationValue.value.direction));
|
|
286
|
+
return [direction.includes("deg") ? direction : `to ${direction}`, ...declarationValue.value.items.map(item => this.processValue(item))].join(", ");
|
|
287
|
+
}
|
|
288
|
+
return void 0;
|
|
289
|
+
case "color-stop":
|
|
290
|
+
return [this.Processor.Color.processColor(declarationValue.color), declarationValue.position ? this.processValue(declarationValue.position) : null].filter(_utils.isDefined).join(" ");
|
|
291
|
+
case "side":
|
|
292
|
+
return declarationValue.side;
|
|
293
|
+
case "absolute":
|
|
294
|
+
if ("value" in declarationValue) {
|
|
295
|
+
return typeof declarationValue.value === "string" ? declarationValue.value : this.processValue(declarationValue.value);
|
|
296
|
+
}
|
|
297
|
+
return declarationValue.type;
|
|
298
|
+
case "hash":
|
|
299
|
+
return `#${declarationValue.value}`;
|
|
300
|
+
case "parenthesis-block":
|
|
301
|
+
return "(";
|
|
302
|
+
case "close-parenthesis":
|
|
303
|
+
return ")";
|
|
304
|
+
case "light-dark":
|
|
305
|
+
return `rt.lightDark( ${this.processValue(declarationValue.light)}, ${this.processValue(declarationValue.dark)} )`;
|
|
306
|
+
case "unresolved-color":
|
|
307
|
+
return this.getProcessedValue(declarationValue.value);
|
|
308
|
+
case "track-list":
|
|
309
|
+
case "sticky":
|
|
310
|
+
case "fit-content":
|
|
311
|
+
case "shape":
|
|
312
|
+
return void 0;
|
|
313
|
+
case "weight":
|
|
314
|
+
case "horizontal":
|
|
315
|
+
case "vertical":
|
|
316
|
+
case "white-space":
|
|
317
|
+
case "string":
|
|
318
|
+
case "self-position":
|
|
319
|
+
case "content-distribution":
|
|
320
|
+
case "content-position":
|
|
321
|
+
case "line-style":
|
|
322
|
+
return declarationValue.value;
|
|
323
|
+
case "baseline-position":
|
|
324
|
+
return "baseline";
|
|
325
|
+
default:
|
|
326
|
+
if (Object.keys(declarationValue).length === 1) {
|
|
327
|
+
return declarationValue.type;
|
|
328
|
+
}
|
|
329
|
+
this.logUnsupported(`Unsupported value type - ${JSON.stringify(declarationValue.type)}`);
|
|
330
|
+
return void 0;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
if ("top" in declarationValue) {
|
|
334
|
+
return {
|
|
335
|
+
top: this.processValue(declarationValue.top),
|
|
336
|
+
right: this.processValue(declarationValue.right),
|
|
337
|
+
bottom: this.processValue(declarationValue.bottom),
|
|
338
|
+
left: this.processValue(declarationValue.left)
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
if ("topLeft" in declarationValue) {
|
|
342
|
+
return {
|
|
343
|
+
topLeft: this.processValue(declarationValue.topLeft),
|
|
344
|
+
topRight: this.processValue(declarationValue.topRight),
|
|
345
|
+
bottomLeft: this.processValue(declarationValue.bottomLeft),
|
|
346
|
+
bottomRight: this.processValue(declarationValue.bottomRight)
|
|
347
|
+
};
|
|
348
|
+
}
|
|
349
|
+
if ("grow" in declarationValue) {
|
|
350
|
+
const parsedFlex = {
|
|
351
|
+
flexGrow: declarationValue.grow,
|
|
352
|
+
flexShrink: declarationValue.shrink,
|
|
353
|
+
flexBasis: this.processValue(declarationValue.basis)
|
|
354
|
+
};
|
|
355
|
+
if (declarationProperty === "flex" && parsedFlex.flexGrow === 1 && parsedFlex.flexShrink === 1 && parsedFlex.flexBasis === '"0%"') {
|
|
356
|
+
return {
|
|
357
|
+
flex: 1
|
|
358
|
+
};
|
|
359
|
+
}
|
|
360
|
+
return parsedFlex;
|
|
361
|
+
}
|
|
362
|
+
if (Array.isArray(declarationValue)) {
|
|
363
|
+
if (declarationValue.length === 1) {
|
|
364
|
+
return this.processValue(declarationValue[0]);
|
|
365
|
+
}
|
|
366
|
+
if (this.isTransformArray(declarationValue)) {
|
|
367
|
+
return declarationValue.flatMap(value => {
|
|
368
|
+
const result = this.processValue(value);
|
|
369
|
+
return Array.isArray(result) ? result : [result];
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
return this.addComaBetweenTokens(declarationValue).reduce((acc, value, index, array) => {
|
|
373
|
+
if (typeof value === "object") {
|
|
374
|
+
const nextValue = array.at(index + 1);
|
|
375
|
+
if ((0, _utils2.deepEqual)(value, nextValue)) {
|
|
376
|
+
return acc;
|
|
377
|
+
}
|
|
378
|
+
const result = this.processValue(value);
|
|
379
|
+
return acc === "" && typeof result === "number" ? result : acc + result;
|
|
380
|
+
}
|
|
381
|
+
return acc + value;
|
|
382
|
+
}, "");
|
|
383
|
+
}
|
|
384
|
+
if ("property" in declarationValue) {
|
|
385
|
+
const property = typeof declarationValue.property === "string" ? declarationValue.property : declarationValue.property.property;
|
|
386
|
+
return `${property},`;
|
|
387
|
+
}
|
|
388
|
+
if ("case" in declarationValue) {
|
|
389
|
+
return declarationValue.case;
|
|
390
|
+
}
|
|
391
|
+
if ("angle" in declarationValue) {
|
|
392
|
+
const angles = (0, _utils2.pipe)([["rotateX", declarationValue.x * declarationValue.angle.value], ["rotateY", declarationValue.y * declarationValue.angle.value], ["rotateZ", declarationValue.z * declarationValue.angle.value]])(x => x.filter(([, value]) => value !== 0), x => x.map(([key, value]) => [key, `${value}${declarationValue.angle.type}`]), Object.fromEntries);
|
|
393
|
+
return angles;
|
|
394
|
+
}
|
|
395
|
+
if (this.isOverflow(declarationValue)) {
|
|
396
|
+
if (declarationValue.x === declarationValue.y) {
|
|
397
|
+
return {
|
|
398
|
+
overflow: declarationValue.x
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
return {
|
|
402
|
+
overflowX: declarationValue.x,
|
|
403
|
+
overflowY: declarationValue.y
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
if ("auto" in declarationValue) {
|
|
407
|
+
return declarationValue.ratio ? `${declarationValue.ratio[0]}/${declarationValue.ratio[1]}` : "auto";
|
|
408
|
+
}
|
|
409
|
+
if ("x" in declarationValue && "y" in declarationValue) {
|
|
410
|
+
return {
|
|
411
|
+
x: this.processValue(declarationValue.x),
|
|
412
|
+
y: this.processValue(declarationValue.y)
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
if ("xOffset" in declarationValue) {
|
|
416
|
+
return ["inset" in declarationValue && declarationValue.inset ? "inset" : void 0, this.processValue(declarationValue.xOffset), this.processValue(declarationValue.yOffset), this.processValue(declarationValue.blur), this.processValue(declarationValue.spread), this.processValue(declarationValue.color)].filter(_utils.isDefined).join(" ");
|
|
417
|
+
}
|
|
418
|
+
if ("blockStart" in declarationValue) {
|
|
419
|
+
const startValue = this.processValue(declarationValue.blockStart);
|
|
420
|
+
const endValue = this.processValue(declarationValue.blockEnd);
|
|
421
|
+
return {
|
|
422
|
+
start: startValue,
|
|
423
|
+
end: endValue
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
if ("inlineStart" in declarationValue) {
|
|
427
|
+
const startValue = this.processValue(declarationValue.inlineStart);
|
|
428
|
+
const endValue = this.processValue(declarationValue.inlineEnd);
|
|
429
|
+
return {
|
|
430
|
+
start: startValue,
|
|
431
|
+
end: endValue
|
|
432
|
+
};
|
|
433
|
+
}
|
|
434
|
+
if ("start" in declarationValue) {
|
|
435
|
+
const startValue = this.processValue(declarationValue.start);
|
|
436
|
+
const endValue = this.processValue(declarationValue.end);
|
|
437
|
+
return {
|
|
438
|
+
start: startValue,
|
|
439
|
+
end: endValue
|
|
440
|
+
};
|
|
441
|
+
}
|
|
442
|
+
if ("row" in declarationValue) {
|
|
443
|
+
return {
|
|
444
|
+
row: this.processValue(declarationValue.row),
|
|
445
|
+
column: this.processValue(declarationValue.column)
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
if ("keyword" in declarationValue) {
|
|
449
|
+
return declarationValue.keyword === "auto" || declarationValue.keyword === "pointer" ? declarationValue.keyword : "auto";
|
|
450
|
+
}
|
|
451
|
+
if ("style" in declarationValue && "width" in declarationValue) {
|
|
452
|
+
return {
|
|
453
|
+
style: this.processValue(declarationValue.style),
|
|
454
|
+
width: declarationValue.width.type === "length" ? this.processValue(declarationValue.width.value) : void 0,
|
|
455
|
+
color: this.Processor.Color.processColor(declarationValue.color)
|
|
456
|
+
};
|
|
457
|
+
}
|
|
458
|
+
if ("duration" in declarationValue) {
|
|
459
|
+
return Object.entries(declarationValue).map(([key, value]) => [(0, _utils2.toCamelCase)(key), this.processValue(value)]);
|
|
460
|
+
}
|
|
461
|
+
this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`);
|
|
462
|
+
return void 0;
|
|
463
|
+
}
|
|
464
|
+
static TRANSFORM_TYPES = /* @__PURE__ */new Set(["translate", "translateX", "translateY", "translateZ", "rotate", "rotateX", "rotateY", "rotateZ", "scale", "scaleX", "scaleY", "scaleZ", "skew", "skewX", "skewY", "matrix", "perspective"]);
|
|
465
|
+
isTransformArray(values) {
|
|
466
|
+
return values.every(value => typeof value === "object" && value !== null && "type" in value && CSS.TRANSFORM_TYPES.has(value.type));
|
|
467
|
+
}
|
|
468
|
+
isOverflow(value) {
|
|
469
|
+
return typeof value === "object" && "x" in value && ["hidden", "visible"].includes(value.x);
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Between some tokens there isn't a comma but it should be.
|
|
473
|
+
* For example this applies to Array of shadows
|
|
474
|
+
*/
|
|
475
|
+
addComaBetweenTokens(values) {
|
|
476
|
+
return values.reduce((acc, value, index, array) => {
|
|
477
|
+
const next = array.at(index + 1);
|
|
478
|
+
acc.push(value);
|
|
479
|
+
if (next === void 0) {
|
|
480
|
+
return acc;
|
|
481
|
+
}
|
|
482
|
+
if (typeof next === "object" && "type" in next && next.type === "token" && next.value.type === "comma") {
|
|
483
|
+
return acc;
|
|
484
|
+
}
|
|
485
|
+
if (!(typeof value === "object" && "xOffset" in value && "blur" in value)) {
|
|
486
|
+
return acc;
|
|
487
|
+
}
|
|
488
|
+
acc.push({
|
|
489
|
+
type: "token",
|
|
490
|
+
value: {
|
|
491
|
+
type: "comma"
|
|
492
|
+
}
|
|
493
|
+
});
|
|
494
|
+
return acc;
|
|
495
|
+
}, []);
|
|
496
|
+
}
|
|
497
|
+
logUnsupported(message) {
|
|
498
|
+
this.logger.warn([message, this.Processor.meta.className !== void 0 ? `for className ${this.Processor.meta.className}` : null].filter(Boolean).join(" "));
|
|
499
|
+
}
|
|
500
|
+
makeSafeForSerialization(value) {
|
|
501
|
+
if ((0, _utils2.shouldBeSerialized)(value)) {
|
|
502
|
+
return value;
|
|
503
|
+
}
|
|
504
|
+
if (value.endsWith("%")) {
|
|
505
|
+
return `"${(0, _utils2.roundToPrecision)(parseFloat(value), 2)}%"`;
|
|
506
|
+
}
|
|
507
|
+
return `"${value}"`;
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
exports.CSS = CSS;
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Functions = void 0;
|
|
7
|
+
var _logger = require("../logger");
|
|
8
|
+
var _utils = require("./utils");
|
|
9
|
+
class Functions {
|
|
10
|
+
constructor(Processor) {
|
|
11
|
+
this.Processor = Processor;
|
|
12
|
+
}
|
|
13
|
+
logger = new _logger.Logger("Functions");
|
|
14
|
+
processCalc(calc) {
|
|
15
|
+
switch (calc.type) {
|
|
16
|
+
case "sum":
|
|
17
|
+
{
|
|
18
|
+
const sum = calc.value.map(x => this.processCalc(x)).join(" + ");
|
|
19
|
+
return this.tryEval(sum);
|
|
20
|
+
}
|
|
21
|
+
case "value":
|
|
22
|
+
return this.Processor.CSS.processValue(calc.value);
|
|
23
|
+
case "function":
|
|
24
|
+
return this.Processor.CSS.processValue(calc.value);
|
|
25
|
+
case "number":
|
|
26
|
+
return String(calc.value);
|
|
27
|
+
default:
|
|
28
|
+
this.logger.warn(`Unsupported calc type - ${calc.type}`);
|
|
29
|
+
return "";
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
processFunction(fn) {
|
|
33
|
+
if (typeof fn !== "object") {
|
|
34
|
+
this.logger.warn(`Unsupported function - ${fn}`);
|
|
35
|
+
return fn;
|
|
36
|
+
}
|
|
37
|
+
if (fn.name === "calc") {
|
|
38
|
+
const calc = this.Processor.CSS.processValue(fn.arguments);
|
|
39
|
+
return (0, _utils.pipe)(calc)(String, x => this.Processor.Functions.tryEval(x));
|
|
40
|
+
}
|
|
41
|
+
if (fn.name === "cubic-bezier") {
|
|
42
|
+
const cubicArguments = (0, _utils.pipe)(this.Processor.CSS.processValue(fn.arguments))(String, x => x.replace(/,\s/g, ","));
|
|
43
|
+
return `rt.cubicBezier(${cubicArguments})`;
|
|
44
|
+
}
|
|
45
|
+
if (fn.name === "steps") {
|
|
46
|
+
const stepsArguments = (0, _utils.pipe)(this.Processor.CSS.processValue(fn.arguments))(String, x => x.replace(/,\s/g, ","));
|
|
47
|
+
return `rt.steps(${stepsArguments})`;
|
|
48
|
+
}
|
|
49
|
+
if (fn.name === "linear") {
|
|
50
|
+
const linearArguments = (0, _utils.pipe)(this.Processor.CSS.processValue(fn.arguments))(String, x => x.replace(/,\s/g, ","));
|
|
51
|
+
return `rt.linear(${linearArguments})`;
|
|
52
|
+
}
|
|
53
|
+
if (fn.name === "max") {
|
|
54
|
+
return `Math.max(${this.Processor.CSS.processValue(fn.arguments)})`;
|
|
55
|
+
}
|
|
56
|
+
if (fn.name === "linear-gradient") {
|
|
57
|
+
return this.Processor.CSS.processValue(fn.arguments);
|
|
58
|
+
}
|
|
59
|
+
if (fn.name === "color-mix") {
|
|
60
|
+
return this.processColorMix(fn);
|
|
61
|
+
}
|
|
62
|
+
if (fn.name === "translate3d") {
|
|
63
|
+
const [x, y] = this.Processor.CSS.processValue(fn.arguments).split(", ").map(x2 => x2.replace(/\s??\s/g, ""));
|
|
64
|
+
return ` translateX(\${${x}}) translateY(\${${y}})`;
|
|
65
|
+
}
|
|
66
|
+
if (fn.name === "scale3d") {
|
|
67
|
+
const [x, y] = this.Processor.CSS.processValue(fn.arguments).split(", ").map(x2 => x2.replace(/\s??\s/g, ""));
|
|
68
|
+
return ` scaleX(\${${x}}) scaleY(\${${y}})`;
|
|
69
|
+
}
|
|
70
|
+
if (fn.name === "rotate") {
|
|
71
|
+
return ` rotate(\${${this.Processor.CSS.processValue(fn.arguments).replace(/\s??\s/g, "")}})`;
|
|
72
|
+
}
|
|
73
|
+
if (["blur", "brightness", "contrast", "grayscale", "invert", "opacity", "saturate", "sepia", "url", "drop-shadow", "hue-rotate"].includes(fn.name)) {
|
|
74
|
+
const value = this.Processor.CSS.processValue(fn.arguments);
|
|
75
|
+
return `\`${fn.name}(${typeof value === "string" && value.startsWith("this[") ? `\${${value}}` : value})\``;
|
|
76
|
+
}
|
|
77
|
+
if (["rgb", "oklab", "oklch", "hsl", "hwb", "lab", "lch", "srgb"].includes(fn.name)) {
|
|
78
|
+
const color = `${fn.name}(${this.Processor.CSS.processValue(fn.arguments)})`;
|
|
79
|
+
return this.Processor.Color.processColor(color);
|
|
80
|
+
}
|
|
81
|
+
if (["blur", "brightness", "contrast", "grayscale", "hue-rotate", "invert", "opacity", "saturate", "sepia", "conic-gradient", "radial-gradient"].includes(fn.name)) {
|
|
82
|
+
return '""';
|
|
83
|
+
}
|
|
84
|
+
if (["skewX", "skewY"].includes(fn.name)) {
|
|
85
|
+
return `"${fn.name}(${this.Processor.CSS.processValue(fn.arguments).replace(/"/g, "")})"`;
|
|
86
|
+
}
|
|
87
|
+
if (fn.name === "hairlineWidth") {
|
|
88
|
+
return "rt.hairlineWidth";
|
|
89
|
+
}
|
|
90
|
+
if (fn.name === "platformSelect") {
|
|
91
|
+
return `rt.platformSelect(${this.Processor.CSS.processValue(fn.arguments)})`;
|
|
92
|
+
}
|
|
93
|
+
if (fn.name === "pixelRatio") {
|
|
94
|
+
if (fn.arguments.length === 0) {
|
|
95
|
+
return "rt.pixelRatio(1)";
|
|
96
|
+
}
|
|
97
|
+
return `rt.pixelRatio(${this.Processor.CSS.processValue(fn.arguments)})`;
|
|
98
|
+
}
|
|
99
|
+
if (fn.name === "fontScale") {
|
|
100
|
+
if (fn.arguments.length === 0) {
|
|
101
|
+
return "rt.fontScale(1)";
|
|
102
|
+
}
|
|
103
|
+
return `rt.fontScale(${this.Processor.CSS.processValue(fn.arguments)})`;
|
|
104
|
+
}
|
|
105
|
+
if (fn.name === "drop-shadow") {
|
|
106
|
+
return void 0;
|
|
107
|
+
}
|
|
108
|
+
this.logger.warn(`Unsupported function - ${fn.name}`);
|
|
109
|
+
return fn.name;
|
|
110
|
+
}
|
|
111
|
+
processMathFunction(name, value) {
|
|
112
|
+
if (!Array.isArray(value)) {
|
|
113
|
+
return `Math.${name}(${this.processCalc(value)})`;
|
|
114
|
+
}
|
|
115
|
+
const values = value.map(x => this.processCalc(x)).join(" , ");
|
|
116
|
+
return `Math.${name}(${values})`;
|
|
117
|
+
}
|
|
118
|
+
tryEval(value) {
|
|
119
|
+
const units = Array.from(value.replace(/"/g, "").match(/(?<![A-Za-z-])(?:%|deg|rad|grad|turn)(?=\s|$)/g) ?? []);
|
|
120
|
+
if (units.length === 0) {
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
if (new Set(units).size !== 1) {
|
|
124
|
+
this.logger.error(`Invalid calc, you can't mix multiple units`);
|
|
125
|
+
return value;
|
|
126
|
+
}
|
|
127
|
+
if (units.includes("%") && value.includes("+")) {
|
|
128
|
+
this.logger.error(`Invalid calc, you can't mix % with other units`);
|
|
129
|
+
return value;
|
|
130
|
+
}
|
|
131
|
+
const unit = units.at(0) ?? "";
|
|
132
|
+
try {
|
|
133
|
+
const numericValue = value.replace(/"/g, "").replace(new RegExp(unit, "g"), "");
|
|
134
|
+
return new Function(`return ${numericValue} + '${unit}'`)();
|
|
135
|
+
} catch {
|
|
136
|
+
this.logger.error(`Invalid calc ${value}`);
|
|
137
|
+
return value;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
processColorMix(fn) {
|
|
141
|
+
const tokens = fn.arguments.map(arg => (0, _utils.pipe)(arg)(x => this.Processor.CSS.processValue(x), String, x => x.trim())).filter(token => !["", ",", "in", "srgb", "rgb", "hsl", "hwb", "lab", "lch", "oklab", "oklch"].includes(token.replace(/"/g, "")));
|
|
142
|
+
return `rt.colorMix(${tokens.join(", ")})`;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
exports.Functions = Functions;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _addMetaToStylesTemplate = require("./addMetaToStylesTemplate");
|
|
7
|
+
Object.keys(_addMetaToStylesTemplate).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _addMetaToStylesTemplate[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _addMetaToStylesTemplate[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
var _processor = require("./processor");
|
|
18
|
+
Object.keys(_processor).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (key in exports && exports[key] === _processor[key]) return;
|
|
21
|
+
Object.defineProperty(exports, key, {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () {
|
|
24
|
+
return _processor[key];
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
var _serialize = require("./serialize");
|
|
29
|
+
Object.keys(_serialize).forEach(function (key) {
|
|
30
|
+
if (key === "default" || key === "__esModule") return;
|
|
31
|
+
if (key in exports && exports[key] === _serialize[key]) return;
|
|
32
|
+
Object.defineProperty(exports, key, {
|
|
33
|
+
enumerable: true,
|
|
34
|
+
get: function () {
|
|
35
|
+
return _serialize[key];
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|