@mpxjs/webpack-plugin 2.9.69 → 2.9.70-alpha.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 (138) hide show
  1. package/README.md +1 -1
  2. package/lib/config.js +14 -0
  3. package/lib/dependencies/AddEntryDependency.js +24 -0
  4. package/lib/dependencies/ResolveDependency.js +5 -0
  5. package/lib/index.js +38 -7
  6. package/lib/json-compiler/helper.js +3 -3
  7. package/lib/loader.js +53 -0
  8. package/lib/platform/template/wx/component-config/button.js +14 -2
  9. package/lib/platform/template/wx/component-config/image.js +4 -0
  10. package/lib/platform/template/wx/component-config/input.js +5 -1
  11. package/lib/platform/template/wx/component-config/rich-text.js +4 -0
  12. package/lib/platform/template/wx/component-config/scroll-view.js +4 -0
  13. package/lib/platform/template/wx/component-config/swiper.js +1 -1
  14. package/lib/platform/template/wx/component-config/switch.js +4 -0
  15. package/lib/platform/template/wx/component-config/text.js +4 -0
  16. package/lib/platform/template/wx/component-config/textarea.js +6 -1
  17. package/lib/platform/template/wx/component-config/view.js +4 -0
  18. package/lib/platform/template/wx/index.js +127 -1
  19. package/lib/react/processTemplate.js +3 -0
  20. package/lib/resolve-loader.js +4 -1
  21. package/lib/runtime/components/react/context.ts +4 -0
  22. package/lib/runtime/components/react/dist/context.js +1 -0
  23. package/lib/runtime/components/react/dist/event.config.js +24 -24
  24. package/lib/runtime/components/react/dist/getInnerListeners.js +183 -165
  25. package/lib/runtime/components/react/dist/mpx-button.jsx +35 -42
  26. package/lib/runtime/components/react/dist/mpx-canvas/index.jsx +30 -12
  27. package/lib/runtime/components/react/dist/mpx-checkbox-group.jsx +13 -19
  28. package/lib/runtime/components/react/dist/mpx-checkbox.jsx +29 -38
  29. package/lib/runtime/components/react/dist/mpx-form.jsx +16 -19
  30. package/lib/runtime/components/react/dist/mpx-icon.jsx +8 -16
  31. package/lib/runtime/components/react/dist/mpx-image.jsx +291 -0
  32. package/lib/runtime/components/react/dist/mpx-input.jsx +54 -27
  33. package/lib/runtime/components/react/dist/mpx-label.jsx +15 -22
  34. package/lib/runtime/components/react/dist/mpx-movable-area.jsx +13 -16
  35. package/lib/runtime/components/react/dist/mpx-movable-view.jsx +13 -13
  36. package/lib/runtime/components/react/dist/mpx-navigator.jsx +2 -4
  37. package/lib/runtime/components/react/dist/mpx-picker/date.jsx +6 -2
  38. package/lib/runtime/components/react/dist/mpx-picker/index.jsx +5 -3
  39. package/lib/runtime/components/react/dist/mpx-picker/multiSelector.jsx +6 -2
  40. package/lib/runtime/components/react/dist/mpx-picker/region.jsx +6 -2
  41. package/lib/runtime/components/react/dist/mpx-picker/selector.jsx +6 -2
  42. package/lib/runtime/components/react/dist/mpx-picker/time.jsx +10 -15
  43. package/lib/runtime/components/react/dist/mpx-picker-view-column-item.jsx +39 -0
  44. package/lib/runtime/components/react/dist/mpx-picker-view-column.jsx +110 -97
  45. package/lib/runtime/components/react/dist/mpx-picker-view.jsx +32 -29
  46. package/lib/runtime/components/react/dist/mpx-radio-group.jsx +11 -19
  47. package/lib/runtime/components/react/dist/mpx-radio.jsx +27 -42
  48. package/lib/runtime/components/react/dist/mpx-rich-text/html.js +39 -0
  49. package/lib/runtime/components/react/dist/mpx-rich-text/index.jsx +63 -0
  50. package/lib/runtime/components/react/dist/mpx-root-portal.jsx +6 -4
  51. package/lib/runtime/components/react/dist/mpx-scroll-view.jsx +47 -41
  52. package/lib/runtime/components/react/dist/mpx-simple-text.jsx +11 -0
  53. package/lib/runtime/components/react/dist/mpx-swiper-item.jsx +4 -2
  54. package/lib/runtime/components/react/dist/mpx-swiper.jsx +606 -0
  55. package/lib/runtime/components/react/dist/mpx-switch.jsx +20 -10
  56. package/lib/runtime/components/react/dist/mpx-text.jsx +11 -10
  57. package/lib/runtime/components/react/dist/mpx-textarea.jsx +8 -3
  58. package/lib/runtime/components/react/dist/mpx-view.jsx +29 -44
  59. package/lib/runtime/components/react/dist/mpx-web-view.jsx +105 -42
  60. package/lib/runtime/components/react/dist/pickerFaces.js +12 -6
  61. package/lib/runtime/components/react/dist/pickerVIewContext.js +9 -0
  62. package/lib/runtime/components/react/dist/pickerViewMask.jsx +18 -0
  63. package/lib/runtime/components/react/dist/{pickerOverlay.jsx → pickerViewOverlay.jsx} +5 -3
  64. package/lib/runtime/components/react/dist/useAnimationHooks.js +35 -9
  65. package/lib/runtime/components/react/dist/utils.jsx +20 -24
  66. package/lib/runtime/components/react/getInnerListeners.ts +35 -28
  67. package/lib/runtime/components/react/mpx-button.tsx +55 -36
  68. package/lib/runtime/components/react/mpx-canvas/index.tsx +2 -2
  69. package/lib/runtime/components/react/mpx-checkbox-group.tsx +13 -12
  70. package/lib/runtime/components/react/mpx-checkbox.tsx +28 -28
  71. package/lib/runtime/components/react/mpx-form.tsx +10 -8
  72. package/lib/runtime/components/react/mpx-icon.tsx +10 -15
  73. package/lib/runtime/components/react/mpx-image.tsx +396 -0
  74. package/lib/runtime/components/react/mpx-input.tsx +61 -33
  75. package/lib/runtime/components/react/mpx-label.tsx +14 -13
  76. package/lib/runtime/components/react/mpx-movable-area.tsx +8 -7
  77. package/lib/runtime/components/react/mpx-movable-view.tsx +1 -1
  78. package/lib/runtime/components/react/mpx-picker/date.tsx +5 -2
  79. package/lib/runtime/components/react/mpx-picker/index.tsx +3 -2
  80. package/lib/runtime/components/react/mpx-picker/multiSelector.tsx +5 -2
  81. package/lib/runtime/components/react/mpx-picker/region.tsx +5 -2
  82. package/lib/runtime/components/react/mpx-picker/selector.tsx +5 -2
  83. package/lib/runtime/components/react/mpx-picker/time.tsx +10 -15
  84. package/lib/runtime/components/react/mpx-picker/type.ts +48 -43
  85. package/lib/runtime/components/react/mpx-picker-view-column.tsx +4 -1
  86. package/lib/runtime/components/react/mpx-picker-view.tsx +7 -1
  87. package/lib/runtime/components/react/mpx-radio-group.tsx +11 -12
  88. package/lib/runtime/components/react/mpx-radio.tsx +26 -29
  89. package/lib/runtime/components/react/mpx-scroll-view.tsx +32 -30
  90. package/lib/runtime/components/react/mpx-simple-text.tsx +18 -0
  91. package/lib/runtime/components/react/mpx-swiper/carouse.tsx +4 -2
  92. package/lib/runtime/components/react/mpx-swiper-item.tsx +3 -2
  93. package/lib/runtime/components/react/mpx-switch.tsx +10 -8
  94. package/lib/runtime/components/react/mpx-text.tsx +6 -2
  95. package/lib/runtime/components/react/mpx-view.tsx +37 -45
  96. package/lib/runtime/components/react/mpx-web-view.tsx +25 -15
  97. package/lib/runtime/components/react/types/global.d.ts +1 -16
  98. package/lib/runtime/components/react/utils.tsx +24 -24
  99. package/lib/runtime/components/tenon/getInnerListeners.js +334 -0
  100. package/lib/runtime/components/tenon/tenon-button.vue +309 -0
  101. package/lib/runtime/components/tenon/tenon-image.vue +66 -0
  102. package/lib/runtime/components/tenon/tenon-input.vue +171 -0
  103. package/lib/runtime/components/tenon/tenon-rich-text.vue +26 -0
  104. package/lib/runtime/components/tenon/tenon-scroll-view.vue +127 -0
  105. package/lib/runtime/components/tenon/tenon-switch.vue +96 -0
  106. package/lib/runtime/components/tenon/tenon-text.vue +70 -0
  107. package/lib/runtime/components/tenon/tenon-textarea.vue +86 -0
  108. package/lib/runtime/components/tenon/tenon-view.vue +93 -0
  109. package/lib/runtime/components/web/getInnerListeners.js +6 -6
  110. package/lib/runtime/components/web/mpx-movable-view.vue +334 -344
  111. package/lib/runtime/components/web/mpx-picker-view-column.vue +75 -75
  112. package/lib/runtime/components/web/mpx-picker.vue +382 -385
  113. package/lib/runtime/components/web/mpx-web-view.vue +162 -162
  114. package/lib/runtime/optionProcessor.js +7 -16
  115. package/lib/runtime/optionProcessor.tenon.js +84 -0
  116. package/lib/runtime/utils.js +2 -0
  117. package/lib/style-compiler/index.js +1 -1
  118. package/lib/style-compiler/plugins/hm.js +20 -0
  119. package/lib/template-compiler/bind-this.js +7 -2
  120. package/lib/template-compiler/compiler.js +67 -40
  121. package/lib/template-compiler/gen-node-react.js +2 -2
  122. package/lib/tenon/index.js +117 -0
  123. package/lib/tenon/processJSON.js +352 -0
  124. package/lib/tenon/processScript.js +203 -0
  125. package/lib/tenon/processStyles.js +21 -0
  126. package/lib/tenon/processTemplate.js +126 -0
  127. package/lib/tenon/script-helper.js +223 -0
  128. package/lib/utils/env.js +6 -1
  129. package/lib/utils/get-relative-path.js +25 -0
  130. package/package.json +7 -3
  131. package/LICENSE +0 -433
  132. package/lib/runtime/components/react/dist/mpx-image/index.jsx +0 -226
  133. package/lib/runtime/components/react/dist/mpx-image/svg.jsx +0 -7
  134. package/lib/runtime/components/react/dist/mpx-swiper/carouse.jsx +0 -478
  135. package/lib/runtime/components/react/dist/mpx-swiper/index.jsx +0 -68
  136. package/lib/runtime/components/react/dist/mpx-swiper/type.js +0 -1
  137. package/lib/runtime/components/react/mpx-image/index.tsx +0 -345
  138. package/lib/runtime/components/react/mpx-image/svg.tsx +0 -22
