@niibase/uniwind 1.6.4 → 1.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/dist/common/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/common/{css → bundler/artifacts/css}/themes.js +1 -1
- package/dist/common/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +1 -2
- package/dist/common/bundler/config.js +69 -0
- package/dist/common/bundler/css-compiler/compileCSS.js +18 -0
- package/dist/common/bundler/css-compiler/compileNativeCSS.js +19 -0
- package/dist/common/bundler/css-compiler/compileTailwind.js +27 -0
- package/dist/common/bundler/css-compiler/compileWebCSS.js +15 -0
- package/dist/common/{vite → bundler/css-compiler}/index.js +4 -4
- package/dist/common/bundler/css-processor/addMetaToStylesTemplate.js +130 -0
- package/dist/common/bundler/css-processor/animation.js +112 -0
- package/dist/common/bundler/css-processor/color.js +66 -0
- package/dist/common/bundler/css-processor/css.js +510 -0
- package/dist/common/bundler/css-processor/functions.js +145 -0
- package/dist/common/bundler/css-processor/index.js +38 -0
- package/dist/common/bundler/css-processor/mq.js +87 -0
- package/dist/common/bundler/css-processor/processor.js +353 -0
- package/dist/common/bundler/css-processor/rn.js +356 -0
- package/dist/common/bundler/css-processor/serialize.js +86 -0
- package/dist/common/bundler/css-processor/types.js +1 -0
- package/dist/common/bundler/css-processor/units.js +55 -0
- package/dist/common/bundler/css-processor/utils.js +63 -0
- package/dist/common/bundler/css-processor/var.js +20 -0
- package/dist/common/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
- package/dist/common/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/common/bundler/logger.js +41 -0
- package/dist/common/bundler/types.js +1 -0
- package/dist/common/common/consts.js +26 -2
- package/dist/common/components/web/rnw.js +2 -2
- package/dist/common/core/config/config.common.js +9 -9
- package/dist/common/core/config/config.js +2 -2
- package/dist/common/core/config/config.native.js +3 -3
- package/dist/common/core/listener.js +10 -10
- package/dist/common/core/native/runtime.js +7 -3
- package/dist/common/core/native/store.js +3 -4
- package/dist/common/core/web/cssListener.js +2 -2
- package/dist/common/hoc/withUniwind.js +5 -5
- package/dist/common/hoc/withUniwind.native.js +5 -5
- package/dist/common/hooks/useCSSVariable/useCSSVariable.js +6 -2
- package/dist/common/hooks/useUniwind.js +2 -2
- package/dist/metro/index.cjs +14 -24
- package/dist/metro/index.d.ts +2 -0
- package/dist/metro/index.mjs +7 -17
- package/dist/metro/{metro-transformer.cjs → transformer.cjs} +294 -174
- package/dist/metro/{metro-transformer.mjs → transformer.mjs} +236 -116
- package/dist/module/{css → bundler/artifacts/css}/index.d.ts +1 -1
- package/dist/module/{css → bundler/artifacts/css}/index.js +1 -4
- package/dist/module/{css → bundler/artifacts/css}/themes.js +1 -1
- package/dist/module/{utils/buildDtsFile.js → bundler/artifacts/dts.js} +3 -4
- package/dist/module/bundler/config.d.ts +16 -0
- package/dist/module/bundler/config.js +69 -0
- package/dist/module/bundler/css-compiler/compileCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileCSS.js +11 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileNativeCSS.js +33 -0
- package/dist/module/bundler/css-compiler/compileTailwind.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileTailwind.js +22 -0
- package/dist/module/bundler/css-compiler/compileWebCSS.d.ts +2 -0
- package/dist/module/bundler/css-compiler/compileWebCSS.js +8 -0
- package/dist/module/bundler/css-compiler/index.d.ts +1 -0
- package/dist/module/bundler/css-compiler/index.js +1 -0
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.d.ts +3 -0
- package/dist/module/bundler/css-processor/addMetaToStylesTemplate.js +136 -0
- package/dist/module/bundler/css-processor/animation.d.ts +6 -0
- package/dist/module/bundler/css-processor/animation.js +112 -0
- package/dist/module/bundler/css-processor/color.d.ts +12 -0
- package/dist/module/bundler/css-processor/color.js +63 -0
- package/dist/module/bundler/css-processor/css.d.ts +23 -0
- package/dist/module/bundler/css-processor/css.js +566 -0
- package/dist/module/bundler/css-processor/functions.d.ts +12 -0
- package/dist/module/bundler/css-processor/functions.js +190 -0
- package/dist/module/bundler/css-processor/index.d.ts +3 -0
- package/dist/module/bundler/css-processor/index.js +3 -0
- package/dist/module/bundler/css-processor/mq.d.ts +12 -0
- package/dist/module/bundler/css-processor/mq.js +78 -0
- package/dist/module/bundler/css-processor/processor.d.ts +36 -0
- package/dist/module/bundler/css-processor/processor.js +336 -0
- package/dist/module/bundler/css-processor/rn.d.ts +10 -0
- package/dist/module/bundler/css-processor/rn.js +400 -0
- package/dist/module/bundler/css-processor/serialize.d.ts +2 -0
- package/dist/module/bundler/css-processor/serialize.js +101 -0
- package/dist/module/bundler/css-processor/types.d.ts +28 -0
- package/dist/module/bundler/css-processor/types.js +0 -0
- package/dist/module/bundler/css-processor/units.d.ts +10 -0
- package/dist/module/bundler/css-processor/units.js +48 -0
- package/dist/module/bundler/css-processor/utils.d.ts +24 -0
- package/dist/{shared/uniwind.PtWWxxnh.mjs → module/bundler/css-processor/utils.js} +11 -15
- package/dist/module/bundler/css-processor/var.d.ts +7 -0
- package/dist/module/bundler/css-processor/var.js +13 -0
- package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.d.ts +1 -1
- package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.d.ts +4 -3
- package/dist/module/{css-visitor → bundler/css-visitor}/rule-visitor.js +5 -5
- package/dist/module/{css-visitor → bundler/css-visitor}/visitor.d.ts +3 -3
- package/dist/module/{css-visitor → bundler/css-visitor}/visitor.js +5 -6
- package/dist/module/bundler/logger.d.ts +11 -0
- package/dist/module/bundler/logger.js +34 -0
- package/dist/module/bundler/types.d.ts +15 -0
- package/dist/module/bundler/types.js +0 -0
- package/dist/module/common/consts.d.ts +21 -0
- package/dist/module/common/consts.js +24 -0
- package/dist/module/components/ScopedTheme/ScopedTheme.native.d.ts +1 -1
- package/dist/module/components/native/Pressable.d.ts +1 -1
- package/dist/module/components/native/TouchableHighlight.d.ts +1 -1
- package/dist/module/components/native/TouchableOpacity.d.ts +1 -1
- package/dist/module/components/native/useAccentColor.d.ts +1 -1
- package/dist/module/components/native/useStyle.d.ts +2 -2
- package/dist/module/components/react-native-gesture-handler/native/BaseButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/BorderlessButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/DrawerLayoutAndroid.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/FlatList.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Pressable.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/PureNativeButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RawButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RectButton.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/RefreshControl.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/ScrollView.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/Switch.d.ts +1 -1
- package/dist/module/components/react-native-gesture-handler/native/TextInput.d.ts +1 -1
- package/dist/module/components/web/Pressable.d.ts +1 -1
- package/dist/module/components/web/TouchableHighlight.d.ts +1 -1
- package/dist/module/components/web/TouchableOpacity.d.ts +1 -1
- package/dist/module/components/web/rnw.js +1 -1
- package/dist/module/core/config/config.common.d.ts +6 -7
- package/dist/module/core/config/config.common.js +2 -2
- package/dist/module/core/config/config.d.ts +1 -1
- package/dist/module/core/config/config.js +1 -1
- package/dist/module/core/config/config.native.d.ts +2 -2
- package/dist/module/core/config/config.native.js +1 -1
- package/dist/module/core/listener.d.ts +1 -1
- package/dist/module/core/listener.js +1 -1
- package/dist/module/core/native/runtime.js +5 -1
- package/dist/module/core/native/store.d.ts +2 -2
- package/dist/module/core/native/store.js +1 -2
- package/dist/module/core/types.d.ts +6 -3
- package/dist/module/core/web/cssListener.js +1 -1
- package/dist/module/core/web/getWebStyles.d.ts +1 -1
- package/dist/module/hoc/types.d.ts +2 -2
- package/dist/module/hoc/withUniwind.d.ts +1 -1
- package/dist/module/hoc/withUniwind.js +5 -5
- package/dist/module/hoc/withUniwind.native.d.ts +1 -1
- package/dist/module/hoc/withUniwind.native.js +5 -5
- package/dist/module/hooks/useCSSVariable/getVariableValue.native.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.d.ts +1 -1
- package/dist/module/hooks/useCSSVariable/useCSSVariable.js +5 -1
- package/dist/module/hooks/useResolveClassNames.d.ts +1 -1
- package/dist/module/hooks/useUniwind.d.ts +1 -1
- package/dist/module/hooks/useUniwind.js +1 -1
- package/dist/module/index.d.ts +1 -2
- package/dist/shared/{uniwind.r2i22V6d.cjs → uniwind.CFiAZ3D-.cjs} +307 -217
- package/dist/shared/{uniwind.BGiqYvxb.mjs → uniwind.u-s1XVU8.mjs} +299 -214
- package/dist/vite/index.cjs +12 -22
- package/dist/vite/index.mjs +9 -19
- package/package.json +1 -1
- package/src/{metro → bundler/adapters/metro}/index.d.ts +2 -0
- package/src/bundler/adapters/metro/index.ts +1 -0
- package/src/{metro/withUniwindConfig.ts → bundler/adapters/metro/metro.ts} +7 -22
- package/src/{metro/metro-css-patches.ts → bundler/adapters/metro/patches.ts} +2 -1
- package/src/{metro → bundler/adapters/metro}/resolvers.ts +8 -8
- package/src/bundler/adapters/metro/transformer.ts +85 -0
- package/src/{vite → bundler/adapters/vite}/vite.ts +10 -28
- package/src/{css → bundler/artifacts/css}/extraUtilities.ts +1 -1
- package/src/{css → bundler/artifacts/css}/index.ts +1 -5
- package/src/{css → bundler/artifacts/css}/themes.ts +1 -1
- package/src/{utils/buildDtsFile.ts → bundler/artifacts/dts.ts} +3 -4
- package/src/bundler/config.ts +84 -0
- package/src/bundler/css-compiler/compileCSS.ts +15 -0
- package/src/bundler/css-compiler/compileNativeCSS.ts +41 -0
- package/src/bundler/css-compiler/compileTailwind.ts +25 -0
- package/src/bundler/css-compiler/compileWebCSS.ts +10 -0
- package/src/bundler/css-compiler/index.ts +1 -0
- package/src/{metro → bundler/css-processor}/addMetaToStylesTemplate.ts +33 -14
- package/src/{metro/processor → bundler/css-processor}/animation.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/color.ts +4 -3
- package/src/{metro/processor → bundler/css-processor}/css.ts +17 -9
- package/src/{metro/processor → bundler/css-processor}/functions.ts +2 -2
- package/src/bundler/css-processor/index.ts +3 -0
- package/src/{metro/processor → bundler/css-processor}/mq.ts +4 -4
- package/src/{metro/processor → bundler/css-processor}/processor.ts +13 -11
- package/src/{metro/processor → bundler/css-processor}/rn.ts +96 -3
- package/src/{metro/utils → bundler/css-processor}/serialize.ts +2 -2
- package/src/{metro → bundler/css-processor}/types.ts +3 -17
- package/src/{metro/processor → bundler/css-processor}/units.ts +1 -1
- package/src/{metro/processor → bundler/css-processor}/var.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/function-visitor.ts +1 -1
- package/src/{css-visitor → bundler/css-visitor}/rule-visitor.ts +6 -5
- package/src/{css-visitor → bundler/css-visitor}/visitor.ts +4 -3
- package/src/bundler/types.ts +17 -0
- package/src/common/consts.ts +25 -0
- package/src/components/ScopedTheme/ScopedTheme.native.tsx +1 -1
- package/src/components/native/ActivityIndicator.tsx +2 -1
- package/src/components/native/Button.tsx +2 -1
- package/src/components/native/FlatList.tsx +2 -1
- package/src/components/native/Image.tsx +2 -1
- package/src/components/native/ImageBackground.tsx +2 -1
- package/src/components/native/InputAccessoryView.tsx +3 -2
- package/src/components/native/KeyboardAvoidingView.tsx +2 -1
- package/src/components/native/Modal.tsx +2 -1
- package/src/components/native/Pressable.tsx +1 -1
- package/src/components/native/RefreshControl.tsx +2 -1
- package/src/components/native/SafeAreaView.tsx +2 -1
- package/src/components/native/ScrollView.tsx +2 -1
- package/src/components/native/SectionList.tsx +2 -1
- package/src/components/native/Switch.tsx +3 -2
- package/src/components/native/Text.tsx +3 -2
- package/src/components/native/TextInput.tsx +3 -2
- package/src/components/native/TouchableHighlight.tsx +3 -2
- package/src/components/native/TouchableNativeFeedback.tsx +3 -2
- package/src/components/native/TouchableOpacity.tsx +3 -2
- package/src/components/native/TouchableWithoutFeedback.tsx +3 -2
- package/src/components/native/View.tsx +2 -1
- package/src/components/native/VirtualizedList.tsx +2 -1
- package/src/components/native/useAccentColor.ts +1 -1
- package/src/components/native/useStyle.ts +2 -2
- package/src/components/react-native-gesture-handler/native/BaseButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/BorderlessButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/DrawerLayoutAndroid.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/FlatList.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/GestureHandlerRootView.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/Pressable.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/PureNativeButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RawButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RectButton.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/RefreshControl.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/ScrollView.tsx +1 -1
- package/src/components/react-native-gesture-handler/native/Switch.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/Text.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TextInput.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableNativeFeedback.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableOpacity.tsx +2 -2
- package/src/components/react-native-gesture-handler/native/TouchableWithoutFeedback.tsx +2 -2
- package/src/components/web/ActivityIndicator.tsx +2 -1
- package/src/components/web/Button.tsx +2 -1
- package/src/components/web/FlatList.tsx +2 -1
- package/src/components/web/Image.tsx +2 -1
- package/src/components/web/ImageBackground.tsx +2 -1
- package/src/components/web/KeyboardAvoidingView.tsx +2 -1
- package/src/components/web/Modal.tsx +2 -1
- package/src/components/web/Pressable.tsx +2 -1
- package/src/components/web/RefreshControl.tsx +2 -1
- package/src/components/web/SafeAreaView.tsx +2 -1
- package/src/components/web/ScrollView.tsx +2 -1
- package/src/components/web/SectionList.tsx +2 -1
- package/src/components/web/Switch.tsx +2 -1
- package/src/components/web/Text.tsx +2 -1
- package/src/components/web/TextInput.tsx +2 -1
- package/src/components/web/TouchableHighlight.tsx +2 -1
- package/src/components/web/TouchableOpacity.tsx +2 -1
- package/src/components/web/TouchableWithoutFeedback.tsx +2 -1
- package/src/components/web/View.tsx +2 -1
- package/src/components/web/VirtualizedList.tsx +2 -1
- package/src/components/web/rnw.ts +1 -1
- package/src/core/config/config.common.ts +11 -9
- package/src/core/config/config.native.ts +3 -3
- package/src/core/config/config.ts +2 -2
- package/src/core/listener.ts +1 -1
- package/src/core/native/runtime.ts +7 -2
- package/src/core/native/store.ts +3 -4
- package/src/core/types.ts +6 -3
- package/src/core/web/cssListener.ts +1 -1
- package/src/core/web/getWebStyles.ts +1 -1
- package/src/hoc/types.ts +2 -2
- package/src/hoc/withUniwind.native.tsx +4 -3
- package/src/hoc/withUniwind.tsx +3 -2
- package/src/hooks/useCSSVariable/getVariableValue.native.ts +1 -1
- package/src/hooks/useCSSVariable/useCSSVariable.ts +8 -2
- package/src/hooks/useResolveClassNames.ts +1 -1
- package/src/hooks/useUniwind.ts +2 -2
- package/src/index.ts +1 -2
- package/dist/common/types.js +0 -28
- package/dist/common/utils/stringifyThemes.js +0 -8
- package/dist/common/vite/vite.js +0 -95
- package/dist/module/types.d.ts +0 -21
- package/dist/module/types.js +0 -22
- package/dist/module/utils/stringifyThemes.d.ts +0 -1
- package/dist/module/utils/stringifyThemes.js +0 -1
- package/dist/module/vite/index.d.ts +0 -9
- package/dist/module/vite/index.js +0 -1
- package/dist/module/vite/vite.d.ts +0 -8
- package/dist/module/vite/vite.js +0 -98
- package/dist/shared/uniwind.B5q8hBGv.cjs +0 -18
- package/dist/shared/uniwind.Cv73KtI-.cjs +0 -86
- package/dist/shared/uniwind.JSWK3vHl.mjs +0 -14
- package/src/metro/compileVirtual.ts +0 -85
- package/src/metro/index.ts +0 -1
- package/src/metro/injectThemes.ts +0 -23
- package/src/metro/metro-transformer.ts +0 -116
- package/src/metro/processor/index.ts +0 -1
- package/src/metro/utils/index.ts +0 -2
- package/src/types.ts +0 -23
- package/src/utils/stringifyThemes.ts +0 -1
- package/src/vite/index.d.ts +0 -9
- /package/dist/common/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/insets.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/overwrite.js +0 -0
- /package/dist/common/{css → bundler/artifacts/css}/variants.js +0 -0
- /package/dist/common/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
- /package/dist/common/{css-visitor → bundler/css-visitor}/index.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/extraUtilities.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/insets.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/insets.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/overwrite.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/overwrite.js +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/themes.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/variants.d.ts +0 -0
- /package/dist/module/{css → bundler/artifacts/css}/variants.js +0 -0
- /package/dist/module/{utils/buildDtsFile.d.ts → bundler/artifacts/dts.d.ts} +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/function-visitor.js +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/index.d.ts +0 -0
- /package/dist/module/{css-visitor → bundler/css-visitor}/index.js +0 -0
- /package/{dist/common → src/bundler/adapters}/vite/index.d.ts +0 -0
- /package/src/{vite → bundler/adapters/vite}/index.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/insets.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/overwrite.ts +0 -0
- /package/src/{css → bundler/artifacts/css}/variants.ts +0 -0
- /package/src/{metro/utils/common.ts → bundler/css-processor/utils.ts} +0 -0
- /package/src/{css-visitor → bundler/css-visitor}/index.ts +0 -0
- /package/src/{metro → bundler}/logger.ts +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useLayoutEffect, useReducer } from 'react'
|
|
2
2
|
import { useUniwindContext } from '../core/context'
|
|
3
|
-
import { RNStyle } from '../core/types'
|
|
3
|
+
import type { RNStyle } from '../core/types'
|
|
4
4
|
import { CSSListener, getWebStyles } from '../core/web'
|
|
5
5
|
|
|
6
6
|
const emptyState = {} as RNStyle
|
package/src/hooks/useUniwind.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { useLayoutEffect, useState } from 'react'
|
|
2
|
+
import { StyleDependency } from '../common/consts'
|
|
2
3
|
import { Uniwind } from '../core'
|
|
3
4
|
import { useUniwindContext } from '../core/context'
|
|
4
5
|
import { UniwindListener } from '../core/listener'
|
|
5
|
-
import { ThemeName } from '../core/types'
|
|
6
|
-
import { StyleDependency } from '../types'
|
|
6
|
+
import type { ThemeName } from '../core/types'
|
|
7
7
|
|
|
8
8
|
export const useUniwind = (): { theme: ThemeName; hasAdaptiveThemes: boolean } => {
|
|
9
9
|
const uniwindContext = useUniwindContext()
|
package/src/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
export * from './components/ScopedTheme'
|
|
2
2
|
export { Uniwind } from './core'
|
|
3
|
-
export type { ThemeName } from './core/types'
|
|
3
|
+
export type { ThemeName, UniwindConfig } from './core/types'
|
|
4
4
|
export { withUniwind } from './hoc'
|
|
5
5
|
export type { ApplyUniwind, ApplyUniwindOptions } from './hoc/types'
|
|
6
6
|
export { useCSSVariable, useResolveClassNames, useUniwind } from './hooks'
|
|
7
|
-
export type { UniwindConfig } from './types'
|
package/dist/common/types.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.StyleDependency = exports.Orientation = exports.ColorScheme = void 0;
|
|
7
|
-
var StyleDependency = exports.StyleDependency = /* @__PURE__ */(StyleDependency2 => {
|
|
8
|
-
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
9
|
-
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
10
|
-
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
11
|
-
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
12
|
-
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
13
|
-
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
14
|
-
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
15
|
-
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
16
|
-
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
17
|
-
return StyleDependency2;
|
|
18
|
-
})(StyleDependency || {});
|
|
19
|
-
var Orientation = exports.Orientation = /* @__PURE__ */(Orientation2 => {
|
|
20
|
-
Orientation2["Portrait"] = "portrait";
|
|
21
|
-
Orientation2["Landscape"] = "landscape";
|
|
22
|
-
return Orientation2;
|
|
23
|
-
})(Orientation || {});
|
|
24
|
-
var ColorScheme = exports.ColorScheme = /* @__PURE__ */(ColorScheme2 => {
|
|
25
|
-
ColorScheme2["Light"] = "light";
|
|
26
|
-
ColorScheme2["Dark"] = "dark";
|
|
27
|
-
return ColorScheme2;
|
|
28
|
-
})(ColorScheme || {});
|
package/dist/common/vite/vite.js
DELETED
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.uniwind = void 0;
|
|
7
|
-
var _node = require("@tailwindcss/node");
|
|
8
|
-
var _path = _interopRequireDefault(require("path"));
|
|
9
|
-
var _package = require("../../package.json");
|
|
10
|
-
var _css = require("../css");
|
|
11
|
-
var _cssVisitor = require("../css-visitor");
|
|
12
|
-
var _utils = require("../metro/utils");
|
|
13
|
-
var _buildDtsFile = require("../utils/buildDtsFile");
|
|
14
|
-
var _stringifyThemes = require("../utils/stringifyThemes");
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
|
-
const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
17
|
-
const componentPath = _path.default.resolve(dirname, "../module/components/web/index.js");
|
|
18
|
-
const styleSheetPath = _path.default.resolve(dirname, "../module/components/web/createOrderedCSSStyleSheet.js");
|
|
19
|
-
const uniwind = ({
|
|
20
|
-
cssEntryFile,
|
|
21
|
-
extraThemes,
|
|
22
|
-
dtsFile = "uniwind-types.d.ts"
|
|
23
|
-
}) => {
|
|
24
|
-
const themes = (0, _utils.uniq)(["light", "dark", ...(extraThemes ?? [])]);
|
|
25
|
-
const stringifiedThemes = (0, _stringifyThemes.stringifyThemes)(themes);
|
|
26
|
-
return {
|
|
27
|
-
name: "uniwind",
|
|
28
|
-
enforce: "pre",
|
|
29
|
-
resolveId: (source, importer) => {
|
|
30
|
-
const normalizedSource = (0, _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 && (0, _node.normalizePath)(importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
33
|
-
return styleSheetPath;
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
config: () => ({
|
|
37
|
-
css: {
|
|
38
|
-
transformer: "lightningcss",
|
|
39
|
-
lightningcss: {
|
|
40
|
-
visitor: new _cssVisitor.UniwindCSSVisitor(themes)
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
optimizeDeps: {
|
|
44
|
-
exclude: [_package.name, "react-native"],
|
|
45
|
-
esbuildOptions: {
|
|
46
|
-
plugins: [{
|
|
47
|
-
name: "uniwind-esbuild-plugin",
|
|
48
|
-
setup: build => {
|
|
49
|
-
build.onResolve({
|
|
50
|
-
filter: /^\.\/createOrderedCSSStyleSheet$/
|
|
51
|
-
}, args => {
|
|
52
|
-
if ((0, _node.normalizePath)(args.importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
53
|
-
return {
|
|
54
|
-
path: styleSheetPath
|
|
55
|
-
};
|
|
56
|
-
}
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
}]
|
|
60
|
-
}
|
|
61
|
-
},
|
|
62
|
-
resolve: {
|
|
63
|
-
alias: [{
|
|
64
|
-
find: /^react-native$/,
|
|
65
|
-
replacement: componentPath,
|
|
66
|
-
customResolver: {
|
|
67
|
-
resolveId(_, importer) {
|
|
68
|
-
if (importer !== void 0 && (0, _node.normalizePath)(importer).includes(`${_package.name}/dist`)) {
|
|
69
|
-
return this.resolve("react-native-web");
|
|
70
|
-
}
|
|
71
|
-
return componentPath;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
}]
|
|
75
|
-
}
|
|
76
|
-
}),
|
|
77
|
-
transform: (code, id) => {
|
|
78
|
-
const normalizedId = (0, _node.normalizePath)(id);
|
|
79
|
-
if (normalizedId.includes(`${_package.name}/dist`) && normalizedId.includes("config/config.js")) {
|
|
80
|
-
return {
|
|
81
|
-
code: `${code}Uniwind.__reinit(() => ({}), ${stringifiedThemes})`
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
},
|
|
85
|
-
buildStart: async () => {
|
|
86
|
-
await (0, _css.buildCSS)(themes, cssEntryFile);
|
|
87
|
-
(0, _buildDtsFile.buildDtsFile)(dtsFile, stringifiedThemes);
|
|
88
|
-
},
|
|
89
|
-
generateBundle: async () => {
|
|
90
|
-
await (0, _css.buildCSS)(themes, cssEntryFile);
|
|
91
|
-
(0, _buildDtsFile.buildDtsFile)(dtsFile, stringifiedThemes);
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
};
|
|
95
|
-
exports.uniwind = uniwind;
|
package/dist/module/types.d.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare enum StyleDependency {
|
|
2
|
-
ColorScheme = 1,
|
|
3
|
-
Theme = 2,
|
|
4
|
-
Dimensions = 3,
|
|
5
|
-
Orientation = 4,
|
|
6
|
-
Insets = 5,
|
|
7
|
-
FontScale = 6,
|
|
8
|
-
Rtl = 7,
|
|
9
|
-
AdaptiveThemes = 8,
|
|
10
|
-
Variables = 9
|
|
11
|
-
}
|
|
12
|
-
export declare const enum Orientation {
|
|
13
|
-
Portrait = "portrait",
|
|
14
|
-
Landscape = "landscape"
|
|
15
|
-
}
|
|
16
|
-
export declare const enum ColorScheme {
|
|
17
|
-
Light = "light",
|
|
18
|
-
Dark = "dark"
|
|
19
|
-
}
|
|
20
|
-
export interface UniwindConfig {
|
|
21
|
-
}
|
package/dist/module/types.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
|
|
2
|
-
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
3
|
-
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
4
|
-
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
5
|
-
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
6
|
-
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
7
|
-
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
8
|
-
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
9
|
-
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
10
|
-
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
11
|
-
return StyleDependency2;
|
|
12
|
-
})(StyleDependency || {});
|
|
13
|
-
export var Orientation = /* @__PURE__ */ ((Orientation2) => {
|
|
14
|
-
Orientation2["Portrait"] = "portrait";
|
|
15
|
-
Orientation2["Landscape"] = "landscape";
|
|
16
|
-
return Orientation2;
|
|
17
|
-
})(Orientation || {});
|
|
18
|
-
export var ColorScheme = /* @__PURE__ */ ((ColorScheme2) => {
|
|
19
|
-
ColorScheme2["Light"] = "light";
|
|
20
|
-
ColorScheme2["Dark"] = "dark";
|
|
21
|
-
return ColorScheme2;
|
|
22
|
-
})(ColorScheme || {});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const stringifyThemes: (themes?: Array<string>) => string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const stringifyThemes = (themes = []) => `[${themes.map((theme) => `'${theme}'`).join(", ")}]`;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./vite.js";
|
package/dist/module/vite/vite.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
import { normalizePath } from "@tailwindcss/node";
|
|
2
|
-
import path from "path";
|
|
3
|
-
import { name as UNIWIND_PACKAGE_NAME } from "../../package.json";
|
|
4
|
-
import { buildCSS } from "../css/index.js";
|
|
5
|
-
import { UniwindCSSVisitor } from "../css-visitor/index.js";
|
|
6
|
-
import { uniq } from "../metro/utils";
|
|
7
|
-
import { buildDtsFile } from "../utils/buildDtsFile.js";
|
|
8
|
-
import { stringifyThemes } from "../utils/stringifyThemes.js";
|
|
9
|
-
const dirname = typeof __dirname !== "undefined" ? __dirname : import.meta.dirname;
|
|
10
|
-
const componentPath = path.resolve(
|
|
11
|
-
dirname,
|
|
12
|
-
"../module/components/web/index.js"
|
|
13
|
-
);
|
|
14
|
-
const styleSheetPath = path.resolve(
|
|
15
|
-
dirname,
|
|
16
|
-
"../module/components/web/createOrderedCSSStyleSheet.js"
|
|
17
|
-
);
|
|
18
|
-
export const uniwind = ({
|
|
19
|
-
cssEntryFile,
|
|
20
|
-
extraThemes,
|
|
21
|
-
dtsFile = "uniwind-types.d.ts"
|
|
22
|
-
}) => {
|
|
23
|
-
const themes = uniq([
|
|
24
|
-
"light",
|
|
25
|
-
"dark",
|
|
26
|
-
...extraThemes ?? []
|
|
27
|
-
]);
|
|
28
|
-
const stringifiedThemes = stringifyThemes(themes);
|
|
29
|
-
return {
|
|
30
|
-
name: "uniwind",
|
|
31
|
-
enforce: "pre",
|
|
32
|
-
resolveId: (source, importer) => {
|
|
33
|
-
const normalizedSource = normalizePath(source);
|
|
34
|
-
const isTarget = source === "./createOrderedCSSStyleSheet" || normalizedSource.endsWith("react-native-web/dist/exports/StyleSheet/dom/createOrderedCSSStyleSheet.js");
|
|
35
|
-
if (isTarget && importer !== void 0 && normalizePath(importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
36
|
-
return styleSheetPath;
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
config: () => ({
|
|
40
|
-
css: {
|
|
41
|
-
transformer: "lightningcss",
|
|
42
|
-
lightningcss: {
|
|
43
|
-
visitor: new UniwindCSSVisitor(themes)
|
|
44
|
-
}
|
|
45
|
-
},
|
|
46
|
-
optimizeDeps: {
|
|
47
|
-
exclude: [UNIWIND_PACKAGE_NAME, "react-native"],
|
|
48
|
-
esbuildOptions: {
|
|
49
|
-
plugins: [{
|
|
50
|
-
name: "uniwind-esbuild-plugin",
|
|
51
|
-
setup: (build) => {
|
|
52
|
-
build.onResolve(
|
|
53
|
-
{ filter: /^\.\/createOrderedCSSStyleSheet$/ },
|
|
54
|
-
(args) => {
|
|
55
|
-
if (normalizePath(args.importer).includes("react-native-web/dist/exports/StyleSheet")) {
|
|
56
|
-
return { path: styleSheetPath };
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
}]
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
resolve: {
|
|
65
|
-
alias: [
|
|
66
|
-
{
|
|
67
|
-
find: /^react-native$/,
|
|
68
|
-
replacement: componentPath,
|
|
69
|
-
customResolver: {
|
|
70
|
-
resolveId(_, importer) {
|
|
71
|
-
if (importer !== void 0 && normalizePath(importer).includes(`${UNIWIND_PACKAGE_NAME}/dist`)) {
|
|
72
|
-
return this.resolve("react-native-web");
|
|
73
|
-
}
|
|
74
|
-
return componentPath;
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
}),
|
|
81
|
-
transform: (code, id) => {
|
|
82
|
-
const normalizedId = normalizePath(id);
|
|
83
|
-
if (normalizedId.includes(`${UNIWIND_PACKAGE_NAME}/dist`) && normalizedId.includes("config/config.js")) {
|
|
84
|
-
return {
|
|
85
|
-
code: `${code}Uniwind.__reinit(() => ({}), ${stringifiedThemes})`
|
|
86
|
-
};
|
|
87
|
-
}
|
|
88
|
-
},
|
|
89
|
-
buildStart: async () => {
|
|
90
|
-
await buildCSS(themes, cssEntryFile);
|
|
91
|
-
buildDtsFile(dtsFile, stringifiedThemes);
|
|
92
|
-
},
|
|
93
|
-
generateBundle: async () => {
|
|
94
|
-
await buildCSS(themes, cssEntryFile);
|
|
95
|
-
buildDtsFile(dtsFile, stringifiedThemes);
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
4
|
-
Platform2["Android"] = "android";
|
|
5
|
-
Platform2["iOS"] = "ios";
|
|
6
|
-
Platform2["Web"] = "web";
|
|
7
|
-
Platform2["Native"] = "native";
|
|
8
|
-
Platform2["TV"] = "tv";
|
|
9
|
-
Platform2["AndroidTV"] = "android-tv";
|
|
10
|
-
Platform2["AppleTV"] = "apple-tv";
|
|
11
|
-
return Platform2;
|
|
12
|
-
})(Platform || {});
|
|
13
|
-
const UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
14
|
-
const UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
15
|
-
|
|
16
|
-
exports.Platform = Platform;
|
|
17
|
-
exports.UNIWIND_PLATFORM_VARIABLES = UNIWIND_PLATFORM_VARIABLES;
|
|
18
|
-
exports.UNIWIND_THEME_VARIABLES = UNIWIND_THEME_VARIABLES;
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const name = "@niibase/uniwind";
|
|
4
|
-
|
|
5
|
-
const toCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
6
|
-
const pipe = (data) => ((...fns) => fns.reduce((acc, fn) => fn(acc), data));
|
|
7
|
-
const isNumber = (data) => {
|
|
8
|
-
if (typeof data === "number") {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
if (typeof data === "string" && data !== "") {
|
|
12
|
-
return !isNaN(Number(data));
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
};
|
|
16
|
-
const smartSplit = (str, separator = " ") => {
|
|
17
|
-
const escaper = "&&&";
|
|
18
|
-
return pipe(str)(
|
|
19
|
-
(x) => x.replace(/\s\?\?\s/g, `${escaper}??${escaper}`),
|
|
20
|
-
(x) => x.replace(/\s([+\-*/])\s/g, `${escaper}$1${escaper}`),
|
|
21
|
-
(x) => x.split(separator),
|
|
22
|
-
(x) => x.map((token) => token.replace(new RegExp(escaper, "g"), " "))
|
|
23
|
-
);
|
|
24
|
-
};
|
|
25
|
-
const addMissingSpaces = (str) => pipe(str)(
|
|
26
|
-
(x) => x.trim(),
|
|
27
|
-
(x) => x.replace(/([^ {])this/g, "$1 this"),
|
|
28
|
-
(x) => x.replace(/\](?=\d)/g, "] "),
|
|
29
|
-
(x) => x.replace(/\](?=")/g, "] "),
|
|
30
|
-
(x) => x.replace(/\)(?=\S)/g, ") "),
|
|
31
|
-
(x) => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" ')
|
|
32
|
-
);
|
|
33
|
-
const uniq = (arr) => Array.from(new Set(arr));
|
|
34
|
-
const isValidJSValue = (jsValueString) => {
|
|
35
|
-
try {
|
|
36
|
-
new Function(`const test = ${jsValueString}`);
|
|
37
|
-
return true;
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
const shouldBeSerialized = (value) => {
|
|
43
|
-
if (value.includes("-")) {
|
|
44
|
-
return value.split("-").some(shouldBeSerialized);
|
|
45
|
-
}
|
|
46
|
-
return [
|
|
47
|
-
isNumber(value),
|
|
48
|
-
value.startsWith("this["),
|
|
49
|
-
value.startsWith("rt."),
|
|
50
|
-
/[*/+-]/.test(value),
|
|
51
|
-
value.includes('"'),
|
|
52
|
-
value.includes(" "),
|
|
53
|
-
value === "(",
|
|
54
|
-
value === ")"
|
|
55
|
-
].some(Boolean);
|
|
56
|
-
};
|
|
57
|
-
const roundToPrecision = (value, precision) => parseFloat(value.toFixed(precision));
|
|
58
|
-
const deepEqual = (a, b) => {
|
|
59
|
-
if (Object.is(a, b)) {
|
|
60
|
-
return true;
|
|
61
|
-
}
|
|
62
|
-
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
const keysA = Object.keys(a);
|
|
66
|
-
if (keysA.length !== Object.keys(b).length) {
|
|
67
|
-
return false;
|
|
68
|
-
}
|
|
69
|
-
return keysA.every((key) => deepEqual(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key));
|
|
70
|
-
};
|
|
71
|
-
const removeKeys = (obj, keysToRemove) => Object.fromEntries(
|
|
72
|
-
Object.entries(obj).filter(([key]) => !keysToRemove.includes(key))
|
|
73
|
-
);
|
|
74
|
-
|
|
75
|
-
exports.addMissingSpaces = addMissingSpaces;
|
|
76
|
-
exports.deepEqual = deepEqual;
|
|
77
|
-
exports.isNumber = isNumber;
|
|
78
|
-
exports.isValidJSValue = isValidJSValue;
|
|
79
|
-
exports.name = name;
|
|
80
|
-
exports.pipe = pipe;
|
|
81
|
-
exports.removeKeys = removeKeys;
|
|
82
|
-
exports.roundToPrecision = roundToPrecision;
|
|
83
|
-
exports.shouldBeSerialized = shouldBeSerialized;
|
|
84
|
-
exports.smartSplit = smartSplit;
|
|
85
|
-
exports.toCamelCase = toCamelCase;
|
|
86
|
-
exports.uniq = uniq;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
var Platform = /* @__PURE__ */ ((Platform2) => {
|
|
2
|
-
Platform2["Android"] = "android";
|
|
3
|
-
Platform2["iOS"] = "ios";
|
|
4
|
-
Platform2["Web"] = "web";
|
|
5
|
-
Platform2["Native"] = "native";
|
|
6
|
-
Platform2["TV"] = "tv";
|
|
7
|
-
Platform2["AndroidTV"] = "android-tv";
|
|
8
|
-
Platform2["AppleTV"] = "apple-tv";
|
|
9
|
-
return Platform2;
|
|
10
|
-
})(Platform || {});
|
|
11
|
-
const UNIWIND_PLATFORM_VARIABLES = "__uniwind-platform-";
|
|
12
|
-
const UNIWIND_THEME_VARIABLES = "__uniwind-theme-";
|
|
13
|
-
|
|
14
|
-
export { Platform as P, UNIWIND_PLATFORM_VARIABLES as U, UNIWIND_THEME_VARIABLES as a };
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { compile } from '@tailwindcss/node'
|
|
2
|
-
import { Scanner } from '@tailwindcss/oxide'
|
|
3
|
-
import { transform } from 'lightningcss'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import { Platform } from '../common/consts'
|
|
6
|
-
import { UniwindCSSVisitor } from '../css-visitor'
|
|
7
|
-
import { addMetaToStylesTemplate } from './addMetaToStylesTemplate'
|
|
8
|
-
import { Logger } from './logger'
|
|
9
|
-
import { ProcessorBuilder } from './processor'
|
|
10
|
-
import { Polyfills } from './types'
|
|
11
|
-
import { serializeJSObject } from './utils'
|
|
12
|
-
|
|
13
|
-
type CompileVirtualConfig = {
|
|
14
|
-
cssPath: string
|
|
15
|
-
css: string
|
|
16
|
-
platform: Platform
|
|
17
|
-
themes: Array<string>
|
|
18
|
-
polyfills: Polyfills | undefined
|
|
19
|
-
debug: boolean | undefined
|
|
20
|
-
candidates?: Array<string>
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug, candidates }: CompileVirtualConfig) => {
|
|
24
|
-
const compiler = await compile(css, {
|
|
25
|
-
base: path.dirname(cssPath),
|
|
26
|
-
onDependency: () => void 0,
|
|
27
|
-
})
|
|
28
|
-
const scanner = new Scanner({
|
|
29
|
-
sources: [
|
|
30
|
-
...compiler.sources,
|
|
31
|
-
{
|
|
32
|
-
negated: false,
|
|
33
|
-
pattern: '**/*',
|
|
34
|
-
base: path.dirname(cssPath),
|
|
35
|
-
},
|
|
36
|
-
],
|
|
37
|
-
})
|
|
38
|
-
const tailwindCSS = compiler.build(candidates ?? scanner.scan())
|
|
39
|
-
|
|
40
|
-
if (platform === Platform.Web) {
|
|
41
|
-
return transform({
|
|
42
|
-
code: Buffer.from(tailwindCSS),
|
|
43
|
-
filename: 'uniwind.css',
|
|
44
|
-
visitor: new UniwindCSSVisitor(themes),
|
|
45
|
-
}).code.toString()
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const Processor = new ProcessorBuilder(themes, polyfills)
|
|
49
|
-
|
|
50
|
-
Logger.debug = debug === true
|
|
51
|
-
Processor.transform(tailwindCSS)
|
|
52
|
-
|
|
53
|
-
const stylesheet = serializeJSObject(
|
|
54
|
-
addMetaToStylesTemplate(Processor, platform),
|
|
55
|
-
(key, value) => `"${key}": ${value}`,
|
|
56
|
-
)
|
|
57
|
-
const vars = serializeJSObject(
|
|
58
|
-
Processor.vars,
|
|
59
|
-
(key, value) => `get "${key}"() { return ${value} }`,
|
|
60
|
-
)
|
|
61
|
-
const scopedVars = Object.fromEntries(
|
|
62
|
-
Object.entries(Processor.scopedVars)
|
|
63
|
-
.map(([scopedVarsName, scopedVars]) => [
|
|
64
|
-
scopedVarsName,
|
|
65
|
-
serializeJSObject(scopedVars, (key, value) => `get "${key}"() { return ${value} }`),
|
|
66
|
-
]),
|
|
67
|
-
)
|
|
68
|
-
const keyframes = serializeJSObject(
|
|
69
|
-
Processor.keyframes,
|
|
70
|
-
(key, value) => `get "${key}"() { return ${value} }`,
|
|
71
|
-
)
|
|
72
|
-
const serializedScopedVars = Object.entries(scopedVars)
|
|
73
|
-
.map(([scopedVarsName, scopedVars]) => `"${scopedVarsName}": ({ ${scopedVars} }),`)
|
|
74
|
-
.join('')
|
|
75
|
-
const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`
|
|
76
|
-
|
|
77
|
-
return [
|
|
78
|
-
'({',
|
|
79
|
-
`scopedVars: ({ ${serializedScopedVars} }),`,
|
|
80
|
-
`vars: ({ ${currentColorVar} ${vars} }),`,
|
|
81
|
-
`stylesheet: ({ ${stylesheet} }),`,
|
|
82
|
-
`keyframes: ({ ${keyframes} }),`,
|
|
83
|
-
'})',
|
|
84
|
-
].join('')
|
|
85
|
-
}
|
package/src/metro/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './withUniwindConfig'
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { buildCSS } from '../css'
|
|
2
|
-
import { buildDtsFile } from '../utils/buildDtsFile'
|
|
3
|
-
import { stringifyThemes } from '../utils/stringifyThemes'
|
|
4
|
-
|
|
5
|
-
type InjectThemesConfig = {
|
|
6
|
-
themes: Array<string>
|
|
7
|
-
dtsPath?: string
|
|
8
|
-
input: string
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const injectThemes = async ({
|
|
12
|
-
themes,
|
|
13
|
-
dtsPath = 'uniwind-types.d.ts',
|
|
14
|
-
input,
|
|
15
|
-
}: InjectThemesConfig) => {
|
|
16
|
-
const stringifiedThemes = stringifyThemes(themes)
|
|
17
|
-
|
|
18
|
-
buildDtsFile(dtsPath, stringifiedThemes)
|
|
19
|
-
await buildCSS(themes, input)
|
|
20
|
-
|
|
21
|
-
// js generation
|
|
22
|
-
return stringifiedThemes
|
|
23
|
-
}
|