@mpxjs/webpack-plugin 2.10.22 → 2.10.24-test.1
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 -0
- package/lib/platform/style/wx/index.js +395 -104
- package/lib/react/index.js +3 -1
- package/lib/react/processTemplate.js +3 -1
- package/lib/react/style-helper.js +6 -6
- package/lib/runtime/components/react/animationHooks/index.ts +7 -3
- package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
- package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
- package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
- package/lib/runtime/components/react/dist/event.config.js +28 -24
- package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
- package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
- package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
- package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-camera.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
- package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-input.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
- package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
- package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +5 -7
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +2 -2
- package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
- package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
- package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-simple-text.jsx +36 -31
- package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -2
- package/lib/runtime/components/react/dist/mpx-simple-view.jsx +24 -17
- package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
- package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
- package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -1
- package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -7
- package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -2
- package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-text.jsx +44 -40
- package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
- package/lib/runtime/components/react/dist/mpx-video.jsx +4 -4
- package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -1
- package/lib/runtime/components/react/dist/mpx-view.jsx +229 -128
- package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
- package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
- package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
- package/lib/runtime/components/react/dist/utils.d.ts +73 -69
- package/lib/runtime/components/react/dist/utils.jsx +1295 -442
- package/lib/runtime/components/react/event.config.ts +32 -25
- package/lib/runtime/components/react/getInnerListeners.ts +84 -60
- package/lib/runtime/components/react/mpx-button.tsx +18 -16
- package/lib/runtime/components/react/mpx-camera.tsx +0 -3
- package/lib/runtime/components/react/mpx-canvas/index.tsx +1 -3
- package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
- package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -6
- package/lib/runtime/components/react/mpx-checkbox.tsx +9 -11
- package/lib/runtime/components/react/mpx-form.tsx +6 -6
- package/lib/runtime/components/react/mpx-icon/index.tsx +1 -3
- package/lib/runtime/components/react/mpx-image.tsx +65 -54
- package/lib/runtime/components/react/mpx-input.tsx +1 -3
- package/lib/runtime/components/react/mpx-label.tsx +6 -8
- package/lib/runtime/components/react/mpx-movable-area.tsx +3 -4
- package/lib/runtime/components/react/mpx-movable-view.tsx +7 -7
- package/lib/runtime/components/react/mpx-picker-view/index.tsx +6 -8
- package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +2 -4
- package/lib/runtime/components/react/mpx-progress.tsx +0 -3
- package/lib/runtime/components/react/mpx-radio-group.tsx +2 -6
- package/lib/runtime/components/react/mpx-radio.tsx +9 -11
- package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -3
- package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -7
- package/lib/runtime/components/react/mpx-simple-text.tsx +36 -38
- package/lib/runtime/components/react/mpx-simple-view.tsx +29 -17
- package/lib/runtime/components/react/mpx-slider.tsx +15 -10
- package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -6
- package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -7
- package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -6
- package/lib/runtime/components/react/mpx-swiper.tsx +5 -8
- package/lib/runtime/components/react/mpx-switch.tsx +0 -3
- package/lib/runtime/components/react/mpx-text.tsx +46 -49
- package/lib/runtime/components/react/mpx-video.tsx +3 -5
- package/lib/runtime/components/react/mpx-view.tsx +250 -141
- package/lib/runtime/components/react/mpx-web-view.tsx +8 -3
- package/lib/runtime/components/react/namedColorSet.ts +150 -0
- package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
- package/lib/runtime/components/react/types/global.d.ts +1 -0
- package/lib/runtime/components/react/utils.tsx +1347 -539
- package/lib/runtime/i18n.wxs +15 -9
- package/lib/style-compiler/strip-conditional.js +19 -4
- package/lib/template-compiler/compiler.js +5 -1
- package/lib/utils/source-location.js +9 -13
- package/lib/web/index.js +3 -1
- package/lib/web/processTemplate.js +3 -1
- package/package.json +5 -4
- package/LICENSE +0 -433
|
@@ -5,12 +5,11 @@
|
|
|
5
5
|
* ✔ decode
|
|
6
6
|
*/
|
|
7
7
|
import { Text, TextStyle, TextProps } from 'react-native'
|
|
8
|
-
import { useRef, forwardRef, ReactNode, JSX, createElement, Children
|
|
8
|
+
import { useRef, forwardRef, ReactNode, JSX, createElement, Children } from 'react'
|
|
9
9
|
import Portal from './mpx-portal'
|
|
10
10
|
import useInnerProps from './getInnerListeners'
|
|
11
11
|
import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
|
|
12
|
-
import { useTransformStyle, wrapChildren, extendObject, getDefaultAllowFontScaling,
|
|
13
|
-
import { TextPassThroughContext } from './context'
|
|
12
|
+
import { useTransformStyle, wrapChildren, extendObject, getDefaultAllowFontScaling, useTextPassThroughText, isStringChildren, splitStyle } from './utils'
|
|
14
13
|
import * as perf from '@mpxjs/perf'
|
|
15
14
|
|
|
16
15
|
const decodeMap = {
|
|
@@ -31,13 +30,17 @@ function decode (value: string) {
|
|
|
31
30
|
}
|
|
32
31
|
}
|
|
33
32
|
|
|
34
|
-
function getDecodedChildren (children: ReactNode) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
function getDecodedChildren (children: ReactNode): { children: ReactNode, isStringOnly: boolean } {
|
|
34
|
+
if (typeof children === 'string') {
|
|
35
|
+
return { children: decode(children), isStringOnly: true }
|
|
36
|
+
}
|
|
37
|
+
let isStringOnly = true
|
|
38
|
+
const decoded = Children.map(children, (child) => {
|
|
39
|
+
if (typeof child === 'string') return decode(child)
|
|
40
|
+
isStringOnly = false
|
|
39
41
|
return child
|
|
40
42
|
})
|
|
43
|
+
return { children: decoded, isStringOnly }
|
|
41
44
|
}
|
|
42
45
|
interface _TextProps extends TextProps {
|
|
43
46
|
style?: TextStyle
|
|
@@ -45,7 +48,6 @@ interface _TextProps extends TextProps {
|
|
|
45
48
|
selectable?: boolean
|
|
46
49
|
'user-select'?: boolean
|
|
47
50
|
'enable-var'?: boolean
|
|
48
|
-
'external-var-context'?: Record<string, any>
|
|
49
51
|
'parent-font-size'?: number
|
|
50
52
|
'parent-width'?: number
|
|
51
53
|
'parent-height'?: number
|
|
@@ -53,31 +55,28 @@ interface _TextProps extends TextProps {
|
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref): JSX.Element => {
|
|
56
|
-
let
|
|
57
|
-
if (__mpx_perf_framework__)
|
|
58
|
+
let idTotal = -1
|
|
59
|
+
if (__mpx_perf_framework__) idTotal = perf.scopeStart('text:render:total')
|
|
58
60
|
|
|
59
61
|
// ───── props 阶段 ─────
|
|
60
|
-
let
|
|
61
|
-
if (__mpx_perf_framework__)
|
|
62
|
-
const inheritedText = useContext(TextPassThroughContext)
|
|
63
|
-
const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props)
|
|
62
|
+
let idProps = -1
|
|
63
|
+
if (__mpx_perf_framework__) idProps = perf.scopeStart('text:render:props')
|
|
64
64
|
const {
|
|
65
65
|
style: currentStyle = {},
|
|
66
66
|
allowFontScaling,
|
|
67
67
|
selectable,
|
|
68
68
|
'enable-var': enableVar,
|
|
69
|
-
'external-var-context': externalVarContext,
|
|
70
69
|
'user-select': userSelect,
|
|
71
70
|
'parent-font-size': parentFontSize,
|
|
72
71
|
'parent-width': parentWidth,
|
|
73
72
|
'parent-height': parentHeight,
|
|
74
73
|
decode
|
|
75
|
-
} =
|
|
76
|
-
if (__mpx_perf_framework__)
|
|
74
|
+
} = props
|
|
75
|
+
if (__mpx_perf_framework__) perf.scopeEnd(idProps)
|
|
77
76
|
|
|
78
77
|
// ───── style 阶段 ─────
|
|
79
|
-
let
|
|
80
|
-
if (__mpx_perf_framework__)
|
|
78
|
+
let idStyle = -1
|
|
79
|
+
if (__mpx_perf_framework__) idStyle = perf.scopeStart('text:render:style')
|
|
81
80
|
const {
|
|
82
81
|
normalStyle,
|
|
83
82
|
hasVarDec,
|
|
@@ -85,38 +84,38 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
|
|
|
85
84
|
hasPositionFixed
|
|
86
85
|
} = useTransformStyle(currentStyle, {
|
|
87
86
|
enableVar,
|
|
88
|
-
externalVarContext,
|
|
89
87
|
parentFontSize,
|
|
90
88
|
parentWidth,
|
|
91
89
|
parentHeight
|
|
92
90
|
})
|
|
93
|
-
|
|
91
|
+
|
|
92
|
+
let children: ReactNode
|
|
93
|
+
let isStringOnly: boolean
|
|
94
|
+
if (decode) {
|
|
95
|
+
({ children, isStringOnly } = getDecodedChildren(props.children))
|
|
96
|
+
} else {
|
|
97
|
+
children = props.children
|
|
98
|
+
isStringOnly = isStringChildren(children)
|
|
99
|
+
}
|
|
100
|
+
const childTextStyle = !isStringOnly ? (splitStyle(normalStyle).textStyle as TextStyle | undefined) : undefined
|
|
101
|
+
const { inheritedText, textPassThrough } = useTextPassThroughText(childTextStyle)
|
|
102
|
+
|
|
103
|
+
const mergedProps = inheritedText?.pendingTextProps
|
|
104
|
+
? extendObject({}, inheritedText.pendingTextProps, props)
|
|
105
|
+
: props
|
|
106
|
+
const finalStyle = inheritedText?.textStyle
|
|
107
|
+
? extendObject({}, inheritedText.textStyle, normalStyle)
|
|
108
|
+
: normalStyle
|
|
94
109
|
|
|
95
110
|
const nodeRef = useRef(null)
|
|
96
111
|
useNodesRef<Text, _TextProps>(mergedProps, ref, nodeRef, {
|
|
97
112
|
style: finalStyle
|
|
98
113
|
})
|
|
99
|
-
|
|
100
|
-
const children = decode ? getDecodedChildren(mergedProps.children) : mergedProps.children
|
|
101
|
-
const isStringOnly = isStringChildren(children)
|
|
102
|
-
let childTextStyle: TextStyle | undefined
|
|
103
|
-
if (!isStringOnly) {
|
|
104
|
-
const { textStyle = {} } = splitStyle(finalStyle)
|
|
105
|
-
childTextStyle = Object.keys(textStyle).length ? textStyle : undefined
|
|
106
|
-
}
|
|
107
|
-
const textPassThrough = useTextPassThroughValue(
|
|
108
|
-
childTextStyle,
|
|
109
|
-
undefined,
|
|
110
|
-
{
|
|
111
|
-
inheritTextProps: false,
|
|
112
|
-
disabled: isStringOnly
|
|
113
|
-
}
|
|
114
|
-
)
|
|
115
|
-
if (__mpx_perf_framework__) stopStyle!()
|
|
114
|
+
if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
|
|
116
115
|
|
|
117
116
|
// ───── innerProps 阶段 ─────
|
|
118
|
-
let
|
|
119
|
-
if (__mpx_perf_framework__)
|
|
117
|
+
let idInnerProps = -1
|
|
118
|
+
if (__mpx_perf_framework__) idInnerProps = perf.scopeStart('text:render:innerProps')
|
|
120
119
|
const innerProps = useInnerProps(
|
|
121
120
|
extendObject(
|
|
122
121
|
{},
|
|
@@ -133,15 +132,13 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
|
|
|
133
132
|
'decode'
|
|
134
133
|
]
|
|
135
134
|
)
|
|
136
|
-
if (__mpx_perf_framework__)
|
|
135
|
+
if (__mpx_perf_framework__) perf.scopeEnd(idInnerProps)
|
|
137
136
|
|
|
138
137
|
// ───── createElement 阶段 ─────
|
|
139
|
-
let
|
|
140
|
-
if (__mpx_perf_framework__)
|
|
138
|
+
let idCreate = -1
|
|
139
|
+
if (__mpx_perf_framework__) idCreate = perf.scopeStart('text:render:createElement')
|
|
141
140
|
let finalComponent:JSX.Element = createElement(Text, innerProps, wrapChildren(
|
|
142
|
-
|
|
143
|
-
children
|
|
144
|
-
}),
|
|
141
|
+
children,
|
|
145
142
|
{
|
|
146
143
|
hasVarDec,
|
|
147
144
|
varContext: varContextRef.current,
|
|
@@ -152,9 +149,9 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
|
|
|
152
149
|
if (hasPositionFixed) {
|
|
153
150
|
finalComponent = createElement(Portal, null, finalComponent)
|
|
154
151
|
}
|
|
155
|
-
if (__mpx_perf_framework__)
|
|
152
|
+
if (__mpx_perf_framework__) perf.scopeEnd(idCreate)
|
|
156
153
|
|
|
157
|
-
if (__mpx_perf_framework__)
|
|
154
|
+
if (__mpx_perf_framework__) perf.scopeEnd(idTotal)
|
|
158
155
|
return finalComponent
|
|
159
156
|
})
|
|
160
157
|
|
|
@@ -93,7 +93,6 @@ interface VideoProps {
|
|
|
93
93
|
'preferred-peak-bit-rate'?: number
|
|
94
94
|
'enable-auto-rotation'?: number
|
|
95
95
|
'enable-var'?: boolean
|
|
96
|
-
'external-var-context'?: Record<string, any>
|
|
97
96
|
'parent-font-size'?: number
|
|
98
97
|
'parent-width'?: number
|
|
99
98
|
'parent-height'?: number
|
|
@@ -155,7 +154,6 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
|
|
|
155
154
|
'preferred-peak-bit-rate': preferredPeakBitRate = 0,
|
|
156
155
|
'enable-auto-rotation': enableAutoRotation = false,
|
|
157
156
|
'enable-var': enableVar,
|
|
158
|
-
'external-var-context': externalVarContext,
|
|
159
157
|
'parent-font-size': parentFontSize,
|
|
160
158
|
'parent-width': parentWidth,
|
|
161
159
|
'parent-height': parentHeight
|
|
@@ -172,12 +170,12 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
|
|
|
172
170
|
propsRef.current = props
|
|
173
171
|
|
|
174
172
|
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } =
|
|
175
|
-
useTransformStyle(
|
|
173
|
+
useTransformStyle(style, {
|
|
176
174
|
enableVar,
|
|
177
|
-
externalVarContext,
|
|
178
175
|
parentFontSize,
|
|
179
176
|
parentWidth,
|
|
180
|
-
parentHeight
|
|
177
|
+
parentHeight,
|
|
178
|
+
defaultStyle: styles.container
|
|
181
179
|
})
|
|
182
180
|
|
|
183
181
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({
|