UNPKG

24.5 kBSource Map (JSON)View Raw
1{"version":3,"names":["findMatchingState","a","b","undefined","key","aHistoryLength","history","length","routes","bHistoryLength","aRoute","index","bRoute","aChildState","state","bChildState","series","cb","handling","queue","callback","unshift","last","pop","linkingHandlers","useLinking","ref","independent","enabled","config","getStateFromPath","getStateFromPathDefault","getPathFromState","getPathFromStateDefault","getActionFromState","getActionFromStateDefault","React","useEffect","process","env","NODE_ENV","console","error","join","trim","handler","Symbol","push","indexOf","splice","useState","createMemoryHistory","enabledRef","useRef","configRef","getStateFromPathRef","getPathFromStateRef","getActionFromStateRef","current","server","useContext","ServerContext","getInitialState","useCallback","value","location","window","path","pathname","search","thenable","then","onfulfilled","Promise","resolve","catch","previousIndexRef","previousStateRef","pendingPopStatePathRef","listen","navigation","previousIndex","record","get","resetRoot","rootState","getRootState","some","r","routeNames","includes","name","warn","action","dispatch","e","message","getPathForRoute","route","stateForPath","focusedRoute","findFocusedRoute","isEqual","params","replace","onStateChange","previousState","pendingPath","previousFocusedState","focusedState","historyDelta","nextIndex","backIndex","currentIndex","go","addListener"],"sources":["useLinking.tsx"],"sourcesContent":["import {\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n NavigationContainerRef,\n NavigationState,\n ParamListBase,\n} from '@react-navigation/core';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport createMemoryHistory from './createMemoryHistory';\nimport ServerContext from './ServerContext';\nimport type { LinkingOptions } from './types';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\n/**\n * Find the matching navigation state that changed between 2 navigation states\n * e.g.: a -> b -> c -> d and a -> b -> c -> e -> f, if history in b changed, b is the matching state\n */\nconst findMatchingState = <T extends NavigationState>(\n a: T | undefined,\n b: T | undefined\n): [T | undefined, T | undefined] => {\n if (a === undefined || b === undefined || a.key !== b.key) {\n return [undefined, undefined];\n }\n\n // Tab and drawer will have `history` property, but stack will have history in `routes`\n const aHistoryLength = a.history ? a.history.length : a.routes.length;\n const bHistoryLength = b.history ? b.history.length : b.routes.length;\n\n const aRoute = a.routes[a.index];\n const bRoute = b.routes[b.index];\n\n const aChildState = aRoute.state as T | undefined;\n const bChildState = bRoute.state as T | undefined;\n\n // Stop here if this is the state object that changed:\n // - history length is different\n // - focused routes are different\n // - one of them doesn't have child state\n // - child state keys are different\n if (\n aHistoryLength !== bHistoryLength ||\n aRoute.key !== bRoute.key ||\n aChildState === undefined ||\n bChildState === undefined ||\n aChildState.key !== bChildState.key\n ) {\n return [a, b];\n }\n\n return findMatchingState(aChildState, bChildState);\n};\n\n/**\n * Run async function in series as it's called.\n */\nconst series = (cb: () => Promise<void>) => {\n // Whether we're currently handling a callback\n let handling = false;\n let queue: (() => Promise<void>)[] = [];\n\n const callback = async () => {\n try {\n if (handling) {\n // If we're currently handling a previous event, wait before handling this one\n // Add the callback to the beginning of the queue\n queue.unshift(callback);\n return;\n }\n\n handling = true;\n\n await cb();\n } finally {\n handling = false;\n\n if (queue.length) {\n // If we have queued items, handle the last one\n const last = queue.pop();\n\n last?.();\n }\n }\n };\n\n return callback;\n};\n\nlet linkingHandlers: Symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase> & {\n independent?: boolean;\n};\n\nexport default function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n independent,\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options\n) {\n React.useEffect(() => {\n if (process.env.NODE_ENV === 'production') {\n return undefined;\n }\n\n if (independent) {\n return undefined;\n }\n\n if (enabled !== false && linkingHandlers.length) {\n console.error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since deep links should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You don't have multiple NavigationContainers in the app each with 'linking' enabled\",\n '- Only a single instance of the root component is rendered',\n ]\n .join('\\n')\n .trim()\n );\n }\n\n const handler = Symbol();\n\n if (enabled !== false) {\n linkingHandlers.push(handler);\n }\n\n return () => {\n const index = linkingHandlers.indexOf(handler);\n\n if (index > -1) {\n linkingHandlers.splice(index, 1);\n }\n };\n }, [enabled, independent]);\n\n const [history] = React.useState(createMemoryHistory);\n\n // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners\n // This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`\n // Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect\n const enabledRef = React.useRef(enabled);\n const configRef = React.useRef(config);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getPathFromStateRef = React.useRef(getPathFromState);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const server = React.useContext(ServerContext);\n\n const getInitialState = React.useCallback(() => {\n let value: ResultState | undefined;\n\n if (enabledRef.current) {\n const location =\n server?.location ??\n (typeof window !== 'undefined' ? window.location : undefined);\n\n const path = location ? location.pathname + location.search : undefined;\n\n if (path) {\n value = getStateFromPathRef.current(path, configRef.current);\n }\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(value) : value);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n const previousIndexRef = React.useRef<number | undefined>(undefined);\n const previousStateRef = React.useRef<NavigationState | undefined>(undefined);\n const pendingPopStatePathRef = React.useRef<string | undefined>(undefined);\n\n React.useEffect(() => {\n previousIndexRef.current = history.index;\n\n return history.listen(() => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const path = location.pathname + location.search;\n const index = history.index;\n\n const previousIndex = previousIndexRef.current ?? 0;\n\n previousIndexRef.current = index;\n pendingPopStatePathRef.current = path;\n\n // When browser back/forward is clicked, we first need to check if state object for this index exists\n // If it does we'll reset to that state object\n // Otherwise, we'll handle it like a regular deep link\n const record = history.get(index);\n\n if (record?.path === path && record?.state) {\n navigation.resetRoot(record.state);\n return;\n }\n\n const state = getStateFromPathRef.current(path, configRef.current);\n\n // We should only dispatch an action when going forward\n // Otherwise the action will likely add items to history, which would mess things up\n if (state) {\n // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n const rootState = navigation.getRootState();\n\n if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {\n console.warn(\n \"The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.\"\n );\n return;\n }\n\n if (index > previousIndex) {\n const action = getActionFromStateRef.current(\n state,\n configRef.current\n );\n\n if (action !== undefined) {\n try {\n navigation.dispatch(action);\n } catch (e) {\n // Ignore any errors from deep linking.\n // This could happen in case of malformed links, navigation object not being initialized etc.\n console.warn(\n `An error occurred when trying to handle the link '${path}': ${\n typeof e === 'object' && e != null && 'message' in e\n ? // @ts-expect-error: we're already checking for this\n e.message\n : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n navigation.resetRoot(state);\n }\n } else {\n // if current path didn't return any state, we should revert to initial state\n navigation.resetRoot(state);\n }\n });\n }, [enabled, history, ref]);\n\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const getPathForRoute = (\n route: ReturnType<typeof findFocusedRoute>,\n state: NavigationState\n ): string => {\n // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match\n // This makes sure that we preserve the original URL for wildcard routes\n if (route?.path) {\n const stateForPath = getStateFromPathRef.current(\n route.path,\n configRef.current\n );\n\n if (stateForPath) {\n const focusedRoute = findFocusedRoute(stateForPath);\n\n if (\n focusedRoute &&\n focusedRoute.name === route.name &&\n isEqual(focusedRoute.params, route.params)\n ) {\n return route.path;\n }\n }\n }\n\n return getPathFromStateRef.current(state, configRef.current);\n };\n\n if (ref.current) {\n // We need to record the current metadata on the first render if they aren't set\n // This will allow the initial state to be in the history entry\n const state = ref.current.getRootState();\n\n if (state) {\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n if (previousStateRef.current === undefined) {\n previousStateRef.current = state;\n }\n\n history.replace({ path, state });\n }\n }\n\n const onStateChange = async () => {\n const navigation = ref.current;\n\n if (!navigation || !enabled) {\n return;\n }\n\n const previousState = previousStateRef.current;\n const state = navigation.getRootState();\n\n // root state may not available, for example when root navigators switch inside the container\n if (!state) {\n return;\n }\n\n const pendingPath = pendingPopStatePathRef.current;\n const route = findFocusedRoute(state);\n const path = getPathForRoute(route, state);\n\n previousStateRef.current = state;\n pendingPopStatePathRef.current = undefined;\n\n // To detect the kind of state change, we need to:\n // - Find the common focused navigation state in previous and current state\n // - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace\n // - If no common focused navigation state found, it's a replace\n const [previousFocusedState, focusedState] = findMatchingState(\n previousState,\n state\n );\n\n if (\n previousFocusedState &&\n focusedState &&\n // We should only handle push/pop if path changed from what was in last `popstate`\n // Otherwise it's likely a change triggered by `popstate`\n path !== pendingPath\n ) {\n const historyDelta =\n (focusedState.history\n ? focusedState.history.length\n : focusedState.routes.length) -\n (previousFocusedState.history\n ? previousFocusedState.history.length\n : previousFocusedState.routes.length);\n\n if (historyDelta > 0) {\n // If history length is increased, we should pushState\n // Note that path might not actually change here, for example, drawer open should pushState\n history.push({ path, state });\n } else if (historyDelta < 0) {\n // If history length is decreased, i.e. entries were removed, we want to go back\n\n const nextIndex = history.backIndex({ path });\n const currentIndex = history.index;\n\n try {\n if (nextIndex !== -1 && nextIndex < currentIndex) {\n // An existing entry for this path exists and it's less than current index, go back to that\n await history.go(nextIndex - currentIndex);\n } else {\n // We couldn't find an existing entry to go back to, so we'll go back by the delta\n // This won't be correct if multiple routes were pushed in one go before\n // Usually this shouldn't happen and this is a fallback for that\n await history.go(historyDelta);\n }\n\n // Store the updated state as well as fix the path if incorrect\n history.replace({ path, state });\n } catch (e) {\n // The navigation was interrupted\n }\n } else {\n // If history length is unchanged, we want to replaceState\n history.replace({ path, state });\n }\n } else {\n // If no common navigation state was found, assume it's a replace\n // This would happen if the user did a reset/conditionally changed navigators\n history.replace({ path, state });\n }\n };\n\n // We debounce onStateChange coz we don't want multiple state changes to be handled at one time\n // This could happen since `history.go(n)` is asynchronous\n // If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up\n return ref.current?.addListener('state', series(onStateChange));\n });\n\n return {\n getInitialState,\n };\n}\n"],"mappings":";;;;;;;AAAA;;AASA;;AACA;;AAEA;;AACA;;;;;;;;AAKA;AACA;AACA;AACA;AACA,MAAMA,iBAAiB,GAAG,CACxBC,CADwB,EAExBC,CAFwB,KAGW;EACnC,IAAID,CAAC,KAAKE,SAAN,IAAmBD,CAAC,KAAKC,SAAzB,IAAsCF,CAAC,CAACG,GAAF,KAAUF,CAAC,CAACE,GAAtD,EAA2D;IACzD,OAAO,CAACD,SAAD,EAAYA,SAAZ,CAAP;EACD,CAHkC,CAKnC;;;EACA,MAAME,cAAc,GAAGJ,CAAC,CAACK,OAAF,GAAYL,CAAC,CAACK,OAAF,CAAUC,MAAtB,GAA+BN,CAAC,CAACO,MAAF,CAASD,MAA/D;EACA,MAAME,cAAc,GAAGP,CAAC,CAACI,OAAF,GAAYJ,CAAC,CAACI,OAAF,CAAUC,MAAtB,GAA+BL,CAAC,CAACM,MAAF,CAASD,MAA/D;EAEA,MAAMG,MAAM,GAAGT,CAAC,CAACO,MAAF,CAASP,CAAC,CAACU,KAAX,CAAf;EACA,MAAMC,MAAM,GAAGV,CAAC,CAACM,MAAF,CAASN,CAAC,CAACS,KAAX,CAAf;EAEA,MAAME,WAAW,GAAGH,MAAM,CAACI,KAA3B;EACA,MAAMC,WAAW,GAAGH,MAAM,CAACE,KAA3B,CAbmC,CAenC;EACA;EACA;EACA;EACA;;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