expo-router 4.0.0-preview.5 → 4.0.0-preview.7

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 (68) hide show
  1. package/build/exports.d.ts +2 -2
  2. package/build/exports.d.ts.map +1 -1
  3. package/build/exports.js.map +1 -1
  4. package/build/fork/createMemoryHistory.d.ts +1 -1
  5. package/build/fork/createMemoryHistory.d.ts.map +1 -1
  6. package/build/fork/createMemoryHistory.js.map +1 -1
  7. package/build/fork/useBackButton.d.ts +1 -1
  8. package/build/fork/useBackButton.d.ts.map +1 -1
  9. package/build/fork/useBackButton.js.map +1 -1
  10. package/build/fork/useBackButton.native.d.ts +1 -1
  11. package/build/fork/useBackButton.native.d.ts.map +1 -1
  12. package/build/fork/useBackButton.native.js.map +1 -1
  13. package/build/fork/useDocumentTitle.d.ts +1 -2
  14. package/build/fork/useDocumentTitle.d.ts.map +1 -1
  15. package/build/fork/useDocumentTitle.js.map +1 -1
  16. package/build/fork/useLinking.d.ts +5 -6
  17. package/build/fork/useLinking.d.ts.map +1 -1
  18. package/build/fork/useLinking.js +6 -6
  19. package/build/fork/useLinking.js.map +1 -1
  20. package/build/fork/useLinking.native.d.ts +5 -5
  21. package/build/fork/useLinking.native.d.ts.map +1 -1
  22. package/build/fork/useLinking.native.js +3 -3
  23. package/build/fork/useLinking.native.js.map +1 -1
  24. package/build/getRoutesCore.js +22 -4
  25. package/build/getRoutesCore.js.map +1 -1
  26. package/build/global-state/router-store.d.ts.map +1 -1
  27. package/build/global-state/router-store.js +1 -0
  28. package/build/global-state/router-store.js.map +1 -1
  29. package/build/head/ExpoHead.ios.js +2 -2
  30. package/build/head/ExpoHead.ios.js.map +1 -1
  31. package/build/hooks.d.ts.map +1 -1
  32. package/build/hooks.js +1 -0
  33. package/build/hooks.js.map +1 -1
  34. package/build/layouts/Stack.d.ts.map +1 -1
  35. package/build/layouts/Stack.js +1 -0
  36. package/build/layouts/Stack.js.map +1 -1
  37. package/build/layouts/Tabs.d.ts +8 -0
  38. package/build/layouts/Tabs.d.ts.map +1 -1
  39. package/build/layouts/Tabs.js +1 -0
  40. package/build/layouts/Tabs.js.map +1 -1
  41. package/build/layouts/withLayoutContext.d.ts +2 -2
  42. package/build/layouts/withLayoutContext.d.ts.map +1 -1
  43. package/build/layouts/withLayoutContext.js +3 -6
  44. package/build/layouts/withLayoutContext.js.map +1 -1
  45. package/build/link/Link.d.ts.map +1 -1
  46. package/build/link/Link.js +1 -0
  47. package/build/link/Link.js.map +1 -1
  48. package/build/primitives.js +3 -3
  49. package/build/primitives.js.map +1 -1
  50. package/build/rsc/router/noopRouter.d.ts +7 -0
  51. package/build/rsc/router/noopRouter.d.ts.map +1 -0
  52. package/build/rsc/router/noopRouter.js +7 -0
  53. package/build/rsc/router/noopRouter.js.map +1 -0
  54. package/build/useFocusEffect.d.ts.map +1 -1
  55. package/build/useFocusEffect.js +1 -0
  56. package/build/useFocusEffect.js.map +1 -1
  57. package/build/useNavigation.d.ts.map +1 -1
  58. package/build/useNavigation.js +1 -0
  59. package/build/useNavigation.js.map +1 -1
  60. package/build/useScreens.d.ts.map +1 -1
  61. package/build/useScreens.js +1 -0
  62. package/build/useScreens.js.map +1 -1
  63. package/build/views/Splash.d.ts.map +1 -1
  64. package/build/views/Splash.js +1 -0
  65. package/build/views/Splash.js.map +1 -1
  66. package/entry-classic.js +6 -0
  67. package/package.json +7 -7
  68. package/plugin/build/index.js +3 -1
@@ -8,13 +8,13 @@ export { ExpoRoot } from './ExpoRoot';
8
8
  export { Unmatched } from './views/Unmatched';
9
9
  export { ErrorBoundaryProps } from './views/Try';
10
10
  export { ErrorBoundary } from './views/ErrorBoundary';
11
- export { ScreenProps } from './useScreens';
11
+ export type { ScreenProps } from './useScreens';
12
12
  /**
13
13
  * @hidden
14
14
  */
15
15
  export { SplashScreen } from './views/Splash';
16
16
  export { useNavigation } from './useNavigation';
17
17
  export { useFocusEffect, EffectCallback } from './useFocusEffect';
18
- export { ResultState } from './fork/getStateFromPath';
18
+ export type { ResultState } from './fork/getStateFromPath';
19
19
  export type * from './types';
20
20
  //# sourceMappingURL=exports.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EACL,SAAS,EACT,qBAAqB,EACrB,WAAW,EACX,yBAAyB,EACzB,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,sBAAsB,GACvB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAExE,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC;AAG3B,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAG3C;;GAEG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAG9C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,mBAAmB,SAAS,CAAC"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":"AACA,OAAO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,kHAAA,yBAAyB,OAAA;AACzB,8GAAA,qBAAqB,OAAA;AACrB,6GAAA,oBAAoB,OAAA;AACpB,oGAAA,WAAW,OAAA;AACX,0GAAA,iBAAiB,OAAA;AACjB,+GAAA,sBAAsB,OAAA;AAGxB,mDAAkD;AAAzC,wGAAA,MAAM,OAAA;AAEf,oCAAwE;AAA/D,4FAAA,IAAI,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAEvB,iEAAgE;AAAvD,sHAAA,iBAAiB,OAAA;AAG1B,oBAAoB;AACpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+CAA8C;AAArC,sGAAA,SAAS,OAAA;AAElB,uDAAsD;AAA7C,8GAAA,aAAa,OAAA;AAGtB,WAAW;AACX;;GAEG;AACH,yCAA8C;AAArC,sGAAA,YAAY,OAAA;AAErB,mBAAmB;AACnB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,mDAAkE;AAAzD,gHAAA,cAAc,OAAA","sourcesContent":["// Expo Router API\nimport { Navigator, Slot } from './views/Navigator';\n\nexport {\n useRouter,\n useUnstableGlobalHref,\n usePathname,\n useNavigationContainerRef,\n useGlobalSearchParams,\n useLocalSearchParams,\n useSegments,\n useRootNavigation,\n useRootNavigationState,\n} from './hooks';\n\nexport { router, Router } from './imperative-api';\n\nexport { Link, Redirect, LinkProps, WebAnchorProps } from './link/Link';\n\nexport { withLayoutContext } from './layouts/withLayoutContext';\nexport { Navigator, Slot };\n\n// Expo Router Views\nexport { ExpoRoot } from './ExpoRoot';\nexport { Unmatched } from './views/Unmatched';\nexport { ErrorBoundaryProps } from './views/Try';\nexport { ErrorBoundary } from './views/ErrorBoundary';\nexport { ScreenProps } from './useScreens';\n\n// Platform\n/**\n * @hidden\n */\nexport { SplashScreen } from './views/Splash';\n\n// React Navigation\nexport { useNavigation } from './useNavigation';\nexport { useFocusEffect, EffectCallback } from './useFocusEffect';\nexport { ResultState } from './fork/getStateFromPath';\n\nexport type * from './types';\n"]}
