@momo-kits/foundation 0.169.16-beta.4 → 0.169.16-beta.6

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.
Files changed (53) hide show
  1. package/Application/BottomSheet.tsx +2 -2
  2. package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
  3. package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
  4. package/Application/BottomTab/Legacy/TabScreen.tsx +16 -22
  5. package/Application/BottomTab/Legacy/hooks.ts +1 -1
  6. package/Application/BottomTab/Legacy/index.tsx +5 -1
  7. package/Application/BottomTab/TabBarIcon.tsx +1 -1
  8. package/Application/BottomTab/TabScreen.tsx +12 -22
  9. package/Application/BottomTab/index.tsx +1 -1
  10. package/Application/Components/HeaderLeft.tsx +11 -7
  11. package/Application/Components/HeaderRight.styles.ts +5 -1
  12. package/Application/Components/HeaderRight.tsx +7 -21
  13. package/Application/Components/SearchHeader.tsx +2 -2
  14. package/Application/Components/SwipeBackHaptic.tsx +1 -1
  15. package/Application/Components/useHeaderRightWidth.ts +2 -2
  16. package/Application/Components/useToolkitActions.tsx +34 -64
  17. package/Application/KitsBindingProvider.tsx +22 -0
  18. package/Application/KitsHost.ts +182 -0
  19. package/Application/ModalScreen.tsx +4 -4
  20. package/Application/NavigationContainer.tsx +22 -18
  21. package/Application/Navigator.ts +7 -2
  22. package/Application/StackScreen.tracking.ts +22 -12
  23. package/Application/StackScreen.tsx +26 -34
  24. package/Application/TooltipPortal.tsx +3 -3
  25. package/Application/WidgetContainer.tsx +83 -77
  26. package/Application/__tests__/KitsHost.test.ts +76 -0
  27. package/Application/headerLayout.ts +6 -13
  28. package/Application/hooks.ts +16 -1
  29. package/Application/index.ts +4 -0
  30. package/Application/navigationOptions.tsx +5 -12
  31. package/Application/types.binding.ts +134 -0
  32. package/Application/types.ts +14 -3
  33. package/Button/index.tsx +2 -2
  34. package/Divider/DashDivider.tsx +2 -2
  35. package/Divider/index.tsx +3 -3
  36. package/FoundationList/index.tsx +1 -1
  37. package/Icon/types.ts +1 -2
  38. package/Image/index.tsx +62 -7
  39. package/Image/styles.ts +2 -0
  40. package/Image/types.ts +9 -1
  41. package/Input/Input.tsx +2 -2
  42. package/Input/InputMoney.tsx +7 -2
  43. package/Input/InputMoneyView.tsx +2 -2
  44. package/Input/InputOTP.tsx +2 -2
  45. package/Input/InputPhoneNumber.tsx +2 -2
  46. package/Input/InputSearch.tsx +2 -2
  47. package/Input/InputTextArea.tsx +2 -2
  48. package/Input/SearchTextTyping.tsx +2 -2
  49. package/Input/SystemTextInput.tsx +2 -1
  50. package/Input/TextTyping.tsx +7 -2
  51. package/Layout/screenHeader.tsx +15 -17
  52. package/Pagination/types.ts +6 -2
  53. package/package.json +28 -26
