GT2/Ejectable/node_modules/@react-navigation/native/lib/commonjs/useLinking.js.map

1 line
32 KiB
Plaintext

{"version":3,"sources":["useLinking.tsx"],"names":["createMemoryHistory","index","items","pending","interrupt","forEach","it","cb","history","id","window","state","findIndex","item","get","backIndex","path","i","push","slice","length","pushState","replace","replaceState","go","n","Math","min","Promise","resolve","reject","done","interrupted","clearTimeout","timer","Error","title","document","ref","setTimeout","splice","onPopState","last","pop","removeEventListener","addEventListener","listen","listener","findMatchingState","a","b","undefined","key","aHistoryLength","routes","bHistoryLength","aRoute","bRoute","aChildState","bChildState","series","handling","queue","callback","unshift","isUsingLinking","useLinking","enabled","config","getStateFromPath","getStateFromPathDefault","getPathFromState","getPathFromStateDefault","React","useEffect","join","trim","useState","enabledRef","useRef","configRef","getStateFromPathRef","getPathFromStateRef","current","server","useContext","ServerContext","getInitialState","useCallback","value","location","pathname","search","thenable","then","onfulfilled","catch","previousIndexRef","previousStateRef","pendingPopStatePathRef","navigation","previousIndex","record","resetRoot","rootState","getRootState","some","r","routeNames","includes","name","console","warn","action","dispatch","e","message","onStateChange","previousState","pendingPath","previousFocusedState","focusedState","historyDelta","nextIndex","currentIndex","addListener"],"mappings":";;;;;;;AAAA;;AACA;;AAOA;;AACA;;;;;;;;AAcA,MAAMA,mBAAmB,GAAG,MAAM;AAChC,MAAIC,KAAK,GAAG,CAAZ;AACA,MAAIC,KAAsB,GAAG,EAA7B,CAFgC,CAIhC;AACA;;AACA,QAAMC,OAAgE,GAAG,EAAzE;;AAEA,QAAMC,SAAS,GAAG,MAAM;AACtB;AACA;AACA;AACAD,IAAAA,OAAO,CAACE,OAAR,CAAiBC,EAAD,IAAQ;AACtB,YAAMC,EAAE,GAAGD,EAAE,CAACC,EAAd;;AACAD,MAAAA,EAAE,CAACC,EAAH,GAAQ,MAAMA,EAAE,CAAC,IAAD,CAAhB;AACD,KAHD;AAID,GARD;;AAUA,QAAMC,OAAO,GAAG;AACd,QAAIP,KAAJ,GAAoB;AAAA;;AAClB;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;AACF,gBAAI0H,SAAS,KAAK,CAAC,CAAf,IAAoBA,SAAS,GAAGC,YAApC,EAAkD;AAChD;AACA,oBAAMpH,OAAO,CAACgB,EAAR,CAAWmG,SAAS,GAAGC,YAAvB,CAAN;AACD,aAHD,MAGO;AACL;AACA;AACA;AACA,oBAAMpH,OAAO,CAACgB,EAAR,CAAWkG,YAAX,CAAN;AACD,aATC,CAWF;;;AACAlH,YAAAA,OAAO,CAACc,OAAR,CAAgB;AAAEN,cAAAA,IAAF;AAAQL,cAAAA;AAAR,aAAhB;AACD,WAbD,CAaE,OAAOwG,CAAP,EAAU,CACV;AACD;AACF,SAtBM,MAsBA;AACL;AACA3G,UAAAA,OAAO,CAACc,OAAR,CAAgB;AAAEN,YAAAA,IAAF;AAAQL,YAAAA;AAAR,WAAhB;AACD;AACF,OA7CD,MA6CO;AACL;AACA;AACAH,QAAAA,OAAO,CAACc,OAAR,CAAgB;AAAEN,UAAAA,IAAF;AAAQL,UAAAA;AAAR,SAAhB;AACD;AACF,KA3ED,CArBoB,CAkGpB;AACA;AACA;;;AACA,2BAAO2B,GAAG,CAAC6C,OAAX,iDAAO,aAAa0C,WAAb,CAAyB,OAAzB,EAAkCjE,MAAM,CAACyD,aAAD,CAAxC,CAAP;AACD,GAtGD;AAwGA,SAAO;AACL9B,IAAAA;AADK,GAAP;AAGD","sourcesContent":["import * as React from 'react';\nimport {\n getStateFromPath as getStateFromPathDefault,\n getPathFromState as getPathFromStateDefault,\n NavigationContainerRef,\n NavigationState,\n getActionFromState,\n} from '@react-navigation/core';\nimport { nanoid } from 'nanoid/non-secure';\nimport ServerContext from './ServerContext';\nimport type { LinkingOptions } from './types';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\ntype HistoryRecord = {\n // Unique identifier for this record to match it with window.history.state\n id: string;\n // Navigation state object for the history entry\n state: NavigationState;\n // Path of the history entry\n path: string;\n};\n\nconst createMemoryHistory = () => {\n let index = 0;\n let items: HistoryRecord[] = [];\n\n // Pending callbacks for `history.go(n)`\n // We might modify the callback stored if it was interrupted, so we have a ref to identify it\n const pending: { ref: unknown; cb: (interrupted?: boolean) => void }[] = [];\n\n const interrupt = () => {\n // If another history operation was performed we need to interrupt existing ones\n // This makes sure that calls such as `history.replace` after `history.go` don't happen\n // Since otherwise it won't be correct if something else has changed\n pending.forEach((it) => {\n const cb = it.cb;\n it.cb = () => cb(true);\n });\n };\n\n const history = {\n get index(): number {\n // We store an id in the state instead of an index\n // Index could get out of sync with in-memory values if page reloads\n const id = window.history.state?.id;\n\n if (id) {\n const index = items.findIndex((item) => item.id === id);\n\n return index > -1 ? index : 0;\n }\n\n return 0;\n },\n\n get(index: number) {\n return items[index];\n },\n\n backIndex({ path }: { path: string }) {\n // We need to find the index from the element before current to get closest path to go back to\n for (let i = index - 1; i >= 0; i--) {\n const item = items[i];\n\n if (item.path === path) {\n return i;\n }\n }\n\n return -1;\n },\n\n push({ path, state }: { path: string; state: NavigationState }) {\n interrupt();\n\n const id = nanoid();\n\n // When a new entry is pushed, all the existing entries after index will be inaccessible\n // So we remove any existing entries after the current index to clean them up\n items = items.slice(0, index + 1);\n\n items.push({ path, state, id });\n index = items.length - 1;\n\n // We pass empty string for title because it's ignored in all browsers except safari\n // We don't store state object in history.state because:\n // - browsers have limits on how big it can be, and we don't control the size\n // - while not recommended, there could be non-serializable data in state\n window.history.pushState({ id }, '', path);\n },\n\n replace({ path, state }: { path: string; state: NavigationState }) {\n interrupt();\n\n const id = window.history.state?.id ?? nanoid();\n\n if (items.length) {\n items[index] = { path, state, id };\n } else {\n // This is the first time any state modifications are done\n // So we need to push the entry as there's nothing to replace\n items.push({ path, state, id });\n }\n\n window.history.replaceState({ id }, '', path);\n },\n\n // `history.go(n)` is asynchronous, there are couple of things to keep in mind:\n // - it won't do anything if we can't go `n` steps, the `popstate` event won't fire.\n // - each `history.go(n)` call will trigger a separate `popstate` event with correct location.\n // - the `popstate` event fires before the next frame after calling `history.go(n)`.\n // This method differs from `history.go(n)` in the sense that it'll go back as many steps it can.\n go(n: number) {\n interrupt();\n\n if (n > 0) {\n // We shouldn't go forward more than available index\n n = Math.min(n, items.length - 1);\n } else if (n < 0) {\n // We shouldn't go back more than the 0 index\n // Otherwise we'll exit the page\n n = index + n < 0 ? -index : n;\n }\n\n if (n === 0) {\n return;\n }\n\n index += n;\n\n // When we call `history.go`, `popstate` will fire when there's history to go back to\n // So we need to somehow handle following cases:\n // - There's history to go back, `history.go` is called, and `popstate` fires\n // - `history.go` is called multiple times, we need to resolve on respective `popstate`\n // - No history to go back, but `history.go` was called, browser has no API to detect it\n return new Promise((resolve, reject) => {\n const done = (interrupted?: boolean) => {\n clearTimeout(timer);\n\n if (interrupted) {\n reject(new Error('History was changed during navigation.'));\n return;\n }\n\n // There seems to be a bug in Chrome regarding updating the title\n // If we set a title just before calling `history.go`, the title gets lost\n // However the value of `document.title` is still what we set it to\n // It's just not displayed in the tab bar\n // To update the tab bar, we need to reset the title to something else first (e.g. '')\n // And set the title to what it was before so it gets applied\n // It won't work without setting it to empty string coz otherwise title isn't changing\n // Which means that the browser won't do anything after setting the title\n const { title } = window.document;\n\n window.document.title = '';\n window.document.title = title;\n\n resolve();\n };\n\n pending.push({ ref: done, cb: done });\n\n // If navigation didn't happen within 100ms, assume that it won't happen\n // This may not be accurate, but hopefully it won't take so much time\n // In Chrome, navigation seems to happen instantly in next microtask\n // But on Firefox, it seems to take much longer, around 50ms from our testing\n // We're using a hacky timeout since there doesn't seem to be way to know for sure\n const timer = setTimeout(() => {\n const index = pending.findIndex((it) => it.ref === done);\n\n if (index > -1) {\n pending[index].cb();\n pending.splice(index, 1);\n }\n }, 100);\n\n const onPopState = () => {\n const last = pending.pop();\n\n window.removeEventListener('popstate', onPopState);\n last?.cb();\n };\n\n window.addEventListener('popstate', onPopState);\n window.history.go(n);\n });\n },\n\n // The `popstate` event is triggered when history changes, except `pushState` and `replaceState`\n // If we call `history.go(n)` ourselves, we don't want it to trigger the listener\n // Here we normalize it so that only external changes (e.g. user pressing back/forward) trigger the listener\n listen(listener: () => void) {\n const onPopState = () => {\n if (pending.length) {\n // This was triggered by `history.go(n)`, we shouldn't call the listener\n return;\n }\n\n listener();\n };\n\n window.addEventListener('popstate', onPopState);\n\n return () => window.removeEventListener('popstate', onPopState);\n },\n };\n\n return history;\n};\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 isUsingLinking = false;\n\nexport default function useLinking(\n ref: React.RefObject<NavigationContainerRef>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n }: LinkingOptions\n) {\n React.useEffect(() => {\n if (enabled !== false && isUsingLinking) {\n throw new Error(\n [\n 'Looks like you have configured linking in multiple places. This is likely an error since URL integration should only be handled in one place to avoid conflicts. Make sure that:',\n \"- You are not using both 'linking' prop and 'useLinking'\",\n \"- You don't have 'useLinking' in multiple components\",\n ]\n .join('\\n')\n .trim()\n );\n } else {\n isUsingLinking = enabled !== false;\n }\n\n return () => {\n isUsingLinking = false;\n };\n });\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\n React.useEffect(() => {\n enabledRef.current = enabled;\n configRef.current = config;\n getStateFromPathRef.current = getStateFromPath;\n getPathFromStateRef.current = getPathFromState;\n }, [config, enabled, getPathFromState, getStateFromPath]);\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 // Make it a thenable to keep consistent with the native impl\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 = getActionFromState(state, configRef.current);\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}': ${e.message}`\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 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 path = getPathFromStateRef.current(state, configRef.current);\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 const pendingPath = pendingPopStatePathRef.current;\n const path = getPathFromStateRef.current(state, configRef.current);\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"]}