@mpxjs/webpack-plugin 2.10.24 → 2.11.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 (151) hide show
  1. package/lib/index.js +4 -1
  2. package/lib/platform/style/wx/index.js +417 -120
  3. package/lib/platform/template/wx/component-config/picker.js +0 -6
  4. package/lib/react/style-helper.js +6 -6
  5. package/lib/resolver/AddEnvPlugin.js +1 -1
  6. package/lib/resolver/AddModePlugin.js +1 -1
  7. package/lib/resolver/ExtendComponentsPlugin.js +68 -0
  8. package/lib/runtime/components/extends/section-list.mpx +14 -0
  9. package/lib/runtime/components/react/animationHooks/index.ts +7 -3
  10. package/lib/runtime/components/react/dist/animationHooks/index.d.ts +0 -2
  11. package/lib/runtime/components/react/dist/animationHooks/index.js +6 -1
  12. package/lib/runtime/components/react/dist/event.config.d.ts +2 -6
  13. package/lib/runtime/components/react/dist/event.config.js +28 -24
  14. package/lib/runtime/components/react/dist/getInnerListeners.d.ts +1 -1
  15. package/lib/runtime/components/react/dist/getInnerListeners.js +74 -56
  16. package/lib/runtime/components/react/dist/mpx-button.d.ts +1 -2
  17. package/lib/runtime/components/react/dist/mpx-button.jsx +16 -9
  18. package/lib/runtime/components/react/dist/mpx-camera.d.ts +0 -2
  19. package/lib/runtime/components/react/dist/mpx-camera.jsx +36 -5
  20. package/lib/runtime/components/react/dist/mpx-canvas/index.d.ts +0 -2
  21. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +1 -3
  22. package/lib/runtime/components/react/dist/mpx-canvas/utils.d.ts +1 -1
  23. package/lib/runtime/components/react/dist/mpx-checkbox-group.d.ts +0 -2
  24. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +3 -4
  25. package/lib/runtime/components/react/dist/mpx-checkbox.d.ts +1 -2
  26. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +8 -9
  27. package/lib/runtime/components/react/dist/mpx-form.d.ts +1 -2
  28. package/lib/runtime/components/react/dist/mpx-form.jsx +5 -5
  29. package/lib/runtime/components/react/dist/mpx-icon/index.d.ts +0 -2
  30. package/lib/runtime/components/react/dist/mpx-icon/index.jsx +2 -2
  31. package/lib/runtime/components/react/dist/mpx-image.d.ts +0 -2
  32. package/lib/runtime/components/react/dist/mpx-image.jsx +59 -43
  33. package/lib/runtime/components/react/dist/mpx-inline-text.jsx +13 -4
  34. package/lib/runtime/components/react/dist/mpx-input.d.ts +0 -2
  35. package/lib/runtime/components/react/dist/mpx-input.jsx +16 -8
  36. package/lib/runtime/components/react/dist/mpx-label.d.ts +1 -2
  37. package/lib/runtime/components/react/dist/mpx-label.jsx +5 -6
  38. package/lib/runtime/components/react/dist/mpx-movable-area.d.ts +0 -2
  39. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +3 -3
  40. package/lib/runtime/components/react/dist/mpx-movable-view.d.ts +1 -2
  41. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +6 -6
  42. package/lib/runtime/components/react/dist/mpx-nav.jsx +1 -1
  43. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +72 -23
  44. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +2 -2
  45. package/lib/runtime/components/react/dist/mpx-picker/type.d.ts +4 -0
  46. package/lib/runtime/components/react/dist/mpx-picker-view/index.d.ts +1 -1
  47. package/lib/runtime/components/react/dist/mpx-picker-view/index.jsx +10 -14
  48. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.d.ts +0 -2
  49. package/lib/runtime/components/react/dist/mpx-picker-view/pickerVIewContext.js +0 -5
  50. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.d.ts +1 -1
  51. package/lib/runtime/components/react/dist/mpx-picker-view-column/index.jsx +34 -14
  52. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.d.ts +0 -2
  53. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItem.jsx +4 -5
  54. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.d.ts +0 -2
  55. package/lib/runtime/components/react/dist/mpx-picker-view-column/pickerViewColumnItemLite.jsx +3 -5
  56. package/lib/runtime/components/react/dist/mpx-popup/index.d.ts +5 -4
  57. package/lib/runtime/components/react/dist/mpx-popup/index.jsx +2 -2
  58. package/lib/runtime/components/react/dist/mpx-popup/popupBase.jsx +3 -2
  59. package/lib/runtime/components/react/dist/mpx-progress.d.ts +0 -2
  60. package/lib/runtime/components/react/dist/mpx-progress.jsx +1 -3
  61. package/lib/runtime/components/react/dist/mpx-radio-group.d.ts +0 -2
  62. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +3 -4
  63. package/lib/runtime/components/react/dist/mpx-radio.d.ts +1 -2
  64. package/lib/runtime/components/react/dist/mpx-radio.jsx +8 -9
  65. package/lib/runtime/components/react/dist/mpx-rich-text/index.d.ts +0 -2
  66. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +1 -3
  67. package/lib/runtime/components/react/dist/mpx-scroll-view.d.ts +1 -2
  68. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +6 -6
  69. package/lib/runtime/components/react/dist/mpx-section-list.d.ts +51 -0
  70. package/lib/runtime/components/react/dist/mpx-section-list.jsx +376 -0
  71. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +37 -19
  72. package/lib/runtime/components/react/dist/mpx-simple-view.d.ts +4 -1
  73. package/lib/runtime/components/react/dist/mpx-simple-view.jsx +11 -4
  74. package/lib/runtime/components/react/dist/mpx-slider.d.ts +0 -2
  75. package/lib/runtime/components/react/dist/mpx-slider.jsx +6 -7
  76. package/lib/runtime/components/react/dist/mpx-sticky-header.d.ts +1 -2
  77. package/lib/runtime/components/react/dist/mpx-sticky-header.jsx +5 -5
  78. package/lib/runtime/components/react/dist/mpx-sticky-section.d.ts +1 -2
  79. package/lib/runtime/components/react/dist/mpx-sticky-section.jsx +6 -6
  80. package/lib/runtime/components/react/dist/mpx-swiper-item.d.ts +1 -2
  81. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +5 -5
  82. package/lib/runtime/components/react/dist/mpx-swiper.d.ts +1 -2
  83. package/lib/runtime/components/react/dist/mpx-swiper.jsx +4 -8
  84. package/lib/runtime/components/react/dist/mpx-switch.d.ts +0 -2
  85. package/lib/runtime/components/react/dist/mpx-switch.jsx +1 -3
  86. package/lib/runtime/components/react/dist/mpx-text.d.ts +0 -2
  87. package/lib/runtime/components/react/dist/mpx-text.jsx +43 -25
  88. package/lib/runtime/components/react/dist/mpx-video.d.ts +0 -2
  89. package/lib/runtime/components/react/dist/mpx-video.jsx +4 -5
  90. package/lib/runtime/components/react/dist/mpx-view.d.ts +2 -2
  91. package/lib/runtime/components/react/dist/mpx-view.jsx +214 -114
  92. package/lib/runtime/components/react/dist/mpx-web-view.d.ts +2 -1
  93. package/lib/runtime/components/react/dist/mpx-web-view.jsx +5 -1
  94. package/lib/runtime/components/react/dist/namedColorSet.d.ts +2 -0
  95. package/lib/runtime/components/react/dist/namedColorSet.js +149 -0
  96. package/lib/runtime/components/react/dist/utils.d.ts +71 -70
  97. package/lib/runtime/components/react/dist/utils.jsx +1295 -456
  98. package/lib/runtime/components/react/event.config.ts +32 -25
  99. package/lib/runtime/components/react/getInnerListeners.ts +84 -60
  100. package/lib/runtime/components/react/mpx-button.tsx +18 -18
  101. package/lib/runtime/components/react/mpx-camera.tsx +40 -8
  102. package/lib/runtime/components/react/mpx-canvas/index.tsx +5 -7
  103. package/lib/runtime/components/react/mpx-canvas/utils.tsx +3 -1
  104. package/lib/runtime/components/react/mpx-checkbox-group.tsx +2 -8
  105. package/lib/runtime/components/react/mpx-checkbox.tsx +9 -13
  106. package/lib/runtime/components/react/mpx-form.tsx +6 -8
  107. package/lib/runtime/components/react/mpx-icon/index.tsx +1 -5
  108. package/lib/runtime/components/react/mpx-image.tsx +66 -58
  109. package/lib/runtime/components/react/mpx-inline-text.tsx +13 -4
  110. package/lib/runtime/components/react/mpx-input.tsx +19 -12
  111. package/lib/runtime/components/react/mpx-label.tsx +6 -10
  112. package/lib/runtime/components/react/mpx-movable-area.tsx +3 -5
  113. package/lib/runtime/components/react/mpx-movable-view.tsx +7 -9
  114. package/lib/runtime/components/react/mpx-nav.tsx +1 -1
  115. package/lib/runtime/components/react/mpx-picker/index.tsx +100 -29
  116. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +3 -3
  117. package/lib/runtime/components/react/mpx-picker/selector.tsx +1 -1
  118. package/lib/runtime/components/react/mpx-picker/type.ts +4 -0
  119. package/lib/runtime/components/react/mpx-picker-view/index.tsx +17 -24
  120. package/lib/runtime/components/react/mpx-picker-view/pickerVIewContext.ts +0 -9
  121. package/lib/runtime/components/react/mpx-picker-view-column/index.tsx +44 -23
  122. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItem.tsx +1 -9
  123. package/lib/runtime/components/react/mpx-picker-view-column/pickerViewColumnItemLite.tsx +0 -9
  124. package/lib/runtime/components/react/mpx-popup/index.tsx +7 -3
  125. package/lib/runtime/components/react/mpx-popup/popupBase.tsx +3 -2
  126. package/lib/runtime/components/react/mpx-progress.tsx +0 -6
  127. package/lib/runtime/components/react/mpx-radio-group.tsx +2 -8
  128. package/lib/runtime/components/react/mpx-radio.tsx +9 -13
  129. package/lib/runtime/components/react/mpx-rich-text/index.tsx +0 -6
  130. package/lib/runtime/components/react/mpx-scroll-view.tsx +7 -9
  131. package/lib/runtime/components/react/mpx-section-list.tsx +557 -0
  132. package/lib/runtime/components/react/mpx-simple-text.tsx +36 -25
  133. package/lib/runtime/components/react/mpx-simple-view.tsx +17 -5
  134. package/lib/runtime/components/react/mpx-slider.tsx +15 -13
  135. package/lib/runtime/components/react/mpx-sticky-header.tsx +6 -8
  136. package/lib/runtime/components/react/mpx-sticky-section.tsx +7 -9
  137. package/lib/runtime/components/react/mpx-swiper-item.tsx +6 -7
  138. package/lib/runtime/components/react/mpx-swiper.tsx +5 -11
  139. package/lib/runtime/components/react/mpx-switch.tsx +0 -6
  140. package/lib/runtime/components/react/mpx-text.tsx +45 -36
  141. package/lib/runtime/components/react/mpx-video.tsx +3 -8
  142. package/lib/runtime/components/react/mpx-view.tsx +235 -129
  143. package/lib/runtime/components/react/mpx-web-view.tsx +12 -6
  144. package/lib/runtime/components/react/namedColorSet.ts +150 -0
  145. package/lib/runtime/components/react/types/getInnerListeners.d.ts +21 -1
  146. package/lib/runtime/components/react/types/global.d.ts +1 -0
  147. package/lib/runtime/components/react/utils.tsx +1352 -550
  148. package/lib/runtime/i18n.wxs +15 -9
  149. package/lib/style-compiler/strip-conditional.js +19 -4
  150. package/lib/template-compiler/compiler.js +6 -0
  151. package/package.json +6 -6