@@ -0,0 +1,182 @@
1
+ import type {
2
+ KitsBinding,
3
+ KitsRequest,
4
+ KitsSubscription,
5
+ ResolvedKitsBinding,
6
+ } from './types.binding';
7
+
8
+ type BindingMethod = keyof KitsBinding;
9
+
10
+ const NO_REQUEST: KitsRequest = { cancel: () => {} };
11
+ const NO_SUBSCRIPTION: KitsSubscription = { remove: () => {} };
12
+
13
+ const NO_OP_BINDING: ResolvedKitsBinding = {
14
+ dismiss: () => {},
15
+ trackEvent: () => {},
16
+ getLanguage: () => NO_REQUEST,
17
+ vibrateLight: () => {},
18
+ checkFavorite: () => NO_REQUEST,
19
+ toggleFavorite: () => NO_REQUEST,
20
+ showToolkit: () => NO_REQUEST,
21
+ showHelpCenter: () => NO_REQUEST,
22
+ logError: () => {},
23
+ observeConfig: () => NO_SUBSCRIPTION,
24
+ observeFavorites: () => NO_SUBSCRIPTION,
25
+ getCurrentScreen: () => NO_REQUEST,
26
+ setCurrentScreen: () => {},
27
+ onFocusApp: () => NO_SUBSCRIPTION,
28
+ startScreenTrace: () => NO_REQUEST,
29
+ stopTrace: () => {},
30
+ showToastDebug: () => {},
31
+ showNoticePopup: () => {},
32
+ openWeb: () => {},
33
+ startFeatureCode: () => {},
34
+ };
35
+
36
+ // Resolved bindings delegate to the host, so one installed as the host would loop.
37
+ const resolvedBindings = new WeakSet<KitsBinding>();
38
+ let installed: KitsBinding | undefined;
39
+
40
+ /**
41
+ * The host app installs its binding here once; containers use it unless a caller
42
+ * passes or provides another. Until then `binding` does nothing, never throws.
43
+ */
44
+ const KitsHost = {
45
+ get binding(): KitsBinding {
46
+ return installed ?? NO_OP_BINDING;
47
+ },
48
+ /** The last install wins. The kit borrows the binding and never closes it. */
49
+ install(binding: KitsBinding) {
50
+ installed = binding;
51
+ },
52
+ uninstall() {
53
+ installed = undefined;
54
+ },
55
+ };
56
+
57
+ /**
58
+ * Object that implements `method`, looked up at call time: `binding`, else the
59
+ * installed host binding unless that is `binding` itself, else the no-op.
60
+ */
61
+ const getMethodOwner = (
62
+ binding: KitsBinding | undefined,
63
+ method: BindingMethod,
64
+ ): KitsBinding => {
65
+ if (typeof binding?.[method] === 'function') {
66
+ return binding;
67
+ }
68
+ const host = KitsHost.binding;
69
+ const isOtherHost = host !== binding && !resolvedBindings.has(host);
70
+ if (isOtherHost && typeof host[method] === 'function') {
71
+ return host;
72
+ }
73
+ return NO_OP_BINDING;
74
+ };
75
+
76
+ /**
77
+ * Starts a host request whose callback is dropped once the kit cancels it, so a
78
+ * late host answer never reaches an unmounted screen. `cancel` is idempotent.
79
+ */
80
+ const startRequest = <T>(
81
+ start: (callback: (value: T) => void) => KitsRequest | undefined,
82
+ callback: (value: T) => void,
83
+ ): KitsRequest => {
84
+ let isActive = true;
85
+ const request = start(value => {
86
+ if (isActive) {
87
+ callback(value);
88
+ }
89
+ });
90
+ return {
91
+ cancel: () => {
92
+ if (!isActive) {
93
+ return;
94
+ }
95
+ isActive = false;
96
+ request?.cancel();
97
+ },
98
+ };
99
+ };
100
+
101
+ /** Every method of `binding`, each falling back to `KitsHost` when missing. */
102
+ const resolveKitsBinding = (binding?: KitsBinding): ResolvedKitsBinding => {
103
+ /** Owner of `method` for this binding. */
104
+ const owner = (method: BindingMethod) => getMethodOwner(binding, method);
105
+ const resolved: ResolvedKitsBinding = {
106
+ dismiss: (target, data) => owner('dismiss').dismiss?.(target, data),
107
+ trackEvent: (eventName, attributes) => {
108
+ owner('trackEvent').trackEvent?.(eventName, attributes);
109
+ },
110
+ getLanguage: callback => {
111
+ return startRequest(
112
+ cb => owner('getLanguage').getLanguage?.(cb),
113
+ callback,
114
+ );
115
+ },
116
+ vibrateLight: () => owner('vibrateLight').vibrateLight?.(),
117
+ checkFavorite: (appCode, callback) => {
118
+ return startRequest(
119
+ cb => owner('checkFavorite').checkFavorite?.(appCode, cb),
120
+ callback,
121
+ );
122
+ },
123
+ toggleFavorite: (appCode, callback) => {
124
+ return startRequest(
125
+ cb => owner('toggleFavorite').toggleFavorite?.(appCode, cb),
126
+ callback,
127
+ );
128
+ },
129
+ showToolkit: (request, onAction) => {
130
+ return startRequest(
131
+ cb => owner('showToolkit').showToolkit?.(request, cb),
132
+ onAction,
133
+ );
134
+ },
135
+ showHelpCenter: request => {
136
+ return owner('showHelpCenter').showHelpCenter?.(request) ?? NO_REQUEST;
137
+ },
138
+ logError: message => owner('logError').logError?.(message),
139
+ observeConfig: (key, callback) => {
140
+ const host = owner('observeConfig');
141
+ return host.observeConfig?.(key, callback) ?? NO_SUBSCRIPTION;
142
+ },
143
+ observeFavorites: callback => {
144
+ const host = owner('observeFavorites');
145
+ return host.observeFavorites?.(callback) ?? NO_SUBSCRIPTION;
146
+ },
147
+ getCurrentScreen: callback => {
148
+ return startRequest(
149
+ cb => owner('getCurrentScreen').getCurrentScreen?.(cb),
150
+ callback,
151
+ );
152
+ },
153
+ setCurrentScreen: screen => {
154
+ owner('setCurrentScreen').setCurrentScreen?.(screen);
155
+ },
156
+ onFocusApp: listener => {
157
+ return owner('onFocusApp').onFocusApp?.(listener) ?? NO_SUBSCRIPTION;
158
+ },
159
+ startScreenTrace: (kind, screenName, context, callback) => {
160
+ const host = owner('startScreenTrace');
161
+ return startRequest(
162
+ cb => host.startScreenTrace?.(kind, screenName, context, cb),
163
+ callback,
164
+ );
165
+ },
166
+ stopTrace: (traceId, value) => {
167
+ owner('stopTrace').stopTrace?.(traceId, value);
168
+ },
169
+ showToastDebug: toast => owner('showToastDebug').showToastDebug?.(toast),
170
+ showNoticePopup: popup => {
171
+ owner('showNoticePopup').showNoticePopup?.(popup);
172
+ },
173
+ openWeb: request => owner('openWeb').openWeb?.(request),
174
+ startFeatureCode: (featureCode, params) => {
175
+ owner('startFeatureCode').startFeatureCode?.(featureCode, params);
176
+ },
177
+ };
178
+ resolvedBindings.add(resolved);
179
+ return resolved;
180
+ };
181
+
182
+ export { KitsHost, resolveKitsBinding };
@@ -66,7 +66,7 @@ const Modal: React.FC<ModalParams> = props => {
66
66
 
67
67
  // Auto-tracks the popup as displayed on the current screen.
68
68
  useEffect(() => {
69
- navigator?.maxApi?.getDataObserver?.('current_screen', (curScreen: any) => {
69
+ navigator?.binding.getCurrentScreen(curScreen => {
70
70
  context.autoTracking({
71
71
  ...context,
72
72
  screenName: curScreen?.screenName,
@@ -75,7 +75,7 @@ const Modal: React.FC<ModalParams> = props => {
75
75
  title,
76
76
  });
77
77
  });
78
- }, [context, description, navigator?.maxApi, title]);
78
+ }, [context, description, navigator?.binding, title]);
79
79
 
80
80
  const opacity = useRef(new Animated.Value(0)).current;
81
81
  const scale = useRef(new Animated.Value(INITIAL_SCALE)).current;
@@ -161,7 +161,7 @@ const Modal: React.FC<ModalParams> = props => {
161
161
  transparent
162
162
  visible={true}
163
163
  onRequestClose={handleDismiss}
164
- style={StyleSheet.absoluteFillObject}
164
+ style={StyleSheet.absoluteFill}
165
165
  isModalKit={true}
166
166
  supportedOrientations={isDuo ? DUO_ORIENTATIONS : undefined}
167
167
  >
@@ -170,7 +170,7 @@ const Modal: React.FC<ModalParams> = props => {
170
170
  behavior={Platform.OS === 'ios' ? 'padding' : undefined}
171
171
  >
172
172
  <Pressable
173
- style={StyleSheet.absoluteFillObject}
173
+ style={StyleSheet.absoluteFill}
174
174
  onPress={() => handleDismiss(undefined, barrierDismissible)}
175
175
  >
176
176
  <Animated.View style={[styles.overlayContent, scrimStyle]} />
@@ -18,7 +18,7 @@ import ModalScreen from './ModalScreen';
18
18
  import Navigator from './Navigator';
19
19
  import { getModalOptions, getStackOptions } from './navigationOptions';
20
20
  import { isWhiteListDesignSystem } from './utils';
21
- import { useNativeCanGoBack } from './hooks';
21
+ import { useKitsBinding, useNativeCanGoBack } from './hooks';
22
22
  import { NavigationContainerProps } from './types';
23
23
  import { ApplicationContext, MiniAppContext } from '../Context';
24
24
  import Localize from './Localize';
@@ -30,18 +30,19 @@ import { HeaderBackground } from './Components/HeaderBackground';
30
30
  import { useScreenLayout } from '../Layout';
31
31
  import { getHeaderRowOptions } from '../Layout/utils';
32
32
  import { ReservedRegionsProvider } from '../Layout/ReservedRegions';
33
+ import { KitsBindingContext } from './KitsBindingProvider';
33
34
 
34
35
  const Stack = createStackNavigator();
35
36
 
36
37
  /**
37
- * Root of a mini app: safe area, reserved regions and the merged mini app
38
- * context around the kit's navigator.
38
+ * Root of a mini app: safe area, reserved regions, the merged mini app context
39
+ * and its host binding around the kit's navigator.
39
40
  */
40
41
  const NavigationContainer: React.FC<NavigationContainerProps> = ({
41
42
  screen,
42
43
  theme = defaultTheme,
43
44
  options,
44
- maxApi,
45
+ binding,
45
46
  initialParams,
46
47
  localize = new Localize({ vi: {}, en: {} }),
47
48
  features = {
@@ -53,13 +54,14 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
53
54
  }) => {
54
55
  const context = useContext<any>(MiniAppContext);
55
56
  const [currentContext, setCurrentContext] = useState<any>({});
57
+ const { source, resolved } = useKitsBinding(binding);
56
58
 
57
59
  useEffect(() => {
58
- const sub = maxApi?.observer?.('font_scale_config', (data: any) => {
60
+ const sub = resolved.observeConfig('font_scale_config', data => {
59
61
  setCurrentContext((prev: any) => ({ ...prev, fontScale: data }));
60
62
  });
61
- return () => sub?.remove?.();
62
- }, [maxApi]);
63
+ return () => sub.remove();
64
+ }, [resolved]);
63
65
 
64
66
  const mergedContext = {
65
67
  ...context,
@@ -81,15 +83,17 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
81
83
  >
82
84
  <ReservedRegionsProvider>
83
85
  <MiniAppContext.Provider value={mergedContext}>
84
- <Navigation
85
- screen={screen}
86
- theme={theme}
87
- options={options}
88
- maxApi={maxApi}
89
- setCurrentContext={setCurrentContext}
90
- initialParams={initialParams}
91
- localize={localize}
92
- />
86
+ <KitsBindingContext.Provider value={source}>
87
+ <Navigation
88
+ screen={screen}
89
+ theme={theme}
90
+ options={options}
91
+ binding={resolved}
92
+ setCurrentContext={setCurrentContext}
93
+ initialParams={initialParams}
94
+ localize={localize}
95
+ />
96
+ </KitsBindingContext.Provider>
93
97
  </MiniAppContext.Provider>
94
98
  </ReservedRegionsProvider>
95
99
  </SafeAreaProvider>
@@ -104,7 +108,7 @@ const Navigation: React.FC<any> = ({
104
108
  screen,
105
109
  theme = defaultTheme,
106
110
  options,
107
- maxApi,
111
+ binding,
108
112
  initialParams,
109
113
  setCurrentContext,
110
114
  localize = new Localize({ vi: {}, en: {} }),
@@ -131,7 +135,7 @@ const Navigation: React.FC<any> = ({
131
135
  headerGradient = context?.designSystemConfig?.config?.headerGradient;
132
136
  }
133
137
 
134
- navigator.current.maxApi = maxApi;
138
+ navigator.current.binding = binding;
135
139
 
136
140
  /** Text for a localization key, or the current-language side of `{ vi, en }`. */
137
141
  const translate = (data?: string | { vi: string; en: string }) => {
@@ -1,5 +1,9 @@
1
1
  import {CommonActions, StackActions} from '@react-navigation/native';
2
2
  import {BottomSheetParams, ModalParams, ScreenParams} from './types';
3
+ import { resolveKitsBinding } from './KitsHost';
4
+ import type { ResolvedKitsBinding } from './types.binding';
5
+
6
+ const HOST_BINDING = resolveKitsBinding();
3
7
 
4
8
  /**
5
9
  * Imperative navigation API exposed to features through `ApplicationContext`.
@@ -9,7 +13,8 @@ class Navigator {
9
13
  ref?: any;
10
14
  isReady?: any;
11
15
  isWidget?: any;
12
- maxApi?: any;
16
+ /** Host services; the container replaces this `KitsHost` default with its own. */
17
+ binding: ResolvedKitsBinding = HOST_BINDING;
13
18
  dismissData?: any;
14
19
 
15
20
  constructor(navigation: any, isReady: any, isWidget = false) {
@@ -121,7 +126,7 @@ class Navigator {
121
126
  }
122
127
  };
123
128
 
124
- /** Sets the payload the header passes to `maxApi.dismiss` on close. */
129
+ /** Sets the payload the header passes to `binding.dismiss` on close. */
125
130
  setDismissData = (data: any) => {
126
131
  this.dismissData = data;
127
132
  };
@@ -1,13 +1,27 @@
1
1
  import { Alert } from 'react-native';
2
2
  import { version } from '../package.json';
3
+ import type { NavigatorProps } from './types';
4
+
5
+ const MS_PER_SECOND = 1000;
3
6
 
4
7
  type ScreenTrackingDeps = {
5
8
  tracking: { current: any };
6
9
  context: any;
7
- navigator: any;
10
+ navigator?: NavigatorProps;
8
11
  screenName: string;
9
12
  };
10
13
 
14
+ /** Ends a host performance trace; skipped when the host never returned an id. */
15
+ const stopTrace = (
16
+ navigator: NavigatorProps | undefined,
17
+ traceId: string | undefined,
18
+ durationMs: number,
19
+ ) => {
20
+ if (traceId) {
21
+ navigator?.binding.stopTrace(traceId, durationMs / MS_PER_SECOND);
22
+ }
23
+ };
24
+
11
25
  /**
12
26
  * Auto-tracking reporters of a stack screen. Each event fires at most once per
13
27
  * screen, guarded by the `release*` flags on `tracking.current`.
@@ -37,14 +51,10 @@ export const createScreenTracking = ({
37
51
  version: version,
38
52
  lastElement: tracking.current.lastElement,
39
53
  });
40
- navigator?.maxApi?.stopTrace?.(
41
- tracking.current.traceIdLoad,
42
- { value: timeLoad / 1000 },
43
- null,
44
- );
54
+ stopTrace(navigator, tracking.current.traceIdLoad, timeLoad);
45
55
  tracking.current.releaseLoad = true;
46
56
 
47
- navigator?.maxApi?.showToastDebug?.({
57
+ navigator?.binding.showToastDebug({
48
58
  appId: context.appId,
49
59
  message: `${screenName} screen_load_time ${timeLoad}`,
50
60
  type: 'ERROR',
@@ -80,14 +90,14 @@ export const createScreenTracking = ({
80
90
  params: tracking.current.params,
81
91
  version: version,
82
92
  });
83
- navigator?.maxApi?.stopTrace?.(
93
+ stopTrace(
94
+ navigator,
84
95
  tracking.current.traceIdInteraction,
85
- { value: tracking.current.timeInteraction / 1000 },
86
- null,
96
+ tracking.current.timeInteraction,
87
97
  );
88
98
  tracking.current.releaseInteraction = true;
89
99
 
90
- navigator?.maxApi?.showToastDebug?.({
100
+ navigator?.binding.showToastDebug({
91
101
  appId: context.appId,
92
102
  message: `${screenName} screen_interaction_time ${tracking.current.timeInteraction}`,
93
103
  type: 'ERROR',
@@ -109,7 +119,7 @@ export const createScreenTracking = ({
109
119
  });
110
120
  tracking.current.releaseUserInteraction = true;
111
121
 
112
- navigator?.maxApi?.showToastDebug?.({
122
+ navigator?.binding.showToastDebug({
113
123
  appId: context.appId,
114
124
  message: `${screenName} user_interaction ${timeLoad}`,
115
125
  type: 'ERROR',
@@ -1,7 +1,6 @@
1
1
  import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
2
- import { InteractionManager } from 'react-native';
3
2
  import { useHeaderHeight } from '@react-navigation/elements';
4
- import { ScreenTrackingParams } from './types';
3
+ import { type KitsSubscription, ScreenTrackingParams } from './types';
5
4
  import Navigation from './Navigation';
6
5
  import { ApplicationContext, MiniAppContext, ScreenContext } from '../Context';
7
6
  import { SwipeBackHaptic } from './Components/SwipeBackHaptic';
@@ -14,7 +13,12 @@ const TRACKING_TIMEOUT = 5000;
14
13
  const ELEMENT_IDLE_TIMEOUT = 2000;
15
14
  const LOADING_IDLE_TIMEOUT = 2000;
16
15
 
17
- const runAfterInteractions = InteractionManager.runAfterInteractions;
16
+ // RN 0.87+: InteractionManager đã bị xoá khỏi react-native → thay bằng requestIdleCallback.
17
+ // Giữ nguyên shape trả về { cancel } để code bên dưới (timeoutInteraction?.cancel?.()) không đổi.
18
+ const runAfterInteractions = (task: () => void) => {
19
+ const handle = requestIdleCallback(() => task());
20
+ return { cancel: () => cancelIdleCallback(handle) };
21
+ };
18
22
 
19
23
  /**
20
24
  * Hosts a feature screen in the stack: applies its header options, provides
@@ -84,9 +88,9 @@ const StackScreen: React.FC<any> = props => {
84
88
 
85
89
  useEffect(() => {
86
90
  let focusScreen: any;
87
- let focusAppListener: { remove?: () => void } | undefined;
91
+ let focusAppListener: KitsSubscription | undefined;
88
92
  if (['Invalid', 'screen'].includes(screenName)) {
89
- navigator?.maxApi?.showPopup?.('notice', {
93
+ navigator?.binding.showNoticePopup({
90
94
  title: 'Invalid screen name',
91
95
  message:
92
96
  'Your screen has not been rendered because Platform has not detected the screen name. Please migrate to support this feature.',
@@ -97,42 +101,30 @@ const StackScreen: React.FC<any> = props => {
97
101
 
98
102
  if (!bottomTab) {
99
103
  focusScreen = props.navigation.addListener('focus', () => {
100
- navigator?.maxApi?.getDataObserver?.('current_screen', (item: any) => {
104
+ navigator?.binding.getCurrentScreen(item => {
101
105
  handleScreenNavigated(item?.screenName, screenName);
102
- navigator?.maxApi?.setDataObserver?.('current_screen', {
103
- screenName,
104
- startTime,
105
- });
106
+ navigator?.binding.setCurrentScreen({ screenName, startTime });
106
107
  });
107
108
  });
108
- focusAppListener = navigator?.maxApi?.listen?.('onFocusApp', () => {
109
+ focusAppListener = navigator?.binding.onFocusApp(() => {
109
110
  if (props.navigation.isFocused()) {
110
- navigator?.maxApi?.getDataObserver?.(
111
- 'current_screen',
112
- (item: any) => {
113
- handleScreenNavigated(item?.screenName, screenName);
114
- navigator?.maxApi?.setDataObserver?.('current_screen', {
115
- screenName,
116
- startTime,
117
- });
118
- },
119
- );
111
+ navigator?.binding.getCurrentScreen(item => {
112
+ handleScreenNavigated(item?.screenName, screenName);
113
+ navigator?.binding.setCurrentScreen({ screenName, startTime });
114
+ });
120
115
  }
121
116
  });
122
117
  }
123
118
 
124
- navigator?.maxApi?.startTraceScreenLoad?.(
125
- screenName,
126
- context,
127
- (item: any) => {
128
- tracking.current.traceIdLoad = item?.traceId;
129
- },
130
- );
131
- navigator?.maxApi?.startTraceScreenInteraction?.(
119
+ navigator?.binding.startScreenTrace('load', screenName, context, id => {
120
+ tracking.current.traceIdLoad = id;
121
+ });
122
+ navigator?.binding.startScreenTrace(
123
+ 'interaction',
132
124
  screenName,
133
125
  context,
134
- (item: any) => {
135
- tracking.current.traceIdInteraction = item?.traceId;
126
+ id => {
127
+ tracking.current.traceIdInteraction = id;
136
128
  },
137
129
  );
138
130
 
@@ -150,13 +142,13 @@ const StackScreen: React.FC<any> = props => {
150
142
  // eslint-disable-next-line react-hooks/exhaustive-deps
151
143
  clearTimeout(tracking.current.timeoutLoading);
152
144
  focusScreen?.();
153
- focusAppListener?.remove?.();
145
+ focusAppListener?.remove();
154
146
  };
155
147
  // eslint-disable-next-line react-hooks/exhaustive-deps
156
148
  }, []);
157
149
 
158
150
  /** Reports a navigation to this screen: `back` if it was shown before. */
159
- const handleScreenNavigated = (pre: string, current: string) => {
151
+ const handleScreenNavigated = (pre: string | undefined, current: string) => {
160
152
  if (!isBackgroundToForeground) {
161
153
  const item: any = {
162
154
  preScreenName: pre,
@@ -173,7 +165,7 @@ const StackScreen: React.FC<any> = props => {
173
165
 
174
166
  tracking.current.mounted = true;
175
167
 
176
- navigator?.maxApi?.showToastDebug?.({
168
+ navigator?.binding.showToastDebug({
177
169
  appId: context.appId,
178
170
  message: `${screenName} screen_navigated`,
179
171
  type: 'ERROR',
@@ -8,13 +8,13 @@ import React, {
8
8
  useReducer,
9
9
  useRef,
10
10
  } from 'react';
11
- import { StyleSheet, View } from 'react-native';
11
+ import { StyleSheet, View, type ViewInstance } from 'react-native';
12
12
 
13
13
  interface TooltipPortalContextValue {
14
14
  register: (id: string, content: ReactNode) => void;
15
15
  unregister: (id: string, immediate?: boolean) => void;
16
16
  portals: Map<string, ReactNode>;
17
- hostRef: RefObject<View | null>;
17
+ hostRef: RefObject<ViewInstance | null>;
18
18
  }
19
19
 
20
20
  const TooltipPortalContext = createContext<TooltipPortalContextValue | null>(
@@ -30,7 +30,7 @@ export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
30
30
  }) => {
31
31
  // The ref map updates synchronously; the reducer only triggers re-renders.
32
32
  const portalsRef = useRef<Map<string, ReactNode>>(new Map());
33
- const hostRef = useRef<View>(null);
33
+ const hostRef = useRef<ViewInstance>(null);
34
34
  const [updateCounter, forceUpdate] = useReducer((x: number) => x + 1, 0);
35
35
  const pendingUpdateRef = useRef<any>(null);
36
36