@momo-kits/foundation 0.157.5-beta.1 → 0.158.1-beta.1
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.
- package/Application/ModalScreen.tsx +25 -1
- package/Application/StackScreen.tsx +1 -1
- package/Popup/PopupPromotion.tsx +1 -1
- package/ViewBoundary/index.tsx +74 -0
- package/index.ts +1 -0
- package/package.json +1 -1
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
View,
|
|
12
12
|
} from 'react-native';
|
|
13
13
|
|
|
14
|
-
import { ApplicationContext } from '../Context';
|
|
14
|
+
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
15
15
|
import { Styles } from '../Consts';
|
|
16
16
|
import Navigation from './Navigation';
|
|
17
17
|
import { ModalParams } from './types';
|
|
@@ -27,6 +27,8 @@ const ModalScreen: React.FC<any> = props => {
|
|
|
27
27
|
|
|
28
28
|
const Modal: React.FC<ModalParams> = props => {
|
|
29
29
|
const { navigator } = useContext(ApplicationContext);
|
|
30
|
+
const context = useContext<any>(MiniAppContext);
|
|
31
|
+
const modalParams = useRef<any>(undefined);
|
|
30
32
|
const {
|
|
31
33
|
screen,
|
|
32
34
|
barrierDismissible,
|
|
@@ -48,6 +50,28 @@ const Modal: React.FC<ModalParams> = props => {
|
|
|
48
50
|
Container = ModalRN;
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
if (screen != null) {
|
|
54
|
+
const screenProps = screen?.()?.props || {};
|
|
55
|
+
modalParams.current = {
|
|
56
|
+
title: screenProps?.title || '',
|
|
57
|
+
description: screenProps?.description || '',
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
navigator?.maxApi?.getDataObserver?.('current_screen', (curScreen: any) => {
|
|
63
|
+
const item: any = {
|
|
64
|
+
screenName: curScreen?.screenName,
|
|
65
|
+
componentName: 'Modal',
|
|
66
|
+
...modalParams.current,
|
|
67
|
+
};
|
|
68
|
+
context?.autoTracking?.({
|
|
69
|
+
...context,
|
|
70
|
+
...item,
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
}, [context, navigator?.maxApi]);
|
|
74
|
+
|
|
51
75
|
useEffect(() => {
|
|
52
76
|
Animated.parallel([
|
|
53
77
|
Animated.timing(opacity, {
|
|
@@ -7,7 +7,7 @@ import { ApplicationContext, MiniAppContext, ScreenContext } from '../Context';
|
|
|
7
7
|
import { GridSystem } from '../Layout';
|
|
8
8
|
import { version } from '../package.json';
|
|
9
9
|
import { useAppState } from './utils';
|
|
10
|
-
import { TooltipPortalHost, TooltipPortalProvider } from './TooltipPortal
|
|
10
|
+
import { TooltipPortalHost, TooltipPortalProvider } from './TooltipPortal';
|
|
11
11
|
|
|
12
12
|
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
13
13
|
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -92,7 +92,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
92
92
|
|
|
93
93
|
const styles = StyleSheet.create({
|
|
94
94
|
container: {
|
|
95
|
-
aspectRatio: 0.
|
|
95
|
+
aspectRatio: 0.5625, // 9:16
|
|
96
96
|
width: '100%',
|
|
97
97
|
},
|
|
98
98
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { NativeModules, ViewStyle, StyleProp } from 'react-native';
|
|
3
|
+
import { MiniAppContext } from '../Context';
|
|
4
|
+
|
|
5
|
+
export interface ViewBoundaryProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
fallback?: React.ReactNode;
|
|
8
|
+
fallbackStyle?: StyleProp<ViewStyle>;
|
|
9
|
+
onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface ViewBoundaryState {
|
|
13
|
+
hasError: boolean;
|
|
14
|
+
error: Error | null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
class ViewBoundary extends React.Component<
|
|
18
|
+
ViewBoundaryProps,
|
|
19
|
+
ViewBoundaryState
|
|
20
|
+
> {
|
|
21
|
+
static contextType = MiniAppContext;
|
|
22
|
+
|
|
23
|
+
constructor(props: ViewBoundaryProps) {
|
|
24
|
+
super(props);
|
|
25
|
+
this.state = { hasError: false, error: null };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
static getDerivedStateFromError(error: Error): ViewBoundaryState {
|
|
29
|
+
return { hasError: true, error };
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
componentDidCatch(error: Error, errorInfo: React.ErrorInfo) {
|
|
33
|
+
this.props.onError?.(error, errorInfo);
|
|
34
|
+
|
|
35
|
+
const context = (this as any).context ?? {};
|
|
36
|
+
// check exist native module method onJSBoundaryCrash
|
|
37
|
+
const nativeMethod = NativeModules?.MiniAppModule?.onJSBoundaryCrash;
|
|
38
|
+
if (typeof nativeMethod === 'function') {
|
|
39
|
+
try {
|
|
40
|
+
nativeMethod({
|
|
41
|
+
hostId: context.hostId ?? '',
|
|
42
|
+
appId: context.appId ?? '',
|
|
43
|
+
code: context.code ?? '',
|
|
44
|
+
buildNumber: context.buildNumber ?? '',
|
|
45
|
+
tag: 'ViewBoundary',
|
|
46
|
+
error: {
|
|
47
|
+
errorName: error.name,
|
|
48
|
+
errorMessage: error.message,
|
|
49
|
+
componentStack: errorInfo?.componentStack?.substring(0, 500) ?? '',
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
console.info('[ViewBoundary] onJSBoundaryCrash success!');
|
|
53
|
+
} catch (_e) {
|
|
54
|
+
console.warn('[ViewBoundary] onJSBoundaryCrash failed:', _e);
|
|
55
|
+
}
|
|
56
|
+
} else {
|
|
57
|
+
console.warn(
|
|
58
|
+
'[ViewBoundary] onJSBoundaryCrash not available on this platform build',
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
render() {
|
|
64
|
+
if (this.state.hasError) {
|
|
65
|
+
if (this.props.fallback !== undefined) {
|
|
66
|
+
return this.props.fallback;
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
return this.props.children;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export { ViewBoundary };
|
package/index.ts
CHANGED