@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
package/dist/vite/index.cjs
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const node = require('@tailwindcss/node');
|
|
4
|
+
const node_module = require('node:module');
|
|
4
5
|
const path = require('path');
|
|
5
|
-
const
|
|
6
|
-
const
|
|
6
|
+
const _package = require('../shared/uniwind.DJ5M1Q4q.cjs');
|
|
7
|
+
const config = require('../shared/uniwind.BEqYiPBB.cjs');
|
|
7
8
|
require('fs');
|
|
8
9
|
require('lightningcss');
|
|
9
10
|
|
|
11
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
10
12
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
11
13
|
|
|
12
14
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
@@ -20,84 +22,105 @@ const styleSheetPath = path__default.resolve(
|
|
|
20
22
|
dirname,
|
|
21
23
|
"../module/components/web/createOrderedCSSStyleSheet.js"
|
|
22
24
|
);
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
25
|
+
const cssArtifactPath = path__default.resolve(dirname, "../../uniwind.css");
|
|
26
|
+
const require$1 = node_module.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('vite/index.cjs', document.baseURI).href)));
|
|
27
|
+
const viteVersion = require$1("vite/package.json").version;
|
|
28
|
+
const isVite8 = Number(viteVersion.split(".")[0]) >= 8;
|
|
29
|
+
const resolveOrderedCSSStyleSheet = (source, importer) => {
|
|
30
|
+
const normalizedSource = node.normalizePath(source);
|
|
31
|
+
const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
|
|
32
|
+
if (isTarget && importer !== void 0 && node.normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
33
|
+
return styleSheetPath;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const vite8OptimizeDeps = {
|
|
37
|
+
exclude: [_package.name, "react-native"],
|
|
38
|
+
rolldownOptions: {
|
|
39
|
+
plugins: [{
|
|
40
|
+
name: "uniwind-rolldown-plugin",
|
|
41
|
+
resolveId: resolveOrderedCSSStyleSheet
|
|
42
|
+
}]
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
const vite7OptimizeDeps = {
|
|
46
|
+
exclude: [_package.name, "react-native"],
|
|
47
|
+
esbuildOptions: {
|
|
48
|
+
plugins: [{
|
|
49
|
+
name: "uniwind-esbuild-plugin",
|
|
50
|
+
setup: (build) => {
|
|
51
|
+
build.onResolve(
|
|
52
|
+
{ filter: /^\.\/createOrderedCSSStyleSheet$/ },
|
|
53
|
+
(args) => {
|
|
54
|
+
const resolved = resolveOrderedCSSStyleSheet(args.path, args.importer);
|
|
55
|
+
if (resolved !== void 0) {
|
|
56
|
+
return { path: resolved };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}]
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
const vite8Resolve = {
|
|
65
|
+
alias: [{
|
|
66
|
+
find: /^react-native$/,
|
|
67
|
+
replacement: componentPath,
|
|
68
|
+
customResolver: {
|
|
69
|
+
resolveId(_, importer) {
|
|
70
|
+
if (importer !== void 0 && node.normalizePath(importer).includes(`${_package.name}/dist`)) {
|
|
71
|
+
return this.resolve("react-native-web", importer, { skipSelf: true });
|
|
72
|
+
}
|
|
73
|
+
return componentPath;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}]
|
|
77
|
+
};
|
|
78
|
+
const vite7Resolve = {
|
|
79
|
+
alias: [{
|
|
80
|
+
find: /^react-native$/,
|
|
81
|
+
replacement: componentPath,
|
|
82
|
+
customResolver: {
|
|
83
|
+
resolveId(_, importer) {
|
|
84
|
+
if (importer !== void 0 && node.normalizePath(importer).includes(`${_package.name}/dist`)) {
|
|
85
|
+
return this.resolve("react-native-web");
|
|
86
|
+
}
|
|
87
|
+
return componentPath;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}]
|
|
91
|
+
};
|
|
92
|
+
const uniwind = (config$1) => {
|
|
93
|
+
const bundlerConfig = config.UniwindBundlerConfig.fromViteConfig(config$1);
|
|
34
94
|
return {
|
|
35
95
|
name: "uniwind",
|
|
36
96
|
enforce: "pre",
|
|
37
97
|
resolveId: (source, importer) => {
|
|
38
|
-
|
|
39
|
-
const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
|
|
40
|
-
if (isTarget && importer !== void 0 && node.normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
41
|
-
return styleSheetPath;
|
|
42
|
-
}
|
|
98
|
+
return resolveOrderedCSSStyleSheet(source, importer);
|
|
43
99
|
},
|
|
44
100
|
config: () => ({
|
|
45
101
|
css: {
|
|
46
102
|
transformer: "lightningcss",
|
|
47
103
|
lightningcss: {
|
|
48
|
-
visitor:
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
optimizeDeps: {
|
|
52
|
-
exclude: [common.name, "react-native"],
|
|
53
|
-
esbuildOptions: {
|
|
54
|
-
plugins: [{
|
|
55
|
-
name: "uniwind-esbuild-plugin",
|
|
56
|
-
setup: (build) => {
|
|
57
|
-
build.onResolve(
|
|
58
|
-
{ filter: /^\.\/createOrderedCSSStyleSheet$/ },
|
|
59
|
-
(args) => {
|
|
60
|
-
if (node.normalizePath(args.importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
61
|
-
return { path: styleSheetPath };
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
}]
|
|
104
|
+
visitor: bundlerConfig.cssVisitor
|
|
67
105
|
}
|
|
68
106
|
},
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
{
|
|
72
|
-
find: /^react-native$/,
|
|
73
|
-
replacement: componentPath,
|
|
74
|
-
customResolver: {
|
|
75
|
-
resolveId(_, importer) {
|
|
76
|
-
if (importer !== void 0 && node.normalizePath(importer).includes(`${common.name}/dist`)) {
|
|
77
|
-
return this.resolve("react-native-web");
|
|
78
|
-
}
|
|
79
|
-
return componentPath;
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
]
|
|
84
|
-
}
|
|
107
|
+
optimizeDeps: isVite8 ? vite8OptimizeDeps : vite7OptimizeDeps,
|
|
108
|
+
resolve: isVite8 ? vite8Resolve : vite7Resolve
|
|
85
109
|
}),
|
|
86
110
|
transform: (code, id) => {
|
|
87
111
|
const normalizedId = node.normalizePath(id);
|
|
88
|
-
if (normalizedId.includes(`${
|
|
112
|
+
if (normalizedId.includes(`${_package.name}/dist`) && normalizedId.includes("config/config.js")) {
|
|
89
113
|
return {
|
|
90
|
-
code: `${code}
|
|
114
|
+
code: `${code}
|
|
115
|
+
;Uniwind.__reinit(() => ({}), ${bundlerConfig.stringifiedThemes})`
|
|
91
116
|
};
|
|
92
117
|
}
|
|
93
118
|
},
|
|
94
119
|
buildStart: async () => {
|
|
95
|
-
await
|
|
96
|
-
stringifyThemes.buildDtsFile(dtsFile, stringifiedThemes);
|
|
120
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
97
121
|
},
|
|
98
122
|
generateBundle: async () => {
|
|
99
|
-
await
|
|
100
|
-
stringifyThemes.buildDtsFile(dtsFile, stringifiedThemes);
|
|
123
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
101
124
|
}
|
|
102
125
|
};
|
|
103
126
|
};
|
package/dist/vite/index.mjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { normalizePath } from '@tailwindcss/node';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
2
3
|
import path from 'path';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
4
|
+
import { n as name } from '../shared/uniwind.CFAAUZ2t.mjs';
|
|
5
|
+
import { U as UniwindBundlerConfig } from '../shared/uniwind.DgC4MT51.mjs';
|
|
5
6
|
import 'fs';
|
|
6
7
|
import 'lightningcss';
|
|
7
8
|
|
|
@@ -14,84 +15,105 @@ const styleSheetPath = path.resolve(
|
|
|
14
15
|
dirname,
|
|
15
16
|
"../module/components/web/createOrderedCSSStyleSheet.js"
|
|
16
17
|
);
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
18
|
+
const cssArtifactPath = path.resolve(dirname, "../../uniwind.css");
|
|
19
|
+
const require = createRequire(import.meta.url);
|
|
20
|
+
const viteVersion = require("vite/package.json").version;
|
|
21
|
+
const isVite8 = Number(viteVersion.split(".")[0]) >= 8;
|
|
22
|
+
const resolveOrderedCSSStyleSheet = (source, importer) => {
|
|
23
|
+
const normalizedSource = normalizePath(source);
|
|
24
|
+
const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
|
|
25
|
+
if (isTarget && importer !== void 0 && normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
26
|
+
return styleSheetPath;
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const vite8OptimizeDeps = {
|
|
30
|
+
exclude: [name, "react-native"],
|
|
31
|
+
rolldownOptions: {
|
|
32
|
+
plugins: [{
|
|
33
|
+
name: "uniwind-rolldown-plugin",
|
|
34
|
+
resolveId: resolveOrderedCSSStyleSheet
|
|
35
|
+
}]
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const vite7OptimizeDeps = {
|
|
39
|
+
exclude: [name, "react-native"],
|
|
40
|
+
esbuildOptions: {
|
|
41
|
+
plugins: [{
|
|
42
|
+
name: "uniwind-esbuild-plugin",
|
|
43
|
+
setup: (build) => {
|
|
44
|
+
build.onResolve(
|
|
45
|
+
{ filter: /^\.\/createOrderedCSSStyleSheet$/ },
|
|
46
|
+
(args) => {
|
|
47
|
+
const resolved = resolveOrderedCSSStyleSheet(args.path, args.importer);
|
|
48
|
+
if (resolved !== void 0) {
|
|
49
|
+
return { path: resolved };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
}]
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const vite8Resolve = {
|
|
58
|
+
alias: [{
|
|
59
|
+
find: /^react-native$/,
|
|
60
|
+
replacement: componentPath,
|
|
61
|
+
customResolver: {
|
|
62
|
+
resolveId(_, importer) {
|
|
63
|
+
if (importer !== void 0 && normalizePath(importer).includes(`${name}/dist`)) {
|
|
64
|
+
return this.resolve("react-native-web", importer, { skipSelf: true });
|
|
65
|
+
}
|
|
66
|
+
return componentPath;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}]
|
|
70
|
+
};
|
|
71
|
+
const vite7Resolve = {
|
|
72
|
+
alias: [{
|
|
73
|
+
find: /^react-native$/,
|
|
74
|
+
replacement: componentPath,
|
|
75
|
+
customResolver: {
|
|
76
|
+
resolveId(_, importer) {
|
|
77
|
+
if (importer !== void 0 && normalizePath(importer).includes(`${name}/dist`)) {
|
|
78
|
+
return this.resolve("react-native-web");
|
|
79
|
+
}
|
|
80
|
+
return componentPath;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}]
|
|
84
|
+
};
|
|
85
|
+
const uniwind = (config) => {
|
|
86
|
+
const bundlerConfig = UniwindBundlerConfig.fromViteConfig(config);
|
|
28
87
|
return {
|
|
29
88
|
name: "uniwind",
|
|
30
89
|
enforce: "pre",
|
|
31
90
|
resolveId: (source, importer) => {
|
|
32
|
-
|
|
33
|
-
const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
|
|
34
|
-
if (isTarget && importer !== void 0 && normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
35
|
-
return styleSheetPath;
|
|
36
|
-
}
|
|
91
|
+
return resolveOrderedCSSStyleSheet(source, importer);
|
|
37
92
|
},
|
|
38
93
|
config: () => ({
|
|
39
94
|
css: {
|
|
40
95
|
transformer: "lightningcss",
|
|
41
96
|
lightningcss: {
|
|
42
|
-
visitor:
|
|
43
|
-
}
|
|
44
|
-
},
|
|
45
|
-
optimizeDeps: {
|
|
46
|
-
exclude: [name, "react-native"],
|
|
47
|
-
esbuildOptions: {
|
|
48
|
-
plugins: [{
|
|
49
|
-
name: "uniwind-esbuild-plugin",
|
|
50
|
-
setup: (build) => {
|
|
51
|
-
build.onResolve(
|
|
52
|
-
{ filter: /^\.\/createOrderedCSSStyleSheet$/ },
|
|
53
|
-
(args) => {
|
|
54
|
-
if (normalizePath(args.importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
55
|
-
return { path: styleSheetPath };
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
);
|
|
59
|
-
}
|
|
60
|
-
}]
|
|
97
|
+
visitor: bundlerConfig.cssVisitor
|
|
61
98
|
}
|
|
62
99
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
find: /^react-native$/,
|
|
67
|
-
replacement: componentPath,
|
|
68
|
-
customResolver: {
|
|
69
|
-
resolveId(_, importer) {
|
|
70
|
-
if (importer !== void 0 && normalizePath(importer).includes(`${name}/dist`)) {
|
|
71
|
-
return this.resolve("react-native-web");
|
|
72
|
-
}
|
|
73
|
-
return componentPath;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
]
|
|
78
|
-
}
|
|
100
|
+
optimizeDeps: isVite8 ? vite8OptimizeDeps : vite7OptimizeDeps,
|
|
101
|
+
resolve: isVite8 ? vite8Resolve : vite7Resolve
|
|
79
102
|
}),
|
|
80
103
|
transform: (code, id) => {
|
|
81
104
|
const normalizedId = normalizePath(id);
|
|
82
105
|
if (normalizedId.includes(`${name}/dist`) && normalizedId.includes("config/config.js")) {
|
|
83
106
|
return {
|
|
84
|
-
code: `${code}
|
|
107
|
+
code: `${code}
|
|
108
|
+
;Uniwind.__reinit(() => ({}), ${bundlerConfig.stringifiedThemes})`
|
|
85
109
|
};
|
|
86
110
|
}
|
|
87
111
|
},
|
|
88
112
|
buildStart: async () => {
|
|
89
|
-
await
|
|
90
|
-
buildDtsFile(dtsFile, stringifiedThemes);
|
|
113
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
91
114
|
},
|
|
92
115
|
generateBundle: async () => {
|
|
93
|
-
await
|
|
94
|
-
buildDtsFile(dtsFile, stringifiedThemes);
|
|
116
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
95
117
|
}
|
|
96
118
|
};
|
|
97
119
|
};
|
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"private": false,
|
|
3
3
|
"name": "@niibase/uniwind",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.8.0",
|
|
5
5
|
"description": "A fork of Uniwind with Reanimated 4 support",
|
|
6
6
|
"homepage": "https://uniwind.dev",
|
|
7
7
|
"author": "Unistack",
|
|
8
8
|
"type": "module",
|
|
9
|
+
"bin": {
|
|
10
|
+
"uniwind": "./dist/cli/index.mjs"
|
|
11
|
+
},
|
|
9
12
|
"repository": "https://github.com/divineniiquaye/uniwind-oss",
|
|
10
13
|
"sideEffects": false,
|
|
11
14
|
"scripts": {
|
|
@@ -22,7 +25,7 @@
|
|
|
22
25
|
"test:native": "jest --config jest.config.native.js",
|
|
23
26
|
"test:web": "jest --config jest.config.web.js",
|
|
24
27
|
"test:types": "tsc --project tests/type-test/tsconfig.json",
|
|
25
|
-
"test:e2e": "playwright test",
|
|
28
|
+
"test:e2e": "bun --bun playwright test",
|
|
26
29
|
"release": "release-it"
|
|
27
30
|
},
|
|
28
31
|
"keywords": [
|
|
@@ -83,8 +86,8 @@
|
|
|
83
86
|
"LICENSE"
|
|
84
87
|
],
|
|
85
88
|
"dependencies": {
|
|
86
|
-
"@tailwindcss/node": "4.
|
|
87
|
-
"@tailwindcss/oxide": "4.
|
|
89
|
+
"@tailwindcss/node": "4.3.0",
|
|
90
|
+
"@tailwindcss/oxide": "4.3.0",
|
|
88
91
|
"culori": "4.0.2",
|
|
89
92
|
"lightningcss": "1.30.1"
|
|
90
93
|
},
|
|
@@ -94,35 +97,48 @@
|
|
|
94
97
|
"react-native-gesture-handler": ">=2.28.0",
|
|
95
98
|
"react-native-reanimated": ">=4",
|
|
96
99
|
"react-native-safe-area-context": ">=5.6.0",
|
|
97
|
-
"tailwindcss": ">=4"
|
|
100
|
+
"tailwindcss": ">=4",
|
|
101
|
+
"metro": "*",
|
|
102
|
+
"metro-cache": "*",
|
|
103
|
+
"@expo/metro-config": "*",
|
|
104
|
+
"metro-transform-worker": "*"
|
|
105
|
+
},
|
|
106
|
+
"peerDependenciesMeta": {
|
|
107
|
+
"@expo/metro-config": {
|
|
108
|
+
"optional": true
|
|
109
|
+
},
|
|
110
|
+
"metro-transform-worker": {
|
|
111
|
+
"optional": true
|
|
112
|
+
}
|
|
98
113
|
},
|
|
99
114
|
"devDependencies": {
|
|
100
|
-
"@playwright/test": "1.
|
|
101
|
-
"@react-native/babel-preset": "0.
|
|
115
|
+
"@playwright/test": "1.60.0",
|
|
116
|
+
"@react-native/babel-preset": "0.85.3",
|
|
117
|
+
"@react-native/jest-preset": "0.85.3",
|
|
118
|
+
"@swc/core": "1.15.33",
|
|
119
|
+
"@swc/jest": "0.2.39",
|
|
102
120
|
"@testing-library/jest-dom": "6.9.1",
|
|
103
121
|
"@testing-library/jest-native": "5.4.3",
|
|
104
122
|
"@testing-library/react": "16.3.2",
|
|
105
123
|
"@testing-library/react-native": "13.3.3",
|
|
106
124
|
"@types/bun": "catalog:",
|
|
107
125
|
"@types/culori": "4.0.1",
|
|
108
|
-
"@types/jest": "
|
|
126
|
+
"@types/jest": "29.5.14",
|
|
109
127
|
"@types/react": "catalog:",
|
|
110
|
-
"dpdm": "4.0
|
|
111
|
-
"git-cliff": "2.
|
|
112
|
-
"jest": "
|
|
113
|
-
"jest-environment-jsdom": "
|
|
114
|
-
"metro": "0.84.
|
|
115
|
-
"prettier": "3.8.
|
|
116
|
-
"react-native-gesture-handler": "2.
|
|
128
|
+
"dpdm": "4.2.0",
|
|
129
|
+
"git-cliff": "2.13.1",
|
|
130
|
+
"jest": "29.7.0",
|
|
131
|
+
"jest-environment-jsdom": "29.7.0",
|
|
132
|
+
"metro": "0.84.4",
|
|
133
|
+
"prettier": "3.8.3",
|
|
134
|
+
"react-native-gesture-handler": "2.31.2",
|
|
117
135
|
"react-native-reanimated": "catalog:",
|
|
118
|
-
"react-native-safe-area-context": "5.
|
|
136
|
+
"react-native-safe-area-context": "5.7.0",
|
|
119
137
|
"react-native-web": "catalog:",
|
|
120
|
-
"react-test-renderer": "19.2.
|
|
121
|
-
"release-it": "
|
|
122
|
-
"ts-jest": "29.4.6",
|
|
138
|
+
"react-test-renderer": "19.2.3",
|
|
139
|
+
"release-it": "20.0.1",
|
|
123
140
|
"typescript": "catalog:",
|
|
124
141
|
"unbuild": "3.6.1",
|
|
125
|
-
"vite": "catalog:"
|
|
126
|
-
"esbuild": "0.27.3"
|
|
142
|
+
"vite": "catalog:"
|
|
127
143
|
}
|
|
128
144
|
}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './metro'
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { UniwindBundlerConfig } from '@/bundler/config'
|
|
2
|
+
import type { UniwindConfig } from '@/bundler/types'
|
|
3
|
+
import { Platform } from '@/common/consts'
|
|
4
|
+
import type { MetroConfig } from 'metro-config'
|
|
5
|
+
import type { CustomResolver } from 'metro-resolver'
|
|
6
|
+
import { join } from 'node:path'
|
|
7
|
+
import { name as UNIWIND_PACKAGE_NAME } from '../../../../package.json'
|
|
8
|
+
import { cacheStore, patchMetroGraphToSupportUncachedModules } from './patches'
|
|
9
|
+
import { nativeResolver, webResolver } from './resolvers'
|
|
10
|
+
|
|
11
|
+
const isUniwindRequest = (moduleName: string) => moduleName === UNIWIND_PACKAGE_NAME || moduleName.startsWith(`${UNIWIND_PACKAGE_NAME}/`)
|
|
12
|
+
|
|
13
|
+
export const withUniwindConfig = <T extends MetroConfig>(
|
|
14
|
+
config: T,
|
|
15
|
+
uniwindConfig: UniwindConfig,
|
|
16
|
+
): T => {
|
|
17
|
+
const bundlerConfig = UniwindBundlerConfig.fromMetroConfig(uniwindConfig)
|
|
18
|
+
const pinnedUniwindOrigin = join(config.projectRoot ?? process.cwd(), 'package.json')
|
|
19
|
+
|
|
20
|
+
patchMetroGraphToSupportUncachedModules()
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
...config,
|
|
24
|
+
cacheStores: [cacheStore],
|
|
25
|
+
transformerPath: require.resolve('./transformer.cjs'),
|
|
26
|
+
transformer: {
|
|
27
|
+
...config.transformer,
|
|
28
|
+
uniwind: bundlerConfig.toMetroConfig(),
|
|
29
|
+
},
|
|
30
|
+
resolver: {
|
|
31
|
+
...config.resolver,
|
|
32
|
+
sourceExts: [
|
|
33
|
+
...config.resolver?.sourceExts ?? [],
|
|
34
|
+
'css',
|
|
35
|
+
],
|
|
36
|
+
assetExts: config.resolver?.assetExts?.filter(
|
|
37
|
+
ext => ext !== 'css',
|
|
38
|
+
),
|
|
39
|
+
resolveRequest: (context, moduleName, platform) => {
|
|
40
|
+
const baseResolver = config.resolver?.resolveRequest ?? context.resolveRequest
|
|
41
|
+
const resolver: CustomResolver = (nextContext, nextModuleName, nextPlatform) => {
|
|
42
|
+
if (isUniwindRequest(nextModuleName)) {
|
|
43
|
+
return baseResolver(
|
|
44
|
+
{
|
|
45
|
+
...nextContext,
|
|
46
|
+
originModulePath: pinnedUniwindOrigin,
|
|
47
|
+
},
|
|
48
|
+
nextModuleName,
|
|
49
|
+
nextPlatform,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return baseResolver(nextContext, nextModuleName, nextPlatform)
|
|
54
|
+
}
|
|
55
|
+
const platformResolver = platform === Platform.Web ? webResolver : nativeResolver
|
|
56
|
+
const resolved = platformResolver(uniwindConfig.extraComponents ?? {})({
|
|
57
|
+
context,
|
|
58
|
+
moduleName,
|
|
59
|
+
platform,
|
|
60
|
+
resolver,
|
|
61
|
+
})
|
|
62
|
+
|
|
63
|
+
return resolved
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Graph, Result as GraphResult } from '@expo/metro/metro/DeltaBundler/Graph'
|
|
2
2
|
import FileStoreBase from 'metro-cache/private/stores/FileStore'
|
|
3
|
+
import type * as MetroGraphModule from 'metro/private/DeltaBundler/Graph'
|
|
3
4
|
import type { Options as GraphOptions } from 'metro/private/DeltaBundler/types'
|
|
4
5
|
import os from 'os'
|
|
5
6
|
import path from 'path'
|
|
@@ -24,7 +25,7 @@ interface TraverseDependencies {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
export const patchMetroGraphToSupportUncachedModules = () => {
|
|
27
|
-
const { Graph } = require('metro/private/DeltaBundler/Graph') as typeof
|
|
28
|
+
const { Graph } = require('metro/private/DeltaBundler/Graph') as typeof MetroGraphModule
|
|
28
29
|
|
|
29
30
|
// oxlint-disable-next-line @typescript-eslint/unbound-method
|
|
30
31
|
const original_traverseDependencies = Graph.prototype.traverseDependencies as unknown as TraverseDependencies
|
|
@@ -38,7 +39,7 @@ export const patchMetroGraphToSupportUncachedModules = () => {
|
|
|
38
39
|
function traverseDependencies(this: Graph, paths: Array<string>, options: GraphOptions<any>) {
|
|
39
40
|
this.dependencies.forEach(dependency => {
|
|
40
41
|
if (
|
|
41
|
-
dependency.output.find(file => file.data
|
|
42
|
+
dependency.output.find(file => (file.data as any)?.css?.skipCache === true)
|
|
42
43
|
&& !paths.includes(dependency.path)
|
|
43
44
|
) {
|
|
44
45
|
// @ts-expect-error Hidden property
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CustomResolutionContext, CustomResolver } from 'metro-resolver'
|
|
1
|
+
import type { CustomResolutionContext, CustomResolver } from 'metro-resolver'
|
|
2
2
|
import { basename, dirname, sep } from 'node:path'
|
|
3
|
-
import { name } from '
|
|
3
|
+
import { name as UNIWIND_PACKAGE_NAME } from '../../../../package.json'
|
|
4
4
|
|
|
5
5
|
type ResolverConfig = {
|
|
6
6
|
platform: string | null
|
|
@@ -48,7 +48,7 @@ export const nativeResolver = (extraComponents: Record<string, string>) =>
|
|
|
48
48
|
|
|
49
49
|
if (cachedInternalBasePath === null) {
|
|
50
50
|
try {
|
|
51
|
-
cachedInternalBasePath = dirname(require.resolve(`${
|
|
51
|
+
cachedInternalBasePath = dirname(require.resolve(`${UNIWIND_PACKAGE_NAME}/package.json`))
|
|
52
52
|
} catch {
|
|
53
53
|
cachedInternalBasePath = ''
|
|
54
54
|
}
|
|
@@ -69,11 +69,11 @@ export const nativeResolver = (extraComponents: Record<string, string>) =>
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
if (moduleName === 'react-native') {
|
|
72
|
-
return resolver(context, `${
|
|
72
|
+
return resolver(context, `${UNIWIND_PACKAGE_NAME}/components`, platform)
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
if (moduleName === 'react-native-gesture-handler') {
|
|
76
|
-
return resolver(context, `${
|
|
76
|
+
return resolver(context, `${UNIWIND_PACKAGE_NAME}/components/react-native-gesture-handler`, platform)
|
|
77
77
|
}
|
|
78
78
|
|
|
79
79
|
if (
|
|
@@ -83,7 +83,7 @@ export const nativeResolver = (extraComponents: Record<string, string>) =>
|
|
|
83
83
|
const module = filename.split('.').at(0)
|
|
84
84
|
|
|
85
85
|
if (module !== undefined && SUPPORTED_COMPONENTS.includes(module)) {
|
|
86
|
-
return resolver(context, `${
|
|
86
|
+
return resolver(context, `${UNIWIND_PACKAGE_NAME}/components/${module}`, platform)
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -106,7 +106,7 @@ export const webResolver = (extraComponents: Record<string, string>) =>
|
|
|
106
106
|
|
|
107
107
|
if (cachedInternalBasePath === null) {
|
|
108
108
|
try {
|
|
109
|
-
cachedInternalBasePath = dirname(require.resolve(`${
|
|
109
|
+
cachedInternalBasePath = dirname(require.resolve(`${UNIWIND_PACKAGE_NAME}/package.json`))
|
|
110
110
|
} catch {
|
|
111
111
|
cachedInternalBasePath = ''
|
|
112
112
|
}
|
|
@@ -139,5 +139,5 @@ export const webResolver = (extraComponents: Record<string, string>) =>
|
|
|
139
139
|
return resolution
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
return resolver(context, `${
|
|
142
|
+
return resolver(context, `${UNIWIND_PACKAGE_NAME}/components/${module}`, platform)
|
|
143
143
|
}
|