@mpxjs/webpack-plugin 2.10.4-beta.2 → 2.10.4-beta.4

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.
@@ -113,13 +113,14 @@ module.exports = function (jsonContent, {
113
113
  }
114
114
 
115
115
  if (ctorType === 'page') {
116
- const keysToExtract = ['navigationStyle']
116
+ // const keysToExtract = ['navigationStyle']
117
117
  const configObj = {}
118
- keysToExtract.forEach(key => {
119
- if (jsonObj[key]) {
120
- configObj[key] = jsonObj[key]
121
- }
122
- })
118
+ // 暂时先不注入数据,后续如需要使用再用
119
+ // keysToExtract.forEach(key => {
120
+ // if (jsonObj[key]) {
121
+ // configObj[key] = jsonObj[key]
122
+ // }
123
+ // })
123
124
  loaderContext._module.addPresentationalDependency(new RecordPageConfigsMapDependency(parseRequest(loaderContext.resource).resourcePath, configObj))
124
125
  }
125
126
 
@@ -1,7 +1,6 @@
1
- import React, { useContext, useEffect, useMemo } from 'react';
1
+ import React, { useContext, useEffect } from 'react';
2
2
  import { Keyboard, View } from 'react-native';
3
3
  import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated';
4
- import { GestureDetector, Gesture } from 'react-native-gesture-handler';
5
4
  import { KeyboardAvoidContext } from './context';
6
5
  import { isIOS } from './utils';
7
6
  const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
@@ -10,20 +9,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
10
9
  const offset = useSharedValue(0);
11
10
  const basic = useSharedValue('auto');
12
11
  const keyboardAvoid = useContext(KeyboardAvoidContext);
13
- const dismiss = () => {
14
- Keyboard.isVisible() && Keyboard.dismiss();
15
- };
16
- const gesture = useMemo(() => {
17
- return Gesture.Tap()
18
- .onEnd(() => {
19
- dismiss();
20
- }).runOnJS(true);
21
- }, []);
22
- const animatedStyle = useAnimatedStyle(() => {
23
- return Object.assign({
24
- transform: [{ translateY: -offset.value }]
25
- }, isIOS ? {} : { flexBasis: basic.value });
26
- });
12
+ const animatedStyle = useAnimatedStyle(() => ({
13
+ transform: [{ translateY: -offset.value }],
14
+ flexBasis: basic.value
15
+ }));
27
16
  const resetKeyboard = () => {
28
17
  if (keyboardAvoid?.current) {
29
18
  keyboardAvoid.current = null;
@@ -31,6 +20,9 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
31
20
  offset.value = withTiming(0, { duration, easing });
32
21
  basic.value = 'auto';
33
22
  };
23
+ const onTouchEnd = () => {
24
+ Keyboard.isVisible() && Keyboard.dismiss();
25
+ };
34
26
  useEffect(() => {
35
27
  let subscriptions = [];
36
28
  if (isIOS) {
@@ -46,7 +38,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
46
38
  const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing;
47
39
  const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing);
48
40
  const value = aboveOffset > 0 ? belowValue : aboveValue;
49
- offset.value = withTiming(value, { duration, easing });
41
+ offset.value = withTiming(value, { duration, easing }, (finished) => {
42
+ if (finished) {
43
+ // Set flexBasic after animation to trigger re-layout and reset layout information
44
+ basic.value = '99.99%';
45
+ }
46
+ });
50
47
  });
51
48
  });
52
49
  }),
@@ -68,11 +65,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
68
65
  const value = aboveOffset > 0 ? belowValue : aboveValue;
69
66
  offset.value = withTiming(value, { duration, easing }, (finished) => {
70
67
  if (finished) {
71
- /**
72
- * In the Android environment, the layout information is not synchronized after the animation,
73
- * which results in the inability to correctly trigger element events.
74
- * Here, we utilize flexBasic to proactively trigger a re-layout
75
- */
68
+ // Set flexBasic after animation to trigger re-layout and reset layout information
76
69
  basic.value = '99.99%';
77
70
  }
78
71
  });
@@ -85,16 +78,14 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }) => {
85
78
  subscriptions.forEach(subscription => subscription.remove());
86
79
  };
87
80
  }, [keyboardAvoid]);