@@ -18,7 +18,6 @@ interface SwiperItemProps {
18
18
 
19
19
  const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProps>((props: SwiperItemProps, ref) => {
20
20
  const {
21
- 'enable-offset': enableOffset,
22
21
  'enable-var': enableVar,
23
22
  'external-var-context': externalVarContext,
24
23
  style
@@ -26,7 +25,6 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
26
25
 
27
26
  const { textProps } = splitProps(props)
28
27
  const nodeRef = useRef(null)
29
- useNodesRef(props, ref, nodeRef, {})
30
28
 
31
29
  const {
32
30
  normalStyle,
@@ -37,6 +35,9 @@ const _SwiperItem = forwardRef<HandlerRef<View, SwiperItemProps>, SwiperItemProp
37
35
  setHeight
38
36
  } = useTransformStyle(style, { enableVar, externalVarContext })
39
37
  const { textStyle, innerStyle } = splitStyle(normalStyle)
38
+ useNodesRef(props, ref, nodeRef, {
39
+ style: normalStyle
40
+ })
40
41
 
41
42
  const {
42
43
  // 存储layout布局信息
@@ -12,7 +12,7 @@ import useInnerProps, { getCustomEvent } from './getInnerListeners'
12
12
 
13
13
  import CheckBox from './mpx-checkbox'
14
14
  import { FormContext, FormFieldValue } from './context'
15
- import { useTransformStyle, useLayout } from './utils'
15
+ import { useTransformStyle, useLayout, extendObject } from './utils'
16
16
 
17
17
  interface _SwitchProps extends SwitchProps {
18
18
  style?: ViewStyle
@@ -42,7 +42,6 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
42
42
  'parent-font-size': parentFontSize,
43
43
  'parent-width': parentWidth,
44
44
  'parent-height': parentHeight,
45
-
46
45
  bindchange,
47
46
  catchchange
48
47
  } = props
@@ -77,7 +76,9 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
77
76
  }, [checked])
78
77
 
79
78
  const nodeRef = useRef(null)
80
- useNodesRef<Switch, _SwitchProps>(props, ref, nodeRef)
79
+ useNodesRef<Switch, _SwitchProps>(props, ref, nodeRef, {
80
+ style: normalStyle
81
+ })
81
82
 
82
83
  const {
83
84
  layoutRef,
@@ -119,12 +120,13 @@ const _Switch = forwardRef<HandlerRef<Switch, _SwitchProps>, _SwitchProps>((prop
119
120
  }
120
121
  }, [])
121
122
 
122
- const innerProps = useInnerProps(props, {
123
+ const innerProps = useInnerProps(props, extendObject({
123
124
  ref: nodeRef,
124
- style: { ...normalStyle, ...layoutStyle },
125
- ...layoutProps,
126
- ...!disabled ? { [type === 'switch' ? 'onValueChange' : '_onChange']: onChange } : {}
127
- }, [
125
+ style: extendObject({}, normalStyle, layoutStyle)
126
+ },
127
+ layoutProps,
128
+ !disabled ? { [type === 'switch' ? 'onValueChange' : '_onChange']: onChange } : {})
129
+ , [
128
130
  'checked',
129
131
  'disabled',
130
132
  'type',
@@ -25,6 +25,7 @@ interface _TextProps extends TextProps {
25
25
  const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref): JSX.Element => {
26
26
  const {
27
27
  style = {},
28
+ allowFontScaling = false,
28
29
  selectable,
29
30
  'enable-var': enableVar,
30
31
  'external-var-context': externalVarContext,
@@ -49,12 +50,15 @@ const _Text = forwardRef<HandlerRef<Text, _TextProps>, _TextProps>((props, ref):
49
50
  })
50
51
 
51
52
  const nodeRef = useRef(null)
52
- useNodesRef<Text, _TextProps>(props, ref, nodeRef)
53
+ useNodesRef<Text, _TextProps>(props, ref, nodeRef, {
54
+ style: normalStyle
55
+ })
53
56
 
54
57
  const innerProps = useInnerProps(props, {
55
58
  ref: nodeRef,
56
59
  style: normalStyle,
57
- selectable: !!selectable || !!userSelect
60
+ selectable: !!selectable || !!userSelect,
61
+ allowFontScaling
58
62
  }, [
59
63
  'user-select'
60
64
  ], {
@@ -12,7 +12,7 @@ import useAnimationHooks from './useAnimationHooks'
12
12
  import type { AnimationProp } from './useAnimationHooks'
13
13
  import { ExtendedViewStyle } from './types/common'
14
14
  import useNodesRef, { HandlerRef } from './useNodesRef'
15
- import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle } from './utils'
15
+ import { parseUrl, PERCENT_REGEX, splitStyle, splitProps, useTransformStyle, wrapChildren, useLayout, renderImage, pickStyle, extendObject } from './utils'
16
16
  import LinearGradient from 'react-native-linear-gradient'
17
17
 
18
18
  export interface _ViewProps extends ViewProps {
@@ -236,10 +236,7 @@ function backgroundPosition (imageProps: ImageProps, preImageInfo: PreImageInfo,
236
236
  }
237
237
  }
238
238
 
239
- imageProps.style = {
240
- ...imageProps.style as ImageStyle,
241
- ...style
242
- }
239
+ extendObject(imageProps.style, style)
243
240
  }
244
241
 
245
242
  // background-size 转换
@@ -292,10 +289,7 @@ function backgroundSize (imageProps: ImageProps, preImageInfo: PreImageInfo, ima
292
289
  }
293
290
 
294
291
  // 样式合并
295
- imageProps.style = {
296
- ...imageProps.style as ImageStyle,
297
- ...dimensions
298
- }
292
+ extendObject(imageProps.style, dimensions)
299
293
  }
300
294
 
301
295
  // background-image转换为source
@@ -481,10 +475,9 @@ function parseLinearGradient (text: string): LinearInfo | undefined {
481
475
  return prev
482
476
  }, { colors: [], locations: [] })
483
477
 
484
- return {
485
- ...linearInfo,
478
+ return extendObject({}, linearInfo, {
486
479
  direction: direction.trim()
487
- }
480
+ })
488
481
  }
489
482
 
490
483
  function parseBgImage (text: string): {
@@ -692,21 +685,16 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
692
685
  const [isHover, setIsHover] = useState(false)
693
686
 
694
687
  // 默认样式
695
- const defaultStyle: ExtendedViewStyle = {
696
- // flex 布局相关的默认样式
697
- ...style.display === 'flex' && {
698
- flexDirection: 'row',
699
- flexBasis: 'auto',
700
- flexShrink: 1,
701
- flexWrap: 'nowrap'
702
- }
703
- }
688
+ const defaultStyle: ExtendedViewStyle = style.display === 'flex'
689
+ ? {
690
+ flexDirection: 'row',
691
+ flexBasis: 'auto',
692
+ flexShrink: 1,
693
+ flexWrap: 'nowrap'
694
+ }
695
+ : {}
704
696
 
705
- const styleObj: ExtendedViewStyle = {
706
- ...defaultStyle,
707
- ...style,
708
- ...(isHover ? hoverStyle : null)
709
- }
697
+ const styleObj: ExtendedViewStyle = extendObject({}, defaultStyle, style, isHover ? hoverStyle as ExtendedViewStyle : {})
710
698
 
711
699
  const {
712
700
  normalStyle,
@@ -723,7 +711,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
723
711
  parentHeight
724
712
  })
725
713
 
726
- const { textStyle, backgroundStyle, innerStyle } = splitStyle(normalStyle)
714
+ const { textStyle, backgroundStyle, innerStyle = {} } = splitStyle(normalStyle)
727
715
 
728
716
  enableBackground = enableBackground || !!backgroundStyle
729
717
  const enableBackgroundRef = useRef(enableBackground)
@@ -733,7 +721,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
733
721
 
734
722
  const nodeRef = useRef(null)
735
723
  useNodesRef<View, _ViewProps>(props, ref, nodeRef, {
736
- defaultStyle
724
+ style: normalStyle
737
725
  })
738
726
 
739
727
  const dataRef = useRef<{
@@ -781,7 +769,7 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
781
769
  layoutProps
782
770
  } = useLayout({ props, hasSelfPercent, setWidth, setHeight, nodeRef })
783
771
 
784
- const viewStyle = Object.assign({}, innerStyle, layoutStyle)
772
+ const viewStyle = extendObject({}, innerStyle, layoutStyle)
785
773
 
786
774
  enableAnimation = enableAnimation || !!animation
787
775
  const enableAnimationRef = useRef(enableAnimation)
@@ -794,23 +782,27 @@ const _View = forwardRef<HandlerRef<View, _ViewProps>, _ViewProps>((viewProps, r
794
782
  style: viewStyle
795
783
  })
796
784
  : viewStyle
797
-
798
- const innerProps = useInnerProps(props, {
799
- ref: nodeRef,
800
- style: finalStyle,
801
- ...layoutProps,
802
- ...(hoverStyle && {
803
- bindtouchstart: onTouchStart,
804
- bindtouchend: onTouchEnd
785
+ const innerProps = useInnerProps(
786
+ props,
787
+ extendObject({
788
+ ref: nodeRef,
789
+ style: finalStyle
790
+ },
791
+ layoutProps,
792
+ hoverStyle
793
+ ? {
794
+ bindtouchstart: onTouchStart,
795
+ bindtouchend: onTouchEnd
796
+ }
797
+ : {}
798
+ ), [
799
+ 'hover-start-time',
800
+ 'hover-stay-time',
801
+ 'hover-style',
802
+ 'hover-class'
803
+ ], {
804
+ layoutRef
805
805
  })
806
- }, [
807
- 'hover-start-time',
808
- 'hover-stay-time',
809
- 'hover-style',
810
- 'hover-class'
811
- ], {
812
- layoutRef
813
- })
814
806
 
815
807
  const childNode = wrapWithChildren(props, {
816
808
  hasVarDec,
@@ -1,11 +1,12 @@
1
1
  import { forwardRef, JSX, useEffect, useRef, useContext, useMemo } from 'react'
2
2
  import { noop, warn } from '@mpxjs/utils'
3
+ import { View } from 'react-native'
3
4
  import { Portal } from '@ant-design/react-native'
4
5
  import { getCustomEvent } from './getInnerListeners'
5
6
  import { promisify, redirectTo, navigateTo, navigateBack, reLaunch, switchTab } from '@mpxjs/api-proxy'
6
7
  import { WebView } from 'react-native-webview'
7
8
  import useNodesRef, { HandlerRef } from './useNodesRef'
8
- import { getCurrentPage } from './utils'
9
+ import { getCurrentPage, extendObject } from './utils'
9
10
  import { WebViewNavigationEvent, WebViewErrorEvent, WebViewMessageEvent, WebViewNavigation } from 'react-native-webview/lib/WebViewTypes'
10
11
  import { RouteContext } from './context'
11
12
 
@@ -39,17 +40,11 @@ type MessageData = {
39
40
  callbackId?: number
40
41
  }
41
42
 
42
- interface NativeEvent {
43
- url: string,
44
- data: string
45
- }
46
-
47
- interface FormRef {
48
- postMessage: (value: any) => void;
49
- }
50
-
51
43
  const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((props, ref): JSX.Element => {
52
- const { src = '', bindmessage = noop, bindload = noop, binderror = noop } = props
44
+ const { src, bindmessage = noop, bindload = noop, binderror = noop } = props
45
+ if (!src) {
46
+ return (<View></View>)
47
+ }
53
48
  if (props.style) {
54
49
  warn('The web-view component does not support the style prop.')
55
50
  }
@@ -66,7 +61,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
66
61
 
67
62
  const webViewRef = useRef<WebView>(null)
68
63
  useNodesRef<WebView, WebViewProps>(props, ref, webViewRef, {
69
- defaultStyle: defaultWebViewStyle
64
+ style: defaultWebViewStyle
70
65
  })
71
66
 
72
67
  const _messageList = useRef<any[]>([])
@@ -165,14 +160,29 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
165
160
  }
166
161
  })
167
162
  }
163
+ const events = {}
164
+
165
+ if (bindload) {
166
+ extendObject(events, {
167
+ onLoad: _load
168
+ })
169
+ }
170
+ if (binderror) {
171
+ extendObject(events, {
172
+ onError: _error
173
+ })
174
+ }
175
+ if (bindmessage) {
176
+ extendObject(events, {
177
+ onMessage: _message
178
+ })
179
+ }
168
180
  return (<Portal>
169
181
  <WebView
170
182
  style={defaultWebViewStyle}
171
183
  source={{ uri: src }}
172
184
  ref={webViewRef}
173
- onLoad={_load}
174
- onError={_error}
175
- onMessage={_message}
185
+ {...events}
176
186
  onNavigationStateChange={_changeUrl}
177
187
  javaScriptEnabled={true}
178
188
  ></WebView>
@@ -1,22 +1,7 @@
1
- declare module 'react-native-svg/css' {
2
- import type { ImageSourcePropType, StyleProp, ImageStyle } from 'react-native'
3
- import type { SvgProps as SvgCssUriProps } from 'react-native-svg'
4
-
5
- export const SvgCssUri: React.ComponentType<SvgCssUriProps & { uri?: string }>
6
-
7
- export interface WithLocalSvgProps {
8
- asset: ImageSourcePropType
9
- style?: StyleProp<ImageStyle>
10
- width?: string | number
11
- height?: string | number
12
- }
13
-
14
- export const WithLocalSvg: React.ComponentType<WithLocalSvgProps>
15
- }
16
-
17
1
  declare module '@mpxjs/utils' {
18
2
  export function isEmptyObject (obj: Object): boolean
19
3
  export function isFunction (fn: unknown): boolean
4
+ export function isNumber (num: unknown): boolean
20
5
  export function hasOwn (obj: Object, key: string): boolean
21
6
  export function noop (...arg: any): void
22
7
  export function diffAndCloneA<A, B> (a: A, b?: B): {
@@ -1,6 +1,6 @@
1
1
  import { useEffect, useCallback, useMemo, useRef, ReactNode, ReactElement, isValidElement, useContext, useState, Dispatch, SetStateAction, Children, cloneElement } from 'react'
2
2
  import { LayoutChangeEvent, TextStyle, ImageProps, Image } from 'react-native'
3
- import { isObject, isFunction, hasOwn, diffAndCloneA, error, warn, getFocusedNavigation } from '@mpxjs/utils'
3
+ import { isObject, isFunction, isNumber, hasOwn, diffAndCloneA, error, warn, getFocusedNavigation } from '@mpxjs/utils'
4
4
  import { VarContext } from './context'
5
5
  import { ExpressionParser, parseFunc, ReplaceSource } from './parser'
6
6
  import { initialWindowMetrics } from 'react-native-safe-area-context'
@@ -10,8 +10,9 @@ import type { AnyFunc, ExtendedFunctionComponent } from './types/common'
10
10
  export const TEXT_STYLE_REGEX = /color|font.*|text.*|letterSpacing|lineHeight|includeFontPadding|writingDirection/
11
11
  export const PERCENT_REGEX = /^\s*-?\d+(\.\d+)?%\s*$/
12
12
  export const URL_REGEX = /^\s*url\(["']?(.*?)["']?\)\s*$/
13
+ export const SVG_REGEXP = /https?:\/\/.*\.(?:svg)/i
13
14
  export const BACKGROUND_REGEX = /^background(Image|Size|Repeat|Position)$/
14
- export const TEXT_PROPS_REGEX = /ellipsizeMode|numberOfLines/
15
+ export const TEXT_PROPS_REGEX = /ellipsizeMode|numberOfLines|allowFontScaling/
15
16
  export const DEFAULT_FONT_SIZE = 16
16
17
  export const HIDDEN_STYLE = {
17
18
  opacity: 0
@@ -31,10 +32,7 @@ const safeAreaInsetMap: Record<string, 'top' | 'right' | 'bottom' | 'left'> = {
31
32
 
32
33
  function getSafeAreaInset (name: string) {
33
34
  const navigation = getFocusedNavigation()
34
- const insets = {
35
- ...initialWindowMetrics?.insets,
36
- ...navigation?.insets
37
- }
35
+ const insets = extendObject({}, initialWindowMetrics?.insets, navigation?.insets)
38
36
  return insets[safeAreaInsetMap[name]]
39
37
  }
40
38
 
@@ -90,25 +88,18 @@ export const parseUrl = (cssUrl = '') => {
90
88
  }
91
89
 
92
90
  export const getRestProps = (transferProps: any = {}, originProps: any = {}, deletePropsKey: any = []) => {
93
- return {
94
- ...transferProps,
95
- ...omit(originProps, deletePropsKey)
96
- }
91
+ return extendObject(
92
+ {},
93
+ transferProps,
94
+ omit(originProps, deletePropsKey)
95
+ )
97
96
  }
98
97
 
99
98
  export function isText (ele: ReactNode): ele is ReactElement {
100
99
  if (isValidElement(ele)) {
101
100
  const displayName = (ele.type as ExtendedFunctionComponent)?.displayName
102
101
  const isCustomText = (ele.type as ExtendedFunctionComponent)?.isCustomText
103
- return displayName === 'MpxText' || displayName === 'Text' || !!isCustomText
104
- }
105
- return false
106
- }
107
-
108
- export function isEmbedded (ele: ReactNode): ele is ReactElement {
109
- if (isValidElement(ele)) {
110
- const displayName = (ele.type as ExtendedFunctionComponent)?.displayName || ''
111
- return ['mpx-checkbox', 'mpx-radio', 'mpx-switch'].includes(displayName)
102
+ return displayName === 'MpxText' || displayName === 'MpxSimpleText' || displayName === 'Text' || !!isCustomText
112
103
  }
113
104
  return false
114
105
  }
@@ -276,6 +267,15 @@ function transformCalc (styleObj: Record<string, any>, calcKeyPaths: Array<Array
276
267
  })
277
268
  }
278
269
 
270
+ const stringifyProps = ['fontWeight']
271
+ function transformStringify (styleObj: Record<string, any>) {
272
+ stringifyProps.forEach((prop) => {
273
+ if (isNumber(styleObj[prop])) {
274
+ styleObj[prop] = '' + styleObj[prop]
275
+ }
276
+ })
277
+ }
278
+
279
279
  interface TransformStyleConfig {
280
280
  enableVar?: boolean
281
281
  externalVarContext?: Record<string, any>
@@ -386,6 +386,8 @@ export function useTransformStyle (styleObj: Record<string, any> = {}, { enableV
386
386
  }
387
387
  }
388
388
  })
389
+ // transform number enum stringify
390
+ transformStringify(normalStyle)
389
391
 
390
392
  return {
391
393
  normalStyle,
@@ -514,8 +516,8 @@ export function wrapChildren (props: Record<string, any> = {}, { hasVarDec, varC
514
516
  if (textStyle || textProps) {
515
517
  children = Children.map(children, (child) => {
516
518
  if (isText(child)) {
517
- const style = { ...textStyle, ...child.props.style }
518
- return cloneElement(child, { ...textProps, style })
519
+ const style = extendObject({}, textStyle, child.props.style)
520
+ return cloneElement(child, extendObject({}, textProps, { style }))
519
521
  }
520
522
  return child
521
523
  })
@@ -584,9 +586,7 @@ export function flatGesture (gestures: Array<GestureHandler> = []) {
584
586
  })) || []
585
587
  }
586
588
 
587
- export function extendObject (...args: Record<string, any>[]) {
588
- return Object.assign({}, ...args)
589
- }
589
+ export const extendObject = Object.assign
590
590
 
591
591
  export function getCurrentPage (pageId: number | null) {
592
592
  if (!global.getCurrentPages) return