@mpxjs/webpack-plugin 2.10.19 → 2.10.21

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 (137) hide show
  1. package/lib/dependencies/ResolveDependency.js +2 -2
  2. package/lib/index.js +38 -7
  3. package/lib/json-compiler/helper.js +11 -10
  4. package/lib/json-compiler/index.js +7 -4
  5. package/lib/json-compiler/plugin.js +4 -4
  6. package/lib/loader.js +4 -4
  7. package/lib/native-loader.js +4 -4
  8. package/lib/parser.js +1 -1
  9. package/lib/platform/create-diagnostic.js +168 -0
  10. package/lib/platform/index.js +16 -3
  11. package/lib/platform/json/wx/index.js +66 -17
  12. package/lib/platform/run-rules.js +9 -5
  13. package/lib/platform/style/wx/index.js +82 -33
  14. package/lib/platform/template/normalize-component-rules.js +7 -9
  15. package/lib/platform/template/wx/component-config/block.js +2 -1
  16. package/lib/platform/template/wx/component-config/custom-built-in-component.js +34 -0
  17. package/lib/platform/template/wx/component-config/index.js +18 -3
  18. package/lib/platform/template/wx/component-config/input.js +1 -7
  19. package/lib/platform/template/wx/component-config/movable-view.js +1 -7
  20. package/lib/platform/template/wx/component-config/text.js +1 -1
  21. package/lib/platform/template/wx/component-config/textarea.js +1 -25
  22. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  23. package/lib/platform/template/wx/index.js +48 -34
  24. package/lib/react/processJSON.js +7 -4
  25. package/lib/react/processStyles.js +22 -8
  26. package/lib/react/processTemplate.js +98 -41
  27. package/lib/react/style-helper.js +121 -86
  28. package/lib/react/template-loader.js +161 -0
  29. package/lib/runtime/components/react/context.ts +8 -1
  30. package/lib/runtime/components/react/dist/context.d.ts +6 -1
  31. package/lib/runtime/components/react/dist/context.js +1 -0
  32. package/lib/runtime/components/react/dist/getInnerListeners.js +1 -0
  33. package/lib/runtime/components/react/dist/mpx-async-suspense.jsx +1 -1
  34. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -1
  35. package/lib/runtime/components/react/dist/mpx-button.jsx +6 -5
  36. package/lib/runtime/components/react/dist/mpx-camera.jsx +1 -0
  37. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +4 -1
  38. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +2 -1
  39. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +6 -4
  40. package/lib/runtime/components/react/dist/mpx-form.jsx +3 -3
  41. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +5 -1
  42. package/lib/runtime/components/react/dist/mpx-image.d.ts +3 -3
  43. package/lib/runtime/components/react/dist/mpx-image.jsx +45 -12
  44. package/lib/runtime/components/react/dist/mpx-inline-text.jsx +10 -6
  45. package/lib/runtime/components/react/dist/mpx-input.jsx +17 -4
  46. package/lib/runtime/components/react/dist/mpx-label.jsx +6 -4
  47. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +19 -4
  48. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +12 -2
  49. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +1 -1
  50. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +7 -4
  51. package/lib/runtime/components/react/dist/mpx-portal/index.jsx +5 -1
  52. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +4 -1
  53. package/lib/runtime/components/react/dist/mpx-radio.jsx +5 -4
  54. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +3 -1
  55. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +13 -4
  56. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +52 -6
  57. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +36 -6
  58. package/lib/runtime/components/react/dist/mpx-slider.jsx +2 -1
  59. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +8 -4
  60. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -4
  61. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +7 -4
  62. package/lib/runtime/components/react/dist/mpx-swiper.jsx +15 -4
  63. package/lib/runtime/components/react/dist/mpx-switch.jsx +4 -1
  64. package/lib/runtime/components/react/dist/mpx-text.jsx +57 -12
  65. package/lib/runtime/components/react/dist/mpx-video.d.ts +2 -1
  66. package/lib/runtime/components/react/dist/mpx-video.jsx +10 -4
  67. package/lib/runtime/components/react/dist/mpx-view.jsx +42 -7
  68. package/lib/runtime/components/react/dist/utils.d.ts +21 -11
  69. package/lib/runtime/components/react/dist/utils.jsx +105 -35
  70. package/lib/runtime/components/react/getInnerListeners.ts +1 -0
  71. package/lib/runtime/components/react/mpx-async-suspense.tsx +2 -1
  72. package/lib/runtime/components/react/mpx-button.tsx +6 -5
  73. package/lib/runtime/components/react/mpx-camera.tsx +1 -0
  74. package/lib/runtime/components/react/mpx-canvas/index.tsx +4 -1
  75. package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -1
  76. package/lib/runtime/components/react/mpx-checkbox.tsx +6 -4
  77. package/lib/runtime/components/react/mpx-form.tsx +3 -3
  78. package/lib/runtime/components/react/mpx-icon/index.tsx +5 -1
  79. package/lib/runtime/components/react/mpx-image.tsx +57 -20
  80. package/lib/runtime/components/react/mpx-inline-text.tsx +12 -7
  81. package/lib/runtime/components/react/mpx-input.tsx +17 -4
  82. package/lib/runtime/components/react/mpx-label.tsx +6 -4
  83. package/lib/runtime/components/react/mpx-movable-view.tsx +20 -4
  84. package/lib/runtime/components/react/mpx-picker/index.tsx +12 -2
  85. package/lib/runtime/components/react/mpx-picker/type.ts +1 -1
  86. package/lib/runtime/components/react/mpx-picker-view/index.tsx +8 -4
  87. package/lib/runtime/components/react/mpx-portal/index.tsx +5 -1
  88. package/lib/runtime/components/react/mpx-radio-group.tsx +4 -1
  89. package/lib/runtime/components/react/mpx-radio.tsx +5 -4
  90. package/lib/runtime/components/react/mpx-rich-text/index.tsx +3 -1
  91. package/lib/runtime/components/react/mpx-scroll-view.tsx +13 -4
  92. package/lib/runtime/components/react/mpx-simple-text.tsx +55 -8
  93. package/lib/runtime/components/react/mpx-simple-view.tsx +30 -6
  94. package/lib/runtime/components/react/mpx-slider.tsx +2 -1
  95. package/lib/runtime/components/react/mpx-sticky-header.tsx +8 -4
  96. package/lib/runtime/components/react/mpx-sticky-section.tsx +6 -4
  97. package/lib/runtime/components/react/mpx-swiper-item.tsx +7 -4
  98. package/lib/runtime/components/react/mpx-swiper.tsx +16 -4
  99. package/lib/runtime/components/react/mpx-switch.tsx +4 -1
  100. package/lib/runtime/components/react/mpx-text.tsx +55 -15
  101. package/lib/runtime/components/react/mpx-video.tsx +11 -5
  102. package/lib/runtime/components/react/mpx-view.tsx +35 -7
  103. package/lib/runtime/components/react/types/global.d.ts +4 -0
  104. package/lib/runtime/components/react/utils.tsx +126 -45
  105. package/lib/runtime/components/wx/default-component.mpx +9 -0
  106. package/lib/runtime/components/wx/default-page.mpx +3 -11
  107. package/lib/runtime/optionProcessor.d.ts +2 -0
  108. package/lib/runtime/optionProcessor.js +77 -1
  109. package/lib/runtime/optionProcessorReact.js +5 -0
  110. package/lib/script-setup-compiler/index.js +1 -1
  111. package/lib/style-compiler/index.js +2 -0
  112. package/lib/style-compiler/plugins/remove-strip-conditional-comments.js +14 -0
  113. package/lib/style-compiler/plugins/trans-special.js +1 -1
  114. package/lib/style-compiler/strip-conditional.js +40 -26
  115. package/lib/template-compiler/compiler.js +306 -125
  116. package/lib/template-compiler/gen-node-react.js +35 -7
  117. package/lib/template-compiler/index.js +9 -7
  118. package/lib/utils/const.js +4 -1
  119. package/lib/utils/gen-component-tag.js +1 -5
  120. package/lib/utils/normalize-perf-options.js +47 -0
  121. package/lib/utils/partial-compile-rules.js +27 -0
  122. package/lib/utils/pre-process-json.js +3 -0
  123. package/lib/utils/source-location.js +96 -0
  124. package/lib/web/compile-wx-template-fragment.js +68 -0
  125. package/lib/web/index.js +3 -0
  126. package/lib/web/processJSON.js +7 -4
  127. package/lib/web/processMainScript.js +3 -7
  128. package/lib/web/processScript.js +43 -8
  129. package/lib/web/processStyles.js +12 -3
  130. package/lib/web/processTemplate.js +61 -19
  131. package/lib/web/template-loader.js +123 -0
  132. package/lib/web/template-shared.js +48 -0
  133. package/lib/wxml/loader.js +4 -3
  134. package/lib/wxss/loader.js +1 -1
  135. package/lib/wxss/utils.js +6 -4
  136. package/package.json +12 -4
  137. package/lib/platform/template/wx/component-config/component.js +0 -41
