@react-navigation/native 6.1.0 → 6.1.2

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 (136) hide show
  1. package/lib/commonjs/Link.js +2 -12
  2. package/lib/commonjs/Link.js.map +1 -1
  3. package/lib/commonjs/LinkingContext.js +0 -4
  4. package/lib/commonjs/LinkingContext.js.map +1 -1
  5. package/lib/commonjs/NavigationContainer.js +9 -31
  6. package/lib/commonjs/NavigationContainer.js.map +1 -1
  7. package/lib/commonjs/ServerContainer.js +2 -12
  8. package/lib/commonjs/ServerContainer.js.map +1 -1
  9. package/lib/commonjs/ServerContext.js +0 -4
  10. package/lib/commonjs/ServerContext.js.map +1 -1
  11. package/lib/commonjs/createMemoryHistory.js +29 -54
  12. package/lib/commonjs/createMemoryHistory.js.map +1 -1
  13. package/lib/commonjs/extractPathFromURL.js +2 -8
  14. package/lib/commonjs/extractPathFromURL.js.map +1 -1
  15. package/lib/commonjs/index.js +0 -17
  16. package/lib/commonjs/index.js.map +1 -1
  17. package/lib/commonjs/theming/DarkTheme.js.map +1 -1
  18. package/lib/commonjs/theming/DefaultTheme.js.map +1 -1
  19. package/lib/commonjs/theming/ThemeContext.js +0 -6
  20. package/lib/commonjs/theming/ThemeContext.js.map +1 -1
  21. package/lib/commonjs/theming/ThemeProvider.js +0 -6
  22. package/lib/commonjs/theming/ThemeProvider.js.map +1 -1
  23. package/lib/commonjs/theming/useTheme.js +0 -6
  24. package/lib/commonjs/theming/useTheme.js.map +1 -1
  25. package/lib/commonjs/types.js.map +1 -1
  26. package/lib/commonjs/useBackButton.js +0 -9
  27. package/lib/commonjs/useBackButton.js.map +1 -1
  28. package/lib/commonjs/useDocumentTitle.js +1 -12
  29. package/lib/commonjs/useDocumentTitle.js.map +1 -1
  30. package/lib/commonjs/useDocumentTitle.native.js +2 -2
  31. package/lib/commonjs/useDocumentTitle.native.js.map +1 -1
  32. package/lib/commonjs/useLinkBuilder.js +5 -15
  33. package/lib/commonjs/useLinkBuilder.js.map +1 -1
  34. package/lib/commonjs/useLinkProps.js +8 -24
  35. package/lib/commonjs/useLinkProps.js.map +1 -1
  36. package/lib/commonjs/useLinkTo.js +0 -12
  37. package/lib/commonjs/useLinkTo.js.map +1 -1
  38. package/lib/commonjs/useLinking.js +35 -79
  39. package/lib/commonjs/useLinking.js.map +1 -1
  40. package/lib/commonjs/useLinking.native.js +9 -36
  41. package/lib/commonjs/useLinking.native.js.map +1 -1
  42. package/lib/commonjs/useScrollToTop.js +10 -17
  43. package/lib/commonjs/useScrollToTop.js.map +1 -1
  44. package/lib/commonjs/useThenable.js +2 -9
  45. package/lib/commonjs/useThenable.js.map +1 -1
  46. package/lib/module/Link.js +2 -6
  47. package/lib/module/Link.js.map +1 -1
  48. package/lib/module/LinkingContext.js.map +1 -1
  49. package/lib/module/NavigationContainer.js +9 -18
  50. package/lib/module/NavigationContainer.js.map +1 -1
  51. package/lib/module/ServerContainer.js +2 -5
  52. package/lib/module/ServerContainer.js.map +1 -1
  53. package/lib/module/ServerContext.js.map +1 -1
  54. package/lib/module/createMemoryHistory.js +29 -52
  55. package/lib/module/createMemoryHistory.js.map +1 -1
  56. package/lib/module/extractPathFromURL.js +2 -5
  57. package/lib/module/extractPathFromURL.js.map +1 -1
  58. package/lib/module/index.js.map +1 -1
  59. package/lib/module/theming/DarkTheme.js.map +1 -1
  60. package/lib/module/theming/DefaultTheme.js.map +1 -1
  61. package/lib/module/theming/ThemeContext.js.map +1 -1
  62. package/lib/module/theming/ThemeProvider.js.map +1 -1
  63. package/lib/module/theming/useTheme.js.map +1 -1
  64. package/lib/module/types.js.map +1 -1
  65. package/lib/module/useBackButton.js +0 -3
  66. package/lib/module/useBackButton.js.map +1 -1
  67. package/lib/module/useDocumentTitle.js +1 -9
  68. package/lib/module/useDocumentTitle.js.map +1 -1
  69. package/lib/module/useDocumentTitle.native.js +2 -1
  70. package/lib/module/useDocumentTitle.native.js.map +1 -1
  71. package/lib/module/useLinkBuilder.js +5 -9
  72. package/lib/module/useLinkBuilder.js.map +1 -1
  73. package/lib/module/useLinkProps.js +8 -16
  74. package/lib/module/useLinkProps.js.map +1 -1
  75. package/lib/module/useLinkTo.js +0 -5
  76. package/lib/module/useLinkTo.js.map +1 -1
  77. package/lib/module/useLinking.js +35 -70
  78. package/lib/module/useLinking.js.map +1 -1
  79. package/lib/module/useLinking.native.js +9 -26
  80. package/lib/module/useLinking.native.js.map +1 -1
  81. package/lib/module/useScrollToTop.js +10 -13
  82. package/lib/module/useScrollToTop.js.map +1 -1
  83. package/lib/module/useThenable.js +2 -5
  84. package/lib/module/useThenable.js.map +1 -1
  85. package/lib/typescript/src/Link.d.ts +1 -0
  86. package/lib/typescript/src/Link.d.ts.map +1 -0
  87. package/lib/typescript/src/LinkingContext.d.ts +1 -0
  88. package/lib/typescript/src/LinkingContext.d.ts.map +1 -0
  89. package/lib/typescript/src/NavigationContainer.d.ts +1 -0
  90. package/lib/typescript/src/NavigationContainer.d.ts.map +1 -0
  91. package/lib/typescript/src/ServerContainer.d.ts +1 -0
  92. package/lib/typescript/src/ServerContainer.d.ts.map +1 -0
  93. package/lib/typescript/src/ServerContext.d.ts +1 -0
  94. package/lib/typescript/src/ServerContext.d.ts.map +1 -0
  95. package/lib/typescript/src/__mocks__/window.d.ts +1 -0
  96. package/lib/typescript/src/__mocks__/window.d.ts.map +1 -0
  97. package/lib/typescript/src/createMemoryHistory.d.ts +1 -0
  98. package/lib/typescript/src/createMemoryHistory.d.ts.map +1 -0
  99. package/lib/typescript/src/extractPathFromURL.d.ts +1 -0
  100. package/lib/typescript/src/extractPathFromURL.d.ts.map +1 -0
  101. package/lib/typescript/src/index.d.ts +1 -0
  102. package/lib/typescript/src/index.d.ts.map +1 -0
  103. package/lib/typescript/src/theming/DarkTheme.d.ts +1 -0
  104. package/lib/typescript/src/theming/DarkTheme.d.ts.map +1 -0
  105. package/lib/typescript/src/theming/DefaultTheme.d.ts +1 -0
  106. package/lib/typescript/src/theming/DefaultTheme.d.ts.map +1 -0
  107. package/lib/typescript/src/theming/ThemeContext.d.ts +1 -0
  108. package/lib/typescript/src/theming/ThemeContext.d.ts.map +1 -0
  109. package/lib/typescript/src/theming/ThemeProvider.d.ts +1 -0
  110. package/lib/typescript/src/theming/ThemeProvider.d.ts.map +1 -0
  111. package/lib/typescript/src/theming/useTheme.d.ts +1 -0
  112. package/lib/typescript/src/theming/useTheme.d.ts.map +1 -0
  113. package/lib/typescript/src/types.d.ts +1 -0
  114. package/lib/typescript/src/types.d.ts.map +1 -0
  115. package/lib/typescript/src/useBackButton.d.ts +1 -0
  116. package/lib/typescript/src/useBackButton.d.ts.map +1 -0
  117. package/lib/typescript/src/useDocumentTitle.d.ts +1 -0
  118. package/lib/typescript/src/useDocumentTitle.d.ts.map +1 -0
  119. package/lib/typescript/src/useDocumentTitle.native.d.ts +1 -0
  120. package/lib/typescript/src/useDocumentTitle.native.d.ts.map +1 -0
  121. package/lib/typescript/src/useLinkBuilder.d.ts +1 -0
  122. package/lib/typescript/src/useLinkBuilder.d.ts.map +1 -0
  123. package/lib/typescript/src/useLinkProps.d.ts +1 -0
  124. package/lib/typescript/src/useLinkProps.d.ts.map +1 -0
  125. package/lib/typescript/src/useLinkTo.d.ts +1 -0
  126. package/lib/typescript/src/useLinkTo.d.ts.map +1 -0
  127. package/lib/typescript/src/useLinking.d.ts +1 -0
  128. package/lib/typescript/src/useLinking.d.ts.map +1 -0
  129. package/lib/typescript/src/useLinking.native.d.ts +1 -0
  130. package/lib/typescript/src/useLinking.native.d.ts.map +1 -0
  131. package/lib/typescript/src/useScrollToTop.d.ts +1 -0
  132. package/lib/typescript/src/useScrollToTop.d.ts.map +1 -0
  133. package/lib/typescript/src/useThenable.d.ts +1 -0
  134. package/lib/typescript/src/useThenable.d.ts.map +1 -0
  135. package/package.json +4 -4
  136. package/src/useScrollToTop.tsx +6 -1
