@mpxjs/webpack-plugin 2.10.24-beta.1 → 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 (124) hide show
  1. package/lib/index.js +1 -4
  2. package/lib/platform/style/wx/index.js +395 -104
  3. package/lib/react/style-helper.js +6 -6
  4. package/lib/resolver/AddEnvPlugin.js +1 -1
  5. package/lib/resolver/AddModePlugin.js +1 -1
  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 -3
  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 +24 -19
  53. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
  54. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
  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 +29 -25
  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 +214 -113
  73. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +1 -2
  74. package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
  75. package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
  76. package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
  77. package/lib/runtime/components/react/dist/utils.d.ts +73 -70
  78. package/lib/runtime/components/react/dist/utils.jsx +1295 -445
  79. package/lib/runtime/components/react/event.config.ts +32 -25
  80. package/lib/runtime/components/react/getInnerListeners.ts +84 -60
  81. package/lib/runtime/components/react/mpx-button.tsx +18 -16
  82. package/lib/runtime/components/react/mpx-camera.tsx +0 -3
  83. package/lib/runtime/components/react/mpx-canvas/index.tsx +3 -7
  84. package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -3
  85. package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -6
  86. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -11
  87. package/lib/runtime/components/react/mpx-form.tsx +6 -6
  88. package/lib/runtime/components/react/mpx-icon/index.tsx +1 -3
  89. package/lib/runtime/components/react/mpx-image.tsx +65 -54
  90. package/lib/runtime/components/react/mpx-input.tsx +1 -3
  91. package/lib/runtime/components/react/mpx-label.tsx +6 -8
  92. package/lib/runtime/components/react/mpx-movable-area.tsx +3 -4
  93. package/lib/runtime/components/react/mpx-movable-view.tsx +7 -7
  94. package/lib/runtime/components/react/mpx-picker-view/index.tsx +6 -8
  95. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +2 -4
  96. package/lib/runtime/components/react/mpx-progress.tsx +0 -3
  97. package/lib/runtime/components/react/mpx-radio-group.tsx +2 -6
  98. package/lib/runtime/components/react/mpx-radio.tsx +9 -11
  99. package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -3
  100. package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -7
  101. package/lib/runtime/components/react/mpx-simple-text.tsx +24 -26
  102. package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
  103. package/lib/runtime/components/react/mpx-slider.tsx +15 -10
  104. package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -6
  105. package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -7
  106. package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -6
  107. package/lib/runtime/components/react/mpx-swiper.tsx +5 -8
  108. package/lib/runtime/components/react/mpx-switch.tsx +0 -3
  109. package/lib/runtime/components/react/mpx-text.tsx +31 -34
  110. package/lib/runtime/components/react/mpx-video.tsx +3 -5
  111. package/lib/runtime/components/react/mpx-view.tsx +235 -126
  112. package/lib/runtime/components/react/mpx-web-view.tsx +11 -7
  113. package/lib/runtime/components/react/namedColorSet.ts +150 -0
  114. package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
  115. package/lib/runtime/components/react/types/global.d.ts +1 -0
  116. package/lib/runtime/components/react/utils.tsx +1348 -544
  117. package/lib/runtime/i18n.wxs +15 -9
  118. package/lib/style-compiler/strip-conditional.js +19 -4
  119. package/package.json +2 -2
  120. package/lib/resolver/ExtendComponentsPlugin.js +0 -91
  121. package/lib/runtime/components/extends/section-list.mpx +0 -14
  122. package/lib/runtime/components/react/dist/mpx-section-list.d.ts +0 -56
  123. package/lib/runtime/components/react/dist/mpx-section-list.jsx +0 -484
  124. package/lib/runtime/components/react/mpx-section-list.tsx +0 -734
@@ -38,7 +38,7 @@ import Animated, { useSharedValue, withTiming, useAnimatedStyle, runOnJS } from
38
38
  import { warn, hasOwn } from '@mpxjs/utils'
39
39
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
40
40
  import useNodesRef, { HandlerRef } from './useNodesRef'
41
- import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture, GestureHandler, HIDDEN_STYLE, useRunOnJSCallback, useTextPassThroughValue } from './utils'
41
+ import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture, GestureHandler, hiddenStyle, useRunOnJSCallback, useTextPassThrough } from './utils'
42
42
  import { IntersectionObserverContext, ScrollViewContext } from './context'
43
43
  import Portal from './mpx-portal'
44
44
 
