@niibase/uniwind 1.6.3 → 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 +58 -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/index.js +0 -3
- package/dist/common/components/web/rnw.js +2 -2
- package/dist/common/core/config/config.common.js +15 -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/index.js +7 -11
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +26 -18
- 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} +306 -173
- package/dist/metro/{metro-transformer.mjs → transformer.mjs} +249 -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/index.js +0 -3
- 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 +7 -6
- package/dist/module/core/config/config.common.js +6 -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/index.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/index.js +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +4 -2
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +23 -16
- 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 +115 -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/index.ts +0 -3
- 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 +15 -8
- 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/index.ts +1 -1
- package/src/hooks/useCSSVariable/useCSSVariable.ts +34 -25
- 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
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,61 @@
|
|
|
1
|
+
## What's Changed in 1.7.0
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### 🚀 Features
|
|
6
|
+
|
|
7
|
+
* introduce responsive scaling support by @divineniiquaye
|
|
8
|
+
|
|
9
|
+
### 🐛 Bug Fixes
|
|
10
|
+
|
|
11
|
+
* reemove redundant constructor assignment from css processor by @divineniiquaye
|
|
12
|
+
* dont parse flex: 1 (#543) by @Brentlok
|
|
13
|
+
* deeply find themed variables (#535) by @Brentlok
|
|
14
|
+
|
|
15
|
+
### 🔨 Refactoring
|
|
16
|
+
|
|
17
|
+
* major bundler refactor (#523) by @Brentlok
|
|
18
|
+
|
|
19
|
+
### 🏠 Chores
|
|
20
|
+
|
|
21
|
+
* pass bundler config directly by @Brentlok
|
|
22
|
+
* generate artifacts before compiling virtual code by @Brentlok
|
|
23
|
+
* update version by @Brentlok
|
|
24
|
+
* silent css variable warning for SSR (#539) by @Brentlok
|
|
25
|
+
|
|
26
|
+
### 📦 Other
|
|
27
|
+
|
|
28
|
+
* Merge branch 'updates' by @divineniiquaye
|
|
29
|
+
* Fix !important modifier having no effect on native (#534) by @jezsung
|
|
30
|
+
|
|
31
|
+
### New Contributors
|
|
32
|
+
* @jezsung made their first contribution
|
|
33
|
+
|
|
34
|
+
**Full Changelog**: https://github.com/divineniiquaye/uniwind/compare/v1.6.4...v1.7.0
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## What's Changed in 1.6.4
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### 🚀 Features
|
|
42
|
+
|
|
43
|
+
* getCSSVariable function to get css variable outside of react (#521) by @Brentlok
|
|
44
|
+
* parse inline-start inline-end border to RN (#515) by @Brentlok
|
|
45
|
+
|
|
46
|
+
### 🐛 Bug Fixes
|
|
47
|
+
|
|
48
|
+
* join border radius to fix some components (#517) by @Brentlok
|
|
49
|
+
* remove deprecated push notification ios export (#516) by @Brentlok
|
|
50
|
+
|
|
51
|
+
### 📦 Other
|
|
52
|
+
|
|
53
|
+
* Merge branch 'pre-release' by @divineniiquaye
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
**Full Changelog**: https://github.com/divineniiquaye/uniwind/compare/v1.6.3...v1.6.4
|
|
57
|
+
|
|
58
|
+
|
|
1
59
|
## What's Changed in 1.6.3
|
|
2
60
|
|
|
3
61
|
|
|
@@ -5,17 +5,14 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.buildCSS = void 0;
|
|
7
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
8
|
var _extraUtilities = require("./extraUtilities");
|
|
10
9
|
var _insets = require("./insets");
|
|
11
10
|
var _overwrite = require("./overwrite");
|
|
12
11
|
var _themes = require("./themes");
|
|
13
12
|
var _variants = require("./variants");
|
|
14
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
15
|
-
const
|
|
16
|
-
const buildCSS = async (themes, input) => {
|
|
14
|
+
const buildCSS = async (themes, input, cssFilePath) => {
|
|
17
15
|
const themesCSS = await (0, _themes.generateCSSForThemes)(themes, input);
|
|
18
|
-
const cssFilePath = _path.default.join(dirname, "../../uniwind.css");
|
|
19
16
|
const oldCSSFile = _fs.default.existsSync(cssFilePath) ? _fs.default.readFileSync(cssFilePath, "utf-8") : "";
|
|
20
17
|
const newCssFile = [_variants.VARIANTS_CSS, _insets.INSETS_CSS, _overwrite.OVERWRITE_CSS, _extraUtilities.EXTRA_UTILITIES_CSS, themesCSS].join("\n");
|
|
21
18
|
if (oldCSSFile === newCssFile) {
|
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.generateCSSForThemes = void 0;
|
|
7
|
+
var _logger = require("@/bundler/logger");
|
|
7
8
|
var _node = require("@tailwindcss/node");
|
|
8
9
|
var _fs = _interopRequireDefault(require("fs"));
|
|
9
10
|
var _lightningcss = require("lightningcss");
|
|
10
11
|
var _path = _interopRequireDefault(require("path"));
|
|
11
|
-
var _logger = require("../metro/logger");
|
|
12
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
13
13
|
const readFileSafe = filePath => {
|
|
14
14
|
try {
|
|
@@ -5,11 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.buildDtsFile = void 0;
|
|
7
7
|
var _fs = _interopRequireDefault(require("fs"));
|
|
8
|
-
var _package = require("../../package.json");
|
|
9
8
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
10
9
|
const buildDtsFile = (dtsPath, stringifiedThemes) => {
|
|
11
10
|
const oldDtsContent = _fs.default.existsSync(dtsPath) ? _fs.default.readFileSync(dtsPath, "utf-8") : "";
|
|
12
|
-
const dtsContent = [`// NOTE: This file is generated by
|
|
11
|
+
const dtsContent = [`// NOTE: This file is generated by uniwind and it should not be edited manually.`, `/// <reference types="uniwind/types" />`, "", `declare module 'uniwind' {`, ` export interface UniwindConfig {`, ` themes: readonly ${stringifiedThemes}`, ` }`, `}`, "", `export {}`, ""].join("\n");
|
|
13
12
|
if (oldDtsContent === dtsContent) {
|
|
14
13
|
return;
|
|
15
14
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.UniwindBundlerConfig = void 0;
|
|
7
|
+
var _css = require("@/bundler/artifacts/css");
|
|
8
|
+
var _dts = require("@/bundler/artifacts/dts");
|
|
9
|
+
var _cssVisitor = require("@/bundler/css-visitor");
|
|
10
|
+
var _consts = require("@/common/consts");
|
|
11
|
+
var _utils = require("@/common/utils");
|
|
12
|
+
var _path = _interopRequireDefault(require("path"));
|
|
13
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
|
+
class UniwindBundlerConfig {
|
|
15
|
+
constructor(config, platform) {
|
|
16
|
+
this.config = config;
|
|
17
|
+
this.platform = platform;
|
|
18
|
+
}
|
|
19
|
+
static fromMetroConfig(config, platform) {
|
|
20
|
+
const getPlatform = () => {
|
|
21
|
+
if (!(0, _utils.isDefined)(platform)) {
|
|
22
|
+
return _consts.Platform.Native;
|
|
23
|
+
}
|
|
24
|
+
if (!config.isTV) {
|
|
25
|
+
return platform;
|
|
26
|
+
}
|
|
27
|
+
if (platform === _consts.Platform.Android) {
|
|
28
|
+
return _consts.Platform.AndroidTV;
|
|
29
|
+
}
|
|
30
|
+
if (platform === _consts.Platform.iOS) {
|
|
31
|
+
return _consts.Platform.AppleTV;
|
|
32
|
+
}
|
|
33
|
+
throw new Error(`Platform ${platform} not supported`);
|
|
34
|
+
};
|
|
35
|
+
if (typeof config === "undefined") {
|
|
36
|
+
throw new Error("Uniwind: You need to pass second parameter to withUniwindConfig");
|
|
37
|
+
}
|
|
38
|
+
if (typeof config.cssEntryFile === "undefined") {
|
|
39
|
+
throw new Error('Uniwind: You need to pass css css entry file to withUniwindConfig, e.g. withUniwindConfig(config, { cssEntryFile: "./global.css" })');
|
|
40
|
+
}
|
|
41
|
+
return new UniwindBundlerConfig(config, getPlatform());
|
|
42
|
+
}
|
|
43
|
+
static fromViteConfig(config) {
|
|
44
|
+
return new UniwindBundlerConfig(config, _consts.Platform.Web);
|
|
45
|
+
}
|
|
46
|
+
get cssPath() {
|
|
47
|
+
return _path.default.join(process.cwd(), this.config.cssEntryFile);
|
|
48
|
+
}
|
|
49
|
+
get themes() {
|
|
50
|
+
return Array.from(/* @__PURE__ */new Set(["light", "dark", ...(this.config.extraThemes ?? [])]));
|
|
51
|
+
}
|
|
52
|
+
get cssVisitor() {
|
|
53
|
+
return new _cssVisitor.UniwindCSSVisitor(this);
|
|
54
|
+
}
|
|
55
|
+
get polyfills() {
|
|
56
|
+
return this.config.polyfills;
|
|
57
|
+
}
|
|
58
|
+
get stringifiedThemes() {
|
|
59
|
+
return `[${this.themes.map(theme => `'${theme}'`).join(", ")}]`;
|
|
60
|
+
}
|
|
61
|
+
toMetroConfig() {
|
|
62
|
+
return this.config;
|
|
63
|
+
}
|
|
64
|
+
async generateArtifacts(cssArtifactPath) {
|
|
65
|
+
await (0, _css.buildCSS)(this.themes, this.config.cssEntryFile, cssArtifactPath);
|
|
66
|
+
(0, _dts.buildDtsFile)(this.config.dtsFile ?? "uniwind-types.d.ts", this.stringifiedThemes);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.UniwindBundlerConfig = UniwindBundlerConfig;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compileCSS = void 0;
|
|
7
|
+
var _consts = require("@/common/consts");
|
|
8
|
+
var _compileNativeCSS = require("./compileNativeCSS");
|
|
9
|
+
var _compileTailwind = require("./compileTailwind");
|
|
10
|
+
var _compileWebCSS = require("./compileWebCSS");
|
|
11
|
+
const compileCSS = async bundlerConfig => {
|
|
12
|
+
const tailwindCSS = await (0, _compileTailwind.compileTailwind)(bundlerConfig);
|
|
13
|
+
if (bundlerConfig.platform === _consts.Platform.Web) {
|
|
14
|
+
return (0, _compileWebCSS.compileWebCSS)(bundlerConfig, tailwindCSS);
|
|
15
|
+
}
|
|
16
|
+
return (0, _compileNativeCSS.compileNativeCSS)(bundlerConfig, tailwindCSS);
|
|
17
|
+
};
|
|
18
|
+
exports.compileCSS = compileCSS;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compileNativeCSS = void 0;
|
|
7
|
+
var _cssProcessor = require("../css-processor");
|
|
8
|
+
const compileNativeCSS = (bundlerConfig, tailwindCSS) => {
|
|
9
|
+
const Processor = new _cssProcessor.ProcessorBuilder(bundlerConfig);
|
|
10
|
+
Processor.transform(tailwindCSS);
|
|
11
|
+
const stylesheet = (0, _cssProcessor.serializeJSObject)((0, _cssProcessor.addMetaToStylesTemplate)(Processor, bundlerConfig.platform), (key, value) => `"${key}": ${value}`);
|
|
12
|
+
const vars = (0, _cssProcessor.serializeJSObject)(Processor.vars, (key, value) => `get "${key}"() { return ${value} }`);
|
|
13
|
+
const keyframes = (0, _cssProcessor.serializeJSObject)(Processor.keyframes, (key, value) => `get "${key}"() { return ${value} }`);
|
|
14
|
+
const scopedVars = Object.fromEntries(Object.entries(Processor.scopedVars).map(([scopedVarsName, scopedVars2]) => [scopedVarsName, (0, _cssProcessor.serializeJSObject)(scopedVars2, (key, value) => `get "${key}"() { return ${value} }`)]));
|
|
15
|
+
const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
|
|
16
|
+
const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`;
|
|
17
|
+
return ["({", `scopedVars: ({ ${serializedScopedVars} }),`, `vars: ({ ${currentColorVar} ${vars} }),`, `stylesheet: ({ ${stylesheet} }),`, `keyframes: ({ ${keyframes} }),`, "})"].join("");
|
|
18
|
+
};
|
|
19
|
+
exports.compileNativeCSS = compileNativeCSS;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compileTailwind = void 0;
|
|
7
|
+
var _node = require("@tailwindcss/node");
|
|
8
|
+
var _oxide = require("@tailwindcss/oxide");
|
|
9
|
+
var _fs = _interopRequireDefault(require("fs"));
|
|
10
|
+
var _path = _interopRequireDefault(require("path"));
|
|
11
|
+
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
+
const compileTailwind = async bundlerConfig => {
|
|
13
|
+
const css = await _fs.default.promises.readFile(bundlerConfig.cssPath, "utf-8");
|
|
14
|
+
const compiler = await (0, _node.compile)(css, {
|
|
15
|
+
base: _path.default.dirname(bundlerConfig.cssPath),
|
|
16
|
+
onDependency: () => void 0
|
|
17
|
+
});
|
|
18
|
+
const scanner = new _oxide.Scanner({
|
|
19
|
+
sources: [...compiler.sources, {
|
|
20
|
+
negated: false,
|
|
21
|
+
pattern: "**/*",
|
|
22
|
+
base: _path.default.dirname(bundlerConfig.cssPath)
|
|
23
|
+
}]
|
|
24
|
+
});
|
|
25
|
+
return compiler.build(scanner.scan());
|
|
26
|
+
};
|
|
27
|
+
exports.compileTailwind = compileTailwind;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.compileWebCSS = void 0;
|
|
7
|
+
var _lightningcss = require("lightningcss");
|
|
8
|
+
const compileWebCSS = (bundlerConfig, tailwindCSS) => {
|
|
9
|
+
return (0, _lightningcss.transform)({
|
|
10
|
+
code: Buffer.from(tailwindCSS),
|
|
11
|
+
filename: "uniwind.css",
|
|
12
|
+
visitor: bundlerConfig.cssVisitor
|
|
13
|
+
}).code.toString();
|
|
14
|
+
};
|
|
15
|
+
exports.compileWebCSS = compileWebCSS;
|
|
@@ -3,14 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
var
|
|
7
|
-
Object.keys(
|
|
6
|
+
var _compileCSS = require("./compileCSS");
|
|
7
|
+
Object.keys(_compileCSS).forEach(function (key) {
|
|
8
8
|
if (key === "default" || key === "__esModule") return;
|
|
9
|
-
if (key in exports && exports[key] ===
|
|
9
|
+
if (key in exports && exports[key] === _compileCSS[key]) return;
|
|
10
10
|
Object.defineProperty(exports, key, {
|
|
11
11
|
enumerable: true,
|
|
12
12
|
get: function () {
|
|
13
|
-
return
|
|
13
|
+
return _compileCSS[key];
|
|
14
14
|
}
|
|
15
15
|
});
|
|
16
16
|
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.addMetaToStylesTemplate = void 0;
|
|
7
|
+
var _consts = require("@/common/consts");
|
|
8
|
+
var _utils = require("@/common/utils");
|
|
9
|
+
var _serialize = require("./serialize");
|
|
10
|
+
var _utils2 = require("./utils");
|
|
11
|
+
const extractVarsFromString = value => {
|
|
12
|
+
const thisIndexes = [...value.matchAll(/this\[/g)].map(m => m.index);
|
|
13
|
+
return thisIndexes.map(index => {
|
|
14
|
+
const afterIndex = value.slice(index + 5);
|
|
15
|
+
const closingIndex = afterIndex.indexOf("]");
|
|
16
|
+
const varName = afterIndex.slice(0, closingIndex);
|
|
17
|
+
return varName.replace(/[`"\\]/g, "");
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const makeSafeForSerialization = value => {
|
|
21
|
+
if (value === null) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (typeof value === "string") {
|
|
25
|
+
return `"${value}"`;
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
};
|
|
29
|
+
const hasThemedVarDependency = (varName, Processor, visited = /* @__PURE__ */new Set()) => {
|
|
30
|
+
if (visited.has(varName)) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
visited.add(varName);
|
|
34
|
+
const isScopedVar = Object.values(Processor.scopedVars).some(scopedVars => varName in scopedVars);
|
|
35
|
+
if (isScopedVar) {
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
const globalVarValue = Processor.vars[varName];
|
|
39
|
+
if (typeof globalVarValue !== "string") {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
return extractVarsFromString(globalVarValue).some(usedVarName => {
|
|
43
|
+
return hasThemedVarDependency(usedVarName, Processor, visited);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
47
|
+
const stylesheetsEntries = Object.entries(Processor.stylesheets).map(([className, stylesPerMediaQuery]) => {
|
|
48
|
+
const styles = stylesPerMediaQuery.map((style, index) => {
|
|
49
|
+
const {
|
|
50
|
+
platform,
|
|
51
|
+
rtl,
|
|
52
|
+
theme,
|
|
53
|
+
orientation,
|
|
54
|
+
minWidth,
|
|
55
|
+
maxWidth,
|
|
56
|
+
colorScheme,
|
|
57
|
+
important: _,
|
|
58
|
+
importantProperties,
|
|
59
|
+
active,
|
|
60
|
+
focus,
|
|
61
|
+
disabled,
|
|
62
|
+
dataAttributes,
|
|
63
|
+
...rest
|
|
64
|
+
} = style;
|
|
65
|
+
const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function() { return ${(0, _serialize.serialize)(value)} }`]);
|
|
66
|
+
if (platform) {
|
|
67
|
+
const isTV = currentPlatform === _consts.Platform.AndroidTV || currentPlatform === _consts.Platform.AppleTV;
|
|
68
|
+
const commonPlatform = isTV ? _consts.Platform.TV : _consts.Platform.Native;
|
|
69
|
+
if (platform !== commonPlatform && platform !== currentPlatform) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
if (entries.length === 0) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
const dependencies = [];
|
|
77
|
+
const stringifiedEntries = JSON.stringify(entries);
|
|
78
|
+
const usedVars = extractVarsFromString(stringifiedEntries);
|
|
79
|
+
const isUsingThemedVar = usedVars.some(usedVarName => hasThemedVarDependency(usedVarName, Processor));
|
|
80
|
+
if (usedVars.length > 0) {
|
|
81
|
+
dependencies.push(_consts.StyleDependency.Variables);
|
|
82
|
+
}
|
|
83
|
+
if (theme !== null || isUsingThemedVar || stringifiedEntries.includes("rt.lightDark")) {
|
|
84
|
+
dependencies.push(_consts.StyleDependency.Theme);
|
|
85
|
+
}
|
|
86
|
+
if (orientation !== null) {
|
|
87
|
+
dependencies.push(_consts.StyleDependency.Orientation);
|
|
88
|
+
}
|
|
89
|
+
if (rtl !== null) {
|
|
90
|
+
dependencies.push(_consts.StyleDependency.Rtl);
|
|
91
|
+
}
|
|
92
|
+
if (Number(minWidth) !== 0 || Number(maxWidth) !== Number.MAX_VALUE || stringifiedEntries.includes("rt.makeResponsive") || stringifiedEntries.includes("rt.screen")) {
|
|
93
|
+
dependencies.push(_consts.StyleDependency.Dimensions);
|
|
94
|
+
}
|
|
95
|
+
if (stringifiedEntries.includes("rt.insets")) {
|
|
96
|
+
dependencies.push(_consts.StyleDependency.Insets);
|
|
97
|
+
}
|
|
98
|
+
if (stringifiedEntries.includes("rt.fontScale")) {
|
|
99
|
+
dependencies.push(_consts.StyleDependency.FontScale);
|
|
100
|
+
}
|
|
101
|
+
return {
|
|
102
|
+
entries,
|
|
103
|
+
minWidth,
|
|
104
|
+
maxWidth,
|
|
105
|
+
theme: makeSafeForSerialization(theme),
|
|
106
|
+
orientation: makeSafeForSerialization(orientation),
|
|
107
|
+
rtl,
|
|
108
|
+
colorScheme: makeSafeForSerialization(colorScheme),
|
|
109
|
+
native: platform !== null,
|
|
110
|
+
dependencies: dependencies.length > 0 ? dependencies : null,
|
|
111
|
+
index,
|
|
112
|
+
className: makeSafeForSerialization(className),
|
|
113
|
+
active,
|
|
114
|
+
focus,
|
|
115
|
+
disabled,
|
|
116
|
+
importantProperties: importantProperties?.map(property => property.startsWith("--") ? property : (0, _utils2.toCamelCase)(property)).map(makeSafeForSerialization) ?? [],
|
|
117
|
+
dataAttributes,
|
|
118
|
+
complexity: [minWidth !== 0, theme !== null, orientation !== null, rtl !== null, platform !== null, active !== null, focus !== null, disabled !== null, dataAttributes !== null].filter(Boolean).length
|
|
119
|
+
};
|
|
120
|
+
});
|
|
121
|
+
const filteredStyles = styles.filter(_utils.isDefined);
|
|
122
|
+
if (filteredStyles.length === 0) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
return [className, filteredStyles];
|
|
126
|
+
}).filter(_utils.isDefined);
|
|
127
|
+
const stylesheets = Object.fromEntries(stylesheetsEntries);
|
|
128
|
+
return stylesheets;
|
|
129
|
+
};
|
|
130
|
+
exports.addMetaToStylesTemplate = addMetaToStylesTemplate;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getProcessedVarAnimation = exports.getProcessedAnimation = void 0;
|
|
7
|
+
var _utils = require("./utils");
|
|
8
|
+
const STATIC_TIMING_FUNCTIONS = /* @__PURE__ */new Set(["linear", "ease", "ease-in", "ease-out", "ease-in-out", "step-start", "step-end"]);
|
|
9
|
+
const DIRECTION_VALUES = /* @__PURE__ */new Set(["normal", "reverse", "alternate", "alternate-reverse"]);
|
|
10
|
+
const FILL_MODE_VALUES = /* @__PURE__ */new Set(["none", "forwards", "backwards", "both"]);
|
|
11
|
+
const PLAY_STATE_VALUES = /* @__PURE__ */new Set(["running", "paused"]);
|
|
12
|
+
const isTimeString = x => {
|
|
13
|
+
if (typeof x === "number") return true;
|
|
14
|
+
return typeof x === "string" && /^-?\d*(?:\.\d+)?(?:e[+-]?\d+)?(ms|s)$/.test(x.trim());
|
|
15
|
+
};
|
|
16
|
+
const isTimingFunctionCustom = x => {
|
|
17
|
+
if (typeof x !== "string") return false;
|
|
18
|
+
return x.startsWith("rt.cubicBezier(") || x.startsWith("rt.steps(") || x.startsWith("rt.linear(");
|
|
19
|
+
};
|
|
20
|
+
const getProcessedVarAnimation = (declarationValue, styles, updateVar) => {
|
|
21
|
+
const tokens = declarationValue.replace(/\)/g, ") ").split(" ");
|
|
22
|
+
let duration = false;
|
|
23
|
+
for (const unprocessedToken of tokens) {
|
|
24
|
+
const token = unprocessedToken.replace(/^"|"$/g, "");
|
|
25
|
+
if (isTimeString(token) && !duration) {
|
|
26
|
+
styles["animation-duration"] = unprocessedToken;
|
|
27
|
+
duration = true;
|
|
28
|
+
} else if (isTimeString(token) && duration) {
|
|
29
|
+
styles["animation-delay"] = unprocessedToken;
|
|
30
|
+
} else if (STATIC_TIMING_FUNCTIONS.has(token)) {
|
|
31
|
+
styles["animation-timing-function"] = unprocessedToken;
|
|
32
|
+
} else if (isTimingFunctionCustom(token)) {
|
|
33
|
+
styles["animation-timing-function"] = unprocessedToken;
|
|
34
|
+
} else if (token === "infinite" || /^\d+$/.test(token)) {
|
|
35
|
+
styles["animation-iteration-count"] = unprocessedToken;
|
|
36
|
+
} else if (DIRECTION_VALUES.has(token)) {
|
|
37
|
+
styles["animation-direction"] = unprocessedToken;
|
|
38
|
+
} else if (FILL_MODE_VALUES.has(token)) {
|
|
39
|
+
styles["animation-fill-mode"] = unprocessedToken;
|
|
40
|
+
} else if (PLAY_STATE_VALUES.has(token)) {
|
|
41
|
+
styles["animation-play-state"] = unprocessedToken;
|
|
42
|
+
} else {
|
|
43
|
+
updateVar(`"${token}"`);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
exports.getProcessedVarAnimation = getProcessedVarAnimation;
|
|
48
|
+
const parseValues = (tokens, getProcessedValue) => {
|
|
49
|
+
const groups = [];
|
|
50
|
+
let group = [];
|
|
51
|
+
for (const token of tokens) {
|
|
52
|
+
if (token.type === "token" && token.value.type === "delim" && token.value.value === "|") {
|
|
53
|
+
if (group.length > 0) {
|
|
54
|
+
groups.push(group);
|
|
55
|
+
group = [];
|
|
56
|
+
}
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
group.push(token);
|
|
60
|
+
}
|
|
61
|
+
if (group.length > 0) {
|
|
62
|
+
groups.push(group);
|
|
63
|
+
}
|
|
64
|
+
const values = groups.map(groupTokens => tokensToText(groupTokens, getProcessedValue));
|
|
65
|
+
return values.length > 1 ? values : values[0];
|
|
66
|
+
};
|
|
67
|
+
const tokensToText = (tokens, getProcessedValue) => {
|
|
68
|
+
return tokens.map(token => {
|
|
69
|
+
const value = getProcessedValue(token);
|
|
70
|
+
if (typeof value === "string") {
|
|
71
|
+
return /^"[^"]+"$/.test(value) ? value : `"${value}"`;
|
|
72
|
+
}
|
|
73
|
+
return value;
|
|
74
|
+
}).join(" ").trim();
|
|
75
|
+
};
|
|
76
|
+
const getProcessedAnimation = (declarationValue, getProcessedValue) => {
|
|
77
|
+
const segments = [];
|
|
78
|
+
const result = [];
|
|
79
|
+
let current = [];
|
|
80
|
+
for (const token of declarationValue) {
|
|
81
|
+
if (token.type === "var") {
|
|
82
|
+
return getProcessedValue(token);
|
|
83
|
+
}
|
|
84
|
+
if (token.type === "token" && token.value.type === "comma") {
|
|
85
|
+
if (current.length > 0) {
|
|
86
|
+
segments.push(current);
|
|
87
|
+
current = [];
|
|
88
|
+
}
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
current.push(token);
|
|
92
|
+
}
|
|
93
|
+
if (current.length > 0) {
|
|
94
|
+
segments.push(current);
|
|
95
|
+
}
|
|
96
|
+
for (const segment of segments) {
|
|
97
|
+
const colonIndex = segment.findIndex(token => token.type === "token" && token.value.type === "colon");
|
|
98
|
+
if (colonIndex === -1) {
|
|
99
|
+
const nameValue = parseValues(segment, getProcessedValue);
|
|
100
|
+
result.push(["name", Array.isArray(nameValue) ? nameValue : [nameValue]]);
|
|
101
|
+
continue;
|
|
102
|
+
}
|
|
103
|
+
const keyTokens = segment.slice(0, colonIndex);
|
|
104
|
+
const valueTokens = segment.slice(colonIndex + 1);
|
|
105
|
+
const rawKey = tokensToText(keyTokens, getProcessedValue);
|
|
106
|
+
const value = parseValues(valueTokens, getProcessedValue);
|
|
107
|
+
const key = (0, _utils.toCamelCase)(rawKey);
|
|
108
|
+
result.push([key, value]);
|
|
109
|
+
}
|
|
110
|
+
return result;
|
|
111
|
+
};
|
|
112
|
+
exports.getProcessedAnimation = getProcessedAnimation;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.Color = void 0;
|
|
7
|
+
var _culori = require("culori");
|
|
8
|
+
var _logger = require("../logger");
|
|
9
|
+
var _utils = require("./utils");
|
|
10
|
+
class Color {
|
|
11
|
+
constructor(Processor) {
|
|
12
|
+
this.Processor = Processor;
|
|
13
|
+
}
|
|
14
|
+
toRgb = (0, _culori.converter)("rgb");
|
|
15
|
+
black = "#000000";
|
|
16
|
+
logger = new _logger.Logger("Color");
|
|
17
|
+
processColor(color) {
|
|
18
|
+
if (typeof color === "string") {
|
|
19
|
+
const parsed = (0, _culori.parse)(color);
|
|
20
|
+
if (parsed === void 0) {
|
|
21
|
+
const colorFunction = color.match(/^([a-zA-Z_$][a-zA-Z0-9_$]*)\s*\(/)?.[1];
|
|
22
|
+
if (colorFunction === void 0) {
|
|
23
|
+
this.logger.error(`Failed to convert color ${color}`);
|
|
24
|
+
return this.black;
|
|
25
|
+
}
|
|
26
|
+
const colorValue = color.replace(colorFunction, "").slice(1, -1);
|
|
27
|
+
return `rt.parseColor("${colorFunction}", ${colorValue})`;
|
|
28
|
+
}
|
|
29
|
+
return this.format(parsed);
|
|
30
|
+
}
|
|
31
|
+
try {
|
|
32
|
+
if (color.type === "currentcolor") {
|
|
33
|
+
return 'this["currentColor"]';
|
|
34
|
+
}
|
|
35
|
+
if (color.type === "rgb" || color.type === "srgb") {
|
|
36
|
+
const alpha = typeof color.alpha === "number" ? color.alpha : (0, _utils.pipe)(color.alpha)(x => this.Processor.CSS.processValue(x), Number, x => isNaN(x) ? 1 : x);
|
|
37
|
+
return this.format({
|
|
38
|
+
r: color.r / 255,
|
|
39
|
+
g: color.g / 255,
|
|
40
|
+
b: color.b / 255,
|
|
41
|
+
alpha,
|
|
42
|
+
mode: "rgb"
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
const colorType = color.type === "display-p3" ? "p3" : color.type;
|
|
46
|
+
const result = this.toRgb({
|
|
47
|
+
mode: colorType,
|
|
48
|
+
...color
|
|
49
|
+
});
|
|
50
|
+
return this.format(result);
|
|
51
|
+
} catch {
|
|
52
|
+
this.logger.error(`Failed to convert color ${JSON.stringify(color)}`);
|
|
53
|
+
return this.black;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
isColor(value) {
|
|
57
|
+
return typeof value === "string" && (0, _culori.parse)(value) !== void 0;
|
|
58
|
+
}
|
|
59
|
+
format(color) {
|
|
60
|
+
if (color.alpha === 1 || color.alpha === void 0) {
|
|
61
|
+
return (0, _culori.formatHex)(color);
|
|
62
|
+
}
|
|
63
|
+
return (0, _culori.formatHex8)(color);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.Color = Color;
|