@@ -1 +1 @@
1
- {"version":3,"names":["linkingHandlers","useLinking","ref","independent","enabled","prefixes","filter","config","getInitialURL","Promise","race","Linking","resolve","setTimeout","subscribe","listener","callback","url","subscription","addEventListener","removeEventListener","bind","remove","getStateFromPath","getStateFromPathDefault","getActionFromState","getActionFromStateDefault","React","useEffect","process","env","NODE_ENV","undefined","length","console","error","Platform","OS","join","trim","handler","Symbol","push","index","indexOf","splice","enabledRef","useRef","prefixesRef","filterRef","configRef","getInitialURLRef","getStateFromPathRef","getActionFromStateRef","current","getStateFromURL","useCallback","path","extractPathFromURL","getInitialState","state","then","thenable","onfulfilled","catch","navigation","rootState","getRootState","routes","some","r","routeNames","includes","name","warn","action","dispatch","e","message","resetRoot"],"sources":["useLinking.native.tsx"],"sourcesContent":["import {\n getActionFromState as getActionFromStateDefault,\n getStateFromPath as getStateFromPathDefault,\n NavigationContainerRef,\n ParamListBase,\n} from '@react-navigation/core';\nimport * as React from 'react';\nimport { Linking, Platform } from 'react-native';\n\nimport extractPathFromURL from './extractPathFromURL';\nimport type { LinkingOptions } from './types';\n\ntype ResultState = ReturnType<typeof getStateFromPathDefault>;\n\ntype Options = LinkingOptions<ParamListBase> & {\n independent?: boolean;\n};\n\nlet linkingHandlers: Symbol[] = [];\n\nexport default function useLinking(\n ref: React.RefObject<NavigationContainerRef<ParamListBase>>,\n {\n independent,\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 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) {\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 = extractPathFromURL(prefixesRef.current, url);\n\n return path !== undefined\n ? getStateFromPathRef.current(path, configRef.current)\n : undefined;\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 && typeof url !== 'string') {\n return url.then((url) => {\n const state = getStateFromURL(url);\n\n return state;\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]);\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 // Make sure that the routes in the state exist in the root navigator\n // Otherwise there's an error in the linking configuration\n const rootState = navigation.getRootState();\n\n if (state.routes.some((r) => !rootState?.routeNames.includes(r.name))) {\n console.warn(\n \"The navigation state parsed from the URL contains routes not present in the root navigator. This usually means that the linking configuration doesn't match the navigation structure. See https://reactnavigation.org/docs/configuring-links for more details on how to specify a linking configuration.\"\n );\n return;\n }\n\n 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\n ? // @ts-expect-error: we're already checking for this\n e.message\n : e\n }`\n );\n }\n } else {\n navigation.resetRoot(state);\n }\n }\n };\n\n return subscribe(listener);\n }, [enabled, getStateFromURL, ref, subscribe]);\n\n return {\n getInitialState,\n };\n}\n"],"mappings":";;;;;;;AAAA;;AAMA;;AACA;;AAEA;;;;;;;;AASA,IAAIA,eAAyB,GAAG,EAAhC;;AAEe,SAASC,UAAT,CACbC,GADa,QAuCb;EAAA,IArCA;IACEC,WADF;IAEEC,OAAO,GAAG,IAFZ;IAGEC,QAH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AAD,CAAhB;EACD,CA7CD,EA6CG,CAACX,OAAD,EAAUmD,eAAV,EAA2BrD,GAA3B,EAAgCY,SAAhC,CA7CH;EA+CA,OAAO;IACL6C;EADK,CAAP;AAGD"}
1
+ {"version":3,"names":["linkingHandlers","useLinking","ref","independent","enabled","prefixes","filter","config","getInitialURL","Promise","race","Linking","resolve","setTimeout","subscribe","listener","callback","url","subscription","addEventListener","removeEventListener","bind","remove","getStateFromPath","getStateFromPathDefault","getActionFromState","getActionFromStateDefault","React","useEffect","process","env","NODE_ENV","undefined","length","console","error","Platform","OS","join","trim","handler","Symbol","push","index","indexOf","splice","enabledRef","useRef","prefixesRef","filterRef","configRef","getInitialURLRef","getStateFromPathRef","getActionFromStateRef","current","getStateFromURL","useCallback","path","extractPathFromURL","getInitialState","state","then","thenable","onfulfilled","catch","navigation","rootState","getRootState","routes","some","r","routeNames","includes","name","warn","action","dispatch","e","message","resetRoot"],"sourceRoot":"../../src","sources":["useLinking.native.tsx"],"mappings":";;;;;;AAAA;AAMA;AACA;AAEA;AAAsD;AAAA;AAAA;AAStD,IAAIA,eAAyB,GAAG,EAAE;AAEnB,SAASC,UAAU,CAChCC,GAA2D,QAsC3D;EAAA,IArCA;IACEC,WAAW;IACXC,OAAO,GAAG,IAAI;IACdC,QAAQ;IACRC,MAAM;IACNC,MAAM;IACNC,aAAa,GAAG,MACdC,OAAO,CAACC,IAAI,CAAC,CACXC,oBAAO,CAACH,aAAa,EAAE,EACvB,IAAIC,OAAO,CAAaG,OAAO;IAC7B;IACA;IACAC,UAAU,CAACD,OAAO,EAAE,GAAG,CAAC,CACzB,CACF,CAAC;IACJE,SAAS,GAAIC,QAAQ,IAAK;MAAA;MACxB,MAAMC,QAAQ,GAAG;QAAA,IAAC;UAAEC;QAAqB,CAAC;QAAA,OAAKF,QAAQ,CAACE,GAAG,CAAC;MAAA;MAE5D,MAAMC,YAAY,GAAGP,oBAAO,CAACQ,gBAAgB,CAAC,KAAK,EAAEH,QAAQ,CAEh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C,CAAC,IAAK,EAACJ,SAAS,aAATA,SAAS,eAATA,SAAS,CAAEK,UAAU,CAACC,QAAQ,CAACF,CAAC,CAACG,IAAI,CAAC,EAAC,EAAE;UACrEvC,OAAO,CAACwC,IAAI,CACV,0SAA0S,CAC3S;UACD;QACF;QAEA,MAAMC,MAAM,GAAGtB,qBAAqB,CAACC,OAAO,CAACM,KAAK,EAAEV,SAAS,CAACI,OAAO,CAAC;QAEtE,IAAIqB,MAAM,KAAK3C,SAAS,EAAE;UACxB,IAAI;YACFiC,UAAU,CAACW,QAAQ,CAACD,MAAM,CAAC;UAC7B,CAAC,CAAC,OAAOE,CAAC,EAAE;YACV;YACA;YACA3C,OAAO,CAACwC,IAAI,CACT,qDAAoDzD,GAAI,MACvD,OAAO4D,CAAC,KAAK,QAAQ,IAAIA,CAAC,IAAI,IAAI,IAAI,SAAS,IAAIA,CAAC;YAChD;YACAA,CAAC,CAACC,OAAO,GACTD,CACL,EAAC,CACH;UACH;QACF,CAAC,MAAM;UACLZ,UAAU,CAACc,SAAS,CAACnB,KAAK,CAAC;QAC7B;MACF;IACF,CAAC;IAED,OAAO9C,SAAS,CAACC,QAAQ,CAAC;EAC5B,CAAC,EAAE,CAACX,OAAO,EAAEmD,eAAe,EAAErD,GAAG,EAAEY,SAAS,CAAC,CAAC;EAE9C,OAAO;IACL6C;EACF,CAAC;AACH"}
@@ -4,20 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useScrollToTop;
7
-
8
7
  var _core = require("@react-navigation/core");