88
- return (<GestureDetector gesture={gesture}>
89
- <View style={style}>
90
- <Animated.View style={[
81
+ return (<View style={style} onTouchEnd={onTouchEnd}>
82
+ <Animated.View style={[
91
83
  contentContainerStyle,
92
84
  animatedStyle
93
85
  ]}>
94
- {children}
95
- </Animated.View>
96
- </View>
97
- </GestureDetector>);
86
+ {children}
87
+ </Animated.View>
88
+ </View>);
98
89
  };
99
90
  KeyboardAvoidingView.displayName = 'MpxKeyboardAvoidingView';
100
91
  export default KeyboardAvoidingView;
@@ -1,4 +1,4 @@
1
- import { forwardRef, useRef, useContext, useMemo, useState, useEffect } from 'react';
1
+ import { forwardRef, useRef, useContext, useMemo, useState } from 'react';
2
2
  import { warn, isFunction } from '@mpxjs/utils';
3
3
  import Portal from './mpx-portal/index';
4
4
  import { getCustomEvent } from './getInnerListeners';
@@ -74,17 +74,17 @@ const _WebView = forwardRef((props, ref) => {
74
74
  isNavigateBack.current = false;
75
75
  };
76
76
  const navigation = useNavigation();
77
- useEffect(() => {
78
- let beforeRemoveSubscription;
79
- if (__mpx_mode__ !== 'ios') {
80
- beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle);
81
- }
82
- return () => {
83
- if (isFunction(beforeRemoveSubscription)) {
84
- beforeRemoveSubscription();
85
- }
86
- };
87
- }, []);
77
+ // useEffect(() => {
78
+ // let beforeRemoveSubscription:any
79
+ // if (__mpx_mode__ !== 'ios') {
80
+ // beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle)
81
+ // }
82
+ // return () => {
83
+ // if (isFunction(beforeRemoveSubscription)) {
84
+ // beforeRemoveSubscription()
85
+ // }
86
+ // }
87
+ // }, [])
88
88
  useNodesRef(props, ref, webViewRef, {
89
89
  style: defaultWebViewStyle
90
90
  });
@@ -160,7 +160,7 @@ const _WebView = forwardRef((props, ref) => {
160
160
  { // case下不允许直接声明,包个块解决该问题
161
161
  const title = postData._documentTitle?.trim();
162
162
  if (title !== undefined) {
163
- navigation && navigation.setOptions({ title });
163
+ navigation && navigation.setPageConfig({ navigationBarTitleText: title });
164
164
  }
165
165
  }
166
166
  break;
@@ -1,7 +1,6 @@
1
- import React, { ReactNode, useContext, useEffect, useMemo } from 'react'
2
- import { DimensionValue, EmitterSubscription, Keyboard, Platform, View, ViewStyle } from 'react-native'
3
- import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing, runOnJS } from 'react-native-reanimated'
4
- import { GestureDetector, Gesture } from 'react-native-gesture-handler'
1
+ import React, { ReactNode, useContext, useEffect } from 'react'
2
+ import { DimensionValue, EmitterSubscription, Keyboard, View, ViewStyle } from 'react-native'
3
+ import Animated, { useSharedValue, useAnimatedStyle, withTiming, Easing } from 'react-native-reanimated'
5
4
  import { KeyboardAvoidContext } from './context'
6
5
  import { isIOS } from './utils'
7
6
 
@@ -19,25 +18,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
19
18
  const basic = useSharedValue('auto')
20
19
  const keyboardAvoid = useContext(KeyboardAvoidContext)
21
20
 
22
- const dismiss = () => {
23
- Keyboard.isVisible() && Keyboard.dismiss()
24
- }
25
-
26
- const gesture = useMemo(() => {
27
- return Gesture.Tap()
28
- .onEnd(() => {
29
- dismiss()
30
- }).runOnJS(true)
31
- }, [])
32
-
33
- const animatedStyle = useAnimatedStyle(() => {
34
- return Object.assign(
35
- {
36
- transform: [{ translateY: -offset.value }]
37
- },
38
- isIOS ? {} : { flexBasis: basic.value as DimensionValue }
39
- )
40
- })
21
+ const animatedStyle = useAnimatedStyle(() => ({
22
+ transform: [{ translateY: -offset.value }],
23
+ flexBasis: basic.value as DimensionValue
24
+ }))
41
25
 
42
26
  const resetKeyboard = () => {
43
27
  if (keyboardAvoid?.current) {
@@ -47,6 +31,10 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
47
31
  basic.value = 'auto'
48
32
  }
49
33
 
34
+ const onTouchEnd = () => {
35
+ Keyboard.isVisible() && Keyboard.dismiss()
36
+ }
37
+
50
38
  useEffect(() => {
51
39
  let subscriptions: EmitterSubscription[] = []
52
40
 
@@ -62,7 +50,12 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
62
50
  const aboveValue = -aboveOffset >= cursorSpacing ? 0 : aboveOffset + cursorSpacing
63
51
  const belowValue = Math.min(endCoordinates.height, aboveOffset + cursorSpacing)
64
52
  const value = aboveOffset > 0 ? belowValue : aboveValue
65
- offset.value = withTiming(value, { duration, easing })
53
+ offset.value = withTiming(value, { duration, easing }, (finished) => {
54
+ if (finished) {
55
+ // Set flexBasic after animation to trigger re-layout and reset layout information
56
+ basic.value = '99.99%'
57
+ }
58
+ })
66
59
  })
67
60
  })
68
61
  }),
