You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 7-8.RSVP
Socket
Socket
Sign inDemoInstall

@react-navigation/native

Package Overview
Dependencies
Maintainers
6
Versions
246
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.0.12 to 6.1.8

lib/commonjs/useBackButton.native.js

89

lib/commonjs/createMemoryHistory.js

@@ -7,12 +7,10 @@ "use strict";

exports.default = createMemoryHistory;
var _nonSecure = require("nanoid/non-secure");
function createMemoryHistory() {
let index = 0;
let items = []; // Pending callbacks for `history.go(n)`
let items = [];
// Pending callbacks for `history.go(n)`
// We might modify the callback stored if it was interrupted, so we have a ref to identify it
const pending = [];
const interrupt = () => {

@@ -24,15 +22,11 @@ // If another history operation was performed we need to interrupt existing ones

const cb = it.cb;
it.cb = () => cb(true);
});
};
const history = {
get index() {
var _window$history$state;
// We store an id in the state instead of an index
// Index could get out of sync with in-memory values if page reloads
const id = (_window$history$state = window.history.state) === null || _window$history$state === void 0 ? void 0 : _window$history$state.id;
if (id) {

@@ -42,10 +36,7 @@ const index = items.findIndex(item => item.id === id);

}
return 0;
},
get(index) {
return items[index];
},
backIndex(_ref) {

@@ -55,7 +46,5 @@ let {

} = _ref;
// We need to find the index from the element before current to get closest path to go back to
for (let i = index - 1; i >= 0; i--) {
const item = items[i];
if (item.path === path) {

@@ -65,6 +54,4 @@ return i;

}
return -1;
},
push(_ref2) {

@@ -76,5 +63,6 @@ let {

interrupt();
const id = (0, _nonSecure.nanoid)(); // When a new entry is pushed, all the existing entries after index will be inaccessible
const id = (0, _nonSecure.nanoid)();
// When a new entry is pushed, all the existing entries after index will be inaccessible
// So we remove any existing entries after the current index to clean them up
items = items.slice(0, index + 1);

@@ -86,7 +74,8 @@ items.push({

});
index = items.length - 1; // We pass empty string for title because it's ignored in all browsers except safari
index = items.length - 1;
// We pass empty string for title because it's ignored in all browsers except safari
// We don't store state object in history.state because:
// - browsers have limits on how big it can be, and we don't control the size
// - while not recommended, there could be non-serializable data in state
window.history.pushState({

@@ -96,6 +85,4 @@ id

},
replace(_ref3) {
var _window$history$state2, _window$history$state3;
var _window$history$state2;
let {

@@ -106,4 +93,7 @@ path,

interrupt();
const id = (_window$history$state2 = (_window$history$state3 = window.history.state) === null || _window$history$state3 === void 0 ? void 0 : _window$history$state3.id) !== null && _window$history$state2 !== void 0 ? _window$history$state2 : (0, _nonSecure.nanoid)();
const id = ((_window$history$state2 = window.history.state) === null || _window$history$state2 === void 0 ? void 0 : _window$history$state2.id) ?? (0, _nonSecure.nanoid)();
// Need to keep the hash part of the path if there was no previous history entry
// or the previous history entry had the same path
let pathWithHash = path;
if (!items.length || items.findIndex(item => item.id === id) < 0) {

@@ -116,4 +106,5 @@ // There are two scenarios for creating an array with only one history record:

// So we need to push the entry as there's nothing to replace
pathWithHash = pathWithHash + location.hash;
items = [{
path,
path: pathWithHash,
state,

@@ -124,2 +115,5 @@ id

} else {
if (items[index].path === path) {
pathWithHash = pathWithHash + location.hash;
}
items[index] = {

@@ -131,8 +125,6 @@ path,

}
window.history.replaceState({
id
}, '', path);
}, '', pathWithHash);
},
// `history.go(n)` is asynchronous, there are couple of things to keep in mind:

@@ -144,8 +136,8 @@ // - it won't do anything if we can't go `n` steps, the `popstate` event won't fire.

go(n) {
interrupt(); // 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
interrupt();
// 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
// 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.
const nextIndex = index + n;
const lastItemIndex = items.length - 1;
if (n < 0 && !items[nextIndex]) {

@@ -162,6 +154,7 @@ // Attempted to navigate beyond the first index. Negating the current index will align the browser history with the first item.

}
if (n === 0) {
return;
} // When we call `history.go`, `popstate` will fire when there's history to go back to
}
// When we call `history.go`, `popstate` will fire when there's history to go back to
// So we need to somehow handle following cases:

@@ -171,12 +164,11 @@ // - There's history to go back, `history.go` is called, and `popstate` fires

// - No history to go back, but `history.go` was called, browser has no API to detect it
return new Promise((resolve, reject) => {
const done = interrupted => {
clearTimeout(timer);
if (interrupted) {
reject(new Error('History was changed during navigation.'));
return;
} // There seems to be a bug in Chrome regarding updating the title
}
// There seems to be a bug in Chrome regarding updating the title
// If we set a title just before calling `history.go`, the title gets lost

@@ -189,4 +181,2 @@ // However the value of `document.title` is still what we set it to

// Which means that the browser won't do anything after setting the title
const {

@@ -199,7 +189,8 @@ title

};
pending.push({
ref: done,
cb: done
}); // If navigation didn't happen within 100ms, assume that it won't happen
});
// If navigation didn't happen within 100ms, assume that it won't happen
// This may not be accurate, but hopefully it won't take so much time

@@ -209,6 +200,4 @@ // In Chrome, navigation seems to happen instantly in next microtask

// We're using a hacky timeout since there doesn't seem to be way to know for sure
const timer = setTimeout(() => {
const index = pending.findIndex(it => it.ref === done);
if (index > -1) {

@@ -219,10 +208,9 @@ pending[index].cb();

}, 100);
const onPopState = () => {
var _window$history$state4;
var _window$history$state3;
const id = (_window$history$state3 = window.history.state) === null || _window$history$state3 === void 0 ? void 0 : _window$history$state3.id;
const currentIndex = items.findIndex(item => item.id === id);
const id = (_window$history$state4 = window.history.state) === null || _window$history$state4 === void 0 ? void 0 : _window$history$state4.id;
const currentIndex = items.findIndex(item => item.id === id); // Fix createMemoryHistory.index variable's value
// Fix createMemoryHistory.index variable's value
// as it may go out of sync when navigating in the browser.
index = Math.max(currentIndex, 0);

@@ -233,3 +221,2 @@ const last = pending.pop();

};
window.addEventListener('popstate', onPopState);

@@ -239,3 +226,2 @@ window.history.go(n);

},
// The `popstate` event is triggered when history changes, except `pushState` and `replaceState`

@@ -250,10 +236,7 @@ // If we call `history.go(n)` ourselves, we don't want it to trigger the listener

}
listener();
};
window.addEventListener('popstate', onPopState);
return () => window.removeEventListener('popstate', onPopState);
}
};

@@ -260,0 +243,0 @@ return history;

@@ -7,12 +7,8 @@ "use strict";

exports.default = extractPathFromURL;
var _escapeStringRegexp = _interopRequireDefault(require("escape-string-regexp"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function extractPathFromURL(prefixes, url) {
for (const prefix of prefixes) {
var _prefix$match$, _prefix$match;
const protocol = (_prefix$match$ = (_prefix$match = prefix.match(/^[^:]+:/)) === null || _prefix$match === void 0 ? void 0 : _prefix$match[0]) !== null && _prefix$match$ !== void 0 ? _prefix$match$ : '';
var _prefix$match;
const protocol = ((_prefix$match = prefix.match(/^[^:]+:/)) === null || _prefix$match === void 0 ? void 0 : _prefix$match[0]) ?? '';
const host = prefix.replace(new RegExp(`^${(0, _escapeStringRegexp.default)(protocol)}`), '').replace(/\/+/g, '/') // Replace multiple slash (//) with single ones

@@ -22,4 +18,4 @@ .replace(/^\//, ''); // Remove extra leading slash

const prefixRegex = new RegExp(`^${(0, _escapeStringRegexp.default)(protocol)}(/)*${host.split('.').map(it => it === '*' ? '[^/]+' : (0, _escapeStringRegexp.default)(it)).join('\\.')}`);
const normalizedURL = url.replace(/\/+/g, '/');
const [originAndPath, searchParams] = url.split('?');
const normalizedURL = originAndPath.replace(/\/+/g, '/').concat(searchParams ? `?${searchParams}` : '');
if (prefixRegex.test(normalizedURL)) {

@@ -29,5 +25,4 @@ return normalizedURL.replace(prefixRegex, '');

}
return undefined;
}
//# sourceMappingURL=extractPathFromURL.js.map

@@ -92,21 +92,11 @@ "use strict";

});
var _Link = _interopRequireDefault(require("./Link"));
var _LinkingContext = _interopRequireDefault(require("./LinkingContext"));
var _NavigationContainer = _interopRequireDefault(require("./NavigationContainer"));
var _ServerContainer = _interopRequireDefault(require("./ServerContainer"));
var _DarkTheme = _interopRequireDefault(require("./theming/DarkTheme"));
var _DefaultTheme = _interopRequireDefault(require("./theming/DefaultTheme"));
var _ThemeProvider = _interopRequireDefault(require("./theming/ThemeProvider"));
var _useTheme = _interopRequireDefault(require("./theming/useTheme"));
var _types = require("./types");
Object.keys(_types).forEach(function (key) {

@@ -123,13 +113,7 @@ if (key === "default" || key === "__esModule") return;

});
var _useLinkBuilder = _interopRequireDefault(require("./useLinkBuilder"));
var _useLinkProps = _interopRequireDefault(require("./useLinkProps"));
var _useLinkTo = _interopRequireDefault(require("./useLinkTo"));
var _useScrollToTop = _interopRequireDefault(require("./useScrollToTop"));
var _core = require("@react-navigation/core");
Object.keys(_core).forEach(function (key) {

@@ -146,4 +130,3 @@ if (key === "default" || key === "__esModule") return;

});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

@@ -7,15 +7,8 @@ "use strict";

exports.default = Link;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _useLinkProps = _interopRequireDefault(require("./useLinkProps"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
/**

@@ -39,14 +32,11 @@ * Component to render link to another screen using a path.

});
const onPress = e => {
if ('onPress' in rest) {
var _rest$onPress;
(_rest$onPress = rest.onPress) === null || _rest$onPress === void 0 ? void 0 : _rest$onPress.call(rest, e);
}
props.onPress(e);
};
return /*#__PURE__*/React.createElement(_reactNative.Text, { ...props,
return /*#__PURE__*/React.createElement(_reactNative.Text, {
...props,
...rest,

@@ -53,0 +43,0 @@ ..._reactNative.Platform.select({

@@ -7,9 +7,5 @@ "use strict";

exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
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); }
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; }
const LinkingContext = /*#__PURE__*/React.createContext({

@@ -16,0 +12,0 @@ options: undefined

@@ -7,31 +7,16 @@ "use strict";

exports.default = void 0;
var _core = require("@react-navigation/core");
var React = _interopRequireWildcard(require("react"));
var _LinkingContext = _interopRequireDefault(require("./LinkingContext"));
var _DefaultTheme = _interopRequireDefault(require("./theming/DefaultTheme"));
var _ThemeProvider = _interopRequireDefault(require("./theming/ThemeProvider"));
var _useBackButton = _interopRequireDefault(require("./useBackButton"));
var _useDocumentTitle = _interopRequireDefault(require("./useDocumentTitle"));
var _useLinking = _interopRequireDefault(require("./useLinking"));
var _useThenable = _interopRequireDefault(require("./useThenable"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
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); }
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); }
global.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
/**

@@ -61,7 +46,5 @@ * Container component which holds the navigation state designed for React Native apps.

const isLinkingEnabled = linking ? linking.enabled !== false : false;
if (linking !== null && linking !== void 0 && linking.config) {
(0, _core.validatePathConfig)(linking.config);
}
const refContainer = React.useRef(null);

@@ -77,5 +60,6 @@ (0, _useBackButton.default)(refContainer);

...linking
}); // Add additional linking related info to the ref
});
// Add additional linking related info to the ref
// This will be used by the devtools
React.useEffect(() => {

@@ -85,13 +69,11 @@ if (refContainer.current) {

get linking() {
var _linking$prefixes, _linking$getStateFrom, _linking$getPathFromS, _linking$getActionFro;
return { ...linking,
return {
...linking,
enabled: isLinkingEnabled,
prefixes: (_linking$prefixes = linking === null || linking === void 0 ? void 0 : linking.prefixes) !== null && _linking$prefixes !== void 0 ? _linking$prefixes : [],
getStateFromPath: (_linking$getStateFrom = linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) !== null && _linking$getStateFrom !== void 0 ? _linking$getStateFrom : _core.getStateFromPath,
getPathFromState: (_linking$getPathFromS = linking === null || linking === void 0 ? void 0 : linking.getPathFromState) !== null && _linking$getPathFromS !== void 0 ? _linking$getPathFromS : _core.getPathFromState,
getActionFromState: (_linking$getActionFro = linking === null || linking === void 0 ? void 0 : linking.getActionFromState) !== null && _linking$getActionFro !== void 0 ? _linking$getActionFro : _core.getActionFromState
prefixes: (linking === null || linking === void 0 ? void 0 : linking.prefixes) ?? [],
getStateFromPath: (linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) ?? _core.getStateFromPath,
getPathFromState: (linking === null || linking === void 0 ? void 0 : linking.getPathFromState) ?? _core.getPathFromState,
getActionFromState: (linking === null || linking === void 0 ? void 0 : linking.getActionFromState) ?? _core.getActionFromState
};
}
});

@@ -113,7 +95,5 @@ }

var _onReadyRef$current;
(_onReadyRef$current = onReadyRef.current) === null || _onReadyRef$current === void 0 ? void 0 : _onReadyRef$current.call(onReadyRef);
}
}, [isReady]);
if (!isReady) {

@@ -124,3 +104,2 @@ // This is temporary until we have Suspense for data-fetching

}
return /*#__PURE__*/React.createElement(_LinkingContext.default.Provider, {

@@ -135,3 +114,2 @@ value: linkingContext

}
const NavigationContainer = /*#__PURE__*/React.forwardRef(NavigationContainerInner);

@@ -138,0 +116,0 @@ var _default = NavigationContainer;

@@ -7,15 +7,8 @@ "use strict";

exports.default = void 0;
var _core = require("@react-navigation/core");
var React = _interopRequireWildcard(require("react"));
var _ServerContext = _interopRequireDefault(require("./ServerContext"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
/**

@@ -37,3 +30,2 @@ * Container component for server rendering.

const current = {};
if (ref) {

@@ -44,8 +36,8 @@ const value = {

}
};
}; // We write to the `ref` during render instead of `React.useImperativeHandle`
// We write to the `ref` during render instead of `React.useImperativeHandle`
// This is because `useImperativeHandle` will update the ref after 'commit',
// and there's no 'commit' phase during SSR.
// Mutating ref during render is unsafe in concurrent mode, but we don't care about it for SSR.
if (typeof ref === 'function') {

@@ -58,3 +50,2 @@ ref(value);

}
return /*#__PURE__*/React.createElement(_ServerContext.default.Provider, {

@@ -68,4 +59,3 @@ value: {

});
exports.default = _default;
//# sourceMappingURL=ServerContainer.js.map

@@ -7,9 +7,5 @@ "use strict";

exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
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); }
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; }
const ServerContext = /*#__PURE__*/React.createContext(undefined);

@@ -16,0 +12,0 @@ var _default = ServerContext;

@@ -7,13 +7,7 @@ "use strict";

exports.default = void 0;
var React = _interopRequireWildcard(require("react"));
var _DefaultTheme = _interopRequireDefault(require("./DefaultTheme"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
const ThemeContext = /*#__PURE__*/React.createContext(_DefaultTheme.default);

@@ -20,0 +14,0 @@ ThemeContext.displayName = 'ThemeContext';

@@ -7,13 +7,7 @@ "use strict";

exports.default = ThemeProvider;
var React = _interopRequireWildcard(require("react"));
var _ThemeContext = _interopRequireDefault(require("./ThemeContext"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
function ThemeProvider(_ref) {

@@ -20,0 +14,0 @@ let {

@@ -7,13 +7,7 @@ "use strict";

exports.default = useTheme;
var React = _interopRequireWildcard(require("react"));
var _ThemeContext = _interopRequireDefault(require("./ThemeContext"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
function useTheme() {

@@ -20,0 +14,0 @@ const theme = React.useContext(_ThemeContext.default);

@@ -7,31 +7,6 @@ "use strict";

exports.default = useBackButton;
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
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); }
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; }
function useBackButton(ref) {
React.useEffect(() => {
const subscription = _reactNative.BackHandler.addEventListener('hardwareBackPress', () => {
const navigation = ref.current;
if (navigation == null) {
return false;
}
if (navigation.canGoBack()) {
navigation.goBack();
return true;
}
return false;
});
return () => subscription.remove();
}, [ref]);
function useBackButton(_) {
// No-op
// BackHandler is not available on web
}
//# sourceMappingURL=useBackButton.js.map

@@ -7,9 +7,5 @@ "use strict";

exports.default = useDocumentTitle;
var React = _interopRequireWildcard(require("react"));
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); }
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; }
/**

@@ -21,7 +17,3 @@ * Set the document title for the active screen

enabled = true,
formatter = (options, route) => {
var _options$title;
return (_options$title = options === null || options === void 0 ? void 0 : options.title) !== null && _options$title !== void 0 ? _options$title : route === null || route === void 0 ? void 0 : route.name;
}
formatter = (options, route) => (options === null || options === void 0 ? void 0 : options.title) ?? (route === null || route === void 0 ? void 0 : route.name)
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -32,5 +24,3 @@ React.useEffect(() => {

}
const navigation = ref.current;
if (navigation) {

@@ -40,3 +30,2 @@ const title = formatter(navigation.getCurrentOptions(), navigation.getCurrentRoute());

}
return navigation === null || navigation === void 0 ? void 0 : navigation.addListener('options', e => {

@@ -43,0 +32,0 @@ const title = formatter(e.data.options, navigation === null || navigation === void 0 ? void 0 : navigation.getCurrentRoute());

@@ -7,5 +7,5 @@ "use strict";

exports.default = useDocumentTitle;
function useDocumentTitle() {// Noop for React Native
function useDocumentTitle() {
// Noop for React Native
}
//# sourceMappingURL=useDocumentTitle.native.js.map

@@ -7,18 +7,10 @@ "use strict";

exports.default = useLinkBuilder;
var _core = require("@react-navigation/core");
var React = _interopRequireWildcard(require("react"));
var _LinkingContext = _interopRequireDefault(require("./LinkingContext"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
const getRootStateForNavigate = (navigation, state) => {
const parent = navigation.getParent();
if (parent) {

@@ -28,3 +20,4 @@ const parentState = parent.getState();

index: 0,
routes: [{ ...parentState.routes[parentState.index],
routes: [{
...parentState.routes[parentState.index],
state: state

@@ -34,5 +27,5 @@ }]

}
return state;
};
/**

@@ -42,4 +35,2 @@ * Build destination link for a navigate action.

*/
function useLinkBuilder() {

@@ -52,7 +43,5 @@ const navigation = React.useContext(_core.NavigationHelpersContext);

} = linking;
if ((options === null || options === void 0 ? void 0 : options.enabled) === false) {
return undefined;
}
const state = navigation ? getRootStateForNavigate(navigation, {

@@ -64,3 +53,4 @@ index: 0,

}]
}) : // If we couldn't find a navigation object in context, we're at root
}) :
// If we couldn't find a navigation object in context, we're at root
// So we'll construct a basic state object to use

@@ -67,0 +57,0 @@ {

@@ -7,19 +7,11 @@ "use strict";

exports.default = useLinking;
exports.series = void 0;
var _core = require("@react-navigation/core");
var _fastDeepEqual = _interopRequireDefault(require("fast-deep-equal"));
var React = _interopRequireWildcard(require("react"));
var _createMemoryHistory = _interopRequireDefault(require("./createMemoryHistory"));
var _ServerContext = _interopRequireDefault(require("./ServerContext"));
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); }
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; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -32,5 +24,5 @@ * Find the matching navigation state that changed between 2 navigation states

return [undefined, undefined];
} // Tab and drawer will have `history` property, but stack will have history in `routes`
}
// Tab and drawer will have `history` property, but stack will have history in `routes`
const aHistoryLength = a.history ? a.history.length : a.routes.length;

@@ -41,3 +33,5 @@ const bHistoryLength = b.history ? b.history.length : b.routes.length;

const aChildState = aRoute.state;
const bChildState = bRoute.state; // Stop here if this is the state object that changed:
const bChildState = bRoute.state;
// Stop here if this is the state object that changed:
// - history length is different

@@ -47,46 +41,20 @@ // - focused routes are different

// - child state keys are different
if (aHistoryLength !== bHistoryLength || aRoute.key !== bRoute.key || aChildState === undefined || bChildState === undefined || aChildState.key !== bChildState.key) {
return [a, b];
}
return findMatchingState(aChildState, bChildState);
};
/**
* Run async function in series as it's called.
*/
const series = cb => {
// Whether we're currently handling a callback
let handling = false;
let queue = [];
const callback = async () => {
try {
if (handling) {
// If we're currently handling a previous event, wait before handling this one
// Add the callback to the beginning of the queue
queue.unshift(callback);
return;
}
handling = true;
await cb();
} finally {
handling = false;
if (queue.length) {
// If we have queued items, handle the last one
const last = queue.pop();
last === null || last === void 0 ? void 0 : last();
}
}
let queue = Promise.resolve();
const callback = () => {
queue = queue.then(cb);
};
return callback;
};
exports.series = series;
let linkingHandlers = [];
function useLinking(ref, _ref) {

@@ -105,20 +73,14 @@ let {

}
if (independent) {
return undefined;
}
if (enabled !== false && linkingHandlers.length) {
console.error(['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:', "- You don't have multiple NavigationContainers in the app each with 'linking' enabled", '- Only a single instance of the root component is rendered'].join('\n').trim());
}
const handler = Symbol();
if (enabled !== false) {
linkingHandlers.push(handler);
}
return () => {
const index = linkingHandlers.indexOf(handler);
if (index > -1) {

@@ -129,6 +91,7 @@ linkingHandlers.splice(index, 1);

}, [enabled, independent]);
const [history] = React.useState(_createMemoryHistory.default); // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
const [history] = React.useState(_createMemoryHistory.default);
// We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
// This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
// Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
const enabledRef = React.useRef(enabled);

@@ -149,9 +112,5 @@ const configRef = React.useRef(config);

let value;
if (enabledRef.current) {
var _server$location;
const location = (_server$location = server === null || server === void 0 ? void 0 : server.location) !== null && _server$location !== void 0 ? _server$location : typeof window !== 'undefined' ? window.location : undefined;
const location = (server === null || server === void 0 ? void 0 : server.location) ?? (typeof window !== 'undefined' ? window.location : undefined);
const path = location ? location.pathname + location.search : undefined;
if (path) {

@@ -161,3 +120,2 @@ value = getStateFromPathRef.current(path, configRef.current);

}
const thenable = {

@@ -167,9 +125,8 @@ then(onfulfilled) {

},
catch() {
return thenable;
}
};
return thenable; // eslint-disable-next-line react-hooks/exhaustive-deps
return thenable;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

@@ -182,20 +139,16 @@ const previousIndexRef = React.useRef(undefined);

return history.listen(() => {
var _previousIndexRef$cur;
const navigation = ref.current;
if (!navigation || !enabled) {
return;
}
const path = location.pathname + location.search;
const index = history.index;
const previousIndex = (_previousIndexRef$cur = previousIndexRef.current) !== null && _previousIndexRef$cur !== void 0 ? _previousIndexRef$cur : 0;
const previousIndex = previousIndexRef.current ?? 0;
previousIndexRef.current = index;
pendingPopStatePathRef.current = path; // When browser back/forward is clicked, we first need to check if state object for this index exists
pendingPopStatePathRef.current = path;
// When browser back/forward is clicked, we first need to check if state object for this index exists
// If it does we'll reset to that state object
// Otherwise, we'll handle it like a regular deep link
const record = history.get(index);
if ((record === null || record === void 0 ? void 0 : record.path) === path && record !== null && record !== void 0 && record.state) {

@@ -205,6 +158,6 @@ navigation.resetRoot(record.state);

}
const state = getStateFromPathRef.current(path, configRef.current);
const state = getStateFromPathRef.current(path, configRef.current); // We should only dispatch an action when going forward
// We should only dispatch an action when going forward
// Otherwise the action will likely add items to history, which would mess things up
if (state) {

@@ -214,3 +167,2 @@ // Make sure that the routes in the state exist in the root navigator

const rootState = navigation.getRootState();
if (state.routes.some(r => !(rootState !== null && rootState !== void 0 && rootState.routeNames.includes(r.name)))) {

@@ -220,6 +172,4 @@ console.warn("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.");

}
if (index > previousIndex) {
const action = getActionFromStateRef.current(state, configRef.current);
if (action !== undefined) {

@@ -231,4 +181,3 @@ try {

// This could happen in case of malformed links, navigation object not being initialized etc.
console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ? // @ts-expect-error: we're already checking for this
e.message : e}`);
console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ? e.message : e}`);
}

@@ -249,7 +198,5 @@ } else {

var _ref$current;
if (!enabled) {
return;
}
const getPathForRoute = (route, state) => {

@@ -260,6 +207,4 @@ // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match

const stateForPath = getStateFromPathRef.current(route.path, configRef.current);
if (stateForPath) {
const focusedRoute = (0, _core.findFocusedRoute)(stateForPath);
if (focusedRoute && focusedRoute.name === route.name && (0, _fastDeepEqual.default)(focusedRoute.params, route.params)) {

@@ -270,6 +215,4 @@ return route.path;

}
return getPathFromStateRef.current(state, configRef.current);
};
if (ref.current) {

@@ -279,11 +222,8 @@ // We need to record the current metadata on the first render if they aren't set

const state = ref.current.getRootState();
if (state) {
const route = (0, _core.findFocusedRoute)(state);
const path = getPathForRoute(route, state);
if (previousStateRef.current === undefined) {
previousStateRef.current = state;
}
history.replace({

@@ -295,17 +235,14 @@ path,

}
const onStateChange = async () => {
const navigation = ref.current;
if (!navigation || !enabled) {
return;
}
const previousState = previousStateRef.current;
const state = navigation.getRootState(); // root state may not available, for example when root navigators switch inside the container
const state = navigation.getRootState();
// root state may not available, for example when root navigators switch inside the container
if (!state) {
return;
}
const pendingPath = pendingPopStatePathRef.current;

@@ -315,14 +252,14 @@ const route = (0, _core.findFocusedRoute)(state);

previousStateRef.current = state;
pendingPopStatePathRef.current = undefined; // To detect the kind of state change, we need to:
pendingPopStatePathRef.current = undefined;
// To detect the kind of state change, we need to:
// - Find the common focused navigation state in previous and current state
// - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace
// - If no common focused navigation state found, it's a replace
const [previousFocusedState, focusedState] = findMatchingState(previousState, state);
if (previousFocusedState && focusedState && // We should only handle push/pop if path changed from what was in last `popstate`
if (previousFocusedState && focusedState &&
// We should only handle push/pop if path changed from what was in last `popstate`
// Otherwise it's likely a change triggered by `popstate`
path !== pendingPath) {
const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);
if (historyDelta > 0) {

@@ -337,2 +274,3 @@ // If history length is increased, we should pushState

// If history length is decreased, i.e. entries were removed, we want to go back
const nextIndex = history.backIndex({

@@ -342,3 +280,2 @@ path

const currentIndex = history.index;
try {

@@ -353,5 +290,5 @@ if (nextIndex !== -1 && nextIndex < currentIndex) {

await history.go(historyDelta);
} // Store the updated state as well as fix the path if incorrect
}
// Store the updated state as well as fix the path if incorrect
history.replace({

@@ -361,3 +298,4 @@ path,

});
} catch (e) {// The navigation was interrupted
} catch (e) {
// The navigation was interrupted
}

@@ -379,9 +317,9 @@ } else {

}
}; // We debounce onStateChange coz we don't want multiple state changes to be handled at one time
};
// We debounce onStateChange coz we don't want multiple state changes to be handled at one time
// This could happen since `history.go(n)` is asynchronous
// If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.addListener('state', series(onStateChange));
});
}, [enabled, history, ref]);
return {

@@ -388,0 +326,0 @@ getInitialState

@@ -7,19 +7,10 @@ "use strict";

exports.default = useLinking;
var _core = require("@react-navigation/core");
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _extractPathFromURL = _interopRequireDefault(require("./extractPathFromURL"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
let linkingHandlers = [];
function useLinking(ref, _ref) {

@@ -32,3 +23,4 @@ let {

config,
getInitialURL = () => Promise.race([_reactNative.Linking.getInitialURL(), new Promise(resolve => // Timeout in 150ms if `getInitialState` doesn't resolve
getInitialURL = () => Promise.race([_reactNative.Linking.getInitialURL(), new Promise(resolve =>
// Timeout in 150ms if `getInitialState` doesn't resolve
// Workaround for https://github.com/facebook/react-native/issues/25675

@@ -38,3 +30,2 @@ setTimeout(resolve, 150))]),

var _Linking$removeEventL;
const callback = _ref2 => {

@@ -46,6 +37,6 @@ let {

};
const subscription = _reactNative.Linking.addEventListener('url', callback);
const subscription = _reactNative.Linking.addEventListener('url', callback); // Storing this in a local variable stops Jest from complaining about import after teardown
// Storing this in a local variable stops Jest from complaining about import after teardown
// @ts-expect-error: removeEventListener is not present in newer RN versions
const removeEventListener = (_Linking$removeEventL = _reactNative.Linking.removeEventListener) === null || _Linking$removeEventL === void 0 ? void 0 : _Linking$removeEventL.bind(_reactNative.Linking);

@@ -68,20 +59,14 @@ return () => {

}
if (independent) {
return undefined;
}
if (enabled !== false && linkingHandlers.length) {
console.error(['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:', "- You don't have multiple NavigationContainers in the app each with 'linking' enabled", '- Only a single instance of the root component is rendered', _reactNative.Platform.OS === 'android' ? "- You have set 'android:launchMode=singleTask' in the '<activity />' section of the 'AndroidManifest.xml' file to avoid launching multiple instances" : ''].join('\n').trim());
}
const handler = Symbol();
if (enabled !== false) {
linkingHandlers.push(handler);
}
return () => {
const index = linkingHandlers.indexOf(handler);
if (index > -1) {

@@ -91,6 +76,7 @@ linkingHandlers.splice(index, 1);

};
}, [enabled, independent]); // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
}, [enabled, independent]);
// We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
// This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
// Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
const enabledRef = React.useRef(enabled);

@@ -116,3 +102,2 @@ const prefixesRef = React.useRef(prefixes);

}
const path = (0, _extractPathFromURL.default)(prefixesRef.current, url);

@@ -123,6 +108,4 @@ return path !== undefined ? getStateFromPathRef.current(path, configRef.current) : undefined;

let state;
if (enabledRef.current) {
const url = getInitialURLRef.current();
if (url != null && typeof url !== 'string') {

@@ -134,6 +117,4 @@ return url.then(url => {

}
state = getStateFromURL(url);
}
const thenable = {

@@ -143,7 +124,5 @@ then(onfulfilled) {

},
catch() {
return thenable;
}
};

@@ -157,6 +136,4 @@ return thenable;

}
const navigation = ref.current;
const state = navigation ? getStateFromURL(url) : undefined;
if (navigation && state) {

@@ -166,3 +143,2 @@ // Make sure that the routes in the state exist in the root navigator

const rootState = navigation.getRootState();
if (state.routes.some(r => !(rootState !== null && rootState !== void 0 && rootState.routeNames.includes(r.name)))) {

@@ -172,5 +148,3 @@ console.warn("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.");

}
const action = getActionFromStateRef.current(state, configRef.current);
if (action !== undefined) {

@@ -182,4 +156,3 @@ try {

// This could happen in case of malformed links, navigation object not being initialized etc.
console.warn(`An error occurred when trying to handle the link '${url}': ${typeof e === 'object' && e != null && 'message' in e ? // @ts-expect-error: we're already checking for this
e.message : e}`);
console.warn(`An error occurred when trying to handle the link '${url}': ${typeof e === 'object' && e != null && 'message' in e ? e.message : e}`);
}

@@ -191,3 +164,2 @@ } else {

};
return subscribe(listener);

@@ -194,0 +166,0 @@ }, [enabled, getStateFromURL, ref, subscribe]);

@@ -7,19 +7,10 @@ "use strict";

exports.default = useLinkProps;
var _core = require("@react-navigation/core");
var React = _interopRequireWildcard(require("react"));
var _reactNative = require("react-native");
var _LinkingContext = _interopRequireDefault(require("./LinkingContext"));
var _useLinkTo = _interopRequireDefault(require("./useLinkTo"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
const getStateFromParams = params => {

@@ -29,3 +20,2 @@ if (params !== null && params !== void 0 && params.state) {

}
if (params !== null && params !== void 0 && params.screen) {

@@ -41,5 +31,5 @@ return {

}
return undefined;
};
/**

@@ -51,7 +41,3 @@ * Hook to get props for an anchor tag so it can work with in page navigation.

*/
function useLinkProps(_ref) {
var _options$getPathFromS;
let {

@@ -67,15 +53,15 @@ to,

const linkTo = (0, _useLinkTo.default)();
const onPress = e => {
var _e$currentTarget;
let shouldHandle = false;
if (_reactNative.Platform.OS !== 'web' || !e) {
shouldHandle = e ? !e.defaultPrevented : true;
} else if (!e.defaultPrevented && // onPress prevented default
} else if (!e.defaultPrevented &&
// onPress prevented default
// @ts-expect-error: these properties exist on web, but not in React Native
!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && ( // ignore clicks with modifier keys
!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && (
// ignore clicks with modifier keys
// @ts-expect-error: these properties exist on web, but not in React Native
e.button == null || e.button === 0) && // ignore everything but left clicks
e.button == null || e.button === 0) &&
// ignore everything but left clicks
// @ts-expect-error: these properties exist on web, but not in React Native

@@ -87,3 +73,2 @@ [undefined, null, '', 'self'].includes((_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.target) // let browser handle "target=_blank" etc.

}
if (shouldHandle) {

@@ -103,4 +88,3 @@ if (action) {

};
const getPathFromStateHelper = (_options$getPathFromS = options === null || options === void 0 ? void 0 : options.getPathFromState) !== null && _options$getPathFromS !== void 0 ? _options$getPathFromS : _core.getPathFromState;
const getPathFromStateHelper = (options === null || options === void 0 ? void 0 : options.getPathFromState) ?? _core.getPathFromState;
const href = typeof to === 'string' ? to : getPathFromStateHelper({

@@ -107,0 +91,0 @@ routes: [{

@@ -7,15 +7,8 @@ "use strict";

exports.default = useLinkTo;
var _core = require("@react-navigation/core");
var React = _interopRequireWildcard(require("react"));
var _LinkingContext = _interopRequireDefault(require("./LinkingContext"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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); }
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; }
function useLinkTo() {

@@ -28,3 +21,2 @@ const navigation = React.useContext(_core.NavigationContainerRefContext);

}
if (typeof to !== 'string') {

@@ -35,7 +27,5 @@ // @ts-expect-error: This is fine

}
if (!to.startsWith('/')) {
throw new Error(`The path must start with '/' (${to}).`);
}
const {

@@ -45,6 +35,4 @@ options

const state = options !== null && options !== void 0 && options.getStateFromPath ? options.getStateFromPath(to, options.config) : (0, _core.getStateFromPath)(to, options === null || options === void 0 ? void 0 : options.config);
if (state) {
const action = (0, _core.getActionFromState)(state, options === null || options === void 0 ? void 0 : options.config);
if (action !== undefined) {

@@ -51,0 +39,0 @@ navigation.dispatch(action);

@@ -7,11 +7,6 @@ "use strict";

exports.default = useScrollToTop;
var _core = require("@react-navigation/core");
var React = _interopRequireWildcard(require("react"));
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); }
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; }
function getScrollableNode(ref) {

@@ -21,3 +16,2 @@ if (ref.current == null) {

}
if ('scrollToTop' in ref.current || 'scrollTo' in ref.current || 'scrollToOffset' in ref.current || 'scrollResponderScrollTo' in ref.current) {

@@ -40,3 +34,2 @@ // This is already a scrollable node.

}
function useScrollToTop(ref) {

@@ -46,53 +39,61 @@ const navigation = (0, _core.useNavigation)();

React.useEffect(() => {
let current = navigation; // The screen might be inside another navigator such as stack nested in tabs
// We need to find the closest tab navigator and add the listener there
let tabNavigations = [];
let currentNavigation = navigation;
while (current && current.getState().type !== 'tab') {
current = current.getParent();
// If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
// So we need to find all the parent tab navigators and add the listeners there
while (currentNavigation) {
if (currentNavigation.getState().type === 'tab') {
tabNavigations.push(currentNavigation);
}
currentNavigation = currentNavigation.getParent();
}
if (!current) {
if (tabNavigations.length === 0) {
return;
}
const unsubscribers = tabNavigations.map(tab => {
return tab.addListener(
// We don't wanna import tab types here to avoid extra deps
// in addition, there are multiple tab implementations
// @ts-expect-error
'tabPress', e => {
// We should scroll to top only when the screen is focused
const isFocused = navigation.isFocused();
const unsubscribe = current.addListener( // We don't wanna import tab types here to avoid extra deps
// in addition, there are multiple tab implementations
// @ts-expect-error
'tabPress', e => {
// We should scroll to top only when the screen is focused
const isFocused = navigation.isFocused(); // In a nested stack navigator, tab press resets the stack to first screen
// So we should scroll to top only when we are on first screen
// In a nested stack navigator, tab press resets the stack to first screen
// So we should scroll to top only when we are on first screen
const isFirst = tabNavigations.includes(navigation) || navigation.getState().routes[0].key === route.key;
const isFirst = navigation === current || navigation.getState().routes[0].key === route.key; // Run the operation in the next frame so we're sure all listeners have been run
// This is necessary to know if preventDefault() has been called
requestAnimationFrame(() => {
const scrollable = getScrollableNode(ref);
if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
if ('scrollToTop' in scrollable) {
scrollable.scrollToTop();
} else if ('scrollTo' in scrollable) {
scrollable.scrollTo({
x: 0,
y: 0,
animated: true
});
} else if ('scrollToOffset' in scrollable) {
scrollable.scrollToOffset({
offset: 0,
animated: true
});
} else if ('scrollResponderScrollTo' in scrollable) {
scrollable.scrollResponderScrollTo({
y: 0,
animated: true
});
// Run the operation in the next frame so we're sure all listeners have been run
// This is necessary to know if preventDefault() has been called
requestAnimationFrame(() => {
const scrollable = getScrollableNode(ref);
if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
if ('scrollToTop' in scrollable) {
scrollable.scrollToTop();
} else if ('scrollTo' in scrollable) {
scrollable.scrollTo({
y: 0,
animated: true
});
} else if ('scrollToOffset' in scrollable) {
scrollable.scrollToOffset({
offset: 0,
animated: true
});
} else if ('scrollResponderScrollTo' in scrollable) {
scrollable.scrollResponderScrollTo({
y: 0,
animated: true
});
}
}
}
});
});
});
return unsubscribe;
return () => {
unsubscribers.forEach(unsubscribe => unsubscribe());
};
}, [navigation, ref, route.key]);
}
//# sourceMappingURL=useScrollToTop.js.map

@@ -7,13 +7,10 @@ "use strict";

exports.default = useThenable;
var React = _interopRequireWildcard(require("react"));
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); }
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; }
function useThenable(create) {
const [promise] = React.useState(create);
let initialState = [false, undefined]; // Check if our thenable is synchronous
let initialState = [false, undefined];
// Check if our thenable is synchronous
promise.then(result => {

@@ -26,6 +23,4 @@ initialState = [true, result];

let cancelled = false;
const resolve = async () => {
let result;
try {

@@ -39,7 +34,5 @@ result = await promise;

};
if (!resolved) {
resolve();
}
return () => {

@@ -46,0 +39,0 @@ cancelled = true;

import { nanoid } from 'nanoid/non-secure';
export default function createMemoryHistory() {
let index = 0;
let items = []; // Pending callbacks for `history.go(n)`
let items = [];
// Pending callbacks for `history.go(n)`
// We might modify the callback stored if it was interrupted, so we have a ref to identify it
const pending = [];
const interrupt = () => {

@@ -15,15 +15,11 @@ // If another history operation was performed we need to interrupt existing ones

const cb = it.cb;
it.cb = () => cb(true);
});
};
const history = {
get index() {
var _window$history$state;
// We store an id in the state instead of an index
// Index could get out of sync with in-memory values if page reloads
const id = (_window$history$state = window.history.state) === null || _window$history$state === void 0 ? void 0 : _window$history$state.id;
if (id) {

@@ -33,10 +29,7 @@ const index = items.findIndex(item => item.id === id);

}
return 0;
},
get(index) {
return items[index];
},
backIndex(_ref) {

@@ -46,7 +39,5 @@ let {

} = _ref;
// We need to find the index from the element before current to get closest path to go back to
for (let i = index - 1; i >= 0; i--) {
const item = items[i];
if (item.path === path) {

@@ -56,6 +47,4 @@ return i;

}
return -1;
},
push(_ref2) {

@@ -67,5 +56,6 @@ let {

interrupt();
const id = nanoid(); // When a new entry is pushed, all the existing entries after index will be inaccessible
const id = nanoid();
// When a new entry is pushed, all the existing entries after index will be inaccessible
// So we remove any existing entries after the current index to clean them up
items = items.slice(0, index + 1);

@@ -77,7 +67,8 @@ items.push({

});
index = items.length - 1; // We pass empty string for title because it's ignored in all browsers except safari
index = items.length - 1;
// We pass empty string for title because it's ignored in all browsers except safari
// We don't store state object in history.state because:
// - browsers have limits on how big it can be, and we don't control the size
// - while not recommended, there could be non-serializable data in state
window.history.pushState({

@@ -87,6 +78,4 @@ id

},
replace(_ref3) {
var _window$history$state2, _window$history$state3;
var _window$history$state2;
let {

@@ -97,4 +86,7 @@ path,

interrupt();
const id = (_window$history$state2 = (_window$history$state3 = window.history.state) === null || _window$history$state3 === void 0 ? void 0 : _window$history$state3.id) !== null && _window$history$state2 !== void 0 ? _window$history$state2 : nanoid();
const id = ((_window$history$state2 = window.history.state) === null || _window$history$state2 === void 0 ? void 0 : _window$history$state2.id) ?? nanoid();
// Need to keep the hash part of the path if there was no previous history entry
// or the previous history entry had the same path
let pathWithHash = path;
if (!items.length || items.findIndex(item => item.id === id) < 0) {

@@ -107,4 +99,5 @@ // There are two scenarios for creating an array with only one history record:

// So we need to push the entry as there's nothing to replace
pathWithHash = pathWithHash + location.hash;
items = [{
path,
path: pathWithHash,
state,

@@ -115,2 +108,5 @@ id

} else {
if (items[index].path === path) {
pathWithHash = pathWithHash + location.hash;
}
items[index] = {

@@ -122,8 +118,6 @@ path,

}
window.history.replaceState({
id
}, '', path);
}, '', pathWithHash);
},
// `history.go(n)` is asynchronous, there are couple of things to keep in mind:

@@ -135,8 +129,8 @@ // - it won't do anything if we can't go `n` steps, the `popstate` event won't fire.

go(n) {
interrupt(); // 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
interrupt();
// 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
// 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.
const nextIndex = index + n;
const lastItemIndex = items.length - 1;
if (n < 0 && !items[nextIndex]) {

@@ -153,6 +147,7 @@ // Attempted to navigate beyond the first index. Negating the current index will align the browser history with the first item.

}
if (n === 0) {
return;
} // When we call `history.go`, `popstate` will fire when there's history to go back to
}
// When we call `history.go`, `popstate` will fire when there's history to go back to
// So we need to somehow handle following cases:

@@ -162,12 +157,11 @@ // - There's history to go back, `history.go` is called, and `popstate` fires

// - No history to go back, but `history.go` was called, browser has no API to detect it
return new Promise((resolve, reject) => {
const done = interrupted => {
clearTimeout(timer);
if (interrupted) {
reject(new Error('History was changed during navigation.'));
return;
} // There seems to be a bug in Chrome regarding updating the title
}
// There seems to be a bug in Chrome regarding updating the title
// If we set a title just before calling `history.go`, the title gets lost

@@ -180,4 +174,2 @@ // However the value of `document.title` is still what we set it to

// Which means that the browser won't do anything after setting the title
const {

@@ -190,7 +182,8 @@ title

};
pending.push({
ref: done,
cb: done
}); // If navigation didn't happen within 100ms, assume that it won't happen
});
// If navigation didn't happen within 100ms, assume that it won't happen
// This may not be accurate, but hopefully it won't take so much time

@@ -200,6 +193,4 @@ // In Chrome, navigation seems to happen instantly in next microtask

// We're using a hacky timeout since there doesn't seem to be way to know for sure
const timer = setTimeout(() => {
const index = pending.findIndex(it => it.ref === done);
if (index > -1) {

@@ -210,10 +201,9 @@ pending[index].cb();

}, 100);
const onPopState = () => {
var _window$history$state4;
var _window$history$state3;
const id = (_window$history$state3 = window.history.state) === null || _window$history$state3 === void 0 ? void 0 : _window$history$state3.id;
const currentIndex = items.findIndex(item => item.id === id);
const id = (_window$history$state4 = window.history.state) === null || _window$history$state4 === void 0 ? void 0 : _window$history$state4.id;
const currentIndex = items.findIndex(item => item.id === id); // Fix createMemoryHistory.index variable's value
// Fix createMemoryHistory.index variable's value
// as it may go out of sync when navigating in the browser.
index = Math.max(currentIndex, 0);

@@ -224,3 +214,2 @@ const last = pending.pop();

};
window.addEventListener('popstate', onPopState);

@@ -230,3 +219,2 @@ window.history.go(n);

},
// The `popstate` event is triggered when history changes, except `pushState` and `replaceState`

@@ -241,10 +229,7 @@ // If we call `history.go(n)` ourselves, we don't want it to trigger the listener

}
listener();
};
window.addEventListener('popstate', onPopState);
return () => window.removeEventListener('popstate', onPopState);
}
};

@@ -251,0 +236,0 @@ return history;

import escapeStringRegexp from 'escape-string-regexp';
export default function extractPathFromURL(prefixes, url) {
for (const prefix of prefixes) {
var _prefix$match$, _prefix$match;
const protocol = (_prefix$match$ = (_prefix$match = prefix.match(/^[^:]+:/)) === null || _prefix$match === void 0 ? void 0 : _prefix$match[0]) !== null && _prefix$match$ !== void 0 ? _prefix$match$ : '';
var _prefix$match;
const protocol = ((_prefix$match = prefix.match(/^[^:]+:/)) === null || _prefix$match === void 0 ? void 0 : _prefix$match[0]) ?? '';
const host = prefix.replace(new RegExp(`^${escapeStringRegexp(protocol)}`), '').replace(/\/+/g, '/') // Replace multiple slash (//) with single ones

@@ -11,4 +10,4 @@ .replace(/^\//, ''); // Remove extra leading slash

const prefixRegex = new RegExp(`^${escapeStringRegexp(protocol)}(/)*${host.split('.').map(it => it === '*' ? '[^/]+' : escapeStringRegexp(it)).join('\\.')}`);
const normalizedURL = url.replace(/\/+/g, '/');
const [originAndPath, searchParams] = url.split('?');
const normalizedURL = originAndPath.replace(/\/+/g, '/').concat(searchParams ? `?${searchParams}` : '');
if (prefixRegex.test(normalizedURL)) {

@@ -18,5 +17,4 @@ return normalizedURL.replace(prefixRegex, '');

}
return undefined;
}
//# sourceMappingURL=extractPathFromURL.js.map
import * as React from 'react';
import { Platform, Text } from 'react-native';
import useLinkProps from './useLinkProps';
/**

@@ -23,14 +22,11 @@ * Component to render link to another screen using a path.

});
const onPress = e => {
if ('onPress' in rest) {
var _rest$onPress;
(_rest$onPress = rest.onPress) === null || _rest$onPress === void 0 ? void 0 : _rest$onPress.call(rest, e);
}
props.onPress(e);
};
return /*#__PURE__*/React.createElement(Text, { ...props,
return /*#__PURE__*/React.createElement(Text, {
...props,
...rest,

@@ -37,0 +33,0 @@ ...Platform.select({

@@ -1,3 +0,2 @@

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); }
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); }
import { BaseNavigationContainer, getActionFromState, getPathFromState, getStateFromPath, validatePathConfig } from '@react-navigation/core';

@@ -13,3 +12,2 @@ import * as React from 'react';

global.REACT_NAVIGATION_DEVTOOLS = new WeakMap();
/**

@@ -39,7 +37,5 @@ * Container component which holds the navigation state designed for React Native apps.

const isLinkingEnabled = linking ? linking.enabled !== false : false;
if (linking !== null && linking !== void 0 && linking.config) {
validatePathConfig(linking.config);
}
const refContainer = React.useRef(null);

@@ -55,5 +51,6 @@ useBackButton(refContainer);

...linking
}); // Add additional linking related info to the ref
});
// Add additional linking related info to the ref
// This will be used by the devtools
React.useEffect(() => {

@@ -63,13 +60,11 @@ if (refContainer.current) {

get linking() {
var _linking$prefixes, _linking$getStateFrom, _linking$getPathFromS, _linking$getActionFro;
return { ...linking,
return {
...linking,
enabled: isLinkingEnabled,
prefixes: (_linking$prefixes = linking === null || linking === void 0 ? void 0 : linking.prefixes) !== null && _linking$prefixes !== void 0 ? _linking$prefixes : [],
getStateFromPath: (_linking$getStateFrom = linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) !== null && _linking$getStateFrom !== void 0 ? _linking$getStateFrom : getStateFromPath,
getPathFromState: (_linking$getPathFromS = linking === null || linking === void 0 ? void 0 : linking.getPathFromState) !== null && _linking$getPathFromS !== void 0 ? _linking$getPathFromS : getPathFromState,
getActionFromState: (_linking$getActionFro = linking === null || linking === void 0 ? void 0 : linking.getActionFromState) !== null && _linking$getActionFro !== void 0 ? _linking$getActionFro : getActionFromState
prefixes: (linking === null || linking === void 0 ? void 0 : linking.prefixes) ?? [],
getStateFromPath: (linking === null || linking === void 0 ? void 0 : linking.getStateFromPath) ?? getStateFromPath,
getPathFromState: (linking === null || linking === void 0 ? void 0 : linking.getPathFromState) ?? getPathFromState,
getActionFromState: (linking === null || linking === void 0 ? void 0 : linking.getActionFromState) ?? getActionFromState
};
}
});

@@ -91,7 +86,5 @@ }

var _onReadyRef$current;
(_onReadyRef$current = onReadyRef.current) === null || _onReadyRef$current === void 0 ? void 0 : _onReadyRef$current.call(onReadyRef);
}
}, [isReady]);
if (!isReady) {

@@ -102,3 +95,2 @@ // This is temporary until we have Suspense for data-fetching

}
return /*#__PURE__*/React.createElement(LinkingContext.Provider, {

@@ -113,5 +105,4 @@ value: linkingContext

}
const NavigationContainer = /*#__PURE__*/React.forwardRef(NavigationContainerInner);
export default NavigationContainer;
//# sourceMappingURL=NavigationContainer.js.map
import { CurrentRenderContext } from '@react-navigation/core';
import * as React from 'react';
import ServerContext from './ServerContext';
/**

@@ -21,3 +20,2 @@ * Container component for server rendering.

const current = {};
if (ref) {

@@ -28,8 +26,8 @@ const value = {

}
};
}; // We write to the `ref` during render instead of `React.useImperativeHandle`
// We write to the `ref` during render instead of `React.useImperativeHandle`
// This is because `useImperativeHandle` will update the ref after 'commit',
// and there's no 'commit' phase during SSR.
// Mutating ref during render is unsafe in concurrent mode, but we don't care about it for SSR.
if (typeof ref === 'function') {

@@ -42,3 +40,2 @@ ref(value);

}
return /*#__PURE__*/React.createElement(ServerContext.Provider, {

@@ -45,0 +42,0 @@ value: {

@@ -1,22 +0,5 @@

import * as React from 'react';
import { BackHandler } from 'react-native';
export default function useBackButton(ref) {
React.useEffect(() => {
const subscription = BackHandler.addEventListener('hardwareBackPress', () => {
const navigation = ref.current;
if (navigation == null) {
return false;
}
if (navigation.canGoBack()) {
navigation.goBack();
return true;
}
return false;
});
return () => subscription.remove();
}, [ref]);
export default function useBackButton(_) {
// No-op
// BackHandler is not available on web
}
//# sourceMappingURL=useBackButton.js.map
import * as React from 'react';
/**

@@ -9,7 +8,3 @@ * Set the document title for the active screen

enabled = true,
formatter = (options, route) => {
var _options$title;
return (_options$title = options === null || options === void 0 ? void 0 : options.title) !== null && _options$title !== void 0 ? _options$title : route === null || route === void 0 ? void 0 : route.name;
}
formatter = (options, route) => (options === null || options === void 0 ? void 0 : options.title) ?? (route === null || route === void 0 ? void 0 : route.name)
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

@@ -20,5 +15,3 @@ React.useEffect(() => {

}
const navigation = ref.current;
if (navigation) {

@@ -28,3 +21,2 @@ const title = formatter(navigation.getCurrentOptions(), navigation.getCurrentRoute());

}
return navigation === null || navigation === void 0 ? void 0 : navigation.addListener('options', e => {

@@ -31,0 +23,0 @@ const title = formatter(e.data.options, navigation === null || navigation === void 0 ? void 0 : navigation.getCurrentRoute());

@@ -1,3 +0,4 @@

export default function useDocumentTitle() {// Noop for React Native
export default function useDocumentTitle() {
// Noop for React Native
}
//# sourceMappingURL=useDocumentTitle.native.js.map
import { getPathFromState, NavigationHelpersContext } from '@react-navigation/core';
import * as React from 'react';
import LinkingContext from './LinkingContext';
const getRootStateForNavigate = (navigation, state) => {
const parent = navigation.getParent();
if (parent) {

@@ -12,3 +10,4 @@ const parentState = parent.getState();

index: 0,
routes: [{ ...parentState.routes[parentState.index],
routes: [{
...parentState.routes[parentState.index],
state: state

@@ -18,5 +17,5 @@ }]

}
return state;
};
/**

@@ -26,4 +25,2 @@ * Build destination link for a navigate action.

*/
export default function useLinkBuilder() {

@@ -36,7 +33,5 @@ const navigation = React.useContext(NavigationHelpersContext);

} = linking;
if ((options === null || options === void 0 ? void 0 : options.enabled) === false) {
return undefined;
}
const state = navigation ? getRootStateForNavigate(navigation, {

@@ -48,3 +43,4 @@ index: 0,

}]
}) : // If we couldn't find a navigation object in context, we're at root
}) :
// If we couldn't find a navigation object in context, we're at root
// So we'll construct a basic state object to use

@@ -51,0 +47,0 @@ {

@@ -6,3 +6,2 @@ import { findFocusedRoute, getActionFromState as getActionFromStateDefault, getPathFromState as getPathFromStateDefault, getStateFromPath as getStateFromPathDefault } from '@react-navigation/core';

import ServerContext from './ServerContext';
/**

@@ -15,5 +14,5 @@ * Find the matching navigation state that changed between 2 navigation states

return [undefined, undefined];
} // Tab and drawer will have `history` property, but stack will have history in `routes`
}
// Tab and drawer will have `history` property, but stack will have history in `routes`
const aHistoryLength = a.history ? a.history.length : a.routes.length;

@@ -24,3 +23,5 @@ const bHistoryLength = b.history ? b.history.length : b.routes.length;

const aChildState = aRoute.state;
const bChildState = bRoute.state; // Stop here if this is the state object that changed:
const bChildState = bRoute.state;
// Stop here if this is the state object that changed:
// - history length is different

@@ -30,44 +31,18 @@ // - focused routes are different

// - child state keys are different
if (aHistoryLength !== bHistoryLength || aRoute.key !== bRoute.key || aChildState === undefined || bChildState === undefined || aChildState.key !== bChildState.key) {
return [a, b];
}
return findMatchingState(aChildState, bChildState);
};
/**
* Run async function in series as it's called.
*/
const series = cb => {
// Whether we're currently handling a callback
let handling = false;
let queue = [];
const callback = async () => {
try {
if (handling) {
// If we're currently handling a previous event, wait before handling this one
// Add the callback to the beginning of the queue
queue.unshift(callback);
return;
}
handling = true;
await cb();
} finally {
handling = false;
if (queue.length) {
// If we have queued items, handle the last one
const last = queue.pop();
last === null || last === void 0 ? void 0 : last();
}
}
export const series = cb => {
let queue = Promise.resolve();
const callback = () => {
queue = queue.then(cb);
};
return callback;
};
let linkingHandlers = [];

@@ -87,20 +62,14 @@ export default function useLinking(ref, _ref) {

}
if (independent) {
return undefined;
}
if (enabled !== false && linkingHandlers.length) {
console.error(['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:', "- You don't have multiple NavigationContainers in the app each with 'linking' enabled", '- Only a single instance of the root component is rendered'].join('\n').trim());
}
const handler = Symbol();
if (enabled !== false) {
linkingHandlers.push(handler);
}
return () => {
const index = linkingHandlers.indexOf(handler);
if (index > -1) {

@@ -111,6 +80,7 @@ linkingHandlers.splice(index, 1);

}, [enabled, independent]);
const [history] = React.useState(createMemoryHistory); // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
const [history] = React.useState(createMemoryHistory);
// We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
// This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
// Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
const enabledRef = React.useRef(enabled);

@@ -131,9 +101,5 @@ const configRef = React.useRef(config);

let value;
if (enabledRef.current) {
var _server$location;
const location = (_server$location = server === null || server === void 0 ? void 0 : server.location) !== null && _server$location !== void 0 ? _server$location : typeof window !== 'undefined' ? window.location : undefined;
const location = (server === null || server === void 0 ? void 0 : server.location) ?? (typeof window !== 'undefined' ? window.location : undefined);
const path = location ? location.pathname + location.search : undefined;
if (path) {

@@ -143,3 +109,2 @@ value = getStateFromPathRef.current(path, configRef.current);

}
const thenable = {

@@ -149,9 +114,8 @@ then(onfulfilled) {

},
catch() {
return thenable;
}
};
return thenable; // eslint-disable-next-line react-hooks/exhaustive-deps
return thenable;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

@@ -164,20 +128,16 @@ const previousIndexRef = React.useRef(undefined);

return history.listen(() => {
var _previousIndexRef$cur;
const navigation = ref.current;
if (!navigation || !enabled) {
return;
}
const path = location.pathname + location.search;
const index = history.index;
const previousIndex = (_previousIndexRef$cur = previousIndexRef.current) !== null && _previousIndexRef$cur !== void 0 ? _previousIndexRef$cur : 0;
const previousIndex = previousIndexRef.current ?? 0;
previousIndexRef.current = index;
pendingPopStatePathRef.current = path; // When browser back/forward is clicked, we first need to check if state object for this index exists
pendingPopStatePathRef.current = path;
// When browser back/forward is clicked, we first need to check if state object for this index exists
// If it does we'll reset to that state object
// Otherwise, we'll handle it like a regular deep link
const record = history.get(index);
if ((record === null || record === void 0 ? void 0 : record.path) === path && record !== null && record !== void 0 && record.state) {

@@ -187,6 +147,6 @@ navigation.resetRoot(record.state);

}
const state = getStateFromPathRef.current(path, configRef.current);
const state = getStateFromPathRef.current(path, configRef.current); // We should only dispatch an action when going forward
// We should only dispatch an action when going forward
// Otherwise the action will likely add items to history, which would mess things up
if (state) {

@@ -196,3 +156,2 @@ // Make sure that the routes in the state exist in the root navigator

const rootState = navigation.getRootState();
if (state.routes.some(r => !(rootState !== null && rootState !== void 0 && rootState.routeNames.includes(r.name)))) {

@@ -202,6 +161,4 @@ console.warn("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.");

}
if (index > previousIndex) {
const action = getActionFromStateRef.current(state, configRef.current);
if (action !== undefined) {

@@ -213,4 +170,3 @@ try {

// This could happen in case of malformed links, navigation object not being initialized etc.
console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ? // @ts-expect-error: we're already checking for this
e.message : e}`);
console.warn(`An error occurred when trying to handle the link '${path}': ${typeof e === 'object' && e != null && 'message' in e ? e.message : e}`);
}

@@ -231,7 +187,5 @@ } else {

var _ref$current;
if (!enabled) {
return;
}
const getPathForRoute = (route, state) => {

@@ -242,6 +196,4 @@ // If the `route` object contains a `path`, use that path as long as `route.name` and `params` still match

const stateForPath = getStateFromPathRef.current(route.path, configRef.current);
if (stateForPath) {
const focusedRoute = findFocusedRoute(stateForPath);
if (focusedRoute && focusedRoute.name === route.name && isEqual(focusedRoute.params, route.params)) {

@@ -252,6 +204,4 @@ return route.path;

}
return getPathFromStateRef.current(state, configRef.current);
};
if (ref.current) {

@@ -261,11 +211,8 @@ // We need to record the current metadata on the first render if they aren't set

const state = ref.current.getRootState();
if (state) {
const route = findFocusedRoute(state);
const path = getPathForRoute(route, state);
if (previousStateRef.current === undefined) {
previousStateRef.current = state;
}
history.replace({

@@ -277,17 +224,14 @@ path,

}
const onStateChange = async () => {
const navigation = ref.current;
if (!navigation || !enabled) {
return;
}
const previousState = previousStateRef.current;
const state = navigation.getRootState(); // root state may not available, for example when root navigators switch inside the container
const state = navigation.getRootState();
// root state may not available, for example when root navigators switch inside the container
if (!state) {
return;
}
const pendingPath = pendingPopStatePathRef.current;

@@ -297,14 +241,14 @@ const route = findFocusedRoute(state);

previousStateRef.current = state;
pendingPopStatePathRef.current = undefined; // To detect the kind of state change, we need to:
pendingPopStatePathRef.current = undefined;
// To detect the kind of state change, we need to:
// - Find the common focused navigation state in previous and current state
// - If only the route keys changed, compare history/routes.length to check if we go back/forward/replace
// - If no common focused navigation state found, it's a replace
const [previousFocusedState, focusedState] = findMatchingState(previousState, state);
if (previousFocusedState && focusedState && // We should only handle push/pop if path changed from what was in last `popstate`
if (previousFocusedState && focusedState &&
// We should only handle push/pop if path changed from what was in last `popstate`
// Otherwise it's likely a change triggered by `popstate`
path !== pendingPath) {
const historyDelta = (focusedState.history ? focusedState.history.length : focusedState.routes.length) - (previousFocusedState.history ? previousFocusedState.history.length : previousFocusedState.routes.length);
if (historyDelta > 0) {

@@ -319,2 +263,3 @@ // If history length is increased, we should pushState

// If history length is decreased, i.e. entries were removed, we want to go back
const nextIndex = history.backIndex({

@@ -324,3 +269,2 @@ path

const currentIndex = history.index;
try {

@@ -335,5 +279,5 @@ if (nextIndex !== -1 && nextIndex < currentIndex) {

await history.go(historyDelta);
} // Store the updated state as well as fix the path if incorrect
}
// Store the updated state as well as fix the path if incorrect
history.replace({

@@ -343,3 +287,4 @@ path,

});
} catch (e) {// The navigation was interrupted
} catch (e) {
// The navigation was interrupted
}

@@ -361,9 +306,9 @@ } else {

}
}; // We debounce onStateChange coz we don't want multiple state changes to be handled at one time
};
// We debounce onStateChange coz we don't want multiple state changes to be handled at one time
// This could happen since `history.go(n)` is asynchronous
// If `pushState` or `replaceState` were called before `history.go(n)` completes, it'll mess stuff up
return (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.addListener('state', series(onStateChange));
});
}, [enabled, history, ref]);
return {

@@ -370,0 +315,0 @@ getInitialState

@@ -13,3 +13,4 @@ import { getActionFromState as getActionFromStateDefault, getStateFromPath as getStateFromPathDefault } from '@react-navigation/core';

config,
getInitialURL = () => Promise.race([Linking.getInitialURL(), new Promise(resolve => // Timeout in 150ms if `getInitialState` doesn't resolve
getInitialURL = () => Promise.race([Linking.getInitialURL(), new Promise(resolve =>
// Timeout in 150ms if `getInitialState` doesn't resolve
// Workaround for https://github.com/facebook/react-native/issues/25675

@@ -19,3 +20,2 @@ setTimeout(resolve, 150))]),

var _Linking$removeEventL;
const callback = _ref2 => {

@@ -27,5 +27,6 @@ let {

};
const subscription = Linking.addEventListener('url', callback);
const subscription = Linking.addEventListener('url', callback); // Storing this in a local variable stops Jest from complaining about import after teardown
// Storing this in a local variable stops Jest from complaining about import after teardown
// @ts-expect-error: removeEventListener is not present in newer RN versions
const removeEventListener = (_Linking$removeEventL = Linking.removeEventListener) === null || _Linking$removeEventL === void 0 ? void 0 : _Linking$removeEventL.bind(Linking);

@@ -48,20 +49,14 @@ return () => {

}
if (independent) {
return undefined;
}
if (enabled !== false && linkingHandlers.length) {
console.error(['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:', "- You don't have multiple NavigationContainers in the app each with 'linking' enabled", '- Only a single instance of the root component is rendered', Platform.OS === 'android' ? "- You have set 'android:launchMode=singleTask' in the '<activity />' section of the 'AndroidManifest.xml' file to avoid launching multiple instances" : ''].join('\n').trim());
}
const handler = Symbol();
if (enabled !== false) {
linkingHandlers.push(handler);
}
return () => {
const index = linkingHandlers.indexOf(handler);
if (index > -1) {

@@ -71,6 +66,7 @@ linkingHandlers.splice(index, 1);

};
}, [enabled, independent]); // We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
}, [enabled, independent]);
// We store these options in ref to avoid re-creating getInitialState and re-subscribing listeners
// This lets user avoid wrapping the items in `React.useCallback` or `React.useMemo`
// Not re-creating `getInitialState` is important coz it makes it easier for the user to use in an effect
const enabledRef = React.useRef(enabled);

@@ -96,3 +92,2 @@ const prefixesRef = React.useRef(prefixes);

}
const path = extractPathFromURL(prefixesRef.current, url);

@@ -103,6 +98,4 @@ return path !== undefined ? getStateFromPathRef.current(path, configRef.current) : undefined;

let state;
if (enabledRef.current) {
const url = getInitialURLRef.current();
if (url != null && typeof url !== 'string') {

@@ -114,6 +107,4 @@ return url.then(url => {

}
state = getStateFromURL(url);
}
const thenable = {

@@ -123,7 +114,5 @@ then(onfulfilled) {

},
catch() {
return thenable;
}
};

@@ -137,6 +126,4 @@ return thenable;

}
const navigation = ref.current;
const state = navigation ? getStateFromURL(url) : undefined;
if (navigation && state) {

@@ -146,3 +133,2 @@ // Make sure that the routes in the state exist in the root navigator

const rootState = navigation.getRootState();
if (state.routes.some(r => !(rootState !== null && rootState !== void 0 && rootState.routeNames.includes(r.name)))) {

@@ -152,5 +138,3 @@ console.warn("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.");

}
const action = getActionFromStateRef.current(state, configRef.current);
if (action !== undefined) {

@@ -162,4 +146,3 @@ try {

// This could happen in case of malformed links, navigation object not being initialized etc.
console.warn(`An error occurred when trying to handle the link '${url}': ${typeof e === 'object' && e != null && 'message' in e ? // @ts-expect-error: we're already checking for this
e.message : e}`);
console.warn(`An error occurred when trying to handle the link '${url}': ${typeof e === 'object' && e != null && 'message' in e ? e.message : e}`);
}

@@ -171,3 +154,2 @@ } else {

};
return subscribe(listener);

@@ -174,0 +156,0 @@ }, [enabled, getStateFromURL, ref, subscribe]);

@@ -6,3 +6,2 @@ import { getPathFromState, NavigationContainerRefContext, NavigationHelpersContext } from '@react-navigation/core';

import useLinkTo from './useLinkTo';
const getStateFromParams = params => {

@@ -12,3 +11,2 @@ if (params !== null && params !== void 0 && params.state) {

}
if (params !== null && params !== void 0 && params.screen) {

@@ -24,5 +22,5 @@ return {

}
return undefined;
};
/**

@@ -34,7 +32,3 @@ * Hook to get props for an anchor tag so it can work with in page navigation.

*/
export default function useLinkProps(_ref) {
var _options$getPathFromS;
let {

@@ -50,15 +44,15 @@ to,

const linkTo = useLinkTo();
const onPress = e => {
var _e$currentTarget;
let shouldHandle = false;
if (Platform.OS !== 'web' || !e) {
shouldHandle = e ? !e.defaultPrevented : true;
} else if (!e.defaultPrevented && // onPress prevented default
} else if (!e.defaultPrevented &&
// onPress prevented default
// @ts-expect-error: these properties exist on web, but not in React Native
!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && ( // ignore clicks with modifier keys
!(e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) && (
// ignore clicks with modifier keys
// @ts-expect-error: these properties exist on web, but not in React Native
e.button == null || e.button === 0) && // ignore everything but left clicks
e.button == null || e.button === 0) &&
// ignore everything but left clicks
// @ts-expect-error: these properties exist on web, but not in React Native

@@ -70,3 +64,2 @@ [undefined, null, '', 'self'].includes((_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 ? void 0 : _e$currentTarget.target) // let browser handle "target=_blank" etc.

}
if (shouldHandle) {

@@ -86,4 +79,3 @@ if (action) {

};
const getPathFromStateHelper = (_options$getPathFromS = options === null || options === void 0 ? void 0 : options.getPathFromState) !== null && _options$getPathFromS !== void 0 ? _options$getPathFromS : getPathFromState;
const getPathFromStateHelper = (options === null || options === void 0 ? void 0 : options.getPathFromState) ?? getPathFromState;
const href = typeof to === 'string' ? to : getPathFromStateHelper({

@@ -90,0 +82,0 @@ routes: [{

@@ -11,3 +11,2 @@ import { getActionFromState, getStateFromPath, NavigationContainerRefContext } from '@react-navigation/core';

}
if (typeof to !== 'string') {

@@ -18,7 +17,5 @@ // @ts-expect-error: This is fine

}
if (!to.startsWith('/')) {
throw new Error(`The path must start with '/' (${to}).`);
}
const {

@@ -28,6 +25,4 @@ options

const state = options !== null && options !== void 0 && options.getStateFromPath ? options.getStateFromPath(to, options.config) : getStateFromPath(to, options === null || options === void 0 ? void 0 : options.config);
if (state) {
const action = getActionFromState(state, options === null || options === void 0 ? void 0 : options.config);
if (action !== undefined) {

@@ -34,0 +29,0 @@ navigation.dispatch(action);

import { useNavigation, useRoute } from '@react-navigation/core';
import * as React from 'react';
function getScrollableNode(ref) {

@@ -8,3 +7,2 @@ if (ref.current == null) {

}
if ('scrollToTop' in ref.current || 'scrollTo' in ref.current || 'scrollToOffset' in ref.current || 'scrollResponderScrollTo' in ref.current) {

@@ -27,3 +25,2 @@ // This is already a scrollable node.

}
export default function useScrollToTop(ref) {

@@ -33,53 +30,61 @@ const navigation = useNavigation();

React.useEffect(() => {
let current = navigation; // The screen might be inside another navigator such as stack nested in tabs
// We need to find the closest tab navigator and add the listener there
let tabNavigations = [];
let currentNavigation = navigation;
while (current && current.getState().type !== 'tab') {
current = current.getParent();
// If the screen is nested inside multiple tab navigators, we should scroll to top for any of them
// So we need to find all the parent tab navigators and add the listeners there
while (currentNavigation) {
if (currentNavigation.getState().type === 'tab') {
tabNavigations.push(currentNavigation);
}
currentNavigation = currentNavigation.getParent();
}
if (!current) {
if (tabNavigations.length === 0) {
return;
}
const unsubscribers = tabNavigations.map(tab => {
return tab.addListener(
// We don't wanna import tab types here to avoid extra deps
// in addition, there are multiple tab implementations
// @ts-expect-error
'tabPress', e => {
// We should scroll to top only when the screen is focused
const isFocused = navigation.isFocused();
const unsubscribe = current.addListener( // We don't wanna import tab types here to avoid extra deps
// in addition, there are multiple tab implementations
// @ts-expect-error
'tabPress', e => {
// We should scroll to top only when the screen is focused
const isFocused = navigation.isFocused(); // In a nested stack navigator, tab press resets the stack to first screen
// So we should scroll to top only when we are on first screen
// In a nested stack navigator, tab press resets the stack to first screen
// So we should scroll to top only when we are on first screen
const isFirst = tabNavigations.includes(navigation) || navigation.getState().routes[0].key === route.key;
const isFirst = navigation === current || navigation.getState().routes[0].key === route.key; // Run the operation in the next frame so we're sure all listeners have been run
// This is necessary to know if preventDefault() has been called
requestAnimationFrame(() => {
const scrollable = getScrollableNode(ref);
if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
if ('scrollToTop' in scrollable) {
scrollable.scrollToTop();
} else if ('scrollTo' in scrollable) {
scrollable.scrollTo({
x: 0,
y: 0,
animated: true
});
} else if ('scrollToOffset' in scrollable) {
scrollable.scrollToOffset({
offset: 0,
animated: true
});
} else if ('scrollResponderScrollTo' in scrollable) {
scrollable.scrollResponderScrollTo({
y: 0,
animated: true
});
// Run the operation in the next frame so we're sure all listeners have been run
// This is necessary to know if preventDefault() has been called
requestAnimationFrame(() => {
const scrollable = getScrollableNode(ref);
if (isFocused && isFirst && scrollable && !e.defaultPrevented) {
if ('scrollToTop' in scrollable) {
scrollable.scrollToTop();
} else if ('scrollTo' in scrollable) {
scrollable.scrollTo({
y: 0,
animated: true
});
} else if ('scrollToOffset' in scrollable) {
scrollable.scrollToOffset({
offset: 0,
animated: true
});
} else if ('scrollResponderScrollTo' in scrollable) {
scrollable.scrollResponderScrollTo({
y: 0,
animated: true
});
}
}
}
});
});
});
return unsubscribe;
return () => {
unsubscribers.forEach(unsubscribe => unsubscribe());
};
}, [navigation, ref, route.key]);
}
//# sourceMappingURL=useScrollToTop.js.map
import * as React from 'react';
export default function useThenable(create) {
const [promise] = React.useState(create);
let initialState = [false, undefined]; // Check if our thenable is synchronous
let initialState = [false, undefined];
// Check if our thenable is synchronous
promise.then(result => {

@@ -13,6 +14,4 @@ initialState = [true, result];

let cancelled = false;
const resolve = async () => {
let result;
try {

@@ -26,7 +25,5 @@ result = await promise;

};
if (!resolved) {
resolve();
}
return () => {

@@ -33,0 +30,0 @@ cancelled = true;

@@ -19,1 +19,2 @@ declare const window: {

export default window;
//# sourceMappingURL=window.d.ts.map
import type { NavigationState } from '@react-navigation/core';
declare type HistoryRecord = {
type HistoryRecord = {
id: string;

@@ -25,1 +25,2 @@ state: NavigationState;

export {};
//# sourceMappingURL=createMemoryHistory.d.ts.map
export default function extractPathFromURL(prefixes: string[], url: string): string | undefined;
//# sourceMappingURL=extractPathFromURL.d.ts.map

@@ -15,1 +15,2 @@ export { default as Link } from './Link';

export * from '@react-navigation/core';
//# sourceMappingURL=index.d.ts.map

@@ -5,3 +5,3 @@ import type { NavigationAction } from '@react-navigation/core';

import type { To } from './useLinkTo';
declare type Props<ParamList extends ReactNavigation.RootParamList> = {
type Props<ParamList extends ReactNavigation.RootParamList> = {
to: To<ParamList>;

@@ -11,3 +11,4 @@ action?: NavigationAction;

onPress?: (e: React.MouseEvent<HTMLAnchorElement, MouseEvent> | GestureResponderEvent) => void;
} & (TextProps & {
} & (Omit<TextProps, 'disabled'> & {
disabled?: boolean | null;
children: React.ReactNode;

@@ -25,1 +26,2 @@ });

export {};
//# sourceMappingURL=Link.d.ts.map

@@ -8,1 +8,2 @@ import type { ParamListBase } from '@react-navigation/core';

export default LinkingContext;
//# sourceMappingURL=LinkingContext.d.ts.map

@@ -9,3 +9,3 @@ import { NavigationContainerProps, NavigationContainerRef } from '@react-navigation/core';

}
declare type Props<ParamList extends {}> = NavigationContainerProps & {
type Props<ParamList extends {}> = NavigationContainerProps & {
theme?: Theme;

@@ -27,1 +27,2 @@ linking?: LinkingOptions<ParamList>;

export default NavigationContainer;
//# sourceMappingURL=NavigationContainer.d.ts.map

@@ -15,1 +15,2 @@ import * as React from 'react';

export default _default;
//# sourceMappingURL=ServerContainer.d.ts.map
import * as React from 'react';
export declare type ServerContextType = {
export type ServerContextType = {
location?: {

@@ -10,1 +10,2 @@ pathname: string;

export default ServerContext;
//# sourceMappingURL=ServerContext.d.ts.map
import type { Theme } from '../types';
declare const DarkTheme: Theme;
export default DarkTheme;
//# sourceMappingURL=DarkTheme.d.ts.map
import type { Theme } from '../types';
declare const DefaultTheme: Theme;
export default DefaultTheme;
//# sourceMappingURL=DefaultTheme.d.ts.map

@@ -5,1 +5,2 @@ import * as React from 'react';

export default ThemeContext;
//# sourceMappingURL=ThemeContext.d.ts.map
import * as React from 'react';
import type { Theme } from '../types';
declare type Props = {
type Props = {
value: Theme;

@@ -9,1 +9,2 @@ children: React.ReactNode;

export {};
//# sourceMappingURL=ThemeProvider.d.ts.map
export default function useTheme(): import("..").Theme;
//# sourceMappingURL=useTheme.d.ts.map
import type { getActionFromState as getActionFromStateDefault, getPathFromState as getPathFromStateDefault, getStateFromPath as getStateFromPathDefault, PathConfigMap, Route } from '@react-navigation/core';
export declare type Theme = {
export type Theme = {
dark: boolean;

@@ -13,3 +13,3 @@ colors: {

};
export declare type LinkingOptions<ParamList extends {}> = {
export type LinkingOptions<ParamList extends {}> = {
/**

@@ -121,8 +121,9 @@ * Whether deep link handling should be enabled.

};
export declare type DocumentTitleOptions = {
export type DocumentTitleOptions = {
enabled?: boolean;
formatter?: (options: Record<string, any> | undefined, route: Route<string> | undefined) => string;
};
export declare type ServerContainerRef = {
export type ServerContainerRef = {
getCurrentOptions(): Record<string, any> | undefined;
};
//# sourceMappingURL=types.d.ts.map

@@ -0,3 +1,4 @@

/// <reference types="react" />
import type { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
import * as React from 'react';
export default function useBackButton(ref: React.RefObject<NavigationContainerRef<ParamListBase>>): void;
export default function useBackButton(_: React.RefObject<NavigationContainerRef<ParamListBase>>): void;
//# sourceMappingURL=useBackButton.d.ts.map

@@ -8,1 +8,2 @@ import type { NavigationContainerRef, ParamListBase } from '@react-navigation/core';

export default function useDocumentTitle(ref: React.RefObject<NavigationContainerRef<ParamListBase>>, { enabled, formatter, }?: DocumentTitleOptions): void;
//# sourceMappingURL=useDocumentTitle.d.ts.map
export default function useDocumentTitle(): void;
//# sourceMappingURL=useDocumentTitle.native.d.ts.map

@@ -6,1 +6,2 @@ /**

export default function useLinkBuilder(): (name: string, params?: object) => string | undefined;
//# sourceMappingURL=useLinkBuilder.d.ts.map
import { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
import * as React from 'react';
import type { LinkingOptions } from './types';
declare type Options = LinkingOptions<ParamListBase> & {
/**
* Run async function in series as it's called.
*/
export declare const series: (cb: () => Promise<void>) => () => void;
type Options = LinkingOptions<ParamListBase> & {
independent?: boolean;

@@ -51,1 +55,2 @@ };

export {};
//# sourceMappingURL=useLinking.d.ts.map
import { NavigationContainerRef, ParamListBase } from '@react-navigation/core';
import * as React from 'react';
import type { LinkingOptions } from './types';
declare type Options = LinkingOptions<ParamListBase> & {
type Options = LinkingOptions<ParamListBase> & {
independent?: boolean;

@@ -51,1 +51,2 @@ };

export {};
//# sourceMappingURL=useLinking.native.d.ts.map

@@ -5,3 +5,3 @@ import { NavigationAction } from '@react-navigation/core';

import { To } from './useLinkTo';
declare type Props<ParamList extends ReactNavigation.RootParamList> = {
type Props<ParamList extends ReactNavigation.RootParamList> = {
to: To<ParamList>;

@@ -22,1 +22,2 @@ action?: NavigationAction;

export {};
//# sourceMappingURL=useLinkProps.d.ts.map

@@ -1,2 +0,2 @@

export declare type To<ParamList extends ReactNavigation.RootParamList = ReactNavigation.RootParamList, RouteName extends keyof ParamList = keyof ParamList> = string | (undefined extends ParamList[RouteName] ? {
export type To<ParamList extends ReactNavigation.RootParamList = ReactNavigation.RootParamList, RouteName extends keyof ParamList = keyof ParamList> = string | (undefined extends ParamList[RouteName] ? {
screen: Extract<RouteName, string>;

@@ -9,1 +9,2 @@ params?: ParamList[RouteName];

export default function useLinkTo<ParamList extends ReactNavigation.RootParamList>(): (to: To<ParamList>) => void;
//# sourceMappingURL=useLinkTo.d.ts.map
import * as React from 'react';
declare type ScrollOptions = {
import type { ScrollView } from 'react-native';
type ScrollOptions = {
x?: number;

@@ -7,3 +8,3 @@ y?: number;

};
declare type ScrollableView = {
type ScrollableView = {
scrollToTop(): void;

@@ -20,4 +21,4 @@ } | {

};
declare type ScrollableWrapper = {
getScrollResponder(): React.ReactNode;
type ScrollableWrapper = {
getScrollResponder(): React.ReactNode | ScrollView;
} | {

@@ -28,1 +29,2 @@ getNode(): ScrollableView;

export {};
//# sourceMappingURL=useScrollToTop.d.ts.map
export default function useThenable<T>(create: () => PromiseLike<T>): [boolean, T | undefined];
//# sourceMappingURL=useThenable.d.ts.map
{
"name": "@react-navigation/native",
"description": "React Native integration for React Navigation",
"version": "6.0.12",
"version": "6.1.8",
"keywords": [

@@ -40,3 +40,3 @@ "react-native",

"dependencies": {
"@react-navigation/core": "^6.3.0",
"@react-navigation/core": "^6.4.9",
"escape-string-regexp": "^4.0.0",

@@ -47,12 +47,12 @@ "fast-deep-equal": "^3.1.3",

"devDependencies": {
"@testing-library/react-native": "^7.2.0",
"@types/react": "^17.0.47",
"@types/react-dom": "^17.0.11",
"@types/react-native": "~0.68.1",
"del-cli": "^3.0.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-native": "~0.68.2",
"react-native-builder-bob": "^0.18.1",
"typescript": "^4.7.4"
"@testing-library/react-native": "^11.5.0",
"@types/react": "~18.0.27",
"@types/react-dom": "~18.0.10",
"@types/react-native": "~0.71.3",
"del-cli": "^5.0.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-native": "0.71.8",
"react-native-builder-bob": "^0.20.4",
"typescript": "^4.9.4"
},

@@ -77,3 +77,3 @@ "peerDependencies": {

},
"gitHead": "83aa392f1e13796d609c9df0afa44699ce4bacae"
"gitHead": "46954cec3d746aa2d9097d1b94f9e2a915d3e1c7"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc