@mpxjs/webpack-plugin 2.10.24 → 2.11.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.
Files changed (151) hide show
  1. package/lib/index.js +4 -1
  2. package/lib/platform/style/wx/index.js +417 -120
  3. package/lib/platform/template/wx/component-config/picker.js +0 -6
  4. package/lib/react/style-helper.js +6 -6
  5. package/lib/resolver/AddEnvPlugin.js +1 -1
  6. package/lib/resolver/AddModePlugin.js +1 -1
  7. package/lib/resolver/ExtendComponentsPlugin.js +68 -0
  8. package/lib/runtime/components/extends/section-list.mpx +14 -0
  9. package/lib/runtime/components/react/animationHooks/index.ts +7 -3
  10. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
  11. package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
  12. package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
  13. package/lib/runtime/components/react/dist/event.config.js +28 -24
  14. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
  15. package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
  16. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -2
  17. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
  18. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -2
  19. package/lib/runtime/components/react/dist/mpx-camera.jsx +36 -5
  20. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -2
  21. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -3
  22. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
  23. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -2
  24. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
  25. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -2
  26. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
  27. package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -2
  28. package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
  29. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -2
  30. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  31. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -2
  32. package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
  33. package/lib/runtime/components/react/dist/mpx-inline-text.jsx +13 -4
  34. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -2
  35. package/lib/runtime/components/react/dist/mpx-input.jsx +16 -8
  36. package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -2
  37. package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
  38. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -2
  39. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
  40. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -2
  41. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
  42. package/lib/runtime/components/react/dist/mpx-nav.jsx +1 -1
  43. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +72 -23
  44. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -2
  45. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +4 -0
  46. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
  47. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +10 -14
  48. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -2
  49. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.js +0 -5
  50. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +1 -1
  51. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +34 -14
  52. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -2
  53. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +4 -5
  54. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -2
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +3 -5
  56. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +5 -4
  57. package/lib/runtime/components/react/dist/mpx-popup/index.jsx +2 -2
  58. package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +3 -2
  59. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -2
  60. package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -3
  61. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -2
  62. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
  63. package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -2
  64. package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
  65. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -2
  66. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -3
  67. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -2
  68. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
  69. package/lib/runtime/components/react/dist/mpx-section-list.d.ts +51 -0
  70. package/lib/runtime/components/react/dist/mpx-section-list.jsx +376 -0
  71. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +37 -19
  72. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
  73. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
  74. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -2
  75. package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -7
  76. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -2
  77. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
  78. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -2
  79. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
  80. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -2
  81. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
  82. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -2
  83. package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -8
  84. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -2
  85. package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -3
  86. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -2
  87. package/lib/runtime/components/react/dist/mpx-text.jsx +43 -25
  88. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -2
  89. package/lib/runtime/components/react/dist/mpx-video.jsx +4 -5
  90. package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -2
  91. package/lib/runtime/components/react/dist/mpx-view.jsx +214 -114
  92. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
  93. package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
  94. package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
  95. package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
  96. package/lib/runtime/components/react/dist/utils.d.ts +71 -70
  97. package/lib/runtime/components/react/dist/utils.jsx +1295 -456
  98. package/lib/runtime/components/react/event.config.ts +32 -25
  99. package/lib/runtime/components/react/getInnerListeners.ts +84 -60
  100. package/lib/runtime/components/react/mpx-button.tsx +18 -18
  101. package/lib/runtime/components/react/mpx-camera.tsx +40 -8
  102. package/lib/runtime/components/react/mpx-canvas/index.tsx +5 -7
  103. package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
  104. package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -8
  105. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -13
  106. package/lib/runtime/components/react/mpx-form.tsx +6 -8
  107. package/lib/runtime/components/react/mpx-icon/index.tsx +1 -5
  108. package/lib/runtime/components/react/mpx-image.tsx +66 -58
  109. package/lib/runtime/components/react/mpx-inline-text.tsx +13 -4
  110. package/lib/runtime/components/react/mpx-input.tsx +19 -12
  111. package/lib/runtime/components/react/mpx-label.tsx +6 -10
  112. package/lib/runtime/components/react/mpx-movable-area.tsx +3 -5
  113. package/lib/runtime/components/react/mpx-movable-view.tsx +7 -9
  114. package/lib/runtime/components/react/mpx-nav.tsx +1 -1
  115. package/lib/runtime/components/react/mpx-picker/index.tsx +100 -29
  116. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +3 -3
  117. package/lib/runtime/components/react/mpx-picker/selector.tsx +1 -1
  118. package/lib/runtime/components/react/mpx-picker/type.ts +4 -0
  119. package/lib/runtime/components/react/mpx-picker-view/index.tsx +17 -24
  120. package/lib/runtime/components/react/mpx-picker-view/pickerVIewContext.ts +0 -9
  121. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +44 -23
  122. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +1 -9
  123. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -9
  124. package/lib/runtime/components/react/mpx-popup/index.tsx +7 -3
  125. package/lib/runtime/components/react/mpx-popup/popupBase.tsx +3 -2
  126. package/lib/runtime/components/react/mpx-progress.tsx +0 -6
  127. package/lib/runtime/components/react/mpx-radio-group.tsx +2 -8
  128. package/lib/runtime/components/react/mpx-radio.tsx +9 -13
  129. package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -6
  130. package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -9
  131. package/lib/runtime/components/react/mpx-section-list.tsx +557 -0
  132. package/lib/runtime/components/react/mpx-simple-text.tsx +36 -25
  133. package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
  134. package/lib/runtime/components/react/mpx-slider.tsx +15 -13
  135. package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -8
  136. package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -9
  137. package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -7
  138. package/lib/runtime/components/react/mpx-swiper.tsx +5 -11
  139. package/lib/runtime/components/react/mpx-switch.tsx +0 -6
  140. package/lib/runtime/components/react/mpx-text.tsx +45 -36
  141. package/lib/runtime/components/react/mpx-video.tsx +3 -8
  142. package/lib/runtime/components/react/mpx-view.tsx +235 -129
  143. package/lib/runtime/components/react/mpx-web-view.tsx +12 -6
  144. package/lib/runtime/components/react/namedColorSet.ts +150 -0
  145. package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
  146. package/lib/runtime/components/react/types/global.d.ts +1 -0
  147. package/lib/runtime/components/react/utils.tsx +1352 -550
  148. package/lib/runtime/i18n.wxs +15 -9
  149. package/lib/style-compiler/strip-conditional.js +19 -4
  150. package/lib/template-compiler/compiler.js +6 -0
  151. package/package.json +6 -6
@@ -1,10 +1,14 @@
1
1
  import { View, ViewProps, TextStyle } from 'react-native'
2
2
  import { createElement } from 'react'
3
- import { splitProps, splitStyle, wrapChildren, extendObject, useTextPassThroughValue, transformBoxSizing, isBoxSizingAffectingStyle } from './utils'
3
+ import { splitProps, splitStyle, wrapChildren, extendObject, useTextPassThrough, transformBoxSizing, isBoxSizingAffectingStyle } from './utils'
4
4
  import useInnerProps from './getInnerListeners'
5
5
  import * as perf from '@mpxjs/perf'
6
6
 
7
- const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
7
+ interface SimpleViewProps extends ViewProps {
8
+ 'enable-text-pass-through'?: boolean
9
+ }
10
+
11
+ const SimpleView = (simpleViewProps: SimpleViewProps): JSX.Element => {
8
12
  let idTotal = -1
9
13
  if (__mpx_perf_framework__) idTotal = perf.scopeStart('simple-view:render:total')
10
14
 
@@ -12,6 +16,7 @@ const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
12
16
  let idStyle = -1
13
17
  if (__mpx_perf_framework__) idStyle = perf.scopeStart('simple-view:render:style')
14
18
  const { textProps, innerProps: props = {} } = splitProps(simpleViewProps)
19
+ const enableTextPassThrough = props['enable-text-pass-through']
15
20
 
16
21
  let hasBoxSizingAffectingStyle = false
17
22
  const { textStyle, innerStyle = {} } = splitStyle(props.style || {}, (key) => {
@@ -19,7 +24,14 @@ const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
19
24
  hasBoxSizingAffectingStyle = true
20
25
  }
21
26
  })