@@ -66,7 +66,7 @@ interface ScrollViewProps {
66
66
  'scroll-into-view'?: string;
67
67
  'enable-trigger-intersection-observer'?: boolean;
68
68
  'enable-var'?: boolean;
69
- 'external-var-context'?: Record<string, any>;
69
+ 'enable-text-pass-through'?: boolean;
70
70
  'parent-font-size'?: number;
71
71
  'parent-width'?: number;
72
72
  'parent-height'?: number;
@@ -145,7 +145,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
145
145
  'scroll-left': scrollLeft = 0,
146
146
  'refresher-triggered': refresherTriggered,
147
147
  'enable-var': enableVar,
148
- 'external-var-context': externalVarContext,
148
+ 'enable-text-pass-through': enableTextPassThrough,
149
149
  'parent-font-size': parentFontSize,
150
150
  'parent-width': parentWidth,
151
151
  'parent-height': parentHeight,
@@ -200,10 +200,10 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
200
200
  hasPositionFixed,
201
201
  setWidth,
202
202
  setHeight
203
- } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
203
+ } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight })
204
204
 
205
205
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
206
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
206
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
207
207
 
208
208
  const scrollViewRef = useRef<ScrollView>(null)
209
209
 
@@ -255,7 +255,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
255
255
  const hasRefresherLayoutRef = useRef(false)
256
256
 
257
257
  // layout 完成前先隐藏,避免安卓闪烁问题
258
- const refresherLayoutStyle = useMemo(() => { return !hasRefresherLayoutRef.current ? HIDDEN_STYLE : {} }, [hasRefresherLayoutRef.current])
258
+ const refresherLayoutStyle = useMemo(() => { return !hasRefresherLayoutRef.current ? hiddenStyle : {} }, [hasRefresherLayoutRef.current])
259
259
  const lastOffset = useRef(0)
260
260
 