@@ -4,13 +4,18 @@ import Portal from './mpx-portal/index'
4
4
  import { usePreventRemove, PreventRemoveEvent } from '@react-navigation/native'
5
5
  import { getCustomEvent } from './getInnerListeners'
6
6
  import { promisify, redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
7
- import { WebView } from 'react-native-webview'
7
+ import { WebView, WebViewProps as RNWebViewProps } from 'react-native-webview'
8
8
  import useNodesRef, { HandlerRef } from './useNodesRef'
9
9
  import { getCurrentPage, useNavigation } from './utils'
10
10
  import { WebViewHttpErrorEvent, WebViewEvent, WebViewMessageEvent, WebViewNavigation, WebViewProgressEvent } from 'react-native-webview/lib/WebViewTypes'
11
11
  import { RouteContext } from './context'
12
12
  import { StyleSheet, View, Text } from 'react-native'
13
13
 
14
+ // react-native-webview@13.17+ 将 WebView 泛型默认值由 {} 改为 undefined,
15
+ // 导致 WebViewProps & undefined 塌成 never、JSX 直接使用时 props 全部不可赋值。
16
+ // 显式实参化为 WebView<object>(其 props 即 WebViewProps),保留类实例签名使 ref 仍解析为 WebView,兼容各版本声明。
17
+ const RNWebView = WebView as unknown as new (props: RNWebViewProps) => WebView<object>
18
+
14
19
  type OnMessageCallbackEvent = {
15
20
  detail: {
16
21
  data: any[]
@@ -30,6 +35,7 @@ interface WebViewProps {
30
35
  binderror?: (event: CommonCallbackEvent) => void
31
36
  [x: string]: any
32
37
  }
38
+ type WebViewInstance = WebView<any>
33
39
  type Listener = (type: string, callback: (e: Event) => void) => () => void
34
40
 
35
41
  interface PayloadData {
@@ -77,7 +83,7 @@ const styles = StyleSheet.create({
77
83
  }
78
84
  })
79
85
 
80
- const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((props, ref): JSX.Element | null => {
86
+ const _WebView = forwardRef<HandlerRef<WebViewInstance, WebViewProps>, WebViewProps>((props, ref): JSX.Element | null => {
81
87
  const { src, bindmessage, bindload, binderror } = props
82
88
  const mpx = global.__mpx
83
89
  const errorText: ErrorTextMap = {
@@ -98,7 +104,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
98
104
  const { pageId } = useContext(RouteContext) || {}
99
105
  const [pageLoadErr, setPageLoadErr] = useState<boolean>(false)
100
106
  const currentPage = useMemo(() => getCurrentPage(pageId), [pageId])
101
- const webViewRef = useRef<WebView>(null)
107
+ const webViewRef = useRef<WebViewInstance>(null)
102
108
  const fristLoaded = useRef<boolean>(false)
103
109
  const isLoadError = useRef<boolean>(false)
104
110
  const isNavigateBack = useRef<boolean>(false)
@@ -123,7 +129,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
123
129
  isNavigateBack.current = false
124
130
  })
125
131
 
126
- useNodesRef<WebView, WebViewProps>(props, ref, webViewRef, {
132
+ useNodesRef<WebViewInstance, WebViewProps>(props, ref, webViewRef, {
127
133
  style: defaultWebViewStyle
128
134
  })
129
135
 
@@ -352,7 +358,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
352
358
  </View>
353
359
  )
354
360
  : (
355
- <WebView
361
+ <RNWebView
356
362
  containerStyle={ defaultWebViewStyle }
357
363
  source={{ uri: src }}
358
364
  ref={webViewRef}
@@ -365,7 +371,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
365
371
  onHttpError={onHttpError}
366
372
  onError={onError}
367
373
  allowsBackForwardNavigationGestures={true}
368
- ></WebView>)}
374
+ ></RNWebView>)}
369
375
  </Portal>
370
376
  )
371
377
  })
@@ -0,0 +1,150 @@
1
+ const namedColorSet: Record<string, boolean> = {
2
+ transparent: true,
3
+ aliceblue: true,
4
+ antiquewhite: true,
5
+ aqua: true,
6
+ aquamarine: true,
7
+ azure: true,
8
+ beige: true,
9
+ bisque: true,
10
+ black: true,
11
+ blanchedalmond: true,
12
+ blue: true,
13
+ blueviolet: true,
14
+ brown: true,
15
+ burlywood: true,
16
+ cadetblue: true,
17
+ chartreuse: true,
18
+ chocolate: true,
19
+ coral: true,
20
+ cornflowerblue: true,
21
+ cornsilk: true,
22
+ crimson: true,
23
+ cyan: true,
24
+ darkblue: true,
25
+ darkcyan: true,
26
+ darkgoldenrod: true,
27
+ darkgray: true,
28
+ darkgreen: true,
29
+ darkgrey: true,
30
+ darkkhaki: true,
31
+ darkmagenta: true,
32
+ darkolivegreen: true,
33
+ darkorange: true,
34
+ darkorchid: true,
35
+ darkred: true,
36
+ darksalmon: true,
37
+ darkseagreen: true,
38
+ darkslateblue: true,
39
+ darkslategrey: true,
40
+ darkturquoise: true,
41
+ darkviolet: true,
42
+ deeppink: true,
43
+ deepskyblue: true,
44
+ dimgray: true,
45
+ dimgrey: true,
46
+ dodgerblue: true,
47
+ firebrick: true,
48
+ floralwhite: true,
49
+ forestgreen: true,
50
+ fuchsia: true,
51
+ gainsboro: true,
52
+ ghostwhite: true,
53
+ gold: true,
54
+ goldenrod: true,
55
+ gray: true,
56
+ green: true,
57
+ greenyellow: true,
58
+ grey: true,
59
+ honeydew: true,
60
+ hotpink: true,
61
+ indianred: true,
62
+ indigo: true,
63
+ ivory: true,
64
+ khaki: true,
65
+ lavender: true,
66
+ lavenderblush: true,
67
+ lawngreen: true,
68
+ lemonchiffon: true,
69
+ lightblue: true,
70
+ lightcoral: true,
71
+ lightcyan: true,
72
+ lightgoldenrodyellow: true,
73
+ lightgray: true,
74
+ lightgreen: true,
75
+ lightgrey: true,
76
+ lightpink: true,
77
+ lightsalmon: true,
78
+ lightseagreen: true,
79
+ lightskyblue: true,
80
+ lightslategrey: true,
81
+ lightsteelblue: true,
82
+ lightyellow: true,
83
+ lime: true,
84
+ limegreen: true,
85
+ linen: true,
86
+ magenta: true,
87
+ maroon: true,
88
+ mediumaquamarine: true,
89
+ mediumblue: true,
90
+ mediumorchid: true,
91
+ mediumpurple: true,
92
+ mediumseagreen: true,
93
+ mediumslateblue: true,
94
+ mediumspringgreen: true,
95
+ mediumturquoise: true,
96
+ mediumvioletred: true,
97
+ midnightblue: true,
98
+ mintcream: true,
99
+ mistyrose: true,
100
+ moccasin: true,
101
+ navajowhite: true,
102
+ navy: true,
103
+ oldlace: true,
104
+ olive: true,
105
+ olivedrab: true,
106
+ orange: true,
107
+ orangered: true,
108
+ orchid: true,
109
+ palegoldenrod: true,
110
+ palegreen: true,
111
+ paleturquoise: true,
112
+ palevioletred: true,
113
+ papayawhip: true,
114
+ peachpuff: true,
115
+ peru: true,
116
+ pink: true,
117
+ plum: true,
118
+ powderblue: true,
119
+ purple: true,
120
+ rebeccapurple: true,
121
+ red: true,
122
+ rosybrown: true,
123
+ royalblue: true,
124
+ saddlebrown: true,
125
+ salmon: true,
126
+ sandybrown: true,
127
+ seagreen: true,
128
+ seashell: true,
129
+ sienna: true,
130
+ silver: true,
131
+ skyblue: true,
132
+ slateblue: true,
133
+ slategray: true,
134
+ snow: true,
135
+ springgreen: true,
136
+ steelblue: true,
137
+ tan: true,
138
+ teal: true,
139
+ thistle: true,
140
+ tomato: true,
141
+ turquoise: true,
142
+ violet: true,
143
+ wheat: true,
144
+ white: true,
145
+ whitesmoke: true,
146
+ yellow: true,
147
+ yellowgreen: true
148
+ }
149
+
150
+ export default namedColorSet
@@ -43,6 +43,14 @@ interface EventConfigDetail {
43
43
  hasCatch: boolean
44
44
  }
45
45
 
46
+ interface EventMeta {
47
+ bitFlag: string
48
+ events: string[]
49
+ eventName: string
50
+ eventType: EventType
51
+ hasCatch: boolean
52
+ }
53
+
46
54
  type EventConfig = {
47
55
  innerRef: InnerRef
48
56
  propsRef: PropsRef
@@ -52,6 +60,15 @@ type EventConfig = {
52
60
  [index: string]: EventConfigDetail
53
61
  }
54
62
 
63
+ type EventConfigRef = MutableRefObject<EventConfig>
64
+
65
+ type TouchHandler = (e: ExtendedNativeTouchEvent, type: EventType, eventConfig: EventConfig) => void
66
+
67
+ interface TouchHandlerConfig {
68
+ type: EventType
69
+ handler: TouchHandler
70
+ }
71
+
55
72
  interface RawConfig {
56
73
  layoutRef?: LayoutRef
57
74
  disableTap?: boolean
@@ -101,7 +118,10 @@ export {
101
118
  Navigation,
102
119
  ExtendedNativeTouchEvent,
103
120
  EventConfig,
121
+ EventConfigRef,
122
+ EventMeta,
104
123
  RawConfig,
105
124
  EventType,
106
- GlobalEventState
125
+ GlobalEventState,
126
+ TouchHandlerConfig
107
127
  }
@@ -14,6 +14,7 @@ declare module '@mpxjs/utils' {
14
14
  diff: boolean
15
15
  diffData: Object | null
16
16
  }
17
+ export function shallowEqual (a: unknown, b: unknown): boolean
17
18
  export function isObject (value): value is Object
18
19
  export function error (msg: string, location?: string, e?: any): void
19
20
  export function warn (msg: string, location?: string, e?: any): void