@niibase/uniwind 1.6.4 → 1.8.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 +71 -0
- package/dist/cli/index.cjs +91 -0
- package/dist/cli/index.mjs +84 -0
- package/dist/common/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/common/{css → bundler/artifacts/css}/themes.js +4 -1
- package/dist/common/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +1 -2
- package/dist/common/bundler/cli/index.js +76 -0
- package/dist/common/bundler/config.js +75 -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 +61 -0
- package/dist/common/bundler/css-processor/var.js +20 -0
- package/dist/common/{css-visitor → bundler/css-visitor}/rule-visitor.js +7 -7
- package/dist/common/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/common/bundler/logger.js +44 -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 +4 -8
- package/dist/common/core/listener.js +10 -10
- package/dist/common/core/native/native-utils.js +1 -8
- package/dist/common/core/native/parsers/textShadow.js +6 -18
- package/dist/common/core/native/parsers/transforms.js +1 -5
- package/dist/common/core/native/runtime.js +7 -3
- package/dist/common/core/native/store.js +22 -69
- 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/getVariableValue.native.js +4 -1
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +6 -2
- package/dist/common/hooks/useUniwind.js +2 -2
- package/dist/metro/index.cjs +40 -34
- package/dist/metro/index.d.ts +2 -0
- package/dist/metro/index.mjs +28 -22
- package/dist/metro/{metro-transformer.cjs → transformer.cjs} +316 -200
- package/dist/metro/{metro-transformer.mjs → transformer.mjs} +254 -138
- 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 +4 -1
- package/dist/module/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +3 -4
- package/dist/module/bundler/cli/index.d.ts +2 -0
- package/dist/module/bundler/cli/index.js +81 -0
- package/dist/module/bundler/config.d.ts +17 -0
- package/dist/module/bundler/config.js +77 -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 +23 -0
- package/dist/{shared/uniwind.PtWWxxnh.mjs → module/bundler/css-processor/utils.js} +12 -18
- 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 +7 -7
- 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 +12 -0
- package/dist/module/bundler/logger.js +37 -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 +3 -3
- 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/Text.d.ts +4 -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 +2 -6
- package/dist/module/core/listener.d.ts +1 -1
- package/dist/module/core/listener.js +1 -1
- package/dist/module/core/native/native-utils.d.ts +0 -1
- package/dist/module/core/native/native-utils.js +0 -6
- package/dist/module/core/native/parsers/textShadow.js +6 -18
- package/dist/module/core/native/parsers/transforms.js +1 -5
- package/dist/module/core/native/runtime.js +5 -1
- package/dist/module/core/native/store.d.ts +3 -3
- package/dist/module/core/native/store.js +22 -65
- package/dist/module/core/types.d.ts +12 -7
- 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/getVariableValue.native.js +4 -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.BEqYiPBB.cjs} +319 -217
- package/dist/shared/uniwind.CFAAUZ2t.mjs +3 -0
- package/dist/shared/uniwind.DJ5M1Q4q.cjs +5 -0
- package/dist/shared/{uniwind.BGiqYvxb.mjs → uniwind.DgC4MT51.mjs} +312 -214
- package/dist/vite/index.cjs +82 -59
- package/dist/vite/index.mjs +80 -58
- package/package.json +37 -21
- package/src/{metro → bundler/adapters/metro}/index.d.ts +2 -0
- package/src/bundler/adapters/metro/index.ts +1 -0
- package/src/bundler/adapters/metro/metro.ts +67 -0
- package/src/{metro/metro-css-patches.ts → bundler/adapters/metro/patches.ts} +3 -2
- package/src/{metro → bundler/adapters/metro}/resolvers.ts +8 -8
- package/src/bundler/adapters/metro/transformer.ts +85 -0
- package/src/bundler/adapters/vite/vite.ts +148 -0
- 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 +7 -2
- package/src/{utils/buildDtsFile.ts → bundler/artifacts/dts.ts} +3 -4
- package/src/bundler/cli/index.ts +105 -0
- package/src/bundler/config.ts +94 -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 +36 -17
- package/src/{metro/processor → bundler/css-processor}/animation.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/color.ts +5 -4
- package/src/{metro/processor → bundler/css-processor}/css.ts +19 -11
- 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 +20 -18
- 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 +2 -2
- package/src/{metro/utils/common.ts → bundler/css-processor/utils.ts} +2 -5
- package/src/{metro/processor → bundler/css-processor}/var.ts +2 -2
- package/src/{css-visitor → bundler/css-visitor}/function-visitor.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/rule-visitor.ts +8 -7
- package/src/{css-visitor → bundler/css-visitor}/visitor.ts +4 -3
- package/src/{metro → bundler}/logger.ts +4 -0
- 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 +4 -8
- package/src/core/config/config.ts +2 -2
- package/src/core/listener.ts +1 -1
- package/src/core/native/native-utils.ts +0 -9
- package/src/core/native/parsers/textShadow.ts +6 -18
- package/src/core/native/parsers/transforms.ts +1 -5
- package/src/core/native/runtime.ts +6 -1
- package/src/core/native/store.ts +26 -69
- package/src/core/types.ts +13 -7
- 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 +6 -3
- 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/metro/withUniwindConfig.ts +0 -61
- package/src/types.ts +0 -23
- package/src/utils/stringifyThemes.ts +0 -1
- package/src/vite/index.d.ts +0 -9
- package/src/vite/vite.ts +0 -113
- /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/{css-visitor → bundler/css-visitor}/index.ts +0 -0
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
1
|
+
import { createElement, useMemo } from 'react'
|
|
2
|
+
import type { Insets } from 'react-native'
|
|
3
|
+
import { Appearance, Platform } from 'react-native'
|
|
4
|
+
import { ColorScheme, StyleDependency } from '../../common/consts'
|
|
5
|
+
import { withUniwind } from '../../hoc'
|
|
6
|
+
import type { ApplyUniwind } from '../../hoc/types'
|
|
7
|
+
import type { GetCSSVariable } from '../../hooks/useCSSVariable/useCSSVariable'
|
|
8
|
+
import { getCSSVariable } from '../../hooks/useCSSVariable/useCSSVariable'
|
|
7
9
|
import { UniwindListener } from '../listener'
|
|
8
|
-
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
10
|
+
import type { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
9
11
|
|
|
10
12
|
const SYSTEM_THEME = 'system' as const
|
|
11
13
|
// Platform.constants is not defined in RNW
|
|
@@ -54,9 +56,9 @@ export class UniwindConfigBuilder {
|
|
|
54
56
|
return colorScheme ?? ColorScheme.Light
|
|
55
57
|
}
|
|
56
58
|
|
|
57
|
-
Wrapper<T extends ElementType>({ as, ...props }: {
|
|
59
|
+
Wrapper<T extends React.ElementType>({ as, ...props }: {
|
|
58
60
|
as: T
|
|
59
|
-
} & ApplyUniwind<Omit<ComponentPropsWithRef<T>, 'as'>>) {
|
|
61
|
+
} & ApplyUniwind<Omit<React.ComponentPropsWithRef<T>, 'as'>>) {
|
|
60
62
|
const StyledComponent = useMemo(() => withUniwind(as as any), [as])
|
|
61
63
|
return createElement(StyledComponent, props)
|
|
62
64
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { formatHex, formatHex8, parse } from 'culori'
|
|
2
|
-
import { Insets } from 'react-native'
|
|
3
|
-
import { StyleDependency } from '../../
|
|
2
|
+
import type { Insets } from 'react-native'
|
|
3
|
+
import { StyleDependency } from '../../common/consts'
|
|
4
4
|
import { UniwindListener } from '../listener'
|
|
5
5
|
import { Logger } from '../logger'
|
|
6
6
|
import { UniwindStore } from '../native'
|
|
7
|
-
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
7
|
+
import type { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
8
8
|
import { UniwindConfigBuilder as UniwindConfigBuilderBase } from './config.common'
|
|
9
9
|
|
|
10
10
|
class UniwindConfigBuilder extends UniwindConfigBuilderBase {
|
|
@@ -37,11 +37,7 @@ class UniwindConfigBuilder extends UniwindConfigBuilderBase {
|
|
|
37
37
|
}
|
|
38
38
|
|
|
39
39
|
UniwindStore.vars[theme] ??= {}
|
|
40
|
-
|
|
41
|
-
configurable: true,
|
|
42
|
-
enumerable: true,
|
|
43
|
-
get: getValue,
|
|
44
|
-
})
|
|
40
|
+
UniwindStore.vars[theme][varName] = getValue
|
|
45
41
|
})
|
|
46
42
|
|
|
47
43
|
UniwindListener.notify([StyleDependency.Variables])
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { StyleDependency } from '../../common/consts'
|
|
1
2
|
import { arrayEquals } from '../../common/utils'
|
|
2
|
-
import { StyleDependency } from '../../types'
|
|
3
3
|
import { UniwindListener } from '../listener'
|
|
4
4
|
import { Logger } from '../logger'
|
|
5
|
-
import { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
5
|
+
import type { CSSVariables, GenerateStyleSheetsCallback, ThemeName } from '../types'
|
|
6
6
|
import { getWebVariable } from '../web'
|
|
7
7
|
import { UniwindConfigBuilder as UniwindConfigBuilderBase } from './config.common'
|
|
8
8
|
|
package/src/core/listener.ts
CHANGED
|
@@ -31,15 +31,6 @@ export function lightDark(this: UniwindRuntime, light: string, dark: string) {
|
|
|
31
31
|
return light
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
export const cloneWithAccessors = <T extends object>(obj: T) => {
|
|
35
|
-
const proto = Object.getPrototypeOf(obj)
|
|
36
|
-
const clone = Object.create(proto)
|
|
37
|
-
|
|
38
|
-
Object.defineProperties(clone, Object.getOwnPropertyDescriptors(obj))
|
|
39
|
-
|
|
40
|
-
return clone
|
|
41
|
-
}
|
|
42
|
-
|
|
43
34
|
export const parseColor = (type: string, color: string) => {
|
|
44
35
|
try {
|
|
45
36
|
const parsedColor = parse(`${type}(${color})`)
|
|
@@ -10,28 +10,16 @@ export const parseTextShadowMutation = (styles: Record<string, any>) => {
|
|
|
10
10
|
const [offsetX, offsetY, radius] = offsets
|
|
11
11
|
|
|
12
12
|
if (offsetX !== undefined && offsetY !== undefined) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
width: Number(offsetX),
|
|
18
|
-
height: Number(offsetY),
|
|
19
|
-
},
|
|
20
|
-
})
|
|
13
|
+
styles.textShadowOffset = {
|
|
14
|
+
width: Number(offsetX),
|
|
15
|
+
height: Number(offsetY),
|
|
16
|
+
}
|
|
21
17
|
delete styles.textShadow
|
|
22
18
|
}
|
|
23
19
|
|
|
24
20
|
if (radius !== undefined) {
|
|
25
|
-
|
|
26
|
-
configurable: true,
|
|
27
|
-
enumerable: true,
|
|
28
|
-
value: Number(radius),
|
|
29
|
-
})
|
|
21
|
+
styles.textShadowRadius = Number(radius)
|
|
30
22
|
}
|
|
31
23
|
|
|
32
|
-
|
|
33
|
-
configurable: true,
|
|
34
|
-
enumerable: true,
|
|
35
|
-
value: color,
|
|
36
|
-
})
|
|
24
|
+
styles.textShadowColor = color
|
|
37
25
|
}
|
|
@@ -57,10 +57,6 @@ export const parseTransformsMutation = (styles: Record<string, any>, preserve: b
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
if (transformsResult.length > 0) {
|
|
60
|
-
|
|
61
|
-
configurable: true,
|
|
62
|
-
enumerable: true,
|
|
63
|
-
value: transformsResult,
|
|
64
|
-
})
|
|
60
|
+
styles.transform = transformsResult
|
|
65
61
|
}
|
|
66
62
|
}
|
|
@@ -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'
|
|
5
5
|
import type { UniwindRuntime as UniwindRuntimeType } from '../types'
|
|
6
6
|
import { colorMix, lightDark, parseColor } from './native-utils'
|
|
7
7
|
|
|
@@ -31,6 +31,11 @@ export const UniwindRuntime = {
|
|
|
31
31
|
// eslint-disable-next-line no-extra-boolean-cast
|
|
32
32
|
return Platform.select(Boolean(other) ? { android, ios, default: other } : { android, default: ios })
|
|
33
33
|
},
|
|
34
|
+
makeResponsive(value: number, base: number = DEFAULT_SCREEN_WIDTH, useHeight: boolean = false) {
|
|
35
|
+
const dimension = useHeight ? this.screen.height : this.screen.width
|
|
36
|
+
|
|
37
|
+
return Math.round(value * dimension / base)
|
|
38
|
+
},
|
|
34
39
|
} as UniwindRuntimeType
|
|
35
40
|
|
|
36
41
|
UniwindRuntime.lightDark = lightDark.bind(UniwindRuntime)
|
package/src/core/native/store.ts
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Dimensions, Platform } from 'react-native'
|
|
2
|
-
import { CSSAnimationKeyframes } from 'react-native-reanimated'
|
|
3
|
-
import { Platform as UniwindPlatform, UNIWIND_PLATFORM_VARIABLES, UNIWIND_THEME_VARIABLES } from '../../common/consts'
|
|
4
|
-
import { Orientation, StyleDependency } from '../../types'
|
|
2
|
+
import type { CSSAnimationKeyframes } from 'react-native-reanimated'
|
|
3
|
+
import { Orientation, Platform as UniwindPlatform, StyleDependency, UNIWIND_PLATFORM_VARIABLES, UNIWIND_THEME_VARIABLES } from '../../common/consts'
|
|
5
4
|
import { UniwindListener } from '../listener'
|
|
6
|
-
import { ComponentState, GenerateStyleSheetsCallback, RNStyle, Style, StyleSheets, ThemeName, UniwindContextType } from '../types'
|
|
7
|
-
import { cloneWithAccessors } from './native-utils'
|
|
5
|
+
import type { ComponentState, GenerateStyleSheetsCallback, RNStyle, Style, StyleSheets, ThemeName, UniwindContextType, Var, Vars } from '../types'
|
|
8
6
|
import {
|
|
9
7
|
parseBoxShadow,
|
|
10
8
|
parseFontVariant,
|
|
@@ -25,8 +23,7 @@ const emptyState: StylesResult = { styles: {}, dependencies: [], dependencySum:
|
|
|
25
23
|
|
|
26
24
|
class UniwindStoreBuilder {
|
|
27
25
|
runtime = UniwindRuntime
|
|
28
|
-
vars = {} as Record<ThemeName,
|
|
29
|
-
|
|
26
|
+
vars = {} as Record<ThemeName, Vars>
|
|
30
27
|
private stylesheet = {} as StyleSheets
|
|
31
28
|
private keyframes = {} as Record<string, CSSAnimationKeyframes>
|
|
32
29
|
private cache = {} as Record<ThemeName, Map<string, StylesResult>>
|
|
@@ -73,21 +70,21 @@ class UniwindStoreBuilder {
|
|
|
73
70
|
const platformVars = scopedVars[`${UNIWIND_PLATFORM_VARIABLES}${platform}`]
|
|
74
71
|
|
|
75
72
|
if (commonPlatformVars) {
|
|
76
|
-
Object.
|
|
73
|
+
Object.assign(vars, commonPlatformVars)
|
|
77
74
|
}
|
|
78
75
|
|
|
79
76
|
if (platformVars) {
|
|
80
|
-
Object.
|
|
77
|
+
Object.assign(vars, platformVars)
|
|
81
78
|
}
|
|
82
79
|
|
|
83
80
|
this.keyframes = keyframes
|
|
84
81
|
this.stylesheet = stylesheet
|
|
85
82
|
this.vars = Object.fromEntries(themes.map(theme => {
|
|
86
|
-
const clonedVars =
|
|
83
|
+
const clonedVars = Object.create(vars) as Vars
|
|
87
84
|
const themeVars = scopedVars[`${UNIWIND_THEME_VARIABLES}${theme}`]
|
|
88
85
|
|
|
89
86
|
if (themeVars) {
|
|
90
|
-
Object.
|
|
87
|
+
Object.assign(clonedVars, themeVars)
|
|
91
88
|
}
|
|
92
89
|
|
|
93
90
|
return [theme, clonedVars]
|
|
@@ -105,7 +102,7 @@ class UniwindStoreBuilder {
|
|
|
105
102
|
state: ComponentState | undefined,
|
|
106
103
|
uniwindContext: UniwindContextType,
|
|
107
104
|
) {
|
|
108
|
-
const
|
|
105
|
+
const resultGetters = {} as Record<string, Var>
|
|
109
106
|
const theme = uniwindContext.scopedTheme ?? this.runtime.currentThemeName
|
|
110
107
|
// At this point we're sure that theme is correct
|
|
111
108
|
let vars = this.vars[theme]!
|
|
@@ -168,20 +165,12 @@ class UniwindStoreBuilder {
|
|
|
168
165
|
if (property[0] === '-') {
|
|
169
166
|
// Clone vars object if we are adding inline variables
|
|
170
167
|
if (vars === originalVars) {
|
|
171
|
-
vars =
|
|
168
|
+
vars = Object.create(originalVars)
|
|
172
169
|
}
|
|
173
170
|
|
|
174
|
-
|
|
175
|
-
configurable: true,
|
|
176
|
-
enumerable: true,
|
|
177
|
-
get: valueGetter,
|
|
178
|
-
})
|
|
171
|
+
vars[property] = valueGetter
|
|
179
172
|
} else {
|
|
180
|
-
|
|
181
|
-
configurable: true,
|
|
182
|
-
enumerable: true,
|
|
183
|
-
get: () => valueGetter.call(vars),
|
|
184
|
-
})
|
|
173
|
+
resultGetters[property] = valueGetter
|
|
185
174
|
}
|
|
186
175
|
|
|
187
176
|
bestBreakpoints.set(property, style)
|
|
@@ -189,81 +178,49 @@ class UniwindStoreBuilder {
|
|
|
189
178
|
}
|
|
190
179
|
}
|
|
191
180
|
|
|
181
|
+
const result = Object.fromEntries(
|
|
182
|
+
Object.entries(resultGetters).map(([property, valueGetter]) => [property, valueGetter(vars)]),
|
|
183
|
+
) as Record<string, any>
|
|
184
|
+
|
|
192
185
|
if (result.lineHeight !== undefined && result.lineHeight < 6) {
|
|
193
|
-
|
|
194
|
-
value: result.fontSize * result.lineHeight,
|
|
195
|
-
configurable: true,
|
|
196
|
-
enumerable: true,
|
|
197
|
-
})
|
|
186
|
+
result.lineHeight *= result.fontSize
|
|
198
187
|
}
|
|
199
188
|
|
|
200
189
|
if (result.boxShadow !== undefined) {
|
|
201
|
-
|
|
202
|
-
value: parseBoxShadow(result.boxShadow),
|
|
203
|
-
configurable: true,
|
|
204
|
-
enumerable: true,
|
|
205
|
-
})
|
|
190
|
+
result.boxShadow = parseBoxShadow(result.boxShadow)
|
|
206
191
|
}
|
|
207
192
|
|
|
208
193
|
if (result.visibility === 'hidden') {
|
|
209
|
-
|
|
210
|
-
value: 'none',
|
|
211
|
-
configurable: true,
|
|
212
|
-
enumerable: true,
|
|
213
|
-
})
|
|
194
|
+
result.display = 'none'
|
|
214
195
|
}
|
|
215
196
|
|
|
216
197
|
if (
|
|
217
198
|
result.borderStyle !== undefined && result.borderColor === undefined
|
|
218
199
|
) {
|
|
219
|
-
|
|
220
|
-
value: '#000000',
|
|
221
|
-
configurable: true,
|
|
222
|
-
enumerable: true,
|
|
223
|
-
})
|
|
200
|
+
result.borderColor = '#000000'
|
|
224
201
|
}
|
|
225
202
|
|
|
226
203
|
if (
|
|
227
204
|
result.outlineStyle !== undefined && result.outlineColor === undefined
|
|
228
205
|
) {
|
|
229
|
-
|
|
230
|
-
value: '#000000',
|
|
231
|
-
configurable: true,
|
|
232
|
-
enumerable: true,
|
|
233
|
-
})
|
|
206
|
+
result.outlineColor = '#000000'
|
|
234
207
|
}
|
|
235
208
|
|
|
236
209
|
if (result.fontVariant !== undefined) {
|
|
237
|
-
|
|
238
|
-
value: parseFontVariant(result.fontVariant),
|
|
239
|
-
configurable: true,
|
|
240
|
-
enumerable: true,
|
|
241
|
-
})
|
|
210
|
+
result.fontVariant = parseFontVariant(result.fontVariant)
|
|
242
211
|
}
|
|
243
212
|
|
|
244
213
|
parseTransformsMutation(result)
|
|
245
214
|
parseTransitionsMutation(result)
|
|
246
215
|
|
|
247
216
|
if (typeof result.animationName === 'string') {
|
|
248
|
-
|
|
249
|
-
value: this.keyframes[result.animationName] ?? [],
|
|
250
|
-
configurable: true,
|
|
251
|
-
enumerable: true,
|
|
252
|
-
})
|
|
217
|
+
result.animationName = this.keyframes[result.animationName] ?? []
|
|
253
218
|
} else if (Array.isArray(result.animationName)) {
|
|
254
|
-
|
|
255
|
-
value: result.animationName.map(animationName => this.keyframes[animationName] ?? undefined).filter(Boolean),
|
|
256
|
-
configurable: true,
|
|
257
|
-
enumerable: true,
|
|
258
|
-
})
|
|
219
|
+
result.animationName = result.animationName.map(animationName => this.keyframes[animationName] ?? undefined).filter(Boolean)
|
|
259
220
|
}
|
|
260
221
|
|
|
261
222
|
if (result.experimental_backgroundImage !== undefined) {
|
|
262
|
-
|
|
263
|
-
value: resolveGradient(result.experimental_backgroundImage),
|
|
264
|
-
configurable: true,
|
|
265
|
-
enumerable: true,
|
|
266
|
-
})
|
|
223
|
+
result.experimental_backgroundImage = resolveGradient(result.experimental_backgroundImage)
|
|
267
224
|
}
|
|
268
225
|
|
|
269
226
|
if (result.textShadow !== undefined) {
|
|
@@ -271,7 +228,7 @@ class UniwindStoreBuilder {
|
|
|
271
228
|
}
|
|
272
229
|
|
|
273
230
|
return {
|
|
274
|
-
styles:
|
|
231
|
+
styles: result,
|
|
275
232
|
dependencies: Array.from(dependencies),
|
|
276
233
|
dependencySum,
|
|
277
234
|
hasDataAttributes,
|
package/src/core/types.ts
CHANGED
|
@@ -1,16 +1,19 @@
|
|
|
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
|
|
|
8
|
+
export type Vars = Record<PropertyKey, Var>
|
|
9
|
+
export type Var = (vars: Vars) => unknown
|
|
10
|
+
|
|
8
11
|
export type Style = {
|
|
9
|
-
entries: Array<[string,
|
|
12
|
+
entries: Array<[string, Var]>
|
|
10
13
|
minWidth: number
|
|
11
14
|
maxWidth: number
|
|
12
15
|
orientation: Orientation | null
|
|
13
|
-
theme:
|
|
16
|
+
theme: ThemeName | null
|
|
14
17
|
rtl: boolean | null
|
|
15
18
|
native: boolean
|
|
16
19
|
dependencies: Array<StyleDependency> | null
|
|
@@ -28,11 +31,13 @@ export type StyleSheets = Record<string, Array<Style>>
|
|
|
28
31
|
|
|
29
32
|
export type GenerateStyleSheetsCallback = (rt: UniwindRuntime) => {
|
|
30
33
|
stylesheet: StyleSheets
|
|
31
|
-
vars:
|
|
34
|
+
vars: Vars
|
|
32
35
|
keyframes: Record<string, CSSAnimationKeyframes>
|
|
33
|
-
scopedVars: Partial<Record<string,
|
|
36
|
+
scopedVars: Partial<Record<string, Vars>>
|
|
34
37
|
}
|
|
35
38
|
|
|
39
|
+
export interface UniwindConfig {}
|
|
40
|
+
|
|
36
41
|
type UserThemes = UniwindConfig extends { themes: infer T extends readonly string[] } ? T
|
|
37
42
|
: readonly string[]
|
|
38
43
|
|
|
@@ -63,6 +68,7 @@ export type UniwindRuntime = {
|
|
|
63
68
|
lightDark: (light: string, dark: string) => string
|
|
64
69
|
parseColor: (type: string, color: string) => string
|
|
65
70
|
platformSelect: (android: string, ios: string, other?: string) => string
|
|
71
|
+
makeResponsive: (value: number, base: number, useHeight?: boolean) => number
|
|
66
72
|
}
|
|
67
73
|
|
|
68
74
|
export type RNStyle = ViewStyle & TextStyle & ImageStyle & {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { generateDataSet } from '../../components/web/generateDataSet'
|
|
2
|
-
import { RNStyle, UniwindContextType } from '../types'
|
|
2
|
+
import type { RNStyle, UniwindContextType } from '../types'
|
|
3
3
|
import { CSSListener } from './cssListener'
|
|
4
4
|
import { parseCSSValue } from './parseCSSValue'
|
|
5
5
|
|
package/src/hoc/types.ts
CHANGED
|
@@ -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
|
|
|
4
4
|
export type AnyObject = Record<PropertyKey, any>
|
|
5
5
|
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ComponentProps
|
|
1
|
+
import type { ComponentProps } from 'react'
|
|
2
|
+
import { useLayoutEffect, useReducer } from 'react'
|
|
3
|
+
import type { StyleDependency } from '../common/consts'
|
|
2
4
|
import { isDefined } from '../common/utils'
|
|
3
5
|
import { useUniwindContext } from '../core/context'
|
|
4
6
|
import { UniwindListener } from '../core/listener'
|
|
5
7
|
import { Logger } from '../core/logger'
|
|
6
8
|
import { UniwindStore } from '../core/native'
|
|
7
|
-
import {
|
|
8
|
-
import { AnyObject, Component, OptionMapping, WithUniwind } from './types'
|
|
9
|
+
import type { AnyObject, Component, OptionMapping, WithUniwind } from './types'
|
|
9
10
|
import { classToColor, classToStyle, isClassProperty, isColorClassProperty, isStyleProperty } from './withUniwindUtils'
|
|
10
11
|
|
|
11
12
|
let warnedOnce = false
|
package/src/hoc/withUniwind.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { ComponentProps
|
|
1
|
+
import type { ComponentProps } from 'react'
|
|
2
|
+
import { useLayoutEffect, useReducer } from 'react'
|
|
2
3
|
import { isDefined } from '../common/utils'
|
|
3
4
|
import { generateDataSet } from '../components/web/generateDataSet'
|
|
4
5
|
import { useUniwindContext } from '../core/context'
|
|
5
6
|
import { Logger } from '../core/logger'
|
|
6
7
|
import { CSSListener, formatColor, getWebStyles } from '../core/web'
|
|
7
|
-
import { AnyObject, Component, OptionMapping, WithUniwind } from './types'
|
|
8
|
+
import type { AnyObject, Component, OptionMapping, WithUniwind } from './types'
|
|
8
9
|
import { classToColor, classToStyle, isClassProperty, isColorClassProperty, isStyleProperty } from './withUniwindUtils'
|
|
9
10
|
|
|
10
11
|
let warnedOnce = false
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import { UniwindRuntime, UniwindStore } from '../../core/native'
|
|
2
|
-
import { UniwindContextType } from '../../core/types'
|
|
2
|
+
import type { UniwindContextType } from '../../core/types'
|
|
3
3
|
|
|
4
|
-
export const getVariableValue = (name: string, uniwindContext: UniwindContextType) =>
|
|
5
|
-
UniwindStore.vars[uniwindContext.scopedTheme ?? UniwindRuntime.currentThemeName]
|
|
4
|
+
export const getVariableValue = (name: string, uniwindContext: UniwindContextType) => {
|
|
5
|
+
const vars = UniwindStore.vars[uniwindContext.scopedTheme ?? UniwindRuntime.currentThemeName]
|
|
6
|
+
|
|
7
|
+
return vars?.[name]?.(vars)
|
|
8
|
+
}
|
|
@@ -1,15 +1,21 @@
|
|
|
1
1
|
import { useLayoutEffect, useRef, useState } from 'react'
|
|
2
|
+
import { Platform } from 'react-native'
|
|
3
|
+
import { StyleDependency } from '../../common/consts'
|
|
2
4
|
import { arrayEquals } from '../../common/utils'
|
|
3
5
|
import { useUniwindContext } from '../../core/context'
|
|
4
6
|
import { UniwindListener } from '../../core/listener'
|
|
5
7
|
import { Logger } from '../../core/logger'
|
|
6
|
-
import { UniwindContextType } from '../../core/types'
|
|
7
|
-
import { StyleDependency } from '../../types'
|
|
8
|
+
import type { UniwindContextType } from '../../core/types'
|
|
8
9
|
import { getVariableValue } from './getVariableValue'
|
|
9
10
|
|
|
10
11
|
let warned = false
|
|
11
12
|
|
|
12
13
|
const logDevError = (name: string) => {
|
|
14
|
+
// Silent warnings for SSR
|
|
15
|
+
if (Platform.OS === 'web' && (typeof document === 'undefined' || typeof window === 'undefined')) {
|
|
16
|
+
return
|
|
17
|
+
}
|
|
18
|
+
|
|
13
19
|
warned = true
|
|
14
20
|
Logger.warn(
|
|
15
21
|
`We couldn't find your variable ${name}. Make sure it's used at least once in your className, or define it in a static theme as described in the docs: https://docs.uniwind.dev/api/use-css-variable`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useLayoutEffect, useReducer } from 'react'
|
|
2
2
|
import { useUniwindContext } from '../core/context'
|
|
3
|
-
import { RNStyle } from '../core/types'
|
|
3
|
+
import type { RNStyle } from '../core/types'
|
|
4
4
|
import { CSSListener, getWebStyles } from '../core/web'
|
|
5
5
|
|
|
6
6
|
const emptyState = {} as RNStyle
|
package/src/hooks/useUniwind.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useLayoutEffect, useState } from 'react'
|
|
2
|
+
import { StyleDependency } from '../common/consts'
|
|
2
3
|
import { Uniwind } from '../core'
|
|
3
4
|
import { useUniwindContext } from '../core/context'
|
|
4
5
|
import { UniwindListener } from '../core/listener'
|
|
5
|
-
import { ThemeName } from '../core/types'
|
|
6
|
-
import { StyleDependency } from '../types'
|
|
6
|
+
import type { ThemeName } from '../core/types'
|
|
7
7
|
|
|
8
8
|
export const useUniwind = (): { theme: ThemeName; hasAdaptiveThemes: boolean } => {
|
|
9
9
|
const uniwindContext = useUniwindContext()
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './components/ScopedTheme'
|
|
2
2
|
export { Uniwind } from './core'
|
|
3
|
-
export type { ThemeName } from './core/types'
|
|
3
|
+
export type { ThemeName, UniwindConfig } from './core/types'
|
|
4
4
|
export { withUniwind } from './hoc'
|
|
5
5
|
export type { ApplyUniwind, ApplyUniwindOptions } from './hoc/types'
|
|
6
6
|
export { useCSSVariable, useResolveClassNames, useUniwind } from './hooks'
|
|
7
|
-
export type { UniwindConfig } from './types'
|
package/dist/common/types.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StyleDependency = exports.Orientation = exports.ColorScheme = void 0;
|
|
7
|
-
var StyleDependency = exports.StyleDependency = /* @__PURE__ */(StyleDependency2 => {
|
|
8
|
-
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
9
|
-
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
10
|
-
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
11
|
-
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
12
|
-
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
13
|
-
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
14
|
-
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
15
|
-
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
16
|
-
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
17
|
-
return StyleDependency2;
|
|
18
|
-
})(StyleDependency || {});
|
|
19
|
-
var Orientation = exports.Orientation = /* @__PURE__ */(Orientation2 => {
|
|
20
|
-
Orientation2["Portrait"] = "portrait";
|
|
21
|
-
Orientation2["Landscape"] = "landscape";
|
|
22
|
-
return Orientation2;
|
|
23
|
-
})(Orientation || {});
|
|
24
|
-
var ColorScheme = exports.ColorScheme = /* @__PURE__ */(ColorScheme2 => {
|
|
25
|
-
ColorScheme2["Light"] = "light";
|
|
26
|
-
ColorScheme2["Dark"] = "dark";
|
|
27
|
-
return ColorScheme2;
|
|
28
|
-
})(ColorScheme || {});
|