@@ -82,11 +75,7 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
82
75
  const value = aboveOffset > 0 ? belowValue : aboveValue
83
76
  offset.value = withTiming(value, { duration, easing }, (finished) => {
84
77
  if (finished) {
85
- /**
86
- * In the Android environment, the layout information is not synchronized after the animation,
87
- * which results in the inability to correctly trigger element events.
88
- * Here, we utilize flexBasic to proactively trigger a re-layout
89
- */
78
+ // Set flexBasic after animation to trigger re-layout and reset layout information
90
79
  basic.value = '99.99%'
91
80
  }
92
81
  })
@@ -102,18 +91,16 @@ const KeyboardAvoidingView = ({ children, style, contentContainerStyle }: Keyboa
102
91
  }, [keyboardAvoid])
103
92
 
104
93
  return (
105
- <GestureDetector gesture={gesture}>
106
- <View style={style}>
107
- <Animated.View
108
- style={[
109
- contentContainerStyle,
110
- animatedStyle
111
- ]}
112
- >
113
- {children}
114
- </Animated.View>
115
- </View>
116
- </GestureDetector>
94
+ <View style={style} onTouchEnd={onTouchEnd}>
95
+ <Animated.View
96
+ style={[
97
+ contentContainerStyle,
98
+ animatedStyle
99
+ ]}
100
+ >
101
+ {children}
102
+ </Animated.View>
103
+ </View>
117
104
  )
118
105
  }
119
106
 
@@ -122,17 +122,17 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
122
122
 
123
123
  const navigation = useNavigation()
124
124
 
125
- useEffect(() => {
126
- let beforeRemoveSubscription:any
127
- if (__mpx_mode__ !== 'ios') {
128
- beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle)
129
- }
130
- return () => {
131
- if (isFunction(beforeRemoveSubscription)) {
132
- beforeRemoveSubscription()
133
- }
134
- }
135
- }, [])
125
+ // useEffect(() => {
126
+ // let beforeRemoveSubscription:any
127
+ // if (__mpx_mode__ !== 'ios') {
128
+ // beforeRemoveSubscription = navigation?.addListener?.('beforeRemove', beforeRemoveHandle)
129
+ // }
130
+ // return () => {
131
+ // if (isFunction(beforeRemoveSubscription)) {
132
+ // beforeRemoveSubscription()
133
+ // }
134
+ // }
135
+ // }, [])
136
136
 
137
137
  useNodesRef<WebView, WebViewProps>(props, ref, webViewRef, {
138
138
  style: defaultWebViewStyle
@@ -212,7 +212,7 @@ const _WebView = forwardRef<HandlerRef<WebView, WebViewProps>, WebViewProps>((pr
212
212
  { // case下不允许直接声明,包个块解决该问题
213
213
  const title = postData._documentTitle?.trim()
214
214
  if (title !== undefined) {
215
- navigation && navigation.setOptions({ title })
215
+ navigation && navigation.setPageConfig({ navigationBarTitleText: title })
216
216
  }
217
217
  }
218
218
  break
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/webpack-plugin",
3
- "version": "2.10.4-beta.2",
3
+ "version": "2.10.4-beta.4",
4
4
  "description": "mpx compile core",
5
5
  "keywords": [
6
6
  "mpx"