@niibase/uniwind 1.6.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/common/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/common/{css → bundler/artifacts/css}/themes.js +1 -1
- package/dist/common/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +1 -2
- package/dist/common/bundler/config.js +69 -0
- package/dist/common/bundler/css-compiler/compileCSS.js +18 -0
- package/dist/common/bundler/css-compiler/compileNativeCSS.js +19 -0
- package/dist/common/bundler/css-compiler/compileTailwind.js +27 -0
- package/dist/common/bundler/css-compiler/compileWebCSS.js +15 -0
- package/dist/common/{vite → bundler/css-compiler}/index.js +4 -4
- package/dist/common/bundler/css-processor/addMetaToStylesTemplate.js +130 -0
- package/dist/common/bundler/css-processor/animation.js +112 -0
- package/dist/common/bundler/css-processor/color.js +66 -0
- package/dist/common/bundler/css-processor/css.js +510 -0
- package/dist/common/bundler/css-processor/functions.js +145 -0
- package/dist/common/bundler/css-processor/index.js +38 -0
- package/dist/common/bundler/css-processor/mq.js +87 -0
- package/dist/common/bundler/css-processor/processor.js +353 -0
- package/dist/common/bundler/css-processor/rn.js +356 -0
- package/dist/common/bundler/css-processor/serialize.js +86 -0
- package/dist/common/bundler/css-processor/types.js +1 -0
- package/dist/common/bundler/css-processor/units.js +55 -0
- package/dist/common/bundler/css-processor/utils.js +63 -0
- package/dist/common/bundler/css-processor/var.js +20 -0
- package/dist/common/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
- package/dist/common/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/common/bundler/logger.js +41 -0
- package/dist/common/bundler/types.js +1 -0
- package/dist/common/common/consts.js +26 -2
- package/dist/common/components/web/rnw.js +2 -2
- package/dist/common/core/config/config.common.js +9 -9
- package/dist/common/core/config/config.js +2 -2
- package/dist/common/core/config/config.native.js +3 -3
- package/dist/common/core/listener.js +10 -10
- package/dist/common/core/native/runtime.js +7 -3
- package/dist/common/core/native/store.js +3 -4
- package/dist/common/core/web/cssListener.js +2 -2
- package/dist/common/hoc/withUniwind.js +5 -5
- package/dist/common/hoc/withUniwind.native.js +5 -5
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +6 -2
- package/dist/common/hooks/useUniwind.js +2 -2
- package/dist/metro/index.cjs +14 -24
- package/dist/metro/index.d.ts +2 -0
- package/dist/metro/index.mjs +7 -17
- package/dist/metro/{metro-transformer.cjs → transformer.cjs} +294 -174
- package/dist/metro/{metro-transformer.mjs → transformer.mjs} +236 -116
- package/dist/module/{css → bundler/artifacts/css}/index.d.ts +1 -1
- package/dist/module/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/module/{css → bundler/artifacts/css}/themes.js +1 -1
- package/dist/module/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +3 -4
- package/dist/module/bundler/config.d.ts +16 -0
- package/dist/module/bundler/config.js +69 -0
- package/dist/module/bundler/css-compiler/compileCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileCSS.js +11 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.js +33 -0
- package/dist/module/bundler/css-compiler/compileTailwind.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileTailwind.js +22 -0
- package/dist/module/bundler/css-compiler/compileWebCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileWebCSS.js +8 -0
- package/dist/module/bundler/css-compiler/index.d.ts +1 -0
- package/dist/module/bundler/css-compiler/index.js +1 -0
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.d.ts +3 -0
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.js +136 -0
- package/dist/module/bundler/css-processor/animation.d.ts +6 -0
- package/dist/module/bundler/css-processor/animation.js +112 -0
- package/dist/module/bundler/css-processor/color.d.ts +12 -0
- package/dist/module/bundler/css-processor/color.js +63 -0
- package/dist/module/bundler/css-processor/css.d.ts +23 -0
- package/dist/module/bundler/css-processor/css.js +566 -0
- package/dist/module/bundler/css-processor/functions.d.ts +12 -0
- package/dist/module/bundler/css-processor/functions.js +190 -0
- package/dist/module/bundler/css-processor/index.d.ts +3 -0
- package/dist/module/bundler/css-processor/index.js +3 -0
- package/dist/module/bundler/css-processor/mq.d.ts +12 -0
- package/dist/module/bundler/css-processor/mq.js +78 -0
- package/dist/module/bundler/css-processor/processor.d.ts +36 -0
- package/dist/module/bundler/css-processor/processor.js +336 -0
- package/dist/module/bundler/css-processor/rn.d.ts +10 -0
- package/dist/module/bundler/css-processor/rn.js +400 -0
- package/dist/module/bundler/css-processor/serialize.d.ts +2 -0
- package/dist/module/bundler/css-processor/serialize.js +101 -0
- package/dist/module/bundler/css-processor/types.d.ts +28 -0
- package/dist/module/bundler/css-processor/types.js +0 -0
- package/dist/module/bundler/css-processor/units.d.ts +10 -0
- package/dist/module/bundler/css-processor/units.js +48 -0
- package/dist/module/bundler/css-processor/utils.d.ts +24 -0
- package/dist/{shared/uniwind.PtWWxxnh.mjs → module/bundler/css-processor/utils.js} +11 -15
- package/dist/module/bundler/css-processor/var.d.ts +7 -0
- package/dist/module/bundler/css-processor/var.js +13 -0
- package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.d.ts +1 -1
- package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.d.ts +4 -3
- package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
- package/dist/module/{css-visitor → bundler/css-visitor}/visitor.d.ts +3 -3
- package/dist/module/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/module/bundler/logger.d.ts +11 -0
- package/dist/module/bundler/logger.js +34 -0
- package/dist/module/bundler/types.d.ts +15 -0
- package/dist/module/bundler/types.js +0 -0
- package/dist/module/common/consts.d.ts +21 -0
- package/dist/module/common/consts.js +24 -0
- package/dist/module/components/ScopedTheme/ScopedTheme.native.d.ts +1 -1
- package/dist/module/components/native/Pressable.d.ts +1 -1
- package/dist/module/components/native/TouchableHighlight.d.ts +1 -1
- package/dist/module/components/native/TouchableOpacity.d.ts +1 -1
- package/dist/module/components/native/useAccentColor.d.ts +1 -1
- package/dist/module/components/native/useStyle.d.ts +2 -2
- package/dist/module/components/react-native-gesture-handler/native/BaseButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/BorderlessButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/DrawerLayoutAndroid.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/FlatList.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Pressable.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/PureNativeButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RawButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RectButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RefreshControl.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/ScrollView.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Switch.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/TextInput.d.ts +1 -1
- package/dist/module/components/web/Pressable.d.ts +1 -1
- package/dist/module/components/web/TouchableHighlight.d.ts +1 -1
- package/dist/module/components/web/TouchableOpacity.d.ts +1 -1
- package/dist/module/components/web/rnw.js +1 -1
- package/dist/module/core/config/config.common.d.ts +6 -7
- package/dist/module/core/config/config.common.js +2 -2
- package/dist/module/core/config/config.d.ts +1 -1
- package/dist/module/core/config/config.js +1 -1
- package/dist/module/core/config/config.native.d.ts +2 -2
- package/dist/module/core/config/config.native.js +1 -1
- package/dist/module/core/listener.d.ts +1 -1
- package/dist/module/core/listener.js +1 -1
- package/dist/module/core/native/runtime.js +5 -1
- package/dist/module/core/native/store.d.ts +2 -2
- package/dist/module/core/native/store.js +1 -2
- package/dist/module/core/types.d.ts +6 -3
- package/dist/module/core/web/cssListener.js +1 -1
- package/dist/module/core/web/getWebStyles.d.ts +1 -1
- package/dist/module/hoc/types.d.ts +2 -2
- package/dist/module/hoc/withUniwind.d.ts +1 -1
- package/dist/module/hoc/withUniwind.js +5 -5
- package/dist/module/hoc/withUniwind.native.d.ts +1 -1
- package/dist/module/hoc/withUniwind.native.js +5 -5
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +5 -1
- package/dist/module/hooks/useResolveClassNames.d.ts +1 -1
- package/dist/module/hooks/useUniwind.d.ts +1 -1
- package/dist/module/hooks/useUniwind.js +1 -1
- package/dist/module/index.d.ts +1 -2
- package/dist/shared/{uniwind.r2i22V6d.cjs → uniwind.CFiAZ3D-.cjs} +307 -217
- package/dist/shared/{uniwind.BGiqYvxb.mjs → uniwind.u-s1XVU8.mjs} +299 -214
- package/dist/vite/index.cjs +12 -22
- package/dist/vite/index.mjs +9 -19
- package/package.json +1 -1
- package/src/{metro → bundler/adapters/metro}/index.d.ts +2 -0
- package/src/bundler/adapters/metro/index.ts +1 -0
- package/src/{metro/withUniwindConfig.ts → bundler/adapters/metro/metro.ts} +7 -22
- package/src/{metro/metro-css-patches.ts → bundler/adapters/metro/patches.ts} +2 -1
- package/src/{metro → bundler/adapters/metro}/resolvers.ts +8 -8
- package/src/bundler/adapters/metro/transformer.ts +85 -0
- package/src/{vite → bundler/adapters/vite}/vite.ts +10 -28
- package/src/{css → bundler/artifacts/css}/extraUtilities.ts +1 -1
- package/src/{css → bundler/artifacts/css}/index.ts +1 -5
- package/src/{css → bundler/artifacts/css}/themes.ts +1 -1
- package/src/{utils/buildDtsFile.ts → bundler/artifacts/dts.ts} +3 -4
- package/src/bundler/config.ts +84 -0
- package/src/bundler/css-compiler/compileCSS.ts +15 -0
- package/src/bundler/css-compiler/compileNativeCSS.ts +41 -0
- package/src/bundler/css-compiler/compileTailwind.ts +25 -0
- package/src/bundler/css-compiler/compileWebCSS.ts +10 -0
- package/src/bundler/css-compiler/index.ts +1 -0
- package/src/{metro → bundler/css-processor}/addMetaToStylesTemplate.ts +33 -14
- package/src/{metro/processor → bundler/css-processor}/animation.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/color.ts +4 -3
- package/src/{metro/processor → bundler/css-processor}/css.ts +17 -9
- package/src/{metro/processor → bundler/css-processor}/functions.ts +2 -2
- package/src/bundler/css-processor/index.ts +3 -0
- package/src/{metro/processor → bundler/css-processor}/mq.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/processor.ts +13 -11
- package/src/{metro/processor → bundler/css-processor}/rn.ts +96 -3
- package/src/{metro/utils → bundler/css-processor}/serialize.ts +2 -2
- package/src/{metro → bundler/css-processor}/types.ts +3 -17
- package/src/{metro/processor → bundler/css-processor}/units.ts +1 -1
- package/src/{metro/processor → bundler/css-processor}/var.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/function-visitor.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/rule-visitor.ts +6 -5
- package/src/{css-visitor → bundler/css-visitor}/visitor.ts +4 -3
- package/src/bundler/types.ts +17 -0
- package/src/common/consts.ts +25 -0
- package/src/components/ScopedTheme/ScopedTheme.native.tsx +1 -1
- package/src/components/native/ActivityIndicator.tsx +2 -1
- package/src/components/native/Button.tsx +2 -1
- package/src/components/native/FlatList.tsx +2 -1
- package/src/components/native/Image.tsx +2 -1
- package/src/components/native/ImageBackground.tsx +2 -1
- package/src/components/native/InputAccessoryView.tsx +3 -2
- package/src/components/native/KeyboardAvoidingView.tsx +2 -1
- package/src/components/native/Modal.tsx +2 -1
- package/src/components/native/Pressable.tsx +1 -1
- package/src/components/native/RefreshControl.tsx +2 -1
- package/src/components/native/SafeAreaView.tsx +2 -1
- package/src/components/native/ScrollView.tsx +2 -1
- package/src/components/native/SectionList.tsx +2 -1
- package/src/components/native/Switch.tsx +3 -2
- package/src/components/native/Text.tsx +3 -2
- package/src/components/native/TextInput.tsx +3 -2
- package/src/components/native/TouchableHighlight.tsx +3 -2
- package/src/components/native/TouchableNativeFeedback.tsx +3 -2
- package/src/components/native/TouchableOpacity.tsx +3 -2
- package/src/components/native/TouchableWithoutFeedback.tsx +3 -2
- package/src/components/native/View.tsx +2 -1
- package/src/components/native/VirtualizedList.tsx +2 -1
- package/src/components/native/useAccentColor.ts +1 -1
- package/src/components/native/useStyle.ts +2 -2
- package/src/components/react-native-gesture-handler/native/BaseButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/BorderlessButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/DrawerLayoutAndroid.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/FlatList.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/GestureHandlerRootView.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/Pressable.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/PureNativeButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RawButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RectButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/ScrollView.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/Switch.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/Text.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TextInput.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableNativeFeedback.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableOpacity.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableWithoutFeedback.tsx +2 -2
- package/src/components/web/ActivityIndicator.tsx +2 -1
- package/src/components/web/Button.tsx +2 -1
- package/src/components/web/FlatList.tsx +2 -1
- package/src/components/web/Image.tsx +2 -1
- package/src/components/web/ImageBackground.tsx +2 -1
- package/src/components/web/KeyboardAvoidingView.tsx +2 -1
- package/src/components/web/Modal.tsx +2 -1
- package/src/components/web/Pressable.tsx +2 -1
- package/src/components/web/RefreshControl.tsx +2 -1
- package/src/components/web/SafeAreaView.tsx +2 -1
- package/src/components/web/ScrollView.tsx +2 -1
- package/src/components/web/SectionList.tsx +2 -1
- package/src/components/web/Switch.tsx +2 -1
- package/src/components/web/Text.tsx +2 -1
- package/src/components/web/TextInput.tsx +2 -1
- package/src/components/web/TouchableHighlight.tsx +2 -1
- package/src/components/web/TouchableOpacity.tsx +2 -1
- package/src/components/web/TouchableWithoutFeedback.tsx +2 -1
- package/src/components/web/View.tsx +2 -1
- package/src/components/web/VirtualizedList.tsx +2 -1
- package/src/components/web/rnw.ts +1 -1
- package/src/core/config/config.common.ts +11 -9
- package/src/core/config/config.native.ts +3 -3
- package/src/core/config/config.ts +2 -2
- package/src/core/listener.ts +1 -1
- package/src/core/native/runtime.ts +7 -2
- package/src/core/native/store.ts +3 -4
- package/src/core/types.ts +6 -3
- package/src/core/web/cssListener.ts +1 -1
- package/src/core/web/getWebStyles.ts +1 -1
- package/src/hoc/types.ts +2 -2
- package/src/hoc/withUniwind.native.tsx +4 -3
- package/src/hoc/withUniwind.tsx +3 -2
- package/src/hooks/useCSSVariable/getVariableValue.native.ts +1 -1
- package/src/hooks/useCSSVariable/useCSSVariable.ts +8 -2
- package/src/hooks/useResolveClassNames.ts +1 -1
- package/src/hooks/useUniwind.ts +2 -2
- package/src/index.ts +1 -2
- package/dist/common/types.js +0 -28
- package/dist/common/utils/stringifyThemes.js +0 -8
- package/dist/common/vite/vite.js +0 -95
- package/dist/module/types.d.ts +0 -21
- package/dist/module/types.js +0 -22
- package/dist/module/utils/stringifyThemes.d.ts +0 -1
- package/dist/module/utils/stringifyThemes.js +0 -1
- package/dist/module/vite/index.d.ts +0 -9
- package/dist/module/vite/index.js +0 -1
- package/dist/module/vite/vite.d.ts +0 -8
- package/dist/module/vite/vite.js +0 -98
- package/dist/shared/uniwind.B5q8hBGv.cjs +0 -18
- package/dist/shared/uniwind.Cv73KtI-.cjs +0 -86
- package/dist/shared/uniwind.JSWK3vHl.mjs +0 -14
- package/src/metro/compileVirtual.ts +0 -85
- package/src/metro/index.ts +0 -1
- package/src/metro/injectThemes.ts +0 -23
- package/src/metro/metro-transformer.ts +0 -116
- package/src/metro/processor/index.ts +0 -1
- package/src/metro/utils/index.ts +0 -2
- package/src/types.ts +0 -23
- package/src/utils/stringifyThemes.ts +0 -1
- package/src/vite/index.d.ts +0 -9
- /package/dist/common/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/insets.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/overwrite.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/variants.js +0 -0
- /package/dist/common/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
- /package/dist/common/{css-visitor → bundler/css-visitor}/index.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/insets.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/insets.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/overwrite.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/overwrite.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/themes.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/variants.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/variants.js +0 -0
- /package/dist/module/{utils/buildDtsFile.d.ts → bundler/artifacts/dts.d.ts} +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/index.d.ts +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/index.js +0 -0
- /package/{dist/common → src/bundler/adapters}/vite/index.d.ts +0 -0
- /package/src/{vite → bundler/adapters/vite}/index.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/insets.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/overwrite.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/variants.ts +0 -0
- /package/src/{metro/utils/common.ts → bundler/css-processor/utils.ts} +0 -0
- /package/src/{css-visitor → bundler/css-visitor}/index.ts +0 -0
- /package/src/{metro → bundler}/logger.ts +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export class Var {
|
|
2
|
+
constructor(Processor) {
|
|
3
|
+
this.Processor = Processor;
|
|
4
|
+
}
|
|
5
|
+
processVar(variable) {
|
|
6
|
+
const value = `this[\`${variable.name.ident}\`]`;
|
|
7
|
+
if (!variable.fallback || variable.fallback.length === 0) {
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
const fallback = this.Processor.CSS.processValue(variable.fallback);
|
|
11
|
+
return `${value} ?? ${fallback}`;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Function as LightningCSSFunction, TokenOrValue } from 'lightningcss';
|
|
1
|
+
import type { Function as LightningCSSFunction, TokenOrValue } from 'lightningcss';
|
|
2
2
|
export declare class FunctionVisitor {
|
|
3
3
|
[name: string]: (fn: LightningCSSFunction) => TokenOrValue;
|
|
4
4
|
platformSelect(fn: LightningCSSFunction): TokenOrValue;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { ReturnedDeclaration, ReturnedMediaQuery, ReturnedRule, Rule } from 'lightningcss';
|
|
1
|
+
import type { ReturnedDeclaration, ReturnedMediaQuery, ReturnedRule, Rule } from 'lightningcss';
|
|
2
|
+
import type { UniwindBundlerConfig } from '../config';
|
|
2
3
|
type LightningRuleVisitor = Rule<ReturnedDeclaration, ReturnedMediaQuery>;
|
|
3
4
|
type LightningRuleVisitors = Partial<{
|
|
4
5
|
[K in LightningRuleVisitor['type']]: (rule: Extract<LightningRuleVisitor, {
|
|
@@ -6,11 +7,11 @@ type LightningRuleVisitors = Partial<{
|
|
|
6
7
|
}>) => ReturnedRule | Array<ReturnedRule> | void;
|
|
7
8
|
}>;
|
|
8
9
|
export declare class RuleVisitor implements LightningRuleVisitors {
|
|
9
|
-
private readonly
|
|
10
|
+
private readonly bundlerConfig;
|
|
10
11
|
processedClassNames: Set<string>;
|
|
11
12
|
processedVariables: Set<string>;
|
|
12
13
|
currentLayerName: string;
|
|
13
|
-
constructor(
|
|
14
|
+
constructor(bundlerConfig: UniwindBundlerConfig);
|
|
14
15
|
'layer-block': (layer: Extract<LightningRuleVisitor, {
|
|
15
16
|
type: "layer-block";
|
|
16
17
|
}>) => void;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export class RuleVisitor {
|
|
2
|
-
constructor(
|
|
3
|
-
this.
|
|
2
|
+
constructor(bundlerConfig) {
|
|
3
|
+
this.bundlerConfig = bundlerConfig;
|
|
4
4
|
}
|
|
5
5
|
processedClassNames = /* @__PURE__ */ new Set();
|
|
6
6
|
processedVariables = /* @__PURE__ */ new Set();
|
|
@@ -60,7 +60,7 @@ export class RuleVisitor {
|
|
|
60
60
|
if (whereSelector?.type !== "class") {
|
|
61
61
|
return styleRule;
|
|
62
62
|
}
|
|
63
|
-
const selectedVariant = this.themes.find((theme) => whereSelector.name === theme);
|
|
63
|
+
const selectedVariant = this.bundlerConfig.themes.find((theme) => whereSelector.name === theme);
|
|
64
64
|
if (selectedVariant === void 0 || this.processedVariables.has(selectedVariant)) {
|
|
65
65
|
return styleRule;
|
|
66
66
|
}
|
|
@@ -76,7 +76,7 @@ export class RuleVisitor {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
processClassStyle(styleRule, firstSelector) {
|
|
79
|
-
const selectedVariant = this.themes.find((theme) => firstSelector.name.includes(`${theme}:`));
|
|
79
|
+
const selectedVariant = this.bundlerConfig.themes.find((theme) => firstSelector.name.includes(`${theme}:`));
|
|
80
80
|
if (selectedVariant === void 0 || this.processedClassNames.has(firstSelector.name)) {
|
|
81
81
|
return;
|
|
82
82
|
}
|
|
@@ -87,7 +87,7 @@ export class RuleVisitor {
|
|
|
87
87
|
loc: styleRule.value.loc,
|
|
88
88
|
rules: [styleRule],
|
|
89
89
|
scopeStart: [[{ type: "class", name: selectedVariant }]],
|
|
90
|
-
scopeEnd: this.themes.filter((theme) => theme !== selectedVariant).map((theme) => [{ type: "class", name: theme }])
|
|
90
|
+
scopeEnd: this.bundlerConfig.themes.filter((theme) => theme !== selectedVariant).map((theme) => [{ type: "class", name: theme }])
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
93
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { CustomAtRules, Visitor } from 'lightningcss';
|
|
1
|
+
import type { CustomAtRules, Visitor } from 'lightningcss';
|
|
2
|
+
import type { UniwindBundlerConfig } from '../config';
|
|
2
3
|
export declare class UniwindCSSVisitor implements Visitor<CustomAtRules> {
|
|
3
|
-
private readonly themes;
|
|
4
4
|
Function: Visitor<CustomAtRules>['Function'];
|
|
5
5
|
Rule: Visitor<CustomAtRules>['Rule'];
|
|
6
6
|
StyleSheet: Visitor<CustomAtRules>['StyleSheet'];
|
|
7
|
-
constructor(
|
|
7
|
+
constructor(bundlerConfig: UniwindBundlerConfig);
|
|
8
8
|
}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { FunctionVisitor } from "./function-visitor.js";
|
|
2
2
|
import { RuleVisitor } from "./rule-visitor.js";
|
|
3
3
|
export class UniwindCSSVisitor {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
Function;
|
|
5
|
+
Rule;
|
|
6
|
+
StyleSheet;
|
|
7
|
+
constructor(bundlerConfig) {
|
|
8
|
+
const ruleVisitor = new RuleVisitor(bundlerConfig);
|
|
7
9
|
this.Function = new FunctionVisitor();
|
|
8
10
|
this.Rule = ruleVisitor;
|
|
9
11
|
this.StyleSheet = () => {
|
|
10
12
|
ruleVisitor.cleanup();
|
|
11
13
|
};
|
|
12
14
|
}
|
|
13
|
-
Function;
|
|
14
|
-
Rule;
|
|
15
|
-
StyleSheet;
|
|
16
15
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Logger {
|
|
2
|
+
private readonly name;
|
|
3
|
+
static debug: boolean;
|
|
4
|
+
constructor(name: string);
|
|
5
|
+
static log(message: string, meta?: string): void;
|
|
6
|
+
static error(message: string, meta?: string): void;
|
|
7
|
+
static warn(message: string, meta?: string): void;
|
|
8
|
+
log(message: string): void;
|
|
9
|
+
error(message: string): void;
|
|
10
|
+
warn(message: string): void;
|
|
11
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
const red = "\x1B[91m";
|
|
2
|
+
const yellow = "\x1B[33m";
|
|
3
|
+
const blue = "\x1B[36m";
|
|
4
|
+
const reset = "\x1B[0m";
|
|
5
|
+
export class Logger {
|
|
6
|
+
constructor(name) {
|
|
7
|
+
this.name = name;
|
|
8
|
+
}
|
|
9
|
+
static debug = false;
|
|
10
|
+
static log(message, meta = "") {
|
|
11
|
+
if (!Logger.debug) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
console.log(`${blue}Uniwind ${meta}- ${message}${reset}`);
|
|
15
|
+
}
|
|
16
|
+
static error(message, meta = "") {
|
|
17
|
+
console.log(`${red}Uniwind Error ${meta}- ${message}${reset}`);
|
|
18
|
+
}
|
|
19
|
+
static warn(message, meta = "") {
|
|
20
|
+
if (!Logger.debug) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
console.log(`${yellow}Uniwind Warning ${meta}- ${message}${reset}`);
|
|
24
|
+
}
|
|
25
|
+
log(message) {
|
|
26
|
+
Logger.log(message, `[${this.name} Processor] `);
|
|
27
|
+
}
|
|
28
|
+
error(message) {
|
|
29
|
+
Logger.error(message, `[${this.name} Processor] `);
|
|
30
|
+
}
|
|
31
|
+
warn(message) {
|
|
32
|
+
Logger.warn(message, `[${this.name} Processor] `);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type UniwindConfig = {
|
|
2
|
+
cssEntryFile: string;
|
|
3
|
+
extraThemes?: Array<string>;
|
|
4
|
+
extraComponents?: Record<string, string>;
|
|
5
|
+
dtsFile?: string;
|
|
6
|
+
};
|
|
7
|
+
export type Polyfills = {
|
|
8
|
+
rem?: number;
|
|
9
|
+
responsive?: 'text' | 'components' | boolean;
|
|
10
|
+
};
|
|
11
|
+
export type UniwindMetroConfig = UniwindConfig & {
|
|
12
|
+
polyfills?: Polyfills;
|
|
13
|
+
debug?: boolean;
|
|
14
|
+
isTV?: boolean;
|
|
15
|
+
};
|
|
File without changes
|
|
@@ -9,3 +9,24 @@ export declare const enum Platform {
|
|
|
9
9
|
}
|
|
10
10
|
export declare const UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
11
11
|
export declare const UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
12
|
+
export declare enum StyleDependency {
|
|
13
|
+
ColorScheme = 1,
|
|
14
|
+
Theme = 2,
|
|
15
|
+
Dimensions = 3,
|
|
16
|
+
Orientation = 4,
|
|
17
|
+
Insets = 5,
|
|
18
|
+
FontScale = 6,
|
|
19
|
+
Rtl = 7,
|
|
20
|
+
AdaptiveThemes = 8,
|
|
21
|
+
Variables = 9
|
|
22
|
+
}
|
|
23
|
+
export declare const enum Orientation {
|
|
24
|
+
Portrait = "portrait",
|
|
25
|
+
Landscape = "landscape"
|
|
26
|
+
}
|
|
27
|
+
export declare const enum ColorScheme {
|
|
28
|
+
Light = "light",
|
|
29
|
+
Dark = "dark"
|
|
30
|
+
}
|
|
31
|
+
export declare const DEFAULT_SCREEN_WIDTH = 375;
|
|
32
|
+
export declare const DEFAULT_SCREEN_HEIGHT = 680;
|
|
@@ -10,3 +10,27 @@ export var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
|
10
10
|
})(Platform || {});
|
|
11
11
|
export const UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
12
12
|
export const UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
13
|
+
export var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
|
|
14
|
+
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
15
|
+
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
16
|
+
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
17
|
+
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
18
|
+
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
19
|
+
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
20
|
+
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
21
|
+
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
22
|
+
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
23
|
+
return StyleDependency2;
|
|
24
|
+
})(StyleDependency || {});
|
|
25
|
+
export var Orientation = /* @__PURE__ */ ((Orientation2) => {
|
|
26
|
+
Orientation2["Portrait"] = "portrait";
|
|
27
|
+
Orientation2["Landscape"] = "landscape";
|
|
28
|
+
return Orientation2;
|
|
29
|
+
})(Orientation || {});
|
|
30
|
+
export var ColorScheme = /* @__PURE__ */ ((ColorScheme2) => {
|
|
31
|
+
ColorScheme2["Light"] = "light";
|
|
32
|
+
ColorScheme2["Dark"] = "dark";
|
|
33
|
+
return ColorScheme2;
|
|
34
|
+
})(ColorScheme || {});
|
|
35
|
+
export const DEFAULT_SCREEN_WIDTH = 375;
|
|
36
|
+
export const DEFAULT_SCREEN_HEIGHT = 680;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TouchableHighlightProps } from 'react-native';
|
|
1
|
+
import type { TouchableHighlightProps } from 'react-native';
|
|
2
2
|
export declare const TouchableHighlight: import("react").ForwardRefExoticComponent<TouchableHighlightProps & import("react").RefAttributes<import("react-native").View>>;
|
|
3
3
|
export default TouchableHighlight;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TouchableOpacityProps } from 'react-native';
|
|
1
|
+
import type { TouchableOpacityProps } from 'react-native';
|
|
2
2
|
export declare const TouchableOpacity: import("react").ForwardRefExoticComponent<TouchableOpacityProps & import("react").RefAttributes<import("react-native").View>>;
|
|
3
3
|
export default TouchableOpacity;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { ComponentState } from '../../core/types';
|
|
1
|
+
import type { ComponentState } from '../../core/types';
|
|
2
2
|
export declare const useAccentColor: (className: string | undefined, componentProps: Record<string, any>, state?: ComponentState) => string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentType } from 'react';
|
|
2
|
-
import { ComponentState, RNStyle } from '../../core/types';
|
|
1
|
+
import { type ComponentType } from 'react';
|
|
2
|
+
import type { ComponentState, RNStyle } from '../../core/types';
|
|
3
3
|
export declare function useStyle(className?: string, componentProps?: Record<string, any>, state?: ComponentState): RNStyle;
|
|
4
4
|
export declare function useStyle<T extends React.ComponentType<any>>(component: T, className?: string, componentProps?: Record<string, any>, state?: ComponentState): {
|
|
5
5
|
style: RNStyle;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BaseButtonProps } from 'react-native-gesture-handler';
|
|
1
|
+
import { type BaseButtonProps } from 'react-native-gesture-handler';
|
|
2
2
|
export declare const BaseButton: import("react").ForwardRefExoticComponent<Omit<BaseButtonProps, "innerRef"> & import("react").RefAttributes<import("react").ComponentType<{}>>>;
|
|
3
3
|
export default BaseButton;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { BorderlessButtonProps } from 'react-native-gesture-handler';
|
|
1
|
+
import { type BorderlessButtonProps } from 'react-native-gesture-handler';
|
|
2
2
|
export declare const BorderlessButton: import("react").ForwardRefExoticComponent<Omit<BorderlessButtonProps, "innerRef"> & import("react").RefAttributes<import("react").ComponentType<{}>>>;
|
|
3
3
|
export default BorderlessButton;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DrawerLayoutAndroidProps } from 'react-native';
|
|
1
|
+
import type { DrawerLayoutAndroidProps } from 'react-native';
|
|
2
2
|
export declare const DrawerLayoutAndroid: import("react").ForwardRefExoticComponent<DrawerLayoutAndroidProps & {
|
|
3
3
|
children?: React.ReactNode | undefined;
|
|
4
4
|
} & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FlatListProps } from 'react-native';
|
|
1
|
+
import type { FlatListProps } from 'react-native';
|
|
2
2
|
import { FlatList as RNGHFlatList } from 'react-native-gesture-handler';
|
|
3
3
|
export declare const FlatList: <ItemT = any>(props: import("react").PropsWithChildren<Omit<FlatListProps<ItemT>, "renderScrollComponent"> & import("react").RefAttributes<RNGHFlatList<ItemT>> & import("react-native-gesture-handler").NativeViewGestureHandlerProps>, ref?: import("react").ForwardedRef<RNGHFlatList<ItemT>>) => import("react").ReactElement | null;
|
|
4
4
|
export default FlatList;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RawButtonProps } from 'react-native-gesture-handler';
|
|
1
|
+
import { type RawButtonProps } from 'react-native-gesture-handler';
|
|
2
2
|
export declare const RawButton: import("react").ForwardRefExoticComponent<RawButtonProps & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>>;
|
|
3
3
|
export default RawButton;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RectButtonProps } from 'react-native-gesture-handler';
|
|
1
|
+
import { type RectButtonProps } from 'react-native-gesture-handler';
|
|
2
2
|
export declare const RectButton: import("react").ForwardRefExoticComponent<Omit<RectButtonProps, "innerRef"> & import("react").RefAttributes<import("react").ComponentType<{}>>>;
|
|
3
3
|
export default RectButton;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RefreshControlProps } from 'react-native';
|
|
1
|
+
import type { RefreshControlProps } from 'react-native';
|
|
2
2
|
export declare const RefreshControl: import("react").ForwardRefExoticComponent<RefreshControlProps & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>>;
|
|
3
3
|
export default RefreshControl;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { ScrollViewProps } from 'react-native';
|
|
1
|
+
import type { ScrollViewProps } from 'react-native';
|
|
2
2
|
export declare const ScrollView: import("react").ForwardRefExoticComponent<ScrollViewProps & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react-native").ScrollView>>;
|
|
3
3
|
export default ScrollView;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SwitchProps } from 'react-native';
|
|
1
|
+
import type { SwitchProps } from 'react-native';
|
|
2
2
|
export declare const Switch: import("react").ForwardRefExoticComponent<SwitchProps & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>>;
|
|
3
3
|
export default Switch;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TextInputProps } from 'react-native';
|
|
1
|
+
import type { TextInputProps } from 'react-native';
|
|
2
2
|
export declare const TextInput: import("react").ForwardRefExoticComponent<TextInputProps & import("react-native-gesture-handler").NativeViewGestureHandlerProps & import("react").RefAttributes<import("react").ComponentType<any>>>;
|
|
3
3
|
export default TextInput;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { PressableProps } from 'react-native';
|
|
1
|
+
import type { PressableProps } from 'react-native';
|
|
2
2
|
export declare const Pressable: import("react").ForwardRefExoticComponent<PressableProps & import("react").RefAttributes<import("react-native").View>>;
|
|
3
3
|
export default Pressable;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TouchableHighlightProps } from 'react-native';
|
|
1
|
+
import type { TouchableHighlightProps } from 'react-native';
|
|
2
2
|
export declare const TouchableHighlight: import("react").ForwardRefExoticComponent<TouchableHighlightProps & import("react").RefAttributes<import("react-native").View>>;
|
|
3
3
|
export default TouchableHighlight;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { TouchableOpacityProps } from 'react-native';
|
|
1
|
+
import type { TouchableOpacityProps } from 'react-native';
|
|
2
2
|
export declare const TouchableOpacity: import("react").ForwardRefExoticComponent<TouchableOpacityProps & import("react").RefAttributes<import("react-native").View>>;
|
|
3
3
|
export default TouchableOpacity;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import { StyleDependency } from "../../common/consts.js";
|
|
1
2
|
import { Uniwind } from "../../core/index.js";
|
|
2
3
|
import { UniwindListener } from "../../core/listener.js";
|
|
3
|
-
import { StyleDependency } from "../../types.js";
|
|
4
4
|
import "./metro-injected";
|
|
5
5
|
const addClassNameToRoot = () => {
|
|
6
6
|
if (typeof document === "undefined") {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
1
|
+
import type { Insets } from 'react-native';
|
|
2
|
+
import type { ApplyUniwind } from '../../hoc/types';
|
|
3
|
+
import type { GetCSSVariable } from '../../hooks/useCSSVariable/useCSSVariable';
|
|
4
|
+
import type { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
6
5
|
declare const SYSTEM_THEME: "system";
|
|
7
6
|
export declare class UniwindConfigBuilder {
|
|
8
7
|
#private;
|
|
@@ -12,9 +11,9 @@ export declare class UniwindConfigBuilder {
|
|
|
12
11
|
get hasAdaptiveThemes(): boolean;
|
|
13
12
|
get currentTheme(): ThemeName;
|
|
14
13
|
private get colorScheme();
|
|
15
|
-
Wrapper<T extends ElementType>({ as, ...props }: {
|
|
14
|
+
Wrapper<T extends React.ElementType>({ as, ...props }: {
|
|
16
15
|
as: T;
|
|
17
|
-
} & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>): import("react").FunctionComponentElement<any>;
|
|
16
|
+
} & ApplyUniwind<Omit<React.ComponentPropsWithRef<T>, 'as'>>): import("react").FunctionComponentElement<any>;
|
|
18
17
|
setTheme(theme: ThemeName | typeof SYSTEM_THEME): void;
|
|
19
18
|
updateCSSVariables(theme: ThemeName, cssVariables: CSSVariables): void;
|
|
20
19
|
updateInsets(insets: Insets): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { createElement, useMemo } from "react";
|
|
2
2
|
import { Appearance, Platform } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { ColorScheme, StyleDependency } from "../../common/consts.js";
|
|
4
|
+
import { withUniwind } from "../../hoc/index.js";
|
|
4
5
|
import { getCSSVariable } from "../../hooks/useCSSVariable/useCSSVariable.js";
|
|
5
|
-
import { ColorScheme, StyleDependency } from "../../types.js";
|
|
6
6
|
import { UniwindListener } from "../listener.js";
|
|
7
7
|
const SYSTEM_THEME = "system";
|
|
8
8
|
const RN_VERSION = Platform.constants?.reactNativeVersion?.minor ?? 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
1
|
+
import type { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
2
2
|
import { UniwindConfigBuilder as UniwindConfigBuilderBase } from './config.common';
|
|
3
3
|
declare class UniwindConfigBuilder extends UniwindConfigBuilderBase {
|
|
4
4
|
private cssRules?;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { StyleDependency } from "../../common/consts.js";
|
|
1
2
|
import { arrayEquals } from "../../common/utils.js";
|
|
2
|
-
import { StyleDependency } from "../../types.js";
|
|
3
3
|
import { UniwindListener } from "../listener.js";
|
|
4
4
|
import { Logger } from "../logger.js";
|
|
5
5
|
import { getWebVariable } from "../web/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Insets } from 'react-native';
|
|
2
|
-
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
1
|
+
import type { Insets } from 'react-native';
|
|
2
|
+
import type { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types';
|
|
3
3
|
import { UniwindConfigBuilder as UniwindConfigBuilderBase } from './config.common';
|
|
4
4
|
declare class UniwindConfigBuilder extends UniwindConfigBuilderBase {
|
|
5
5
|
constructor();
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { formatHex, formatHex8, parse } from "culori";
|
|
2
|
-
import { StyleDependency } from "../../
|
|
2
|
+
import { StyleDependency } from "../../common/consts.js";
|
|
3
3
|
import { UniwindListener } from "../listener.js";
|
|
4
4
|
import { Logger } from "../logger.js";
|
|
5
5
|
import { UniwindStore } from "../native/index.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Appearance, Dimensions, I18nManager, PixelRatio, Platform, StyleSheet } from "react-native";
|
|
2
2
|
import { cubicBezier, linear, steps } from "react-native-reanimated";
|
|
3
3
|
import { initialWindowMetrics } from "react-native-safe-area-context";
|
|
4
|
-
import { ColorScheme, Orientation } from "../../
|
|
4
|
+
import { ColorScheme, DEFAULT_SCREEN_WIDTH, Orientation } from "../../common/consts.js";
|
|
5
5
|
import { colorMix, lightDark, parseColor } from "./native-utils.js";
|
|
6
6
|
const window = Dimensions.get("window");
|
|
7
7
|
const initialColorScheme = Appearance.getColorScheme() ?? ColorScheme.Light;
|
|
@@ -26,6 +26,10 @@ export const UniwindRuntime = {
|
|
|
26
26
|
parseColor,
|
|
27
27
|
platformSelect: (android, ios, other) => {
|
|
28
28
|
return Platform.select(Boolean(other) ? { android, ios, default: other } : { android, default: ios });
|
|
29
|
+
},
|
|
30
|
+
makeResponsive(value, base = DEFAULT_SCREEN_WIDTH, useHeight = false) {
|
|
31
|
+
const dimension = useHeight ? this.screen.height : this.screen.width;
|
|
32
|
+
return Math.round(value * dimension / base);
|
|
29
33
|
}
|
|
30
34
|
};
|
|
31
35
|
UniwindRuntime.lightDark = lightDark.bind(UniwindRuntime);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { StyleDependency } from '../../
|
|
2
|
-
import { ComponentState, GenerateStyleSheetsCallback, RNStyle, ThemeName, UniwindContextType } from '../types';
|
|
1
|
+
import { StyleDependency } from '../../common/consts';
|
|
2
|
+
import type { ComponentState, GenerateStyleSheetsCallback, RNStyle, ThemeName, UniwindContextType } from '../types';
|
|
3
3
|
type StylesResult = {
|
|
4
4
|
styles: RNStyle;
|
|
5
5
|
dependencies: Array<StyleDependency>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Dimensions, Platform } from "react-native";
|
|
2
|
-
import { Platform as UniwindPlatform, UNIWIND_PLATFORM_VARIABLES, UNIWIND_THEME_VARIABLES } from "../../common/consts.js";
|
|
3
|
-
import { Orientation, StyleDependency } from "../../types.js";
|
|
2
|
+
import { Orientation, Platform as UniwindPlatform, StyleDependency, UNIWIND_PLATFORM_VARIABLES, UNIWIND_THEME_VARIABLES } from "../../common/consts.js";
|
|
4
3
|
import { UniwindListener } from "../listener.js";
|
|
5
4
|
import { cloneWithAccessors } from "./native-utils.js";
|
|
6
5
|
import {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ImageStyle, StyleProp, TextStyle, ViewStyle } from 'react-native';
|
|
3
|
-
import { CSSAnimationKeyframes } from 'react-native-reanimated';
|
|
4
|
-
import { ControlPoint, CubicBezierEasing, LinearEasing, StepsEasing, StepsModifier } from 'react-native-reanimated/lib/typescript/css/easing';
|
|
5
|
-
import { ColorScheme, Orientation, StyleDependency
|
|
3
|
+
import type { CSSAnimationKeyframes } from 'react-native-reanimated';
|
|
4
|
+
import type { ControlPoint, CubicBezierEasing, LinearEasing, StepsEasing, StepsModifier } from 'react-native-reanimated/lib/typescript/css/easing';
|
|
5
|
+
import type { ColorScheme, Orientation, StyleDependency } from '../common/consts';
|
|
6
6
|
import type { UniwindContext } from './context';
|
|
7
7
|
export type Style = {
|
|
8
8
|
entries: Array<[string, () => unknown]>;
|
|
@@ -29,6 +29,8 @@ export type GenerateStyleSheetsCallback = (rt: UniwindRuntime) => {
|
|
|
29
29
|
keyframes: Record<string, CSSAnimationKeyframes>;
|
|
30
30
|
scopedVars: Partial<Record<string, Record<string, unknown>>>;
|
|
31
31
|
};
|
|
32
|
+
export interface UniwindConfig {
|
|
33
|
+
}
|
|
32
34
|
type UserThemes = UniwindConfig extends {
|
|
33
35
|
themes: infer T extends readonly string[];
|
|
34
36
|
} ? T : readonly string[];
|
|
@@ -58,6 +60,7 @@ export type UniwindRuntime = {
|
|
|
58
60
|
lightDark: (light: string, dark: string) => string;
|
|
59
61
|
parseColor: (type: string, color: string) => string;
|
|
60
62
|
platformSelect: (android: string, ios: string, other?: string) => string;
|
|
63
|
+
makeResponsive: (value: number, base: number, useHeight?: boolean) => number;
|
|
61
64
|
};
|
|
62
65
|
export type RNStyle = ViewStyle & TextStyle & ImageStyle & {
|
|
63
66
|
accentColor?: string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { RNStyle, UniwindContextType } from '../types';
|
|
1
|
+
import type { RNStyle, UniwindContextType } from '../types';
|
|
2
2
|
export declare const getWebStyles: (className: string | undefined, componentProps: Record<string, unknown> | undefined, uniwindContext: UniwindContextType) => RNStyle;
|
|
3
3
|
export declare const getWebVariable: (name: string, uniwindContext: UniwindContextType) => string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentProps, ComponentPropsWithRef } from 'react';
|
|
2
|
-
import { RNStyle } from '../core/types';
|
|
1
|
+
import type { ComponentProps, ComponentPropsWithRef } from 'react';
|
|
2
|
+
import type { RNStyle } from '../core/types';
|
|
3
3
|
export type AnyObject = Record<PropertyKey, any>;
|
|
4
4
|
type StyleToClass<K extends PropertyKey> = K extends 'style' ? 'className' : K extends `${infer StyleProp}Style` ? `${StyleProp}ClassName` : never;
|
|
5
5
|
type ColorPropToClass<K extends PropertyKey> = K extends 'color' ? 'colorClassName' : K extends `${string}Color` | `${string}color${string}` ? `${K}ClassName` : never;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { WithUniwind } from './types';
|
|
1
|
+
import type { WithUniwind } from './types';
|
|
2
2
|
export declare const withUniwind: WithUniwind;
|
|
@@ -7,8 +7,8 @@ import { Logger } from "../core/logger.js";
|
|
|
7
7
|
import { CSSListener, formatColor, getWebStyles } from "../core/web/index.js";
|
|
8
8
|
import { classToColor, classToStyle, isClassProperty, isColorClassProperty, isStyleProperty } from "./withUniwindUtils.js";
|
|
9
9
|
let warnedOnce = false;
|
|
10
|
-
export const withUniwind = (
|
|
11
|
-
const withAutoUniwind = (
|
|
10
|
+
export const withUniwind = (Component, options) => options ? withManualUniwind(Component, options) : withAutoUniwind(Component);
|
|
11
|
+
const withAutoUniwind = (Component) => (props) => {
|
|
12
12
|
const uniwindContext = useUniwindContext();
|
|
13
13
|
const { classNames, generatedProps } = Object.entries(props).reduce((acc, [propName, propValue]) => {
|
|
14
14
|
if (isColorClassProperty(propName)) {
|
|
@@ -47,7 +47,7 @@ const withAutoUniwind = (Component2) => (props) => {
|
|
|
47
47
|
return dispose;
|
|
48
48
|
}, [classNames]);
|
|
49
49
|
return /* @__PURE__ */ jsx(
|
|
50
|
-
|
|
50
|
+
Component,
|
|
51
51
|
{
|
|
52
52
|
...props,
|
|
53
53
|
...generatedProps,
|
|
@@ -55,7 +55,7 @@ const withAutoUniwind = (Component2) => (props) => {
|
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
};
|
|
58
|
-
const withManualUniwind = (
|
|
58
|
+
const withManualUniwind = (Component, options) => (props) => {
|
|
59
59
|
const uniwindContext = useUniwindContext();
|
|
60
60
|
const { generatedProps, classNames } = Object.entries(options).reduce((acc, [propName, option]) => {
|
|
61
61
|
const className = props[option.fromClassName];
|
|
@@ -81,7 +81,7 @@ const withManualUniwind = (Component2, options) => (props) => {
|
|
|
81
81
|
return dispose;
|
|
82
82
|
}, [classNames]);
|
|
83
83
|
return /* @__PURE__ */ jsx(
|
|
84
|
-
|
|
84
|
+
Component,
|
|
85
85
|
{
|
|
86
86
|
...props,
|
|
87
87
|
...generatedProps,
|