9
-
10
8
  var React = _interopRequireWildcard(require("react"));
11
-
12
9
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
13
-
14
10
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
15
-
16
11
  function getScrollableNode(ref) {
17
12
  if (ref.current == null) {
18
13
  return null;
19
14
  }
20
-
21
15
  if ('scrollToTop' in ref.current || 'scrollTo' in ref.current || 'scrollToOffset' in ref.current || 'scrollResponderScrollTo' in ref.current) {
22
16
  // This is already a scrollable node.
23
17
  return ref.current;
@@ -35,42 +29,41 @@ function getScrollableNode(ref) {
35
29
  return ref.current;
36
30
  }
37
31
  }
38
-
39
32
  function useScrollToTop(ref) {
40
33
  const navigation = (0, _core.useNavigation)();
41
34
  const route = (0, _core.useRoute)();
42
35
  React.useEffect(() => {
43
36
  let tabNavigations = [];
44
- let currentNavigation = navigation; // If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
45
- // So we need to find all the parent tab navigators and add the listeners there
37
+ let currentNavigation = navigation;
46
38
 
39
+ // If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
40
+ // So we need to find all the parent tab navigators and add the listeners there
47
41
  while (currentNavigation) {
48
42
  if (currentNavigation.getState().type === 'tab') {
49
43
  tabNavigations.push(currentNavigation);
50
44
  }
51
-
52
45
  currentNavigation = currentNavigation.getParent();
53
46
  }
54
-
55
47
  if (tabNavigations.length === 0) {
56
48
  return;
57
49
  }
58
-
59
50
  const unsubscribers = tabNavigations.map(tab => {
60
- return tab.addListener( // We don't wanna import tab types here to avoid extra deps
51
+ return tab.addListener(
52
+ // We don't wanna import tab types here to avoid extra deps
61
53
  // in addition, there are multiple tab implementations
62
54
  // @ts-expect-error
63
55
  'tabPress', e => {
64
56
  // We should scroll to top only when the screen is focused
65
- const isFocused = navigation.isFocused(); // In a nested stack navigator, tab press resets the stack to first screen
57
+ const isFocused = navigation.isFocused();
58
+
59
+ // In a nested stack navigator, tab press resets the stack to first screen
66
60
  // So we should scroll to top only when we are on first screen
61
+ const isFirst = tabNavigations.includes(navigation) || navigation.getState().routes[0].key === route.key;
67
62
 
68
- const isFirst = tabNavigations.includes(navigation) || navigation.getState().routes[0].key === route.key; // Run the operation in the next frame so we're sure all listeners have been run
63
+ // Run the operation in the next frame so we're sure all listeners have been run
69
64
  // This is necessary to know if preventDefault() has been called
70
-
71
65
  requestAnimationFrame(() => {
72
66
  const scrollable = getScrollableNode(ref);
73
-
74
67
  if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
75
68
  if ('scrollToTop' in scrollable) {
76
69
  scrollable.scrollToTop();
@@ -1 +1 @@
1
- {"version":3,"names":["getScrollableNode","ref","current","getScrollResponder","getNode","useScrollToTop","navigation","useNavigation","route","useRoute","React","useEffect","tabNavigations","currentNavigation","getState","type","push","getParent","length","unsubscribers","map","tab","addListener","e","isFocused","isFirst","includes","routes","key","requestAnimationFrame","scrollable","defaultPrevented","scrollToTop","scrollTo","y","animated","scrollToOffset","offset","scrollResponderScrollTo","forEach","unsubscribe"],"sources":["useScrollToTop.tsx"],"sourcesContent":["import { EventArg, NavigationProp, useNavigation, useRoute } from '@react-navigation/core';\nimport * as React from 'react';\n\ntype ScrollOptions = { x?: number; y?: number; animated?: boolean };\n\ntype ScrollableView =\n | { scrollToTop(): void }\n | { scrollTo(options: ScrollOptions): void }\n | { scrollToOffset(options: { offset?: number; animated?: boolean }): void }\n | { scrollResponderScrollTo(options: ScrollOptions): void };\n\ntype ScrollableWrapper =\n | { getScrollResponder(): React.ReactNode }\n | { getNode(): ScrollableView }\n | ScrollableView;\n\nfunction getScrollableNode(ref: React.RefObject<ScrollableWrapper>) {\n if (ref.current == null) {\n return null;\n }\n\n if (\n 'scrollToTop' in ref.current ||\n 'scrollTo' in ref.current ||\n 'scrollToOffset' in ref.current ||\n 'scrollResponderScrollTo' in ref.current\n ) {\n // This is already a scrollable node.\n return ref.current;\n } else if ('getScrollResponder' in ref.current) {\n // If the view is a wrapper like FlatList, SectionList etc.\n // We need to use `getScrollResponder` to get access to the scroll responder\n return ref.current.getScrollResponder();\n } else if ('getNode' in ref.current) {\n // When a `ScrollView` is wraped in `Animated.createAnimatedComponent`\n // we need to use `getNode` to get the ref to the actual scrollview.\n // Note that `getNode` is deprecated in newer versions of react-native\n // this is why we check if we already have a scrollable node above.\n return ref.current.getNode();\n } else {\n return ref.current;\n }\n}\n\nexport default function useScrollToTop(\n ref: React.RefObject<ScrollableWrapper>\n) {\n const navigation = useNavigation();\n const route = useRoute();\n\n React.useEffect(() => {\n let tabNavigations: NavigationProp<ReactNavigation.RootParamList>[] = [];\n let currentNavigation = navigation;\n\n // If the screen is nested inside multiple tab navigators, we should scroll to top for any of them\n // So we need to find all the parent tab navigators and add the listeners there\n while (currentNavigation) {\n if (currentNavigation.getState().type === 'tab') {\n tabNavigations.push(currentNavigation);\n }\n\n currentNavigation = currentNavigation.getParent();\n }\n\n if (tabNavigations.length === 0) {\n return;\n }\n\n const unsubscribers = tabNavigations.map((tab) => {\n return tab.addListener(\n // We don't wanna import tab types here to avoid extra deps\n // in addition, there are multiple tab implementations\n // @ts-expect-error\n 'tabPress',\n (e: EventArg<'tabPress', true>) => {\n // We should scroll to top only when the screen is focused\n const isFocused = navigation.isFocused();\n\n // In a nested stack navigator, tab press resets the stack to first screen\n // So we should scroll to top only when we are on first screen\n const isFirst =\n tabNavigations.includes(navigation) ||\n navigation.getState().routes[0].key === route.key;\n\n // Run the operation in the next frame so we're sure all listeners have been run\n // This is necessary to know if preventDefault() has been called\n requestAnimationFrame(() => {\n const scrollable = getScrollableNode(ref) as ScrollableWrapper;\n\n if (isFocused && isFirst && scrollable && !e.defaultPrevented) {\n if ('scrollToTop' in scrollable) {\n scrollable.scrollToTop();\n } else if ('scrollTo' in scrollable) {\n scrollable.scrollTo({ y: 0, animated: true });\n } else if ('scrollToOffset' in scrollable) {\n scrollable.scrollToOffset({ offset: 0, animated: true });\n } else if ('scrollResponderScrollTo' in scrollable) {\n scrollable.scrollResponderScrollTo({ y: 0, animated: true });\n }\n }\n });\n }\n );\n });\n\n return () => {\n unsubscribers.forEach((unsubscribe) => unsubscribe());\n };\n }, [navigation, ref, route.key]);\n}\n"],"mappings":";;;;;;;AAAA;;AACA;;;;;;AAeA,SAASA,iBAAT,CAA2BC,GAA3B,EAAoE;EAClE,IAAIA,GAAG,CAACC,OAAJ,IAAe,IAAnB,EAAyB;IACvB,OAAO,IAAP;EACD;;EAED,IACE,iBAAiBD,GAAG,CAACC,OAArB,IACA,cAAcD,GAAG,CAACC,OADlB,IAEA,oBAAoBD,GAAG,CAACC,OAFxB,IAGA,6BAA6BD,GAAG,CAACC,OAJnC,EAKE;IACA;IACA,OAAOD,GAAG,CAACC,OAAX;EACD,CARD,MAQO,IAAI,wBAAwBD,GAAG,CAACC,OAAhC,EAAyC;IAC9C;IACA;IACA,OAAOD,GAAG,CAACC,OAAJ,CAAYC,kBAAZ,EAAP;EACD,CAJM,MAIA,IAAI,aAAaF,GAAG,CAACC,OAArB,EAA8B;IACnC;IACA;IACA;IACA;IACA,OAAOD,GAAG,CAACC,OAAJ,CAAYE,OAAZ,EAAP;EACD,CANM,MAMA;IACL,OAAOH,GAAG,CAACC,OAAX;EACD;AACF;;AAEc,SAASG,cAAT,CACbJ,GADa,EAEb;EACA,MAAMK,UAAU,GAAG,IAAAC,mBAAA,GAAnB;EACA,MAAMC,KAAK,GAAG,IAAAC,cAAA,GAAd;EAEAC,KAAK,CAACC,SAAN,CAAgB,MAAM;IACpB,IAAIC,cAA+D,GAAG,EAAtE;IACA,IAAIC,iBAAiB,GAAGP,UAAxB,CAFoB,CAIpB;I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EAA6C;cAClDA,UAAU,CAACQ,uBAAX,CAAmC;gBAAEJ,CAAC,EAAE,CAAL;gBAAQC,QAAQ,EAAE;cAAlB,CAAnC;YACD;UACF;QACF,CAdoB,CAArB;MAeD,CAhCI,CAAP;IAkCD,CAnCqB,CAAtB;IAqCA,OAAO,MAAM;MACXhB,aAAa,CAACoB,OAAd,CAAuBC,WAAD,IAAiBA,WAAW,EAAlD;IACD,CAFD;EAGD,CA1DD,EA0DG,CAAClC,UAAD,EAAaL,GAAb,EAAkBO,KAAK,CAACoB,GAAxB,CA1DH;AA2DD"}
1
+ {"version":3,"names":["getScrollableNode","ref","current","getScrollResponder","getNode","useScrollToTop","navigation","useNavigation","route","useRoute","React","useEffect","tabNavigations","currentNavigation","getState","type","push","getParent","length","unsubscribers","map","tab","addListener","e","isFocused","isFirst","includes","routes","key","requestAnimationFrame","scrollable","defaultPrevented","scrollToTop","scrollTo","y","animated","scrollToOffset","offset","scrollResponderScrollTo","forEach","unsubscribe"],"sourceRoot":"../../src","sources":["useScrollToTop.tsx"],"mappings":";;;;;;AAAA;AAMA;AAA+B;AAAA;AAe/B,SAASA,iBAAiB,CAACC,GAAuC,EAAE;EAClE,IAAIA,GAAG,CAACC,OAAO,IAAI,IAAI,EAAE;IACvB,OAAO,IAAI;EACb;EAEA,IACE,aAAa,IAAID,GAAG,CAACC,OAAO,IAC5B,UAAU,IAAID,GAAG,CAACC,OAAO,IACzB,gBAAgB,IAAID,GAAG,CAACC,OAAO,IAC/B,yBAAyB,IAAID,GAAG,CAACC,OAAO,EACxC;IACA;IACA,OAAOD,GAAG,CAACC,OAAO;EACpB,CAAC,MAAM,IAAI,oBAAoB,IAAID,GAAG,CAACC,OAAO,EAAE;IAC9C;IACA;IACA,OAAOD,GAAG,CAACC,OAAO,CAACC,kBAAkB,EAAE;EACzC,CAAC,MAAM,IAAI,SAAS,IAAIF,GAAG,CAACC,OAAO,EAAE;IACnC;IACA;IACA;IACA;IACA,OAAOD,GAAG,CAACC,OA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B,CAAC,MAAM,IAAI,UAAU,IAAIF,UAAU,EAAE;cACnCA,UAAU,CAACG,QAAQ,CAAC;gBAAEC,CAAC,EAAE,CAAC;gBAAEC,QAAQ,EAAE;cAAK,CAAC,CAAC;YAC/C,CAAC,MAAM,IAAI,gBAAgB,IAAIL,UAAU,EAAE;cACzCA,UAAU,CAACM,cAAc,CAAC;gBAAEC,MAAM,EAAE,CAAC;gBAAEF,QAAQ,EAAE;cAAK,CAAC,CAAC;YAC1D,CAAC,MAAM,IAAI,yBAAyB,IAAIL,UAAU,EAAE;cAClDA,UAAU,CAACQ,uBAAuB,CAAC;gBAAEJ,CAAC,EAAE,CAAC;gBAAEC,QAAQ,EAAE;cAAK,CAAC,CAAC;YAC9D;UACF;QACF,CAAC,CAAC;MACJ,CAAC,CACF;IACH,CAAC,CAAC;IAEF,OAAO,MAAM;MACXhB,aAAa,CAACoB,OAAO,CAAEC,WAAW,IAAKA,WAAW,EAAE,CAAC;IACvD,CAAC;EACH,CAAC,EAAE,CAAClC,UAAU,EAAEL,GAAG,EAAEO,KAAK,CAACoB,GAAG,CAAC,CAAC;AAClC"}
@@ -4,17 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = useThenable;
7
-
8
7
  var React = _interopRequireWildcard(require("react"));
9
-
10
8
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
11
-
12
9
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
-
14
10
  function useThenable(create) {
15
11
  const [promise] = React.useState(create);
16
- let initialState = [false, undefined]; // Check if our thenable is synchronous
12
+ let initialState = [false, undefined];
17
13
 
14
+ // Check if our thenable is synchronous
18
15
  promise.then(result => {
19
16
  initialState = [true, result];
20
17
  });
@@ -22,10 +19,8 @@ function useThenable(create) {
22
19
  const [resolved] = state;
23
20
  React.useEffect(() => {
24
21
  let cancelled = false;
25
-
26
22
  const resolve = async () => {
27
23
  let result;
28
-
29
24
  try {
30
25
  result = await promise;
31
26
  } finally {
@@ -34,11 +29,9 @@ function useThenable(create) {
34
29
  }
35
30
  }
36
31
  };
37
-
38
32
  if (!resolved) {
39
33
  resolve();
40
34
  }
41
-
42
35
  return () => {
43
36
  cancelled = true;
44
37
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useThenable","create","promise","React","useState","initialState","undefined","then","result","state","setState","resolved","useEffect","cancelled","resolve"],"sources":["useThenable.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport default function useThenable<T>(create: () => PromiseLike<T>) {\n const [promise] = React.useState(create);\n\n let initialState: [boolean, T | undefined] = [false, undefined];\n\n // Check if our thenable is synchronous\n promise.then((result) => {\n initialState = [true, result];\n });\n\n const [state, setState] = React.useState(initialState);\n const [resolved] = state;\n\n React.useEffect(() => {\n let cancelled = false;\n\n const resolve = async () => {\n let result;\n\n try {\n result = await promise;\n } finally {\n if (!cancelled) {\n setState([true, result]);\n }\n }\n };\n\n if (!resolved) {\n resolve();\n }\n\n return () => {\n cancelled = true;\n };\n }, [promise, resolved]);\n\n return state;\n}\n"],"mappings":";;;;;;;AAAA;;;;;;AAEe,SAASA,WAAT,CAAwBC,MAAxB,EAAsD;EACnE,MAAM,CAACC,OAAD,IAAYC,KAAK,CAACC,QAAN,CAAeH,MAAf,CAAlB;EAEA,IAAII,YAAsC,GAAG,CAAC,KAAD,EAAQC,SAAR,CAA7C,CAHmE,CAKnE;;EACAJ,OAAO,CAACK,IAAR,CAAcC,MAAD,IAAY;IACvBH,YAAY,GAAG,CAAC,IAAD,EAAOG,MAAP,CAAf;EACD,CAFD;EAIA,MAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBP,KAAK,CAACC,QAAN,CAAeC,YAAf,CAA1B;EACA,MAAM,CAACM,QAAD,IAAaF,KAAnB;EAEAN,KAAK,CAACS,SAAN,CAAgB,MAAM;IACpB,IAAIC,SAAS,GAAG,KAAhB;;IAEA,MAAMC,OAAO,GAAG,YAAY;MAC1B,IAAIN,MAAJ;;MAEA,IAAI;QACFA,MAAM,GAAG,MAAMN,OAAf;MACD,CAFD,SAEU;QACR,IAAI,CAACW,SAAL,EAAgB;UACdH,QAAQ,CAAC,CAAC,IAAD,EAAOF,MAAP,CAAD,CAAR;QACD;MACF;IACF,CAVD;;IAYA,IAAI,CAACG,QAAL,EAAe;MACbG,OAAO;IACR;;IAED,OAAO,MAAM;MACXD,SAAS,GAAG,IAAZ;IACD,CAFD;EAGD,CAtBD,EAsBG,CAACX,OAAD,EAAUS,QAAV,CAtBH;EAwBA,OAAOF,KAAP;AACD"}
1
+ {"version":3,"names":["useThenable","create","promise","React","useState","initialState","undefined","then","result","state","setState","resolved","useEffect","cancelled","resolve"],"sourceRoot":"../../src","sources":["useThenable.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAEhB,SAASA,WAAW,CAAIC,MAA4B,EAAE;EACnE,MAAM,CAACC,OAAO,CAAC,GAAGC,KAAK,CAACC,QAAQ,CAACH,MAAM,CAAC;EAExC,IAAII,YAAsC,GAAG,CAAC,KAAK,EAAEC,SAAS,CAAC;;EAE/D;EACAJ,OAAO,CAACK,IAAI,CAAEC,MAAM,IAAK;IACvBH,YAAY,GAAG,CAAC,IAAI,EAAEG,MAAM,CAAC;EAC/B,CAAC,CAAC;EAEF,MAAM,CAACC,KAAK,EAAEC,QAAQ,CAAC,GAAGP,KAAK,CAACC,QAAQ,CAACC,YAAY,CAAC;EACtD,MAAM,CAACM,QAAQ,CAAC,GAAGF,KAAK;EAExBN,KAAK,CAACS,SAAS,CAAC,MAAM;IACpB,IAAIC,SAAS,GAAG,KAAK;IAErB,MAAMC,OAAO,GAAG,YAAY;MAC1B,IAAIN,MAAM;MAEV,IAAI;QACFA,MAAM,GAAG,MAAMN,OAAO;MACxB,CAAC,SAAS;QACR,IAAI,CAACW,SAAS,EAAE;UACdH,QAAQ,CAAC,CAAC,IAAI,EAAEF,MAAM,CAAC,CAAC;QAC1B;MACF;IACF,CAAC;IAED,IAAI,CAACG,QAAQ,EAAE;MACbG,OAAO,EAAE;IACX;IAEA,OAAO,MAAM;MACXD,SAAS,GAAG,IAAI;IAClB,CAAC;EACH,CAAC,EAAE,CAACX,OAAO,EAAES,QAAQ,CAAC,CAAC;EAEvB,OAAOF,KAAK;AACd"}
@@ -1,7 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { Platform, Text } from 'react-native';
3
3
  import useLinkProps from './useLinkProps';
4
-
5
4
  /**
6
5
  * Component to render link to another screen using a path.
7
6
  * Uses an anchor tag on the web.
@@ -20,18 +19,15 @@ export default function Link(_ref) {
20
19
  to,
21
20
  action
22
21
  });
23
-
24
22
  const onPress = e => {
25
23
  if ('onPress' in rest) {
26
24
  var _rest$onPress;
27
-
28
25
  (_rest$onPress = rest.onPress) === null || _rest$onPress === void 0 ? void 0 : _rest$onPress.call(rest, e);
29
26
  }
30
-
31
27
  props.onPress(e);
32
28
  };
33
-
34
- return /*#__PURE__*/React.createElement(Text, { ...props,
29
+ return /*#__PURE__*/React.createElement(Text, {
30
+ ...props,
35
31
  ...rest,
36
32
  ...Platform.select({
37
33
  web: {
@@ -1 +1 @@
1
- {"version":3,"names":["React","Platform","Text","useLinkProps","Link","to","action","rest","props","onPress","e","createElement","select","web","onClick","default"],"sources":["Link.tsx"],"sourcesContent":["import type { NavigationAction } from '@react-navigation/core';\nimport * as React from 'react';\nimport { GestureResponderEvent, Platform, Text, TextProps } from 'react-native';\n\nimport useLinkProps from './useLinkProps';\nimport type { To } from './useLinkTo';\n\ntype Props<ParamList extends ReactNavigation.RootParamList> = {\n to: To<ParamList>;\n action?: NavigationAction;\n target?: string;\n onPress?: (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => void;\n} & (TextProps & { children: React.ReactNode });\n\n/**\n * Component to render link to another screen using a path.\n * Uses an anchor tag on the web.\n *\n * @param props.to Absolute path to screen (e.g. `/feeds/hot`).\n * @param props.action Optional action to use for in-page navigation. By default, the path is parsed to an action based on linking config.\n * @param props.children Child elements to render the content.\n */\nexport default function Link<ParamList extends ReactNavigation.RootParamList>({\n to,\n action,\n ...rest\n}: Props<ParamList>) {\n const props = useLinkProps<ParamList>({ to, action });\n\n const onPress = (\n e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent\n ) => {\n if ('onPress' in rest) {\n rest.onPress?.(e);\n }\n\n props.onPress(e);\n };\n\n return React.createElement(Text, {\n ...props,\n ...rest,\n ...Platform.select({\n web: { onClick: onPress } as any,\n default: { onPress },\n }),\n });\n}\n"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAAgCC,QAAhC,EAA0CC,IAA1C,QAAiE,cAAjE;AAEA,OAAOC,YAAP,MAAyB,gBAAzB;;AAYA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,IAAT,OAIM;EAAA,IAJyD;IAC5EC,EAD4E;IAE5EC,MAF4E;IAG5E,GAAGC;EAHyE,CAIzD;EACnB,MAAMC,KAAK,GAAGL,YAAY,CAAY;IAAEE,EAAF;IAAMC;EAAN,CAAZ,CAA1B;;EAEA,MAAMG,OAAO,GACXC,CADc,IAEX;IACH,IAAI,aAAaH,IAAjB,EAAuB;MAAA;;MACrB,iBAAAA,IAAI,CAACE,OAAL,qEAAAF,IAAI,EAAWG,CAAX,CAAJ;IACD;;IAEDF,KAAK,CAACC,OAAN,CAAcC,CAAd;EACD,CARD;;EAUA,oBAAOV,KAAK,CAACW,aAAN,CAAoBT,IAApB,EAA0B,EAC/B,GAAGM,KAD4B;IAE/B,GAAGD,IAF4B;IAG/B,GAAGN,QAAQ,CAACW,MAAT,CAAgB;MACjBC,GAAG,EAAE;QAAEC,OAAO,EAAEL;MAAX,CADY;MAEjBM,OAAO,EAAE;QAAEN;MAAF;IAFQ,CAAhB;EAH4B,CAA1B,CAAP;AAQD"}
1
+ {"version":3,"names":["React","Platform","Text","useLinkProps","Link","to","action","rest","props","onPress","e","createElement","select","web","onClick","default"],"sourceRoot":"../../src","sources":["Link.tsx"],"mappings":"AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAAgCC,QAAQ,EAAEC,IAAI,QAAmB,cAAc;AAE/E,OAAOC,YAAY,MAAM,gBAAgB;AAYzC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,eAAe,SAASC,IAAI,OAIP;EAAA,IAJyD;IAC5EC,EAAE;IACFC,MAAM;IACN,GAAGC;EACa,CAAC;EACjB,MAAMC,KAAK,GAAGL,YAAY,CAAY;IAAEE,EAAE;IAAEC;EAAO,CAAC,CAAC;EAErD,MAAMG,OAAO,GACXC,CAA0E,IACvE;IACH,IAAI,SAAS,IAAIH,IAAI,EAAE;MAAA;MACrB,iBAAAA,IAAI,CAACE,OAAO,kDAAZ,mBAAAF,IAAI,EAAWG,CAAC,CAAC;IACnB;IAEAF,KAAK,CAACC,OAAO,CAACC,CAAC,CAAC;EAClB,CAAC;EAED,oBAAOV,KAAK,CAACW,aAAa,CAACT,IAAI,EAAE;IAC/B,GAAGM,KAAK;IACR,GAAGD,IAAI;IACP,GAAGN,QAAQ,CAACW,MAAM,CAAC;MACjBC,GAAG,EAAE;QAAEC,OAAO,EAAEL;MAAQ,CAAQ;MAChCM,OAAO,EAAE;QAAEN;MAAQ;IACrB,CAAC;EACH,CAAC,CAAC;AACJ"}
@@ -1 +1 @@
1
- {"version":3,"names":["React","LinkingContext","createContext","options","undefined","displayName"],"sources":["LinkingContext.tsx"],"sourcesContent":["import type { ParamListBase } from '@react-navigation/core';\nimport * as React from 'react';\n\nimport type { LinkingOptions } from './types';\n\nconst LinkingContext = React.createContext<{\n options: LinkingOptions<ParamListBase> | undefined;\n}>({ options: undefined });\n\nLinkingContext.displayName = 'LinkingContext';\n\nexport default LinkingContext;\n"],"mappings":"AACA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AAIA,MAAMC,cAAc,gBAAGD,KAAK,CAACE,aAAN,CAEpB;EAAEC,OAAO,EAAEC;AAAX,CAFoB,CAAvB;AAIAH,cAAc,CAACI,WAAf,GAA6B,gBAA7B;AAEA,eAAeJ,cAAf"}
1
+ {"version":3,"names":["React","LinkingContext","createContext","options","undefined","displayName"],"sourceRoot":"../../src","sources":["LinkingContext.tsx"],"mappings":"AACA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAI9B,MAAMC,cAAc,gBAAGD,KAAK,CAACE,aAAa,CAEvC;EAAEC,OAAO,EAAEC;AAAU,CAAC,CAAC;AAE1BH,cAAc,CAACI,WAAW,GAAG,gBAAgB;AAE7C,eAAeJ,cAAc"}
@@ -1,5 +1,4 @@
1
1
  function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
-
3
2
  import { BaseNavigationContainer, getActionFromState, getPathFromState, getStateFromPath, validatePathConfig } from '@react-navigation/core';
4
3
  import * as React from 'react';
5
4
  import LinkingContext from './LinkingContext';
@@ -10,7 +9,6 @@ import useDocumentTitle from './useDocumentTitle';
10
9
  import useLinking from './useLinking';
11
10
  import useThenable from './useThenable';
12
11
  global.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
13
-
14
12
  /**
15
13
  * Container component which holds the navigation state designed for React Native apps.
16
14
  * This should be rendered at the root wrapping the whole app.
@@ -35,11 +33,9 @@ function NavigationContainerInner(_ref, ref) {
35
33
  ...rest
36
34
  } = _ref;
37
35
  const isLinkingEnabled = linking ? linking.enabled !== false : false;
38
-
39
36
  if (linking !== null && linking !== void 0 && linking.config) {
40
37
  validatePathConfig(linking.config);
41
38
  }
42
-
43
39
  const refContainer = React.useRef(null);
44
40
  useBackButton(refContainer);
45
41
  useDocumentTitle(refContainer, documentTitle);
@@ -50,24 +46,23 @@ function NavigationContainerInner(_ref, ref) {
50
46
  enabled: isLinkingEnabled,
51
47
  prefixes: [],
52
48
  ...linking
53
- }); // Add additional linking related info to the ref
54
- // This will be used by the devtools
49
+ });
55
50
 
51
+ // Add additional linking related info to the ref
52
+ // This will be used by the devtools
56
53
  React.useEffect(() => {
57
54
  if (refContainer.current) {
58
55
  REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {
59
56
  get linking() {
60
- var _linking$prefixes, _linking$getStateFrom, _linking$getPathFromS, _linking$getActionFro;
61
-
62
- return { ...linking,
57
+ return {
58
+ ...linking,
63
59
  enabled: isLinkingEnabled,
64
- prefixes: (_linking$prefixes = linking === null || linking === void 0 ? void 0 : linking.prefixes) !== null && _linking$prefixes !== void 0 ? _linking$prefixes : [],
65
- getStateFromPath: (_linking$getStateFrom = linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) !== null && _linking$getStateFrom !== void 0 ? _linking$getStateFrom : getStateFromPath,
66
- getPathFromState: (_linking$getPathFromS = linking === null || linking === void 0 ? void 0 : linking.getPathFromState) !== null && _linking$getPathFromS !== void 0 ? _linking$getPathFromS : getPathFromState,
67
- getActionFromState: (_linking$getActionFro = linking === null || linking === void 0 ? void 0 : linking.getActionFromState) !== null && _linking$getActionFro !== void 0 ? _linking$getActionFro : getActionFromState
60
+ prefixes: (linking === null || linking === void 0 ? void 0 : linking.prefixes) ?? [],
61
+ getStateFromPath: (linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) ?? getStateFromPath,
62
+ getPathFromState: (linking === null || linking === void 0 ? void 0 : linking.getPathFromState) ?? getPathFromState,
63
+ getActionFromState: (linking === null || linking === void 0 ? void 0 : linking.getActionFromState) ?? getActionFromState
68
64
  };
69
65
  }
70
-
71
66
  });
72
67
  }
73
68
  });
@@ -84,17 +79,14 @@ function NavigationContainerInner(_ref, ref) {
84
79
  React.useEffect(() => {
85
80
  if (isReady) {
86
81
  var _onReadyRef$current;
87
-
88
82
  (_onReadyRef$current = onReadyRef.current) === null || _onReadyRef$current === void 0 ? void 0 : _onReadyRef$current.call(onReadyRef);
89
83
  }
90
84
  }, [isReady]);
91
-
92
85
  if (!isReady) {
93
86
  // This is temporary until we have Suspense for data-fetching
94
87
  // Then the fallback will be handled by a parent `Suspense` component
95
88
  return fallback;
96
89
  }
97
-
98
90
  return /*#__PURE__*/React.createElement(LinkingContext.Provider, {
99
91
  value: linkingContext
100
92
  }, /*#__PURE__*/React.createElement(ThemeProvider, {
@@ -104,7 +96,6 @@ function NavigationContainerInner(_ref, ref) {
104
96
  ref: refContainer
105
97
  }))));
106
98
  }
107
-
108
99
  const NavigationContainer = /*#__PURE__*/React.forwardRef(NavigationContainerInner);
109
100
  export default NavigationContainer;
110
101
  //# sourceMappingURL=NavigationContainer.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["BaseNavigationContainer","getActionFromState","getPathFromState","getStateFromPath","validatePathConfig","React","LinkingContext","DefaultTheme","ThemeProvider","useBackButton","useDocumentTitle","useLinking","useThenable","global","REACT_NAVIGATION_DEVTOOLS","WeakMap","NavigationContainerInner","ref","theme","linking","fallback","documentTitle","onReady","rest","isLinkingEnabled","enabled","config","refContainer","useRef","getInitialState","independent","prefixes","useEffect","current","set","isResolved","initialState","useImperativeHandle","linkingContext","useMemo","options","isReady","onReadyRef","NavigationContainer","forwardRef"],"sources":["NavigationContainer.tsx"],"sourcesContent":["import {\n BaseNavigationContainer,\n getActionFromState,\n getPathFromState,\n getStateFromPath,\n NavigationContainerProps,\n NavigationContainerRef,\n ParamListBase,\n validatePathConfig,\n} from '@react-navigation/core';\nimport * as React from 'react';\n\nimport LinkingContext from './LinkingContext';\nimport DefaultTheme from './theming/DefaultTheme';\nimport ThemeProvider from './theming/ThemeProvider';\nimport type { DocumentTitleOptions, LinkingOptions, Theme } from './types';\nimport useBackButton from './useBackButton';\nimport useDocumentTitle from './useDocumentTitle';\nimport useLinking from './useLinking';\nimport useThenable from './useThenable';\n\ndeclare global {\n var REACT_NAVIGATION_DEVTOOLS: WeakMap<\n NavigationContainerRef<any>,\n { readonly linking: LinkingOptions<any> }\n >;\n}\n\nglobal.REACT_NAVIGATION_DEVTOOLS = new WeakMap();\n\ntype Props<ParamList extends {}> = NavigationContainerProps & {\n theme?: Theme;\n linking?: LinkingOptions<ParamList>;\n fallback?: React.ReactNode;\n documentTitle?: DocumentTitleOptions;\n onReady?: () => void;\n};\n\n/**\n * Container component which holds the navigation state designed for React Native apps.\n * This should be rendered at the root wrapping the whole app.\n *\n * @param props.initialState Initial state object for the navigation tree. When deep link handling is enabled, this will override deep links when specified. Make sure that you don't specify an `initialState` when there's a deep link (`Linking.getInitialURL()`).\n * @param props.onReady Callback which is called after the navigation tree mounts.\n * @param props.onStateChange Callback which is called with the latest navigation state when it changes.\n * @param props.theme Theme object for the navigators.\n * @param props.linking Options for deep linking. Deep link handling is enabled when this prop is provided, unless `linking.enabled` is `false`.\n * @param props.fallback Fallback component to render until we have finished getting initial state when linking is enabled. Defaults to `null`.\n * @param props.documentTitle Options to configure the document title on Web. Updating document title is handled by default unless `documentTitle.enabled` is `false`.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which refers to the navigation object containing helper methods.\n */\nfunction NavigationContainerInner(\n {\n theme = DefaultTheme,\n linking,\n fallback = null,\n documentTitle,\n onReady,\n ...rest\n }: Props<ParamListBase>,\n ref?: React.Ref<NavigationContainerRef<ParamListBase> | null>\n) {\n const isLinkingEnabled = linking ? linking.enabled !== false : false;\n\n if (linking?.config) {\n validatePathConfig(linking.config);\n }\n\n const refContainer =\n React.useRef<NavigationContainerRef<ParamListBase>>(null);\n\n useBackButton(refContainer);\n useDocumentTitle(refContainer, documentTitle);\n\n const { getInitialState } = useLinking(refContainer, {\n independent: rest.independent,\n enabled: isLinkingEnabled,\n prefixes: [],\n ...linking,\n });\n\n // Add additional linking related info to the ref\n // This will be used by the devtools\n React.useEffect(() => {\n if (refContainer.current) {\n REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {\n get linking() {\n return {\n ...linking,\n enabled: isLinkingEnabled,\n prefixes: linking?.prefixes ?? [],\n getStateFromPath: linking?.getStateFromPath ?? getStateFromPath,\n getPathFromState: linking?.getPathFromState ?? getPathFromState,\n getActionFromState:\n linking?.getActionFromState ?? getActionFromState,\n };\n },\n });\n }\n });\n\n const [isResolved, initialState] = useThenable(getInitialState);\n\n React.useImperativeHandle(ref, () => refContainer.current);\n\n const linkingContext = React.useMemo(() => ({ options: linking }), [linking]);\n\n const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;\n\n const onReadyRef = React.useRef(onReady);\n\n React.useEffect(() => {\n onReadyRef.current = onReady;\n });\n\n React.useEffect(() => {\n if (isReady) {\n onReadyRef.current?.();\n }\n }, [isReady]);\n\n if (!isReady) {\n // This is temporary until we have Suspense for data-fetching\n // Then the fallback will be handled by a parent `Suspense` component\n return fallback as React.ReactElement;\n }\n\n return (\n <LinkingContext.Provider value={linkingContext}>\n <ThemeProvider value={theme}>\n <BaseNavigationContainer\n {...rest}\n initialState={\n rest.initialState == null ? initialState : rest.initialState\n }\n ref={refContainer}\n />\n </ThemeProvider>\n </LinkingContext.Provider>\n );\n}\n\nconst NavigationContainer = React.forwardRef(NavigationContainerInner) as <\n RootParamList extends {} = ReactNavigation.RootParamList\n>(\n props: Props<RootParamList> & {\n ref?: React.Ref<NavigationContainerRef<RootParamList>>;\n }\n) => React.ReactElement;\n\nexport default NavigationContainer;\n"],"mappings":";;AAAA,SACEA,uBADF,EAEEC,kBAFF,EAGEC,gBAHF,EAIEC,gBAJF,EAQEC,kBARF,QASO,wBATP;AAUA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,cAAP,MAA2B,kBAA3B;AACA,OAAOC,YAAP,MAAyB,wBAAzB;AACA,OAAOC,aAAP,MAA0B,yBAA1B;AAEA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,OAAOC,gBAAP,MAA6B,oBAA7B;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,WAAP,MAAwB,eAAxB;AASAC,MAAM,CAACC,yBAAP,GAAmC,IAAIC,OAAJ,EAAnC;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,wBAAT,OASEC,GATF,EAUE;EAAA,IATA;IACEC,KAAK,GAAGX,YADV;IAEEY,OAFF;IAGEC,QAAQ,GAAG,IAHb;IAIEC,aAJF;IAKEC,OALF;IAME,GAAGC;EANL,CASA;EACA,MAAMC,gBAAgB,GAAGL,OAAO,GAAGA,OAAO,CAACM,OAAR,KAAoB,KAAvB,GAA+B,KAA/D;;EAEA,IAAIN,OAAJ,aAAIA,OAAJ,eAAIA,OAAO,CAAEO,MAAb,EAAqB;IACnBtB,kBAAkB,CAACe,OAAO,CAACO,MAAT,CAAlB;EACD;;EAED,MAAMC,YAAY,GAChBtB,KAAK,CAACuB,MAAN,CAAoD,IAApD,CADF;EAGAnB,aAAa,CAACkB,YAAD,CAAb;EACAjB,gBAAgB,CAACiB,YAAD,EAAeN,aAAf,CAAhB;EAEA,MAAM;IAAEQ;EAAF,IAAsBlB,UAAU,CAACgB,YAAD,EAAe;IACnDG,WAAW,EAAEP,IAAI,CAACO,WADiC;IAEnDL,OAAO,EAAED,gBAF0C;IAGnDO,QAAQ,EAAE,EAHyC;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AFD;EAIAjB,KAAK,CAAC2B,SAAN,CAAgB,MAAM;IACpB,IAAIS,OAAJ,EAAa;MAAA;;MACX,uBAAAC,UAAU,CAACT,OAAX,iFAAAS,UAAU;IACX;EACF,CAJD,EAIG,CAACD,OAAD,CAJH;;EAMA,IAAI,CAACA,OAAL,EAAc;IACZ;IACA;IACA,OAAOrB,QAAP;EACD;;EAED,oBACE,oBAAC,cAAD,CAAgB,QAAhB;IAAyB,KAAK,EAAEkB;EAAhC,gBACE,oBAAC,aAAD;IAAe,KAAK,EAAEpB;EAAtB,gBACE,oBAAC,uBAAD,eACMK,IADN;IAEE,YAAY,EACVA,IAAI,CAACa,YAAL,IAAqB,IAArB,GAA4BA,YAA5B,GAA2Cb,IAAI,CAACa,YAHpD;IAKE,GAAG,EAAET;EALP,GADF,CADF,CADF;AAaD;;AAED,MAAMgB,mBAAmB,gBAAGtC,KAAK,CAACuC,UAAN,CAAiB5B,wBAAjB,CAA5B;AAQA,eAAe2B,mBAAf"}
1
+ {"version":3,"names":["BaseNavigationContainer","getActionFromState","getPathFromState","getStateFromPath","validatePathConfig","React","LinkingContext","DefaultTheme","ThemeProvider","useBackButton","useDocumentTitle","useLinking","useThenable","global","REACT_NAVIGATION_DEVTOOLS","WeakMap","NavigationContainerInner","ref","theme","linking","fallback","documentTitle","onReady","rest","isLinkingEnabled","enabled","config","refContainer","useRef","getInitialState","independent","prefixes","useEffect","current","set","isResolved","initialState","useImperativeHandle","linkingContext","useMemo","options","isReady","onReadyRef","NavigationContainer","forwardRef"],"sourceRoot":"../../src","sources":["NavigationContainer.tsx"],"mappings":";AAAA,SACEA,uBAAuB,EACvBC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,EAIhBC,kBAAkB,QACb,wBAAwB;AAC/B,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,OAAOC,cAAc,MAAM,kBAAkB;AAC7C,OAAOC,YAAY,MAAM,wBAAwB;AACjD,OAAOC,aAAa,MAAM,yBAAyB;A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AAC,KAAK,EAAEkB;EAAe,gBAC7C,oBAAC,aAAa;IAAC,KAAK,EAAEpB;EAAM,gBAC1B,oBAAC,uBAAuB,eAClBK,IAAI;IACR,YAAY,EACVA,IAAI,CAACa,YAAY,IAAI,IAAI,GAAGA,YAAY,GAAGb,IAAI,CAACa,YACjD;IACD,GAAG,EAAET;EAAa,GAClB,CACY,CACQ;AAE9B;AAEA,MAAMgB,mBAAmB,gBAAGtC,KAAK,CAACuC,UAAU,CAAC5B,wBAAwB,CAM9C;AAEvB,eAAe2B,mBAAmB"}
@@ -1,7 +1,6 @@
1
1
  import { CurrentRenderContext } from '@react-navigation/core';
2
2
  import * as React from 'react';
3
3
  import ServerContext from './ServerContext';
4
-
5
4
  /**
6
5
  * Container component for server rendering.
7
6
  *
@@ -18,18 +17,17 @@ export default /*#__PURE__*/React.forwardRef(function ServerContainer(_ref, ref)
18
17
  console.error("'ServerContainer' should only be used on the server with 'react-dom/server' for SSR.");
19
18
  }, []);
20
19
  const current = {};
21
-
22
20
  if (ref) {
23
21
  const value = {
24
22
  getCurrentOptions() {
25
23
  return current.options;
26
24
  }
25
+ };
27
26
 
28
- }; // We write to the `ref` during render instead of `React.useImperativeHandle`
27
+ // We write to the `ref` during render instead of `React.useImperativeHandle`
29
28
  // This is because `useImperativeHandle` will update the ref after 'commit',
30
29
  // and there's no 'commit' phase during SSR.
31
30
  // Mutating ref during render is unsafe in concurrent mode, but we don't care about it for SSR.
32
-
33
31
  if (typeof ref === 'function') {
34
32
  ref(value);
35
33
  } else {
@@ -37,7 +35,6 @@ export default /*#__PURE__*/React.forwardRef(function ServerContainer(_ref, ref)
37
35
  ref.current = value;
38
36
  }
39
37
  }
40
-
41
38
  return /*#__PURE__*/React.createElement(ServerContext.Provider, {
42
39
  value: {
43
40
  location
@@ -1 +1 @@
1
- {"version":3,"names":["CurrentRenderContext","React","ServerContext","forwardRef","ServerContainer","ref","children","location","useEffect","console","error","current","value","getCurrentOptions","options"],"sources":["ServerContainer.tsx"],"sourcesContent":["import { CurrentRenderContext } from '@react-navigation/core';\nimport * as React from 'react';\n\nimport ServerContext, { ServerContextType } from './ServerContext';\nimport type { ServerContainerRef } from './types';\n\ntype Props = ServerContextType & {\n children: React.ReactNode;\n};\n\n/**\n * Container component for server rendering.\n *\n * @param props.location Location object to base the initial URL for SSR.\n * @param props.children Child elements to render the content.\n * @param props.ref Ref object which contains helper methods.\n */\nexport default React.forwardRef(function ServerContainer(\n { children, location }: Props,\n ref: React.Ref<ServerContainerRef>\n) {\n React.useEffect(() => {\n console.error(\n \"'ServerContainer' should only be used on the server with 'react-dom/server' for SSR.\"\n );\n }, []);\n\n const current: { options?: object } = {};\n\n if (ref) {\n const value = {\n getCurrentOptions() {\n return current.options;\n },\n };\n\n // We write to the `ref` during render instead of `React.useImperativeHandle`\n // This is because `useImperativeHandle` will update the ref after 'commit',\n // and there's no 'commit' phase during SSR.\n // Mutating ref during render is unsafe in concurrent mode, but we don't care about it for SSR.\n if (typeof ref === 'function') {\n ref(value);\n } else {\n // @ts-expect-error: the TS types are incorrect and say that ref.current is readonly\n ref.current = value;\n }\n }\n\n return (\n <ServerContext.Provider value={{ location }}>\n <CurrentRenderContext.Provider value={current}>\n {children}\n </CurrentRenderContext.Provider>\n </ServerContext.Provider>\n );\n});\n"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,wBAArC;AACA,OAAO,KAAKC,KAAZ,MAAuB,OAAvB;AAEA,OAAOC,aAAP,MAAiD,iBAAjD;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAAeD,KAAK,CAACE,UAAN,CAAiB,SAASC,eAAT,OAE9BC,GAF8B,EAG9B;EAAA,IAFA;IAAEC,QAAF;IAAYC;EAAZ,CAEA;EACAN,KAAK,CAACO,SAAN,CAAgB,MAAM;IACpBC,OAAO,CAACC,KAAR,CACE,sFADF;EAGD,CAJD,EAIG,EAJH;EAMA,MAAMC,OAA6B,GAAG,EAAtC;;EAEA,IAAIN,GAAJ,EAAS;IACP,MAAMO,KAAK,GAAG;MACZC,iBAAiB,GAAG;QAClB,OAAOF,OAAO,CAACG,OAAf;MACD;;IAHW,CAAd,CADO,CAOP;IACA;IACA;IACA;;IACA,IAAI,OAAOT,GAAP,KAAe,UAAnB,EAA+B;MAC7BA,GAAG,CAACO,KAAD,CAAH;IACD,CAFD,MAEO;MACL;MACAP,GAAG,CAACM,OAAJ,GAAcC,KAAd;IACD;EACF;;EAED,oBACE,oBAAC,aAAD,CAAe,QAAf;IAAwB,KAAK,EAAE;MAAEL;IAAF;EAA/B,gBACE,oBAAC,oBAAD,CAAsB,QAAtB;IAA+B,KAAK,EAAEI;EAAtC,GACGL,QADH,CADF,CADF;AAOD,CAtCc,CAAf"}
1
+ {"version":3,"names":["CurrentRenderContext","React","ServerContext","forwardRef","ServerContainer","ref","children","location","useEffect","console","error","current","value","getCurrentOptions","options"],"sourceRoot":"../../src","sources":["ServerContainer.tsx"],"mappings":"AAAA,SAASA,oBAAoB,QAAQ,wBAAwB;AAC7D,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,OAAOC,aAAa,MAA6B,iBAAiB;AAOlE;AACA;AACA;AACA;AACA;AACA;AACA;AACA,4BAAeD,KAAK,CAACE,UAAU,CAAC,SAASC,eAAe,OAEtDC,GAAkC,EAClC;EAAA,IAFA;IAAEC,QAAQ;IAAEC;EAAgB,CAAC;EAG7BN,KAAK,CAACO,SAAS,CAAC,MAAM;IACpBC,OAAO,CAACC,KAAK,CACX,sFAAsF,CACvF;EACH,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMC,OAA6B,GAAG,CAAC,CAAC;EAExC,IAAIN,GAAG,EAAE;IACP,MAAMO,KAAK,GAAG;MACZC,iBAAiB,GAAG;QAClB,OAAOF,OAAO,CAACG,OAAO;MACxB;IACF,CAAC;;IAED;IACA;IACA;IACA;IACA,IAAI,OAAOT,GAAG,KAAK,UAAU,EAAE;MAC7BA,GAAG,CAACO,KAAK,CAAC;IACZ,CAAC,MAAM;MACL;MACAP,GAAG,CAACM,OAAO,GAAGC,KAAK;IACrB;EACF;EAEA,oBACE,oBAAC,aAAa,CAAC,QAAQ;IAAC,KAAK,EAAE;MAAEL;IAAS;EAAE,gBAC1C,oBAAC,oBAAoB,CAAC,QAAQ;IAAC,KAAK,EAAEI;EAAQ,GAC3CL,QAAQ,CACqB,CACT;AAE7B,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"names":["React","ServerContext","createContext","undefined"],"sources":["ServerContext.tsx"],"sourcesContent":["import * as React from 'react';\n\nexport type ServerContextType = {\n location?: {\n pathname: string;\n search: string;\n };\n};\n\nconst ServerContext = React.createContext<ServerContextType | undefined>(\n undefined\n);\n\nexport default ServerContext;\n"],"mappings":"AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AASA,MAAMC,aAAa,gBAAGD,KAAK,CAACE,aAAN,CACpBC,SADoB,CAAtB;AAIA,eAAeF,aAAf"}
1
+ {"version":3,"names":["React","ServerContext","createContext","undefined"],"sourceRoot":"../../src","sources":["ServerContext.tsx"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAS9B,MAAMC,aAAa,gBAAGD,KAAK,CAACE,aAAa,CACvCC,SAAS,CACV;AAED,eAAeF,aAAa"}