@mpxjs/webpack-plugin 2.9.40 → 2.9.41

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 (66) hide show
  1. package/lib/config.js +63 -97
  2. package/lib/dependencies/DynamicEntryDependency.js +13 -4
  3. package/lib/dependencies/{RecordVueContentDependency.js → RecordLoaderContentDependency.js} +5 -5
  4. package/lib/dependencies/ResolveDependency.js +2 -2
  5. package/lib/helpers.js +5 -1
  6. package/lib/index.js +59 -45
  7. package/lib/json-compiler/helper.js +6 -3
  8. package/lib/json-compiler/index.js +9 -7
  9. package/lib/loader.js +43 -97
  10. package/lib/native-loader.js +0 -1
  11. package/lib/platform/index.js +3 -0
  12. package/lib/platform/style/wx/index.js +414 -0
  13. package/lib/platform/template/wx/component-config/button.js +36 -0
  14. package/lib/platform/template/wx/component-config/image.js +15 -0
  15. package/lib/platform/template/wx/component-config/input.js +41 -0
  16. package/lib/platform/template/wx/component-config/scroll-view.js +27 -1
  17. package/lib/platform/template/wx/component-config/swiper-item.js +13 -1
  18. package/lib/platform/template/wx/component-config/swiper.js +25 -1
  19. package/lib/platform/template/wx/component-config/text.js +15 -0
  20. package/lib/platform/template/wx/component-config/textarea.js +39 -0
  21. package/lib/platform/template/wx/component-config/unsupported.js +18 -0
  22. package/lib/platform/template/wx/component-config/view.js +14 -0
  23. package/lib/platform/template/wx/index.js +88 -4
  24. package/lib/react/index.js +104 -0
  25. package/lib/react/processJSON.js +361 -0
  26. package/lib/react/processMainScript.js +21 -0
  27. package/lib/react/processScript.js +70 -0
  28. package/lib/react/processStyles.js +69 -0
  29. package/lib/react/processTemplate.js +152 -0
  30. package/lib/react/script-helper.js +133 -0
  31. package/lib/react/style-helper.js +91 -0
  32. package/lib/resolver/PackageEntryPlugin.js +1 -0
  33. package/lib/runtime/components/react/event.config.ts +32 -0
  34. package/lib/runtime/components/react/getInnerListeners.ts +289 -0
  35. package/lib/runtime/components/react/getInnerListeners.type.ts +68 -0
  36. package/lib/runtime/components/react/mpx-button.tsx +402 -0
  37. package/lib/runtime/components/react/mpx-image/index.tsx +351 -0
  38. package/lib/runtime/components/react/mpx-image/svg.tsx +21 -0
  39. package/lib/runtime/components/react/mpx-input.tsx +389 -0
  40. package/lib/runtime/components/react/mpx-scroll-view.tsx +412 -0
  41. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +398 -0
  42. package/lib/runtime/components/react/mpx-swiper/index.tsx +68 -0
  43. package/lib/runtime/components/react/mpx-swiper/type.ts +69 -0
  44. package/lib/runtime/components/react/mpx-swiper-item.tsx +42 -0
  45. package/lib/runtime/components/react/mpx-text.tsx +106 -0
  46. package/lib/runtime/components/react/mpx-textarea.tsx +46 -0
  47. package/lib/runtime/components/react/mpx-view.tsx +397 -0
  48. package/lib/runtime/components/react/useNodesRef.ts +39 -0
  49. package/lib/runtime/components/react/utils.ts +92 -0
  50. package/lib/runtime/optionProcessorReact.d.ts +9 -0
  51. package/lib/runtime/optionProcessorReact.js +21 -0
  52. package/lib/runtime/stringify.wxs +10 -28
  53. package/lib/style-compiler/index.js +2 -1
  54. package/lib/template-compiler/compiler.js +280 -37
  55. package/lib/template-compiler/gen-node-react.js +95 -0
  56. package/lib/template-compiler/index.js +15 -24
  57. package/lib/utils/env.js +17 -0
  58. package/lib/utils/make-map.js +1 -1
  59. package/lib/utils/shallow-stringify.js +12 -12
  60. package/lib/web/index.js +123 -0
  61. package/lib/web/processJSON.js +3 -3
  62. package/lib/web/processMainScript.js +25 -23
  63. package/lib/web/processScript.js +12 -16
  64. package/lib/web/processTemplate.js +13 -12
  65. package/lib/web/script-helper.js +14 -22
  66. package/package.json +4 -3
