@momo-kits/foundation 0.157.5-beta.1 → 0.158.1-beta.2
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 +17 -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 +34 -34
|
@@ -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,13 +27,29 @@ 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);
|
|
30
31
|
const {
|
|
31
32
|
screen,
|
|
32
33
|
barrierDismissible,
|
|
33
34
|
modalStyle,
|
|
34
35
|
useNativeModal = false,
|
|
36
|
+
description,
|
|
37
|
+
title,
|
|
35
38
|
} = props.route.params;
|
|
36
39
|
const Component = useRef(screen).current;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Fire auto_popup_displayed tracking event on mount
|
|
43
|
+
*/
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
context.autoTracking({
|
|
46
|
+
componentName: 'Modal',
|
|
47
|
+
description,
|
|
48
|
+
title,
|
|
49
|
+
});
|
|
50
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
51
|
+
}, []);
|
|
52
|
+
|
|
37
53
|
const opacity = useRef(new Animated.Value(0)).current;
|
|
38
54
|
const scale = useRef(new Animated.Value(0.8)).current;
|
|
39
55
|
|
|
@@ -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
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
2
|
+
"name": "@momo-kits/foundation",
|
|
3
|
+
"version": "0.158.1-beta.2",
|
|
4
|
+
"description": "React Native Component Kits",
|
|
5
|
+
"main": "index.ts",
|
|
6
|
+
"scripts": {},
|
|
7
|
+
"keywords": [
|
|
8
|
+
"@momo-kits/foundation"
|
|
9
|
+
],
|
|
10
|
+
"dependencies": {
|
|
11
|
+
"react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
|
|
12
|
+
"@react-navigation/bottom-tabs": "7.4.2",
|
|
13
|
+
"@react-navigation/core": "7.12.1",
|
|
14
|
+
"@react-navigation/elements": "2.5.2",
|
|
15
|
+
"@react-navigation/native": "7.1.14",
|
|
16
|
+
"@react-navigation/routers": "7.4.1",
|
|
17
|
+
"@react-navigation/stack": "7.4.2",
|
|
18
|
+
"react-native-gesture-handler": "2.27.1",
|
|
19
|
+
"react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
|
|
20
|
+
"react-native-reanimated": "4.1.0",
|
|
21
|
+
"react-native-safe-area-context": "5.5.2",
|
|
22
|
+
"@shopify/flash-list": "2.1.0",
|
|
23
|
+
"lottie-react-native": "7.2.4"
|
|
24
|
+
},
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react-native": "*"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/color": "3.0.6"
|
|
30
|
+
},
|
|
31
|
+
"publishConfig": {
|
|
32
|
+
"registry": "https://registry.npmjs.org/"
|
|
33
|
+
},
|
|
34
|
+
"license": "MoMo"
|
|
35
|
+
}
|