@mpxjs/webpack-plugin 2.10.16-beta.5 → 2.10.16-beta.6
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/lib/loader.js +2 -2
- package/lib/runtime/components/react/context.ts +10 -6
- package/lib/runtime/components/react/dist/context.d.ts +75 -0
- package/lib/runtime/components/react/dist/context.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/event.config.d.ts +8 -0
- package/lib/runtime/components/react/dist/event.config.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +8 -0
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-async-suspense.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts +69 -0
- package/lib/runtime/components/react/dist/mpx-button.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +28 -0
- package/lib/runtime/components/react/dist/mpx-camera.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Bus.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-canvas/Image.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-canvas/ImageData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts +11 -0
- package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts +3 -0
- package/lib/runtime/components/react/dist/mpx-canvas/html.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +53 -0
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts +28 -0
- package/lib/runtime/components/react/dist/mpx-form.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +19 -0
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts +22 -0
- package/lib/runtime/components/react/dist/mpx-image.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-inline-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts +50 -0
- package/lib/runtime/components/react/dist/mpx-input.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-input.jsx +35 -9
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-keyboard-avoiding-view.jsx +46 -53
- package/lib/runtime/components/react/dist/mpx-label.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-label.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +66 -0
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-nav.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-nav.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-nav.jsx +132 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-navigator.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/date.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-picker/dateData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/multiSelector.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/region.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts +3 -0
- package/lib/runtime/components/react/dist/mpx-picker/regionData.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/selector.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts +7 -0
- package/lib/runtime/components/react/dist/mpx-picker/time.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +107 -0
- package/lib/runtime/components/react/dist/mpx-picker/type.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +33 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +9 -0
- package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +14 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewFaces.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts +13 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewIndicator.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts +12 -0
- package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewMask.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-popup/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts +17 -0
- package/lib/runtime/components/react/dist/mpx-popup/popupBase.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-portal/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts +30 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-host.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts +10 -0
- package/lib/runtime/components/react/dist/mpx-portal/portal-manager.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +24 -0
- package/lib/runtime/components/react/dist/mpx-progress.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +21 -0
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-radio.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts +2 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/html.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +25 -0
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts +15 -0
- package/lib/runtime/components/react/dist/mpx-root-portal.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +55 -0
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-simple-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +31 -0
- package/lib/runtime/components/react/dist/mpx-slider.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +18 -0
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +16 -0
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +19 -0
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +53 -0
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +27 -0
- package/lib/runtime/components/react/dist/mpx-switch.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-text.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts +8 -0
- package/lib/runtime/components/react/dist/mpx-textarea.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts +102 -0
- package/lib/runtime/components/react/dist/mpx-video.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts +35 -0
- package/lib/runtime/components/react/dist/mpx-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts +23 -0
- package/lib/runtime/components/react/dist/mpx-web-view.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/parser.d.ts +40 -0
- package/lib/runtime/components/react/dist/parser.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts +33 -0
- package/lib/runtime/components/react/dist/useAnimationHooks.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts +12 -0
- package/lib/runtime/components/react/dist/useNodesRef.d.ts.map +1 -0
- package/lib/runtime/components/react/dist/utils.d.ts +123 -0
- package/lib/runtime/components/react/dist/utils.d.ts.map +1 -0
- package/lib/runtime/components/react/mpx-camera.tsx +1 -1
- package/lib/runtime/components/react/mpx-input.tsx +41 -16
- package/lib/runtime/components/react/mpx-keyboard-avoiding-view.tsx +48 -58
- package/lib/runtime/components/react/mpx-nav.tsx +155 -0
- package/lib/runtime/components/react/types/common.d.ts +19 -0
- package/lib/style-compiler/strip-conditional-loader.js +27 -4
- package/package.json +4 -1
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/* eslint-disable space-before-function-paren */
|
|
2
|
+
import { useState, useMemo, memo } from 'react'
|
|
3
|
+
import { useSafeAreaInsets } from 'react-native-safe-area-context'
|
|
4
|
+
import { StatusBar, processColor, TouchableWithoutFeedback, Image, View, StyleSheet, Text } from 'react-native'
|
|
5
|
+
|
|
6
|
+
function convertToHex(color?: string) {
|
|
7
|
+
try {
|
|
8
|
+
const intColor = processColor(color) as number | null | undefined
|
|
9
|
+
if (intColor === null || intColor === undefined) {
|
|
10
|
+
return null
|
|
11
|
+
}
|
|
12
|
+
// 将32位整数颜色值转换为RGBA
|
|
13
|
+
const r = (intColor >> 16) & 255
|
|
14
|
+
const g = (intColor >> 8) & 255
|
|
15
|
+
const b = intColor & 255
|
|
16
|
+
// 转换为十六进制
|
|
17
|
+
const hexR = r.toString(16).padStart(2, '0')
|
|
18
|
+
const hexG = g.toString(16).padStart(2, '0')
|
|
19
|
+
const hexB = b.toString(16).padStart(2, '0')
|
|
20
|
+
return `#${hexR}${hexG}${hexB}`
|
|
21
|
+
} catch (error) {
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const titleHeight = 44
|
|
27
|
+
export function useInnerHeaderHeight(pageConfig: PageConfig) {
|
|
28
|
+
const safeArea = useSafeAreaInsets()
|
|
29
|
+
if (pageConfig.navigationStyle === 'custom') {
|
|
30
|
+
return 0
|
|
31
|
+
} else {
|
|
32
|
+
const safeAreaTop = safeArea?.top || 0
|
|
33
|
+
const headerHeight = safeAreaTop + titleHeight
|
|
34
|
+
return headerHeight
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const styles = StyleSheet.create({
|
|
39
|
+
header: {
|
|
40
|
+
elevation: 3
|
|
41
|
+
},
|
|
42
|
+
headerContent: {
|
|
43
|
+
flexDirection: 'row',
|
|
44
|
+
alignItems: 'center',
|
|
45
|
+
justifyContent: 'center'
|
|
46
|
+
},
|
|
47
|
+
backButton: {
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
height: '100%',
|
|
50
|
+
width: 40,
|
|
51
|
+
left: 0,
|
|
52
|
+
top: 0,
|
|
53
|
+
alignItems: 'center',
|
|
54
|
+
justifyContent: 'center'
|
|
55
|
+
},
|
|
56
|
+
backButtonImage: {
|
|
57
|
+
width: 22,
|
|
58
|
+
height: 22
|
|
59
|
+
},
|
|
60
|
+
title: {
|
|
61
|
+
fontSize: 17,
|
|
62
|
+
fontWeight: 600,
|
|
63
|
+
width: '60%',
|
|
64
|
+
textAlign: 'center'
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
const NavColor = {
|
|
68
|
+
White: '#ffffff',
|
|
69
|
+
Black: '#000000'
|
|
70
|
+
}
|
|
71
|
+
// navigationBarTextStyle 只支持黑白 'white'/'black
|
|
72
|
+
const validBarTextStyle = (textStyle?: string) => {
|
|
73
|
+
const textStyleColor = convertToHex(textStyle)
|
|
74
|
+
if (textStyle && textStyleColor && [NavColor.White, NavColor.Black].includes(textStyleColor)) {
|
|
75
|
+
return textStyleColor
|
|
76
|
+
} else {
|
|
77
|
+
return NavColor.White
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface MpxNavProps {
|
|
82
|
+
pageConfig: PageConfig
|
|
83
|
+
navigation: any
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
const BACK_ICON =
|
|
87
|
+
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADwAAABICAYAAACqT5alAAAA2UlEQVR4nO3bMQrCUBRE0Yla6AYEN2nnBrTL+izcitW3MRDkEUWSvPzJvfCqgMwhZbAppWhNbbIHzB1g9wATERFRVyvpkj1irlpJ5X326D7WHh1hbdFD2CLpLmmftm7kfsEe09aNHFiBrT+wAlt/YAW2/sAKbP2BFdj6Ayuwy+ufz6XPL893krZ//O6iu2n4LT8kndLWTRTo4EC7BDo40C6BDg60S6CDA+0S6OBAuwQ6uNWiD2nrJmoIfU7cNWkR2hbb1UfbY7uuWhGWiIg+a/iHuHmA3QPs3gu4JW9Gan+OJAAAAABJRU5ErkJggg=='
|
|
88
|
+
|
|
89
|
+
const MpxNav = memo(({ pageConfig, navigation }: MpxNavProps) => {
|
|
90
|
+
const [innerPageConfig, setPageConfig] = useState<PageConfig>(pageConfig || {})
|
|
91
|
+
const safeAreaTop = useSafeAreaInsets()?.top || 0
|
|
92
|
+
|
|
93
|
+
navigation.setPageConfig = (config: PageConfig) => {
|
|
94
|
+
setPageConfig(Object.assign({}, innerPageConfig, config))
|
|
95
|
+
}
|
|
96
|
+
const isCustom = innerPageConfig.navigationStyle === 'custom'
|
|
97
|
+
const navigationBarTextStyle = useMemo(() => validBarTextStyle(innerPageConfig.navigationBarTextStyle), [innerPageConfig.navigationBarTextStyle])
|
|
98
|
+
// 状态栏的颜色
|
|
99
|
+
const statusBarElement = (
|
|
100
|
+
<StatusBar
|
|
101
|
+
translucent
|
|
102
|
+
backgroundColor='transparent'
|
|
103
|
+
barStyle={navigationBarTextStyle === NavColor.White ? 'light-content' : 'dark-content'}></StatusBar>
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
if (isCustom) return statusBarElement
|
|
107
|
+
// 假设是栈导航,获取栈的长度
|
|
108
|
+
const stackLength = navigation.getState()?.routes?.length
|
|
109
|
+
const onStackTopBack = mpxGlobal?.__mpx?.config?.rnConfig?.onStackTopBack
|
|
110
|
+
const isHandleStackTopBack = typeof onStackTopBack === 'function'
|
|
111
|
+
|
|
112
|
+
// 回退按钮与图标
|
|
113
|
+
// prettier-ignore
|
|
114
|
+
const backElement = stackLength > 1 || isHandleStackTopBack
|
|
115
|
+
? (
|
|
116
|
+
<TouchableWithoutFeedback
|
|
117
|
+
onPress={() => {
|
|
118
|
+
if (stackLength <= 1 && isHandleStackTopBack) {
|
|
119
|
+
onStackTopBack()
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
navigation.goBack()
|
|
123
|
+
}}>
|
|
124
|
+
<View style={[styles.backButton]}>
|
|
125
|
+
<Image style={[styles.backButtonImage, { tintColor: navigationBarTextStyle }]} source={{ uri: BACK_ICON }}></Image>
|
|
126
|
+
</View>
|
|
127
|
+
</TouchableWithoutFeedback>
|
|
128
|
+
)
|
|
129
|
+
: null
|
|
130
|
+
|
|
131
|
+
return (
|
|
132
|
+
<View
|
|
133
|
+
style={[
|
|
134
|
+
styles.header,
|
|
135
|
+
{
|
|
136
|
+
paddingTop: safeAreaTop,
|
|
137
|
+
backgroundColor: innerPageConfig.navigationBarBackgroundColor || '#000000'
|
|
138
|
+
}
|
|
139
|
+
]}>
|
|
140
|
+
{statusBarElement}
|
|
141
|
+
{/* TODO: 确定 height 的有效性 */}
|
|
142
|
+
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
|
|
143
|
+
{/* @ts-expect-error */}
|
|
144
|
+
<View style={styles.headerContent} height={titleHeight}>
|
|
145
|
+
{backElement}
|
|
146
|
+
<Text style={[styles.title, { color: navigationBarTextStyle }]} numberOfLines={1}>
|
|
147
|
+
{innerPageConfig.navigationBarTitleText?.trim() || ''}
|
|
148
|
+
</Text>
|
|
149
|
+
</View>
|
|
150
|
+
</View>
|
|
151
|
+
)
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
MpxNav.displayName = 'MpxNav'
|
|
155
|
+
export default MpxNav
|
|
@@ -18,3 +18,22 @@ export type ExtendedFunctionComponent = FunctionComponent & {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
export type AnyFunc = (...args: ReadonlyArray<any>) => any
|
|
21
|
+
|
|
22
|
+
declare global {
|
|
23
|
+
interface PageConfig {
|
|
24
|
+
/**
|
|
25
|
+
* 是否自定义导航栏
|
|
26
|
+
*/
|
|
27
|
+
navigationStyle?: 'custom'
|
|
28
|
+
/**
|
|
29
|
+
* 标题栏样式
|
|
30
|
+
*/
|
|
31
|
+
navigationBarTextStyle?: 'white' | 'black' | '#ffffff' | '#000000'
|
|
32
|
+
/**
|
|
33
|
+
* 页面标题
|
|
34
|
+
*/
|
|
35
|
+
navigationBarTitleText?: string
|
|
36
|
+
|
|
37
|
+
[key: string]: any
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -193,7 +193,17 @@ async function stripByPostcss(options) {
|
|
|
193
193
|
const syntax = styleSyntaxProcesserMap[options.lang]?.()
|
|
194
194
|
const defs = options.defs ?? {}
|
|
195
195
|
|
|
196
|
-
|
|
196
|
+
function stripContentCondition(content) {
|
|
197
|
+
content = stripCondition(content, defs)
|
|
198
|
+
|
|
199
|
+
if (options.lang === 'stylus') {
|
|
200
|
+
content = content.replace(/\t/g, ' ')
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return content
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
const afterConditionStrip = stripContentCondition(options.css, defs)
|
|
197
207
|
|
|
198
208
|
/**
|
|
199
209
|
* @type {import('postcss').AcceptedPlugin[]}
|
|
@@ -204,7 +214,7 @@ async function stripByPostcss(options) {
|
|
|
204
214
|
let content = await fs.readFile(filename, 'utf-8')
|
|
205
215
|
const processer = postcss(plugins)
|
|
206
216
|
|
|
207
|
-
content =
|
|
217
|
+
content = stripContentCondition(content, defs)
|
|
208
218
|
|
|
209
219
|
const { css } = await processer.process(content, {
|
|
210
220
|
syntax,
|
|
@@ -228,11 +238,24 @@ async function stripByPostcss(options) {
|
|
|
228
238
|
})
|
|
229
239
|
})
|
|
230
240
|
}
|
|
231
|
-
})
|
|
241
|
+
}),
|
|
242
|
+
{
|
|
243
|
+
// less/scss syntax 在 postcss 重新生成 css 后,`//` 注释后面不会保留换行,会和后续的 css 语句和注释连在一起,导致后续语法错误
|
|
244
|
+
postcssPlugin: 'mpx-strip-conditional-loader-append-command',
|
|
245
|
+
CommentExit(comment) {
|
|
246
|
+
if (!comment.raws.right) {
|
|
247
|
+
comment.raws.right = '\n'
|
|
248
|
+
return
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
if (!comment.raws.right.startsWith('\n')) {
|
|
252
|
+
comment.raws.right = '\n' + comment.raws.right
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
232
256
|
]
|
|
233
257
|
|
|
234
258
|
const processer = postcss(plugins)
|
|
235
|
-
|
|
236
259
|
return processer.process(afterConditionStrip, {
|
|
237
260
|
from: options.resourcePath,
|
|
238
261
|
syntax
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mpxjs/webpack-plugin",
|
|
3
|
-
"version": "2.10.16-beta.
|
|
3
|
+
"version": "2.10.16-beta.6",
|
|
4
4
|
"description": "mpx compile core",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mpx"
|
|
@@ -30,6 +30,9 @@
|
|
|
30
30
|
"@better-scroll/zoom": "^2.5.1",
|
|
31
31
|
"@mpxjs/template-engine": "^2.8.7",
|
|
32
32
|
"@mpxjs/utils": "^2.10.16",
|
|
33
|
+
"postcss-less": "^6.0.0",
|
|
34
|
+
"postcss-scss": "^4.0.9",
|
|
35
|
+
"postcss-styl": "^0.12.3",
|
|
33
36
|
"acorn": "^8.11.3",
|
|
34
37
|
"acorn-walk": "^7.2.0",
|
|
35
38
|
"async": "^2.6.0",
|