22
- const textPassThrough = useTextPassThroughValue(textStyle as TextStyle, textProps)
27
+ const textPassThrough = useTextPassThrough(textStyle as TextStyle, textProps, { enableTextPassThrough })
28
+
29
+ let styleObj: Record<string, any> = innerStyle
30
+ if (hasBoxSizingAffectingStyle) {
31
+ // 复制一次再 mutate,避免污染 splitStyle 复用的原 props.style
32
+ styleObj = extendObject({}, innerStyle)
33
+ transformBoxSizing(styleObj)
34
+ }
23
35
  if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
24
36
 
25
37
  // ───── innerProps 阶段 ─────
@@ -30,7 +42,7 @@ const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
30
42
  {},
31
43
  props,
32
44
  {
33
- style: transformBoxSizing(extendObject({}, innerStyle), hasBoxSizingAffectingStyle)
45
+ style: styleObj
34
46
  }
35
47
  )
36
48
  )
@@ -40,7 +52,7 @@ const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
40
52
  let idCreate = -1
41
53
  if (__mpx_perf_framework__) idCreate = perf.scopeStart('simple-view:render:createElement')
42
54
  const result = createElement(View, innerProps, wrapChildren(
43
- props,
55
+ props.children,
44
56
  {
45
57
  hasVarDec: false,
46
58
  textPassThrough
@@ -31,7 +31,7 @@ import {
31
31
  } from 'react-native'
32
32
  import { GestureDetector, Gesture, GestureStateChangeEvent, PanGestureHandlerEventPayload } from 'react-native-gesture-handler'
33
33
  import Animated, { useSharedValue, useAnimatedStyle, runOnJS } from 'react-native-reanimated'
34
- import { warn } from '@mpxjs/utils'
34
+ import { warn, hasOwn } from '@mpxjs/utils'
35
35
 
36
36
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
37
37
  import useNodesRef, { HandlerRef } from './useNodesRef'
@@ -59,8 +59,6 @@ export interface SliderProps {
59
59
  style?: ViewStyle & Record<string, any>
60
60
  'enable-offset'?: boolean
61
61
  'enable-var'?: boolean
62
- 'external-var-context'?: Record<string, any>
63
- 'parent-font-size'?: number
64
62
  'parent-width'?: number
65
63
  'parent-height'?: number
66
64
  }
@@ -84,8 +82,6 @@ const Slider = forwardRef<
84
82
  name,
85
83
  style = {},
86
84
  'enable-var': enableVar,
87
- 'external-var-context': externalVarContext,
88
- 'parent-font-size': parentFontSize,
89
85
  'parent-width': parentWidth,
90
86
  'parent-height': parentHeight
91
87
  } = props
@@ -128,8 +124,6 @@ const Slider = forwardRef<
128
124
  hasPositionFixed
129
125
  } = useTransformStyle(style, {
130
126
  enableVar,
131
- externalVarContext,
132
- parentFontSize,
133
127
  parentWidth,
134
128
  parentHeight
135
129
  })
@@ -337,12 +331,20 @@ const Slider = forwardRef<
337
331
  const blockSizeNum = Math.max(12, Math.min(28, blockSize))
338
332
  const trackHeight = 4
339
333
 
340
- const containerStyle: ViewStyle = extendObject({} as ViewStyle, {
341
- flexDirection: 'row' as const,
342
- alignItems: 'center' as const,
343
- minHeight: Math.max(blockSizeNum + 8, 40),
344
- paddingHorizontal: 14 // 固定内边距,不受 block-size 影响
345
- }, normalStyle, layoutStyle)
334
+ // 用户传 padding shorthand 时跳过 paddingLeft/Right default,
335
+ // 避免 number 形式 padding:0 longhand default 反向覆盖
336
+ const containerStyle: ViewStyle = extendObject(
337
+ {} as ViewStyle,
338
+ {
339
+ flexDirection: 'row' as const,
340
+ alignItems: 'center' as const,
341
+ minHeight: Math.max(blockSizeNum + 8, 40)
342
+ },
343
+ hasOwn(style, 'padding') ? null : { paddingHorizontal: 14 },
344
+ hasOwn(style, 'margin') ? null : { marginHorizontal: 18, marginVertical: 10 },
345
+ normalStyle,
346
+ layoutStyle
347
+ )
346
348
 
347
349
  const trackStyle: ViewStyle = {
348
350
  flex: 1,
@@ -2,7 +2,7 @@ import { useEffect, useRef, useContext, forwardRef, useMemo, createElement, Reac
2
2
  import { Animated, StyleSheet, View, NativeSyntheticEvent, ViewStyle, LayoutChangeEvent, useAnimatedValue } from 'react-native'
3
3
  import { ScrollViewContext, StickyContext } from './context'
4
4
  import useNodesRef, { HandlerRef } from './useNodesRef'
5
- import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject, useTextPassThroughValue } from './utils'
5
+ import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject, useTextPassThrough } from './utils'
6
6
  import { error } from '@mpxjs/utils'
7
7
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
8
8
 
@@ -12,8 +12,7 @@ interface StickyHeaderProps {
12
12
  padding?: [number, number, number, number];
13
13
  'offset-top'?: number;
14
14
  'enable-var'?: boolean;
15
- 'external-var-context'?: Record<string, any>;
16
- 'parent-font-size'?: number;
15
+ 'enable-text-pass-through'?: boolean;
17
16
  'parent-width'?: number;
18
17
  'parent-height'?: number;
19
18
  bindstickontopchange?: (e: NativeSyntheticEvent<unknown>) => void;
@@ -27,8 +26,7 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
27
26
  padding = [0, 0, 0, 0],
28
27
  'offset-top': offsetTop = 0,
29
28
  'enable-var': enableVar,
30
- 'external-var-context': externalVarContext,
31
- 'parent-font-size': parentFontSize,
29
+ 'enable-text-pass-through': enableTextPassThrough,
32
30
  'parent-width': parentWidth,
33
31
  'parent-height': parentHeight
34
32
  } = props
@@ -47,12 +45,12 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
47
45
  hasSelfPercent,
48
46
  setWidth,
49
47
  setHeight
50
- } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
48
+ } = useTransformStyle(style, { enableVar, parentWidth, parentHeight })
51
49
 
