@mpxjs/webpack-plugin 2.9.70-alpha.0 → 2.9.71

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 (126) hide show
  1. package/LICENSE +433 -0
  2. package/README.md +1 -1
  3. package/lib/config.js +0 -14
  4. package/lib/dependencies/ResolveDependency.js +0 -5
  5. package/lib/index.js +7 -38
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +0 -53
  8. package/lib/parser.js +1 -1
  9. package/lib/platform/json/wx/index.js +21 -8
  10. package/lib/platform/style/wx/index.js +51 -54
  11. package/lib/platform/template/wx/component-config/button.js +2 -14
  12. package/lib/platform/template/wx/component-config/fix-component-name.js +15 -12
  13. package/lib/platform/template/wx/component-config/image.js +0 -4
  14. package/lib/platform/template/wx/component-config/index.js +1 -1
  15. package/lib/platform/template/wx/component-config/input.js +0 -4
  16. package/lib/platform/template/wx/component-config/movable-view.js +8 -1
  17. package/lib/platform/template/wx/component-config/picker-view.js +1 -5
  18. package/lib/platform/template/wx/component-config/rich-text.js +6 -2
  19. package/lib/platform/template/wx/component-config/scroll-view.js +1 -5
  20. package/lib/platform/template/wx/component-config/switch.js +0 -4
  21. package/lib/platform/template/wx/component-config/text.js +0 -4
  22. package/lib/platform/template/wx/component-config/textarea.js +0 -5
  23. package/lib/platform/template/wx/component-config/unsupported.js +1 -1
  24. package/lib/platform/template/wx/component-config/view.js +0 -4
  25. package/lib/platform/template/wx/index.js +1 -131
  26. package/lib/resolve-loader.js +1 -4
  27. package/lib/runtime/components/react/context.ts +8 -0
  28. package/lib/runtime/components/react/dist/context.js +2 -0
  29. package/lib/runtime/components/react/dist/getInnerListeners.js +39 -37
  30. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -44
  31. package/lib/runtime/components/react/dist/mpx-canvas/html.js +2 -4
  32. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +5 -1
  33. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +93 -58
  34. package/lib/runtime/components/react/dist/mpx-navigator.jsx +1 -1
  35. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +10 -14
  36. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +94 -81
  37. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +19 -16
  38. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +10 -11
  39. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +11 -4
  40. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +31 -8
  41. package/lib/runtime/components/react/dist/mpx-swiper.jsx +435 -371
  42. package/lib/runtime/components/react/dist/mpx-view.jsx +18 -53
  43. package/lib/runtime/components/react/dist/pickerFaces.js +3 -8
  44. package/lib/runtime/components/react/dist/pickerVIewContext.js +5 -0
  45. package/lib/runtime/components/react/dist/{pickerViewOverlay.jsx → pickerViewIndicator.jsx} +6 -6
  46. package/lib/runtime/components/react/dist/pickerViewMask.jsx +2 -2
  47. package/lib/runtime/components/react/dist/useAnimationHooks.js +27 -10
  48. package/lib/runtime/components/react/dist/utils.jsx +162 -70
  49. package/lib/runtime/components/react/event.config.ts +25 -26
  50. package/lib/runtime/components/react/getInnerListeners.ts +236 -182
  51. package/lib/runtime/components/react/mpx-button.tsx +27 -69
  52. package/lib/runtime/components/react/mpx-canvas/html.ts +2 -4
  53. package/lib/runtime/components/react/mpx-canvas/index.tsx +44 -46
  54. package/lib/runtime/components/react/mpx-checkbox-group.tsx +15 -13
  55. package/lib/runtime/components/react/mpx-checkbox.tsx +20 -21
  56. package/lib/runtime/components/react/mpx-form.tsx +15 -20
  57. package/lib/runtime/components/react/mpx-icon.tsx +2 -2
  58. package/lib/runtime/components/react/mpx-image.tsx +87 -47
  59. package/lib/runtime/components/react/mpx-input.tsx +24 -32
  60. package/lib/runtime/components/react/mpx-label.tsx +12 -14
  61. package/lib/runtime/components/react/mpx-movable-area.tsx +10 -16
  62. package/lib/runtime/components/react/mpx-movable-view.tsx +133 -92
  63. package/lib/runtime/components/react/mpx-navigator.tsx +3 -9
  64. package/lib/runtime/components/react/mpx-picker-view-column-item.tsx +76 -0
  65. package/lib/runtime/components/react/mpx-picker-view-column.tsx +206 -183
  66. package/lib/runtime/components/react/mpx-picker-view.tsx +49 -48
  67. package/lib/runtime/components/react/mpx-radio-group.tsx +13 -15
  68. package/lib/runtime/components/react/mpx-radio.tsx +19 -25
  69. package/lib/runtime/components/react/mpx-rich-text/html.ts +40 -0
  70. package/lib/runtime/components/react/mpx-rich-text/index.tsx +115 -0
  71. package/lib/runtime/components/react/mpx-root-portal.tsx +3 -5
  72. package/lib/runtime/components/react/mpx-scroll-view.tsx +53 -43
  73. package/lib/runtime/components/react/mpx-swiper-item.tsx +45 -11
  74. package/lib/runtime/components/react/mpx-swiper.tsx +742 -0
  75. package/lib/runtime/components/react/mpx-switch.tsx +19 -15
  76. package/lib/runtime/components/react/mpx-text.tsx +8 -16
  77. package/lib/runtime/components/react/mpx-textarea.tsx +11 -10
  78. package/lib/runtime/components/react/mpx-view.tsx +28 -77
  79. package/lib/runtime/components/react/mpx-web-view.tsx +94 -59
  80. package/lib/runtime/components/react/pickerFaces.ts +10 -7
  81. package/lib/runtime/components/react/pickerVIewContext.ts +27 -0
  82. package/lib/runtime/components/react/pickerViewIndicator.tsx +34 -0
  83. package/lib/runtime/components/react/pickerViewMask.tsx +30 -0
  84. package/lib/runtime/components/react/types/{getInnerListeners.ts → getInnerListeners.d.ts} +4 -5
  85. package/lib/runtime/components/react/types/global.d.ts +12 -1
  86. package/lib/runtime/components/react/useAnimationHooks.ts +60 -15
  87. package/lib/runtime/components/react/utils.tsx +175 -71
  88. package/lib/runtime/components/web/mpx-checkbox.vue +1 -1
  89. package/lib/runtime/components/web/mpx-picker-view-column.vue +9 -4
  90. package/lib/runtime/components/web/mpx-web-view.vue +34 -20
  91. package/lib/runtime/optionProcessor.js +0 -22
  92. package/lib/style-compiler/index.js +1 -1
  93. package/lib/style-compiler/plugins/scope-id.js +30 -2
  94. package/lib/template-compiler/compiler.js +91 -39
  95. package/lib/utils/env.js +1 -6
  96. package/lib/utils/pre-process-json.js +9 -5
  97. package/lib/wxss/loader.js +15 -2
  98. package/package.json +4 -7
  99. package/lib/dependencies/AddEntryDependency.js +0 -24
  100. package/lib/runtime/components/react/dist/types/common.js +0 -1
  101. package/lib/runtime/components/react/dist/types/getInnerListeners.js +0 -1
  102. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +0 -527
  103. package/lib/runtime/components/react/mpx-swiper/index.tsx +0 -80
  104. package/lib/runtime/components/react/mpx-swiper/type.ts +0 -87
  105. package/lib/runtime/components/react/pickerOverlay.tsx +0 -32
  106. package/lib/runtime/components/tenon/getInnerListeners.js +0 -334
  107. package/lib/runtime/components/tenon/tenon-button.vue +0 -309
  108. package/lib/runtime/components/tenon/tenon-image.vue +0 -66
  109. package/lib/runtime/components/tenon/tenon-input.vue +0 -171
  110. package/lib/runtime/components/tenon/tenon-rich-text.vue +0 -26
  111. package/lib/runtime/components/tenon/tenon-scroll-view.vue +0 -127
  112. package/lib/runtime/components/tenon/tenon-switch.vue +0 -96
  113. package/lib/runtime/components/tenon/tenon-text.vue +0 -70
  114. package/lib/runtime/components/tenon/tenon-textarea.vue +0 -86
  115. package/lib/runtime/components/tenon/tenon-view.vue +0 -93
  116. package/lib/runtime/components/web/event.js +0 -105
  117. package/lib/runtime/optionProcessor.tenon.js +0 -84
  118. package/lib/style-compiler/plugins/hm.js +0 -20
  119. package/lib/tenon/index.js +0 -117
  120. package/lib/tenon/processJSON.js +0 -352
  121. package/lib/tenon/processScript.js +0 -203
  122. package/lib/tenon/processStyles.js +0 -21
  123. package/lib/tenon/processTemplate.js +0 -126
  124. package/lib/tenon/script-helper.js +0 -223
  125. package/lib/utils/get-relative-path.js +0 -25
  126. /package/lib/runtime/components/react/types/{common.ts → common.d.ts} +0 -0
