@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.
Files changed (123) hide show
  1. package/lib/loader.js +2 -0
  2. package/lib/platform/style/wx/index.js +395 -104
  3. package/lib/react/index.js +3 -1
  4. package/lib/react/processTemplate.js +3 -1
  5. package/lib/react/style-helper.js +6 -6
  6. package/lib/runtime/components/react/animationHooks/index.ts +7 -3
  7. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
  8. package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
  9. package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
  10. package/lib/runtime/components/react/dist/event.config.js +28 -24
  11. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
  12. package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
  13. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -1
  14. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
  15. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -1
  16. package/lib/runtime/components/react/dist/mpx-camera.jsx +1 -2
  17. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -1
  18. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -2
  19. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
  20. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -1
  21. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
  22. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -1
  23. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
  24. package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -1
  25. package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
  26. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -1
  27. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  28. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -1
  29. package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
  30. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -1
  31. package/lib/runtime/components/react/dist/mpx-input.jsx +2 -2
  32. package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -1
  33. package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
  34. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -1
  35. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
  36. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -1
  37. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
  38. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
  39. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +5 -7
  40. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +0 -1
  41. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +2 -2
  42. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -1
  43. package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -2
  44. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -1
  45. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
  46. package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -1
  47. package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
  48. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -1
  49. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -2
  50. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -1
  51. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
  52. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +36 -31
  53. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -2
  54. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +24 -17
  55. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -1
  56. package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -6
  57. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -1
  58. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
  59. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -1
  60. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
  61. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -1
  62. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
  63. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -1
  64. package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -7
  65. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -1
  66. package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -2
  67. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -1
  68. package/lib/runtime/components/react/dist/mpx-text.jsx +44 -40
  69. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -1
  70. package/lib/runtime/components/react/dist/mpx-video.jsx +4 -4
  71. package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -1
  72. package/lib/runtime/components/react/dist/mpx-view.jsx +229 -128
  73. package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
  74. package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
  75. package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
  76. package/lib/runtime/components/react/dist/utils.d.ts +73 -69
  77. package/lib/runtime/components/react/dist/utils.jsx +1295 -442
  78. package/lib/runtime/components/react/event.config.ts +32 -25
  79. package/lib/runtime/components/react/getInnerListeners.ts +84 -60
  80. package/lib/runtime/components/react/mpx-button.tsx +18 -16
  81. package/lib/runtime/components/react/mpx-camera.tsx +0 -3
  82. package/lib/runtime/components/react/mpx-canvas/index.tsx +1 -3
  83. package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
  84. package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -6
  85. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -11
  86. package/lib/runtime/components/react/mpx-form.tsx +6 -6
  87. package/lib/runtime/components/react/mpx-icon/index.tsx +1 -3
  88. package/lib/runtime/components/react/mpx-image.tsx +65 -54
  89. package/lib/runtime/components/react/mpx-input.tsx +1 -3
  90. package/lib/runtime/components/react/mpx-label.tsx +6 -8
  91. package/lib/runtime/components/react/mpx-movable-area.tsx +3 -4
  92. package/lib/runtime/components/react/mpx-movable-view.tsx +7 -7
  93. package/lib/runtime/components/react/mpx-picker-view/index.tsx +6 -8
  94. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +2 -4
  95. package/lib/runtime/components/react/mpx-progress.tsx +0 -3
  96. package/lib/runtime/components/react/mpx-radio-group.tsx +2 -6
  97. package/lib/runtime/components/react/mpx-radio.tsx +9 -11
  98. package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -3
  99. package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -7
  100. package/lib/runtime/components/react/mpx-simple-text.tsx +36 -38
  101. package/lib/runtime/components/react/mpx-simple-view.tsx +29 -17
  102. package/lib/runtime/components/react/mpx-slider.tsx +15 -10
  103. package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -6
  104. package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -7
  105. package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -6
  106. package/lib/runtime/components/react/mpx-swiper.tsx +5 -8
  107. package/lib/runtime/components/react/mpx-switch.tsx +0 -3
  108. package/lib/runtime/components/react/mpx-text.tsx +46 -49
  109. package/lib/runtime/components/react/mpx-video.tsx +3 -5
  110. package/lib/runtime/components/react/mpx-view.tsx +250 -141
  111. package/lib/runtime/components/react/mpx-web-view.tsx +8 -3
  112. package/lib/runtime/components/react/namedColorSet.ts +150 -0
  113. package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
  114. package/lib/runtime/components/react/types/global.d.ts +1 -0
  115. package/lib/runtime/components/react/utils.tsx +1347 -539
  116. package/lib/runtime/i18n.wxs +15 -9
  117. package/lib/style-compiler/strip-conditional.js +19 -4
  118. package/lib/template-compiler/compiler.js +5 -1
  119. package/lib/utils/source-location.js +9 -13
  120. package/lib/web/index.js +3 -1
  121. package/lib/web/processTemplate.js +3 -1
  122. package/package.json +5 -4
  123. 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, useContext } from 'react';
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, useTextPassThroughValue, isStringChildren, splitStyle } from './utils';
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
  '&lt;': '<',
@@ -28,59 +27,66 @@ function decode(value) {
28
27
  }
29
28
  }
30
29
  function getDecodedChildren(children) {
31
- return Children.map(children, (child) => {
32
- if (typeof child === 'string') {
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 stopTotal;
43
+ let idTotal = -1;
40
44
  if (__mpx_perf_framework__)
41
- stopTotal = perf.scope('text:render:total');
45
+ idTotal = perf.scopeStart('text:render:total');
42
46
  // ───── props 阶段 ─────
43
- let stopProps;
47
+ let idProps = -1;
44
48
  if (__mpx_perf_framework__)
45
- stopProps = perf.scope('text:render:props');
46
- const inheritedText = useContext(TextPassThroughContext);
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
- stopProps();
52
+ perf.scopeEnd(idProps);
51
53
  // ───── style 阶段 ─────
52
- let stopStyle;
54
+ let idStyle = -1;
53
55
  if (__mpx_perf_framework__)
54
- stopStyle = perf.scope('text:render:style');
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
- const finalStyle = extendObject({}, inheritedText?.textStyle, normalStyle);
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
- stopStyle();
85
+ perf.scopeEnd(idStyle);
80
86
  // ───── innerProps 阶段 ─────
81
- let stopInnerProps;
87
+ let idInnerProps = -1;
82
88
  if (__mpx_perf_framework__)
83
- stopInnerProps = perf.scope('text:render:innerProps');
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
- stopInnerProps();
100
+ perf.scopeEnd(idInnerProps);
95
101
  // ───── createElement 阶段 ─────
96
- let stopCreate;
102
+ let idCreate = -1;
97
103
  if (__mpx_perf_framework__)
98
- stopCreate = perf.scope('text:render:createElement');
99
- let finalComponent = createElement(Text, innerProps, wrapChildren(extendObject({}, mergedProps, {
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
- stopCreate();
114
+ perf.scopeEnd(idCreate);
111
115
  if (__mpx_perf_framework__)
112
- stopTotal();
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, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight } = props;
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(extendObject({}, styles.container, style), {
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;