@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
|
@@ -1,212 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
|
-
import path from 'path';
|
|
3
2
|
import { compile } from '@tailwindcss/node';
|
|
4
3
|
import { transform } from 'lightningcss';
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
const red = "\x1B[91m";
|
|
8
|
-
const yellow = "\x1B[33m";
|
|
9
|
-
const blue = "\x1B[36m";
|
|
10
|
-
const reset = "\x1B[0m";
|
|
11
|
-
class Logger {
|
|
12
|
-
constructor(name) {
|
|
13
|
-
this.name = name;
|
|
14
|
-
}
|
|
15
|
-
static debug = false;
|
|
16
|
-
static log(message, meta = "") {
|
|
17
|
-
if (!Logger.debug) {
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
console.log(`${blue}Uniwind ${meta}- ${message}${reset}`);
|
|
21
|
-
}
|
|
22
|
-
static error(message, meta = "") {
|
|
23
|
-
console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
|
|
24
|
-
}
|
|
25
|
-
static warn(message, meta = "") {
|
|
26
|
-
if (!Logger.debug) {
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
console.log(`${yellow}Uniwind Warning ${meta}- ${message}${reset}`);
|
|
30
|
-
}
|
|
31
|
-
log(message) {
|
|
32
|
-
Logger.log(message, `[${this.name} Processor] `);
|
|
33
|
-
}
|
|
34
|
-
error(message) {
|
|
35
|
-
Logger.error(message, `[${this.name} Processor] `);
|
|
36
|
-
}
|
|
37
|
-
warn(message) {
|
|
38
|
-
Logger.warn(message, `[${this.name} Processor] `);
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const ONE_PX = {
|
|
43
|
-
type: "token",
|
|
44
|
-
value: { type: "dimension", unit: "px", value: 1 }
|
|
45
|
-
};
|
|
46
|
-
class FunctionVisitor {
|
|
47
|
-
platformSelect(fn) {
|
|
48
|
-
return fn.arguments.at(0) ?? { type: "token", value: { type: "ident", value: "initial" } };
|
|
49
|
-
}
|
|
50
|
-
pixelRatio(fn) {
|
|
51
|
-
return {
|
|
52
|
-
type: "function",
|
|
53
|
-
value: {
|
|
54
|
-
name: "calc",
|
|
55
|
-
arguments: [
|
|
56
|
-
fn.arguments.at(0) ?? ONE_PX,
|
|
57
|
-
{ type: "token", value: { type: "delim", value: "*" } },
|
|
58
|
-
ONE_PX
|
|
59
|
-
]
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
fontScale(fn) {
|
|
64
|
-
return {
|
|
65
|
-
type: "function",
|
|
66
|
-
value: {
|
|
67
|
-
name: "calc",
|
|
68
|
-
arguments: [
|
|
69
|
-
fn.arguments.at(0) ?? ONE_PX,
|
|
70
|
-
{ type: "token", value: { type: "delim", value: "*" } },
|
|
71
|
-
{
|
|
72
|
-
type: "token",
|
|
73
|
-
value: { type: "dimension", value: 1, unit: "rem" }
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
hairlineWidth() {
|
|
80
|
-
return ONE_PX;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
class RuleVisitor {
|
|
85
|
-
constructor(themes) {
|
|
86
|
-
this.themes = themes;
|
|
87
|
-
}
|
|
88
|
-
processedClassNames = /* @__PURE__ */ new Set();
|
|
89
|
-
processedVariables = /* @__PURE__ */ new Set();
|
|
90
|
-
currentLayerName = "";
|
|
91
|
-
"layer-block" = (layer) => {
|
|
92
|
-
this.currentLayerName = layer.value.name?.join("") ?? "";
|
|
93
|
-
};
|
|
94
|
-
style = (styleRule) => {
|
|
95
|
-
const firstSelector = styleRule.value.selectors.at(0)?.at(0);
|
|
96
|
-
if (this.currentLayerName === "theme" && firstSelector?.type === "pseudo-class" && firstSelector.kind === "root") {
|
|
97
|
-
return this.removeNulls(this.processThemeRoot(styleRule));
|
|
98
|
-
}
|
|
99
|
-
if (firstSelector?.type === "class") {
|
|
100
|
-
return this.processClassStyle(styleRule, firstSelector);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
cleanup() {
|
|
104
|
-
this.currentLayerName = "";
|
|
105
|
-
this.processedClassNames.clear();
|
|
106
|
-
this.processedVariables.clear();
|
|
107
|
-
}
|
|
108
|
-
processThemeRoot(styleRule) {
|
|
109
|
-
const themeScopedRules = styleRule.value.rules?.filter((rule) => {
|
|
110
|
-
if (rule.type !== "style") {
|
|
111
|
-
return false;
|
|
112
|
-
}
|
|
113
|
-
const firstSelector = rule.value.selectors.at(0)?.at(0);
|
|
114
|
-
const secondSelector = rule.value.selectors.at(0)?.at(1);
|
|
115
|
-
return firstSelector?.type === "nesting" && secondSelector?.type === "pseudo-class" && secondSelector.kind === "where";
|
|
116
|
-
}) ?? [];
|
|
117
|
-
const nonThemeRules = styleRule.value.rules?.filter((rule) => !themeScopedRules.includes(rule));
|
|
118
|
-
const processedThemeScopedRules = themeScopedRules.map((rule) => {
|
|
119
|
-
if (rule.type !== "style") {
|
|
120
|
-
return rule;
|
|
121
|
-
}
|
|
122
|
-
const secondSelector = rule.value.selectors.at(0)?.at(1);
|
|
123
|
-
if (secondSelector?.type === "pseudo-class" && secondSelector.kind === "where") {
|
|
124
|
-
return this.processThemeStyle(rule, secondSelector);
|
|
125
|
-
}
|
|
126
|
-
return rule;
|
|
127
|
-
});
|
|
128
|
-
return [
|
|
129
|
-
{
|
|
130
|
-
type: "style",
|
|
131
|
-
value: {
|
|
132
|
-
loc: styleRule.value.loc,
|
|
133
|
-
selectors: styleRule.value.selectors,
|
|
134
|
-
rules: nonThemeRules,
|
|
135
|
-
declarations: styleRule.value.declarations
|
|
136
|
-
}
|
|
137
|
-
},
|
|
138
|
-
...processedThemeScopedRules
|
|
139
|
-
];
|
|
140
|
-
}
|
|
141
|
-
processThemeStyle(styleRule, secondSelector) {
|
|
142
|
-
const whereSelector = secondSelector.selectors.at(0)?.at(0);
|
|
143
|
-
if (whereSelector?.type !== "class") {
|
|
144
|
-
return styleRule;
|
|
145
|
-
}
|
|
146
|
-
const selectedVariant = this.themes.find((theme) => whereSelector.name === theme);
|
|
147
|
-
if (selectedVariant === void 0 || this.processedVariables.has(selectedVariant)) {
|
|
148
|
-
return styleRule;
|
|
149
|
-
}
|
|
150
|
-
this.processedVariables.add(selectedVariant);
|
|
151
|
-
return {
|
|
152
|
-
type: "style",
|
|
153
|
-
value: {
|
|
154
|
-
loc: styleRule.value.loc,
|
|
155
|
-
selectors: [[{ type: "class", name: selectedVariant }]],
|
|
156
|
-
declarations: styleRule.value.declarations,
|
|
157
|
-
rules: styleRule.value.rules
|
|
158
|
-
}
|
|
159
|
-
};
|
|
160
|
-
}
|
|
161
|
-
processClassStyle(styleRule, firstSelector) {
|
|
162
|
-
const selectedVariant = this.themes.find((theme) => firstSelector.name.includes(`${theme}:`));
|
|
163
|
-
if (selectedVariant === void 0 || this.processedClassNames.has(firstSelector.name)) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
this.processedClassNames.add(firstSelector.name);
|
|
167
|
-
return {
|
|
168
|
-
type: "scope",
|
|
169
|
-
value: {
|
|
170
|
-
loc: styleRule.value.loc,
|
|
171
|
-
rules: [styleRule],
|
|
172
|
-
scopeStart: [[{ type: "class", name: selectedVariant }]],
|
|
173
|
-
scopeEnd: this.themes.filter((theme) => theme !== selectedVariant).map((theme) => [{ type: "class", name: theme }])
|
|
174
|
-
}
|
|
175
|
-
};
|
|
176
|
-
}
|
|
177
|
-
// Fixes lightningcss serialization bug
|
|
178
|
-
removeNulls(value) {
|
|
179
|
-
if (Array.isArray(value)) {
|
|
180
|
-
return value.map((v) => this.removeNulls(v));
|
|
181
|
-
}
|
|
182
|
-
if (typeof value === "object" && value !== null) {
|
|
183
|
-
return Object.fromEntries(
|
|
184
|
-
Object.entries(value).filter(([_, value2]) => {
|
|
185
|
-
if (value2 === null) {
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
return true;
|
|
189
|
-
}).map(([key, value2]) => [key, this.removeNulls(value2)])
|
|
190
|
-
);
|
|
191
|
-
}
|
|
192
|
-
return value;
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
class UniwindCSSVisitor {
|
|
197
|
-
constructor(themes) {
|
|
198
|
-
this.themes = themes;
|
|
199
|
-
const ruleVisitor = new RuleVisitor(this.themes);
|
|
200
|
-
this.Function = new FunctionVisitor();
|
|
201
|
-
this.Rule = ruleVisitor;
|
|
202
|
-
this.StyleSheet = () => {
|
|
203
|
-
ruleVisitor.cleanup();
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
Function;
|
|
207
|
-
Rule;
|
|
208
|
-
StyleSheet;
|
|
209
|
-
}
|
|
4
|
+
import path from 'path';
|
|
210
5
|
|
|
211
6
|
const toKebabCase = (str) => str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);
|
|
212
7
|
const generateExtraUtilities = (map) => {
|
|
@@ -333,6 +128,37 @@ const overwriteDisabled = `@custom-variant disabled {
|
|
|
333
128
|
`;
|
|
334
129
|
const OVERWRITE_CSS = overwriteDisabled;
|
|
335
130
|
|
|
131
|
+
const red = "\x1B[91m";
|
|
132
|
+
const reset = "\x1B[0m";
|
|
133
|
+
class Logger {
|
|
134
|
+
constructor(name) {
|
|
135
|
+
this.name = name;
|
|
136
|
+
}
|
|
137
|
+
static debug = false;
|
|
138
|
+
static log(message, meta = "") {
|
|
139
|
+
{
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
static error(message, meta = "") {
|
|
144
|
+
console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
|
|
145
|
+
}
|
|
146
|
+
static warn(message, meta = "") {
|
|
147
|
+
{
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
log(message) {
|
|
152
|
+
Logger.log(message, `[${this.name} Processor] `);
|
|
153
|
+
}
|
|
154
|
+
error(message) {
|
|
155
|
+
Logger.error(message, `[${this.name} Processor] `);
|
|
156
|
+
}
|
|
157
|
+
warn(message) {
|
|
158
|
+
Logger.warn(message, `[${this.name} Processor] `);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
336
162
|
const readFileSafe = (filePath) => {
|
|
337
163
|
try {
|
|
338
164
|
return fs.readFileSync(filePath, "utf-8");
|
|
@@ -457,10 +283,8 @@ const generateCSSForVariants = () => {
|
|
|
457
283
|
};
|
|
458
284
|
const VARIANTS_CSS = generateCSSForVariants();
|
|
459
285
|
|
|
460
|
-
const
|
|
461
|
-
const buildCSS = async (themes, input) => {
|
|
286
|
+
const buildCSS = async (themes, input, cssFilePath) => {
|
|
462
287
|
const themesCSS = await generateCSSForThemes(themes, input);
|
|
463
|
-
const cssFilePath = path.join(dirname, "../../uniwind.css");
|
|
464
288
|
const oldCSSFile = fs.existsSync(cssFilePath) ? fs.readFileSync(cssFilePath, "utf-8") : "";
|
|
465
289
|
const newCssFile = [
|
|
466
290
|
VARIANTS_CSS,
|
|
@@ -481,10 +305,10 @@ const buildCSS = async (themes, input) => {
|
|
|
481
305
|
const buildDtsFile = (dtsPath, stringifiedThemes) => {
|
|
482
306
|
const oldDtsContent = fs.existsSync(dtsPath) ? fs.readFileSync(dtsPath, "utf-8") : "";
|
|
483
307
|
const dtsContent = [
|
|
484
|
-
`// NOTE: This file is generated by
|
|
485
|
-
`/// <reference types="
|
|
308
|
+
`// NOTE: This file is generated by uniwind and it should not be edited manually.`,
|
|
309
|
+
`/// <reference types="uniwind/types" />`,
|
|
486
310
|
"",
|
|
487
|
-
`declare module '
|
|
311
|
+
`declare module 'uniwind' {`,
|
|
488
312
|
` export interface UniwindConfig {`,
|
|
489
313
|
` themes: readonly ${stringifiedThemes}`,
|
|
490
314
|
` }`,
|
|
@@ -499,6 +323,267 @@ const buildDtsFile = (dtsPath, stringifiedThemes) => {
|
|
|
499
323
|
fs.writeFileSync(dtsPath, dtsContent);
|
|
500
324
|
};
|
|
501
325
|
|
|
502
|
-
const
|
|
326
|
+
const ONE_PX = {
|
|
327
|
+
type: "token",
|
|
328
|
+
value: { type: "dimension", unit: "px", value: 1 }
|
|
329
|
+
};
|
|
330
|
+
class FunctionVisitor {
|
|
331
|
+
platformSelect(fn) {
|
|
332
|
+
return fn.arguments.at(0) ?? { type: "token", value: { type: "ident", value: "initial" } };
|
|
333
|
+
}
|
|
334
|
+
pixelRatio(fn) {
|
|
335
|
+
return {
|
|
336
|
+
type: "function",
|
|
337
|
+
value: {
|
|
338
|
+
name: "calc",
|
|
339
|
+
arguments: [
|
|
340
|
+
fn.arguments.at(0) ?? ONE_PX,
|
|
341
|
+
{ type: "token", value: { type: "delim", value: "*" } },
|
|
342
|
+
ONE_PX
|
|
343
|
+
]
|
|
344
|
+
}
|
|
345
|
+
};
|
|
346
|
+
}
|
|
347
|
+
fontScale(fn) {
|
|
348
|
+
return {
|
|
349
|
+
type: "function",
|
|
350
|
+
value: {
|
|
351
|
+
name: "calc",
|
|
352
|
+
arguments: [
|
|
353
|
+
fn.arguments.at(0) ?? ONE_PX,
|
|
354
|
+
{ type: "token", value: { type: "delim", value: "*" } },
|
|
355
|
+
{
|
|
356
|
+
type: "token",
|
|
357
|
+
value: { type: "dimension", value: 1, unit: "rem" }
|
|
358
|
+
}
|
|
359
|
+
]
|
|
360
|
+
}
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
hairlineWidth() {
|
|
364
|
+
return ONE_PX;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
class RuleVisitor {
|
|
369
|
+
constructor(bundlerConfig) {
|
|
370
|
+
this.bundlerConfig = bundlerConfig;
|
|
371
|
+
}
|
|
372
|
+
processedClassNames = /* @__PURE__ */ new Set();
|
|
373
|
+
processedVariables = /* @__PURE__ */ new Set();
|
|
374
|
+
currentLayerName = "";
|
|
375
|
+
"layer-block" = (layer) => {
|
|
376
|
+
this.currentLayerName = layer.value.name?.join("") ?? "";
|
|
377
|
+
};
|
|
378
|
+
style = (styleRule) => {
|
|
379
|
+
const firstSelector = styleRule.value.selectors.at(0)?.at(0);
|
|
380
|
+
if (this.currentLayerName === "theme" && firstSelector?.type === "pseudo-class" && firstSelector.kind === "root") {
|
|
381
|
+
return this.removeNulls(this.processThemeRoot(styleRule));
|
|
382
|
+
}
|
|
383
|
+
if (firstSelector?.type === "class") {
|
|
384
|
+
return this.processClassStyle(styleRule, firstSelector);
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
cleanup() {
|
|
388
|
+
this.currentLayerName = "";
|
|
389
|
+
this.processedClassNames.clear();
|
|
390
|
+
this.processedVariables.clear();
|
|
391
|
+
}
|
|
392
|
+
processThemeRoot(styleRule) {
|
|
393
|
+
const themeScopedRules = styleRule.value.rules?.filter((rule) => {
|
|
394
|
+
if (rule.type !== "style") {
|
|
395
|
+
return false;
|
|
396
|
+
}
|
|
397
|
+
const firstSelector = rule.value.selectors.at(0)?.at(0);
|
|
398
|
+
const secondSelector = rule.value.selectors.at(0)?.at(1);
|
|
399
|
+
return firstSelector?.type === "nesting" && secondSelector?.type === "pseudo-class" && secondSelector.kind === "where";
|
|
400
|
+
}) ?? [];
|
|
401
|
+
const nonThemeRules = styleRule.value.rules?.filter((rule) => !themeScopedRules.includes(rule));
|
|
402
|
+
const processedThemeScopedRules = themeScopedRules.map((rule) => {
|
|
403
|
+
if (rule.type !== "style") {
|
|
404
|
+
return rule;
|
|
405
|
+
}
|
|
406
|
+
const secondSelector = rule.value.selectors.at(0)?.at(1);
|
|
407
|
+
if (secondSelector?.type === "pseudo-class" && secondSelector.kind === "where") {
|
|
408
|
+
return this.processThemeStyle(rule, secondSelector);
|
|
409
|
+
}
|
|
410
|
+
return rule;
|
|
411
|
+
});
|
|
412
|
+
return [
|
|
413
|
+
{
|
|
414
|
+
type: "style",
|
|
415
|
+
value: {
|
|
416
|
+
loc: styleRule.value.loc,
|
|
417
|
+
selectors: styleRule.value.selectors,
|
|
418
|
+
rules: nonThemeRules,
|
|
419
|
+
declarations: styleRule.value.declarations
|
|
420
|
+
}
|
|
421
|
+
},
|
|
422
|
+
...processedThemeScopedRules
|
|
423
|
+
];
|
|
424
|
+
}
|
|
425
|
+
processThemeStyle(styleRule, secondSelector) {
|
|
426
|
+
const whereSelector = secondSelector.selectors.at(0)?.at(0);
|
|
427
|
+
if (whereSelector?.type !== "class") {
|
|
428
|
+
return styleRule;
|
|
429
|
+
}
|
|
430
|
+
const selectedVariant = this.bundlerConfig.themes.find((theme) => whereSelector.name === theme);
|
|
431
|
+
if (selectedVariant === void 0 || this.processedVariables.has(selectedVariant)) {
|
|
432
|
+
return styleRule;
|
|
433
|
+
}
|
|
434
|
+
this.processedVariables.add(selectedVariant);
|
|
435
|
+
return {
|
|
436
|
+
type: "style",
|
|
437
|
+
value: {
|
|
438
|
+
loc: styleRule.value.loc,
|
|
439
|
+
selectors: [[{ type: "class", name: selectedVariant }]],
|
|
440
|
+
declarations: styleRule.value.declarations,
|
|
441
|
+
rules: styleRule.value.rules
|
|
442
|
+
}
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
processClassStyle(styleRule, firstSelector) {
|
|
446
|
+
const selectedVariant = this.bundlerConfig.themes.find((theme) => firstSelector.name.includes(`${theme}:`));
|
|
447
|
+
if (selectedVariant === void 0 || this.processedClassNames.has(firstSelector.name)) {
|
|
448
|
+
return;
|
|
449
|
+
}
|
|
450
|
+
this.processedClassNames.add(firstSelector.name);
|
|
451
|
+
return {
|
|
452
|
+
type: "scope",
|
|
453
|
+
value: {
|
|
454
|
+
loc: styleRule.value.loc,
|
|
455
|
+
rules: [styleRule],
|
|
456
|
+
scopeStart: [[{ type: "class", name: selectedVariant }]],
|
|
457
|
+
scopeEnd: this.bundlerConfig.themes.filter((theme) => theme !== selectedVariant).map((theme) => [{ type: "class", name: theme }])
|
|
458
|
+
}
|
|
459
|
+
};
|
|
460
|
+
}
|
|
461
|
+
// Fixes lightningcss serialization bug
|
|
462
|
+
removeNulls(value) {
|
|
463
|
+
if (Array.isArray(value)) {
|
|
464
|
+
return value.map((v) => this.removeNulls(v));
|
|
465
|
+
}
|
|
466
|
+
if (typeof value === "object" && value !== null) {
|
|
467
|
+
return Object.fromEntries(
|
|
468
|
+
Object.entries(value).filter(([_, value2]) => {
|
|
469
|
+
if (value2 === null) {
|
|
470
|
+
return false;
|
|
471
|
+
}
|
|
472
|
+
return true;
|
|
473
|
+
}).map(([key, value2]) => [key, this.removeNulls(value2)])
|
|
474
|
+
);
|
|
475
|
+
}
|
|
476
|
+
return value;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
class UniwindCSSVisitor {
|
|
481
|
+
Function;
|
|
482
|
+
Rule;
|
|
483
|
+
StyleSheet;
|
|
484
|
+
constructor(bundlerConfig) {
|
|
485
|
+
const ruleVisitor = new RuleVisitor(bundlerConfig);
|
|
486
|
+
this.Function = new FunctionVisitor();
|
|
487
|
+
this.Rule = ruleVisitor;
|
|
488
|
+
this.StyleSheet = () => {
|
|
489
|
+
ruleVisitor.cleanup();
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
495
|
+
Platform2["Android"] = "android";
|
|
496
|
+
Platform2["iOS"] = "ios";
|
|
497
|
+
Platform2["Web"] = "web";
|
|
498
|
+
Platform2["Native"] = "native";
|
|
499
|
+
Platform2["TV"] = "tv";
|
|
500
|
+
Platform2["AndroidTV"] = "android-tv";
|
|
501
|
+
Platform2["AppleTV"] = "apple-tv";
|
|
502
|
+
return Platform2;
|
|
503
|
+
})(Platform || {});
|
|
504
|
+
const UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
505
|
+
const UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
506
|
+
var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
|
|
507
|
+
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
508
|
+
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
509
|
+
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
510
|
+
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
511
|
+
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
512
|
+
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
513
|
+
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
514
|
+
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
515
|
+
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
516
|
+
return StyleDependency2;
|
|
517
|
+
})(StyleDependency || {});
|
|
518
|
+
const DEFAULT_SCREEN_WIDTH = 375;
|
|
519
|
+
const DEFAULT_SCREEN_HEIGHT = 680;
|
|
520
|
+
|
|
521
|
+
const isDefined = (value) => value !== void 0 && value !== null;
|
|
522
|
+
|
|
523
|
+
class UniwindBundlerConfig {
|
|
524
|
+
constructor(config, platform) {
|
|
525
|
+
this.config = config;
|
|
526
|
+
this.platform = platform;
|
|
527
|
+
}
|
|
528
|
+
static fromMetroConfig(config, platform) {
|
|
529
|
+
const getPlatform = () => {
|
|
530
|
+
if (!isDefined(platform)) {
|
|
531
|
+
return Platform.Native;
|
|
532
|
+
}
|
|
533
|
+
if (!config.isTV) {
|
|
534
|
+
return platform;
|
|
535
|
+
}
|
|
536
|
+
if (platform === Platform.Android) {
|
|
537
|
+
return Platform.AndroidTV;
|
|
538
|
+
}
|
|
539
|
+
if (platform === Platform.iOS) {
|
|
540
|
+
return Platform.AppleTV;
|
|
541
|
+
}
|
|
542
|
+
throw new Error(`Platform ${platform} not supported`);
|
|
543
|
+
};
|
|
544
|
+
if (typeof config === "undefined") {
|
|
545
|
+
throw new Error("Uniwind: You need to pass second parameter to withUniwindConfig");
|
|
546
|
+
}
|
|
547
|
+
if (typeof config.cssEntryFile === "undefined") {
|
|
548
|
+
throw new Error(
|
|
549
|
+
'Uniwind: You need to pass css css entry file to withUniwindConfig, e.g. withUniwindConfig(config, { cssEntryFile: "./global.css" })'
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
return new UniwindBundlerConfig(config, getPlatform());
|
|
553
|
+
}
|
|
554
|
+
static fromViteConfig(config) {
|
|
555
|
+
return new UniwindBundlerConfig(config, Platform.Web);
|
|
556
|
+
}
|
|
557
|
+
get cssPath() {
|
|
558
|
+
return path.join(process.cwd(), this.config.cssEntryFile);
|
|
559
|
+
}
|
|
560
|
+
get themes() {
|
|
561
|
+
return Array.from(
|
|
562
|
+
/* @__PURE__ */ new Set([
|
|
563
|
+
"light",
|
|
564
|
+
"dark",
|
|
565
|
+
...this.config.extraThemes ?? []
|
|
566
|
+
])
|
|
567
|
+
);
|
|
568
|
+
}
|
|
569
|
+
get cssVisitor() {
|
|
570
|
+
return new UniwindCSSVisitor(this);
|
|
571
|
+
}
|
|
572
|
+
get polyfills() {
|
|
573
|
+
return this.config.polyfills;
|
|
574
|
+
}
|
|
575
|
+
get stringifiedThemes() {
|
|
576
|
+
return `[${this.themes.map((theme) => `'${theme}'`).join(", ")}]`;
|
|
577
|
+
}
|
|
578
|
+
toMetroConfig() {
|
|
579
|
+
return this.config;
|
|
580
|
+
}
|
|
581
|
+
async generateArtifacts(cssArtifactPath) {
|
|
582
|
+
await buildCSS(this.themes, this.config.cssEntryFile, cssArtifactPath);
|
|
583
|
+
buildDtsFile(this.config.dtsFile ?? "uniwind-types.d.ts", this.stringifiedThemes);
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
const name = "@niibase/uniwind";
|
|
503
588
|
|
|
504
|
-
export { Logger as L,
|
|
589
|
+
export { DEFAULT_SCREEN_HEIGHT as D, Logger as L, Platform as P, StyleDependency as S, UniwindBundlerConfig as U, DEFAULT_SCREEN_WIDTH as a, UNIWIND_PLATFORM_VARIABLES as b, UNIWIND_THEME_VARIABLES as c, isDefined as i, name as n };
|
package/dist/vite/index.cjs
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const node = require('@tailwindcss/node');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const
|
|
6
|
-
const stringifyThemes = require('../shared/uniwind.r2i22V6d.cjs');
|
|
5
|
+
const _package = require('../shared/uniwind.CFiAZ3D-.cjs');
|
|
7
6
|
require('fs');
|
|
8
7
|
require('lightningcss');
|
|
9
8
|
|
|
@@ -20,17 +19,9 @@ const styleSheetPath = path__default.resolve(
|
|
|
20
19
|
dirname,
|
|
21
20
|
"../module/components/web/createOrderedCSSStyleSheet.js"
|
|
22
21
|
);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
dtsFile = "uniwind-types.d.ts"
|
|
27
|
-
}) => {
|
|
28
|
-
const themes = common.uniq([
|
|
29
|
-
"light",
|
|
30
|
-
"dark",
|
|
31
|
-
...extraThemes ?? []
|
|
32
|
-
]);
|
|
33
|
-
const stringifiedThemes = stringifyThemes.stringifyThemes(themes);
|
|
22
|
+
const cssArtifactPath = path__default.resolve(dirname, "../../uniwind.css");
|
|
23
|
+
const uniwind = (config) => {
|
|
24
|
+
const bundlerConfig = _package.UniwindBundlerConfig.fromViteConfig(config);
|
|
34
25
|
return {
|
|
35
26
|
name: "uniwind",
|
|
36
27
|
enforce: "pre",
|
|
@@ -45,11 +36,11 @@ const uniwind = ({
|
|
|
45
36
|
css: {
|
|
46
37
|
transformer: "lightningcss",
|
|
47
38
|
lightningcss: {
|
|
48
|
-
visitor:
|
|
39
|
+
visitor: bundlerConfig.cssVisitor
|
|
49
40
|
}
|
|
50
41
|
},
|
|
51
42
|
optimizeDeps: {
|
|
52
|
-
exclude: [
|
|
43
|
+
exclude: [_package.name, "react-native"],
|
|
53
44
|
esbuildOptions: {
|
|
54
45
|
plugins: [{
|
|
55
46
|
name: "uniwind-esbuild-plugin",
|
|
@@ -73,7 +64,7 @@ const uniwind = ({
|
|
|
73
64
|
replacement: componentPath,
|
|
74
65
|
customResolver: {
|
|
75
66
|
resolveId(_, importer) {
|
|
76
|
-
if (importer !== void 0 && node.normalizePath(importer).includes(`${
|
|
67
|
+
if (importer !== void 0 && node.normalizePath(importer).includes(`${_package.name}/dist`)) {
|
|
77
68
|
return this.resolve("react-native-web");
|
|
78
69
|
}
|
|
79
70
|
return componentPath;
|
|
@@ -85,19 +76,18 @@ const uniwind = ({
|
|
|
85
76
|
}),
|
|
86
77
|
transform: (code, id) => {
|
|
87
78
|
const normalizedId = node.normalizePath(id);
|
|
88
|
-
if (normalizedId.includes(`${
|
|
79
|
+
if (normalizedId.includes(`${_package.name}/dist`) && normalizedId.includes("config/config.js")) {
|
|
89
80
|
return {
|
|
90
|
-
code: `${code}
|
|
81
|
+
code: `${code}
|
|
82
|
+
;Uniwind.__reinit(() => ({}), ${bundlerConfig.stringifiedThemes})`
|
|
91
83
|
};
|
|
92
84
|
}
|
|
93
85
|
},
|
|
94
86
|
buildStart: async () => {
|
|
95
|
-
await
|
|
96
|
-
stringifyThemes.buildDtsFile(dtsFile, stringifiedThemes);
|
|
87
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
97
88
|
},
|
|
98
89
|
generateBundle: async () => {
|
|
99
|
-
await
|
|
100
|
-
stringifyThemes.buildDtsFile(dtsFile, stringifiedThemes);
|
|
90
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
101
91
|
}
|
|
102
92
|
};
|
|
103
93
|
};
|
package/dist/vite/index.mjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { normalizePath } from '@tailwindcss/node';
|
|
2
2
|
import path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
import { s as stringifyThemes, U as UniwindCSSVisitor, a as buildCSS, b as buildDtsFile } from '../shared/uniwind.BGiqYvxb.mjs';
|
|
3
|
+
import { n as name, U as UniwindBundlerConfig } from '../shared/uniwind.u-s1XVU8.mjs';
|
|
5
4
|
import 'fs';
|
|
6
5
|
import 'lightningcss';
|
|
7
6
|
|
|
@@ -14,17 +13,9 @@ const styleSheetPath = path.resolve(
|
|
|
14
13
|
dirname,
|
|
15
14
|
"../module/components/web/createOrderedCSSStyleSheet.js"
|
|
16
15
|
);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
dtsFile = "uniwind-types.d.ts"
|
|
21
|
-
}) => {
|
|
22
|
-
const themes = uniq([
|
|
23
|
-
"light",
|
|
24
|
-
"dark",
|
|
25
|
-
...extraThemes ?? []
|
|
26
|
-
]);
|
|
27
|
-
const stringifiedThemes = stringifyThemes(themes);
|
|
16
|
+
const cssArtifactPath = path.resolve(dirname, "../../uniwind.css");
|
|
17
|
+
const uniwind = (config) => {
|
|
18
|
+
const bundlerConfig = UniwindBundlerConfig.fromViteConfig(config);
|
|
28
19
|
return {
|
|
29
20
|
name: "uniwind",
|
|
30
21
|
enforce: "pre",
|
|
@@ -39,7 +30,7 @@ const uniwind = ({
|
|
|
39
30
|
css: {
|
|
40
31
|
transformer: "lightningcss",
|
|
41
32
|
lightningcss: {
|
|
42
|
-
visitor:
|
|
33
|
+
visitor: bundlerConfig.cssVisitor
|
|
43
34
|
}
|
|
44
35
|
},
|
|
45
36
|
optimizeDeps: {
|
|
@@ -81,17 +72,16 @@ const uniwind = ({
|
|
|
81
72
|
const normalizedId = normalizePath(id);
|
|
82
73
|
if (normalizedId.includes(`${name}/dist`) && normalizedId.includes("config/config.js")) {
|
|
83
74
|
return {
|
|
84
|
-
code: `${code}
|
|
75
|
+
code: `${code}
|
|
76
|
+
;Uniwind.__reinit(() => ({}), ${bundlerConfig.stringifiedThemes})`
|
|
85
77
|
};
|
|
86
78
|
}
|
|
87
79
|
},
|
|
88
80
|
buildStart: async () => {
|
|
89
|
-
await
|
|
90
|
-
buildDtsFile(dtsFile, stringifiedThemes);
|
|
81
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
91
82
|
},
|
|
92
83
|
generateBundle: async () => {
|
|
93
|
-
await
|
|
94
|
-
buildDtsFile(dtsFile, stringifiedThemes);
|
|
84
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
95
85
|
}
|
|
96
86
|
};
|
|
97
87
|
};
|