You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
14 KiB
1 line
14 KiB
{"ast":null,"code":"import _slicedToArray from \"@babel/runtime/helpers/slicedToArray\";\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nvar _excluded = [\"theme\", \"linking\", \"fallback\", \"documentTitle\", \"onReady\"];\nfunction ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }\nfunction _extends() {\n _extends = Object.assign ? Object.assign.bind() : function (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n if (Object.prototype.hasOwnProperty.call(source, key)) {\n target[key] = source[key];\n }\n }\n }\n return target;\n };\n return _extends.apply(this, arguments);\n}\nimport { BaseNavigationContainer, getActionFromState, getPathFromState, getStateFromPath, validatePathConfig } from '@react-navigation/core';\nimport * as React from 'react';\nimport LinkingContext from \"./LinkingContext\";\nimport DefaultTheme from \"./theming/DefaultTheme\";\nimport ThemeProvider from \"./theming/ThemeProvider\";\nimport useBackButton from \"./useBackButton\";\nimport useDocumentTitle from \"./useDocumentTitle\";\nimport useLinking from \"./useLinking\";\nimport useThenable from \"./useThenable\";\nglobal.REACT_NAVIGATION_DEVTOOLS = new WeakMap();\nfunction NavigationContainerInner(_ref, ref) {\n var _ref$theme = _ref.theme,\n theme = _ref$theme === void 0 ? DefaultTheme : _ref$theme,\n linking = _ref.linking,\n _ref$fallback = _ref.fallback,\n fallback = _ref$fallback === void 0 ? null : _ref$fallback,\n documentTitle = _ref.documentTitle,\n onReady = _ref.onReady,\n rest = _objectWithoutProperties(_ref, _excluded);\n var isLinkingEnabled = linking ? linking.enabled !== false : false;\n if (linking !== null && linking !== void 0 && linking.config) {\n validatePathConfig(linking.config);\n }\n var refContainer = React.useRef(null);\n useBackButton(refContainer);\n useDocumentTitle(refContainer, documentTitle);\n var _useLinking = useLinking(refContainer, _objectSpread({\n independent: rest.independent,\n enabled: isLinkingEnabled,\n prefixes: []\n }, linking)),\n getInitialState = _useLinking.getInitialState;\n React.useEffect(function () {\n if (refContainer.current) {\n REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {\n get linking() {\n var _ref2, _ref3, _ref4, _ref5;\n return _objectSpread(_objectSpread({}, linking), {}, {\n enabled: isLinkingEnabled,\n prefixes: (_ref2 = linking === null || linking === void 0 ? void 0 : linking.prefixes) != null ? _ref2 : [],\n getStateFromPath: (_ref3 = linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) != null ? _ref3 : getStateFromPath,\n getPathFromState: (_ref4 = linking === null || linking === void 0 ? void 0 : linking.getPathFromState) != null ? _ref4 : getPathFromState,\n getActionFromState: (_ref5 = linking === null || linking === void 0 ? void 0 : linking.getActionFromState) != null ? _ref5 : getActionFromState\n });\n }\n });\n }\n });\n var _useThenable = useThenable(getInitialState),\n _useThenable2 = _slicedToArray(_useThenable, 2),\n isResolved = _useThenable2[0],\n initialState = _useThenable2[1];\n React.useImperativeHandle(ref, function () {\n return refContainer.current;\n });\n var linkingContext = React.useMemo(function () {\n return {\n options: linking\n };\n }, [linking]);\n var isReady = rest.initialState != null || !isLinkingEnabled || isResolved;\n var onReadyRef = React.useRef(onReady);\n React.useEffect(function () {\n onReadyRef.current = onReady;\n });\n React.useEffect(function () {\n if (isReady) {\n var _onReadyRef$current;\n (_onReadyRef$current = onReadyRef.current) === null || _onReadyRef$current === void 0 ? void 0 : _onReadyRef$current.call(onReadyRef);\n }\n }, [isReady]);\n if (!isReady) {\n return fallback;\n }\n return React.createElement(LinkingContext.Provider, {\n value: linkingContext\n }, React.createElement(ThemeProvider, {\n value: theme\n }, React.createElement(BaseNavigationContainer, _extends({}, rest, {\n initialState: rest.initialState == null ? initialState : rest.initialState,\n ref: refContainer\n }))));\n}\nvar NavigationContainer = React.forwardRef(NavigationContainerInner);\nexport default NavigationContainer;","map":{"version":3,"sources":["NavigationContainer.tsx"],"names":["BaseNavigationContainer","getActionFromState","getPathFromState","getStateFromPath","validatePathConfig","React","LinkingContext","DefaultTheme","ThemeProvider","useBackButton","useDocumentTitle","useLinking","useThenable","global","REACT_NAVIGATION_DEVTOOLS","WeakMap","NavigationContainerInner","theme","linking","fallback","documentTitle","onReady","rest","ref","isLinkingEnabled","enabled","config","refContainer","useRef","getInitialState","independent","prefixes","useEffect","current","set","isResolved","initialState","useImperativeHandle","linkingContext","useMemo","options","isReady","onReadyRef","NavigationContainer","forwardRef"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,SACEA,uBAAuB,EACvBC,kBAAkB,EAClBC,gBAAgB,EAChBC,gBAAgB,EAIhBC,kBAAkB,QACb,wBAAwB;AAC/B,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,OAAOC,cAAc;AACrB,OAAOC,YAAY;AACnB,OAAOC,aAAa;AAEpB,OAAOC,aAAa;AACpB,OAAOC,gBAAgB;AACvB,OAAOC,UAAU;AACjB,OAAOC,WAAW;AASlBC,MAAM,CAACC,yBAAyB,GAAG,IAAIC,OAAO,EAAE;AAwBhD,SAASC,wBAAwB,CAAA,IAAA,EAS/BO,GAA6D,EAC7D;EATA,iBAOuB,IAAA,CANrBN,KAAK;IAALA,KAAK,2BAAGV,YAAY;IACpBW,OAAO,GAKc,IAAA,CALrBA,OAAO;IAAA,gBAKc,IAA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AAA;IAAC,KAAK,EAAEmB;EAAe,CAAA,EAC7C,KAAA,CAAA,aAAA,CAAC,aAAa,EAAA;IAAC,KAAK,EAAErB;EAAM,CAAA,EAC1B,KAAA,CAAA,aAAA,CAAC,uBAAuB,EAAA,QAAA,CAAA,CAAA,CAAA,EAClBK,IAAI,EAAA;IACR,YAAY,EACVA,IAAI,CAACc,YAAY,IAAI,IAAI,GAAGA,YAAY,GAAGd,IAAI,CAACc,YACjD;IACD,GAAG,EAAET;EAAa,CAAA,CAAA,CAClB,CACY,CACQ;AAE9B;AAEA,IAAMgB,mBAAmB,GAAGtC,KAAK,CAACuC,UAAU,CAAC5B,wBAAwB,CAM9C;AAEvB,eAAe2B,mBAAmB","sourceRoot":"../../src","sourcesContent":["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); }\nimport { BaseNavigationContainer, getActionFromState, getPathFromState, getStateFromPath, validatePathConfig } from '@react-navigation/core';\nimport * as React from 'react';\nimport LinkingContext from './LinkingContext';\nimport DefaultTheme from './theming/DefaultTheme';\nimport ThemeProvider from './theming/ThemeProvider';\nimport useBackButton from './useBackButton';\nimport useDocumentTitle from './useDocumentTitle';\nimport useLinking from './useLinking';\nimport useThenable from './useThenable';\nglobal.REACT_NAVIGATION_DEVTOOLS = new WeakMap();\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(_ref, ref) {\n let {\n theme = DefaultTheme,\n linking,\n fallback = null,\n documentTitle,\n onReady,\n ...rest\n } = _ref;\n const isLinkingEnabled = linking ? linking.enabled !== false : false;\n if (linking !== null && linking !== void 0 && linking.config) {\n validatePathConfig(linking.config);\n }\n const refContainer = React.useRef(null);\n useBackButton(refContainer);\n useDocumentTitle(refContainer, documentTitle);\n const {\n getInitialState\n } = 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 === null || linking === void 0 ? void 0 : linking.prefixes) ?? [],\n getStateFromPath: (linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) ?? getStateFromPath,\n getPathFromState: (linking === null || linking === void 0 ? void 0 : linking.getPathFromState) ?? getPathFromState,\n getActionFromState: (linking === null || linking === void 0 ? void 0 : linking.getActionFromState) ?? getActionFromState\n };\n }\n });\n }\n });\n const [isResolved, initialState] = useThenable(getInitialState);\n React.useImperativeHandle(ref, () => refContainer.current);\n const linkingContext = React.useMemo(() => ({\n options: linking\n }), [linking]);\n const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;\n const onReadyRef = React.useRef(onReady);\n React.useEffect(() => {\n onReadyRef.current = onReady;\n });\n React.useEffect(() => {\n if (isReady) {\n var _onReadyRef$current;\n (_onReadyRef$current = onReadyRef.current) === null || _onReadyRef$current === void 0 ? void 0 : _onReadyRef$current.call(onReadyRef);\n }\n }, [isReady]);\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;\n }\n return /*#__PURE__*/React.createElement(LinkingContext.Provider, {\n value: linkingContext\n }, /*#__PURE__*/React.createElement(ThemeProvider, {\n value: theme\n }, /*#__PURE__*/React.createElement(BaseNavigationContainer, _extends({}, rest, {\n initialState: rest.initialState == null ? initialState : rest.initialState,\n ref: refContainer\n }))));\n}\nconst NavigationContainer = /*#__PURE__*/React.forwardRef(NavigationContainerInner);\nexport default NavigationContainer;\n//# sourceMappingURL=NavigationContainer.js.map"]},"metadata":{},"sourceType":"module"} |