@@ -54,7 +54,7 @@ import {
54
54
  NativeTouchEvent
55
55
  } from 'react-native'
56
56
  import { warn } from '@mpxjs/utils'
57
- import { useUpdateEffect, useTransformStyle, useLayout, extendObject, isAndroid } from './utils'
57
+ import { useUpdateEffect, useTransformStyle, useLayout, extendObject, isAndroid, getDefaultAllowFontScaling } from './utils'
58
58
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
59
59
  import useNodesRef, { HandlerRef } from './useNodesRef'
60
60
  import { FormContext, FormFieldValue, KeyboardAvoidContext } from './context'
@@ -131,7 +131,7 @@ const inputModeMap: Record<Type, string> = {
131
131
  const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps>((props: FinalInputProps, ref): JSX.Element => {
132
132
  const {
133
133
  style = {},
134
- allowFontScaling = false,
134
+ allowFontScaling,
135
135
  type = 'text',
136
136
  value,
137
137
  password,
@@ -483,7 +483,7 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
483
483
  {
484
484
  ref: nodeRef,
485
485
  style: extendObject({}, normalStyle, layoutStyle),
486
- allowFontScaling,
486
+ allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling(),
487
487
  inputMode: originalKeyboardType ? undefined : inputModeMap[type],
488
488
  keyboardType: originalKeyboardType,
489
489
  secureTextEntry: !!password,
@@ -512,7 +512,14 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
512
512
  !!multiline && confirmType === 'return' ? {} : { enterKeyHint: confirmType }
513
513
  ),
514
514
  [
515
+ 'name',
515
516
  'type',
517
+ 'maxlength',
518
+ 'cursor-spacing',
519
+ 'adjust-position',
520
+ 'hold-keyboard',
521
+ 'keyboard-type',
522
+ 'auto-height',
516
523
  'password',
517
524
  'placeholder-style',
518
525
  'disabled',
@@ -523,7 +530,13 @@ const Input = forwardRef<HandlerRef<TextInput, FinalInputProps>, FinalInputProps
523
530
  'cursor',
524
531
  'cursor-color',
525
532
  'selection-start',
526
- 'selection-end'
533
+ 'selection-end',
534
+ 'bindinput',
535
+ 'bindfocus',
536
+ 'bindblur',
537
+ 'bindconfirm',
538
+ 'bindselectionchange',
539
+ 'bindlinechange'
527
540
  ],
528
541
  {
529
542
  layoutRef
@@ -6,7 +6,7 @@ import { View, ViewStyle, NativeSyntheticEvent } from 'react-native'
6
6
  import { noop, warn } from '@mpxjs/utils'
7
7
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
8
8
  import useNodesRef, { HandlerRef } from './useNodesRef'
9
- import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
9
+ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThroughValue } from './utils'
10
10
  import { LabelContext, LabelContextValue } from './context'
11
11
  import Portal from './mpx-portal'
12
12
 
@@ -61,6 +61,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
61
61
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
62
62
 
63
63
  const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
64
+ const textPassThrough = useTextPassThroughValue(textStyle, textProps)
64
65
 
65
66
  if (backgroundStyle) {
66
67
  warn('Label does not support background image-related styles!')
@@ -87,7 +88,9 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
87
88
  bindtap: onTap
88
89
  }
89
90
  ),
90
- [],
91
+ [
92
+ 'for'
93
+ ],
91
94
  {
92
95
  layoutRef
93
96
  }
@@ -101,8 +104,7 @@ const Label = forwardRef<HandlerRef<View, LabelProps>, LabelProps>(
101
104
  {
102
105
  hasVarDec,
103
106
  varContext: varContextRef.current,
104
- textStyle,
105
- textProps
107
+ textPassThrough
106
108
  }
107
109
  )
108
110
  ))
@@ -22,7 +22,7 @@ import { StyleSheet, View, LayoutChangeEvent } from 'react-native'
22
22
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
23
23
  import useNodesRef, { HandlerRef } from './useNodesRef'
24
24
  import { MovableAreaContext } from './context'
25
- import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, GestureHandler, flatGesture, extendObject, omit, useNavigation, useRunOnJSCallback } from './utils'
25
+ import { useTransformStyle, splitProps, splitStyle, HIDDEN_STYLE, wrapChildren, GestureHandler, flatGesture, extendObject, omit, useNavigation, useRunOnJSCallback, useTextPassThroughValue } from './utils'
26
26
  import { GestureDetector, Gesture, GestureTouchEvent, GestureStateChangeEvent, PanGestureHandlerEventPayload, PanGesture } from 'react-native-gesture-handler'