52
50
  const { layoutRef, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: headerRef, onLayout })
53
51
 
54
52
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
55
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
53
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
56
54
 
57
55
  const headerTopAnimated = useAnimatedValue(0)
58
56
  // harmony animatedValue 不支持通过 _value 访问
@@ -161,7 +159,7 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
161
159
  Animated.View,
162
160
  innerProps,
163
161
  wrapChildren(
164
- props,
162
+ props.children,
165
163
  {
166
164
  hasVarDec,
167
165
  varContext: varContextRef.current,
@@ -2,7 +2,7 @@
2
2
  import { useRef, forwardRef, createElement, ReactNode, useCallback, useMemo } from 'react'
3
3
  import { View, ViewStyle } from 'react-native'
4
4
  import useNodesRef, { HandlerRef } from './useNodesRef'
5
- import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject, useTextPassThroughValue } from './utils'
5
+ import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject, useTextPassThrough } from './utils'
6
6
  import { StickyContext } from './context'
7
7
  import useInnerProps from './getInnerListeners'
8
8
 
@@ -11,8 +11,7 @@ interface StickySectionProps {
11
11
  style?: ViewStyle;
12
12
  'offset-top'?: number;
13
13
  'enable-var'?: boolean;
14
- 'external-var-context'?: Record<string, any>;
15
- 'parent-font-size'?: number;
14
+ 'enable-text-pass-through'?: boolean;
16
15
  'parent-width'?: number;
17
16
  'parent-height'?: number;
18
17
  }
