@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
|
@@ -4,12 +4,11 @@
|
|
|
4
4
|
* ✔ decode
|
|
5
5
|
*/
|
|
6
6
|
import { Text } from 'react-native';
|
|
7
|
-
import { useRef, forwardRef, createElement, Children
|
|
7
|
+
import { useRef, forwardRef, createElement, Children } from 'react';
|
|
8
8
|
import Portal from './mpx-portal';
|
|
9
9
|
import useInnerProps from './getInnerListeners';
|
|
10
10
|
import useNodesRef from './useNodesRef'; // 引入辅助函数
|
|
11
|
-
import { useTransformStyle, wrapChildren, extendObject, getDefaultAllowFontScaling,
|
|
12
|
-
import { TextPassThroughContext } from './context';
|
|
11
|
+
import { useTransformStyle, wrapChildren, extendObject, getDefaultAllowFontScaling, useTextPassThroughText, isStringChildren, splitStyle } from './utils';
|
|
13
12
|
import * as perf from '@mpxjs/perf';
|
|
14
13
|
const decodeMap = {
|
|
15
14
|
'<': '<',
|
|
@@ -28,59 +27,66 @@ function decode(value) {
|
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
29
|
function getDecodedChildren(children) {
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
if (typeof children === 'string') {
|
|
31
|
+
return { children: decode(children), isStringOnly: true };
|
|
32
|
+
}
|
|
33
|
+
let isStringOnly = true;
|
|
34
|
+
const decoded = Children.map(children, (child) => {
|
|
35
|
+
if (typeof child === 'string')
|
|
33
36
|
return decode(child);
|
|
34
|
-
|
|
37
|
+
isStringOnly = false;
|
|
35
38
|
return child;
|
|
36
39
|
});
|
|
40
|
+
return { children: decoded, isStringOnly };
|
|
37
41
|
}
|
|
38
42
|
const _Text = forwardRef((props, ref) => {
|
|
39
|
-
let
|
|
43
|
+
let idTotal = -1;
|
|
40
44
|
if (__mpx_perf_framework__)
|
|
41
|
-
|
|
45
|
+
idTotal = perf.scopeStart('text:render:total');
|
|
42
46
|
// ───── props 阶段 ─────
|
|
43
|
-
let
|
|
47
|
+
let idProps = -1;
|
|
44
48
|
if (__mpx_perf_framework__)
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props);
|
|
48
|
-
const { style: currentStyle = {}, allowFontScaling, selectable, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = mergedProps;
|
|
49
|
+
idProps = perf.scopeStart('text:render:props');
|
|
50
|
+
const { style: currentStyle = {}, allowFontScaling, selectable, 'enable-var': enableVar, 'user-select': userSelect, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, decode } = props;
|
|
49
51
|
if (__mpx_perf_framework__)
|
|
50
|
-
|
|
52
|
+
perf.scopeEnd(idProps);
|
|
51
53
|
// ───── style 阶段 ─────
|
|
52
|
-
let
|
|
54
|
+
let idStyle = -1;
|
|
53
55
|
if (__mpx_perf_framework__)
|
|
54
|
-
|
|
56
|
+
idStyle = perf.scopeStart('text:render:style');
|
|
55
57
|
const { normalStyle, hasVarDec, varContextRef, hasPositionFixed } = useTransformStyle(currentStyle, {
|
|
56
58
|
enableVar,
|
|
57
|
-
externalVarContext,
|
|
58
59
|
parentFontSize,
|
|
59
60
|
parentWidth,
|
|
60
61
|
parentHeight
|
|
61
62
|
});
|
|
62
|
-
|
|
63
|
+
let children;
|
|
64
|
+
let isStringOnly;
|
|
65
|
+
if (decode) {
|
|
66
|
+
({ children, isStringOnly } = getDecodedChildren(props.children));
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
children = props.children;
|
|
70
|
+
isStringOnly = isStringChildren(children);
|
|
71
|
+
}
|
|
72
|
+
const childTextStyle = !isStringOnly ? splitStyle(normalStyle).textStyle : undefined;
|
|
73
|
+
const { inheritedText, textPassThrough } = useTextPassThroughText(childTextStyle);
|
|
74
|
+
const mergedProps = inheritedText?.pendingTextProps
|
|
75
|
+
? extendObject({}, inheritedText.pendingTextProps, props)
|
|
76
|
+
: props;
|
|
77
|
+
const finalStyle = inheritedText?.textStyle
|
|
78
|
+
? extendObject({}, inheritedText.textStyle, normalStyle)
|
|
79
|
+
: normalStyle;
|
|
63
80
|
const nodeRef = useRef(null);
|
|
64
81
|
useNodesRef(mergedProps, ref, nodeRef, {
|
|
65
82
|
style: finalStyle
|
|
66
83
|
});
|
|
67
|
-
const children = decode ? getDecodedChildren(mergedProps.children) : mergedProps.children;
|
|
68
|
-
const isStringOnly = isStringChildren(children);
|
|
69
|
-
let childTextStyle;
|
|
70
|
-
if (!isStringOnly) {
|
|
71
|
-
const { textStyle = {} } = splitStyle(finalStyle);
|
|
72
|
-
childTextStyle = Object.keys(textStyle).length ? textStyle : undefined;
|
|
73
|
-
}
|
|
74
|
-
const textPassThrough = useTextPassThroughValue(childTextStyle, undefined, {
|
|
75
|
-
inheritTextProps: false,
|
|
76
|
-
disabled: isStringOnly
|
|
77
|
-
});
|
|
78
84
|
if (__mpx_perf_framework__)
|
|
79
|
-
|
|
85
|
+
perf.scopeEnd(idStyle);
|
|
80
86
|
// ───── innerProps 阶段 ─────
|
|
81
|
-
let
|
|
87
|
+
let idInnerProps = -1;
|
|
82
88
|
if (__mpx_perf_framework__)
|
|
83
|
-
|
|
89
|
+
idInnerProps = perf.scopeStart('text:render:innerProps');
|
|
84
90
|
const innerProps = useInnerProps(extendObject({}, mergedProps, {
|
|
85
91
|
ref: nodeRef,
|
|
86
92
|
style: finalStyle,
|
|
@@ -91,14 +97,12 @@ const _Text = forwardRef((props, ref) => {
|
|
|
91
97
|
'decode'
|
|
92
98
|
]);
|
|
93
99
|
if (__mpx_perf_framework__)
|
|
94
|
-
|
|
100
|
+
perf.scopeEnd(idInnerProps);
|
|
95
101
|
// ───── createElement 阶段 ─────
|
|
96
|
-
let
|
|
102
|
+
let idCreate = -1;
|
|
97
103
|
if (__mpx_perf_framework__)
|
|
98
|
-
|
|
99
|
-
let finalComponent = createElement(Text, innerProps, wrapChildren(
|
|
100
|
-
children
|
|
101
|
-
}), {
|
|
104
|
+
idCreate = perf.scopeStart('text:render:createElement');
|
|
105
|
+
let finalComponent = createElement(Text, innerProps, wrapChildren(children, {
|
|
102
106
|
hasVarDec,
|
|
103
107
|
varContext: varContextRef.current,
|
|
104
108
|
textPassThrough
|
|
@@ -107,9 +111,9 @@ const _Text = forwardRef((props, ref) => {
|
|
|
107
111
|
finalComponent = createElement(Portal, null, finalComponent);
|
|
108
112
|
}
|
|
109
113
|
if (__mpx_perf_framework__)
|
|
110
|
-
|
|
114
|
+
perf.scopeEnd(idCreate);
|
|
111
115
|
if (__mpx_perf_framework__)
|
|
112
|
-
|
|
116
|
+
perf.scopeEnd(idTotal);
|
|
113
117
|
return finalComponent;
|
|
114
118
|
});
|
|
115
119
|
_Text.displayName = 'MpxText';
|
|
@@ -83,7 +83,6 @@ interface VideoProps {
|
|
|
83
83
|
'preferred-peak-bit-rate'?: number;
|
|
84
84
|
'enable-auto-rotation'?: number;
|
|
85
85
|
'enable-var'?: boolean;
|
|
86
|
-
'external-var-context'?: Record<string, any>;
|
|
87
86
|
'parent-font-size'?: number;
|
|
88
87
|
'parent-width'?: number;
|
|
89
88
|
'parent-height'?: number;
|
|
@@ -80,18 +80,18 @@ const styles = StyleSheet.create({
|
|
|
80
80
|
});
|
|
81
81
|
const MpxVideo = forwardRef((videoProps, ref) => {
|
|
82
82
|
const { innerProps: props = {} } = splitProps(videoProps);
|
|
83
|
-
const { src, autoplay = false, loop = false, muted = false, controls = true, poster = '', bindplay, bindpause, bindended, bindtimeupdate, bindfullscreenchange, bindwaiting, binderror, bindloadedmetadata, bindcontrolstoggle, bindseekcomplete, style, 'initial-time': initialTime = 0, 'object-fit': objectFit = 'contain', 'is-drm': isDrm = false, 'provision-url': provisionUrl, 'certificate-url': certificateUrl, 'license-url': licenseUrl, 'preferred-peak-bit-rate': preferredPeakBitRate = 0, 'enable-auto-rotation': enableAutoRotation = false, 'enable-var': enableVar, '
|
|
83
|
+
const { src, autoplay = false, loop = false, muted = false, controls = true, poster = '', bindplay, bindpause, bindended, bindtimeupdate, bindfullscreenchange, bindwaiting, binderror, bindloadedmetadata, bindcontrolstoggle, bindseekcomplete, style, 'initial-time': initialTime = 0, 'object-fit': objectFit = 'contain', 'is-drm': isDrm = false, 'provision-url': provisionUrl, 'certificate-url': certificateUrl, 'license-url': licenseUrl, 'preferred-peak-bit-rate': preferredPeakBitRate = 0, 'enable-auto-rotation': enableAutoRotation = false, 'enable-var': enableVar, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
|
|
84
84
|
const videoRef = useRef(null);
|
|
85
85
|
const viewRef = useRef(null);
|
|
86
86
|
const videoInfoRef = useRef({});
|
|
87
87
|
const propsRef = useRef({});
|
|
88
88
|
propsRef.current = props;
|
|
89
|
-
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(
|
|
89
|
+
const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } = useTransformStyle(style, {
|
|
90
90
|
enableVar,
|
|
91
|
-
externalVarContext,
|
|
92
91
|
parentFontSize,
|
|
93
92
|
parentWidth,
|
|
94
|
-
parentHeight
|
|
93
|
+
parentHeight,
|
|
94
|
+
defaultStyle: styles.container
|
|
95
95
|
});
|
|
96
96
|
const { layoutRef, layoutStyle, layoutProps } = useLayout({
|
|
97
97
|
props,
|
|
@@ -18,9 +18,9 @@ export interface _ViewProps extends ViewProps {
|
|
|
18
18
|
'hover-start-time'?: number;
|
|
19
19
|
'hover-stay-time'?: number;
|
|
20
20
|
'enable-background'?: boolean;
|
|
21
|
+
'enable-text-pass-through'?: boolean;
|
|
21
22
|
'enable-var'?: boolean;
|
|
22
23
|
'enable-fast-image'?: boolean;
|
|
23
|
-
'external-var-context'?: Record<string, any>;
|
|
24
24
|
'parent-font-size'?: number;
|
|
25
25
|
'parent-width'?: number;
|
|
26
26
|
'parent-height'?: number;
|
|
@@ -31,5 +31,6 @@ export interface _ViewProps extends ViewProps {
|
|
|
31
31
|
bindtransitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
32
32
|
catchtransitionend?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void;
|
|
33
33
|
}
|
|
34
|
+
export declare const __parseBgImageForTest: (text?: string) => any;
|
|
34
35
|
declare const _View: import("react").ForwardRefExoticComponent<_ViewProps & import("react").RefAttributes<HandlerRef<View, _ViewProps>>>;
|
|
35
36
|
export default _View;
|