27
27
  import Animated, {
28
28
  useSharedValue,
@@ -251,6 +251,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
251
251
  const prevWaitForHandlersRef = useRef<Array<GestureHandler>>(waitFor || [])
252
252
  const gestureSwitch = useRef(false)
253
253
  const { textStyle, innerStyle } = splitStyle(normalStyle)
254
+ const textPassThrough = useTextPassThroughValue(textStyle, textProps)
254
255
 
255
256
  const offsetX = useSharedValue(x)
256
257
  const offsetY = useSharedValue(y)
@@ -745,7 +746,23 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
745
746
  style: [innerStyle, animatedStyles, layoutStyle]
746
747
  },
747
748
  rewriteCatchEvent()
748
- )
749
+ ),
750
+ [
751
+ 'direction',
752
+ 'x',
753
+ 'y',
754
+ 'disabled',
755
+ 'animation',
756
+ 'damping',
757
+ 'friction',
758
+ 'out-of-bounds',
759
+ 'inertia',
760
+ 'wait-for',
761
+ 'simultaneous-handlers',
762
+ 'disable-event-passthrough',
763
+ 'changeThrottleTime',
764
+ 'bindchange'
765
+ ]
749
766
  )
750
767
 
751
768
  return createElement(GestureDetector, { gesture: gesture }, createElement(
@@ -756,8 +773,7 @@ const _MovableView = forwardRef<HandlerRef<View, MovableViewProps>, MovableViewP
756
773
  {
757
774
  hasVarDec,
758
775
  varContext: varContextRef.current,
759
- textStyle,
760
- textProps
776
+ textPassThrough
761
777
  }
762
778
  )
763
779
  ))