@@ -22,8 +21,7 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
22
21
  const {
23
22
  style,
24
23
  'enable-var': enableVar,
25
- 'external-var-context': externalVarContext,
26
- 'parent-font-size': parentFontSize,
24
+ 'enable-text-pass-through': enableTextPassThrough,
27
25
  'parent-width': parentWidth,
28
26
  'parent-height': parentHeight
29
27
  } = props
@@ -36,12 +34,12 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
36
34
  hasSelfPercent,
37
35
  setWidth,
38
36
  setHeight
39
- } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
37
+ } = useTransformStyle(style, { enableVar, parentWidth, parentHeight })
40
38
 
41
39
  const { layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: sectionRef, onLayout })
42
40
 
43
41
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
44
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
42
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
45
43
 
46
44
  const stickyHeaders = useRef<Map<string, any>>(new Map())
47
45
 
@@ -69,7 +67,7 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
69
67
  }
70
68
 
71
69
  const innerProps = useInnerProps(extendObject({}, props, {
72
- style: extendObject(innerStyle, layoutStyle),
70
+ style: extendObject({}, innerStyle, layoutStyle),
73
71
  ref: sectionRef
74
72
  }, layoutProps), [
75
73
  'offset-top'
@@ -83,7 +81,7 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
83
81
  StickyContext.Provider,
84
82
  { value: contextValue },
85
83
  wrapChildren(
86
- props,
84
+ props.children,
87
85
  {
88
86
  hasVarDec,
89
87
  varContext: varContextRef.current,
@@ -3,15 +3,14 @@ import Animated, { useAnimatedStyle, interpolate, SharedValue } from 'react-nati
3
3
  import { ReactNode, forwardRef, useRef, useContext, createElement } from 'react'
4
4
  import useInnerProps from './getInnerListeners'
5
5
  import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
6
- import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout, extendObject, isHarmony, useTextPassThroughValue } from './utils'
6
+ import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout, extendObject, isHarmony, useTextPassThrough } from './utils'
7
7
  import { SwiperContext } from './context'
8
8
 
9
9
  interface SwiperItemProps {
10
10
  'item-id'?: string
11
11
  'enable-offset'?: boolean
12
12
  'enable-var': boolean
13
- 'external-var-context'?: Record<string, any>
14
- 'parent-font-size'?: number
13
+ 'enable-text-pass-through'?: boolean
15
14
  'parent-width'?: number
16
15
  'parent-height'?: number
17
16
  children?: ReactNode
@@ -30,7 +29,7 @@ interface ContextType {
30
29
  const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProps>((props: SwiperItemProps, ref) => {
31
30
  const {
32
31
  'enable-var': enableVar,
33
- 'external-var-context': externalVarContext,
32
+ 'enable-text-pass-through': enableTextPassThrough,
34
33
  style,
35
34
  customStyle,
36
35
  itemIndex
@@ -51,9 +50,9 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
51
50
  hasSelfPercent,
52
51
  setWidth,
53
52
  setHeight
54
- } = useTransformStyle(style, { enableVar, externalVarContext })
53
+ } = useTransformStyle(style, { enableVar })
55
54
  const { textStyle, innerStyle } = splitStyle(normalStyle)
56
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
55
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
57
56
  useNodesRef(props, ref, nodeRef, {
58
57
  style: normalStyle
59
58
  })
@@ -103,7 +102,7 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
103
102
  style: [innerStyle, layoutStyle, itemAnimatedStyle, customStyle],
104
103
  'data-itemId': props['item-id']
105
104
  })
106
- return createElement(Animated.View, mergeProps, wrapChildren(props, {
105
+ return createElement(Animated.View, mergeProps, wrapChildren(props.children, {
107
106
  hasVarDec,
108
107
  varContext: varContextRef.current,
109
108
  textPassThrough
@@ -5,7 +5,7 @@ import Animated, { useAnimatedStyle, useSharedValue, withTiming, Easing, runOnJS
5
5
  import React, { JSX, forwardRef, useRef, useEffect, ReactNode, ReactElement, useMemo, createElement } from 'react'
6
6
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
7
7
  import useNodesRef, { HandlerRef } from './useNodesRef' // 引入辅助函数
8
- import { useTransformStyle, splitStyle, splitProps, useLayout, wrapChildren, extendObject, GestureHandler, flatGesture, useRunOnJSCallback, useTextPassThroughValue } from './utils'
8
+ import { useTransformStyle, splitStyle, splitProps, useLayout, wrapChildren, extendObject, GestureHandler, flatGesture, useRunOnJSCallback, useTextPassThrough } from './utils'
9
9
  import { SwiperContext } from './context'
10
10
  import Portal from './mpx-portal'
11
11
  /**
@@ -70,10 +70,9 @@ interface SwiperProps {
70
70
  'next-margin'?: string
71
71
  'enable-offset'?: boolean
72
72
  'enable-var': boolean
73
- 'parent-font-size'?: number
73
+ 'enable-text-pass-through'?: boolean
74
74
  'parent-width'?: number
75
75
  'parent-height'?: number
76
- 'external-var-context'?: Record<string, any>
77
76
  'wait-for'?: Array<GestureHandler>
78
77
  'simultaneous-handlers'?: Array<GestureHandler>
79
78
  disableGesture?: boolean
@@ -147,10 +146,9 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
147
146
  'indicator-margin': paginationMargin = 10,
148
147
  'indicator-active-color': activeDotColor = '#000000',
149
148
  'enable-var': enableVar = false,
150
- 'parent-font-size': parentFontSize,
149
+ 'enable-text-pass-through': enableTextPassThrough,
151
150
  'parent-width': parentWidth,
152
151
  'parent-height': parentHeight,
153
- 'external-var-context': externalVarContext,
154
152
  'simultaneous-handlers': originSimultaneousHandlers = [],
155
153
  'wait-for': waitFor = [],
156
154
  style = {},
@@ -192,14 +190,12 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
192
190
  setHeight
193
191
  } = useTransformStyle(style, {
194
192
  enableVar,
195
- externalVarContext,
196
- parentFontSize,
197
193
  parentWidth,
198
194
  parentHeight
199
195
  })
200
196
  const { textStyle } = splitStyle(normalStyle)
201
197
  const { textProps } = splitProps(props)
202
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
198
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
203
199
  const preMargin = props['previous-margin'] ? global.__formatValue(props['previous-margin']) as number : 0
204
200
  const nextMargin = props['next-margin'] ? global.__formatValue(props['next-margin']) as number : 0
205
201
  const preMarginShared = useSharedValue(preMargin)
@@ -930,9 +926,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
930
926
  const animateComponent = createElement(Animated.View, {
931
927
  key: 'swiperContainer',
932
928
  style: [{ flexDirection: dir === 'x' ? 'row' : 'column', width: '100%', height: '100%' }, animatedStyles]
933
- }, wrapChildren({
934
- children: arrPages
935
- }, {
929
+ }, wrapChildren(arrPages, {
936
930
  hasVarDec,
937
931
  varContext: varContextRef.current,
938
932
  textPassThrough
@@ -23,10 +23,8 @@ interface _SwitchProps extends SwitchProps {
23
23
  disabled: boolean
24
24
  color: string
25
25
  'enable-var'?: boolean
26
- 'parent-font-size'?: number
27
26
  'parent-width'?: number
28
27
  'parent-height'?: number
29
- 'external-var-context'?: Record<string, any>
30
28
  bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
31
29
  catchchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
32
30
  }
@@ -39,8 +37,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
39
37
  disabled = false,
40
38
  color = '#04BE02',
41
39
  'enable-var': enableVar,
42
- 'external-var-context': externalVarContext,
43
- 'parent-font-size': parentFontSize,
44
40
  'parent-width': parentWidth,
45
41
  'parent-height': parentHeight,
46
42
  bindchange,
@@ -67,8 +63,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
67
63
  hasPositionFixed
68
64
  } = useTransformStyle(style, {
69
65
  enableVar,
70
- externalVarContext,
71
- parentFontSize,
72
66
  parentWidth,
73
67
  parentHeight
74
68
  })
@@ -9,9 +9,10 @@ import { useRef, forwardRef, ReactNode, JSX, createElement, Children, useContext
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, useTextPassThroughValue, isStringChildren, splitStyle } from './utils'
13
- import { TextPassThroughContext } from './context'
12
+ import { useTransformStyle, wrapChildren, extendObject, getDefaultAllowFontScaling, isStringChildren, splitStyle, resolveTextFontSizePercentStyle, resolveTextLineHeightPercentStyle } from './utils'
14
13
  import * as perf from '@mpxjs/perf'
14
+ import { diffAndCloneA } from '@mpxjs/utils'
15
+ import { TextPassThroughContext, TextPassThroughContextValue } from './context'
15
16
 
16
17
  const decodeMap = {
17
18
  '&lt;': '<',
@@ -31,13 +32,17 @@ function decode (value: string) {
31
32
  }
32
33
  }
33
34
 
34
- function getDecodedChildren (children: ReactNode) {
35
- return Children.map(children, (child) => {
36
- if (typeof child === 'string') {
37
- return decode(child)
38
- }
35
+ function getDecodedChildren (children: ReactNode): { children: ReactNode, isStringOnly: boolean } {
36
+ if (typeof children === 'string') {
37
+ return { children: decode(children), isStringOnly: true }
38
+ }
39
+ let isStringOnly = true
40
+ const decoded = Children.map(children, (child) => {
41
+ if (typeof child === 'string') return decode(child)
42
+ isStringOnly = false
39
43
  return child
40
44
  })
45
+ return { children: decoded, isStringOnly }
41
46
  }
42
47
  interface _TextProps extends TextProps {
43
48
  style?: TextStyle
@@ -45,8 +50,6 @@ interface _TextProps extends TextProps {
45
50
  selectable?: boolean
46
51
  'user-select'?: boolean
47
52
  'enable-var'?: boolean
48
- 'external-var-context'?: Record<string, any>
49
- 'parent-font-size'?: number
50
53
  'parent-width'?: number
51
54
  'parent-height'?: number
52
55
  decode?: boolean
@@ -59,20 +62,16 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
59
62
  // ───── props 阶段 ─────
60
63
  let idProps = -1
61
64
  if (__mpx_perf_framework__) idProps = perf.scopeStart('text:render:props')
62
- const inheritedText = useContext(TextPassThroughContext)
63
- const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props)
64
65
  const {
65
66
  style: currentStyle = {},
66
67
  allowFontScaling,
67
68
  selectable,
68
69
  'enable-var': enableVar,
69
- 'external-var-context': externalVarContext,
70
70
  'user-select': userSelect,
71
- 'parent-font-size': parentFontSize,
72
71
  'parent-width': parentWidth,
73
72
  'parent-height': parentHeight,
74
73
  decode
75
- } = mergedProps
74
+ } = props
76
75
  if (__mpx_perf_framework__) perf.scopeEnd(idProps)
77
76
 
78
77
  // ───── style 阶段 ─────
@@ -85,33 +84,45 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
85
84
  hasPositionFixed
86
85
  } = useTransformStyle(currentStyle, {
87
86
  enableVar,
88
- externalVarContext,
89
- parentFontSize,
90
87
  parentWidth,
91
88
  parentHeight
92
89
  })
93
- const finalStyle = extendObject({}, inheritedText?.textStyle, normalStyle)
90
+
91
+ let children: ReactNode
92
+ let isStringOnly: boolean
93
+ if (decode) {
94
+ ({ children, isStringOnly } = getDecodedChildren(props.children))
95
+ } else {
96
+ children = props.children
97
+ isStringOnly = isStringChildren(children)
98
+ }
99
+ const inheritedText = useContext(TextPassThroughContext)
100
+ const resolvedNormalStyle = resolveTextFontSizePercentStyle(normalStyle, inheritedText?.textStyle)
101
+ const childTextStyle = !isStringOnly ? (splitStyle(resolvedNormalStyle).textStyle as TextStyle | undefined) : undefined
102
+ const textPassThroughRef = useRef<TextPassThroughContextValue | null>(null)
103
+ let textPassThrough: TextPassThroughContextValue | null = null
104
+ if (childTextStyle) {
105
+ const nextTextPassThrough = {
106
+ textStyle: extendObject({}, inheritedText?.textStyle, childTextStyle)
107
+ }
108
+ if (diffAndCloneA(textPassThroughRef.current, nextTextPassThrough).diff) {
109
+ textPassThroughRef.current = nextTextPassThrough
110
+ }
111
+ textPassThrough = textPassThroughRef.current
112
+ }
113
+
114
+ const mergedProps = inheritedText?.pendingTextProps
115
+ ? extendObject({}, inheritedText.pendingTextProps, props)
116
+ : props
117
+ const finalStyle = inheritedText?.textStyle
118
+ ? extendObject({}, inheritedText.textStyle, resolvedNormalStyle)
119
+ : resolvedNormalStyle
120
+ resolveTextLineHeightPercentStyle(finalStyle, inheritedText?.textStyle)
94
121
 
95
122
  const nodeRef = useRef(null)
96
123
  useNodesRef<Text, _TextProps>(mergedProps, ref, nodeRef, {
97
124
  style: finalStyle
98
125
  })
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
126
  if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
116
127
 
117
128
  // ───── innerProps 阶段 ─────
@@ -139,9 +150,7 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
139
150
  let idCreate = -1
140
151
  if (__mpx_perf_framework__) idCreate = perf.scopeStart('text:render:createElement')
141
152
  let finalComponent:JSX.Element = createElement(Text, innerProps, wrapChildren(
142
- extendObject({}, mergedProps, {
143
- children
144
- }),
153
+ children,
145
154
  {
146
155
  hasVarDec,
147
156
  varContext: varContextRef.current,
@@ -93,8 +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
- 'parent-font-size'?: number
98
96
  'parent-width'?: number
99
97
  'parent-height'?: number
100
98
  bindplay?: (event: Record<string, any>) => void
@@ -155,8 +153,6 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
155
153
  'preferred-peak-bit-rate': preferredPeakBitRate = 0,
156
154
  'enable-auto-rotation': enableAutoRotation = false,
157
155
  'enable-var': enableVar,
158
- 'external-var-context': externalVarContext,
159
- 'parent-font-size': parentFontSize,
160
156
  'parent-width': parentWidth,
161
157
  'parent-height': parentHeight
162
158
  } = props
@@ -172,12 +168,11 @@ const MpxVideo = forwardRef<HandlerRef<View, VideoProps>, VideoProps>((videoProp
172
168
  propsRef.current = props
173
169
 
174
170
  const { normalStyle, hasSelfPercent, setWidth, setHeight, hasPositionFixed } =
175
- useTransformStyle(extendObject({}, styles.container, style), {
171
+ useTransformStyle(style, {
176
172
  enableVar,
177
- externalVarContext,
178
- parentFontSize,
179
173
  parentWidth,
180
- parentHeight
174
+ parentHeight,
175
+ defaultStyle: styles.container
181
176
  })
182
177
 
183
178
  const { layoutRef, layoutStyle, layoutProps } = useLayout({