@mpxjs/webpack-plugin 2.9.67 → 2.9.69-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. package/lib/index.js +13 -8
  2. package/lib/platform/json/wx/index.js +21 -8
  3. package/lib/platform/style/wx/index.js +35 -38
  4. package/lib/platform/template/wx/component-config/canvas.js +8 -0
  5. package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
  6. package/lib/platform/template/wx/component-config/index.js +1 -1
  7. package/lib/platform/template/wx/component-config/input.js +1 -1
  8. package/lib/platform/template/wx/component-config/rich-text.js +8 -0
  9. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  10. package/lib/platform/template/wx/component-config/textarea.js +1 -1
  11. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  12. package/lib/react/processStyles.js +14 -4
  13. package/lib/react/processTemplate.js +3 -0
  14. package/lib/resolver/AddModePlugin.js +8 -8
  15. package/lib/runtime/components/react/context.ts +6 -0
  16. package/lib/runtime/components/react/dist/context.js +2 -0
  17. package/lib/runtime/components/react/dist/event.config.js +24 -24
  18. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -174
  19. package/lib/runtime/components/react/dist/mpx-button.jsx +77 -49
  20. package/lib/runtime/components/react/dist/mpx-canvas/Bus.js +60 -0
  21. package/lib/runtime/components/react/dist/mpx-canvas/CanvasGradient.js +15 -0
  22. package/lib/runtime/components/react/dist/mpx-canvas/CanvasRenderingContext2D.js +84 -0
  23. package/lib/runtime/components/react/dist/mpx-canvas/Image.js +87 -0
  24. package/lib/runtime/components/react/dist/mpx-canvas/ImageData.js +15 -0
  25. package/lib/runtime/components/react/dist/mpx-canvas/constructorsRegistry.js +28 -0
  26. package/lib/runtime/components/react/dist/mpx-canvas/html.js +343 -0
  27. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +232 -0
  28. package/lib/runtime/components/react/dist/mpx-canvas/utils.jsx +89 -0
  29. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  30. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  31. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  32. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  33. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  34. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  35. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  36. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  37. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  38. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  39. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  40. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  41. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  42. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  43. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  44. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  45. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  46. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +160 -88
  47. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +80 -121
  48. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  49. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  50. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  51. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  52. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  53. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  54. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  55. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  56. package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
  57. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  58. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  59. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  60. package/lib/runtime/components/react/dist/mpx-view.jsx +65 -61
  61. package/lib/runtime/components/react/dist/mpx-web-view.jsx +112 -35
  62. package/lib/runtime/components/react/dist/pickerFaces.js +81 -0
  63. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  64. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  65. package/lib/runtime/components/react/dist/pickerViewOverlay.jsx +23 -0
  66. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
  67. package/lib/runtime/components/react/dist/utils.jsx +70 -23
  68. package/lib/runtime/components/react/event.config.ts +25 -26
  69. package/lib/runtime/components/react/getInnerListeners.ts +237 -199
  70. package/lib/runtime/components/react/mpx-button.tsx +104 -57
  71. package/lib/runtime/components/react/mpx-canvas/Bus.ts +70 -0
  72. package/lib/runtime/components/react/mpx-canvas/CanvasGradient.ts +18 -0
  73. package/lib/runtime/components/react/mpx-canvas/CanvasRenderingContext2D.ts +87 -0
  74. package/lib/runtime/components/react/mpx-canvas/Image.ts +102 -0
  75. package/lib/runtime/components/react/mpx-canvas/ImageData.ts +23 -0
  76. package/lib/runtime/components/react/mpx-canvas/constructorsRegistry.ts +38 -0
  77. package/lib/runtime/components/react/mpx-canvas/html.ts +343 -0
  78. package/lib/runtime/components/react/mpx-canvas/index.tsx +296 -0
  79. package/lib/runtime/components/react/mpx-canvas/utils.tsx +150 -0
  80. package/lib/runtime/components/react/mpx-checkbox-group.tsx +28 -25
  81. package/lib/runtime/components/react/mpx-checkbox.tsx +48 -49
  82. package/lib/runtime/components/react/mpx-form.tsx +25 -28
  83. package/lib/runtime/components/react/mpx-icon.tsx +12 -17
  84. package/lib/runtime/components/react/mpx-image.tsx +436 -0
  85. package/lib/runtime/components/react/mpx-input.tsx +77 -57
  86. package/lib/runtime/components/react/mpx-label.tsx +26 -27
  87. package/lib/runtime/components/react/mpx-movable-area.tsx +18 -23
  88. package/lib/runtime/components/react/mpx-movable-view.tsx +21 -25
  89. package/lib/runtime/components/react/mpx-navigator.tsx +2 -8
  90. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  91. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  92. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  93. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  94. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  95. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  96. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  97. package/lib/runtime/components/react/mpx-picker-view-column.tsx +236 -104
  98. package/lib/runtime/components/react/mpx-picker-view.tsx +132 -122
  99. package/lib/runtime/components/react/mpx-radio-group.tsx +24 -27
  100. package/lib/runtime/components/react/mpx-radio.tsx +45 -54
  101. package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
  102. package/lib/runtime/components/react/mpx-rich-text/index.tsx +121 -0
  103. package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
  104. package/lib/runtime/components/react/mpx-scroll-view.tsx +72 -71
  105. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  106. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  107. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  108. package/lib/runtime/components/react/mpx-switch.tsx +29 -23
  109. package/lib/runtime/components/react/mpx-text.tsx +14 -18
  110. package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
  111. package/lib/runtime/components/react/mpx-view.tsx +92 -76
  112. package/lib/runtime/components/react/mpx-web-view.tsx +116 -54
  113. package/lib/runtime/components/react/pickerFaces.ts +104 -0
  114. package/lib/runtime/components/react/pickerOverlay.tsx +32 -0
  115. package/lib/runtime/components/react/types/common.ts +2 -0
  116. package/lib/runtime/components/react/types/global.d.ts +5 -17
  117. package/lib/runtime/components/react/useAnimationHooks.ts +36 -11
  118. package/lib/runtime/components/react/utils.tsx +99 -28
  119. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  120. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  121. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  122. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  123. package/lib/runtime/components/web/mpx-web-view.vue +175 -161
  124. package/lib/runtime/optionProcessor.js +7 -38
  125. package/lib/runtime/utils.js +2 -0
  126. package/lib/style-compiler/plugins/scope-id.js +30 -2
  127. package/lib/template-compiler/bind-this.js +7 -2
  128. package/lib/template-compiler/compiler.js +79 -47
  129. package/lib/template-compiler/gen-node-react.js +3 -3
  130. package/lib/utils/pre-process-json.js +9 -5
  131. package/package.json +6 -4
  132. package/LICENSE +0 -433
  133. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  134. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  135. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  136. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  137. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  138. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  139. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
  140. package/lib/runtime/components/web/event.js +0 -105