@@ -2,10 +2,10 @@
2
2
  * ✔ nodes
3
3
  */
4
4
  import { View } from 'react-native';
5
- import { useRef, forwardRef, useState } from 'react';
5
+ import { useRef, forwardRef, useState, createElement } from 'react';
6
6
  import useInnerProps from '../getInnerListeners';
7
7
  import useNodesRef from '../useNodesRef'; // 引入辅助函数
8
- import { useTransformStyle, useLayout } from '../utils';
8
+ import { useTransformStyle, useLayout, extendObject } from '../utils';
9
9
  import { WebView } from 'react-native-webview';
10
10
  import { generateHTML } from './html';
11
11
  function jsonToHtmlStr(elements) {
@@ -44,20 +44,19 @@ const _RichText = forwardRef((props, ref) => {
44
44
  useNodesRef(props, ref, nodeRef, {
45
45
  layoutRef
46
46
  });
47
- const innerProps = useInnerProps(props, {
47
+ const innerProps = useInnerProps(props, extendObject({
48
48
  ref: nodeRef,
49
- style: { ...normalStyle, ...layoutStyle },
50
- ...layoutProps
51
- }, [], {
49
+ style: extendObject(normalStyle, layoutStyle)
50
+ }, layoutProps), [], {
52
51
  layoutRef
53
52
  });
54
53
  const html = typeof nodes === 'string' ? nodes : jsonToHtmlStr(nodes);
55
- return (<View {...innerProps}>
56
- <WebView source={{ html: generateHTML(html) }} onMessage={(event) => {
54
+ return createElement(View, innerProps, createElement(WebView, {
55
+ source: { html: generateHTML(html) },
56
+ onMessage: (event) => {
57
57
  setWebViewHeight(+event.nativeEvent.data);
58
- }}>
59
- </WebView>
60
- </View>);
58
+ }
59
+ }));
61
60
  });
62
61
  _RichText.displayName = 'mpx-rich-text';
63
62
  export default _RichText;
@@ -33,13 +33,13 @@
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, createElement } from 'react';
36
+ import { useRef, useState, useEffect, forwardRef, useContext, createElement, useMemo } 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
41
  import { splitProps, splitStyle, useTransformStyle, useLayout, wrapChildren, extendObject, flatGesture } from './utils';
42
- import { IntersectionObserverContext } from './context';
42
+ import { IntersectionObserverContext, ScrollViewContext } from './context';
43
43
  const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
44
44
  const { textProps, innerProps: props = {} } = splitProps(scrollViewProps);
45
45
  const { enhanced = false, bounces = true, style = {}, binddragstart, binddragging, binddragend, bindtouchstart, bindtouchmove, bindtouchend, 'scroll-x': scrollX = false, 'scroll-y': scrollY = false, 'enable-back-to-top': enableBackToTop = false, 'enable-trigger-intersection-observer': enableTriggerIntersectionObserver = false, 'paging-enabled': pagingEnabled = false, 'upper-threshold': upperThreshold = 50, 'lower-threshold': lowerThreshold = 50, 'scroll-with-animation': scrollWithAnimation, 'refresher-enabled': refresherEnabled, 'refresher-default-style': refresherDefaultStyle, 'refresher-background': refresherBackground, 'show-scrollbar': showScrollbar = true, 'scroll-into-view': scrollIntoView = '', 'scroll-top': scrollTop = 0, 'scroll-left': scrollLeft = 0, 'refresher-triggered': refresherTriggered, 'enable-var': enableVar, 'external-var-context': externalVarContext, 'parent-font-size': parentFontSize, 'parent-width': parentWidth, 'parent-height': parentHeight, 'simultaneous-handlers': originSimultaneousHandlers, 'wait-for': waitFor, __selectRef } = props;
@@ -78,6 +78,11 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
78
78
  },
79
79
  gestureRef: scrollViewRef
80
80
  });