261
261
  if (scrollX && scrollY) {
@@ -880,7 +880,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
880
880
  const ScrollViewComponent = enableSticky ? AnimatedScrollView : ScrollView
881
881
 
882
882
  const createScrollViewContent = () => {
883
- const wrappedChildren = wrapChildren(hasRefresher ? extendObject({}, props, { children: otherContent }) : props,
883
+ const wrappedChildren = wrapChildren(hasRefresher ? otherContent : props.children,
884
884
  {
885
885
  hasVarDec,
886
886
  varContext: varContextRef.current,
@@ -1,8 +1,7 @@
1
1
  import { Text, TextStyle, TextProps } from 'react-native'
2
- import { JSX, createElement, useContext } from 'react'
2
+ import { JSX, createElement } from 'react'
3
3
  import useInnerProps from './getInnerListeners'
4
- import { extendObject, getDefaultAllowFontScaling, useTextPassThroughValue, wrapChildren, isStringChildren, transformBoxSizing, splitStyle, isBoxSizingAffectingStyle } from './utils'
5
- import { TextPassThroughContext } from './context'
4
+ import { extendObject, getDefaultAllowFontScaling, useTextPassThroughText, wrapChildren, isStringChildren, transformBoxSizing, splitStyle, isBoxSizingAffectingStyle } from './utils'
6
5
  import * as perf from '@mpxjs/perf'
7
6
 
8
7
  const SimpleText = (props: TextProps): JSX.Element => {
@@ -12,30 +11,29 @@ const SimpleText = (props: TextProps): JSX.Element => {
12
11
  // ───── style 阶段 ─────
13
12
  let idStyle = -1
14
13
  if (__mpx_perf_framework__) idStyle = perf.scopeStart('simple-text:render:style')
15
- const inheritedText = useContext(TextPassThroughContext)
16
- const mergedStyle = extendObject({}, inheritedText?.textStyle, props.style)
17
14
  let hasBoxSizingAffectingStyle = false
18
- const { textStyle = {} } = splitStyle(mergedStyle, (key) => {
15
+ const { textStyle } = splitStyle(props.style || {}, (key) => {
19
16
  if (!hasBoxSizingAffectingStyle && isBoxSizingAffectingStyle(key)) {
20
17
  hasBoxSizingAffectingStyle = true
21
18
  }
22
19
  })
23
- const finalStyle = transformBoxSizing(mergedStyle, hasBoxSizingAffectingStyle)
24
- const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props)
25
- const {
26
- allowFontScaling,
27
- children
28
- } = mergedProps
29
- const isStringOnly = isStringChildren(children)
30
- const childTextStyle: TextStyle | undefined = !isStringOnly && Object.keys(textStyle).length ? textStyle : undefined
31
- const childTextPassThrough = useTextPassThroughValue(
32
- childTextStyle,
33
- undefined,
34
- {
35
- inheritTextProps: false,
36
- disabled: isStringOnly
37
- }
38
- )
20
+ // textStyle 仅在子节点非纯字符串时才需要透传给子级;按需计算 isStringChildren
21
+ const childTextStyle: TextStyle | undefined = textStyle && !isStringChildren(props.children)
22
+ ? textStyle as TextStyle
23
+ : undefined
24
+ const { inheritedText, textPassThrough } = useTextPassThroughText(childTextStyle)
25
+
26
+ const mergedProps = inheritedText?.pendingTextProps
27
+ ? extendObject({}, inheritedText.pendingTextProps, props)
28
+ : props
29
+ let mergedStyle = inheritedText?.textStyle
30
+ ? extendObject({}, inheritedText.textStyle, props.style)
31
+ : props.style
32
+ if (hasBoxSizingAffectingStyle) {
33
+ // 仅在需要 mutate 时 clone,避免污染上游 props.style
34
+ if (mergedStyle === props.style) mergedStyle = extendObject({}, props.style)
35
+ transformBoxSizing(mergedStyle as Record<string, any>)
36
+ }
39
37
  if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
40
38
 
41
39
  // ───── innerProps 阶段 ─────
@@ -46,8 +44,8 @@ const SimpleText = (props: TextProps): JSX.Element => {
46
44
  {},
47
45
  mergedProps,
48
46
  {
49
- allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling(),
50
- style: finalStyle
47
+ allowFontScaling: mergedProps.allowFontScaling ?? getDefaultAllowFontScaling(),
48
+ style: mergedStyle
51
49
  }
52
50
  )
53
51
  )
@@ -57,10 +55,10 @@ const SimpleText = (props: TextProps): JSX.Element => {
57
55
  let idCreate = -1
58
56
  if (__mpx_perf_framework__) idCreate = perf.scopeStart('simple-text:render:createElement')
59
57
  const result = createElement(Text, innerProps, wrapChildren(
60
- { children },
58
+ mergedProps.children,
61
59
  {
62
60
  hasVarDec: false,
63
- textPassThrough: childTextPassThrough
61
+ textPassThrough
64
62
  }
65
63
  ))
66
64
  if (__mpx_perf_framework__) perf.scopeEnd(idCreate)
@@ -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,7 +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
62
  'parent-font-size'?: number
64
63
  'parent-width'?: number
65
64
  'parent-height'?: number
@@ -84,7 +83,6 @@ const Slider = forwardRef<
84
83
  name,
85
84
  style = {},
86
85
  'enable-var': enableVar,
87
- 'external-var-context': externalVarContext,
88
86
  'parent-font-size': parentFontSize,
89
87
  'parent-width': parentWidth,
90
88
  'parent-height': parentHeight
@@ -128,7 +126,6 @@ const Slider = forwardRef<
128
126
  hasPositionFixed
129
127
  } = useTransformStyle(style, {
130
128
  enableVar,
131
- externalVarContext,
132
129
  parentFontSize,
133
130
  parentWidth,
134
131
  parentHeight
@@ -337,12 +334,20 @@ const Slider = forwardRef<
337
334
  const blockSizeNum = Math.max(12, Math.min(28, blockSize))
338
335
  const trackHeight = 4
339
336
 
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)
337
+ // 用户传 padding shorthand 时跳过 paddingLeft/Right default,
338
+ // 避免 number 形式 padding:0 longhand default 反向覆盖
339
+ const containerStyle: ViewStyle = extendObject(
340
+ {} as ViewStyle,
341
+ {
342
+ flexDirection: 'row' as const,
343
+ alignItems: 'center' as const,
344
+ minHeight: Math.max(blockSizeNum + 8, 40)
345
+ },
346
+ hasOwn(style, 'padding') ? null : { paddingHorizontal: 14 },
347
+ hasOwn(style, 'margin') ? null : { marginHorizontal: 18, marginVertical: 10 },
348
+ normalStyle,
349
+ layoutStyle
350
+ )
346
351
 
347
352
  const trackStyle: ViewStyle = {
348
353
  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,7 +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>;
15
+ 'enable-text-pass-through'?: boolean;
16
16
  'parent-font-size'?: number;
17
17
  'parent-width'?: number;
18
18
  'parent-height'?: number;
@@ -27,7 +27,7 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
27
27
  padding = [0, 0, 0, 0],
28
28
  'offset-top': offsetTop = 0,
29
29
  'enable-var': enableVar,
30
- 'external-var-context': externalVarContext,
30
+ 'enable-text-pass-through': enableTextPassThrough,
31
31
  'parent-font-size': parentFontSize,
32
32
  'parent-width': parentWidth,
33
33
  'parent-height': parentHeight
@@ -47,12 +47,12 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
47
47
  hasSelfPercent,
48
48
  setWidth,
49
49
  setHeight
50
- } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
50
+ } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight })
51
51
 
52
52
  const { layoutRef, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: headerRef, onLayout })
53
53
 
54
54
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
55
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
55
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
56
56
 
57
57
  const headerTopAnimated = useAnimatedValue(0)
58
58
  // harmony animatedValue 不支持通过 _value 访问
@@ -161,7 +161,7 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
161
161
  Animated.View,
162
162
  innerProps,
163
163
  wrapChildren(
164
- props,
164
+ props.children,
165
165
  {
166
166
  hasVarDec,
167
167
  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,7 +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>;
14
+ 'enable-text-pass-through'?: boolean;
15
15
  'parent-font-size'?: number;
16
16
  'parent-width'?: number;
17
17
  'parent-height'?: number;
@@ -22,7 +22,7 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
22
22
  const {
23
23
  style,
24
24
  'enable-var': enableVar,
25
- 'external-var-context': externalVarContext,
25
+ 'enable-text-pass-through': enableTextPassThrough,
26
26
  'parent-font-size': parentFontSize,
27
27
  'parent-width': parentWidth,
28
28
  'parent-height': parentHeight
@@ -36,12 +36,12 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
36
36
  hasSelfPercent,
37
37
  setWidth,
38
38
  setHeight
39
- } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
39
+ } = useTransformStyle(style, { enableVar, parentFontSize, parentWidth, parentHeight })
40
40
 
41
41
  const { layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: sectionRef, onLayout })
42
42
 
43
43
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
44
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
44
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
45
45
 
46
46
  const stickyHeaders = useRef<Map<string, any>>(new Map())
47
47
 
@@ -69,7 +69,7 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
69
69
  }
70
70
 
71
71
  const innerProps = useInnerProps(extendObject({}, props, {
72
- style: extendObject(innerStyle, layoutStyle),
72
+ style: extendObject({}, innerStyle, layoutStyle),
73
73
  ref: sectionRef
74
74
  }, layoutProps), [
75
75
  'offset-top'
@@ -83,7 +83,7 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
83
83
  StickyContext.Provider,
84
84
  { value: contextValue },
85
85
  wrapChildren(
86
- props,
86
+ props.children,
87
87
  {
88
88
  hasVarDec,
89
89
  varContext: varContextRef.current,
@@ -3,14 +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>
13
+ 'enable-text-pass-through'?: boolean
14
14
  'parent-font-size'?: number
15
15
  'parent-width'?: number
16
16
  'parent-height'?: number
@@ -30,7 +30,7 @@ interface ContextType {
30
30
  const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProps>((props: SwiperItemProps, ref) => {
31
31
  const {
32
32
  'enable-var': enableVar,
33
- 'external-var-context': externalVarContext,
33
+ 'enable-text-pass-through': enableTextPassThrough,
34
34
  style,
35
35
  customStyle,
36
36
  itemIndex
@@ -51,9 +51,9 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
51
51
  hasSelfPercent,
52
52
  setWidth,
53
53
  setHeight
54
- } = useTransformStyle(style, { enableVar, externalVarContext })
54
+ } = useTransformStyle(style, { enableVar })
55
55
  const { textStyle, innerStyle } = splitStyle(normalStyle)
56
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
56
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
57
57
  useNodesRef(props, ref, nodeRef, {
58
58
  style: normalStyle
59
59
  })
@@ -103,7 +103,7 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
103
103
  style: [innerStyle, layoutStyle, itemAnimatedStyle, customStyle],
104
104
  'data-itemId': props['item-id']
105
105
  })
106
- return createElement(Animated.View, mergeProps, wrapChildren(props, {
106
+ return createElement(Animated.View, mergeProps, wrapChildren(props.children, {
107
107
  hasVarDec,
108
108
  varContext: varContextRef.current,
109
109
  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,10 @@ interface SwiperProps {
70
70
  'next-margin'?: string
71
71
  'enable-offset'?: boolean
72
72
  'enable-var': boolean
73
+ 'enable-text-pass-through'?: boolean
73
74
  'parent-font-size'?: number
74
75
  'parent-width'?: number
75
76
  'parent-height'?: number
76
- 'external-var-context'?: Record<string, any>
77
77
  'wait-for'?: Array<GestureHandler>
78
78
  'simultaneous-handlers'?: Array<GestureHandler>
79
79
  disableGesture?: boolean
@@ -147,10 +147,10 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
147
147
  'indicator-margin': paginationMargin = 10,
148
148
  'indicator-active-color': activeDotColor = '#000000',
149
149
  'enable-var': enableVar = false,
150
+ 'enable-text-pass-through': enableTextPassThrough,
150
151
  'parent-font-size': parentFontSize,
151
152
  'parent-width': parentWidth,
152
153
  'parent-height': parentHeight,
153
- 'external-var-context': externalVarContext,
154
154
  'simultaneous-handlers': originSimultaneousHandlers = [],
155
155
  'wait-for': waitFor = [],
156
156
  style = {},
@@ -192,14 +192,13 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
192
192
  setHeight
193
193
  } = useTransformStyle(style, {
194
194
  enableVar,
195
- externalVarContext,
196
195
  parentFontSize,
197
196
  parentWidth,
198
197
  parentHeight
199
198
  })
200
199
  const { textStyle } = splitStyle(normalStyle)
201
200
  const { textProps } = splitProps(props)
202
- const textPassThrough = useTextPassThroughValue(textStyle, textProps)
201
+ const textPassThrough = useTextPassThrough(textStyle, textProps, { enableTextPassThrough })
203
202
  const preMargin = props['previous-margin'] ? global.__formatValue(props['previous-margin']) as number : 0
204
203
  const nextMargin = props['next-margin'] ? global.__formatValue(props['next-margin']) as number : 0
205
204
  const preMarginShared = useSharedValue(preMargin)
@@ -930,9 +929,7 @@ const SwiperWrapper = forwardRef<HandlerRef<View, SwiperProps>, SwiperProps>((pr
930
929
  const animateComponent = createElement(Animated.View, {
931
930
  key: 'swiperContainer',
932
931
  style: [{ flexDirection: dir === 'x' ? 'row' : 'column', width: '100%', height: '100%' }, animatedStyles]
933
- }, wrapChildren({
934
- children: arrPages
935
- }, {
932
+ }, wrapChildren(arrPages, {
936
933
  hasVarDec,
937
934
  varContext: varContextRef.current,
938
935
  textPassThrough
@@ -26,7 +26,6 @@ interface _SwitchProps extends SwitchProps {
26
26
  'parent-font-size'?: number
27
27
  'parent-width'?: number
28
28
  'parent-height'?: number
29
- 'external-var-context'?: Record<string, any>
30
29
  bindchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
31
30
  catchchange?: (event: NativeSyntheticEvent<TouchEvent> | unknown) => void
32
31
  }
@@ -39,7 +38,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
39
38
  disabled = false,
40
39
  color = '#04BE02',
41
40
  'enable-var': enableVar,
42
- 'external-var-context': externalVarContext,
43
41
  'parent-font-size': parentFontSize,
44
42
  'parent-width': parentWidth,
45
43
  'parent-height': parentHeight,
@@ -67,7 +65,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
67
65
  hasPositionFixed
68
66
  } = useTransformStyle(style, {
69
67
  enableVar,
70
- externalVarContext,
71
68
  parentFontSize,
72
69
  parentWidth,
73
70
  parentHeight
@@ -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, useContext } from 'react'
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, useTextPassThroughValue, isStringChildren, splitStyle } from './utils'
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
- return Children.map(children, (child) => {
36
- if (typeof child === 'string') {
37
- return decode(child)
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
@@ -59,20 +61,17 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
59
61
  // ───── props 阶段 ─────
60
62
  let idProps = -1
61
63
  if (__mpx_perf_framework__) idProps = perf.scopeStart('text:render:props')
62
- const inheritedText = useContext(TextPassThroughContext)
63
- const mergedProps = extendObject({}, inheritedText?.pendingTextProps, 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
- } = mergedProps
74
+ } = props
76
75
  if (__mpx_perf_framework__) perf.scopeEnd(idProps)
77
76
 
78
77
  // ───── style 阶段 ─────
@@ -85,33 +84,33 @@ 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
- const finalStyle = extendObject({}, inheritedText?.textStyle, normalStyle)
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
114
  if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
116
115
 
117
116
  // ───── innerProps 阶段 ─────
@@ -139,9 +138,7 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
139
138
  let idCreate = -1
140
139
  if (__mpx_perf_framework__) idCreate = perf.scopeStart('text:render:createElement')
141
140
  let finalComponent:JSX.Element = createElement(Text, innerProps, wrapChildren(
142
- extendObject({}, mergedProps, {
143
- children
144
- }),
141
+ children,
145
142
  {
146
143
  hasVarDec,
147
144
  varContext: varContextRef.current,
@@ -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(extendObject({}, styles.container, style), {
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({