@@ -33,12 +33,12 @@
33
33
  */
34
34
  import { ScrollView } from 'react-native-gesture-handler';
35
35
  import { RefreshControl } from 'react-native';
36
- import { useRef, useState, useEffect, forwardRef, useContext } from 'react';
36
+ import { useRef, useState, useEffect, forwardRef, useContext, createElement } from 'react';
37
37
  import { useAnimatedRef } from 'react-native-reanimated';
38
38
  import { warn } from '@mpxjs/utils';
39
39
  import useInnerProps, { getCustomEvent } from './getInnerListeners';
40
40
  import useNodesRef from './useNodesRef';
41
- import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, flatGesture } from './utils';
41
+ import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture } from './utils';
42
42
  import { IntersectionObserverContext } from './context';
43
43
  const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
44
44
  const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
@@ -60,11 +60,12 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
60
60
  const hasCallScrollToLower = useRef(false);
61
61
  const initialTimeout = useRef(null);
62
62
  const intersectionObservers = useContext(IntersectionObserverContext);
63
- const snapScrollIntoView = useRef('');
63
+ const firstScrollIntoViewChange = useRef(false);
64
64
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext, parentFontSize, parentWidth, parentHeight });
65
- const { textStyle, innerStyle } = splitStyle(normalStyle);
65
+ const { textStyle, innerStyle = {} } = splitStyle(normalStyle);
66
66
  const scrollViewRef = useAnimatedRef();