81
+ const contextValue = useMemo(() => {
82
+ return {
83
+ gestureRef: scrollViewRef
84
+ };
85
+ }, []);
81
86
  const { layoutRef, layoutStyle, layoutProps } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: scrollViewRef, onLayout });
82
87
  if (scrollX && scrollY) {
83
88
  warn('scroll-x and scroll-y cannot be set to true at the same time, Mpx will use the value of scroll-y as the criterion');
@@ -196,6 +201,8 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
196
201
  layoutRef
197
202
  }, props));
198
203
  updateScrollOptions(e, { scrollLeft, scrollTop });
204
+ onStartReached(e);
205
+ onEndReached(e);
199
206
  if (enableTriggerIntersectionObserver && intersectionObservers) {
200
207
  for (const key in intersectionObservers) {
201
208
  intersectionObservers[key].throttleMeasure();
@@ -342,12 +349,12 @@ const _ScrollView = forwardRef((scrollViewProps = {}, ref) => {
342
349
  onRefresh: onRefresh
343
350
  }, (refresherDefaultStyle && refresherDefaultStyle !== 'none' ? { colors: refreshColor[refresherDefaultStyle] } : null)))
344
351
  : undefined
345
- }), wrapChildren(props, {
352
+ }), createElement(ScrollViewContext.Provider, { value: contextValue }, wrapChildren(props, {
346
353
  hasVarDec,
347
354
  varContext: varContextRef.current,
348
355
  textStyle,
349
356
  textProps
350
- }));
357
+ })));
351
358
  });
