UNPKG

8.3 kBSource Map (JSON)View Raw
1{"version":3,"names":["global","REACT_NAVIGATION_DEVTOOLS","WeakMap","NavigationContainerInner","ref","theme","DefaultTheme","linking","fallback","documentTitle","onReady","rest","isLinkingEnabled","enabled","config","validatePathConfig","refContainer","React","useRef","useBackButton","useDocumentTitle","getInitialState","useLinking","independent","prefixes","useEffect","current","set","getStateFromPath","getPathFromState","getActionFromState","isResolved","initialState","useThenable","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;;AAUA;;AAEA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AACA;;;;;;;;;;AASAA,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,GAAGC,qBADV;IAEEC,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;IACnB,IAAAC,wBAAA,EAAmBR,OAAO,CAACO,MAA3B;EACD;;EAED,MAAME,YAAY,GAChBC,KAAK,CAACC,MAAN,CAAoD,IAApD,CADF;EAGA,IAAAC,sBAAA,EAAcH,YAAd;EACA,IAAAI,yBAAA,EAAiBJ,YAAjB,EAA+BP,aAA/B;EAEA,MAAM;IAAEY;EAAF,IAAsB,IAAAC,mBAAA,EAAWN,YAAX,EAAyB;IACnDO,WAAW,EAAEZ,IAAI,CAACY,WADiC;IAEnDV,OAAO,EAAED,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