67
67
  useNodesRef(props, ref, scrollViewRef, {
68
+ style: normalStyle,
68
69
  scrollOffset: scrollOptions,
69
70
  node: {
70
71
  scrollEnabled: scrollX || scrollY,
@@ -97,19 +98,25 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
97
98
  }
98
99
  }, [refresherTriggered]);
99
100
  useEffect(() => {
100
- if (scrollIntoView && __selectRef && snapScrollIntoView.current !== scrollIntoView) {
101
- snapScrollIntoView.current = scrollIntoView || '';
102
- setTimeout(() => {
103
- const refs = __selectRef(`#${scrollIntoView}`, 'node');
104
- if (refs) {
105
- const { nodeRef } = refs.getNodeInstance();
106
- nodeRef.current?.measureLayout(scrollViewRef.current, (left, top) => {
107
- scrollToOffset(left, top);
108
- });
109
- }
110
- });
101
+ if (scrollIntoView && __selectRef) {
102
+ if (!firstScrollIntoViewChange.current) {
103
+ setTimeout(handleScrollIntoView);
104
+ }
105
+ else {
106
+ handleScrollIntoView();
107
+ }
111
108
  }
109
+ firstScrollIntoViewChange.current = true;
112
110
  }, [scrollIntoView]);
111
+ function handleScrollIntoView() {
112
+ const refs = __selectRef(`#${scrollIntoView}`, 'node');
113
+ if (!refs)
114
+ return;
115
+ const { nodeRef } = refs.getNodeInstance();
116
+ nodeRef.current?.measureLayout(scrollViewRef.current, (left, top) => {
117
+ scrollToOffset(left, top);
118
+ });
119
+ }
113
120
  function selectLength(size) {
114
121
  return !scrollX ? size.height : size.width;
115
122
  }
@@ -164,14 +171,13 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
164
171
  const visibleLength = selectLength(e.nativeEvent.layoutMeasurement);
165
172
  const contentLength = selectLength(e.nativeEvent.contentSize);
166
173
  const offset = selectOffset(e.nativeEvent.contentOffset);
167
- scrollOptions.current = {
168
- ...scrollOptions.current,
174
+ extendObject(scrollOptions.current, {
169
175
  contentLength,
170
176
  offset,
171
177
  scrollLeft: position.scrollLeft,
172
178
  scrollTop: position.scrollTop,
173
179
  visibleLength
174
- };
180
+ });
175
181
  }
176
182
  function onScroll(e) {
177
183
  const { bindscroll } = props;
@@ -272,8 +278,8 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
272
278
  const { x: scrollLeft, y: scrollTop } = e.nativeEvent.contentOffset;
273
279
  updateScrollOptions(e, { scrollLeft, scrollTop });
274
280
  }