352
359
  _ScrollView.displayName = 'MpxScrollView';
353
360
  export default _ScrollView;
@@ -1,10 +1,16 @@
1
- import { View } from 'react-native';
2
- import { forwardRef, useRef } from 'react';
1
+ import Animated, { useAnimatedStyle, interpolate } from 'react-native-reanimated';
2
+ import { forwardRef, useRef, useContext } from 'react';
3
3
  import useInnerProps from './getInnerListeners';
4
4
  import useNodesRef from './useNodesRef'; // 引入辅助函数
5
5
  import { useTransformStyle, splitStyle, splitProps, wrapChildren, useLayout } from './utils';
6
+ import { SwiperContext } from './context';
6
7
  const _SwiperItem = forwardRef((props, ref) => {
7
- const { 'enable-var': enableVar, 'external-var-context': externalVarContext, style } = props;
8
+ const { 'enable-var': enableVar, 'external-var-context': externalVarContext, style, customStyle, itemIndex } = props;
9
+ const contextValue = useContext(SwiperContext);
10
+ const offset = contextValue.offset || 0;
11
+ const step = contextValue.step || 0;
12
+ const scale = contextValue.scale || false;
13
+ const dir = contextValue.dir || 'x';
8
14
  const { textProps } = splitProps(props);
9
15
  const nodeRef = useRef(null);
10
16
  const { normalStyle, hasVarDec, varContextRef, hasSelfPercent, setWidth, setHeight } = useTransformStyle(style, { enableVar, externalVarContext });
@@ -16,21 +22,38 @@ const _SwiperItem = forwardRef((props, ref) => {
16
22
  // 存储layout布局信息
17
23
  layoutRef, layoutProps, layoutStyle } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef: nodeRef });
18
24
  const innerProps = useInnerProps(props, {
19
- style: { ...innerStyle, ...layoutStyle },
20
25
  ref: nodeRef,
21
26
  ...layoutProps
22
27
  }, [
23
28
  'children',
24
- 'enable-offset'
29
+ 'enable-offset',
30
+ 'style'
25
31
  ], { layoutRef });
26
- return (<View data-itemId={props['item-id']} {...innerProps}>
27
- {wrapChildren(props, {
32
+ const itemAnimatedStyle = useAnimatedStyle(() => {
33
+ if (!step.value)
34
+ return {};
35
+ const inputRange = [step.value, 0];
36
+ const outputRange = [0.7, 1];
37
+ // 实现元素的宽度跟随step从0到真实宽度,且不能触发重新渲染整个组件,通过AnimatedStyle的方式实现
38
+ const outerLayoutStyle = dir === 'x' ? { width: step.value, height: '100%' } : { width: '100%', height: step.value };
39
+ const transformStyle = [];
40
+ if (scale) {
41
+ transformStyle.push({
42
+ scale: interpolate(Math.abs(Math.abs(offset.value) - itemIndex * step.value), inputRange, outputRange)
43
+ });
44
+ }
45
+ return Object.assign(outerLayoutStyle, {
46
+ transform: transformStyle
47
+ });
48
+ });
49
+ return (<Animated.View {...innerProps} style={[innerStyle, layoutStyle, itemAnimatedStyle, customStyle]} data-itemId={props['item-id']}>
50
+ {wrapChildren(props, {
28
51
  hasVarDec,
29
52
  varContext: varContextRef.current,
30
53
  textStyle,
31
54
  textProps
32
55
  })}
33
- </View>);
56
+ </Animated.View>);
34
57
  });
35
58
  _SwiperItem.displayName = 'MpxSwiperItem';
36
59
  export default _SwiperItem;