1
+ {"version":3,"file":"exports.js","sourceRoot":"","sources":["../src/exports.ts"],"names":[],"mappings":";;;AAAA,kBAAkB;AAClB,iDAAoD;AAmB3C,0FAnBA,qBAAS,OAmBA;AAAE,qFAnBA,gBAAI,OAmBA;AAjBxB,iCAUiB;AATf,kGAAA,SAAS,OAAA;AACT,8GAAA,qBAAqB,OAAA;AACrB,oGAAA,WAAW,OAAA;AACX,kHAAA,yBAAyB,OAAA;AACzB,8GAAA,qBAAqB,OAAA;AACrB,6GAAA,oBAAoB,OAAA;AACpB,oGAAA,WAAW,OAAA;AACX,0GAAA,iBAAiB,OAAA;AACjB,+GAAA,sBAAsB,OAAA;AAGxB,mDAAkD;AAAzC,wGAAA,MAAM,OAAA;AAEf,oCAAwE;AAA/D,4FAAA,IAAI,OAAA;AAAE,gGAAA,QAAQ,OAAA;AAEvB,iEAAgE;AAAvD,sHAAA,iBAAiB,OAAA;AAG1B,oBAAoB;AACpB,uCAAsC;AAA7B,oGAAA,QAAQ,OAAA;AACjB,+CAA8C;AAArC,sGAAA,SAAS,OAAA;AAElB,uDAAsD;AAA7C,8GAAA,aAAa,OAAA;AAGtB,WAAW;AACX;;GAEG;AACH,yCAA8C;AAArC,sGAAA,YAAY,OAAA;AAErB,mBAAmB;AACnB,iDAAgD;AAAvC,8GAAA,aAAa,OAAA;AACtB,mDAAkE;AAAzD,gHAAA,cAAc,OAAA","sourcesContent":["// Expo Router API\nimport { Navigator, Slot } from './views/Navigator';\n\nexport {\n useRouter,\n useUnstableGlobalHref,\n usePathname,\n useNavigationContainerRef,\n useGlobalSearchParams,\n useLocalSearchParams,\n useSegments,\n useRootNavigation,\n useRootNavigationState,\n} from './hooks';\n\nexport { router, Router } from './imperative-api';\n\nexport { Link, Redirect, LinkProps, WebAnchorProps } from './link/Link';\n\nexport { withLayoutContext } from './layouts/withLayoutContext';\nexport { Navigator, Slot };\n\n// Expo Router Views\nexport { ExpoRoot } from './ExpoRoot';\nexport { Unmatched } from './views/Unmatched';\nexport { ErrorBoundaryProps } from './views/Try';\nexport { ErrorBoundary } from './views/ErrorBoundary';\nexport type { ScreenProps } from './useScreens';\n\n// Platform\n/**\n * @hidden\n */\nexport { SplashScreen } from './views/Splash';\n\n// React Navigation\nexport { useNavigation } from './useNavigation';\nexport { useFocusEffect, EffectCallback } from './useFocusEffect';\nexport type { ResultState } from './fork/getStateFromPath';\n\nexport type * from './types';\n"]}
@@ -1,4 +1,4 @@
1
- import type { NavigationState } from '@react-navigation/core';
1
+ import type { NavigationState } from '@react-navigation/native';
2
2
  type HistoryRecord = {
3
3
  id: string;
4
4
  state: NavigationState;
@@ -1 +1 @@
1
- {"version":3,"file":"createMemoryHistory.d.ts","sourceRoot":"","sources":["../../src/fork/createMemoryHistory.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAG9D,KAAK,aAAa,GAAG;IAEnB,EAAE,EAAE,MAAM,CAAC;IAEX,KAAK,EAAE,eAAe,CAAC;IAEvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,mBAAmB;;eAiCpB,MAAM;;cAIW,MAAM;;;cAaJ,MAAM;eAAS,eAAe;;;cAmB3B,MAAM;eAAS,eAAe;;UAsCzD,MAAM;qBA2FK,MAAM,IAAI;EAiB9B"}
1
+ {"version":3,"file":"createMemoryHistory.d.ts","sourceRoot":"","sources":["../../src/fork/createMemoryHistory.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAGhE,KAAK,aAAa,GAAG;IAEnB,EAAE,EAAE,MAAM,CAAC;IAEX,KAAK,EAAE,eAAe,CAAC;IAEvB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,wBAAgB,mBAAmB;;eAiCpB,MAAM;;cAIW,MAAM;;;cAaJ,MAAM;eAAS,eAAe;;;cAmB3B,MAAM;eAAS,eAAe;;UAsCzD,MAAM;qBA2FK,MAAM,IAA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U,CAAC,CAAC;oBACnD,IAAI,EAAE,EAAE,EAAE,CAAC;gBACb,CAAC,CAAC;gBAEF,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;gBAChD,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACvB,CAAC,CAAC,CAAC;QACL,CAAC;QAED,gGAAgG;QAChG,iFAAiF;QACjF,4GAA4G;QAC5G,MAAM,CAAC,QAAoB;YACzB,MAAM,UAAU,GAAG,GAAG,EAAE;gBACtB,IAAI,OAAO,CAAC,MAAM,EAAE;oBAClB,wEAAwE;oBACxE,OAAO;iBACR;gBAED,QAAQ,EAAE,CAAC;YACb,CAAC,CAAC;YAEF,MAAM,CAAC,gBAAgB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;YAEhD,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAClE,CAAC;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAvND,kDAuNC","sourcesContent":["// Forked from React Navigation in order to use a custom `useLinking` function.\n// https://github.com/react-navigation/react-navigation/blob/6.x/packages/native/src/createMemoryHistory.tsx\n// Look for 'START OF FORK' comments\n// Forked behaviour:\n// - Remove custom management of the URL hash\nimport type { NavigationState } from '@react-navigation/core';\nimport { nanoid } from 'nanoid/non-secure';\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\nexport function 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 // Need to keep the hash part of the path if there was no previous history entry\n // or the previous history entry had the same path\n const pathWithHash = path;\n\n // ------- START OF FORK\n\n // if (!items.length || items.findIndex((item) => item.id === id) < 0) {\n // // There are two scenarios for creating an array with only one history record:\n // // - When loaded id not found in the items array, this function by default will replace\n // // the first item. We need to keep only the new updated object, otherwise it will break\n // // the page when navigating forward in history.\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 // pathWithHash = pathWithHash + location.hash;\n // items = [{ path: pathWithHash, state, id }];\n // index = 0;\n // } else {\n // if (items[index].path === path) {\n // pathWithHash = pathWithHash + location.hash;\n // }\n // items[index] = { path, state, id };\n // }\n\n // ------- END OF FORK\n\n window.history.replaceState({ id }, '', pathWithHash);\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 // To guard against unexpected navigation out of the app we will assume that browser history is only as deep as the length of our memory\n // history. If we don't have an item to navigate to then update our index and navigate as far as we can without taking the user out of the app.\n const nextIndex = index + n;\n const lastItemIndex = items.length - 1;\n if (n < 0 && !items[nextIndex]) {\n // Attempted to navigate beyond the first index. Negating the current index will align the browser history with the first item.\n n = -index;\n index = 0;\n } else if (n > 0 && nextIndex > lastItemIndex) {\n // Attempted to navigate past the last index. Calculate how many indices away from the last index and go there.\n n = lastItemIndex - index;\n index = lastItemIndex;\n } else {\n index = nextIndex;\n }\n\n if (n === 0) {\n return;\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<void>((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 id = window.history.state?.id;\n const currentIndex = items.findIndex((item) => item.id === id);\n\n // Fix createMemoryHistory.index variable's value\n // as it may go out of sync when navigating in the browser.\n index = Math.max(currentIndex, 0);\n\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"]}
1
+ {"version":3,"file":"createMemoryHistory.js","sourceRoot":"","sources":["../../src/fork/createMemoryHistory.ts"],"names":[],"mappings":";;;AAMA,kDAA2C;AAW3C,SAAgB,mBAAmB;IACjC,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,GAAoB,EAAE,CAAC;IAEhC,wCAAwC;IACxC,6FAA6F;IAC7F,MAAM,OAAO,GAA4D,EAAE,CAAC;IAE5E,MAAM,SAAS,GAAG,GAAG,EAAE;QACrB,gFAAgF;QAChF,uFAAuF;QACvF,oEAAoE;QACpE,OAAO,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE;YACrB,MAAM,EAAE,GAAG,EAAE,CAAC,EAAE,CAAC;YACjB,EAAE,CAAC,EAAE,GAAG,GAAG,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;IAEF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C;QAClE,CAAC;KACF,CAAC;IAEF,OAAO,OAAO,CAAC;AACjB,CAAC;AAvND,kDAuNC","sourcesContent":["// Forked from React Navigation in order to use a custom `useLinking` function.\n// https://github.com/react-navigation/react-navigation/blob/6.x/packages/native/src/createMemoryHistory.tsx\n// Look for 'START OF FORK' comments\n// Forked behavior:\n// - Remove custom management of the URL hash\nimport type { NavigationState } from '@react-navigation/native';\nimport { nanoid } from 'nanoid/non-secure';\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\nexport function 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 // Need to keep the hash part of the path if there was no previous history entry\n // or the previous history entry had the same path\n const pathWithHash = path;\n\n // ------- START OF FORK\n\n // if (!items.length || items.findIndex((item) => item.id === id) < 0) {\n // // There are two scenarios for creating an array with only one history record:\n // // - When loaded id not found in the items array, this function by default will replace\n // // the first item. We need to keep only the new updated object, otherwise it will break\n // // the page when navigating forward in history.\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 // pathWithHash = pathWithHash + location.hash;\n // items = [{ path: pathWithHash, state, id }];\n // index = 0;\n // } else {\n // if (items[index].path === path) {\n // pathWithHash = pathWithHash + location.hash;\n // }\n // items[index] = { path, state, id };\n // }\n\n // ------- END OF FORK\n\n window.history.replaceState({ id }, '', pathWithHash);\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 // To guard against unexpected navigation out of the app we will assume that browser history is only as deep as the length of our memory\n // history. If we don't have an item to navigate to then update our index and navigate as far as we can without taking the user out of the app.\n const nextIndex = index + n;\n const lastItemIndex = items.length - 1;\n if (n < 0 && !items[nextIndex]) {\n // Attempted to navigate beyond the first index. Negating the current index will align the browser history with the first item.\n n = -index;\n index = 0;\n } else if (n > 0 && nextIndex > lastItemIndex) {\n // Attempted to navigate past the last index. Calculate how many indices away from the last index and go there.\n n = lastItemIndex - index;\n index = lastItemIndex;\n } else {\n index = nextIndex;\n }\n\n if (n === 0) {\n return;\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<void>((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 id = window.history.state?.id;\n const currentIndex = items.findIndex((item) => item.id === id);\n\n // Fix createMemoryHistory.index variable's value\n // as it may go out of sync when navigating in the browser.\n index = Math.max(currentIndex, 0);\n\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"]}
@@ -1,4 +1,4 @@
1
1
  /// <reference types="react" />
2
- import type { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
2
+ import type { NavigationContainerRef, ParamListBase } from '@react-navigation/native';
3
3
  export declare function useBackButton(_: React.RefObject<NavigationContainerRef<ParamListBase>>): void;
4
4
  //# sourceMappingURL=useBackButton.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBackButton.d.ts","sourceRoot":"","sources":["../../src/fork/useBackButton.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEpF,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,QAGtF"}
1
+ {"version":3,"file":"useBackButton.d.ts","sourceRoot":"","sources":["../../src/fork/useBackButton.ts"],"names":[],"mappings":";AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEtF,wBAAgB,aAAa,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,QAGtF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useBackButton.js","sourceRoot":"","sources":["../../src/fork/useBackButton.ts"],"names":[],"mappings":";;;AAKA,SAAgB,aAAa,CAAC,CAAyD;IACrF,QAAQ;IACR,sCAAsC;AACxC,CAAC;AAHD,sCAGC","sourcesContent":["/*\n * This file is unchanged, except for removing eslint comments\n */\nimport type { NavigationContainerRef, ParamListBase } from '@react-navigation/core';\n\nexport function useBackButton(_: React.RefObject<NavigationContainerRef<ParamListBase>>) {\n // No-op\n // BackHandler is not available on web\n}\n"]}
1
+ {"version":3,"file":"useBackButton.js","sourceRoot":"","sources":["../../src/fork/useBackButton.ts"],"names":[],"mappings":";;;AAKA,SAAgB,aAAa,CAAC,CAAyD;IACrF,QAAQ;IACR,sCAAsC;AACxC,CAAC;AAHD,sCAGC","sourcesContent":["/*\n * This file is unchanged, except for removing eslint comments\n */\nimport type { NavigationContainerRef, ParamListBase } from '@react-navigation/native';\n\nexport function useBackButton(_: React.RefObject<NavigationContainerRef<ParamListBase>>) {\n // No-op\n // BackHandler is not available on web\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * This file is unchanged, except for removing eslint comments
3
3
  */
4
- import type { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
4
+ import type { NavigationContainerRef, ParamListBase } from '@react-navigation/native';
5
5
  import * as React from 'react';
6
6
  export declare function useBackButton(ref: React.RefObject<NavigationContainerRef<ParamListBase>>): void;
7
7
  //# sourceMappingURL=useBackButton.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"useBackButton.native.d.ts","sourceRoot":"","sources":["../../src/fork/useBackButton.native.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,QAoBxF"}
1
+ {"version":3,"file":"useBackButton.native.d.ts","sourceRoot":"","sources":["../../src/fork/useBackButton.native.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,wBAAgB,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,QAoBxF"}
@@ -1 +1 @@
1
- {"version":3,"file":"useBackButton.native.js","sourceRoot":"","sources":["../../src/fork/useBackButton.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,6CAA+B;AAC/B,+CAA2C;AAE3C,SAAgB,aAAa,CAAC,GAA2D;IACvF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,YAAY,GAAG,0BAAW,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC1E,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC;YAE/B,IAAI,UAAU,IAAI,IAAI,EAAE;gBACtB,OAAO,KAAK,CAAC;aACd;YAED,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE;gBAC1B,UAAU,CAAC,MAAM,EAAE,CAAC;gBAEpB,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AACZ,CAAC;AApBD,sCAoBC","sourcesContent":["/**\n * This file is unchanged, except for removing eslint comments\n */\nimport type { NavigationContainerRef, ParamListBase } from '@react-navigation/core';\nimport * as React from 'react';\nimport { BackHandler } from 'react-native';\n\nexport function useBackButton(ref: React.RefObject<NavigationContainerRef<ParamListBase>>) {\n React.useEffect(() => {\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n const navigation = ref.current;\n\n if (navigation == null) {\n return false;\n }\n\n if (navigation.canGoBack()) {\n navigation.goBack();\n\n return true;\n }\n\n return false;\n });\n\n return () => subscription.remove();\n }, [ref]);\n}\n"]}
1
+ {"version":3,"file":"useBackButton.native.js","sourceRoot":"","sources":["../../src/fork/useBackButton.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,6CAA+B;AAC/B,+CAA2C;AAE3C,SAAgB,aAAa,CAAC,GAA2D;IACvF,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,MAAM,YAAY,GAAG,0BAAW,CAAC,gBAAgB,CAAC,mBAAmB,EAAE,GAAG,EAAE;YAC1E,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC;YAE/B,IAAI,UAAU,IAAI,IAAI,EAAE;gBACtB,OAAO,KAAK,CAAC;aACd;YAED,IAAI,UAAU,CAAC,SAAS,EAAE,EAAE;gBAC1B,UAAU,CAAC,MAAM,EAAE,CAAC;gBAEpB,OAAO,IAAI,CAAC;aACb;YAED,OAAO,KAAK,CAAC;QACf,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,CAAC;IACrC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;AACZ,CAAC;AApBD,sCAoBC","sourcesContent":["/**\n * This file is unchanged, except for removing eslint comments\n */\nimport type { NavigationContainerRef, ParamListBase } from '@react-navigation/native';\nimport * as React from 'react';\nimport { BackHandler } from 'react-native';\n\nexport function useBackButton(ref: React.RefObject<NavigationContainerRef<ParamListBase>>) {\n React.useEffect(() => {\n const subscription = BackHandler.addEventListener('hardwareBackPress', () => {\n const navigation = ref.current;\n\n if (navigation == null) {\n return false;\n }\n\n if (navigation.canGoBack()) {\n navigation.goBack();\n\n return true;\n }\n\n return false;\n });\n\n return () => subscription.remove();\n }, [ref]);\n}\n"]}
@@ -1,5 +1,4 @@
1
- import type { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
2
- import type { DocumentTitleOptions } from '@react-navigation/native';
1
+ import type { DocumentTitleOptions, NavigationContainerRef, ParamListBase } from '@react-navigation/native';
3
2
  import * as React from 'react';
4
3
  /**
5
4
  * Set the document title for the active screen
@@ -1 +1 @@
1
- {"version":3,"file":"useDocumentTitle.d.ts","sourceRoot":"","sources":["../../src/fork/useDocumentTitle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACpF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,SAA6D,GAC9D,GAAE,oBAAyB,QAqB7B"}
1
+ {"version":3,"file":"useDocumentTitle.d.ts","sourceRoot":"","sources":["../../src/fork/useDocumentTitle.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,oBAAoB,EACpB,sBAAsB,EACtB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAI/B;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,SAA6D,GAC9D,GAAE,oBAAyB,QAqB7B"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDocumentTitle.js","sourceRoot":"","sources":["../../src/fork/useDocumentTitle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,6CAA+B;AAE/B,uDAAuD;AAEvD;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,GAA2D,EAC3D,EACE,OAAO,GAAG,IAAI,EACd,SAAS,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,IAAI,MACrC,EAAE;IAE5B,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QAED,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC;QAE/B,IAAI,UAAU,EAAE;YACd,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,iBAAiB,EAAE,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;YAEtF,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;SACxB;QAED,OAAO,UAAU,EAAE,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;YAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;YAEvE,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA1BD,4CA0BC","sourcesContent":["/*\n * This file is unchanged, except for fixing imports and removing eslint comments\n */\nimport type { NavigationContainerRef, ParamListBase } from '@react-navigation/core';\nimport type { DocumentTitleOptions } from '@react-navigation/native';\nimport * as React from 'react';\n\n// import type { DocumentTitleOptions } from './types';\n\n/**\n * Set the document title for the active screen\n */\nexport function useDocumentTitle(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n formatter = (options, route) => options?.title ?? route?.name,\n }: DocumentTitleOptions = {}\n) {\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n\n if (navigation) {\n const title = formatter(navigation.getCurrentOptions(), navigation.getCurrentRoute());\n\n document.title = title;\n }\n\n return navigation?.addListener('options', (e) => {\n const title = formatter(e.data.options, navigation?.getCurrentRoute());\n\n document.title = title;\n });\n });\n}\n"]}
1
+ {"version":3,"file":"useDocumentTitle.js","sourceRoot":"","sources":["../../src/fork/useDocumentTitle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAQA,6CAA+B;AAE/B,uDAAuD;AAEvD;;GAEG;AACH,SAAgB,gBAAgB,CAC9B,GAA2D,EAC3D,EACE,OAAO,GAAG,IAAI,EACd,SAAS,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,KAAK,IAAI,KAAK,EAAE,IAAI,MACrC,EAAE;IAE5B,KAAK,CAAC,SAAS,CAAC,GAAG,EAAE;QACnB,IAAI,CAAC,OAAO,EAAE;YACZ,OAAO;SACR;QAED,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,CAAC;QAE/B,IAAI,UAAU,EAAE;YACd,MAAM,KAAK,GAAG,SAAS,CAAC,UAAU,CAAC,iBAAiB,EAAE,EAAE,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;YAEtF,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;SACxB;QAED,OAAO,UAAU,EAAE,WAAW,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE;YAC9C,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;YAEvE,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QACzB,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AA1BD,4CA0BC","sourcesContent":["/*\n * This file is unchanged, except for fixing imports and removing eslint comments\n */\nimport type {\n DocumentTitleOptions,\n NavigationContainerRef,\n ParamListBase,\n} from '@react-navigation/native';\nimport * as React from 'react';\n\n// import type { DocumentTitleOptions } from './types';\n\n/**\n * Set the document title for the active screen\n */\nexport function useDocumentTitle(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n formatter = (options, route) => options?.title ?? route?.name,\n }: DocumentTitleOptions = {}\n) {\n React.useEffect(() => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n\n if (navigation) {\n const title = formatter(navigation.getCurrentOptions(), navigation.getCurrentRoute());\n\n document.title = title;\n }\n\n return navigation?.addListener('options', (e) => {\n const title = formatter(e.data.options, navigation?.getCurrentRoute());\n\n document.title = title;\n });\n });\n}\n"]}
@@ -1,5 +1,4 @@
1
- import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/core';
2
- import { LinkingOptions } from '@react-navigation/native';
1
+ import { LinkingOptions, type NavigationContainerRef, type ParamListBase } from '@react-navigation/native';
3
2
  import * as React from 'react';
4
3
  /**
5
4
  * Run async function in series as it's called.
@@ -12,24 +11,24 @@ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<P
12
11
  index: number;
13
12
  routeNames: string[];
14
13
  history?: unknown[] | undefined;
15
- routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
14
+ routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
16
15
  type: string;
17
16
  stale: false;
18
17
  }>, "stale" | "routes">> & Readonly<{
19
18
  stale?: true | undefined;
20
- routes: import("@react-navigation/core").PartialRoute<import("@react-navigation/core").Route<string, object | undefined>>[];
19
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
21
20
  }> & {
22
21
  state?: (Partial<Omit<Readonly<{
23
22
  key: string;
24
23
  index: number;
25
24
  routeNames: string[];
26
25
  history?: unknown[] | undefined;
27
- routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
26
+ routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
28
27
  type: string;
29
28
  stale: false;
30
29
  }>, "stale" | "routes">> & Readonly<{
31
30
  stale?: true | undefined;
32
- routes: import("@react-navigation/core").PartialRoute<import("@react-navigation/core").Route<string, object | undefined>>[];
31
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
33
32
  }> & any) | undefined;
34
33
  }) | undefined>;
35
34
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA+C/B;;GAEG;AACH,eAAO,MAAM,MAAM,OAAQ,MAAM,QAAQ,IAAI,CAAC,eAM7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EAmVtE"}
1
+ {"version":3,"file":"useLinking.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EAKd,KAAK,sBAAsB,EAE3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAElC,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AA+C/B;;GAEG;AACH,eAAO,MAAM,MAAM,OAAQ,MAAM,QAAQ,IAAI,CAAC,eAM7C,CAAC;AAIF,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAE7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,MAAM,EACN,gBAA0C,EAC1C,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EAmVtE"}
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.useLinking = exports.series = void 0;
30
- const core_1 = require("@react-navigation/core");
30
+ const native_1 = require("@react-navigation/native");
31
31
  const fast_deep_equal_1 = __importDefault(require("fast-deep-equal"));
32
32
  const React = __importStar(require("react"));
33
33
  const createMemoryHistory_1 = require("./createMemoryHistory");
@@ -73,8 +73,8 @@ const series = (cb) => {
73
73
  };
74
74
  exports.series = series;
75
75
  const linkingHandlers = [];
76
- function useLinking(ref, { enabled = true, config, getStateFromPath = core_1.getStateFromPath, getPathFromState = core_1.getPathFromState, getActionFromState = core_1.getActionFromState, }, onUnhandledLinking) {
77
- const independent = (0, core_1.useNavigationIndependentTree)();
76
+ function useLinking(ref, { enabled = true, config, getStateFromPath = native_1.getStateFromPath, getPathFromState = native_1.getPathFromState, getActionFromState = native_1.getActionFromState, }, onUnhandledLinking) {
77
+ const independent = (0, native_1.useNavigationIndependentTree)();
78
78
  React.useEffect(() => {
79
79
  if (process.env.NODE_ENV === 'production') {
80
80
  return undefined;
@@ -220,7 +220,7 @@ function useLinking(ref, { enabled = true, config, getStateFromPath = core_1.get
220
220
  if (route?.path) {
221
221
  const stateForPath = getStateFromPathRef.current(route.path, configRef.current);
222
222
  if (stateForPath) {
223
- const focusedRoute = (0, core_1.findFocusedRoute)(stateForPath);
223
+ const focusedRoute = (0, native_1.findFocusedRoute)(stateForPath);
224
224
  if (focusedRoute &&
225
225
  focusedRoute.name === route.name &&
226
226
  (0, fast_deep_equal_1.default)({ ...focusedRoute.params }, { ...route.params })) {
@@ -253,7 +253,7 @@ function useLinking(ref, { enabled = true, config, getStateFromPath = core_1.get
253
253
  // This will allow the initial state to be in the history entry
254
254
  const state = ref.current.getRootState();
255
255
  if (state) {
256
- const route = (0, core_1.findFocusedRoute)(state);
256
+ const route = (0, native_1.findFocusedRoute)(state);
257
257
  const path = getPathForRoute(route, state);
258
258
  if (previousStateRef.current === undefined) {
259
259
  previousStateRef.current = state;
@@ -273,7 +273,7 @@ function useLinking(ref, { enabled = true, config, getStateFromPath = core_1.get
273
273
  return;
274
274
  }
275
275
  const pendingPath = pendingPopStatePathRef.current;
276
- const route = (0, core_1.findFocusedRoute)(state);
276
+ const route = (0, native_1.findFocusedRoute)(state);
277
277
  const path = getPathForRoute(route, state);
278
278
  previousStateRef.current = state;
279
279
  pendingPopStatePathRef.current = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.js","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDASgC;AAEhC,sEAAsC;AACtC,6CAA+B;AAE/B,+DAA4D;AAC5D,iFAAsE;AAItE;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CACxB,CAAgB,EAChB,CAAgB,EACgB,EAAE;IAClC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE;QACzD,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;KAC/B;IAED,uFAAuF;IACvF,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IACtE,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEtE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAClD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAElD,sDAAsD;IACtD,gCAAgC;IAChC,iCAAiC;IACjC,yCAAyC;IACzC,mCAAmC;IACnC,IACE,cAAc,KAAK,cAAc;QACjC,MAAM,CAAC,GAAG,KAAK,MAAM,CAAC,GAAG;QAC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AM,EAAC,aAAa,CAAC,CAAC,CAAC;IAClE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAE5B,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AA5VD,gCA4VC","sourcesContent":["import {\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type NavigationState,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/core';\nimport { LinkingOptions } from '@react-navigation/native';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { ServerContext } from '../global-state/serverLocationContext';\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 */\nexport const series = (cb: () => Promise<void>) => {\n let queue = Promise.resolve();\n const callback = () => {\n queue = queue.then(cb);\n };\n return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\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 validateRoutesNotExistInRootState = React.useCallback(\n (state: ResultState) => {\n const navigation = ref.current;\n const rootState = navigation?.getRootState();\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 return state?.routes.some((r) => !rootState?.routeNames.includes(r.name));\n },\n [ref]\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 ?? (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 // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\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 { location } = window;\n\n const path = location.pathname + location.search + location.hash;\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 // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\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 if (validateRoutesNotExistInRootState(state)) {\n return;\n }\n\n if (index > previousIndex) {\n const action = getActionFromStateRef.current(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}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : 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, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\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 let path;\n\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(route.path, configRef.current);\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 path = route.path;\n }\n }\n }\n\n if (path == null) {\n path = getPathFromStateRef.current(state, configRef.current);\n }\n\n // START FORK - ExpoRouter manually handles hashes\n // const previousRoute = previousStateRef.current\n // ? findFocusedRoute(previousStateRef.current)\n // : undefined;\n\n // Preserve the hash if the route didn't change\n // if (\n // previousRoute &&\n // route &&\n // 'key' in previousRoute &&\n // 'key' in route &&\n // previousRoute.key === route.key\n // ) {\n // path = path + location.hash;\n // }\n // END FORK\n\n return path;\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(previousState, state);\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 ? focusedState.history.length : 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 (\n nextIndex !== -1 &&\n nextIndex < currentIndex &&\n // We should only go back if the entry exists and it's less than current index\n history.get(nextIndex - currentIndex)\n ) {\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 {\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 }, [enabled, history, ref]);\n\n return {\n getInitialState,\n };\n}\n"]}
1
+ {"version":3,"file":"useLinking.js","sourceRoot":"","sources":["../../src/fork/useLinking.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAUkC;AAClC,sEAAsC;AACtC,6CAA+B;AAE/B,+DAA4D;AAC5D,iFAAsE;AAItE;;;GAGG;AACH,MAAM,iBAAiB,GAAG,CACxB,CAAgB,EAChB,CAAgB,EACgB,EAAE;IAClC,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,KAAK,SAAS,IAAI,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,GAAG,EAAE;QACzD,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;KAC/B;IAED,uFAAuF;IACvF,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IACtE,MAAM,cAAc,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;IAEtE,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAEjC,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAClD,MAAM,WAAW,GAAG,MAAM,CAAC,KAAsB,CAAC;IAElD,sDAAsD;IACtD,gCAAgC;IAChC,iCAAiC;IACjC,yCA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AC/F,0DAA0D;QAC1D,qGAAqG;QACrG,OAAO,GAAG,CAAC,OAAO,EAAE,WAAW,CAAC,OAAO,EAAE,IAAA,cAAM,EAAC,aAAa,CAAC,CAAC,CAAC;IAClE,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;IAE5B,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AA5VD,gCA4VC","sourcesContent":["import {\n LinkingOptions,\n findFocusedRoute,\n getActionFromState as getActionFromStateDefault,\n getPathFromState as getPathFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type NavigationState,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport isEqual from 'fast-deep-equal';\nimport * as React from 'react';\n\nimport { createMemoryHistory } from './createMemoryHistory';\nimport { ServerContext } from '../global-state/serverLocationContext';\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 */\nexport const series = (cb: () => Promise<void>) => {\n let queue = Promise.resolve();\n const callback = () => {\n queue = queue.then(cb);\n };\n return callback;\n};\n\nconst linkingHandlers: symbol[] = [];\n\ntype Options = LinkingOptions<ParamListBase>;\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n config,\n getStateFromPath = getStateFromPathDefault,\n getPathFromState = getPathFromStateDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\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 validateRoutesNotExistInRootState = React.useCallback(\n (state: ResultState) => {\n const navigation = ref.current;\n const rootState = navigation?.getRootState();\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 return state?.routes.some((r) => !rootState?.routeNames.includes(r.name));\n },\n [ref]\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 ?? (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 // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\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 { location } = window;\n\n const path = location.pathname + location.search + location.hash;\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 // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(path);\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 if (validateRoutesNotExistInRootState(state)) {\n return;\n }\n\n if (index > previousIndex) {\n const action = getActionFromStateRef.current(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}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : 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, onUnhandledLinking, ref, validateRoutesNotExistInRootState]);\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 let path;\n\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(route.path, configRef.current);\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 path = route.path;\n }\n }\n }\n\n if (path == null) {\n path = getPathFromStateRef.current(state, configRef.current);\n }\n\n // START FORK - ExpoRouter manually handles hashes\n // const previousRoute = previousStateRef.current\n // ? findFocusedRoute(previousStateRef.current)\n // : undefined;\n\n // Preserve the hash if the route didn't change\n // if (\n // previousRoute &&\n // route &&\n // 'key' in previousRoute &&\n // 'key' in route &&\n // previousRoute.key === route.key\n // ) {\n // path = path + location.hash;\n // }\n // END FORK\n\n return path;\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(previousState, state);\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 ? focusedState.history.length : 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 (\n nextIndex !== -1 &&\n nextIndex < currentIndex &&\n // We should only go back if the entry exists and it's less than current index\n history.get(nextIndex - currentIndex)\n ) {\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 {\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 }, [enabled, history, ref]);\n\n return {\n getInitialState,\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/core';
1
+ import { type NavigationContainerRef, type ParamListBase } from '@react-navigation/native';
2
2
  import { LinkingOptions } from '@react-navigation/native';
3
3
  import * as React from 'react';
4
4
  type Options = LinkingOptions<ParamListBase>;
@@ -8,24 +8,24 @@ export declare function useLinking(ref: React.RefObject<NavigationContainerRef<P
8
8
  index: number;
9
9
  routeNames: string[];
10
10
  history?: unknown[] | undefined;
11
- routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
11
+ routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
12
12
  type: string;
13
13
  stale: false;
14
14
  }>, "stale" | "routes">> & Readonly<{
15
15
  stale?: true | undefined;
16
- routes: import("@react-navigation/core").PartialRoute<import("@react-navigation/core").Route<string, object | undefined>>[];
16
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
17
17
  }> & {
18
18
  state?: (Partial<Omit<Readonly<{
19
19
  key: string;
20
20
  index: number;
21
21
  routeNames: string[];
22
22
  history?: unknown[] | undefined;
23
- routes: import("@react-navigation/core").NavigationRoute<ParamListBase, string>[];
23
+ routes: import("@react-navigation/native").NavigationRoute<ParamListBase, string>[];
24
24
  type: string;
25
25
  stale: false;
26
26
  }>, "stale" | "routes">> & Readonly<{
27
27
  stale?: true | undefined;
28
- routes: import("@react-navigation/core").PartialRoute<import("@react-navigation/core").Route<string, object | undefined>>[];
28
+ routes: import("@react-navigation/native").PartialRoute<import("@react-navigation/native").Route<string, object | undefined>>[];
29
29
  }> & any) | undefined;
30
30
  }) | undefined>;
31
31
  };
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAEnB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EA+JtE"}
1
+ {"version":3,"file":"useLinking.native.d.ts","sourceRoot":"","sources":["../../src/fork/useLinking.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAO/B,KAAK,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,CAAC;AAI7C,wBAAgB,UAAU,CACxB,GAAG,EAAE,KAAK,CAAC,SAAS,CAAC,sBAAsB,CAAC,aAAa,CAAC,CAAC,EAC3D,EACE,OAAc,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAQI,EACJ,SAmBC,EACD,gBAA0C,EAC1C,kBAA8C,GAC/C,EAAE,OAAO,EACV,kBAAkB,EAAE,CAAC,mBAAmB,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;EA+JtE"}
@@ -24,7 +24,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.useLinking = void 0;
27
- const core_1 = require("@react-navigation/core");
27
+ const native_1 = require("@react-navigation/native");
28
28
  const React = __importStar(require("react"));
29
29
  const react_native_1 = require("react-native");
30
30
  const extractPathFromURL_1 = require("./extractPathFromURL");
@@ -51,8 +51,8 @@ function useLinking(ref, { enabled = true, prefixes, filter, config, getInitialU
51
51
  removeEventListener?.('url', callback);
52
52
  }
53
53
  };
54
- }, getStateFromPath = core_1.getStateFromPath, getActionFromState = core_1.getActionFromState, }, onUnhandledLinking) {
55
- const independent = (0, core_1.useNavigationIndependentTree)();
54
+ }, getStateFromPath = native_1.getStateFromPath, getActionFromState = native_1.getActionFromState, }, onUnhandledLinking) {
55
+ const independent = (0, native_1.useNavigationIndependentTree)();
56
56
  React.useEffect(() => {
57
57
  if (process.env.NODE_ENV === 'production') {
58
58
  return undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"useLinking.native.js","sourceRoot":"","sources":["../../src/fork/useLinking.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAMgC;AAEhC,6CAA+B;AAC/B,+CAAiD;AAEjD,6DAA8D;AAM9D,MAAM,eAAe,GAAa,EAAE,CAAC;AAErC,SAAgB,UAAU,CACxB,GAA2D,EAC3D,EACE,OAAO,GAAG,IAAI,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAAa,GAAG,GAAG,EAAE,CACnB,OAAO,CAAC,IAAI,CAAC;IACX,sBAAO,CAAC,aAAa,EAAE;IACvB,IAAI,OAAO,CAAY,CAAC,OAAO,EAAE,EAAE;QACjC,wDAAwD;QACxD,uEAAuE;Q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AI;wBACF,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;qBAC7B;oBAAC,OAAO,CAAC,EAAE;wBACV,uCAAuC;wBACvC,6FAA6F;wBAC7F,OAAO,CAAC,IAAI,CACV,qDAAqD,GAAG,MACtD,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,IAAI,IAAI,IAAI,SAAS,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CACrE,EAAE,CACH,CAAC;qBACH;iBACF;qBAAM;oBACL,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;iBAC7B;aACF;QACH,CAAC,CAAC;QAEF,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC,EAAE,CAAC,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,QAAQ,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC,CAAC;IAE7E,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AAtMD,gCAsMC","sourcesContent":["import {\n getActionFromState as getActionFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/core';\nimport { LinkingOptions } from '@react-navigation/native';\nimport * as React from 'react';\nimport { Linking, Platform } from 'react-native';\n\nimport { extractExpoPathFromURL } from './extractPathFromURL';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\ntype Options = LinkingOptions<ParamListBase>;\n\nconst linkingHandlers: symbol[] = [];\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n prefixes,\n filter,\n config,\n getInitialURL = () =>\n Promise.race([\n Linking.getInitialURL(),\n new Promise<undefined>((resolve) => {\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(resolve, 150);\n }),\n ]),\n subscribe = (listener) => {\n const callback = ({ url }: { url: string }) => listener(url);\n\n const subscription = Linking.addEventListener('url', callback) as\n | { remove(): void }\n | undefined;\n\n // Storing this in a local variable stops Jest from complaining about import after teardown\n // @ts-expect-error: removeEventListener is not present in newer RN versions\n const removeEventListener = Linking.removeEventListener?.bind(Linking);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n if (subscription?.remove) {\n subscription.remove();\n } else {\n removeEventListener?.('url', callback);\n }\n };\n },\n getStateFromPath = getStateFromPathDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\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 Platform.OS === 'android'\n ? \"- You have set 'android:launchMode=singleTask' in the '<activity />' section of the 'AndroidManifest.xml' file to avoid launching multiple instances\"\n : '',\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 // 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 prefixesRef = React.useRef(prefixes);\n const filterRef = React.useRef(filter);\n const configRef = React.useRef(config);\n const getInitialURLRef = React.useRef(getInitialURL);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n prefixesRef.current = prefixes;\n filterRef.current = filter;\n configRef.current = config;\n getInitialURLRef.current = getInitialURL;\n getStateFromPathRef.current = getStateFromPath;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const getStateFromURL = React.useCallback(\n (url: string | null | undefined) => {\n if (!url || (filterRef.current && !filterRef.current(url))) {\n return undefined;\n }\n\n const path = extractExpoPathFromURL(prefixesRef.current, url);\n\n return path !== undefined ? getStateFromPathRef.current(path, configRef.current) : undefined;\n },\n\n []\n );\n\n const getInitialState = React.useCallback(() => {\n let state: ResultState | undefined;\n\n if (enabledRef.current) {\n const url = getInitialURLRef.current();\n\n if (url != null) {\n if (typeof url !== 'string') {\n return url.then((url) => {\n const state = getStateFromURL(url);\n\n if (typeof url === 'string') {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n }\n\n return state;\n });\n } else {\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n }\n }\n\n state = getStateFromURL(url);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(state) : state);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n }, [getStateFromURL, onUnhandledLinking, prefixes]);\n\n React.useEffect(() => {\n const listener = (url: string) => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n const state = navigation ? getStateFromURL(url) : undefined;\n\n if (navigation && state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n const rootState = navigation.getRootState();\n if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {\n return;\n }\n\n const action = getActionFromStateRef.current(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 '${url}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n }\n };\n\n return subscribe(listener);\n }, [enabled, getStateFromURL, onUnhandledLinking, prefixes, ref, subscribe]);\n\n return {\n getInitialState,\n };\n}\n"]}
1
+ {"version":3,"file":"useLinking.native.js","sourceRoot":"","sources":["../../src/fork/useLinking.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAMkC;AAElC,6CAA+B;AAC/B,+CAAiD;AAEjD,6DAA8D;AAM9D,MAAM,eAAe,GAAa,EAAE,CAAC;AAErC,SAAgB,UAAU,CACxB,GAA2D,EAC3D,EACE,OAAO,GAAG,IAAI,EACd,QAAQ,EACR,MAAM,EACN,MAAM,EACN,aAAa,GAAG,GAAG,EAAE,CACnB,OAAO,CAAC,IAAI,CAAC;IACX,sBAAO,CAAC,aAAa,EAAE;IACvB,IAAI,OAAO,CAAY,CAAC,OAAO,EAAE,EAAE;QACjC,wDAAwD;QACxD,uEAAuE;QACvE,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;IAC3B,CAAC,CAAC;CACH,CAAC,EACJ,SAAS,GAAG,CAAC,QAAQ,EAAE,EAAE;IACvB,MAAM,QAAQ,GAAG,CAAC,EAAE,GAAG,EAAmB,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAE7D,MAAM,YAAY,GAAG,sBAAO,CAAC,gBAAgB,CAAC,KAAK,EAAE,QAAQ,CAEhD,CAAC;IAEd,2FAA2F;IAC3F,4EAA4E;IAC5E,MAAM,mBAAmB,GAAG,sBAAO,CAAC,mBAAmB,EAAE,IAAI,CAAC,sBAAO,CAAC,CAAC;IAEvE,OAAO,GAAG,EAAE;QACV,2FAA2F;QAC3F,IAAI,YAAY,EAAE,MAAM,EAAE;YACxB,YAAY,CAAC,MAAM,EAAE,CAAC;SACvB;aAAM;YACL,mBAA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AAC,CAAC,CAAC;IAE7E,OAAO;QACL,eAAe;KAChB,CAAC;AACJ,CAAC;AAtMD,gCAsMC","sourcesContent":["import {\n getActionFromState as getActionFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n type NavigationContainerRef,\n type ParamListBase,\n useNavigationIndependentTree,\n} from '@react-navigation/native';\nimport { LinkingOptions } from '@react-navigation/native';\nimport * as React from 'react';\nimport { Linking, Platform } from 'react-native';\n\nimport { extractExpoPathFromURL } from './extractPathFromURL';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\ntype Options = LinkingOptions<ParamListBase>;\n\nconst linkingHandlers: symbol[] = [];\n\nexport function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n enabled = true,\n prefixes,\n filter,\n config,\n getInitialURL = () =>\n Promise.race([\n Linking.getInitialURL(),\n new Promise<undefined>((resolve) => {\n // Timeout in 150ms if `getInitialState` doesn't resolve\n // Workaround for https://github.com/facebook/react-native/issues/25675\n setTimeout(resolve, 150);\n }),\n ]),\n subscribe = (listener) => {\n const callback = ({ url }: { url: string }) => listener(url);\n\n const subscription = Linking.addEventListener('url', callback) as\n | { remove(): void }\n | undefined;\n\n // Storing this in a local variable stops Jest from complaining about import after teardown\n // @ts-expect-error: removeEventListener is not present in newer RN versions\n const removeEventListener = Linking.removeEventListener?.bind(Linking);\n\n return () => {\n // https://github.com/facebook/react-native/commit/6d1aca806cee86ad76de771ed3a1cc62982ebcd7\n if (subscription?.remove) {\n subscription.remove();\n } else {\n removeEventListener?.('url', callback);\n }\n };\n },\n getStateFromPath = getStateFromPathDefault,\n getActionFromState = getActionFromStateDefault,\n }: Options,\n onUnhandledLinking: (lastUnhandledLining: string | undefined) => void\n) {\n const independent = useNavigationIndependentTree();\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 Platform.OS === 'android'\n ? \"- You have set 'android:launchMode=singleTask' in the '<activity />' section of the 'AndroidManifest.xml' file to avoid launching multiple instances\"\n : '',\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 // 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 prefixesRef = React.useRef(prefixes);\n const filterRef = React.useRef(filter);\n const configRef = React.useRef(config);\n const getInitialURLRef = React.useRef(getInitialURL);\n const getStateFromPathRef = React.useRef(getStateFromPath);\n const getActionFromStateRef = React.useRef(getActionFromState);\n\n React.useEffect(() => {\n enabledRef.current = enabled;\n prefixesRef.current = prefixes;\n filterRef.current = filter;\n configRef.current = config;\n getInitialURLRef.current = getInitialURL;\n getStateFromPathRef.current = getStateFromPath;\n getActionFromStateRef.current = getActionFromState;\n });\n\n const getStateFromURL = React.useCallback(\n (url: string | null | undefined) => {\n if (!url || (filterRef.current && !filterRef.current(url))) {\n return undefined;\n }\n\n const path = extractExpoPathFromURL(prefixesRef.current, url);\n\n return path !== undefined ? getStateFromPathRef.current(path, configRef.current) : undefined;\n },\n\n []\n );\n\n const getInitialState = React.useCallback(() => {\n let state: ResultState | undefined;\n\n if (enabledRef.current) {\n const url = getInitialURLRef.current();\n\n if (url != null) {\n if (typeof url !== 'string') {\n return url.then((url) => {\n const state = getStateFromURL(url);\n\n if (typeof url === 'string') {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n }\n\n return state;\n });\n } else {\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n }\n }\n\n state = getStateFromURL(url);\n }\n\n const thenable = {\n then(onfulfilled?: (state: ResultState | undefined) => void) {\n return Promise.resolve(onfulfilled ? onfulfilled(state) : state);\n },\n catch() {\n return thenable;\n },\n };\n\n return thenable as PromiseLike<ResultState | undefined>;\n }, [getStateFromURL, onUnhandledLinking, prefixes]);\n\n React.useEffect(() => {\n const listener = (url: string) => {\n if (!enabled) {\n return;\n }\n\n const navigation = ref.current;\n const state = navigation ? getStateFromURL(url) : undefined;\n\n if (navigation && state) {\n // If the link were handled, it gets cleared in NavigationContainer\n onUnhandledLinking(extractExpoPathFromURL(prefixes, url));\n const rootState = navigation.getRootState();\n if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {\n return;\n }\n\n const action = getActionFromStateRef.current(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 '${url}': ${\n typeof e === 'object' && e != null && 'message' in e ? e.message : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n }\n };\n\n return subscribe(listener);\n }, [enabled, getStateFromURL, onUnhandledLinking, prefixes, ref, subscribe]);\n\n return {\n getInitialState,\n };\n}\n"]}
@@ -409,8 +409,17 @@ function getLayoutNode(node, options) {
409
409
  let initialRouteName = childMatchingGroup?.route;
410
410
  const loaded = node.loadRoute();
411
411
  if (loaded?.unstable_settings) {
412
- // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.
413
- initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;
412
+ try {
413
+ // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.
414
+ initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;
415
+ }
416
+ catch (error) {
417
+ if (error instanceof Error) {
418
+ if (!error.message.match(/You cannot dot into a client module/)) {
419
+ throw error;
420
+ }
421
+ }
422
+ }
414
423
  if (groupName) {
415
424
  // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.
416
425
  const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;
@@ -449,8 +458,17 @@ function crawlAndAppendInitialRoutesAndEntryFiles(node, options, entryPoints = [
449
458
  if (!options.internal_stripLoadRoute) {
450
459
  const loaded = node.loadRoute();
451
460
  if (loaded?.unstable_settings) {
452
- // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.
453
- initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;
461
+ try {
462
+ // Allow unstable_settings={ initialRouteName: '...' } to override the default initial route name.
463
+ initialRouteName = loaded.unstable_settings.initialRouteName ?? initialRouteName;
464
+ }
465
+ catch (error) {
466
+ if (error instanceof Error) {
467
+ if (!error.message.match(/You cannot dot into a client module/)) {
468
+ throw error;
469
+ }
470
+ }
471
+ }
454
472
  if (groupName) {
455
473
  // Allow unstable_settings={ 'custom': { initialRouteName: '...' } } to override the less specific initial route name.
456
474
  const groupSpecificInitialRouteName = loaded.unstable_settings?.[groupName]?.initialRouteName;