@niibase/uniwind 1.6.3 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +58 -0
- package/dist/common/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/common/{css → bundler/artifacts/css}/themes.js +1 -1
- package/dist/common/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +1 -2
- package/dist/common/bundler/config.js +69 -0
- package/dist/common/bundler/css-compiler/compileCSS.js +18 -0
- package/dist/common/bundler/css-compiler/compileNativeCSS.js +19 -0
- package/dist/common/bundler/css-compiler/compileTailwind.js +27 -0
- package/dist/common/bundler/css-compiler/compileWebCSS.js +15 -0
- package/dist/common/{vite → bundler/css-compiler}/index.js +4 -4
- package/dist/common/bundler/css-processor/addMetaToStylesTemplate.js +130 -0
- package/dist/common/bundler/css-processor/animation.js +112 -0
- package/dist/common/bundler/css-processor/color.js +66 -0
- package/dist/common/bundler/css-processor/css.js +510 -0
- package/dist/common/bundler/css-processor/functions.js +145 -0
- package/dist/common/bundler/css-processor/index.js +38 -0
- package/dist/common/bundler/css-processor/mq.js +87 -0
- package/dist/common/bundler/css-processor/processor.js +353 -0
- package/dist/common/bundler/css-processor/rn.js +356 -0
- package/dist/common/bundler/css-processor/serialize.js +86 -0
- package/dist/common/bundler/css-processor/types.js +1 -0
- package/dist/common/bundler/css-processor/units.js +55 -0
- package/dist/common/bundler/css-processor/utils.js +63 -0
- package/dist/common/bundler/css-processor/var.js +20 -0
- package/dist/common/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
- package/dist/common/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/common/bundler/logger.js +41 -0
- package/dist/common/bundler/types.js +1 -0
- package/dist/common/common/consts.js +26 -2
- package/dist/common/components/index.js +0 -3
- package/dist/common/components/web/rnw.js +2 -2
- package/dist/common/core/config/config.common.js +15 -9
- package/dist/common/core/config/config.js +2 -2
- package/dist/common/core/config/config.native.js +3 -3
- package/dist/common/core/listener.js +10 -10
- package/dist/common/core/native/runtime.js +7 -3
- package/dist/common/core/native/store.js +3 -4
- package/dist/common/core/web/cssListener.js +2 -2
- package/dist/common/hoc/withUniwind.js +5 -5
- package/dist/common/hoc/withUniwind.native.js +5 -5
- package/dist/common/hooks/useCSSVariable/index.js +7 -11
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +26 -18
- package/dist/common/hooks/useUniwind.js +2 -2
- package/dist/metro/index.cjs +14 -24
- package/dist/metro/index.d.ts +2 -0
- package/dist/metro/index.mjs +7 -17
- package/dist/metro/{metro-transformer.cjs → transformer.cjs} +306 -173
- package/dist/metro/{metro-transformer.mjs → transformer.mjs} +249 -116
- package/dist/module/{css → bundler/artifacts/css}/index.d.ts +1 -1
- package/dist/module/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/module/{css → bundler/artifacts/css}/themes.js +1 -1
- package/dist/module/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +3 -4
- package/dist/module/bundler/config.d.ts +16 -0
- package/dist/module/bundler/config.js +69 -0
- package/dist/module/bundler/css-compiler/compileCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileCSS.js +11 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.js +33 -0
- package/dist/module/bundler/css-compiler/compileTailwind.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileTailwind.js +22 -0
- package/dist/module/bundler/css-compiler/compileWebCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileWebCSS.js +8 -0
- package/dist/module/bundler/css-compiler/index.d.ts +1 -0
- package/dist/module/bundler/css-compiler/index.js +1 -0
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.d.ts +3 -0
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.js +136 -0
- package/dist/module/bundler/css-processor/animation.d.ts +6 -0
- package/dist/module/bundler/css-processor/animation.js +112 -0
- package/dist/module/bundler/css-processor/color.d.ts +12 -0
- package/dist/module/bundler/css-processor/color.js +63 -0
- package/dist/module/bundler/css-processor/css.d.ts +23 -0
- package/dist/module/bundler/css-processor/css.js +566 -0
- package/dist/module/bundler/css-processor/functions.d.ts +12 -0
- package/dist/module/bundler/css-processor/functions.js +190 -0
- package/dist/module/bundler/css-processor/index.d.ts +3 -0
- package/dist/module/bundler/css-processor/index.js +3 -0
- package/dist/module/bundler/css-processor/mq.d.ts +12 -0
- package/dist/module/bundler/css-processor/mq.js +78 -0
- package/dist/module/bundler/css-processor/processor.d.ts +36 -0
- package/dist/module/bundler/css-processor/processor.js +336 -0
- package/dist/module/bundler/css-processor/rn.d.ts +10 -0
- package/dist/module/bundler/css-processor/rn.js +400 -0
- package/dist/module/bundler/css-processor/serialize.d.ts +2 -0
- package/dist/module/bundler/css-processor/serialize.js +101 -0
- package/dist/module/bundler/css-processor/types.d.ts +28 -0
- package/dist/module/bundler/css-processor/types.js +0 -0
- package/dist/module/bundler/css-processor/units.d.ts +10 -0
- package/dist/module/bundler/css-processor/units.js +48 -0
- package/dist/module/bundler/css-processor/utils.d.ts +24 -0
- package/dist/{shared/uniwind.PtWWxxnh.mjs → module/bundler/css-processor/utils.js} +11 -15
- package/dist/module/bundler/css-processor/var.d.ts +7 -0
- package/dist/module/bundler/css-processor/var.js +13 -0
- package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.d.ts +1 -1
- package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.d.ts +4 -3
- package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
- package/dist/module/{css-visitor → bundler/css-visitor}/visitor.d.ts +3 -3
- package/dist/module/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/module/bundler/logger.d.ts +11 -0
- package/dist/module/bundler/logger.js +34 -0
- package/dist/module/bundler/types.d.ts +15 -0
- package/dist/module/bundler/types.js +0 -0
- package/dist/module/common/consts.d.ts +21 -0
- package/dist/module/common/consts.js +24 -0
- package/dist/module/components/ScopedTheme/ScopedTheme.native.d.ts +1 -1
- package/dist/module/components/index.js +0 -3
- package/dist/module/components/native/Pressable.d.ts +1 -1
- package/dist/module/components/native/TouchableHighlight.d.ts +1 -1
- package/dist/module/components/native/TouchableOpacity.d.ts +1 -1
- package/dist/module/components/native/useAccentColor.d.ts +1 -1
- package/dist/module/components/native/useStyle.d.ts +2 -2
- package/dist/module/components/react-native-gesture-handler/native/BaseButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/BorderlessButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/DrawerLayoutAndroid.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/FlatList.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Pressable.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/PureNativeButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RawButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RectButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RefreshControl.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/ScrollView.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Switch.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/TextInput.d.ts +1 -1
- package/dist/module/components/web/Pressable.d.ts +1 -1
- package/dist/module/components/web/TouchableHighlight.d.ts +1 -1
- package/dist/module/components/web/TouchableOpacity.d.ts +1 -1
- package/dist/module/components/web/rnw.js +1 -1
- package/dist/module/core/config/config.common.d.ts +7 -6
- package/dist/module/core/config/config.common.js +6 -2
- package/dist/module/core/config/config.d.ts +1 -1
- package/dist/module/core/config/config.js +1 -1
- package/dist/module/core/config/config.native.d.ts +2 -2
- package/dist/module/core/config/config.native.js +1 -1
- package/dist/module/core/listener.d.ts +1 -1
- package/dist/module/core/listener.js +1 -1
- package/dist/module/core/native/runtime.js +5 -1
- package/dist/module/core/native/store.d.ts +2 -2
- package/dist/module/core/native/store.js +1 -2
- package/dist/module/core/types.d.ts +6 -3
- package/dist/module/core/web/cssListener.js +1 -1
- package/dist/module/core/web/getWebStyles.d.ts +1 -1
- package/dist/module/hoc/types.d.ts +2 -2
- package/dist/module/hoc/withUniwind.d.ts +1 -1
- package/dist/module/hoc/withUniwind.js +5 -5
- package/dist/module/hoc/withUniwind.native.d.ts +1 -1
- package/dist/module/hoc/withUniwind.native.js +5 -5
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/index.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/index.js +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +4 -2
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +23 -16
- package/dist/module/hooks/useResolveClassNames.d.ts +1 -1
- package/dist/module/hooks/useUniwind.d.ts +1 -1
- package/dist/module/hooks/useUniwind.js +1 -1
- package/dist/module/index.d.ts +1 -2
- package/dist/shared/{uniwind.r2i22V6d.cjs → uniwind.CFiAZ3D-.cjs} +307 -217
- package/dist/shared/{uniwind.BGiqYvxb.mjs → uniwind.u-s1XVU8.mjs} +299 -214
- package/dist/vite/index.cjs +12 -22
- package/dist/vite/index.mjs +9 -19
- package/package.json +1 -1
- package/src/{metro → bundler/adapters/metro}/index.d.ts +2 -0
- package/src/bundler/adapters/metro/index.ts +1 -0
- package/src/{metro/withUniwindConfig.ts → bundler/adapters/metro/metro.ts} +7 -22
- package/src/{metro/metro-css-patches.ts → bundler/adapters/metro/patches.ts} +2 -1
- package/src/{metro → bundler/adapters/metro}/resolvers.ts +8 -8
- package/src/bundler/adapters/metro/transformer.ts +85 -0
- package/src/{vite → bundler/adapters/vite}/vite.ts +10 -28
- package/src/{css → bundler/artifacts/css}/extraUtilities.ts +1 -1
- package/src/{css → bundler/artifacts/css}/index.ts +1 -5
- package/src/{css → bundler/artifacts/css}/themes.ts +1 -1
- package/src/{utils/buildDtsFile.ts → bundler/artifacts/dts.ts} +3 -4
- package/src/bundler/config.ts +84 -0
- package/src/bundler/css-compiler/compileCSS.ts +15 -0
- package/src/bundler/css-compiler/compileNativeCSS.ts +41 -0
- package/src/bundler/css-compiler/compileTailwind.ts +25 -0
- package/src/bundler/css-compiler/compileWebCSS.ts +10 -0
- package/src/bundler/css-compiler/index.ts +1 -0
- package/src/{metro → bundler/css-processor}/addMetaToStylesTemplate.ts +33 -14
- package/src/{metro/processor → bundler/css-processor}/animation.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/color.ts +4 -3
- package/src/{metro/processor → bundler/css-processor}/css.ts +17 -9
- package/src/{metro/processor → bundler/css-processor}/functions.ts +2 -2
- package/src/bundler/css-processor/index.ts +3 -0
- package/src/{metro/processor → bundler/css-processor}/mq.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/processor.ts +13 -11
- package/src/{metro/processor → bundler/css-processor}/rn.ts +115 -3
- package/src/{metro/utils → bundler/css-processor}/serialize.ts +2 -2
- package/src/{metro → bundler/css-processor}/types.ts +3 -17
- package/src/{metro/processor → bundler/css-processor}/units.ts +1 -1
- package/src/{metro/processor → bundler/css-processor}/var.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/function-visitor.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/rule-visitor.ts +6 -5
- package/src/{css-visitor → bundler/css-visitor}/visitor.ts +4 -3
- package/src/bundler/types.ts +17 -0
- package/src/common/consts.ts +25 -0
- package/src/components/ScopedTheme/ScopedTheme.native.tsx +1 -1
- package/src/components/index.ts +0 -3
- package/src/components/native/ActivityIndicator.tsx +2 -1
- package/src/components/native/Button.tsx +2 -1
- package/src/components/native/FlatList.tsx +2 -1
- package/src/components/native/Image.tsx +2 -1
- package/src/components/native/ImageBackground.tsx +2 -1
- package/src/components/native/InputAccessoryView.tsx +3 -2
- package/src/components/native/KeyboardAvoidingView.tsx +2 -1
- package/src/components/native/Modal.tsx +2 -1
- package/src/components/native/Pressable.tsx +1 -1
- package/src/components/native/RefreshControl.tsx +2 -1
- package/src/components/native/SafeAreaView.tsx +2 -1
- package/src/components/native/ScrollView.tsx +2 -1
- package/src/components/native/SectionList.tsx +2 -1
- package/src/components/native/Switch.tsx +3 -2
- package/src/components/native/Text.tsx +3 -2
- package/src/components/native/TextInput.tsx +3 -2
- package/src/components/native/TouchableHighlight.tsx +3 -2
- package/src/components/native/TouchableNativeFeedback.tsx +3 -2
- package/src/components/native/TouchableOpacity.tsx +3 -2
- package/src/components/native/TouchableWithoutFeedback.tsx +3 -2
- package/src/components/native/View.tsx +2 -1
- package/src/components/native/VirtualizedList.tsx +2 -1
- package/src/components/native/useAccentColor.ts +1 -1
- package/src/components/native/useStyle.ts +2 -2
- package/src/components/react-native-gesture-handler/native/BaseButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/BorderlessButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/DrawerLayoutAndroid.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/FlatList.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/GestureHandlerRootView.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/Pressable.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/PureNativeButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RawButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RectButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/ScrollView.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/Switch.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/Text.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TextInput.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableNativeFeedback.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableOpacity.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableWithoutFeedback.tsx +2 -2
- package/src/components/web/ActivityIndicator.tsx +2 -1
- package/src/components/web/Button.tsx +2 -1
- package/src/components/web/FlatList.tsx +2 -1
- package/src/components/web/Image.tsx +2 -1
- package/src/components/web/ImageBackground.tsx +2 -1
- package/src/components/web/KeyboardAvoidingView.tsx +2 -1
- package/src/components/web/Modal.tsx +2 -1
- package/src/components/web/Pressable.tsx +2 -1
- package/src/components/web/RefreshControl.tsx +2 -1
- package/src/components/web/SafeAreaView.tsx +2 -1
- package/src/components/web/ScrollView.tsx +2 -1
- package/src/components/web/SectionList.tsx +2 -1
- package/src/components/web/Switch.tsx +2 -1
- package/src/components/web/Text.tsx +2 -1
- package/src/components/web/TextInput.tsx +2 -1
- package/src/components/web/TouchableHighlight.tsx +2 -1
- package/src/components/web/TouchableOpacity.tsx +2 -1
- package/src/components/web/TouchableWithoutFeedback.tsx +2 -1
- package/src/components/web/View.tsx +2 -1
- package/src/components/web/VirtualizedList.tsx +2 -1
- package/src/components/web/rnw.ts +1 -1
- package/src/core/config/config.common.ts +15 -8
- package/src/core/config/config.native.ts +3 -3
- package/src/core/config/config.ts +2 -2
- package/src/core/listener.ts +1 -1
- package/src/core/native/runtime.ts +7 -2
- package/src/core/native/store.ts +3 -4
- package/src/core/types.ts +6 -3
- package/src/core/web/cssListener.ts +1 -1
- package/src/core/web/getWebStyles.ts +1 -1
- package/src/hoc/types.ts +2 -2
- package/src/hoc/withUniwind.native.tsx +4 -3
- package/src/hoc/withUniwind.tsx +3 -2
- package/src/hooks/useCSSVariable/getVariableValue.native.ts +1 -1
- package/src/hooks/useCSSVariable/index.ts +1 -1
- package/src/hooks/useCSSVariable/useCSSVariable.ts +34 -25
- package/src/hooks/useResolveClassNames.ts +1 -1
- package/src/hooks/useUniwind.ts +2 -2
- package/src/index.ts +1 -2
- package/dist/common/types.js +0 -28
- package/dist/common/utils/stringifyThemes.js +0 -8
- package/dist/common/vite/vite.js +0 -95
- package/dist/module/types.d.ts +0 -21
- package/dist/module/types.js +0 -22
- package/dist/module/utils/stringifyThemes.d.ts +0 -1
- package/dist/module/utils/stringifyThemes.js +0 -1
- package/dist/module/vite/index.d.ts +0 -9
- package/dist/module/vite/index.js +0 -1
- package/dist/module/vite/vite.d.ts +0 -8
- package/dist/module/vite/vite.js +0 -98
- package/dist/shared/uniwind.B5q8hBGv.cjs +0 -18
- package/dist/shared/uniwind.Cv73KtI-.cjs +0 -86
- package/dist/shared/uniwind.JSWK3vHl.mjs +0 -14
- package/src/metro/compileVirtual.ts +0 -85
- package/src/metro/index.ts +0 -1
- package/src/metro/injectThemes.ts +0 -23
- package/src/metro/metro-transformer.ts +0 -116
- package/src/metro/processor/index.ts +0 -1
- package/src/metro/utils/index.ts +0 -2
- package/src/types.ts +0 -23
- package/src/utils/stringifyThemes.ts +0 -1
- package/src/vite/index.d.ts +0 -9
- /package/dist/common/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/insets.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/overwrite.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/variants.js +0 -0
- /package/dist/common/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
- /package/dist/common/{css-visitor → bundler/css-visitor}/index.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/insets.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/insets.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/overwrite.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/overwrite.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/themes.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/variants.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/variants.js +0 -0
- /package/dist/module/{utils/buildDtsFile.d.ts → bundler/artifacts/dts.d.ts} +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/index.d.ts +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/index.js +0 -0
- /package/{dist/common → src/bundler/adapters}/vite/index.d.ts +0 -0
- /package/src/{vite → bundler/adapters/vite}/index.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/insets.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/overwrite.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/variants.ts +0 -0
- /package/src/{metro/utils/common.ts → bundler/css-processor/utils.ts} +0 -0
- /package/src/{css-visitor → bundler/css-visitor}/index.ts +0 -0
- /package/src/{metro → bundler}/logger.ts +0 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.UNIWIND_THEME_VARIABLES = exports.UNIWIND_PLATFORM_VARIABLES = exports.Platform = void 0;
|
|
6
|
+
exports.UNIWIND_THEME_VARIABLES = exports.UNIWIND_PLATFORM_VARIABLES = exports.StyleDependency = exports.Platform = exports.Orientation = exports.DEFAULT_SCREEN_WIDTH = exports.DEFAULT_SCREEN_HEIGHT = exports.ColorScheme = void 0;
|
|
7
7
|
var Platform = exports.Platform = /* @__PURE__ */(Platform2 => {
|
|
8
8
|
Platform2["Android"] = "android";
|
|
9
9
|
Platform2["iOS"] = "ios";
|
|
@@ -15,4 +15,28 @@ var Platform = exports.Platform = /* @__PURE__ */(Platform2 => {
|
|
|
15
15
|
return Platform2;
|
|
16
16
|
})(Platform || {});
|
|
17
17
|
const UNIWIND_PLATFORM_VARIABLES = exports.UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
18
|
-
const UNIWIND_THEME_VARIABLES = exports.UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
18
|
+
const UNIWIND_THEME_VARIABLES = exports.UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
19
|
+
var StyleDependency = exports.StyleDependency = /* @__PURE__ */(StyleDependency2 => {
|
|
20
|
+
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
21
|
+
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
22
|
+
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
23
|
+
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
24
|
+
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
25
|
+
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
26
|
+
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
27
|
+
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
28
|
+
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
29
|
+
return StyleDependency2;
|
|
30
|
+
})(StyleDependency || {});
|
|
31
|
+
var Orientation = exports.Orientation = /* @__PURE__ */(Orientation2 => {
|
|
32
|
+
Orientation2["Portrait"] = "portrait";
|
|
33
|
+
Orientation2["Landscape"] = "landscape";
|
|
34
|
+
return Orientation2;
|
|
35
|
+
})(Orientation || {});
|
|
36
|
+
var ColorScheme = exports.ColorScheme = /* @__PURE__ */(ColorScheme2 => {
|
|
37
|
+
ColorScheme2["Light"] = "light";
|
|
38
|
+
ColorScheme2["Dark"] = "dark";
|
|
39
|
+
return ColorScheme2;
|
|
40
|
+
})(ColorScheme || {});
|
|
41
|
+
const DEFAULT_SCREEN_WIDTH = exports.DEFAULT_SCREEN_WIDTH = 375;
|
|
42
|
+
const DEFAULT_SCREEN_HEIGHT = exports.DEFAULT_SCREEN_HEIGHT = 680;
|
|
@@ -197,9 +197,6 @@ module.exports = {
|
|
|
197
197
|
get PlatformColor() {
|
|
198
198
|
return require("react-native").PlatformColor;
|
|
199
199
|
},
|
|
200
|
-
get PushNotificationIOS() {
|
|
201
|
-
return require("react-native").PushNotificationIOS;
|
|
202
|
-
},
|
|
203
200
|
get processColor() {
|
|
204
201
|
return require("react-native").processColor;
|
|
205
202
|
},
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.toRNWClassName = void 0;
|
|
7
|
+
var _consts = require("../../common/consts");
|
|
7
8
|
var _core = require("../../core");
|
|
8
9
|
var _listener = require("../../core/listener");
|
|
9
|
-
var _types = require("../../types");
|
|
10
10
|
require("./metro-injected");
|
|
11
11
|
const addClassNameToRoot = () => {
|
|
12
12
|
if (typeof document === "undefined") {
|
|
@@ -18,7 +18,7 @@ const addClassNameToRoot = () => {
|
|
|
18
18
|
};
|
|
19
19
|
_listener.UniwindListener.subscribe(() => {
|
|
20
20
|
addClassNameToRoot();
|
|
21
|
-
}, [
|
|
21
|
+
}, [_consts.StyleDependency.Theme]);
|
|
22
22
|
addClassNameToRoot();
|
|
23
23
|
const toRNWClassName = className => className !== void 0 ? {
|
|
24
24
|
$$css: true,
|
|
@@ -6,8 +6,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.UniwindConfigBuilder = exports.Uniwind = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
var
|
|
10
|
-
var
|
|
9
|
+
var _consts = require("../../common/consts");
|
|
10
|
+
var _hoc = require("../../hoc");
|
|
11
|
+
var _useCSSVariable = require("../../hooks/useCSSVariable/useCSSVariable");
|
|
11
12
|
var _listener = require("../listener");
|
|
12
13
|
const SYSTEM_THEME = "system";
|
|
13
14
|
const RN_VERSION = _reactNative.Platform.constants?.reactNativeVersion?.minor ?? 0;
|
|
@@ -18,12 +19,12 @@ class UniwindConfigBuilder {
|
|
|
18
19
|
#currentTheme = this.colorScheme;
|
|
19
20
|
constructor() {
|
|
20
21
|
_reactNative.Appearance.addChangeListener(event => {
|
|
21
|
-
const colorScheme = event.colorScheme === "unspecified" ?
|
|
22
|
+
const colorScheme = event.colorScheme === "unspecified" ? _consts.ColorScheme.Light : event.colorScheme ?? _consts.ColorScheme.Light;
|
|
22
23
|
const prevTheme = this.#currentTheme;
|
|
23
24
|
if (this.#hasAdaptiveThemes && prevTheme !== colorScheme) {
|
|
24
25
|
this.#currentTheme = colorScheme;
|
|
25
26
|
this.onThemeChange();
|
|
26
|
-
_listener.UniwindListener.notify([
|
|
27
|
+
_listener.UniwindListener.notify([_consts.StyleDependency.Theme]);
|
|
27
28
|
}
|
|
28
29
|
});
|
|
29
30
|
}
|
|
@@ -39,15 +40,15 @@ class UniwindConfigBuilder {
|
|
|
39
40
|
get colorScheme() {
|
|
40
41
|
const colorScheme = _reactNative.Appearance.getColorScheme();
|
|
41
42
|
if (colorScheme === "unspecified") {
|
|
42
|
-
return
|
|
43
|
+
return _consts.ColorScheme.Light;
|
|
43
44
|
}
|
|
44
|
-
return colorScheme ??
|
|
45
|
+
return colorScheme ?? _consts.ColorScheme.Light;
|
|
45
46
|
}
|
|
46
47
|
Wrapper({
|
|
47
48
|
as,
|
|
48
49
|
...props
|
|
49
50
|
}) {
|
|
50
|
-
const StyledComponent = (0, _react.useMemo)(() => (0,
|
|
51
|
+
const StyledComponent = (0, _react.useMemo)(() => (0, _hoc.withUniwind)(as), [as]);
|
|
51
52
|
return (0, _react.createElement)(StyledComponent, props);
|
|
52
53
|
}
|
|
53
54
|
// eslint-disable-next-line @typescript-eslint/no-redundant-type-constituents
|
|
@@ -77,10 +78,10 @@ class UniwindConfigBuilder {
|
|
|
77
78
|
} finally {
|
|
78
79
|
if (prevTheme !== this.#currentTheme) {
|
|
79
80
|
this.onThemeChange();
|
|
80
|
-
_listener.UniwindListener.notify([
|
|
81
|
+
_listener.UniwindListener.notify([_consts.StyleDependency.Theme]);
|
|
81
82
|
}
|
|
82
83
|
if (prevHasAdaptiveThemes !== this.#hasAdaptiveThemes) {
|
|
83
|
-
_listener.UniwindListener.notify([
|
|
84
|
+
_listener.UniwindListener.notify([_consts.StyleDependency.AdaptiveThemes]);
|
|
84
85
|
}
|
|
85
86
|
}
|
|
86
87
|
}
|
|
@@ -88,6 +89,11 @@ class UniwindConfigBuilder {
|
|
|
88
89
|
updateCSSVariables(theme, cssVariables) {}
|
|
89
90
|
// oxlint-disable-next-line typescript/no-unused-vars
|
|
90
91
|
updateInsets(insets) {}
|
|
92
|
+
getCSSVariable = variableName => {
|
|
93
|
+
return (0, _useCSSVariable.getCSSVariable)(variableName, {
|
|
94
|
+
scopedTheme: null
|
|
95
|
+
});
|
|
96
|
+
};
|
|
91
97
|
__reinit(_, themes) {
|
|
92
98
|
this._themes = themes;
|
|
93
99
|
}
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.Uniwind = void 0;
|
|
7
|
+
var _consts = require("../../common/consts");
|
|
7
8
|
var _utils = require("../../common/utils");
|
|
8
|
-
var _types = require("../../types");
|
|
9
9
|
var _listener = require("../listener");
|
|
10
10
|
var _logger = require("../logger");
|
|
11
11
|
var _web = require("../web");
|
|
@@ -35,7 +35,7 @@ class UniwindConfigBuilder extends _config.UniwindConfigBuilder {
|
|
|
35
35
|
rule.style.setProperty(varName, existingRules[rule.theme] ?? null);
|
|
36
36
|
});
|
|
37
37
|
});
|
|
38
|
-
_listener.UniwindListener.notify([
|
|
38
|
+
_listener.UniwindListener.notify([_consts.StyleDependency.Variables]);
|
|
39
39
|
}
|
|
40
40
|
__reinit(generateStyleSheetCallback, themes) {
|
|
41
41
|
const oldThemes = this.themes;
|
|
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.Uniwind = void 0;
|
|
7
7
|
var _culori = require("culori");
|
|
8
|
-
var
|
|
8
|
+
var _consts = require("../../common/consts");
|
|
9
9
|
var _listener = require("../listener");
|
|
10
10
|
var _logger = require("../logger");
|
|
11
11
|
var _native = require("../native");
|
|
@@ -37,14 +37,14 @@ class UniwindConfigBuilder extends _config.UniwindConfigBuilder {
|
|
|
37
37
|
get: getValue
|
|
38
38
|
});
|
|
39
39
|
});
|
|
40
|
-
_listener.UniwindListener.notify([
|
|
40
|
+
_listener.UniwindListener.notify([_consts.StyleDependency.Variables]);
|
|
41
41
|
}
|
|
42
42
|
updateInsets(insets) {
|
|
43
43
|
_native.UniwindStore.runtime.insets.bottom = insets.bottom ?? 0;
|
|
44
44
|
_native.UniwindStore.runtime.insets.top = insets.top ?? 0;
|
|
45
45
|
_native.UniwindStore.runtime.insets.left = insets.left ?? 0;
|
|
46
46
|
_native.UniwindStore.runtime.insets.right = insets.right ?? 0;
|
|
47
|
-
_listener.UniwindListener.notify([
|
|
47
|
+
_listener.UniwindListener.notify([_consts.StyleDependency.Insets]);
|
|
48
48
|
}
|
|
49
49
|
__reinit(generateStyleSheetCallback, themes) {
|
|
50
50
|
super.__reinit(generateStyleSheetCallback, themes);
|
|
@@ -4,18 +4,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.UniwindListener = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _consts = require("../common/consts");
|
|
8
8
|
class UniwindListenerBuilder {
|
|
9
9
|
listeners = {
|
|
10
|
-
[
|
|
11
|
-
[
|
|
12
|
-
[
|
|
13
|
-
[
|
|
14
|
-
[
|
|
15
|
-
[
|
|
16
|
-
[
|
|
17
|
-
[
|
|
18
|
-
[
|
|
10
|
+
[_consts.StyleDependency.ColorScheme]: /* @__PURE__ */new Set(),
|
|
11
|
+
[_consts.StyleDependency.Theme]: /* @__PURE__ */new Set(),
|
|
12
|
+
[_consts.StyleDependency.Dimensions]: /* @__PURE__ */new Set(),
|
|
13
|
+
[_consts.StyleDependency.Orientation]: /* @__PURE__ */new Set(),
|
|
14
|
+
[_consts.StyleDependency.Insets]: /* @__PURE__ */new Set(),
|
|
15
|
+
[_consts.StyleDependency.FontScale]: /* @__PURE__ */new Set(),
|
|
16
|
+
[_consts.StyleDependency.Rtl]: /* @__PURE__ */new Set(),
|
|
17
|
+
[_consts.StyleDependency.AdaptiveThemes]: /* @__PURE__ */new Set(),
|
|
18
|
+
[_consts.StyleDependency.Variables]: /* @__PURE__ */new Set()
|
|
19
19
|
};
|
|
20
20
|
notify(dependencies) {
|
|
21
21
|
dependencies.forEach(dep => {
|
|
@@ -7,10 +7,10 @@ exports.UniwindRuntime = void 0;
|
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _reactNativeReanimated = require("react-native-reanimated");
|
|
9
9
|
var _reactNativeSafeAreaContext = require("react-native-safe-area-context");
|
|
10
|
-
var
|
|
10
|
+
var _consts = require("../../common/consts");
|
|
11
11
|
var _nativeUtils = require("./native-utils");
|
|
12
12
|
const window = _reactNative.Dimensions.get("window");
|
|
13
|
-
const initialColorScheme = _reactNative.Appearance.getColorScheme() ??
|
|
13
|
+
const initialColorScheme = _reactNative.Appearance.getColorScheme() ?? _consts.ColorScheme.Light;
|
|
14
14
|
const UniwindRuntime = exports.UniwindRuntime = {
|
|
15
15
|
screen: {
|
|
16
16
|
width: window.width,
|
|
@@ -18,7 +18,7 @@ const UniwindRuntime = exports.UniwindRuntime = {
|
|
|
18
18
|
},
|
|
19
19
|
colorScheme: initialColorScheme,
|
|
20
20
|
currentThemeName: initialColorScheme,
|
|
21
|
-
orientation: window.width > window.height ?
|
|
21
|
+
orientation: window.width > window.height ? _consts.Orientation.Landscape : _consts.Orientation.Portrait,
|
|
22
22
|
fontScale: value => value * _reactNative.PixelRatio.getFontScale(),
|
|
23
23
|
hairlineWidth: _reactNative.StyleSheet.hairlineWidth,
|
|
24
24
|
rtl: _reactNative.I18nManager.isRTL,
|
|
@@ -44,6 +44,10 @@ const UniwindRuntime = exports.UniwindRuntime = {
|
|
|
44
44
|
android,
|
|
45
45
|
default: ios
|
|
46
46
|
});
|
|
47
|
+
},
|
|
48
|
+
makeResponsive(value, base = _consts.DEFAULT_SCREEN_WIDTH, useHeight = false) {
|
|
49
|
+
const dimension = useHeight ? this.screen.height : this.screen.width;
|
|
50
|
+
return Math.round(value * dimension / base);
|
|
47
51
|
}
|
|
48
52
|
};
|
|
49
53
|
UniwindRuntime.lightDark = _nativeUtils.lightDark.bind(UniwindRuntime);
|
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.UniwindStore = void 0;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var _consts = require("../../common/consts");
|
|
9
|
-
var _types = require("../../types");
|
|
10
9
|
var _listener = require("../listener");
|
|
11
10
|
var _nativeUtils = require("./native-utils");
|
|
12
11
|
var _parsers = require("./parsers");
|
|
@@ -89,7 +88,7 @@ class UniwindStoreBuilder {
|
|
|
89
88
|
for (const style of this.stylesheet[className]) {
|
|
90
89
|
if (style.dependencies) {
|
|
91
90
|
style.dependencies.forEach(dep => {
|
|
92
|
-
if (dep ===
|
|
91
|
+
if (dep === _consts.StyleDependency.Theme && isScopedTheme) {
|
|
93
92
|
return;
|
|
94
93
|
}
|
|
95
94
|
dependencies.add(dep);
|
|
@@ -239,12 +238,12 @@ const UniwindStore = exports.UniwindStore = new UniwindStoreBuilder();
|
|
|
239
238
|
_reactNative.Dimensions.addEventListener("change", ({
|
|
240
239
|
window
|
|
241
240
|
}) => {
|
|
242
|
-
const newOrientation = window.width > window.height ?
|
|
241
|
+
const newOrientation = window.width > window.height ? _consts.Orientation.Landscape : _consts.Orientation.Portrait;
|
|
243
242
|
const orientationChanged = UniwindStore.runtime.orientation !== newOrientation;
|
|
244
243
|
UniwindStore.runtime.screen = {
|
|
245
244
|
width: window.width,
|
|
246
245
|
height: window.height
|
|
247
246
|
};
|
|
248
247
|
UniwindStore.runtime.orientation = newOrientation;
|
|
249
|
-
_listener.UniwindListener.notify([...(orientationChanged ? [
|
|
248
|
+
_listener.UniwindListener.notify([...(orientationChanged ? [_consts.StyleDependency.Orientation] : []), _consts.StyleDependency.Dimensions]);
|
|
250
249
|
});
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.CSSListener = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _consts = require("../../common/consts");
|
|
8
8
|
var _listener = require("../listener");
|
|
9
9
|
class CSSListenerBuilder {
|
|
10
10
|
activeRules = /* @__PURE__ */new Set();
|
|
@@ -54,7 +54,7 @@ class CSSListenerBuilder {
|
|
|
54
54
|
listeners?.add(listener);
|
|
55
55
|
disposables.push(() => listeners?.delete(listener));
|
|
56
56
|
});
|
|
57
|
-
const disposeThemeListener = _listener.UniwindListener.subscribe(listener, [
|
|
57
|
+
const disposeThemeListener = _listener.UniwindListener.subscribe(listener, [_consts.StyleDependency.Theme, _consts.StyleDependency.Variables]);
|
|
58
58
|
return () => {
|
|
59
59
|
disposables.forEach(disposable => disposable());
|
|
60
60
|
disposeThemeListener();
|
|
@@ -13,9 +13,9 @@ var _logger = require("../core/logger");
|
|
|
13
13
|
var _web = require("../core/web");
|
|
14
14
|
var _withUniwindUtils = require("./withUniwindUtils");
|
|
15
15
|
let warnedOnce = false;
|
|
16
|
-
const withUniwind = (
|
|
16
|
+
const withUniwind = (Component, options) => options ? withManualUniwind(Component, options) : withAutoUniwind(Component);
|
|
17
17
|
exports.withUniwind = withUniwind;
|
|
18
|
-
const withAutoUniwind =
|
|
18
|
+
const withAutoUniwind = Component => props => {
|
|
19
19
|
const uniwindContext = (0, _context.useUniwindContext)();
|
|
20
20
|
const {
|
|
21
21
|
classNames,
|
|
@@ -60,13 +60,13 @@ const withAutoUniwind = Component2 => props => {
|
|
|
60
60
|
const dispose = _web.CSSListener.subscribeToClassName(classNames, rerender);
|
|
61
61
|
return dispose;
|
|
62
62
|
}, [classNames]);
|
|
63
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
63
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Component, {
|
|
64
64
|
...props,
|
|
65
65
|
...generatedProps,
|
|
66
66
|
dataSet: (0, _generateDataSet.generateDataSet)(props)
|
|
67
67
|
});
|
|
68
68
|
};
|
|
69
|
-
const withManualUniwind = (
|
|
69
|
+
const withManualUniwind = (Component, options) => props => {
|
|
70
70
|
const uniwindContext = (0, _context.useUniwindContext)();
|
|
71
71
|
const {
|
|
72
72
|
generatedProps,
|
|
@@ -100,7 +100,7 @@ const withManualUniwind = (Component2, options) => props => {
|
|
|
100
100
|
const dispose = _web.CSSListener.subscribeToClassName(classNames, rerender);
|
|
101
101
|
return dispose;
|
|
102
102
|
}, [classNames]);
|
|
103
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
103
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Component, {
|
|
104
104
|
...props,
|
|
105
105
|
...generatedProps,
|
|
106
106
|
dataSet: (0, _generateDataSet.generateDataSet)(props)
|
|
@@ -13,9 +13,9 @@ var _logger = require("../core/logger");
|
|
|
13
13
|
var _native = require("../core/native");
|
|
14
14
|
var _withUniwindUtils = require("./withUniwindUtils");
|
|
15
15
|
let warnedOnce = false;
|
|
16
|
-
const withUniwind = (
|
|
16
|
+
const withUniwind = (Component, options) => options ? withManualUniwind(Component, options) : withAutoUniwind(Component);
|
|
17
17
|
exports.withUniwind = withUniwind;
|
|
18
|
-
const withAutoUniwind =
|
|
18
|
+
const withAutoUniwind = Component => props => {
|
|
19
19
|
const uniwindContext = (0, _context.useUniwindContext)();
|
|
20
20
|
const {
|
|
21
21
|
dependencies,
|
|
@@ -68,12 +68,12 @@ const withAutoUniwind = Component2 => props => {
|
|
|
68
68
|
const dispose = _listener.UniwindListener.subscribe(rerender, Array.from(new Set(dependencies)));
|
|
69
69
|
return dispose;
|
|
70
70
|
}, [dependencySum]);
|
|
71
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
71
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Component, {
|
|
72
72
|
...props,
|
|
73
73
|
...generatedProps
|
|
74
74
|
});
|
|
75
75
|
};
|
|
76
|
-
const withManualUniwind = (
|
|
76
|
+
const withManualUniwind = (Component, options) => props => {
|
|
77
77
|
const uniwindContext = (0, _context.useUniwindContext)();
|
|
78
78
|
const {
|
|
79
79
|
generatedProps,
|
|
@@ -124,7 +124,7 @@ const withManualUniwind = (Component2, options) => props => {
|
|
|
124
124
|
const dispose = _listener.UniwindListener.subscribe(rerender, Array.from(new Set(dependencies)));
|
|
125
125
|
return dispose;
|
|
126
126
|
}, [dependencySum]);
|
|
127
|
-
return /* @__PURE__ */(0, _jsxRuntime.jsx)(
|
|
127
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(Component, {
|
|
128
128
|
...props,
|
|
129
129
|
...generatedProps
|
|
130
130
|
});
|
|
@@ -3,14 +3,10 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
return _useCSSVariable[key];
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
});
|
|
6
|
+
Object.defineProperty(exports, "useCSSVariable", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function () {
|
|
9
|
+
return _useCSSVariable.useCSSVariable;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _useCSSVariable = require("./useCSSVariable");
|
|
@@ -3,53 +3,61 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useCSSVariable = void 0;
|
|
6
|
+
exports.useCSSVariable = exports.getCSSVariable = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
var _consts = require("../../common/consts");
|
|
8
10
|
var _utils = require("../../common/utils");
|
|
9
11
|
var _context = require("../../core/context");
|
|
10
12
|
var _listener = require("../../core/listener");
|
|
11
13
|
var _logger = require("../../core/logger");
|
|
12
|
-
var _types = require("../../types");
|
|
13
14
|
var _getVariableValue = require("./getVariableValue");
|
|
14
|
-
const getValue = (name, uniwindContext) => Array.isArray(name) ? name.map(name2 => (0, _getVariableValue.getVariableValue)(name2, uniwindContext)) : (0, _getVariableValue.getVariableValue)(name, uniwindContext);
|
|
15
15
|
let warned = false;
|
|
16
16
|
const logDevError = name => {
|
|
17
|
+
if (_reactNative.Platform.OS === "web" && (typeof document === "undefined" || typeof window === "undefined")) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
17
20
|
warned = true;
|
|
18
21
|
_logger.Logger.warn(`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`);
|
|
19
22
|
};
|
|
23
|
+
const getCSSVariable = (name, uniwindContext) => {
|
|
24
|
+
const value = Array.isArray(name) ? name.map(name2 => (0, _getVariableValue.getVariableValue)(name2, uniwindContext)) : (0, _getVariableValue.getVariableValue)(name, uniwindContext);
|
|
25
|
+
if (Array.isArray(value)) {
|
|
26
|
+
value.forEach((val, index) => {
|
|
27
|
+
if (val === void 0 && __DEV__ && !warned) {
|
|
28
|
+
logDevError(name[index] ?? "");
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
if (value === void 0 && __DEV__ && !warned) {
|
|
33
|
+
logDevError(name);
|
|
34
|
+
}
|
|
35
|
+
return value;
|
|
36
|
+
};
|
|
37
|
+
exports.getCSSVariable = getCSSVariable;
|
|
20
38
|
const useCSSVariable = name => {
|
|
21
39
|
const uniwindContext = (0, _context.useUniwindContext)();
|
|
22
|
-
const [value, setValue] = (0, _react.useState)(
|
|
40
|
+
const [value, setValue] = (0, _react.useState)(getCSSVariable(name, uniwindContext));
|
|
23
41
|
const nameRef = (0, _react.useRef)(name);
|
|
24
42
|
(0, _react.useLayoutEffect)(() => {
|
|
25
43
|
if (Array.isArray(name) && Array.isArray(nameRef.current)) {
|
|
26
44
|
if ((0, _utils.arrayEquals)(name, nameRef.current)) {
|
|
27
45
|
return;
|
|
28
46
|
}
|
|
29
|
-
setValue(
|
|
47
|
+
setValue(getCSSVariable(name, uniwindContext));
|
|
30
48
|
nameRef.current = name;
|
|
31
49
|
return;
|
|
32
50
|
}
|
|
33
51
|
if (name !== nameRef.current) {
|
|
34
|
-
setValue(
|
|
52
|
+
setValue(getCSSVariable(name, uniwindContext));
|
|
35
53
|
nameRef.current = name;
|
|
36
54
|
}
|
|
37
55
|
}, [name]);
|
|
38
56
|
(0, _react.useLayoutEffect)(() => {
|
|
39
|
-
const updateValue = () => setValue(
|
|
40
|
-
const dispose = _listener.UniwindListener.subscribe(updateValue, [
|
|
57
|
+
const updateValue = () => setValue(getCSSVariable(nameRef.current, uniwindContext));
|
|
58
|
+
const dispose = _listener.UniwindListener.subscribe(updateValue, [_consts.StyleDependency.Theme, _consts.StyleDependency.Variables]);
|
|
41
59
|
return dispose;
|
|
42
60
|
}, [uniwindContext]);
|
|
43
|
-
if (Array.isArray(value)) {
|
|
44
|
-
value.forEach((val, index) => {
|
|
45
|
-
if (val === void 0 && __DEV__ && !warned) {
|
|
46
|
-
logDevError(name[index] ?? "");
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (value === void 0 && __DEV__ && !warned) {
|
|
51
|
-
logDevError(name);
|
|
52
|
-
}
|
|
53
61
|
return value;
|
|
54
62
|
};
|
|
55
63
|
exports.useCSSVariable = useCSSVariable;
|
|
@@ -5,10 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.useUniwind = void 0;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _consts = require("../common/consts");
|
|
8
9
|
var _core = require("../core");
|
|
9
10
|
var _context = require("../core/context");
|
|
10
11
|
var _listener = require("../core/listener");
|
|
11
|
-
var _types = require("../types");
|
|
12
12
|
const useUniwind = () => {
|
|
13
13
|
const uniwindContext = (0, _context.useUniwindContext)();
|
|
14
14
|
const [theme, setTheme] = (0, _react.useState)(_core.Uniwind.currentTheme);
|
|
@@ -20,7 +20,7 @@ const useUniwind = () => {
|
|
|
20
20
|
const dispose = _listener.UniwindListener.subscribe(() => {
|
|
21
21
|
setTheme(_core.Uniwind.currentTheme);
|
|
22
22
|
setHasAdaptiveThemes(_core.Uniwind.hasAdaptiveThemes);
|
|
23
|
-
}, [
|
|
23
|
+
}, [_consts.StyleDependency.Theme, _consts.StyleDependency.AdaptiveThemes]);
|
|
24
24
|
return () => {
|
|
25
25
|
dispose();
|
|
26
26
|
};
|
package/dist/metro/index.cjs
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _package = require('../shared/uniwind.CFiAZ3D-.cjs');
|
|
4
4
|
const FileStoreBase = require('metro-cache/private/stores/FileStore');
|
|
5
5
|
const os = require('os');
|
|
6
6
|
const path = require('path');
|
|
7
7
|
const node_path = require('node:path');
|
|
8
|
-
|
|
8
|
+
require('fs');
|
|
9
|
+
require('@tailwindcss/node');
|
|
10
|
+
require('lightningcss');
|
|
9
11
|
|
|
10
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
13
|
|
|
@@ -79,7 +81,7 @@ const nativeResolver = (extraComponents) => ({
|
|
|
79
81
|
const resolution = resolver(context, moduleName, platform);
|
|
80
82
|
if (cachedInternalBasePath === null) {
|
|
81
83
|
try {
|
|
82
|
-
cachedInternalBasePath = node_path.dirname(require.resolve(`${
|
|
84
|
+
cachedInternalBasePath = node_path.dirname(require.resolve(`${_package.name}/package.json`));
|
|
83
85
|
} catch {
|
|
84
86
|
cachedInternalBasePath = "";
|
|
85
87
|
}
|
|
@@ -92,16 +94,16 @@ const nativeResolver = (extraComponents) => ({
|
|
|
92
94
|
return resolution;
|
|
93
95
|
}
|
|
94
96
|
if (moduleName === "react-native") {
|
|
95
|
-
return resolver(context, `${
|
|
97
|
+
return resolver(context, `${_package.name}/components`, platform);
|
|
96
98
|
}
|
|
97
99
|
if (moduleName === "react-native-gesture-handler") {
|
|
98
|
-
return resolver(context, `${
|
|
100
|
+
return resolver(context, `${_package.name}/components/react-native-gesture-handler`, platform);
|
|
99
101
|
}
|
|
100
102
|
if (resolution.filePath.includes(`${node_path.sep}react-native${node_path.sep}Libraries${node_path.sep}`)) {
|
|
101
103
|
const filename = node_path.basename(resolution.filePath.split(node_path.sep).at(-1) ?? "");
|
|
102
104
|
const module = filename.split(".").at(0);
|
|
103
105
|
if (module !== void 0 && SUPPORTED_COMPONENTS.includes(module)) {
|
|
104
|
-
return resolver(context, `${
|
|
106
|
+
return resolver(context, `${_package.name}/components/${module}`, platform);
|
|
105
107
|
}
|
|
106
108
|
}
|
|
107
109
|
if (moduleName in extraComponents) {
|
|
@@ -119,7 +121,7 @@ const webResolver = (extraComponents) => ({
|
|
|
119
121
|
const resolution = resolver(context, moduleName, platform);
|
|
120
122
|
if (cachedInternalBasePath === null) {
|
|
121
123
|
try {
|
|
122
|
-
cachedInternalBasePath = node_path.dirname(require.resolve(`${
|
|
124
|
+
cachedInternalBasePath = node_path.dirname(require.resolve(`${_package.name}/package.json`));
|
|
123
125
|
} catch {
|
|
124
126
|
cachedInternalBasePath = "";
|
|
125
127
|
}
|
|
@@ -141,31 +143,19 @@ const webResolver = (extraComponents) => ({
|
|
|
141
143
|
if (!isIndex || module === void 0 || !SUPPORTED_COMPONENTS.includes(module) || context.originModulePath.endsWith(`${module}${node_path.sep}index.js`)) {
|
|
142
144
|
return resolution;
|
|
143
145
|
}
|
|
144
|
-
return resolver(context, `${
|
|
146
|
+
return resolver(context, `${_package.name}/components/${module}`, platform);
|
|
145
147
|
};
|
|
146
148
|
|
|
147
149
|
const withUniwindConfig = (config, uniwindConfig) => {
|
|
148
|
-
|
|
149
|
-
"light",
|
|
150
|
-
"dark",
|
|
151
|
-
...uniwindConfig.extraThemes ?? []
|
|
152
|
-
]);
|
|
150
|
+
const bundlerConfig = _package.UniwindBundlerConfig.fromMetroConfig(uniwindConfig);
|
|
153
151
|
patchMetroGraphToSupportUncachedModules();
|
|
154
|
-
if (typeof uniwindConfig === "undefined") {
|
|
155
|
-
throw new Error("Uniwind: You need to pass second parameter to withUniwindConfig");
|
|
156
|
-
}
|
|
157
|
-
if (typeof uniwindConfig.cssEntryFile === "undefined") {
|
|
158
|
-
throw new Error(
|
|
159
|
-
'Uniwind: You need to pass css css entry file to withUniwindConfig, e.g. withUniwindConfig(config, { cssEntryFile: "./global.css" })'
|
|
160
|
-
);
|
|
161
|
-
}
|
|
162
152
|
return {
|
|
163
153
|
...config,
|
|
164
154
|
cacheStores: [cacheStore],
|
|
165
|
-
transformerPath: require.resolve("./
|
|
155
|
+
transformerPath: require.resolve("./transformer.cjs"),
|
|
166
156
|
transformer: {
|
|
167
157
|
...config.transformer,
|
|
168
|
-
uniwind:
|
|
158
|
+
uniwind: bundlerConfig.toMetroConfig()
|
|
169
159
|
},
|
|
170
160
|
resolver: {
|
|
171
161
|
...config.resolver,
|
|
@@ -178,7 +168,7 @@ const withUniwindConfig = (config, uniwindConfig) => {
|
|
|
178
168
|
),
|
|
179
169
|
resolveRequest: (context, moduleName, platform) => {
|
|
180
170
|
const resolver = config.resolver?.resolveRequest ?? context.resolveRequest;
|
|
181
|
-
const platformResolver = (platform ===
|
|
171
|
+
const platformResolver = (platform === _package.Platform.Web ? webResolver : nativeResolver)(uniwindConfig.extraComponents ?? {});
|
|
182
172
|
const resolved = platformResolver({
|
|
183
173
|
context,
|
|
184
174
|
moduleName,
|
package/dist/metro/index.d.ts
CHANGED
|
@@ -2,11 +2,13 @@ import type { MetroConfig } from 'metro-config'
|
|
|
2
2
|
|
|
3
3
|
type Polyfills = {
|
|
4
4
|
rem?: number
|
|
5
|
+
responsive?: 'text' | 'components' | boolean
|
|
5
6
|
}
|
|
6
7
|
|
|
7
8
|
type UniwindConfig = {
|
|
8
9
|
cssEntryFile: string
|
|
9
10
|
extraThemes?: Array<string>
|
|
11
|
+
extraComponents?: Record<string, string>
|
|
10
12
|
dtsFile?: string
|
|
11
13
|
polyfills?: Polyfills
|
|
12
14
|
debug?: boolean
|