@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
@@ -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,71 +1,69 @@
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 => {
9
- let stopTotal: (() => void) | undefined
10
- if (__mpx_perf_framework__) stopTotal = perf.scope('simple-text:render:total')
8
+ let idTotal = -1
9
+ if (__mpx_perf_framework__) idTotal = perf.scopeStart('simple-text:render:total')
11
10
 
12
11
  // ───── style 阶段 ─────
13
- let stopStyle: (() => void) | undefined
14
- if (__mpx_perf_framework__) stopStyle = perf.scope('simple-text:render:style')
15
- const inheritedText = useContext(TextPassThroughContext)
16
- const mergedStyle = extendObject({}, inheritedText?.textStyle, props.style)
12
+ let idStyle = -1
13
+ if (__mpx_perf_framework__) idStyle = perf.scopeStart('simple-text:render: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
- )
39
- if (__mpx_perf_framework__) stopStyle!()
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
+ }
37
+ if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
40
38
 
41
39
  // ───── innerProps 阶段 ─────
42
- let stopInnerProps: (() => void) | undefined
43
- if (__mpx_perf_framework__) stopInnerProps = perf.scope('simple-text:render:innerProps')
40
+ let idInnerProps = -1
41
+ if (__mpx_perf_framework__) idInnerProps = perf.scopeStart('simple-text:render:innerProps')
44
42
  const innerProps = useInnerProps(
45
43
  extendObject(
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
  )
54
- if (__mpx_perf_framework__) stopInnerProps!()
52
+ if (__mpx_perf_framework__) perf.scopeEnd(idInnerProps)
55
53
 
56
54
  // ───── createElement 阶段 ─────
57
- let stopCreate: (() => void) | undefined
58
- if (__mpx_perf_framework__) stopCreate = perf.scope('simple-text:render:createElement')
55
+ let idCreate = -1
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
- if (__mpx_perf_framework__) stopCreate!()
64
+ if (__mpx_perf_framework__) perf.scopeEnd(idCreate)
67
65
 
68
- if (__mpx_perf_framework__) stopTotal!()
66
+ if (__mpx_perf_framework__) perf.scopeEnd(idTotal)
69
67
  return result
70
68
  }
71
69
 
@@ -1,17 +1,22 @@
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 => {
8
- let stopTotal: (() => void) | undefined
9
- if (__mpx_perf_framework__) stopTotal = perf.scope('simple-view:render:total')
7
+ interface SimpleViewProps extends ViewProps {
8
+ 'enable-text-pass-through'?: boolean
9
+ }
10
+
11
+ const SimpleView = (simpleViewProps: SimpleViewProps): JSX.Element => {
12
+ let idTotal = -1
13
+ if (__mpx_perf_framework__) idTotal = perf.scopeStart('simple-view:render:total')
10
14
 
11
15
  // ───── style 阶段 ─────
12
- let stopStyle: (() => void) | undefined
13
- if (__mpx_perf_framework__) stopStyle = perf.scope('simple-view:render:style')
16
+ let idStyle = -1
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,36 +24,43 @@ const SimpleView = (simpleViewProps: ViewProps): JSX.Element => {
19
24
  hasBoxSizingAffectingStyle = true
20
25
  }
21
26
  })
22
- const textPassThrough = useTextPassThroughValue(textStyle as TextStyle, textProps)
23
- if (__mpx_perf_framework__) stopStyle!()
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
+ }
35
+ if (__mpx_perf_framework__) perf.scopeEnd(idStyle)
24
36
 
25
37
  // ───── innerProps 阶段 ─────
26
- let stopInnerProps: (() => void) | undefined
27
- if (__mpx_perf_framework__) stopInnerProps = perf.scope('simple-view:render:innerProps')
38
+ let idInnerProps = -1
39
+ if (__mpx_perf_framework__) idInnerProps = perf.scopeStart('simple-view:render:innerProps')
28
40
  const innerProps = useInnerProps(
29
41
  extendObject(
30
42
  {},
31
43
  props,
32
44
  {
33
- style: transformBoxSizing(extendObject({}, innerStyle), hasBoxSizingAffectingStyle)
45
+ style: styleObj
34
46
  }
35
47
  )
36
48
  )
37
- if (__mpx_perf_framework__) stopInnerProps!()
49
+ if (__mpx_perf_framework__) perf.scopeEnd(idInnerProps)
38
50
 
39
51
  // ───── createElement 阶段 ─────
40
- let stopCreate: (() => void) | undefined
41
- if (__mpx_perf_framework__) stopCreate = perf.scope('simple-view:render:createElement')
52
+ let idCreate = -1
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
47
59
  }
48
60
  ))
49
- if (__mpx_perf_framework__) stopCreate!()
61
+ if (__mpx_perf_framework__) perf.scopeEnd(idCreate)
50
62
 
51
- if (__mpx_perf_framework__) stopTotal!()
63
+ if (__mpx_perf_framework__) perf.scopeEnd(idTotal)
52
64
  return result
53
65
  }
54
66
 
@@ -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