1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | var _core = require("@react-navigation/core");
|
9 |
|
10 | var React = _interopRequireWildcard(require("react"));
|
11 |
|
12 | var _LinkingContext = _interopRequireDefault(require("./LinkingContext"));
|
13 |
|
14 | var _DefaultTheme = _interopRequireDefault(require("./theming/DefaultTheme"));
|
15 |
|
16 | var _ThemeProvider = _interopRequireDefault(require("./theming/ThemeProvider"));
|
17 |
|
18 | var _useBackButton = _interopRequireDefault(require("./useBackButton"));
|
19 |
|
20 | var _useDocumentTitle = _interopRequireDefault(require("./useDocumentTitle"));
|
21 |
|
22 | var _useLinking = _interopRequireDefault(require("./useLinking"));
|
23 |
|
24 | var _useThenable = _interopRequireDefault(require("./useThenable"));
|
25 |
|
26 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
27 |
|
28 | 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); }
|
29 |
|
30 | 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; }
|
31 |
|
32 | function _extends() { _extends = Object.assign || 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); }
|
33 |
|
34 | global.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 |
|
45 |
|
46 |
|
47 |
|
48 |
|
49 |
|
50 | function NavigationContainerInner({
|
51 | theme = _DefaultTheme.default,
|
52 | linking,
|
53 | fallback = null,
|
54 | documentTitle,
|
55 | onReady,
|
56 | ...rest
|
57 | }, ref) {
|
58 | const isLinkingEnabled = linking ? linking.enabled !== false : false;
|
59 |
|
60 | if (linking !== null && linking !== void 0 && linking.config) {
|
61 | (0, _core.validatePathConfig)(linking.config);
|
62 | }
|
63 |
|
64 | const refContainer = React.useRef(null);
|
65 | (0, _useBackButton.default)(refContainer);
|
66 | (0, _useDocumentTitle.default)(refContainer, documentTitle);
|
67 | const {
|
68 | getInitialState
|
69 | } = (0, _useLinking.default)(refContainer, {
|
70 | independent: rest.independent,
|
71 | enabled: isLinkingEnabled,
|
72 | prefixes: [],
|
73 | ...linking
|
74 | });
|
75 |
|
76 |
|
77 | React.useEffect(() => {
|
78 | if (refContainer.current) {
|
79 | REACT_NAVIGATION_DEVTOOLS.set(refContainer.current, {
|
80 | get linking() {
|
81 | var _linking$prefixes, _linking$getStateFrom, _linking$getPathFromS, _linking$getActionFro;
|
82 |
|
83 | return { ...linking,
|
84 | enabled: isLinkingEnabled,
|
85 | prefixes: (_linking$prefixes = linking === null || linking === void 0 ? void 0 : linking.prefixes) !== null && _linking$prefixes !== void 0 ? _linking$prefixes : [],
|
86 | getStateFromPath: (_linking$getStateFrom = linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) !== null && _linking$getStateFrom !== void 0 ? _linking$getStateFrom : _core.getStateFromPath,
|
87 | getPathFromState: (_linking$getPathFromS = linking === null || linking === void 0 ? void 0 : linking.getPathFromState) !== null && _linking$getPathFromS !== void 0 ? _linking$getPathFromS : _core.getPathFromState,
|
88 | getActionFromState: (_linking$getActionFro = linking === null || linking === void 0 ? void 0 : linking.getActionFromState) !== null && _linking$getActionFro !== void 0 ? _linking$getActionFro : _core.getActionFromState
|
89 | };
|
90 | }
|
91 |
|
92 | });
|
93 | }
|
94 | });
|
95 | const [isResolved, initialState] = (0, _useThenable.default)(getInitialState);
|
96 | React.useImperativeHandle(ref, () => refContainer.current);
|
97 | const linkingContext = React.useMemo(() => ({
|
98 | options: linking
|
99 | }), [linking]);
|
100 | const isReady = rest.initialState != null || !isLinkingEnabled || isResolved;
|
101 | const onReadyRef = React.useRef(onReady);
|
102 | React.useEffect(() => {
|
103 | onReadyRef.current = onReady;
|
104 | });
|
105 | React.useEffect(() => {
|
106 | if (isReady) {
|
107 | var _onReadyRef$current;
|
108 |
|
109 | (_onReadyRef$current = onReadyRef.current) === null || _onReadyRef$current === void 0 ? void 0 : _onReadyRef$current.call(onReadyRef);
|
110 | }
|
111 | }, [isReady]);
|
112 |
|
113 | if (!isReady) {
|
114 |
|
115 |
|
116 | return fallback;
|
117 | }
|
118 |
|
119 | return React.createElement(_LinkingContext.default.Provider, {
|
120 | value: linkingContext
|
121 | }, React.createElement(_ThemeProvider.default, {
|
122 | value: theme
|
123 | }, React.createElement(_core.BaseNavigationContainer, _extends({}, rest, {
|
124 | initialState: rest.initialState == null ? initialState : rest.initialState,
|
125 | ref: refContainer
|
126 | }))));
|
127 | }
|
128 |
|
129 | const NavigationContainer = React.forwardRef(NavigationContainerInner);
|
130 | var _default = NavigationContainer;
|
131 | exports.default = _default;
|
132 |
|
\ | No newline at end of file |