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