@@ -147,7 +147,17 @@ const Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>(
147
147
  },
148
148
  layoutProps
149
149
  ),
150
- [],
150
+ [
151
+ 'mode',
152
+ 'value',
153
+ 'range',
154
+ 'disabled',
155
+ 'bindcancel',
156
+ 'bindchange',
157
+ 'header-text',
158
+ 'name',
159
+ 'bindcolumnchange'
160
+ ],
151
161
  { layoutRef }
152
162
  )
153
163
 
@@ -218,7 +228,7 @@ const Picker = forwardRef<HandlerRef<View, PickerProps>, PickerProps>(
218
228
  hide()
219
229
  }
220
230
 
221
- const specificProps = extendObject(innerProps, {
231
+ const specificProps = extendObject({}, innerProps, {
222
232
  mode,
223
233
  children,
224
234
  bindchange: onChange,
@@ -79,7 +79,7 @@ export interface RegionProps extends BasePickerProps {
79
79
  /** 表示选中的省市区,默认选中每一列的第一个值, 默认值 [] */
80
80
  value?: string[]
81
81
  /** 默认值 region */
82
- level?: 'province' | 'city' | 'region' | 'sub-district'
82
+ level?: 'province' | 'city' | 'region'
83
83
  /** 可为每一列的顶部添加一个自定义的项 */
84
84
  'custom-item'?: string
85
85
  /** value 改变时触发 change 事件, event.detail = {value, code, postcode},
@@ -8,7 +8,8 @@ import {
8
8
  splitStyle,
9
9
  wrapChildren,
10
10
  useTransformStyle,
11
- extendObject
11
+ extendObject,
12
+ useTextPassThroughValue
12
13
  } from '../utils'
13
14
  import { PickerViewStyleContext } from './pickerVIewContext'
14
15
  import Portal from '../mpx-portal'
@@ -104,6 +105,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
104
105
  } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef })
105
106
  const { textProps } = splitProps(props)
106
107
  const { textStyle } = splitStyle(normalStyle)
108
+ const textPassThrough = useTextPassThroughValue(textStyle, textProps)
107
109
 
108
110
  const onSelectChange = (columnIndex: number, selectedIndex: number) => {
109
111
  const activeValue = activeValueRef.current
@@ -156,7 +158,10 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
156
158
  'indicator-style',
157
159
  'indicator-class',
158
160
  'mask-style',
159
- 'mask-class'
161
+ 'mask-class',
162
+ 'value',
163
+ 'bindchange',
164
+ 'enable-wheel-animation'
160
165
  ],
161
166
  { layoutRef }
162
167
  )
@@ -190,8 +195,7 @@ const _PickerView = forwardRef<HandlerRef<View, PickerViewProps>, PickerViewProp
190
195
  {
191
196
  hasVarDec,
192
197
  varContext: varContextRef.current,
193
- textStyle,
194
- textProps
198
+ textPassThrough
195
199
  }
196
200
  )
197
201
  }
@@ -1,5 +1,5 @@
1
1
  import { ReactNode, useContext, useEffect, useRef } from 'react'
2
- import { PortalContext, ProviderContext, RouteContext, VarContext } from '../context'
2
+ import { PortalContext, ProviderContext, RouteContext, VarContext, TextPassThroughContext } from '../context'
3
3
  import PortalHost, { portal } from './portal-host'
4
4
 
5
5
  export type PortalProps = {
@@ -11,8 +11,12 @@ const Portal = ({ children }: PortalProps): null => {
11
11
  const keyRef = useRef<any>(null)
12
12
  const { pageId } = useContext(RouteContext) || {}
13
13
  const varContext = useContext(VarContext)
14
+ const textPassThroughContext = useContext(TextPassThroughContext)
14
15
  const parentProvides = useContext(ProviderContext)
15
16
 
17
+ if (textPassThroughContext) {
18
+ children = (<TextPassThroughContext.Provider value={textPassThroughContext} key='textPassThroughWrap'>{children}</TextPassThroughContext.Provider>)
19
+ }
16
20
  if (varContext) {
17
21
  children = (<VarContext.Provider value={varContext} key='varContextWrap'>{children}</VarContext.Provider>)
18
22
  }
@@ -152,7 +152,10 @@ const radioGroup = forwardRef<
152
152
  style: extendObject({}, normalStyle, layoutStyle)
153
153
  }
154
154
  ),
155
- ['name'],
155
+ [
156
+ 'name',
157
+ 'bindchange'
158
+ ],
156
159
  {
157
160
  layoutRef
158
161
  }
@@ -10,7 +10,7 @@ import { warn } from '@mpxjs/utils'
10
10
  import { LabelContext, RadioGroupContext } from './context'
11
11
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
12
12
  import useNodesRef, { HandlerRef } from './useNodesRef'
13
- import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject } from './utils'
13
+ import { splitProps, splitStyle, useLayout, useTransformStyle, wrapChildren, extendObject, useTextPassThroughValue } from './utils'
14
14
  import Icon from './mpx-icon'
15
15
  import Portal from './mpx-portal'
16
16
 
@@ -128,6 +128,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
128
128
  } = useTransformStyle(styleObj, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
129
129
 
130
130
  const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
131
+ const textPassThrough = useTextPassThroughValue(textStyle, textProps)
131
132
 
132
133
  if (backgroundStyle) {
133
134
  warn('Radio does not support background image-related styles!')
@@ -164,7 +165,8 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
164
165
  [
165
166
  'value',
166
167
  'disabled',
167
- 'checked'
168
+ 'checked',
169
+ 'color'
168
170
  ],
169
171
  {
170
172
  layoutRef
@@ -210,8 +212,7 @@ const Radio = forwardRef<HandlerRef<View, RadioProps>, RadioProps>(
210
212
  {
211
213
  hasVarDec,
212
214
  varContext: varContextRef.current,
213
- textStyle,
214
- textProps
215
+ textPassThrough
215
216
  }
216
217
  )
217
218
  )
@@ -103,7 +103,9 @@ const _RichText = forwardRef<HandlerRef<View, _RichTextProps>, _RichTextProps>((
103
103
  style: extendObject(normalStyle, layoutStyle)
104
104
  }
105
105
  ),
106
- [],
106
+ [
107
+ 'nodes'
108
+ ],
107
109
  {
108
110
  layoutRef
109
111
  }
@@ -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 } from './utils'
41
+ import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture, GestureHandler, HIDDEN_STYLE, useRunOnJSCallback, useTextPassThroughValue } from './utils'
42
42
  import { IntersectionObserverContext, ScrollViewContext } from './context'
43
43
  import Portal from './mpx-portal'
44
44
 
@@ -203,6 +203,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
203
203
  } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight })
204
204
 
205
205
  const { textStyle, innerStyle = {} } = splitStyle(normalStyle)
206
+ const textPassThrough = useTextPassThroughValue(textStyle, textProps)
206
207
 
207
208
  const scrollViewRef = useRef<ScrollView>(null)
208
209
 
@@ -855,7 +856,15 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
855
856
  'refresher-triggered',
856
857
  'refresher-enabled',
857
858
  'refresher-default-style',
859
+ 'refresher-threshold',
858
860
  'refresher-background',
861
+ 'scroll-into-view',
862
+ 'enable-sticky',
863
+ 'wait-for',
864
+ 'simultaneous-handlers',
865
+ 'scroll-event-throttle',
866
+ 'scroll-into-view-offset',
867
+ '__selectRef',
859
868
  'children',
860
869
  'enhanced',
861
870
  'binddragstart',
@@ -864,7 +873,8 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
864
873
  'bindscroll',
865
874
  'bindscrolltoupper',
866
875
  'bindscrolltolower',
867
- 'bindrefresherrefresh'
876
+ 'bindrefresherrefresh',
877
+ 'bindscrollend'
868
878
  ], { layoutRef })
869
879
 
870
880
  const ScrollViewComponent = enableSticky ? AnimatedScrollView : ScrollView
@@ -874,8 +884,7 @@ const _ScrollView = forwardRef<HandlerRef<ScrollView & View, ScrollViewProps>, S
874
884
  {
875
885
  hasVarDec,
876
886
  varContext: varContextRef.current,
877
- textStyle,
878
- textProps
887
+ textPassThrough
879
888
  })
880
889
  return createElement(ScrollViewContext.Provider, { value: contextValue }, wrappedChildren)
881
890
  }
@@ -1,25 +1,72 @@
1
- import { Text, TextProps } from 'react-native'
2
- import { JSX, createElement } from 'react'
1
+ import { Text, TextStyle, TextProps } from 'react-native'
2
+ import { JSX, createElement, useContext } from 'react'
3
3
  import useInnerProps from './getInnerListeners'
4
- import { extendObject } from './utils'
4
+ import { extendObject, getDefaultAllowFontScaling, useTextPassThroughValue, wrapChildren, isStringChildren, transformBoxSizing, splitStyle, isBoxSizingAffectingStyle } from './utils'
5
+ import { TextPassThroughContext } from './context'
6
+ import * as perf from '@mpxjs/perf'
5
7
 
6
8
  const SimpleText = (props: TextProps): JSX.Element => {
9
+ let stopTotal: (() => void) | undefined
10
+ if (__mpx_perf_framework__) stopTotal = perf.scope('simple-text:render:total')
11
+
12
+ // ───── 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)
17
+ let hasBoxSizingAffectingStyle = false
18
+ const { textStyle = {} } = splitStyle(mergedStyle, (key) => {
19
+ if (!hasBoxSizingAffectingStyle && isBoxSizingAffectingStyle(key)) {
20
+ hasBoxSizingAffectingStyle = true
21
+ }
22
+ })
23
+ const finalStyle = transformBoxSizing(mergedStyle, hasBoxSizingAffectingStyle)
24
+ const mergedProps = extendObject({}, inheritedText?.pendingTextProps, props)
7
25
  const {
8
- allowFontScaling = false,
26
+ allowFontScaling,
9
27
  children
10
- } = props
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!()
11
40
 
41
+ // ───── innerProps 阶段 ─────
42
+ let stopInnerProps: (() => void) | undefined
43
+ if (__mpx_perf_framework__) stopInnerProps = perf.scope('simple-text:render:innerProps')
12
44
  const innerProps = useInnerProps(
13
45
  extendObject(
14
46
  {},
15
- props,
47
+ mergedProps,
16
48
  {
17
- allowFontScaling
49
+ allowFontScaling: allowFontScaling ?? getDefaultAllowFontScaling(),
50
+ style: finalStyle
18
51
  }
19
52
  )
20
53
  )
54
+ if (__mpx_perf_framework__) stopInnerProps!()
55
+
56
+ // ───── createElement 阶段 ─────
57
+ let stopCreate: (() => void) | undefined
58
+ if (__mpx_perf_framework__) stopCreate = perf.scope('simple-text:render:createElement')
59
+ const result = createElement(Text, innerProps, wrapChildren(
60
+ { children },
61
+ {
62
+ hasVarDec: false,
63
+ textPassThrough: childTextPassThrough
64
+ }
65
+ ))
66
+ if (__mpx_perf_framework__) stopCreate!()
21
67
 
22
- return createElement(Text, innerProps, children)
68
+ if (__mpx_perf_framework__) stopTotal!()
69
+ return result
23
70
  }
24
71
 
25
72
  SimpleText.displayName = 'MpxSimpleText'
@@ -1,31 +1,55 @@
1
1
  import { View, ViewProps, TextStyle } from 'react-native'
2
2
  import { createElement } from 'react'
3
- import { splitProps, splitStyle, wrapChildren, extendObject } from './utils'
3
+ import { splitProps, splitStyle, wrapChildren, extendObject, useTextPassThroughValue, transformBoxSizing, isBoxSizingAffectingStyle } from './utils'
4
4
  import useInnerProps from './getInnerListeners'
5
+ import * as perf from '@mpxjs/perf'
5
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')
10
+
11
+ // ───── style 阶段 ─────
12
+ let stopStyle: (() => void) | undefined
13
+ if (__mpx_perf_framework__) stopStyle = perf.scope('simple-view:render:style')
7
14
  const { textProps, innerProps: props = {} } = splitProps(simpleViewProps)
8
15
 
9
- const { textStyle, innerStyle = {} } = splitStyle(props.style || {})
16
+ let hasBoxSizingAffectingStyle = false
17
+ const { textStyle, innerStyle = {} } = splitStyle(props.style || {}, (key) => {
18
+ if (!hasBoxSizingAffectingStyle && isBoxSizingAffectingStyle(key)) {
19
+ hasBoxSizingAffectingStyle = true
20
+ }
21
+ })
22
+ const textPassThrough = useTextPassThroughValue(textStyle as TextStyle, textProps)
23
+ if (__mpx_perf_framework__) stopStyle!()
10
24
 
25
+ // ───── innerProps 阶段 ─────
26
+ let stopInnerProps: (() => void) | undefined
27
+ if (__mpx_perf_framework__) stopInnerProps = perf.scope('simple-view:render:innerProps')
11
28
  const innerProps = useInnerProps(
12
29
  extendObject(
13
30
  {},
14
31
  props,
15
32
  {
16
- style: innerStyle
33
+ style: transformBoxSizing(extendObject({}, innerStyle), hasBoxSizingAffectingStyle)
17
34
  }
18
35
  )
19
36
  )
37
+ if (__mpx_perf_framework__) stopInnerProps!()
20
38
 
21
- return createElement(View, innerProps, wrapChildren(
39
+ // ───── createElement 阶段 ─────
40
+ let stopCreate: (() => void) | undefined
41
+ if (__mpx_perf_framework__) stopCreate = perf.scope('simple-view:render:createElement')
42
+ const result = createElement(View, innerProps, wrapChildren(
22
43
  props,
23
44
  {
24
45
  hasVarDec: false,
25
- textStyle: textStyle as TextStyle,
26
- textProps
46
+ textPassThrough
27
47
  }
28
48
  ))
49
+ if (__mpx_perf_framework__) stopCreate!()
50
+
51
+ if (__mpx_perf_framework__) stopTotal!()
52
+ return result
29
53
  }
30
54
 
31
55
  SimpleView.displayName = 'MpxSimpleView'
@@ -393,7 +393,8 @@ const Slider = forwardRef<
393
393
  'bindchange',
394
394
  'catchchange',
395
395
  'bindchanging',
396
- 'catchchanging'
396
+ 'catchchanging',
397
+ 'name'
397
398
  ],
398
399
  { layoutRef }
399
400
  )
@@ -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 } from './utils'
5
+ import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject, useTextPassThroughValue } from './utils'
6
6
  import { error } from '@mpxjs/utils'
7
7
  import useInnerProps, { getCustomEvent } from './getInnerListeners'
8
8
 
@@ -52,6 +52,7 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
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
56
 
56
57
  const headerTopAnimated = useAnimatedValue(0)
57
58
  // harmony animatedValue 不支持通过 _value 访问
@@ -149,7 +150,11 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
149
150
  paddingBottom: padding[2] || 0,
150
151
  paddingLeft: padding[3] || 0
151
152
  })
152
- }, layoutProps), [], { layoutRef })
153
+ }, layoutProps), [
154
+ 'padding',
155
+ 'offset-top',
156
+ 'bindstickontopchange'
157
+ ], { layoutRef })
153
158
 
154
159
  return (
155
160
  createElement(
@@ -160,8 +165,7 @@ const _StickyHeader = forwardRef<HandlerRef<View, StickyHeaderProps>, StickyHead
160
165
  {
161
166
  hasVarDec,
162
167
  varContext: varContextRef.current,
163
- textStyle,
164
- textProps
168
+ textPassThrough
165
169
  }
166
170
  )
167
171
  )
@@ -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 } from './utils'
5
+ import { splitProps, splitStyle, useTransformStyle, wrapChildren, useLayout, extendObject, useTextPassThroughValue } from './utils'
6
6
  import { StickyContext } from './context'
7
7
  import useInnerProps from './getInnerListeners'
8
8
 
@@ -41,6 +41,7 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
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
45
 
45
46
  const stickyHeaders = useRef<Map<string, any>>(new Map())
46
47
 
@@ -70,7 +71,9 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
70
71
  const innerProps = useInnerProps(extendObject({}, props, {
71
72
  style: extendObject(innerStyle, layoutStyle),
72
73
  ref: sectionRef
73
- }, layoutProps), [], { layoutRef })
74
+ }, layoutProps), [
75
+ 'offset-top'
76
+ ], { layoutRef })
74
77
 
75
78
  return (
76
79
  createElement(
@@ -84,8 +87,7 @@ const _StickySection = forwardRef<HandlerRef<View, StickySectionProps>, StickySe
84
87
  {
85
88
  hasVarDec,
86
89
  varContext: varContextRef.current,
87
- textStyle,
88
- textProps
90
+ textPassThrough
89
91
  }
90
92
  )
91
93
  ))
@@ -3,7 +3,7 @@ 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 } from './utils'
6
+ import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout, extendObject, isHarmony, useTextPassThroughValue } from './utils'
7
7
  import { SwiperContext } from './context'
8
8
 
9
9
  interface SwiperItemProps {
@@ -53,6 +53,7 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
53
53
  setHeight
54
54
  } = useTransformStyle(style, { enableVar, externalVarContext })
55
55
  const { textStyle, innerStyle } = splitStyle(normalStyle)
56
+ const textPassThrough = useTextPassThroughValue(textStyle, textProps)
56
57
  useNodesRef(props, ref, nodeRef, {
57
58
  style: normalStyle
58
59
  })
@@ -76,7 +77,10 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
76
77
  [
77
78
  'children',
78
79
  'enable-offset',
79
- 'style'
80
+ 'style',
81
+ 'item-id',
82
+ 'customStyle',
83
+ 'itemIndex'
80
84
  ],
81
85
  { layoutRef })
82
86
  const itemAnimatedStyle = useAnimatedStyle(() => {
@@ -102,8 +106,7 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
102
106
  return createElement(Animated.View, mergeProps, wrapChildren(props, {
103
107
  hasVarDec,
104
108
  varContext: varContextRef.current,
105
- textStyle,
106
- textProps
109
+ textPassThrough
107
110
  }))
108
111
  })
109
112