@@ -0,0 +1,402 @@
1
+ /**
2
+ * ✔ size
3
+ * ✔ type
4
+ * ✔ plain
5
+ * ✔ disabled
6
+ * ✔ loading
7
+ * ✘ form-type
8
+ * - open-type: Partially. Only support `share`、`getUserInfo`
9
+ * ✔ hover-class: Convert hoverClass to hoverStyle.
10
+ * ✔ hover-style
11
+ * ✘ hover-stop-propagation
12
+ * ✔ hover-start-time
13
+ * ✔ hover-stay-time
14
+ * ✘ lang
15
+ * ✘ session-from
16
+ * ✘ send-message-title
17
+ * ✘ send-message-path
18
+ * ✘ send-message-img
19
+ * ✘ app-parameter
20
+ * ✘ show-message-card
21
+ * ✘ phone-number-no-quota-toast
22
+ * ✘ bindgetuserinfo
23
+ * ✘ bindcontact
24
+ * ✘ createliveactivity
25
+ * ✘ bindgetphonenumber
26
+ * ✘ bindgetphonenumber
27
+ * ✘ bindgetrealtimephonenumber
28
+ * ✘ binderror
29
+ * ✘ bindopensetting
30
+ * ✘ bindlaunchapp
31
+ * ✘ bindlaunchapp
32
+ * ✘ bindchooseavatar
33
+ * ✘ bindchooseavatar
34
+ * ✘ bindagreeprivacyauthorization
35
+ * ✔ bindtap
36
+ */
37
+ import React, {
38
+ useEffect,
39
+ useRef,
40
+ useState,
41
+ ReactNode,
42
+ forwardRef,
43
+ } from 'react'
44
+ import {
45
+ View,
46
+ Text,
47
+ StyleSheet,
48
+ StyleProp,
49
+ ViewStyle,
50
+ TextStyle,
51
+ Animated,
52
+ Easing,
53
+ NativeSyntheticEvent,
54
+ } from 'react-native'
55
+ import { extractTextStyle, isText, every } from './utils'
56
+ import useInnerProps, { getCustomEvent } from './getInnerListeners'
57
+ import useNodesRef, { HandlerRef } from './useNodesRef'
58
+
59
+ export type Type = 'default' | 'primary' | 'warn'
60
+
61
+ /**
62
+ * normal、hover、plain、disabled
63
+ */
64
+ type TypeColor = [string, string, string, string]
65
+
66
+ export type OpenType = 'share' | 'getUserInfo'
67
+
68
+ export type OpenTypeEvent = 'onShareAppMessage' | 'onUserInfo'
69
+
70
+ export interface ButtonProps {
71
+ size?: string
72
+ type?: Type
73
+ plain?: boolean
74
+ disabled?: boolean
75
+ loading?: boolean
76
+ 'hover-class'?: string
77
+ 'hover-style'?: StyleProp<ViewStyle & TextStyle>
78
+ 'hover-start-time'?: number
79
+ 'hover-stay-time'?: number
80
+ 'open-type'?: OpenType
81
+ 'enable-offset'?: boolean,
82
+ style?: StyleProp<ViewStyle & TextStyle>
83
+ children: ReactNode
84
+ bindgetuserinfo?: (userInfo: any) => void
85
+ bindtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
86
+ catchtap?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
87
+ bindtouchstart?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
88
+ bindtouchend?: (evt: NativeSyntheticEvent<TouchEvent> | unknown) => void
89
+ }
90
+
91
+ const LOADING_IMAGE_URI =
92
+ 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAAAAXNSR0IB2cksfwAAAAlwSFlzAAALEwAACxMBAJqcGAAAB8hJREFUeJztnVtsFFUch6ltUYrEAi0Qo40xChGM+oAGI0EEKl4QfDVI9AkqqQZ4IVA1RSIvJlwUWwqJUokGKMVYwHJTq4mGuA+SxpJYggJSSgMpVFOtvbh+J84mk+3smXN2znZm2fNLvoQH5uQ/v4+Z2Z3dHUaNsrGxsbGxsbGxsbGxsbGxsTGSrq6uUqiHqw7iz6Vhz5WzofwYxJP4Mey5cjIUX+4hI0F52PPlXCi9WiKkOuz5ci5WiMFcvHhxOXRCHPpgLdyis4ZJITtqagtgPfRBHH6HV3XWyNpQ/DxHRDJbddYxLKTGEZHMLK2dy8ZQ/O4UQgQzVdcxJYTSZ6aQIfggrZ3MplD6CYmQmOo6BoXEJEK+TGsnsymUXicRIlimso4JIRS+TCJDsD3QzmZDKHwqDEmEdECR3zpBhVB2EVyWyBiC+4zsdNRD4Vt8jpJ3/dYwIGSTz9Gx2cjOZkMofBx0S4SIl8JlsjWCCKHsMuiXyOiGcUZ3Ouqh8BU+R0mjbPuAQg76HB3Lje5sNoTC86DNR8qcVNunK4Sy5/jIaIO8jOx01CMK9xEihHmWk44Qis53CpcJSfmPICdC4Q0+Ul7z2i5NISt9ZOzP6M5mQ8TF27mIpxIiLv7DLrC6t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['#1AAD19', '#179B16', '26,173,25', '#9ED99D'],
97
+ warn: ['#E64340', '#CE3C39', '230,67,64', '#EC8B89'],
98
+ }
99
+
100
+ const OpenTypeEventsMap = new Map<OpenType, OpenTypeEvent>([
101
+ ['share', 'onShareAppMessage'],
102
+ ['getUserInfo', 'onUserInfo'],
103
+ ])
104
+
105
+ const styles = StyleSheet.create({
106
+ button: {
107
+ width: '100%',
108
+ flexDirection: 'row',
109
+ justifyContent: 'center',
110
+ alignItems: 'center',
111
+ height: 46,
112
+ borderRadius: 5,
113
+ backgroundColor: '#F8F8F8',
114
+ marginHorizontal: 'auto' // 按钮默认居中
115
+ },
116
+ buttonMini: {
117
+ height: 30,
118
+ },
119
+ text: {
120
+ fontSize: 18,
121
+ color: '#000000',
122
+ },
123
+ textMini: {
124
+ fontSize: 13,
125
+ },
126
+ loading: {
127
+ width: 20,
128
+ height: 20,
129
+ },
130
+ })
131
+
132
+ const getOpenTypeEvent = (openType: OpenType) => {
133
+ // @ts-ignore
134
+ if (!global?.__mpx?.config?.rnConfig) {
135
+ console.warn('Environment not supported')
136
+ return
137
+ }
138
+
139
+ const eventName = OpenTypeEventsMap.get(openType)
140
+ if (!eventName) {
141
+ console.warn(`open-type not support ${openType}`)
142
+ return
143
+ }
144
+
145
+ // @ts-ignore
146
+ const event = global.__mpx.config.rnConfig?.openTypeHandler?.[eventName]
147
+ if (!event) {
148
+ console.warn(`Unregistered ${eventName} event`)
149
+ return
150
+ }
151
+
152
+ return event
153
+ }
154
+
155
+ const Loading = ({ alone = false }: { alone: boolean }): React.JSX.Element => {
156
+ const image = useRef(new Animated.Value(0)).current
157
+
158
+ const rotate = image.interpolate({
159
+ inputRange: [0, 1],
160
+ outputRange: ['0deg', '360deg'],
161
+ })
162
+
163
+ useEffect(() => {
164
+ const animation = Animated.loop(
165
+ Animated.timing(image, {
166
+ toValue: 1,
167
+ duration: 1000,
168
+ easing: Easing.linear,
169
+ useNativeDriver: true,
170
+ isInteraction: false,
171
+ })
172
+ )
173
+
174
+ animation.start()
175
+
176
+ return () => {
177
+ animation.stop()
178
+ }
179
+ // eslint-disable-next-line react-hooks/exhaustive-deps
180
+ }, [])
181
+
182
+ const loadingStyle = {
183
+ ...styles.loading,
184
+ transform: [{ rotate }],
185
+ marginRight: alone ? 0 : 5,
186
+ }
187
+
188
+ return <Animated.Image testID="loading" style={loadingStyle} source={{ uri: LOADING_IMAGE_URI }} />
189
+ }
190
+
191
+ const Button = forwardRef<HandlerRef< View, ButtonProps>,ButtonProps >((props, ref): React.JSX.Element => {
192
+ const {
193
+ size = 'default',
194
+ type = 'default',
195
+ plain = false,
196
+ disabled = false,
197
+ loading = false,
198
+ 'hover-class': hoverClass,
199
+ 'hover-style': hoverStyle = [],
200
+ 'hover-start-time': hoverStartTime = 20,
201
+ 'hover-stay-time': hoverStayTime = 70,
202
+ 'open-type': openType,
203
+ 'enable-offset': enableOffset,
204
+ style = [],
205
+ children,
206
+ bindgetuserinfo,
207
+ bindtap,
208
+ catchtap,
209
+ bindtouchstart,
210
+ bindtouchend,
211
+ } = props
212
+
213
+ const refs = useRef<{
214
+ hoverStartTimer: ReturnType<typeof setTimeout> | undefined
215
+ hoverStayTimer: ReturnType<typeof setTimeout> | undefined
216
+ }>({
217
+ hoverStartTimer: undefined,
218
+ hoverStayTimer: undefined,
219
+ })
220
+
221
+ const layoutRef = useRef({})
222
+
223
+ const [isHover, setIsHover] = useState(false)
224
+
225
+ const isMiniSize = size === 'mini'
226
+
227
+ const applyHoverEffect = isHover && hoverClass !== 'none'
228
+
229
+ const inheritTextStyle = extractTextStyle(style)
230
+
231
+ const textHoverStyle = extractTextStyle(hoverStyle)
232
+
233
+ const [color, hoverColor, plainColor, disabledColor] = TypeColorMap[type]
234
+
235
+ const normalBackgroundColor = disabled ? disabledColor : applyHoverEffect || loading ? hoverColor : color
236
+
237
+ const plainBorderColor = disabled
238
+ ? 'rgba(0, 0, 0, .2)'
239
+ : applyHoverEffect
240
+ ? `rgba(${plainColor},.6)`
241
+ : `rgb(${plainColor})`
242
+
243
+ const normalBorderColor = type === 'default' ? 'rgba(0, 0, 0, .2)' : normalBackgroundColor
244
+
245
+ const plainTextColor = disabled
246
+ ? 'rgba(0, 0, 0, .2)'
247
+ : applyHoverEffect
248
+ ? `rgba(${plainColor}, .6)`
249
+ : `rgb(${plainColor})`
250
+
251
+ const normalTextColor =
252
+ type === 'default'
253
+ ? `rgba(0, 0, 0, ${disabled ? 0.3 : applyHoverEffect || loading ? 0.6 : 1})`
254
+ : `rgba(255 ,255 ,255 , ${disabled || applyHoverEffect || loading ? 0.6 : 1})`
255
+
256
+ const viewStyle = {
257
+ borderWidth: 1,
258
+ borderStyle: 'solid',
259
+ borderColor: plain ? plainBorderColor : normalBorderColor,
260
+ backgroundColor: plain ? 'transparent' : normalBackgroundColor,
261
+ }
262
+
263
+ const textStyle = {
264
+ color: plain ? plainTextColor : normalTextColor,
265
+ ...inheritTextStyle
266
+ }
267
+
268
+ const defaultViewStyle = [
269
+ styles.button,
270
+ isMiniSize && styles.buttonMini || {},
271
+ viewStyle,
272
+ ]
273
+
274
+ const defaultTextStyle = [
275
+ styles.text, isMiniSize && styles.textMini, textStyle
276
+ ]
277
+
278
+ const handleOpenTypeEvent = (evt: NativeSyntheticEvent<TouchEvent>) => {
279
+ if (!openType) return
280
+ const handleEvent = getOpenTypeEvent(openType)
281
+
282
+ if (openType === 'share') {
283
+ handleEvent && handleEvent({
284
+ from: 'button',
285
+ target: getCustomEvent('tap', evt, { layoutRef }, props).target,
286
+ })
287
+ }
288
+
289
+ if (openType === 'getUserInfo') {
290
+ const userInfo = handleEvent && handleEvent()
291
+ if (typeof userInfo === 'object') {
292
+ bindgetuserinfo && bindgetuserinfo(userInfo)
293
+ }
294
+ }
295
+ }
296
+
297
+ const setStayTimer = () => {
298
+ clearTimeout(refs.current.hoverStayTimer)
299
+ refs.current.hoverStayTimer = setTimeout(() => {
300
+ setIsHover(false)
301
+ clearTimeout(refs.current.hoverStayTimer)
302
+ }, hoverStayTime)
303
+ }
304
+
305
+ const setStartTimer = () => {
306
+ clearTimeout(refs.current.hoverStartTimer)
307
+ refs.current.hoverStartTimer = setTimeout(() => {
308
+ setIsHover(true)
309
+ clearTimeout(refs.current.hoverStartTimer)
310
+ }, hoverStartTime)
311
+ }
312
+
313
+ const onTouchStart = (evt: NativeSyntheticEvent<TouchEvent>) => {
314
+ bindtouchstart && bindtouchstart(evt)
315
+ if (disabled) return
316
+ setStartTimer()
317
+ }
318
+
319
+ const onTouchEnd = (evt: NativeSyntheticEvent<TouchEvent>) => {
320
+ bindtouchend && bindtouchend(evt)
321
+ if (disabled) return
322
+ setStayTimer()
323
+ }
324
+
325
+ const onTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
326
+ if (disabled) return
327
+ bindtap && bindtap(getCustomEvent('tap', evt, { layoutRef }, props))
328
+ handleOpenTypeEvent(evt)
329
+ }
330
+
331
+ const catchTap = (evt: NativeSyntheticEvent<TouchEvent>) => {
332
+ if (disabled) return
333
+ catchtap && catchtap(getCustomEvent('tap', evt, { layoutRef }, props))
334
+ handleOpenTypeEvent(evt)
335
+ }
336
+
337
+ function wrapChildren(children: ReactNode, textStyle?: StyleProp<TextStyle>) {
338
+ if (every(children, (child)=>isText(child))) {
339
+ children = [<Text key='buttonTextWrap' style={textStyle}>{children}</Text>]
340
+ } else {
341
+ if(textStyle) console.warn('Text style will be ignored unless every child of the button is Text node!')
342
+ }
343
+
344
+ return children
345
+ }
346
+
347
+ const { nodeRef } = useNodesRef(props, ref, {
348
+ defaultStyle: StyleSheet.flatten([
349
+ ...defaultViewStyle,
350
+ ...defaultTextStyle,
351
+ ])
352
+ })
353
+
354
+ const onLayout = () => {
355
+ nodeRef.current?.measure((x: number, y: number, width: number, height: number, offsetLeft: number, offsetTop: number) => {
356
+ layoutRef.current = { x, y, width, height, offsetLeft, offsetTop }
357
+ })
358
+ }
359
+
360
+ const innerProps = useInnerProps(
361
+ props,
362
+ {
363
+ ref: nodeRef,
364
+ bindtouchstart: onTouchStart,
365
+ bindtouchend: onTouchEnd,
366
+ bindtap: onTap,
367
+ catchtap: catchTap,
368
+ ...(enableOffset ? { onLayout } : {}),
369
+ },
370
+ [
371
+ 'enable-offset'
372
+ ],
373
+ {
374
+ layoutRef
375
+ }
376
+ );
377
+
378
+ return (
379
+ <View
380
+ {...innerProps}
381
+ style={[
382
+ ...defaultViewStyle,
383
+ style,
384
+ applyHoverEffect && hoverStyle,
385
+ ]}>
386
+ {loading && <Loading alone={!children} />}
387
+ {
388
+ wrapChildren(
389
+ children,
390
+ [
391
+ ...defaultTextStyle,
392
+ applyHoverEffect && textHoverStyle,
393
+ ]
394
+ )
395
+ }
396
+ </View>
397
+ )
398
+ })
399
+
400
+ Button.displayName = 'mpx-button'
401
+
402
+ export default Button