@momo-kits/foundation 0.157.3-beta.25 → 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.
@@ -29,7 +29,6 @@ import Animated, {
29
29
  withTiming,
30
30
  } from 'react-native-reanimated';
31
31
  import layoutStyles from '../Layout/styles';
32
- import { version } from '../package.json';
33
32
 
34
33
  const BottomSheet: React.FC<BottomSheetParams> = props => {
35
34
  const { theme, navigator } = useContext(ApplicationContext);
@@ -55,40 +54,10 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
55
54
  useDivider = true,
56
55
  footerComponent,
57
56
  leftOptions,
58
- screen_name,
59
- componentName,
60
- componentLabel,
61
- description,
62
- title,
63
- } = props as BottomSheetParams;
57
+ }: BottomSheetParams = props.route.params;
64
58
 
65
59
  const translateY = useSharedValue(heightDevice);
66
60
 
67
- /**
68
- * Fire auto_popup_displayed tracking event on mount
69
- */
70
- useEffect(() => {
71
- if (typeof context?.autoTracking !== 'function') {
72
- return;
73
- }
74
-
75
- context.autoTracking({
76
- ...context,
77
- eventName: 'auto_popup_displayed',
78
- screen_name: screen_name ?? context.screenName,
79
- miniapp_version: context.miniapp_version,
80
- tracking_source: 1,
81
- app_id: context.appId,
82
- feature_code: context.feature_code,
83
- kits_version: version,
84
- component_name: componentName,
85
- component_label: componentLabel,
86
- description,
87
- title,
88
- });
89
- // eslint-disable-next-line react-hooks/exhaustive-deps
90
- }, []);
91
-
92
61
  const openAnimation = useCallback(() => {
93
62
  translateY.value = withTiming(0, {
94
63
  duration: 350,
@@ -17,7 +17,6 @@ import Navigation from './Navigation';
17
17
  import { ModalParams } from './types';
18
18
  import BottomSheet from './BottomSheet';
19
19
  import { runOnJS } from 'react-native-reanimated';
20
- import { version } from '../package.json';
21
20
 
22
21
  const ModalScreen: React.FC<any> = props => {
23
22
  if (props.route?.params?.isBottomSheet) {
@@ -29,29 +28,14 @@ const ModalScreen: React.FC<any> = props => {
29
28
  const Modal: React.FC<ModalParams> = props => {
30
29
  const { navigator } = useContext(ApplicationContext);
31
30
  const context = useContext<any>(MiniAppContext);
31
+ const modalParams = useRef<any>(undefined);
32
32
  const {
33
33
  screen,
34
34
  barrierDismissible,
35
35
  modalStyle,
36
36
  useNativeModal = false,
37
- description,
38
- title,
39
37
  } = props.route.params;
40
38
  const Component = useRef(screen).current;
41
-
42
- /**
43
- * Fire auto_popup_displayed tracking event on mount
44
- */
45
- useEffect(() => {
46
- context.autoTracking({
47
- eventName: 'auto_popup_displayed',
48
- componentName: 'Modal',
49
- description,
50
- title,
51
- });
52
- // eslint-disable-next-line react-hooks/exhaustive-deps
53
- }, []);
54
-
55
39
  const opacity = useRef(new Animated.Value(0)).current;
56
40
  const scale = useRef(new Animated.Value(0.8)).current;
57
41
 
@@ -66,6 +50,28 @@ const Modal: React.FC<ModalParams> = props => {
66
50
  Container = ModalRN;
67
51
  }
68
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
+
69
75
  useEffect(() => {
70
76
  Animated.parallel([
71
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.tsx';
10
+ import { TooltipPortalHost, TooltipPortalProvider } from './TooltipPortal';
11
11
 
12
12
  const runAfterInteractions = InteractionManager.runAfterInteractions;
13
13
 
@@ -185,35 +185,7 @@ export type ScreenTrackingParams = {
185
185
  value2?: any;
186
186
  };
187
187
 
188
- export type ModalTrackingProps = {
189
- /**
190
- * Optional. Screen name for auto_popup_displayed tracking event.
191
- * Falls back to the current screen's name from context if not provided.
192
- */
193
- screen_name?: string;
194
-
195
- /**
196
- * Optional. Component name for auto_popup_displayed tracking event.
197
- */
198
- componentName?: string;
199
-
200
- /**
201
- * Optional. Component label for auto_popup_displayed tracking event.
202
- */
203
- componentLabel?: string;
204
-
205
- /**
206
- * Optional. Description for auto_popup_displayed tracking event.
207
- */
208
- description?: string;
209
-
210
- /**
211
- * Optional. Title for auto_popup_displayed tracking event.
212
- */
213
- title?: string;
214
- };
215
-
216
- export type ModalParams = ModalTrackingProps & {
188
+ export type ModalParams = {
217
189
  [key: string]: any;
218
190
  screen: React.ComponentType;
219
191
  onDismiss?: () => void;
@@ -222,7 +194,7 @@ export type ModalParams = ModalTrackingProps & {
222
194
  useNativeModal?: boolean;
223
195
  };
224
196
 
225
- export type BottomSheetParams = ModalTrackingProps & {
197
+ export type BottomSheetParams = {
226
198
  [key: string]: any;
227
199
  screen: React.ComponentType;
228
200
  options: {
@@ -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
@@ -47,4 +47,5 @@ export * from './Badge';
47
47
  export * from './Badge/types';
48
48
  export * from './FoundationList';
49
49
  export * from './FoundationList/types';
50
+ export * from './ViewBoundary';
50
51
  export { TouchableOpacity };
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@momo-kits/foundation",
3
- "version": "0.157.3-beta.25",
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
- }
2
+ "name": "@momo-kits/foundation",
3
+ "version": "0.158.1-beta.1",
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
+ }