@momo-kits/foundation 0.103.2-rc.13 → 0.103.2-rc.14

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.
@@ -10,7 +10,6 @@ import {
10
10
  Alert,
11
11
  Animated,
12
12
  BackHandler,
13
- DeviceEventEmitter,
14
13
  Dimensions,
15
14
  StatusBar,
16
15
  StyleSheet,
@@ -31,11 +30,10 @@ import {
31
30
  import {scaleSize, Text} from '../Text';
32
31
  import {Icon} from '../Icon';
33
32
  import {PopupNotify} from '../Popup';
34
- import {Badge, BadgeDot} from '../Badge';
33
+ import {Badge, BadgeDot, BadgeDotAnimation} from '../Badge';
35
34
  import {HeaderType} from '../Layout/types';
36
35
  import Navigation from './Navigation';
37
36
  import {InputRef, InputSearch, InputSearchProps} from '../Input';
38
- import {BadgeDotAnimation} from '../Badge';
39
37
 
40
38
  const SCREEN_PADDING = 12;
41
39
  const BACK_WIDTH = 28;
@@ -151,8 +149,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
151
149
  const canGoBack = navigator?.ref?.current?.canGoBack?.();
152
150
  const currentRoute = navigator?.ref?.current?.getCurrentRoute?.();
153
151
  const params = {
154
- appId: context.appId,
155
- code: context.code,
152
+ ...context,
156
153
  screen_name: currentRoute?.params?.screen?.name ?? currentRoute?.name,
157
154
  trigger_id: '111154000000000000',
158
155
  icon_name: 'back',
@@ -168,9 +165,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
168
165
  } else if (navigator?.maxApi) {
169
166
  navigator?.maxApi?.dismiss?.(navigator?.dismissData);
170
167
  } else {
171
- const currentTime = new Date().getTime();
172
- const requestId = `navigationBackPress#${currentTime}`;
173
- DeviceEventEmitter.emit('dismiss', {requestId});
168
+ (global as any)?.miniAppApi?.dispatch?.('dismiss', context);
174
169
  }
175
170
  onPressLeftHeader?.();
176
171
  };
@@ -341,7 +336,7 @@ const HeaderToolkitAction: React.FC<any> = ({
341
336
  preventClose,
342
337
  }) => {
343
338
  const {navigator} = useContext(ApplicationContext);
344
- const miniContext = useContext<any>(MiniAppContext);
339
+ const context = useContext<any>(MiniAppContext);
345
340
  const [toolConfig, setToolConfig] = useState<any>();
346
341
  const {onAction} = toolConfig ?? {};
347
342
 
@@ -351,7 +346,7 @@ const HeaderToolkitAction: React.FC<any> = ({
351
346
  }
352
347
 
353
348
  useEffect(() => {
354
- if (miniContext?.toolkitConfig?.hidden === false) {
349
+ if (context?.toolkitConfig?.hidden === false) {
355
350
  if (navigator?.toolkitConfig) {
356
351
  setToolConfig(navigator?.toolkitConfig);
357
352
  } else {
@@ -114,23 +114,21 @@ const StackScreen: React.FC<ScreenParams> = props => {
114
114
  */
115
115
  const onScreenLoad = () => {
116
116
  if (!tracking.current?.releaseLoad) {
117
- if (tracking.current.timeLoad === 0) {
118
- tracking.current.timeLoad =
119
- tracking.current.endTime - tracking.current.startTime;
117
+ let timeLoad = tracking.current.timeLoad;
118
+ if (timeLoad === 0) {
119
+ timeLoad = tracking.current.endTime - tracking.current.startTime;
120
120
  }
121
121
 
122
122
  context.autoTracking?.({
123
- appId: context.appId,
124
- code: context.code,
125
- buildNumber: context.buildNumber,
123
+ ...context,
126
124
  screenName,
127
125
  componentName: 'Screen',
128
126
  state: 'load',
129
- duration: tracking.current.timeLoad,
127
+ duration: timeLoad,
130
128
  });
131
129
  navigator?.maxApi?.stopTrace?.(
132
130
  tracking.current.traceIdLoad,
133
- {value: tracking.current.timeLoad / 1000},
131
+ {value: timeLoad / 1000},
134
132
  null
135
133
  );
136
134
  tracking.current.releaseLoad = true;
@@ -140,10 +138,10 @@ const StackScreen: React.FC<ScreenParams> = props => {
140
138
  */
141
139
  navigator?.maxApi?.showToastDebug?.({
142
140
  appId: context.appId,
143
- message: `${screenName} screen_load_time ${tracking.current.timeLoad}`,
141
+ message: `${screenName} screen_load_time ${timeLoad}`,
144
142
  type: 'ERROR',
145
143
  });
146
- if (tracking.current.timeLoad <= 0 && context.enableAutoId) {
144
+ if (timeLoad <= 0 && context.enableAutoId) {
147
145
  Alert.alert(screenName, "Can't get screen load time");
148
146
  }
149
147
  }
@@ -154,22 +152,20 @@ const StackScreen: React.FC<ScreenParams> = props => {
154
152
  */
155
153
  const onScreenInteraction = () => {
156
154
  if (!tracking.current?.releaseInteraction) {
157
- if (tracking.current.timeLoad === 0) {
158
- tracking.current.timeLoad =
159
- tracking.current.endTime - tracking.current.startTime;
155
+ let timeLoad = tracking.current.timeLoad;
156
+ if (timeLoad === 0) {
157
+ timeLoad = tracking.current.endTime - tracking.current.startTime;
160
158
  }
161
159
  if (tracking.current.timeInteraction === 0) {
162
- tracking.current.timeInteraction = tracking.current.timeLoad;
160
+ tracking.current.timeInteraction = timeLoad;
163
161
  }
164
162
 
165
163
  context.autoTracking?.({
166
- appId: context.appId,
167
- code: context.code,
168
- buildNumber: context.buildNumber,
164
+ ...context,
169
165
  screenName,
170
166
  componentName: 'Screen',
171
167
  state: 'interaction',
172
- duration: tracking.current.timeInteraction - tracking.current.timeLoad,
168
+ duration: tracking.current.timeInteraction - timeLoad,
173
169
  totalDuration: tracking.current.timeInteraction,
174
170
  });
175
171
  navigator?.maxApi?.stopTrace?.(
@@ -198,9 +194,7 @@ const StackScreen: React.FC<ScreenParams> = props => {
198
194
  */
199
195
  const onScreenNavigated = (preScreenName: string) => {
200
196
  context.autoTracking?.({
201
- appId: context.appId,
202
- code: context.code,
203
- buildNumber: context.buildNumber,
197
+ ...context,
204
198
  preScreenName,
205
199
  screenName,
206
200
  componentName: 'Screen',
@@ -231,9 +225,9 @@ const StackScreen: React.FC<ScreenParams> = props => {
231
225
  Date.now() - tracking.current.startTime;
232
226
  });
233
227
  tracking.current.timeoutLoad = setTimeout(() => {
228
+ const time = tracking.current.endTime - tracking.current.startTime;
234
229
  if (tracking.current.timeLoad === 0) {
235
- tracking.current.timeLoad =
236
- tracking.current.endTime - tracking.current.startTime;
230
+ tracking.current.timeLoad = time;
237
231
  }
238
232
  onScreenLoad();
239
233
  onScreenInteraction();
@@ -40,8 +40,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
40
40
  screen_name = routes[routesLength - 2]?.params?.screen?.name;
41
41
  }
42
42
  const tracking = {
43
- appId: context.appId,
44
- code: context.code,
43
+ ...context,
45
44
  screen_name,
46
45
  component_type: 'popup',
47
46
  component_name: id,
@@ -26,8 +26,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
26
26
  screen_name = routes[routesLength - 2]?.params?.screen?.name;
27
27
  }
28
28
  const tracking = {
29
- appId: context.appId,
30
- code: context.code,
29
+ ...context,
31
30
  screen_name,
32
31
  component_type: 'popup',
33
32
  component_name: id,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.103.2-rc.13",
3
+ "version": "0.103.2-rc.14",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},