275
- let scrollAdditionalProps = {
276
- style: { ...innerStyle, ...layoutStyle },
281
+ const scrollAdditionalProps = extendObject({
282
+ style: extendObject({}, innerStyle, layoutStyle),
277
283
  pinchGestureEnabled: false,
278
284
  horizontal: scrollX && !scrollY,
279
285
  scrollEventThrottle: scrollEventThrottle,
@@ -284,22 +290,18 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
284
290
  ref: scrollViewRef,
285
291
  onScroll: onScroll,
286
292
  onContentSizeChange: onContentSizeChange,
287
- bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) ? onScrollTouchStart : undefined,
288
- bindtouchmove: ((enhanced && binddragging) || bindtouchend) ? onScrollTouchMove : undefined,
289
- bindtouchend: ((enhanced && binddragend) || bindtouchend) ? onScrollTouchEnd : undefined,
293
+ bindtouchstart: ((enhanced && binddragstart) || bindtouchstart) && onScrollTouchStart,
294
+ bindtouchmove: ((enhanced && binddragging) || bindtouchend) && onScrollTouchMove,
295
+ bindtouchend: ((enhanced && binddragend) || bindtouchend) && onScrollTouchEnd,
290
296
  onScrollBeginDrag: onScrollDrag,
291
297
  onScrollEndDrag: onScrollDrag,
292
- onMomentumScrollEnd: onScrollEnd,
293
- ...layoutProps,
294
- ...(simultaneousHandlers ? { simultaneousHandlers } : {}),
295
- ...(waitForHandlers ? { waitFor: waitForHandlers } : {})
296
- };
298
+ onMomentumScrollEnd: onScrollEnd
299
+ }, (simultaneousHandlers ? { simultaneousHandlers } : {}), (waitForHandlers ? { waitFor: waitForHandlers } : {}), layoutProps);
297
300
  if (enhanced) {
298
- scrollAdditionalProps = {
299
- ...scrollAdditionalProps,
301
+ Object.assign(scrollAdditionalProps, {
300
302
  bounces,
301
303
  pagingEnabled
302
- };
304
+ });
303
305
  }
304
306
  const innerProps = useInnerProps(props, scrollAdditionalProps, [
305
307
  'id',
@@ -332,16 +334,20 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
332
334
  black: ['#000'],
333
335
  white: ['#fff']
334
336
  };
335
- return (<ScrollView {...innerProps} refreshControl={refresherEnabled
336
- ? (<RefreshControl progressBackgroundColor={refresherBackground} refreshing={refreshing} onRefresh={onRefresh} {...(refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : {})}/>)
337
- : undefined}>
338
- {wrapChildren(props, {
339
- hasVarDec,
340
- varContext: varContextRef.current,
341
- textStyle,
342
- textProps
343
- })}
344
- </ScrollView>);
337
+ return createElement(ScrollView, extendObject({}, innerProps, {
338
+ refreshControl: refresherEnabled
339
+ ? createElement(RefreshControl, extendObject({
340
+ progressBackgroundColor: refresherBackground,
341
+ refreshing: refreshing,
342
+ onRefresh: onRefresh
343
+ }, (refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : null)))
344
+ : undefined
345
+ }), wrapChildren(props, {
346
+ hasVarDec,
347
+ varContext: varContextRef.current,
348
+ textStyle,
349
+ textProps
350
+ }));
345
351
  });
346
352
  _ScrollView.displayName = 'MpxScrollView';
347
353
  export default _ScrollView;
@@ -0,0 +1,11 @@
1
+ import { Text } from 'react-native';
2
+ import { createElement } from 'react';
3
+ import { extendObject } from './utils';
4
+ const _Text2 = (props) => {
5
+ const { allowFontScaling = false } = props;
6
+ return createElement(Text, extendObject({}, props, {
7
+ allowFontScaling
8
+ }));
9
+ };
10
+ _Text2.displayName = 'MpxSimpleText';
11
+ export default _Text2;
@@ -4,12 +4,14 @@ import useInnerProps from './getInnerListeners';
4
4
  import useNodesRef from './useNodesRef'; // 引入辅助函数
5
5
  import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout } from './utils';
6
6
  const _SwiperItem = forwardRef((props, ref) => {
7
- const { 'enable-offset': enableOffset, 'enable-var': enableVar, 'external-var-context': externalVarContext, style } = props;
7
+ const { 'enable-var': enableVar, 'external-var-context': externalVarContext, style } = props;
8
8
  const { textProps } = splitProps(props);
9
9
  const nodeRef = useRef(null);
10
- useNodesRef(props, ref, nodeRef, {});
11
10
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
12
11
  const { textStyle, innerStyle } = splitStyle(normalStyle);
12
+ useNodesRef(props, ref, nodeRef, {
13
+ style: normalStyle
14
+ });
13
15
  const {
14
16
  // 存储layout布局信息
15
17
  layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });