@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,28 +1,95 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const _package = require('../shared/uniwind.CFiAZ3D-.cjs');
|
|
4
4
|
const path = require('path');
|
|
5
|
-
const common = require('../shared/uniwind.Cv73KtI-.cjs');
|
|
6
|
-
const consts = require('../shared/uniwind.B5q8hBGv.cjs');
|
|
7
|
-
const node = require('@tailwindcss/node');
|
|
8
|
-
const oxide = require('@tailwindcss/oxide');
|
|
9
5
|
const lightningcss = require('lightningcss');
|
|
10
|
-
const stringifyThemes = require('../shared/uniwind.r2i22V6d.cjs');
|
|
11
6
|
const culori = require('culori');
|
|
7
|
+
const node = require('@tailwindcss/node');
|
|
8
|
+
const oxide = require('@tailwindcss/oxide');
|
|
9
|
+
const fs = require('fs');
|
|
12
10
|
|
|
13
11
|
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
14
12
|
|
|
15
|
-
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
16
13
|
const path__default = /*#__PURE__*/_interopDefaultCompat(path);
|
|
14
|
+
const fs__default = /*#__PURE__*/_interopDefaultCompat(fs);
|
|
15
|
+
|
|
16
|
+
const toCamelCase = (str) => str.replace(/-([a-z])/g, (_, letter) => letter.toUpperCase());
|
|
17
|
+
const pipe = (data) => ((...fns) => fns.reduce((acc, fn) => fn(acc), data));
|
|
18
|
+
const isNumber = (data) => {
|
|
19
|
+
if (typeof data === "number") {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
if (typeof data === "string" && data !== "") {
|
|
23
|
+
return !isNaN(Number(data));
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
};
|
|
27
|
+
const smartSplit = (str, separator = " ") => {
|
|
28
|
+
const escaper = "&&&";
|
|
29
|
+
return pipe(str)(
|
|
30
|
+
(x) => x.replace(/\s\?\?\s/g, `${escaper}??${escaper}`),
|
|
31
|
+
(x) => x.replace(/\s([+\-*/])\s/g, `${escaper}$1${escaper}`),
|
|
32
|
+
(x) => x.split(separator),
|
|
33
|
+
(x) => x.map((token) => token.replace(new RegExp(escaper, "g"), " "))
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
const addMissingSpaces = (str) => pipe(str)(
|
|
37
|
+
(x) => x.trim(),
|
|
38
|
+
(x) => x.replace(/([^ {])this/g, "$1 this"),
|
|
39
|
+
(x) => x.replace(/\](?=\d)/g, "] "),
|
|
40
|
+
(x) => x.replace(/\](?=")/g, "] "),
|
|
41
|
+
(x) => x.replace(/\)(?=\S)/g, ") "),
|
|
42
|
+
(x) => x.replace(/(?<!^)(?<!\s)"(?=\d)/g, '" ')
|
|
43
|
+
);
|
|
44
|
+
const isValidJSValue = (jsValueString) => {
|
|
45
|
+
try {
|
|
46
|
+
new Function(`const test = ${jsValueString}`);
|
|
47
|
+
return true;
|
|
48
|
+
} catch {
|
|
49
|
+
return false;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
const shouldBeSerialized = (value) => {
|
|
53
|
+
if (value.includes("-")) {
|
|
54
|
+
return value.split("-").some(shouldBeSerialized);
|
|
55
|
+
}
|
|
56
|
+
return [
|
|
57
|
+
isNumber(value),
|
|
58
|
+
value.startsWith("this["),
|
|
59
|
+
value.startsWith("rt."),
|
|
60
|
+
/[*/+-]/.test(value),
|
|
61
|
+
value.includes('"'),
|
|
62
|
+
value.includes(" "),
|
|
63
|
+
value === "(",
|
|
64
|
+
value === ")"
|
|
65
|
+
].some(Boolean);
|
|
66
|
+
};
|
|
67
|
+
const roundToPrecision = (value, precision) => parseFloat(value.toFixed(precision));
|
|
68
|
+
const deepEqual = (a, b) => {
|
|
69
|
+
if (Object.is(a, b)) {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
if (typeof a !== "object" || a === null || typeof b !== "object" || b === null) {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
const keysA = Object.keys(a);
|
|
76
|
+
if (keysA.length !== Object.keys(b).length) {
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
return keysA.every((key) => deepEqual(a[key], b[key]) && Object.prototype.hasOwnProperty.call(b, key));
|
|
80
|
+
};
|
|
81
|
+
const removeKeys = (obj, keysToRemove) => Object.fromEntries(
|
|
82
|
+
Object.entries(obj).filter(([key]) => !keysToRemove.includes(key))
|
|
83
|
+
);
|
|
17
84
|
|
|
18
85
|
const parseStringValue = (value) => {
|
|
19
|
-
if (
|
|
86
|
+
if (isValidJSValue(value)) {
|
|
20
87
|
return value;
|
|
21
88
|
}
|
|
22
89
|
if (value.startsWith("function")) {
|
|
23
90
|
return value;
|
|
24
91
|
}
|
|
25
|
-
const tokens =
|
|
92
|
+
const tokens = smartSplit(addMissingSpaces(value));
|
|
26
93
|
const parsedTokens = tokens.map((token) => {
|
|
27
94
|
if (token.startsWith('"')) {
|
|
28
95
|
return token.replace(/"/g, "");
|
|
@@ -30,12 +97,12 @@ const parseStringValue = (value) => {
|
|
|
30
97
|
if (/^[a-z]+$/i.test(token.replace(/,/g, ""))) {
|
|
31
98
|
return token;
|
|
32
99
|
}
|
|
33
|
-
if (
|
|
100
|
+
if (isNumber(token)) {
|
|
34
101
|
return token;
|
|
35
102
|
}
|
|
36
103
|
const endsWithComma = token.endsWith(",");
|
|
37
104
|
const expr = endsWithComma ? token.slice(0, -1) : token;
|
|
38
|
-
if (!
|
|
105
|
+
if (!isValidJSValue(expr)) {
|
|
39
106
|
return token;
|
|
40
107
|
}
|
|
41
108
|
return [
|
|
@@ -60,7 +127,7 @@ const serialize = (value) => {
|
|
|
60
127
|
return String(value);
|
|
61
128
|
case "number":
|
|
62
129
|
case "bigint":
|
|
63
|
-
return String(
|
|
130
|
+
return String(roundToPrecision(value, 2));
|
|
64
131
|
case "boolean":
|
|
65
132
|
return value.toString();
|
|
66
133
|
case "object":
|
|
@@ -77,7 +144,7 @@ const serialize = (value) => {
|
|
|
77
144
|
return [
|
|
78
145
|
"{",
|
|
79
146
|
Object.entries(value).map(([key, val]) => {
|
|
80
|
-
const serializedKey =
|
|
147
|
+
const serializedKey = isNumber(key) ? key : `"${key}"`;
|
|
81
148
|
return `${serializedKey}: ${serialize(val)}`;
|
|
82
149
|
}).join(", "),
|
|
83
150
|
"}"
|
|
@@ -91,7 +158,7 @@ const serialize = (value) => {
|
|
|
91
158
|
}
|
|
92
159
|
};
|
|
93
160
|
const serializeJSObject = (obj, serializer) => {
|
|
94
|
-
const serializedObject =
|
|
161
|
+
const serializedObject = pipe(obj)(
|
|
95
162
|
Object.entries,
|
|
96
163
|
(entries) => entries.map(([key, value]) => serializer(key, serialize(value))),
|
|
97
164
|
(serializedValues) => serializedValues.filter((serializedValue) => {
|
|
@@ -99,7 +166,7 @@ const serializeJSObject = (obj, serializer) => {
|
|
|
99
166
|
new Function(`function validateJS() { const obj = ({ ${serializedValue} }) }`);
|
|
100
167
|
return true;
|
|
101
168
|
} catch {
|
|
102
|
-
|
|
169
|
+
_package.Logger.error(`Failed to serialize ${serializedValue} as a valid JS object entry. Skipping.`);
|
|
103
170
|
return false;
|
|
104
171
|
}
|
|
105
172
|
}),
|
|
@@ -114,21 +181,6 @@ const serializeJSObject = (obj, serializer) => {
|
|
|
114
181
|
return serializedObject;
|
|
115
182
|
};
|
|
116
183
|
|
|
117
|
-
const isDefined = (value) => value !== void 0 && value !== null;
|
|
118
|
-
|
|
119
|
-
var StyleDependency = /* @__PURE__ */ ((StyleDependency2) => {
|
|
120
|
-
StyleDependency2[StyleDependency2["ColorScheme"] = 1] = "ColorScheme";
|
|
121
|
-
StyleDependency2[StyleDependency2["Theme"] = 2] = "Theme";
|
|
122
|
-
StyleDependency2[StyleDependency2["Dimensions"] = 3] = "Dimensions";
|
|
123
|
-
StyleDependency2[StyleDependency2["Orientation"] = 4] = "Orientation";
|
|
124
|
-
StyleDependency2[StyleDependency2["Insets"] = 5] = "Insets";
|
|
125
|
-
StyleDependency2[StyleDependency2["FontScale"] = 6] = "FontScale";
|
|
126
|
-
StyleDependency2[StyleDependency2["Rtl"] = 7] = "Rtl";
|
|
127
|
-
StyleDependency2[StyleDependency2["AdaptiveThemes"] = 8] = "AdaptiveThemes";
|
|
128
|
-
StyleDependency2[StyleDependency2["Variables"] = 9] = "Variables";
|
|
129
|
-
return StyleDependency2;
|
|
130
|
-
})(StyleDependency || {});
|
|
131
|
-
|
|
132
184
|
const extractVarsFromString = (value) => {
|
|
133
185
|
const thisIndexes = [...value.matchAll(/this\[/g)].map((m) => m.index);
|
|
134
186
|
return thisIndexes.map((index) => {
|
|
@@ -147,6 +199,23 @@ const makeSafeForSerialization = (value) => {
|
|
|
147
199
|
}
|
|
148
200
|
return value;
|
|
149
201
|
};
|
|
202
|
+
const hasThemedVarDependency = (varName, Processor, visited = /* @__PURE__ */ new Set()) => {
|
|
203
|
+
if (visited.has(varName)) {
|
|
204
|
+
return false;
|
|
205
|
+
}
|
|
206
|
+
visited.add(varName);
|
|
207
|
+
const isScopedVar = Object.values(Processor.scopedVars).some((scopedVars) => varName in scopedVars);
|
|
208
|
+
if (isScopedVar) {
|
|
209
|
+
return true;
|
|
210
|
+
}
|
|
211
|
+
const globalVarValue = Processor.vars[varName];
|
|
212
|
+
if (typeof globalVarValue !== "string") {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return extractVarsFromString(globalVarValue).some((usedVarName) => {
|
|
216
|
+
return hasThemedVarDependency(usedVarName, Processor, visited);
|
|
217
|
+
});
|
|
218
|
+
};
|
|
150
219
|
const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
151
220
|
const stylesheetsEntries = Object.entries(Processor.stylesheets).map(([className, stylesPerMediaQuery]) => {
|
|
152
221
|
const styles = stylesPerMediaQuery.map((style, index) => {
|
|
@@ -168,8 +237,8 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
168
237
|
} = style;
|
|
169
238
|
const entries = Object.entries(rest).flatMap(([property, value]) => Processor.RN.cssToRN(property, value)).map(([property, value]) => [`"${property}"`, `function() { return ${serialize(value)} }`]);
|
|
170
239
|
if (platform) {
|
|
171
|
-
const isTV = currentPlatform ===
|
|
172
|
-
const commonPlatform = isTV ?
|
|
240
|
+
const isTV = currentPlatform === _package.Platform.AndroidTV || currentPlatform === _package.Platform.AppleTV;
|
|
241
|
+
const commonPlatform = isTV ? _package.Platform.TV : _package.Platform.Native;
|
|
173
242
|
if (platform !== commonPlatform && platform !== currentPlatform) {
|
|
174
243
|
return null;
|
|
175
244
|
}
|
|
@@ -180,32 +249,27 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
180
249
|
const dependencies = [];
|
|
181
250
|
const stringifiedEntries = JSON.stringify(entries);
|
|
182
251
|
const usedVars = extractVarsFromString(stringifiedEntries);
|
|
183
|
-
const isUsingThemedVar = usedVars.some((usedVarName) =>
|
|
184
|
-
return Object.values(Processor.scopedVars).some((scopedVars) => {
|
|
185
|
-
const scopedVarsNames = Object.keys(scopedVars);
|
|
186
|
-
return scopedVarsNames.includes(usedVarName);
|
|
187
|
-
});
|
|
188
|
-
});
|
|
252
|
+
const isUsingThemedVar = usedVars.some((usedVarName) => hasThemedVarDependency(usedVarName, Processor));
|
|
189
253
|
if (usedVars.length > 0) {
|
|
190
|
-
dependencies.push(StyleDependency.Variables);
|
|
254
|
+
dependencies.push(_package.StyleDependency.Variables);
|
|
191
255
|
}
|
|
192
256
|
if (theme !== null || isUsingThemedVar || stringifiedEntries.includes("rt.lightDark")) {
|
|
193
|
-
dependencies.push(StyleDependency.Theme);
|
|
257
|
+
dependencies.push(_package.StyleDependency.Theme);
|
|
194
258
|
}
|
|
195
259
|
if (orientation !== null) {
|
|
196
|
-
dependencies.push(StyleDependency.Orientation);
|
|
260
|
+
dependencies.push(_package.StyleDependency.Orientation);
|
|
197
261
|
}
|
|
198
262
|
if (rtl !== null) {
|
|
199
|
-
dependencies.push(StyleDependency.Rtl);
|
|
263
|
+
dependencies.push(_package.StyleDependency.Rtl);
|
|
200
264
|
}
|
|
201
|
-
if (Number(minWidth) !== 0 || Number(maxWidth) !== Number.MAX_VALUE || stringifiedEntries.includes("rt.screen")) {
|
|
202
|
-
dependencies.push(StyleDependency.Dimensions);
|
|
265
|
+
if (Number(minWidth) !== 0 || Number(maxWidth) !== Number.MAX_VALUE || stringifiedEntries.includes("rt.makeResponsive") || stringifiedEntries.includes("rt.screen")) {
|
|
266
|
+
dependencies.push(_package.StyleDependency.Dimensions);
|
|
203
267
|
}
|
|
204
268
|
if (stringifiedEntries.includes("rt.insets")) {
|
|
205
|
-
dependencies.push(StyleDependency.Insets);
|
|
269
|
+
dependencies.push(_package.StyleDependency.Insets);
|
|
206
270
|
}
|
|
207
271
|
if (stringifiedEntries.includes("rt.fontScale")) {
|
|
208
|
-
dependencies.push(StyleDependency.FontScale);
|
|
272
|
+
dependencies.push(_package.StyleDependency.FontScale);
|
|
209
273
|
}
|
|
210
274
|
return {
|
|
211
275
|
entries,
|
|
@@ -222,7 +286,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
222
286
|
active,
|
|
223
287
|
focus,
|
|
224
288
|
disabled,
|
|
225
|
-
importantProperties: importantProperties?.map((property) => property.startsWith("--") ? property :
|
|
289
|
+
importantProperties: importantProperties?.map((property) => property.startsWith("--") ? property : toCamelCase(property)).map(makeSafeForSerialization) ?? [],
|
|
226
290
|
dataAttributes,
|
|
227
291
|
complexity: [
|
|
228
292
|
minWidth !== 0,
|
|
@@ -237,7 +301,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
237
301
|
].filter(Boolean).length
|
|
238
302
|
};
|
|
239
303
|
});
|
|
240
|
-
const filteredStyles = styles.filter(isDefined);
|
|
304
|
+
const filteredStyles = styles.filter(_package.isDefined);
|
|
241
305
|
if (filteredStyles.length === 0) {
|
|
242
306
|
return null;
|
|
243
307
|
}
|
|
@@ -245,7 +309,7 @@ const addMetaToStylesTemplate = (Processor, currentPlatform) => {
|
|
|
245
309
|
className,
|
|
246
310
|
filteredStyles
|
|
247
311
|
];
|
|
248
|
-
}).filter(isDefined);
|
|
312
|
+
}).filter(_package.isDefined);
|
|
249
313
|
const stylesheets = Object.fromEntries(stylesheetsEntries);
|
|
250
314
|
return stylesheets;
|
|
251
315
|
};
|
|
@@ -308,7 +372,7 @@ class Color {
|
|
|
308
372
|
}
|
|
309
373
|
toRgb = culori.converter("rgb");
|
|
310
374
|
black = "#000000";
|
|
311
|
-
logger = new
|
|
375
|
+
logger = new _package.Logger("Color");
|
|
312
376
|
processColor(color) {
|
|
313
377
|
if (typeof color === "string") {
|
|
314
378
|
const parsed = culori.parse(color);
|
|
@@ -328,7 +392,7 @@ class Color {
|
|
|
328
392
|
return 'this["currentColor"]';
|
|
329
393
|
}
|
|
330
394
|
if (color.type === "rgb" || color.type === "srgb") {
|
|
331
|
-
const alpha = typeof color.alpha === "number" ? color.alpha :
|
|
395
|
+
const alpha = typeof color.alpha === "number" ? color.alpha : pipe(color.alpha)(
|
|
332
396
|
(x) => this.Processor.CSS.processValue(x),
|
|
333
397
|
Number,
|
|
334
398
|
(x) => isNaN(x) ? 1 : x
|
|
@@ -469,7 +533,7 @@ const getProcessedAnimation = (declarationValue, getProcessedValue) => {
|
|
|
469
533
|
const valueTokens = segment.slice(colonIndex + 1);
|
|
470
534
|
const rawKey = tokensToText(keyTokens, getProcessedValue);
|
|
471
535
|
const value = parseValues(valueTokens, getProcessedValue);
|
|
472
|
-
const key =
|
|
536
|
+
const key = toCamelCase(rawKey);
|
|
473
537
|
result.push([key, value]);
|
|
474
538
|
}
|
|
475
539
|
return result;
|
|
@@ -479,9 +543,9 @@ class CSS {
|
|
|
479
543
|
constructor(Processor) {
|
|
480
544
|
this.Processor = Processor;
|
|
481
545
|
}
|
|
482
|
-
logger = new
|
|
483
|
-
processValue(declarationValue) {
|
|
484
|
-
const processedValue = this.getProcessedValue(declarationValue);
|
|
546
|
+
logger = new _package.Logger("CSS");
|
|
547
|
+
processValue(declarationValue, declarationProperty) {
|
|
548
|
+
const processedValue = this.getProcessedValue(declarationValue, declarationProperty);
|
|
485
549
|
if (typeof processedValue === "string") {
|
|
486
550
|
return this.makeSafeForSerialization(processedValue);
|
|
487
551
|
}
|
|
@@ -520,7 +584,7 @@ class CSS {
|
|
|
520
584
|
if (token.type === "var") {
|
|
521
585
|
return this.Processor.Var.processVar(token.value);
|
|
522
586
|
}
|
|
523
|
-
return Object.entries(token).map(([key, value]) => [
|
|
587
|
+
return Object.entries(token).map(([key, value]) => [toCamelCase(key), this.processValue(value)]);
|
|
524
588
|
}
|
|
525
589
|
return getProcessedAnimation(
|
|
526
590
|
declarationValue,
|
|
@@ -544,7 +608,7 @@ class CSS {
|
|
|
544
608
|
this.processValue(filter.value.yOffset),
|
|
545
609
|
this.processValue(filter.value.blur),
|
|
546
610
|
this.processValue(filter.value.color)
|
|
547
|
-
].filter(isDefined);
|
|
611
|
+
].filter(_package.isDefined);
|
|
548
612
|
return `drop-shadow(${parts.join(" ")})`;
|
|
549
613
|
}
|
|
550
614
|
const value = this.processValue(filter.value);
|
|
@@ -552,7 +616,7 @@ class CSS {
|
|
|
552
616
|
});
|
|
553
617
|
return filterStrings.join(" ");
|
|
554
618
|
}
|
|
555
|
-
getProcessedValue(declarationValue) {
|
|
619
|
+
getProcessedValue(declarationValue, declarationProperty) {
|
|
556
620
|
if (typeof declarationValue !== "object") {
|
|
557
621
|
return declarationValue;
|
|
558
622
|
}
|
|
@@ -777,7 +841,7 @@ class CSS {
|
|
|
777
841
|
return [
|
|
778
842
|
this.Processor.Color.processColor(declarationValue.color),
|
|
779
843
|
declarationValue.position ? this.processValue(declarationValue.position) : null
|
|
780
|
-
].filter(isDefined).join(" ");
|
|
844
|
+
].filter(_package.isDefined).join(" ");
|
|
781
845
|
case "side":
|
|
782
846
|
return declarationValue.side;
|
|
783
847
|
case "absolute":
|
|
@@ -837,11 +901,17 @@ class CSS {
|
|
|
837
901
|
};
|
|
838
902
|
}
|
|
839
903
|
if ("grow" in declarationValue) {
|
|
840
|
-
|
|
904
|
+
const parsedFlex = {
|
|
841
905
|
flexGrow: declarationValue.grow,
|
|
842
906
|
flexShrink: declarationValue.shrink,
|
|
843
907
|
flexBasis: this.processValue(declarationValue.basis)
|
|
844
908
|
};
|
|
909
|
+
if (declarationProperty === "flex" && parsedFlex.flexGrow === 1 && parsedFlex.flexShrink === 1 && parsedFlex.flexBasis === '"0%"') {
|
|
910
|
+
return {
|
|
911
|
+
flex: 1
|
|
912
|
+
};
|
|
913
|
+
}
|
|
914
|
+
return parsedFlex;
|
|
845
915
|
}
|
|
846
916
|
if (Array.isArray(declarationValue)) {
|
|
847
917
|
if (declarationValue.length === 1) {
|
|
@@ -856,7 +926,7 @@ class CSS {
|
|
|
856
926
|
return this.addComaBetweenTokens(declarationValue).reduce((acc, value, index, array) => {
|
|
857
927
|
if (typeof value === "object") {
|
|
858
928
|
const nextValue = array.at(index + 1);
|
|
859
|
-
if (
|
|
929
|
+
if (deepEqual(value, nextValue)) {
|
|
860
930
|
return acc;
|
|
861
931
|
}
|
|
862
932
|
const result = this.processValue(value);
|
|
@@ -873,7 +943,7 @@ class CSS {
|
|
|
873
943
|
return declarationValue.case;
|
|
874
944
|
}
|
|
875
945
|
if ("angle" in declarationValue) {
|
|
876
|
-
const angles =
|
|
946
|
+
const angles = pipe([
|
|
877
947
|
["rotateX", declarationValue.x * declarationValue.angle.value],
|
|
878
948
|
["rotateY", declarationValue.y * declarationValue.angle.value],
|
|
879
949
|
["rotateZ", declarationValue.z * declarationValue.angle.value]
|
|
@@ -912,7 +982,7 @@ class CSS {
|
|
|
912
982
|
this.processValue(declarationValue.blur),
|
|
913
983
|
this.processValue(declarationValue.spread),
|
|
914
984
|
this.processValue(declarationValue.color)
|
|
915
|
-
].filter(isDefined).join(" ");
|
|
985
|
+
].filter(_package.isDefined).join(" ");
|
|
916
986
|
}
|
|
917
987
|
if ("blockStart" in declarationValue) {
|
|
918
988
|
const startValue = this.processValue(declarationValue.blockStart);
|
|
@@ -955,7 +1025,7 @@ class CSS {
|
|
|
955
1025
|
};
|
|
956
1026
|
}
|
|
957
1027
|
if ("duration" in declarationValue) {
|
|
958
|
-
return Object.entries(declarationValue).map(([key, value]) => [
|
|
1028
|
+
return Object.entries(declarationValue).map(([key, value]) => [toCamelCase(key), this.processValue(value)]);
|
|
959
1029
|
}
|
|
960
1030
|
this.logUnsupported(`Unsupported value - ${JSON.stringify(declarationValue)}`);
|
|
961
1031
|
return void 0;
|
|
@@ -1022,11 +1092,11 @@ class CSS {
|
|
|
1022
1092
|
);
|
|
1023
1093
|
}
|
|
1024
1094
|
makeSafeForSerialization(value) {
|
|
1025
|
-
if (
|
|
1095
|
+
if (shouldBeSerialized(value)) {
|
|
1026
1096
|
return value;
|
|
1027
1097
|
}
|
|
1028
1098
|
if (value.endsWith("%")) {
|
|
1029
|
-
return `"${
|
|
1099
|
+
return `"${roundToPrecision(parseFloat(value), 2)}%"`;
|
|
1030
1100
|
}
|
|
1031
1101
|
return `"${value}"`;
|
|
1032
1102
|
}
|
|
@@ -1036,7 +1106,7 @@ class Functions {
|
|
|
1036
1106
|
constructor(Processor) {
|
|
1037
1107
|
this.Processor = Processor;
|
|
1038
1108
|
}
|
|
1039
|
-
logger = new
|
|
1109
|
+
logger = new _package.Logger("Functions");
|
|
1040
1110
|
processCalc(calc) {
|
|
1041
1111
|
switch (calc.type) {
|
|
1042
1112
|
case "sum": {
|
|
@@ -1061,27 +1131,27 @@ class Functions {
|
|
|
1061
1131
|
}
|
|
1062
1132
|
if (fn.name === "calc") {
|
|
1063
1133
|
const calc = this.Processor.CSS.processValue(fn.arguments);
|
|
1064
|
-
return
|
|
1134
|
+
return pipe(calc)(
|
|
1065
1135
|
String,
|
|
1066
1136
|
(x) => this.Processor.Functions.tryEval(x)
|
|
1067
1137
|
);
|
|
1068
1138
|
}
|
|
1069
1139
|
if (fn.name === "cubic-bezier") {
|
|
1070
|
-
const cubicArguments =
|
|
1140
|
+
const cubicArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
|
|
1071
1141
|
String,
|
|
1072
1142
|
(x) => x.replace(/,\s/g, ",")
|
|
1073
1143
|
);
|
|
1074
1144
|
return `rt.cubicBezier(${cubicArguments})`;
|
|
1075
1145
|
}
|
|
1076
1146
|
if (fn.name === "steps") {
|
|
1077
|
-
const stepsArguments =
|
|
1147
|
+
const stepsArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
|
|
1078
1148
|
String,
|
|
1079
1149
|
(x) => x.replace(/,\s/g, ",")
|
|
1080
1150
|
);
|
|
1081
1151
|
return `rt.steps(${stepsArguments})`;
|
|
1082
1152
|
}
|
|
1083
1153
|
if (fn.name === "linear") {
|
|
1084
|
-
const linearArguments =
|
|
1154
|
+
const linearArguments = pipe(this.Processor.CSS.processValue(fn.arguments))(
|
|
1085
1155
|
String,
|
|
1086
1156
|
(x) => x.replace(/,\s/g, ",")
|
|
1087
1157
|
);
|
|
@@ -1211,7 +1281,7 @@ class Functions {
|
|
|
1211
1281
|
}
|
|
1212
1282
|
processColorMix(fn) {
|
|
1213
1283
|
const tokens = fn.arguments.map(
|
|
1214
|
-
(arg) =>
|
|
1284
|
+
(arg) => pipe(arg)(
|
|
1215
1285
|
(x) => this.Processor.CSS.processValue(x),
|
|
1216
1286
|
String,
|
|
1217
1287
|
(x) => x.trim()
|
|
@@ -1230,12 +1300,12 @@ class MQ {
|
|
|
1230
1300
|
for (const mediaQuery of mediaQueries) {
|
|
1231
1301
|
const { condition, mediaType } = mediaQuery;
|
|
1232
1302
|
if ([
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1303
|
+
_package.Platform.Android,
|
|
1304
|
+
_package.Platform.iOS,
|
|
1305
|
+
_package.Platform.Native,
|
|
1306
|
+
_package.Platform.AndroidTV,
|
|
1307
|
+
_package.Platform.AppleTV,
|
|
1308
|
+
_package.Platform.TV
|
|
1239
1309
|
].includes(mediaType)) {
|
|
1240
1310
|
mq.platform = mediaType;
|
|
1241
1311
|
continue;
|
|
@@ -1305,7 +1375,7 @@ const cssToRNMap = {
|
|
|
1305
1375
|
};
|
|
1306
1376
|
},
|
|
1307
1377
|
transitionProperty: (value) => {
|
|
1308
|
-
const properties = value.replace(/"/g, "").split(",").filter((token) => token !== "" && !token.startsWith("--")).map((token) => transitions[token.trim()] ?? `"${
|
|
1378
|
+
const properties = value.replace(/"/g, "").split(",").filter((token) => token !== "" && !token.startsWith("--")).map((token) => transitions[token.trim()] ?? `"${toCamelCase(token.trim())}"`);
|
|
1309
1379
|
if (properties.length === 1 && ['"allowDiscrete"', '"normal"'].includes(properties[0])) {
|
|
1310
1380
|
const behavior = properties[0] === '"allowDiscrete"' ? "allow-discrete" : "normal";
|
|
1311
1381
|
return {
|
|
@@ -1333,7 +1403,7 @@ const cssToRNMap = {
|
|
|
1333
1403
|
if (val === '"none"') {
|
|
1334
1404
|
continue;
|
|
1335
1405
|
}
|
|
1336
|
-
const keyName =
|
|
1406
|
+
const keyName = toCamelCase(`animation-${key.replace(/^"|"$/g, "")}`);
|
|
1337
1407
|
if (key === "name") {
|
|
1338
1408
|
result[keyName] = typeof val === "string" ? val.split(",").map((v) => v.startsWith('"') ? v : `"${v}"`) : val;
|
|
1339
1409
|
} else {
|
|
@@ -1486,13 +1556,65 @@ const cssToRNMap = {
|
|
|
1486
1556
|
const BORDER_WIDTH_KEYS = ["borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth"];
|
|
1487
1557
|
const BORDER_COLOR_KEYS = ["borderTopColor", "borderRightColor", "borderBottomColor", "borderLeftColor"];
|
|
1488
1558
|
const BORDER_RADIUS_KEYS = ["borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"];
|
|
1559
|
+
const COMPONENT_RESPONSIVE_PROPS = /* @__PURE__ */ new Set([
|
|
1560
|
+
"width",
|
|
1561
|
+
"height",
|
|
1562
|
+
"minWidth",
|
|
1563
|
+
"maxWidth",
|
|
1564
|
+
"minHeight",
|
|
1565
|
+
"maxHeight",
|
|
1566
|
+
"padding",
|
|
1567
|
+
"paddingTop",
|
|
1568
|
+
"paddingRight",
|
|
1569
|
+
"paddingBottom",
|
|
1570
|
+
"paddingLeft",
|
|
1571
|
+
"paddingHorizontal",
|
|
1572
|
+
"paddingVertical",
|
|
1573
|
+
"paddingStart",
|
|
1574
|
+
"paddingEnd",
|
|
1575
|
+
"margin",
|
|
1576
|
+
"marginTop",
|
|
1577
|
+
"marginRight",
|
|
1578
|
+
"marginBottom",
|
|
1579
|
+
"marginLeft",
|
|
1580
|
+
"marginHorizontal",
|
|
1581
|
+
"marginVertical",
|
|
1582
|
+
"marginStart",
|
|
1583
|
+
"marginEnd",
|
|
1584
|
+
"top",
|
|
1585
|
+
"right",
|
|
1586
|
+
"bottom",
|
|
1587
|
+
"left",
|
|
1588
|
+
"gap",
|
|
1589
|
+
"rowGap",
|
|
1590
|
+
"columnGap",
|
|
1591
|
+
"borderWidth",
|
|
1592
|
+
"borderTopWidth",
|
|
1593
|
+
"borderRightWidth",
|
|
1594
|
+
"borderBottomWidth",
|
|
1595
|
+
"borderLeftWidth",
|
|
1596
|
+
"borderStartWidth",
|
|
1597
|
+
"borderEndWidth",
|
|
1598
|
+
"borderRadius",
|
|
1599
|
+
"borderTopLeftRadius",
|
|
1600
|
+
"borderTopRightRadius",
|
|
1601
|
+
"borderBottomLeftRadius",
|
|
1602
|
+
"borderBottomRightRadius",
|
|
1603
|
+
"borderTopStartRadius",
|
|
1604
|
+
"borderTopEndRadius",
|
|
1605
|
+
"borderBottomStartRadius",
|
|
1606
|
+
"borderBottomEndRadius",
|
|
1607
|
+
"flexBasis",
|
|
1608
|
+
"translateX",
|
|
1609
|
+
"translateY"
|
|
1610
|
+
]);
|
|
1489
1611
|
class RN {
|
|
1490
1612
|
constructor(Processor) {
|
|
1491
1613
|
this.Processor = Processor;
|
|
1492
1614
|
}
|
|
1493
1615
|
cssToRN(property, value) {
|
|
1494
|
-
const transformedProperty = property.startsWith("--") ? property :
|
|
1495
|
-
|
|
1616
|
+
const transformedProperty = property.startsWith("--") ? property : pipe(property)(
|
|
1617
|
+
toCamelCase,
|
|
1496
1618
|
(x) => {
|
|
1497
1619
|
if (x.includes("padding") || x.includes("margin")) {
|
|
1498
1620
|
return x.replace("InlineStart", "Start").replace("InlineEnd", "End").replace("Inline", "Horizontal").replace("Block", "Vertical");
|
|
@@ -1505,10 +1627,37 @@ class RN {
|
|
|
1505
1627
|
);
|
|
1506
1628
|
const rn = this.transformProperty(
|
|
1507
1629
|
transformedProperty,
|
|
1508
|
-
typeof value === "string" ?
|
|
1630
|
+
typeof value === "string" ? addMissingSpaces(value) : value
|
|
1509
1631
|
);
|
|
1510
1632
|
const joinedStyles = this.joinStyles(rn);
|
|
1511
|
-
return Object.entries(joinedStyles).filter(([, value2]) => isDefined(value2));
|
|
1633
|
+
return Object.entries(joinedStyles).filter(([, value2]) => _package.isDefined(value2)).map(([prop, val]) => [prop, this.makeResponsive(prop, val)]);
|
|
1634
|
+
}
|
|
1635
|
+
makeResponsive(property, value) {
|
|
1636
|
+
const mode = this.Processor.bundlerConfig.polyfills?.responsive;
|
|
1637
|
+
if (!mode) {
|
|
1638
|
+
return value;
|
|
1639
|
+
}
|
|
1640
|
+
if (typeof value === "string") {
|
|
1641
|
+
const rawValue = value.startsWith('"') && value.endsWith('"') ? value.slice(1, -1) : value;
|
|
1642
|
+
if (rawValue.endsWith("%")) {
|
|
1643
|
+
const numValue = parseFloat(rawValue);
|
|
1644
|
+
if (!isNaN(numValue)) {
|
|
1645
|
+
return `rt.makeResponsive(${numValue}, 100, true)`;
|
|
1646
|
+
}
|
|
1647
|
+
}
|
|
1648
|
+
}
|
|
1649
|
+
if (typeof value !== "number") {
|
|
1650
|
+
return value;
|
|
1651
|
+
}
|
|
1652
|
+
const isTextMode = mode === true || mode === "text";
|
|
1653
|
+
const isComponentMode = mode === true || mode === "components";
|
|
1654
|
+
if (isTextMode && (property === "fontSize" || property === "--uniwind-em")) {
|
|
1655
|
+
return `rt.makeResponsive(${value}, ${_package.DEFAULT_SCREEN_HEIGHT}, true)`;
|
|
1656
|
+
}
|
|
1657
|
+
if (isComponentMode && COMPONENT_RESPONSIVE_PROPS.has(property)) {
|
|
1658
|
+
return `rt.makeResponsive(${value}, ${_package.DEFAULT_SCREEN_WIDTH})`;
|
|
1659
|
+
}
|
|
1660
|
+
return value;
|
|
1512
1661
|
}
|
|
1513
1662
|
transformProperty(property, value) {
|
|
1514
1663
|
if (property in cssToRNMap) {
|
|
@@ -1589,7 +1738,7 @@ class RN {
|
|
|
1589
1738
|
const borderWidth = styles.borderTopWidth;
|
|
1590
1739
|
if (BORDER_WIDTH_KEYS.every((key) => styles[key] === borderWidth)) {
|
|
1591
1740
|
return {
|
|
1592
|
-
...
|
|
1741
|
+
...removeKeys(styles, BORDER_WIDTH_KEYS),
|
|
1593
1742
|
borderWidth
|
|
1594
1743
|
};
|
|
1595
1744
|
}
|
|
@@ -1598,7 +1747,7 @@ class RN {
|
|
|
1598
1747
|
const borderColor = styles.borderTopColor;
|
|
1599
1748
|
if (BORDER_COLOR_KEYS.every((key) => styles[key] === borderColor)) {
|
|
1600
1749
|
return {
|
|
1601
|
-
...
|
|
1750
|
+
...removeKeys(styles, BORDER_COLOR_KEYS),
|
|
1602
1751
|
borderColor
|
|
1603
1752
|
};
|
|
1604
1753
|
}
|
|
@@ -1607,7 +1756,7 @@ class RN {
|
|
|
1607
1756
|
const borderRadius = styles.borderTopLeftRadius;
|
|
1608
1757
|
if (BORDER_RADIUS_KEYS.every((key) => styles[key] === borderRadius)) {
|
|
1609
1758
|
return {
|
|
1610
|
-
...
|
|
1759
|
+
...removeKeys(styles, BORDER_RADIUS_KEYS),
|
|
1611
1760
|
borderRadius
|
|
1612
1761
|
};
|
|
1613
1762
|
}
|
|
@@ -1620,7 +1769,7 @@ class Units {
|
|
|
1620
1769
|
constructor(Processor) {
|
|
1621
1770
|
this.Processor = Processor;
|
|
1622
1771
|
}
|
|
1623
|
-
logger = new
|
|
1772
|
+
logger = new _package.Logger("Units");
|
|
1624
1773
|
processLength(length) {
|
|
1625
1774
|
if (typeof length === "number") {
|
|
1626
1775
|
return length;
|
|
@@ -1679,10 +1828,9 @@ class Var {
|
|
|
1679
1828
|
}
|
|
1680
1829
|
|
|
1681
1830
|
class ProcessorBuilder {
|
|
1682
|
-
constructor(
|
|
1683
|
-
this.
|
|
1684
|
-
this.
|
|
1685
|
-
this.vars["--uniwind-em"] = polyfills?.rem ?? 16;
|
|
1831
|
+
constructor(bundlerConfig) {
|
|
1832
|
+
this.bundlerConfig = bundlerConfig;
|
|
1833
|
+
this.vars["--uniwind-em"] = this.bundlerConfig.polyfills?.rem ?? 16;
|
|
1686
1834
|
}
|
|
1687
1835
|
stylesheets = {};
|
|
1688
1836
|
vars = {};
|
|
@@ -1758,7 +1906,7 @@ class ProcessorBuilder {
|
|
|
1758
1906
|
return this.stylesheets[this.declarationConfig.className]?.at(-1);
|
|
1759
1907
|
}
|
|
1760
1908
|
if (mq.platform !== null) {
|
|
1761
|
-
const platformKey = `${
|
|
1909
|
+
const platformKey = `${_package.UNIWIND_PLATFORM_VARIABLES}${mq.platform}`;
|
|
1762
1910
|
this.scopedVars[platformKey] ??= {};
|
|
1763
1911
|
return this.scopedVars[platformKey];
|
|
1764
1912
|
}
|
|
@@ -1770,7 +1918,7 @@ class ProcessorBuilder {
|
|
|
1770
1918
|
if (this.declarationConfig.theme === null) {
|
|
1771
1919
|
return this.vars;
|
|
1772
1920
|
}
|
|
1773
|
-
const themeKey = `${
|
|
1921
|
+
const themeKey = `${_package.UNIWIND_THEME_VARIABLES}${this.declarationConfig.theme}`;
|
|
1774
1922
|
this.scopedVars[themeKey] ??= {};
|
|
1775
1923
|
return this.scopedVars[themeKey];
|
|
1776
1924
|
})();
|
|
@@ -1843,7 +1991,7 @@ class ProcessorBuilder {
|
|
|
1843
1991
|
if (property === "animation") {
|
|
1844
1992
|
return this.CSS.processAnimation(value);
|
|
1845
1993
|
}
|
|
1846
|
-
return this.CSS.processValue(value);
|
|
1994
|
+
return this.CSS.processValue(value, property);
|
|
1847
1995
|
};
|
|
1848
1996
|
if (declaration.property === "unparsed") {
|
|
1849
1997
|
const property = declaration.value.propertyId.property;
|
|
@@ -1894,7 +2042,7 @@ class ProcessorBuilder {
|
|
|
1894
2042
|
if (selector2.type === "pseudo-class" && selector2.kind === "where") {
|
|
1895
2043
|
selector2.selectors.forEach((selector3) => {
|
|
1896
2044
|
selector3.forEach((selector4) => {
|
|
1897
|
-
if (selector4.type === "class" && this.themes.includes(selector4.name)) {
|
|
2045
|
+
if (selector4.type === "class" && this.bundlerConfig.themes.includes(selector4.name)) {
|
|
1898
2046
|
theme = selector4.name;
|
|
1899
2047
|
}
|
|
1900
2048
|
if (selector4.type === "pseudo-class" && selector4.kind === "dir") {
|
|
@@ -2006,50 +2154,27 @@ class ProcessorBuilder {
|
|
|
2006
2154
|
}
|
|
2007
2155
|
}
|
|
2008
2156
|
|
|
2009
|
-
const
|
|
2010
|
-
const
|
|
2011
|
-
base: path__default.dirname(cssPath),
|
|
2012
|
-
onDependency: () => void 0
|
|
2013
|
-
});
|
|
2014
|
-
const scanner = new oxide.Scanner({
|
|
2015
|
-
sources: [
|
|
2016
|
-
...compiler.sources,
|
|
2017
|
-
{
|
|
2018
|
-
negated: false,
|
|
2019
|
-
pattern: "**/*",
|
|
2020
|
-
base: path__default.dirname(cssPath)
|
|
2021
|
-
}
|
|
2022
|
-
]
|
|
2023
|
-
});
|
|
2024
|
-
const tailwindCSS = compiler.build(candidates ?? scanner.scan());
|
|
2025
|
-
if (platform === consts.Platform.Web) {
|
|
2026
|
-
return lightningcss.transform({
|
|
2027
|
-
code: Buffer.from(tailwindCSS),
|
|
2028
|
-
filename: "uniwind.css",
|
|
2029
|
-
visitor: new stringifyThemes.UniwindCSSVisitor(themes)
|
|
2030
|
-
}).code.toString();
|
|
2031
|
-
}
|
|
2032
|
-
const Processor = new ProcessorBuilder(themes, polyfills);
|
|
2033
|
-
stringifyThemes.Logger.debug = debug === true;
|
|
2157
|
+
const compileNativeCSS = (bundlerConfig, tailwindCSS) => {
|
|
2158
|
+
const Processor = new ProcessorBuilder(bundlerConfig);
|
|
2034
2159
|
Processor.transform(tailwindCSS);
|
|
2035
2160
|
const stylesheet = serializeJSObject(
|
|
2036
|
-
addMetaToStylesTemplate(Processor, platform),
|
|
2161
|
+
addMetaToStylesTemplate(Processor, bundlerConfig.platform),
|
|
2037
2162
|
(key, value) => `"${key}": ${value}`
|
|
2038
2163
|
);
|
|
2039
2164
|
const vars = serializeJSObject(
|
|
2040
2165
|
Processor.vars,
|
|
2041
2166
|
(key, value) => `get "${key}"() { return ${value} }`
|
|
2042
2167
|
);
|
|
2168
|
+
const keyframes = serializeJSObject(
|
|
2169
|
+
Processor.keyframes,
|
|
2170
|
+
(key, value) => `get "${key}"() { return ${value} }`
|
|
2171
|
+
);
|
|
2043
2172
|
const scopedVars = Object.fromEntries(
|
|
2044
2173
|
Object.entries(Processor.scopedVars).map(([scopedVarsName, scopedVars2]) => [
|
|
2045
2174
|
scopedVarsName,
|
|
2046
2175
|
serializeJSObject(scopedVars2, (key, value) => `get "${key}"() { return ${value} }`)
|
|
2047
2176
|
])
|
|
2048
2177
|
);
|
|
2049
|
-
const keyframes = serializeJSObject(
|
|
2050
|
-
Processor.keyframes,
|
|
2051
|
-
(key, value) => `get "${key}"() { return ${value} }`
|
|
2052
|
-
);
|
|
2053
2178
|
const serializedScopedVars = Object.entries(scopedVars).map(([scopedVarsName, scopedVars2]) => `"${scopedVarsName}": ({ ${scopedVars2} }),`).join("");
|
|
2054
2179
|
const currentColorVar = `get currentColor() { return rt.colorScheme === 'dark' ? '#ffffff' : '#000000' },`;
|
|
2055
2180
|
return [
|
|
@@ -2062,17 +2187,42 @@ const compileVirtual = async ({ css, cssPath, platform, themes, polyfills, debug
|
|
|
2062
2187
|
].join("");
|
|
2063
2188
|
};
|
|
2064
2189
|
|
|
2065
|
-
const
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2190
|
+
const compileTailwind = async (bundlerConfig) => {
|
|
2191
|
+
const css = await fs__default.promises.readFile(bundlerConfig.cssPath, "utf-8");
|
|
2192
|
+
const compiler = await node.compile(css, {
|
|
2193
|
+
base: path__default.dirname(bundlerConfig.cssPath),
|
|
2194
|
+
onDependency: () => void 0
|
|
2195
|
+
});
|
|
2196
|
+
const scanner = new oxide.Scanner({
|
|
2197
|
+
sources: [
|
|
2198
|
+
...compiler.sources,
|
|
2199
|
+
{
|
|
2200
|
+
negated: false,
|
|
2201
|
+
pattern: "**/*",
|
|
2202
|
+
base: path__default.dirname(bundlerConfig.cssPath)
|
|
2203
|
+
}
|
|
2204
|
+
]
|
|
2205
|
+
});
|
|
2206
|
+
return compiler.build(scanner.scan());
|
|
2074
2207
|
};
|
|
2075
2208
|
|
|
2209
|
+
const compileWebCSS = (bundlerConfig, tailwindCSS) => {
|
|
2210
|
+
return lightningcss.transform({
|
|
2211
|
+
code: Buffer.from(tailwindCSS),
|
|
2212
|
+
filename: "uniwind.css",
|
|
2213
|
+
visitor: bundlerConfig.cssVisitor
|
|
2214
|
+
}).code.toString();
|
|
2215
|
+
};
|
|
2216
|
+
|
|
2217
|
+
const compileCSS = async (bundlerConfig) => {
|
|
2218
|
+
const tailwindCSS = await compileTailwind(bundlerConfig);
|
|
2219
|
+
if (bundlerConfig.platform === _package.Platform.Web) {
|
|
2220
|
+
return compileWebCSS(bundlerConfig, tailwindCSS);
|
|
2221
|
+
}
|
|
2222
|
+
return compileNativeCSS(bundlerConfig, tailwindCSS);
|
|
2223
|
+
};
|
|
2224
|
+
|
|
2225
|
+
const cssArtifactPath = path__default.resolve(__dirname, "../../uniwind.css");
|
|
2076
2226
|
let worker;
|
|
2077
2227
|
try {
|
|
2078
2228
|
try {
|
|
@@ -2087,16 +2237,11 @@ try {
|
|
|
2087
2237
|
const transform = async (config, projectRoot, filePath, data, options) => {
|
|
2088
2238
|
const isCss = options.type !== "asset" && path__default.join(process.cwd(), config.uniwind.cssEntryFile) === path__default.join(projectRoot, filePath);
|
|
2089
2239
|
if (filePath.endsWith("/components/web/metro-injected.js")) {
|
|
2090
|
-
const
|
|
2091
|
-
const injectedThemesCode2 = await injectThemes({
|
|
2092
|
-
input: cssPath2,
|
|
2093
|
-
themes: config.uniwind.themes,
|
|
2094
|
-
dtsPath: config.uniwind.dtsFile
|
|
2095
|
-
});
|
|
2240
|
+
const bundlerConfig2 = _package.UniwindBundlerConfig.fromMetroConfig(config.uniwind, _package.Platform.Web);
|
|
2096
2241
|
data = Buffer.from(
|
|
2097
2242
|
[
|
|
2098
|
-
`import { Uniwind } from '${
|
|
2099
|
-
`Uniwind.__reinit(() => ({}), ${
|
|
2243
|
+
`import { Uniwind } from '${_package.name}';`,
|
|
2244
|
+
`Uniwind.__reinit(() => ({}), ${bundlerConfig2.stringifiedThemes});`
|
|
2100
2245
|
].join(""),
|
|
2101
2246
|
"utf-8"
|
|
2102
2247
|
);
|
|
@@ -2104,39 +2249,14 @@ const transform = async (config, projectRoot, filePath, data, options) => {
|
|
|
2104
2249
|
if (!isCss) {
|
|
2105
2250
|
return worker.transform(config, projectRoot, filePath, data, options);
|
|
2106
2251
|
}
|
|
2107
|
-
const
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
if (options.platform === consts.Platform.Android) {
|
|
2112
|
-
return consts.Platform.AndroidTV;
|
|
2113
|
-
}
|
|
2114
|
-
if (options.platform === consts.Platform.iOS) {
|
|
2115
|
-
return consts.Platform.AppleTV;
|
|
2116
|
-
}
|
|
2117
|
-
throw new Error(`Platform ${options.platform} not supported`);
|
|
2118
|
-
};
|
|
2119
|
-
const cssPath = path__default.join(process.cwd(), config.uniwind.cssEntryFile);
|
|
2120
|
-
const injectedThemesCode = await injectThemes({
|
|
2121
|
-
input: cssPath,
|
|
2122
|
-
themes: config.uniwind.themes,
|
|
2123
|
-
dtsPath: config.uniwind.dtsFile
|
|
2124
|
-
});
|
|
2125
|
-
const css = fs__default.readFileSync(cssPath, "utf-8");
|
|
2126
|
-
const platform = getPlatform();
|
|
2127
|
-
const virtualCode = await compileVirtual({
|
|
2128
|
-
css,
|
|
2129
|
-
platform,
|
|
2130
|
-
themes: config.uniwind.themes,
|
|
2131
|
-
polyfills: config.uniwind.polyfills,
|
|
2132
|
-
cssPath,
|
|
2133
|
-
debug: config.uniwind.debug
|
|
2134
|
-
});
|
|
2135
|
-
const isWeb = platform === consts.Platform.Web;
|
|
2252
|
+
const bundlerConfig = _package.UniwindBundlerConfig.fromMetroConfig(config.uniwind, options.platform);
|
|
2253
|
+
await bundlerConfig.generateArtifacts(cssArtifactPath);
|
|
2254
|
+
const virtualCode = await compileCSS(bundlerConfig);
|
|
2255
|
+
const isWeb = bundlerConfig.platform === _package.Platform.Web;
|
|
2136
2256
|
data = Buffer.from(
|
|
2137
2257
|
isWeb ? virtualCode : [
|
|
2138
|
-
`const { Uniwind } = require('${
|
|
2139
|
-
`Uniwind.__reinit(rt => ${virtualCode}, ${
|
|
2258
|
+
`const { Uniwind } = require('${_package.name}');`,
|
|
2259
|
+
`Uniwind.__reinit(rt => ${virtualCode}, ${bundlerConfig.stringifiedThemes});`
|
|
2140
2260
|
].join(""),
|
|
2141
2261
|
"utf-8"
|
|
2142
2262
|
);
|