diff --git a/.github/actions/javascript/bumpVersion/index.js b/.github/actions/javascript/bumpVersion/index.js index d17760baa91f..8fe84446ba82 100644 --- a/.github/actions/javascript/bumpVersion/index.js +++ b/.github/actions/javascript/bumpVersion/index.js @@ -2657,12 +2657,17 @@ createToken('XRANGELOOSE', `^${src[t.GTLT]}\\s*${src[t.XRANGEPLAINLOOSE]}$`) // Coercion. // Extract anything that could conceivably be a part of a valid semver -createToken('COERCE', `${'(^|[^\\d])' + +createToken('COERCEPLAIN', `${'(^|[^\\d])' + '(\\d{1,'}${MAX_SAFE_COMPONENT_LENGTH}})` + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + - `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?` + + `(?:\\.(\\d{1,${MAX_SAFE_COMPONENT_LENGTH}}))?`) +createToken('COERCE', `${src[t.COERCEPLAIN]}(?:$|[^\\d])`) +createToken('COERCEFULL', src[t.COERCEPLAIN] + + `(?:${src[t.PRERELEASE]})?` + + `(?:${src[t.BUILD]})?` + `(?:$|[^\\d])`) createToken('COERCERTL', src[t.COERCE], true) +createToken('COERCERTLFULL', src[t.COERCEFULL], true) // Tilde ranges. // Meaning is "reasonably at or greater than" diff --git a/package-lock.json b/package-lock.json index 5f55ddd82868..cafbead8f5eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -37,7 +37,7 @@ "@react-native-google-signin/google-signin": "^10.0.1", "@react-native-picker/picker": "2.5.1", "@react-navigation/material-top-tabs": "^6.6.3", - "@react-navigation/native": "6.1.8", + "@react-navigation/native": "6.1.12", "@react-navigation/stack": "6.3.16", "@react-ng/bounds-observer": "^0.2.1", "@rnmapbox/maps": "^10.1.11", @@ -10317,9 +10317,9 @@ } }, "node_modules/@react-navigation/core": { - "version": "6.4.10", - "resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-6.4.10.tgz", - "integrity": "sha512-oYhqxETRHNHKsipm/BtGL0LI43Hs2VSFoWMbBdHK9OqgQPjTVUitslgLcPpo4zApCcmBWoOLX2qPxhsBda644A==", + "version": "6.4.11", + "resolved": "https://registry.npmjs.org/@react-navigation/core/-/core-6.4.11.tgz", + "integrity": "sha512-kOCyOc1L0lAl53DbyNl3OkUJwSFKSaVCsV8leJawUXMXJ1FTT3nbS3xMOqbZuchxIbl8T62sZ7YnlWG/21rcMw==", "dependencies": { "@react-navigation/routers": "^6.1.9", "escape-string-regexp": "^4.0.0", @@ -10345,6 +10345,17 @@ "react": "*" } }, + "node_modules/@react-navigation/elements": { + "version": "1.3.24", + "resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.3.24.tgz", + "integrity": "sha512-zgZV50qjlv3/N+MzNV0DIRmtg30IZcR0+LaTQRP/OxLtveQkgUG6wIEKl6SXO2ykC9yF9V82msdCzKl9uPSQCA==", + "peerDependencies": { + "@react-navigation/native": "^6.0.0", + "react": "*", + "react-native": "*", + "react-native-safe-area-context": ">= 3.0.0" + } + }, "node_modules/@react-navigation/material-top-tabs": { "version": "6.6.3", "resolved": "https://registry.npmjs.org/@react-navigation/material-top-tabs/-/material-top-tabs-6.6.3.tgz", @@ -10362,11 +10373,11 @@ } }, "node_modules/@react-navigation/native": { - "version": "6.1.8", - "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-6.1.8.tgz", - "integrity": "sha512-0alti852nV+8oCVm9H80G6kZvrHoy51+rXBvVCRUs2rNDDozC/xPZs8tyeCJkqdw3cpxZDK8ndXF22uWq28+0Q==", + "version": "6.1.12", + "resolved": "https://registry.npmjs.org/@react-navigation/native/-/native-6.1.12.tgz", + "integrity": "sha512-t6y7sDCr0HlMf+5TuVjLjyi0ySs0eNGfreDKcWOMEi5wooNFM4LhcUCdEVylpwCPfjQMW/lNVomNromqZFM6HQ==", "dependencies": { - "@react-navigation/core": "^6.4.9", + "@react-navigation/core": "^6.4.11", "escape-string-regexp": "^4.0.0", "fast-deep-equal": "^3.1.3", "nanoid": "^3.1.23" @@ -10402,17 +10413,6 @@ "react-native-screens": ">= 3.0.0" } }, - "node_modules/@react-navigation/stack/node_modules/@react-navigation/elements": { - "version": "1.3.17", - "resolved": "https://registry.npmjs.org/@react-navigation/elements/-/elements-1.3.17.tgz", - "integrity": "sha512-sui8AzHm6TxeEvWT/NEXlz3egYvCUog4tlXA4Xlb2Vxvy3purVXDq/XsM56lJl344U5Aj/jDzkVanOTMWyk4UA==", - "peerDependencies": { - "@react-navigation/native": "^6.0.0", - "react": "*", - "react-native": "*", - "react-native-safe-area-context": ">= 3.0.0" - } - }, "node_modules/@react-ng/bounds-observer": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/@react-ng/bounds-observer/-/bounds-observer-0.2.1.tgz", diff --git a/package.json b/package.json index e3c23d4538d3..46ff187bf64c 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@react-native-google-signin/google-signin": "^10.0.1", "@react-native-picker/picker": "2.5.1", "@react-navigation/material-top-tabs": "^6.6.3", - "@react-navigation/native": "6.1.8", + "@react-navigation/native": "6.1.12", "@react-navigation/stack": "6.3.16", "@react-ng/bounds-observer": "^0.2.1", "@rnmapbox/maps": "^10.1.11", diff --git a/patches/@react-navigation+native+6.1.8.patch b/patches/@react-navigation+native+6.1.12.patch similarity index 97% rename from patches/@react-navigation+native+6.1.8.patch rename to patches/@react-navigation+native+6.1.12.patch index c461d7e510fe..d451d89d687c 100644 --- a/patches/@react-navigation+native+6.1.8.patch +++ b/patches/@react-navigation+native+6.1.12.patch @@ -133,7 +133,7 @@ index 0000000..16da117 +//# sourceMappingURL=findFocusedRouteKey.js.map \ No newline at end of file diff --git a/node_modules/@react-navigation/native/lib/module/useLinking.js b/node_modules/@react-navigation/native/lib/module/useLinking.js -index 6f0ac51..a77b608 100644 +index 6688c62..95a0e32 100644 --- a/node_modules/@react-navigation/native/lib/module/useLinking.js +++ b/node_modules/@react-navigation/native/lib/module/useLinking.js @@ -2,6 +2,7 @@ import { findFocusedRoute, getActionFromState as getActionFromStateDefault, getP @@ -189,17 +189,17 @@ index 6f0ac51..a77b608 100644 export default function useLinking(ref, _ref) { let { independent, -@@ -231,6 +270,9 @@ export default function useLinking(ref, _ref) { +@@ -234,6 +273,9 @@ export default function useLinking(ref, _ref) { // Otherwise it's likely a change triggered by `popstate` path !== pendingPath) { const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length); -+ ++ + // The historyDelta and historyDeltaByKeys may differ if the new state has an entry that didn't exist in previous state + const historyDeltaByKeys = getHistoryDeltaByKeys(focusedState, previousFocusedState); if (historyDelta > 0) { // If history length is increased, we should pushState // Note that path might not actually change here, for example, drawer open should pushState -@@ -242,34 +284,55 @@ export default function useLinking(ref, _ref) { +@@ -245,7 +287,8 @@ export default function useLinking(ref, _ref) { // If history length is decreased, i.e. entries were removed, we want to go back const nextIndex = history.backIndex({ @@ -209,7 +209,8 @@ index 6f0ac51..a77b608 100644 }); const currentIndex = history.index; try { - if (nextIndex !== -1 && nextIndex < currentIndex) { +@@ -254,27 +297,47 @@ export default function useLinking(ref, _ref) { + history.get(nextIndex - currentIndex)) { // An existing entry for this path exists and it's less than current index, go back to that await history.go(nextIndex - currentIndex); + history.replace({ @@ -263,7 +264,7 @@ index 6f0ac51..a77b608 100644 + path, + state + }); -+ } ++ } } } else { // If no common navigation state was found, assume it's a replace diff --git a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx index 8f646f7a748c..f38ec213a466 100644 --- a/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx +++ b/src/libs/Navigation/AppNavigator/createCustomBottomTabNavigator/BottomTabBar.tsx @@ -14,7 +14,7 @@ import useThemeStyles from '@hooks/useThemeStyles'; import interceptAnonymousUser from '@libs/interceptAnonymousUser'; import getTopmostBottomTabRoute from '@libs/Navigation/getTopmostBottomTabRoute'; import Navigation from '@libs/Navigation/Navigation'; -import type {RootStackParamList} from '@libs/Navigation/types'; +import type {RootStackParamList, State} from '@libs/Navigation/types'; import {checkIfWorkspaceSettingsTabHasRBR, getChatTabBrickRoad} from '@libs/WorkspacesSettingsUtils'; import BottomTabBarFloatingActionButton from '@pages/home/sidebar/BottomTabBarFloatingActionButton'; import variables from '@styles/variables'; @@ -39,9 +39,9 @@ function BottomTabBar({isLoadingApp = false}: PurposeForUsingExpensifyModalProps const navigation = useNavigation(); useEffect(() => { - const navigationState = navigation.getState(); - const routes = navigationState.routes; - const currentRoute = routes[navigationState.index]; + const navigationState = navigation.getState() as State | undefined; + const routes = navigationState?.routes; + const currentRoute = routes?.[navigationState?.index ?? 0]; const bottomTabRoute = getTopmostBottomTabRoute(navigationState); if ( // When we are redirected to the Settings tab from the OldDot, we don't want to call the Welcome.show() method. diff --git a/src/libs/Navigation/FreezeWrapper.tsx b/src/libs/Navigation/FreezeWrapper.tsx index 570553d38017..9bb72a34588b 100644 --- a/src/libs/Navigation/FreezeWrapper.tsx +++ b/src/libs/Navigation/FreezeWrapper.tsx @@ -18,7 +18,7 @@ function FreezeWrapper({keepVisible = false, children}: FreezeWrapperProps) { const currentRoute = useRoute(); useEffect(() => { - const index = navigation.getState().routes.findIndex((route) => route.key === currentRoute.key); + const index = navigation.getState()?.routes.findIndex((route) => route.key === currentRoute.key) ?? 0; screenIndexRef.current = index; // eslint-disable-next-line react-hooks/exhaustive-deps }, []); @@ -28,7 +28,7 @@ function FreezeWrapper({keepVisible = false, children}: FreezeWrapperProps) { // if the screen is more than 1 screen away from the current screen, freeze it, // we don't want to freeze the screen if it's the previous screen because the freeze placeholder // would be visible at the beginning of the back animation then - if (navigation.getState().index - (screenIndexRef.current ?? 0) > 1) { + if ((navigation.getState()?.index ?? 0) - (screenIndexRef.current ?? 0) > 1) { InteractionManager.runAfterInteractions(() => setIsScreenBlurred(true)); } else { setIsScreenBlurred(false); diff --git a/src/libs/Navigation/getTopmostBottomTabRoute.ts b/src/libs/Navigation/getTopmostBottomTabRoute.ts index 8cfc60d99c4a..a589f2cbc837 100644 --- a/src/libs/Navigation/getTopmostBottomTabRoute.ts +++ b/src/libs/Navigation/getTopmostBottomTabRoute.ts @@ -1,7 +1,7 @@ import type {BottomTabName, NavigationPartialRoute, RootStackParamList, State} from './types'; -function getTopmostBottomTabRoute(state: State): NavigationPartialRoute | undefined { - const bottomTabNavigatorRoute = state.routes[0]; +function getTopmostBottomTabRoute(state: State | undefined): NavigationPartialRoute | undefined { + const bottomTabNavigatorRoute = state?.routes[0]; // The bottomTabNavigatorRoute state may be empty if we just logged in. if (!bottomTabNavigatorRoute || bottomTabNavigatorRoute.name !== 'BottomTabNavigator' || bottomTabNavigatorRoute.state === undefined) { diff --git a/src/libs/actions/Welcome.ts b/src/libs/actions/Welcome.ts index 3f6b2dc99a8f..30b19ca05c69 100644 --- a/src/libs/actions/Welcome.ts +++ b/src/libs/actions/Welcome.ts @@ -3,7 +3,7 @@ import type {OnyxCollection} from 'react-native-onyx'; import Onyx from 'react-native-onyx'; import Navigation from '@libs/Navigation/Navigation'; import * as ReportUtils from '@libs/ReportUtils'; -import type {RootStackParamList} from '@navigation/types'; +import type {RootStackParamList, State} from '@navigation/types'; import CONST from '@src/CONST'; import ONYXKEYS from '@src/ONYXKEYS'; import ROUTES from '@src/ROUTES'; @@ -125,7 +125,7 @@ Onyx.connect({ /** * Shows a welcome action on first login */ -function show(routes: NavigationState['routes'], showEngagementModal = () => {}) { +function show(routes: State['routes'] | undefined, showEngagementModal = () => {}) { isReadyPromise.then(() => { if (!isFirstTimeNewExpensifyUser) { return; @@ -133,7 +133,7 @@ function show(routes: NavigationState['routes'], showEngagem // If we are rendering the SidebarScreen at the same time as a workspace route that means we've already created a workspace via workspace/new and should not open the global // create menu right now. We should also stay on the workspace page if that is our destination. - const transitionRoute = routes.find( + const transitionRoute = routes?.find( (route): route is NavigationState>['routes'][number] => route.name === SCREENS.TRANSITION_BETWEEN_APPS, ); const isExitingToWorkspaceRoute = transitionRoute?.params?.exitTo === 'workspace/new';