feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 React Navigation Contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -0,0 +1,44 @@
# `@react-navigation/core`
Core utilities for building navigators independent of the platform.
## Installation
Open a Terminal in your project's folder and run,
```sh
yarn add @react-navigation/core
```
## Usage
A basic custom navigator bundling a router and a view looks like this:
```js
import {
createNavigatorFactory,
useNavigationBuilder,
} from '@react-navigation/core';
import { StackRouter } from '@react-navigation/routers';
function StackNavigator({ initialRouteName, children, ...rest }) {
const { state, navigation, descriptors, NavigationContent } =
useNavigationBuilder(StackRouter, {
initialRouteName,
children,
});
return (
<NavigationContent>
<StackView
state={state}
navigation={navigation}
descriptors={descriptors}
{...rest}
/>
</NavigationContent>
);
}
export default createNavigatorFactory(StackNavigator);
```

View File

@@ -0,0 +1,348 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _routers = require("@react-navigation/routers");
var React = _interopRequireWildcard(require("react"));
var _checkDuplicateRouteNames = _interopRequireDefault(require("./checkDuplicateRouteNames"));
var _checkSerializable = _interopRequireDefault(require("./checkSerializable"));
var _createNavigationContainerRef = require("./createNavigationContainerRef");
var _EnsureSingleNavigator = _interopRequireDefault(require("./EnsureSingleNavigator"));
var _findFocusedRoute = _interopRequireDefault(require("./findFocusedRoute"));
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
var _NavigationContainerRefContext = _interopRequireDefault(require("./NavigationContainerRefContext"));
var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
var _NavigationStateContext = _interopRequireDefault(require("./NavigationStateContext"));
var _UnhandledActionContext = _interopRequireDefault(require("./UnhandledActionContext"));
var _useChildListeners = _interopRequireDefault(require("./useChildListeners"));
var _useEventEmitter = _interopRequireDefault(require("./useEventEmitter"));
var _useKeyedChildListeners = _interopRequireDefault(require("./useKeyedChildListeners"));
var _useOptionsGetters = _interopRequireDefault(require("./useOptionsGetters"));
var _useScheduleUpdate = require("./useScheduleUpdate");
var _useSyncState = _interopRequireDefault(require("./useSyncState"));
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 serializableWarnings = [];
const duplicateNameWarnings = [];
/**
* Remove `key` and `routeNames` from the state objects recursively to get partial state.
*
* @param state Initial state object.
*/
const getPartialState = state => {
if (state === undefined) {
return;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {
key,
routeNames,
...partialState
} = state;
return {
...partialState,
stale: true,
routes: state.routes.map(route => {
if (route.state === undefined) {
return route;
}
return {
...route,
state: getPartialState(route.state)
};
})
};
};
/**
* Container component which holds the navigation state.
* This should be rendered at the root wrapping the whole app.
*
* @param props.initialState Initial state object for the navigation tree.
* @param props.onStateChange Callback which is called with the latest navigation state when it changes.
* @param props.children Child elements to render the content.
* @param props.ref Ref object which refers to the navigation object containing helper methods.
*/
const BaseNavigationContainer = /*#__PURE__*/React.forwardRef(function BaseNavigationContainer(_ref, ref) {
let {
initialState,
onStateChange,
onUnhandledAction,
independent,
children
} = _ref;
const parent = React.useContext(_NavigationStateContext.default);
if (!parent.isDefault && !independent) {
throw new Error("Looks like you have nested a 'NavigationContainer' inside another. Normally you need only one container at the root of the app, so this was probably an error. If this was intentional, pass 'independent={true}' explicitly. Note that this will make the child navigators disconnected from the parent and you won't be able to navigate between them.");
}
const [state, getState, setState, scheduleUpdate, flushUpdates] = (0, _useSyncState.default)(() => getPartialState(initialState == null ? undefined : initialState));
const isFirstMountRef = React.useRef(true);
const navigatorKeyRef = React.useRef();
const getKey = React.useCallback(() => navigatorKeyRef.current, []);
const setKey = React.useCallback(key => {
navigatorKeyRef.current = key;
}, []);
const {
listeners,
addListener
} = (0, _useChildListeners.default)();
const {
keyedListeners,
addKeyedListener
} = (0, _useKeyedChildListeners.default)();
const dispatch = React.useCallback(action => {
if (listeners.focus[0] == null) {
console.error(_createNavigationContainerRef.NOT_INITIALIZED_ERROR);
} else {
listeners.focus[0](navigation => navigation.dispatch(action));
}
}, [listeners.focus]);
const canGoBack = React.useCallback(() => {
if (listeners.focus[0] == null) {
return false;
}
const {
result,
handled
} = listeners.focus[0](navigation => navigation.canGoBack());
if (handled) {
return result;
} else {
return false;
}
}, [listeners.focus]);
const resetRoot = React.useCallback(state => {
var _keyedListeners$getSt, _keyedListeners$getSt2;
const target = (state === null || state === void 0 ? void 0 : state.key) ?? ((_keyedListeners$getSt = (_keyedListeners$getSt2 = keyedListeners.getState).root) === null || _keyedListeners$getSt === void 0 ? void 0 : _keyedListeners$getSt.call(_keyedListeners$getSt2).key);
if (target == null) {
console.error(_createNavigationContainerRef.NOT_INITIALIZED_ERROR);
} else {
listeners.focus[0](navigation => navigation.dispatch({
..._routers.CommonActions.reset(state),
target
}));
}
}, [keyedListeners.getState, listeners.focus]);
const getRootState = React.useCallback(() => {
var _keyedListeners$getSt3, _keyedListeners$getSt4;
return (_keyedListeners$getSt3 = (_keyedListeners$getSt4 = keyedListeners.getState).root) === null || _keyedListeners$getSt3 === void 0 ? void 0 : _keyedListeners$getSt3.call(_keyedListeners$getSt4);
}, [keyedListeners.getState]);
const getCurrentRoute = React.useCallback(() => {
const state = getRootState();
if (state == null) {
return undefined;
}
const route = (0, _findFocusedRoute.default)(state);
return route;
}, [getRootState]);
const emitter = (0, _useEventEmitter.default)();
const {
addOptionsGetter,
getCurrentOptions
} = (0, _useOptionsGetters.default)({});
const navigation = React.useMemo(() => ({
...Object.keys(_routers.CommonActions).reduce((acc, name) => {
acc[name] = function () {
return (
// @ts-expect-error: this is ok
dispatch(_routers.CommonActions[name](...arguments))
);
};
return acc;
}, {}),
...emitter.create('root'),
dispatch,
resetRoot,
isFocused: () => true,
canGoBack,
getParent: () => undefined,
getState: () => stateRef.current,
getRootState,
getCurrentRoute,
getCurrentOptions,
isReady: () => listeners.focus[0] != null,
setOptions: () => {
throw new Error('Cannot call setOptions outside a screen');
}
}), [canGoBack, dispatch, emitter, getCurrentOptions, getCurrentRoute, getRootState, listeners.focus, resetRoot]);
React.useImperativeHandle(ref, () => navigation, [navigation]);
const onDispatchAction = React.useCallback((action, noop) => {
emitter.emit({
type: '__unsafe_action__',
data: {
action,
noop,
stack: stackRef.current
}
});
}, [emitter]);
const lastEmittedOptionsRef = React.useRef();
const onOptionsChange = React.useCallback(options => {
if (lastEmittedOptionsRef.current === options) {
return;
}
lastEmittedOptionsRef.current = options;
emitter.emit({
type: 'options',
data: {
options
}
});
}, [emitter]);
const stackRef = React.useRef();
const builderContext = React.useMemo(() => ({
addListener,
addKeyedListener,
onDispatchAction,
onOptionsChange,
stackRef
}), [addListener, addKeyedListener, onDispatchAction, onOptionsChange]);
const scheduleContext = React.useMemo(() => ({
scheduleUpdate,
flushUpdates
}), [scheduleUpdate, flushUpdates]);
const isInitialRef = React.useRef(true);
const getIsInitial = React.useCallback(() => isInitialRef.current, []);
const context = React.useMemo(() => ({
state,
getState,
setState,
getKey,
setKey,
getIsInitial,
addOptionsGetter
}), [state, getState, setState, getKey, setKey, getIsInitial, addOptionsGetter]);
const onStateChangeRef = React.useRef(onStateChange);
const stateRef = React.useRef(state);
React.useEffect(() => {
isInitialRef.current = false;
onStateChangeRef.current = onStateChange;
stateRef.current = state;
});
React.useEffect(() => {
const hydratedState = getRootState();
if (process.env.NODE_ENV !== 'production') {
if (hydratedState !== undefined) {
const serializableResult = (0, _checkSerializable.default)(hydratedState);
if (!serializableResult.serializable) {
const {
location,
reason
} = serializableResult;
let path = '';
let pointer = hydratedState;
let params = false;
for (let i = 0; i < location.length; i++) {
const curr = location[i];
const prev = location[i - 1];
pointer = pointer[curr];
if (!params && curr === 'state') {
continue;
} else if (!params && curr === 'routes') {
if (path) {
path += ' > ';
}
} else if (!params && typeof curr === 'number' && prev === 'routes') {
var _pointer;
path += (_pointer = pointer) === null || _pointer === void 0 ? void 0 : _pointer.name;
} else if (!params) {
path += ` > ${curr}`;
params = true;
} else {
if (typeof curr === 'number' || /^[0-9]+$/.test(curr)) {
path += `[${curr}]`;
} else if (/^[a-z$_]+$/i.test(curr)) {
path += `.${curr}`;
} else {
path += `[${JSON.stringify(curr)}]`;
}
}
}
const message = `Non-serializable values were found in the navigation state. Check:\n\n${path} (${reason})\n\nThis can break usage such as persisting and restoring state. This might happen if you passed non-serializable values such as function, class instances etc. in params. If you need to use components with callbacks in your options, you can use 'navigation.setOptions' instead. See https://reactnavigation.org/docs/troubleshooting#i-get-the-warning-non-serializable-values-were-found-in-the-navigation-state for more details.`;
if (!serializableWarnings.includes(message)) {
serializableWarnings.push(message);
console.warn(message);
}
}
const duplicateRouteNamesResult = (0, _checkDuplicateRouteNames.default)(hydratedState);
if (duplicateRouteNamesResult.length) {
const message = `Found screens with the same name nested inside one another. Check:\n${duplicateRouteNamesResult.map(locations => `\n${locations.join(', ')}`)}\n\nThis can cause confusing behavior during navigation. Consider using unique names for each screen instead.`;
if (!duplicateNameWarnings.includes(message)) {
duplicateNameWarnings.push(message);
console.warn(message);
}
}
}
}
emitter.emit({
type: 'state',
data: {
state
}
});
if (!isFirstMountRef.current && onStateChangeRef.current) {
onStateChangeRef.current(hydratedState);
}
isFirstMountRef.current = false;
}, [getRootState, emitter, state]);
const defaultOnUnhandledAction = React.useCallback(action => {
if (process.env.NODE_ENV === 'production') {
return;
}
const payload = action.payload;
let message = `The action '${action.type}'${payload ? ` with payload ${JSON.stringify(action.payload)}` : ''} was not handled by any navigator.`;
switch (action.type) {
case 'NAVIGATE':
case 'PUSH':
case 'REPLACE':
case 'JUMP_TO':
if (payload !== null && payload !== void 0 && payload.name) {
message += `\n\nDo you have a screen named '${payload.name}'?\n\nIf you're trying to navigate to a screen in a nested navigator, see https://reactnavigation.org/docs/nesting-navigators#navigating-to-a-screen-in-a-nested-navigator.`;
} else {
message += `\n\nYou need to pass the name of the screen to navigate to.\n\nSee https://reactnavigation.org/docs/navigation-actions for usage.`;
}
break;
case 'GO_BACK':
case 'POP':
case 'POP_TO_TOP':
message += `\n\nIs there any screen to go back to?`;
break;
case 'OPEN_DRAWER':
case 'CLOSE_DRAWER':
case 'TOGGLE_DRAWER':
message += `\n\nIs your screen inside a Drawer navigator?`;
break;
}
message += `\n\nThis is a development-only warning and won't be shown in production.`;
console.error(message);
}, []);
let element = /*#__PURE__*/React.createElement(_NavigationContainerRefContext.default.Provider, {
value: navigation
}, /*#__PURE__*/React.createElement(_useScheduleUpdate.ScheduleUpdateContext.Provider, {
value: scheduleContext
}, /*#__PURE__*/React.createElement(_NavigationBuilderContext.default.Provider, {
value: builderContext
}, /*#__PURE__*/React.createElement(_NavigationStateContext.default.Provider, {
value: context
}, /*#__PURE__*/React.createElement(_UnhandledActionContext.default.Provider, {
value: onUnhandledAction ?? defaultOnUnhandledAction
}, /*#__PURE__*/React.createElement(_EnsureSingleNavigator.default, null, children))))));
if (independent) {
// We need to clear any existing contexts for nested independent container to work correctly
element = /*#__PURE__*/React.createElement(_NavigationRouteContext.default.Provider, {
value: undefined
}, /*#__PURE__*/React.createElement(_NavigationContext.default.Provider, {
value: undefined
}, element));
}
return element;
});
var _default = BaseNavigationContainer;
exports.default = _default;
//# sourceMappingURL=BaseNavigationContainer.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }
/**
* Context which holds the values for the current navigation tree.
* Intended for use in SSR. This is not safe to use on the client.
*/
const CurrentRenderContext = /*#__PURE__*/React.createContext(undefined);
var _default = CurrentRenderContext;
exports.default = _default;
//# sourceMappingURL=CurrentRenderContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["CurrentRenderContext","React","createContext","undefined"],"sourceRoot":"../../src","sources":["CurrentRenderContext.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAE/B;AACA;AACA;AACA;AACA,MAAMA,oBAAoB,gBAAGC,KAAK,CAACC,aAAa,CAE9CC,SAAS,CAAC;AAAC,eAEEH,oBAAoB;AAAA"}

View File

@@ -0,0 +1,43 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SingleNavigatorContext = void 0;
exports.default = EnsureSingleNavigator;
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 MULTIPLE_NAVIGATOR_ERROR = `Another navigator is already registered for this container. You likely have multiple navigators under a single "NavigationContainer" or "Screen". Make sure each navigator is under a separate "Screen" container. See https://reactnavigation.org/docs/nesting-navigators for a guide on nesting.`;
const SingleNavigatorContext = /*#__PURE__*/React.createContext(undefined);
/**
* Component which ensures that there's only one navigator nested under it.
*/
exports.SingleNavigatorContext = SingleNavigatorContext;
function EnsureSingleNavigator(_ref) {
let {
children
} = _ref;
const navigatorKeyRef = React.useRef();
const value = React.useMemo(() => ({
register(key) {
const currentKey = navigatorKeyRef.current;
if (currentKey !== undefined && key !== currentKey) {
throw new Error(MULTIPLE_NAVIGATOR_ERROR);
}
navigatorKeyRef.current = key;
},
unregister(key) {
const currentKey = navigatorKeyRef.current;
if (key !== currentKey) {
return;
}
navigatorKeyRef.current = undefined;
}
}), []);
return /*#__PURE__*/React.createElement(SingleNavigatorContext.Provider, {
value: value
}, children);
}
//# sourceMappingURL=EnsureSingleNavigator.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["MULTIPLE_NAVIGATOR_ERROR","SingleNavigatorContext","React","createContext","undefined","EnsureSingleNavigator","children","navigatorKeyRef","useRef","value","useMemo","register","key","currentKey","current","Error","unregister"],"sourceRoot":"../../src","sources":["EnsureSingleNavigator.tsx"],"mappings":";;;;;;;AAAA;AAA+B;AAAA;AAM/B,MAAMA,wBAAwB,GAAI,oSAAmS;AAE9T,MAAMC,sBAAsB,gBAAGC,KAAK,CAACC,aAAa,CAMvDC,SAAS,CAAC;;AAEZ;AACA;AACA;AAFA;AAGe,SAASC,qBAAqB,OAAsB;EAAA,IAArB;IAAEC;EAAgB,CAAC;EAC/D,MAAMC,eAAe,GAAGL,KAAK,CAACM,MAAM,EAAsB;EAE1D,MAAMC,KAAK,GAAGP,KAAK,CAACQ,OAAO,CACzB,OAAO;IACLC,QAAQ,CAACC,GAAW,EAAE;MACpB,MAAMC,UAAU,GAAGN,eAAe,CAACO,OAAO;MAE1C,IAAID,UAAU,KAAKT,SAAS,IAAIQ,GAAG,KAAKC,UAAU,EAAE;QAClD,MAAM,IAAIE,KAAK,CAACf,wBAAwB,CAAC;MAC3C;MAEAO,eAAe,CAACO,OAAO,GAAGF,GAAG;IAC/B,CAAC;IACDI,UAAU,CAACJ,GAAW,EAAE;MACtB,MAAMC,UAAU,GAAGN,eAAe,CAACO,OAAO;MAE1C,IAAIF,GAAG,KAAKC,UAAU,EAAE;QACtB;MACF;MAEAN,eAAe,CAACO,OAAO,GAAGV,SAAS;IACrC;EACF,CAAC,CAAC,EACF,EAAE,CACH;EAED,oBACE,oBAAC,sBAAsB,CAAC,QAAQ;IAAC,KAAK,EAAEK;EAAM,GAC3CH,QAAQ,CACuB;AAEtC"}

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Group;
/**
* Empty component used for grouping screen configs.
*/
function Group(_) {
/* istanbul ignore next */
return null;
}
//# sourceMappingURL=Group.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Group","_"],"sourceRoot":"../../src","sources":["Group.tsx"],"mappings":";;;;;;AAIA;AACA;AACA;AACe,SAASA,KAAK,CAG3BC,CAA6C,EAAE;EAC/C;EACA,OAAO,IAAI;AACb"}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }
/**
* Context which holds the required helpers needed to build nested navigators.
*/
const NavigationBuilderContext = /*#__PURE__*/React.createContext({
onDispatchAction: () => undefined,
onOptionsChange: () => undefined
});
var _default = NavigationBuilderContext;
exports.default = _default;
//# sourceMappingURL=NavigationBuilderContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NavigationBuilderContext","React","createContext","onDispatchAction","undefined","onOptionsChange"],"sourceRoot":"../../src","sources":["NavigationBuilderContext.tsx"],"mappings":";;;;;;AAKA;AAA+B;AAAA;AA6C/B;AACA;AACA;AACA,MAAMA,wBAAwB,gBAAGC,KAAK,CAACC,aAAa,CAWjD;EACDC,gBAAgB,EAAE,MAAMC,SAAS;EACjCC,eAAe,EAAE,MAAMD;AACzB,CAAC,CAAC;AAAC,eAEYJ,wBAAwB;AAAA"}

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }
/**
* Context which holds the route prop for a screen.
*/
const NavigationContainerRefContext = /*#__PURE__*/React.createContext(undefined);
var _default = NavigationContainerRefContext;
exports.default = _default;
//# sourceMappingURL=NavigationContainerRefContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NavigationContainerRefContext","React","createContext","undefined"],"sourceRoot":"../../src","sources":["NavigationContainerRefContext.tsx"],"mappings":";;;;;;AACA;AAA+B;AAAA;AAI/B;AACA;AACA;AACA,MAAMA,6BAA6B,gBAAGC,KAAK,CAACC,aAAa,CAEvDC,SAAS,CAAC;AAAC,eAEEH,6BAA6B;AAAA"}

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }
/**
* Context which holds the navigation prop for a screen.
*/
const NavigationContext = /*#__PURE__*/React.createContext(undefined);
var _default = NavigationContext;
exports.default = _default;
//# sourceMappingURL=NavigationContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NavigationContext","React","createContext","undefined"],"sourceRoot":"../../src","sources":["NavigationContext.tsx"],"mappings":";;;;;;AACA;AAA+B;AAAA;AAI/B;AACA;AACA;AACA,MAAMA,iBAAiB,gBAAGC,KAAK,CAACC,aAAa,CAE3CC,SAAS,CAAC;AAAC,eAEEH,iBAAiB;AAAA"}

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }
/**
* Context which holds the navigation helpers of the parent navigator.
* Navigators should use this context in their view component.
*/
const NavigationHelpersContext = /*#__PURE__*/React.createContext(undefined);
var _default = NavigationHelpersContext;
exports.default = _default;
//# sourceMappingURL=NavigationHelpersContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NavigationHelpersContext","React","createContext","undefined"],"sourceRoot":"../../src","sources":["NavigationHelpersContext.tsx"],"mappings":";;;;;;AACA;AAA+B;AAAA;AAI/B;AACA;AACA;AACA;AACA,MAAMA,wBAAwB,gBAAGC,KAAK,CAACC,aAAa,CAElDC,SAAS,CAAC;AAAC,eAEEH,wBAAwB;AAAA"}

View File

@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }
/**
* Context which holds the route prop for a screen.
*/
const NavigationRouteContext = /*#__PURE__*/React.createContext(undefined);
var _default = NavigationRouteContext;
exports.default = _default;
//# sourceMappingURL=NavigationRouteContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NavigationRouteContext","React","createContext","undefined"],"sourceRoot":"../../src","sources":["NavigationRouteContext.tsx"],"mappings":";;;;;;AACA;AAA+B;AAAA;AAE/B;AACA;AACA;AACA,MAAMA,sBAAsB,gBAAGC,KAAK,CAACC,aAAa,CAChDC,SAAS,CACV;AAAC,eAEaH,sBAAsB;AAAA"}

View File

@@ -0,0 +1,30 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 MISSING_CONTEXT_ERROR = "Couldn't find a navigation context. Have you wrapped your app with 'NavigationContainer'? See https://reactnavigation.org/docs/getting-started for setup instructions.";
var _default = /*#__PURE__*/React.createContext({
isDefault: true,
get getKey() {
throw new Error(MISSING_CONTEXT_ERROR);
},
get setKey() {
throw new Error(MISSING_CONTEXT_ERROR);
},
get getState() {
throw new Error(MISSING_CONTEXT_ERROR);
},
get setState() {
throw new Error(MISSING_CONTEXT_ERROR);
},
get getIsInitial() {
throw new Error(MISSING_CONTEXT_ERROR);
}
});
exports.default = _default;
//# sourceMappingURL=NavigationStateContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["MISSING_CONTEXT_ERROR","React","createContext","isDefault","getKey","Error","setKey","getState","setState","getIsInitial"],"sourceRoot":"../../src","sources":["NavigationStateContext.tsx"],"mappings":";;;;;;AACA;AAA+B;AAAA;AAE/B,MAAMA,qBAAqB,GACzB,wKAAwK;AAAC,4BAE5JC,KAAK,CAACC,aAAa,CAc/B;EACDC,SAAS,EAAE,IAAI;EAEf,IAAIC,MAAM,GAAQ;IAChB,MAAM,IAAIC,KAAK,CAACL,qBAAqB,CAAC;EACxC,CAAC;EACD,IAAIM,MAAM,GAAQ;IAChB,MAAM,IAAID,KAAK,CAACL,qBAAqB,CAAC;EACxC,CAAC;EACD,IAAIO,QAAQ,GAAQ;IAClB,MAAM,IAAIF,KAAK,CAACL,qBAAqB,CAAC;EACxC,CAAC;EACD,IAAIQ,QAAQ,GAAQ;IAClB,MAAM,IAAIH,KAAK,CAACL,qBAAqB,CAAC;EACxC,CAAC;EACD,IAAIS,YAAY,GAAQ;IACtB,MAAM,IAAIJ,KAAK,CAACL,qBAAqB,CAAC;EACxC;AACF,CAAC,CAAC;AAAA"}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 PreventRemoveContext = /*#__PURE__*/React.createContext(undefined);
var _default = PreventRemoveContext;
exports.default = _default;
//# sourceMappingURL=PreventRemoveContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["PreventRemoveContext","React","createContext","undefined"],"sourceRoot":"../../src","sources":["PreventRemoveContext.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAQ/B,MAAMA,oBAAoB,gBAAGC,KAAK,CAACC,aAAa,CAU9CC,SAAS,CAAC;AAAC,eAEEH,oBAAoB;AAAA"}

View File

@@ -0,0 +1,96 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = PreventRemoveProvider;
var _nonSecure = require("nanoid/non-secure");
var React = _interopRequireWildcard(require("react"));
var _useLatestCallback = _interopRequireDefault(require("use-latest-callback"));
var _NavigationHelpersContext = _interopRequireDefault(require("./NavigationHelpersContext"));
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
var _PreventRemoveContext = _interopRequireDefault(require("./PreventRemoveContext"));
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; }
/**
* Util function to transform map of prevented routes to a simpler object.
*/
const transformPreventedRoutes = preventedRoutesMap => {
const preventedRoutesToTransform = [...preventedRoutesMap.values()];
const preventedRoutes = preventedRoutesToTransform.reduce((acc, _ref) => {
var _acc$routeKey;
let {
routeKey,
preventRemove
} = _ref;
acc[routeKey] = {
preventRemove: ((_acc$routeKey = acc[routeKey]) === null || _acc$routeKey === void 0 ? void 0 : _acc$routeKey.preventRemove) || preventRemove
};
return acc;
}, {});
return preventedRoutes;
};
/**
* Component used for managing which routes have to be prevented from removal in native-stack.
*/
function PreventRemoveProvider(_ref2) {
let {
children
} = _ref2;
const [parentId] = React.useState(() => (0, _nonSecure.nanoid)());
const [preventedRoutesMap, setPreventedRoutesMap] = React.useState(new Map());
const navigation = React.useContext(_NavigationHelpersContext.default);
const route = React.useContext(_NavigationRouteContext.default);
const preventRemoveContextValue = React.useContext(_PreventRemoveContext.default);
// take `setPreventRemove` from parent context - if exist it means we're in a nested context
const setParentPrevented = preventRemoveContextValue === null || preventRemoveContextValue === void 0 ? void 0 : preventRemoveContextValue.setPreventRemove;
const setPreventRemove = (0, _useLatestCallback.default)((id, routeKey, preventRemove) => {
if (preventRemove && (navigation == null || navigation !== null && navigation !== void 0 && navigation.getState().routes.every(route => route.key !== routeKey))) {
throw new Error(`Couldn't find a route with the key ${routeKey}. Is your component inside NavigationContent?`);
}
setPreventedRoutesMap(prevPrevented => {
var _prevPrevented$get, _prevPrevented$get2;
// values haven't changed - do nothing
if (routeKey === ((_prevPrevented$get = prevPrevented.get(id)) === null || _prevPrevented$get === void 0 ? void 0 : _prevPrevented$get.routeKey) && preventRemove === ((_prevPrevented$get2 = prevPrevented.get(id)) === null || _prevPrevented$get2 === void 0 ? void 0 : _prevPrevented$get2.preventRemove)) {
return prevPrevented;
}
const nextPrevented = new Map(prevPrevented);
if (preventRemove) {
nextPrevented.set(id, {
routeKey,
preventRemove
});
} else {
nextPrevented.delete(id);
}
return nextPrevented;
});
});
const isPrevented = [...preventedRoutesMap.values()].some(_ref3 => {
let {
preventRemove
} = _ref3;
return preventRemove;
});
React.useEffect(() => {
if ((route === null || route === void 0 ? void 0 : route.key) !== undefined && setParentPrevented !== undefined) {
// when route is defined (and setParentPrevented) it means we're in a nested stack
// route.key then will be the route key of parent
setParentPrevented(parentId, route.key, isPrevented);
return () => {
setParentPrevented(parentId, route.key, false);
};
}
return;
}, [parentId, isPrevented, route === null || route === void 0 ? void 0 : route.key, setParentPrevented]);
const value = React.useMemo(() => ({
setPreventRemove,
preventedRoutes: transformPreventedRoutes(preventedRoutesMap)
}), [setPreventRemove, preventedRoutesMap]);
return /*#__PURE__*/React.createElement(_PreventRemoveContext.default.Provider, {
value: value
}, children);
}
//# sourceMappingURL=PreventRemoveProvider.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["transformPreventedRoutes","preventedRoutesMap","preventedRoutesToTransform","values","preventedRoutes","reduce","acc","routeKey","preventRemove","PreventRemoveProvider","children","parentId","React","useState","nanoid","setPreventedRoutesMap","Map","navigation","useContext","NavigationHelpersContext","route","NavigationRouteContext","preventRemoveContextValue","PreventRemoveContext","setParentPrevented","setPreventRemove","useLatestCallback","id","getState","routes","every","key","Error","prevPrevented","get","nextPrevented","set","delete","isPrevented","some","useEffect","undefined","value","useMemo"],"sourceRoot":"../../src","sources":["PreventRemoveProvider.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AAEA;AACA;AACA;AAA+E;AAAA;AAAA;AAc/E;AACA;AACA;AACA,MAAMA,wBAAwB,GAC5BC,kBAAsC,IAClB;EACpB,MAAMC,0BAA0B,GAAG,CAAC,GAAGD,kBAAkB,CAACE,MAAM,EAAE,CAAC;EAEnE,MAAMC,eAAe,GAAGF,0BAA0B,CAACG,MAAM,CACvD,CAACC,GAAG,WAAkC;IAAA;IAAA,IAAhC;MAAEC,QAAQ;MAAEC;IAAc,CAAC;IAC/BF,GAAG,CAACC,QAAQ,CAAC,GAAG;MACdC,aAAa,EAAE,kBAAAF,GAAG,CAACC,QAAQ,CAAC,kDAAb,cAAeC,aAAa,KAAIA;IACjD,CAAC;IACD,OAAOF,GAAG;EACZ,CAAC,EACD,CAAC,CAAC,CACH;EAED,OAAOF,eAAe;AACxB,CAAC;;AAED;AACA;AACA;AACe,SAASK,qBAAqB,QAAsB;EAAA,IAArB;IAAEC;EAAgB,CAAC;EAC/D,MAAM,CAACC,QAAQ,CAAC,GAAGC,KAAK,CAACC,QAAQ,CAAC,MAAM,IAAAC,iBAAM,GAAE,CAAC;EACjD,MAAM,CAACb,kBAAkB,EAAEc,qBAAqB,CA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a;IACtB,CAAC,CAAC;EACJ,CAAC,CACF;EAED,MAAMG,WAAW,GAAG,CAAC,GAAGrC,kBAAkB,CAACE,MAAM,EAAE,CAAC,CAACoC,IAAI,CACvD;IAAA,IAAC;MAAE/B;IAAc,CAAC;IAAA,OAAKA,aAAa;EAAA,EACrC;EAEDI,KAAK,CAAC4B,SAAS,CAAC,MAAM;IACpB,IAAI,CAAApB,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEW,GAAG,MAAKU,SAAS,IAAIjB,kBAAkB,KAAKiB,SAAS,EAAE;MAChE;MACA;MACAjB,kBAAkB,CAACb,QAAQ,EAAES,KAAK,CAACW,GAAG,EAAEO,WAAW,CAAC;MACpD,OAAO,MAAM;QACXd,kBAAkB,CAACb,QAAQ,EAAES,KAAK,CAACW,GAAG,EAAE,KAAK,CAAC;MAChD,CAAC;IACH;IAEA;EACF,CAAC,EAAE,CAACpB,QAAQ,EAAE2B,WAAW,EAAElB,KAAK,aAALA,KAAK,uBAALA,KAAK,CAAEW,GAAG,EAAEP,kBAAkB,CAAC,CAAC;EAE3D,MAAMkB,KAAK,GAAG9B,KAAK,CAAC+B,OAAO,CACzB,OAAO;IACLlB,gBAAgB;IAChBrB,eAAe,EAAEJ,wBAAwB,CAACC,kBAAkB;EAC9D,CAAC,CAAC,EACF,CAACwB,gBAAgB,EAAExB,kBAAkB,CAAC,CACvC;EAED,oBACE,oBAAC,6BAAoB,CAAC,QAAQ;IAAC,KAAK,EAAEyC;EAAM,GACzChC,QAAQ,CACqB;AAEpC"}

View File

@@ -0,0 +1,93 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = SceneView;
var React = _interopRequireWildcard(require("react"));
var _EnsureSingleNavigator = _interopRequireDefault(require("./EnsureSingleNavigator"));
var _NavigationStateContext = _interopRequireDefault(require("./NavigationStateContext"));
var _StaticContainer = _interopRequireDefault(require("./StaticContainer"));
var _useOptionsGetters = _interopRequireDefault(require("./useOptionsGetters"));
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; }
/**
* Component which takes care of rendering the screen for a route.
* It provides all required contexts and applies optimizations when applicable.
*/
function SceneView(_ref) {
let {
screen,
route,
navigation,
routeState,
getState,
setState,
options,
clearOptions
} = _ref;
const navigatorKeyRef = React.useRef();
const getKey = React.useCallback(() => navigatorKeyRef.current, []);
const {
addOptionsGetter
} = (0, _useOptionsGetters.default)({
key: route.key,
options,
navigation
});
const setKey = React.useCallback(key => {
navigatorKeyRef.current = key;
}, []);
const getCurrentState = React.useCallback(() => {
const state = getState();
const currentRoute = state.routes.find(r => r.key === route.key);
return currentRoute ? currentRoute.state : undefined;
}, [getState, route.key]);
const setCurrentState = React.useCallback(child => {
const state = getState();
setState({
...state,
routes: state.routes.map(r => r.key === route.key ? {
...r,
state: child
} : r)
});
}, [getState, route.key, setState]);
const isInitialRef = React.useRef(true);
React.useEffect(() => {
isInitialRef.current = false;
});
// Clear options set by this screen when it is unmounted
React.useEffect(() => {
return clearOptions;
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
const getIsInitial = React.useCallback(() => isInitialRef.current, []);
const context = React.useMemo(() => ({
state: routeState,
getState: getCurrentState,
setState: setCurrentState,
getKey,
setKey,
getIsInitial,
addOptionsGetter
}), [routeState, getCurrentState, setCurrentState, getKey, setKey, getIsInitial, addOptionsGetter]);
const ScreenComponent = screen.getComponent ? screen.getComponent() : screen.component;
return /*#__PURE__*/React.createElement(_NavigationStateContext.default.Provider, {
value: context
}, /*#__PURE__*/React.createElement(_EnsureSingleNavigator.default, null, /*#__PURE__*/React.createElement(_StaticContainer.default, {
name: screen.name,
render: ScreenComponent || screen.children,
navigation: navigation,
route: route
}, ScreenComponent !== undefined ? /*#__PURE__*/React.createElement(ScreenComponent, {
navigation: navigation,
route: route
}) : screen.children !== undefined ? screen.children({
navigation,
route
}) : null)));
}
//# sourceMappingURL=SceneView.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["SceneView","screen","route","navigation","routeState","getState","setState","options","clearOptions","navigatorKeyRef","React","useRef","getKey","useCallback","current","addOptionsGetter","useOptionsGetters","key","setKey","getCurrentState","state","currentRoute","routes","find","r","undefined","setCurrentState","child","map","isInitialRef","useEffect","getIsInitial","context","useMemo","ScreenComponent","getComponent","component","name","children"],"sourceRoot":"../../src","sources":["SceneView.tsx"],"mappings":";;;;;;AAMA;AAEA;AACA;AACA;AAEA;AAAoD;AAAA;AAAA;AAmBpD;AACA;AACA;AACA;AACe,SAASA,SAAS,OAYD;EAAA,IAT9B;IACAC,MAAM;IACNC,KAAK;IACLC,UAAU;IACVC,UAAU;IACVC,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC;EAC2B,CAAC;EAC5B,MAAMC,eAAe,GAAGC,KAAK,CAACC,MAAM,EAAsB;EAC1D,MAAMC,MAAM,GAAGF,KAAK,CAACG,WAAW,CAAC,MAAMJ,eAAe,CAACK,OAAO,EAAE,EAAE,CAAC;EAEnE,MAAM;IAAEC;EAAiB,CAAC,GAAG,IAAAC,0BAA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ACnB;EACF,CAAC,EAAE,EAAE,CAAC;EAEN,MAAMuB,YAAY,GAAGrB,KAAK,CAACG,WAAW,CAAC,MAAMgB,YAAY,CAACf,OAAO,EAAE,EAAE,CAAC;EAEtE,MAAMkB,OAAO,GAAGtB,KAAK,CAACuB,OAAO,CAC3B,OAAO;IACLb,KAAK,EAAEhB,UAAU;IACjBC,QAAQ,EAAEc,eAAe;IACzBb,QAAQ,EAAEoB,eAAe;IACzBd,MAAM;IACNM,MAAM;IACNa,YAAY;IACZhB;EACF,CAAC,CAAC,EACF,CACEX,UAAU,EACVe,eAAe,EACfO,eAAe,EACfd,MAAM,EACNM,MAAM,EACNa,YAAY,EACZhB,gBAAgB,CACjB,CACF;EAED,MAAMmB,eAAe,GAAGjC,MAAM,CAACkC,YAAY,GACvClC,MAAM,CAACkC,YAAY,EAAE,GACrBlC,MAAM,CAACmC,SAAS;EAEpB,oBACE,oBAAC,+BAAsB,CAAC,QAAQ;IAAC,KAAK,EAAEJ;EAAQ,gBAC9C,oBAAC,8BAAqB,qBACpB,oBAAC,wBAAe;IACd,IAAI,EAAE/B,MAAM,CAACoC,IAAK;IAClB,MAAM,EAAEH,eAAe,IAAIjC,MAAM,CAACqC,QAAS;IAC3C,UAAU,EAAEnC,UAAW;IACvB,KAAK,EAAED;EAAM,GAEZgC,eAAe,KAAKT,SAAS,gBAC5B,oBAAC,eAAe;IAAC,UAAU,EAAEtB,UAAW;IAAC,KAAK,EAAED;EAAM,EAAG,GACvDD,MAAM,CAACqC,QAAQ,KAAKb,SAAS,GAC/BxB,MAAM,CAACqC,QAAQ,CAAC;IAAEnC,UAAU;IAAED;EAAM,CAAC,CAAC,GACpC,IAAI,CACQ,CACI,CACQ;AAEtC"}

View File

@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = Screen;
/**
* Empty component used for specifying route configuration.
*/
function Screen(_) {
/* istanbul ignore next */
return null;
}
//# sourceMappingURL=Screen.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["Screen","_"],"sourceRoot":"../../src","sources":["Screen.tsx"],"mappings":";;;;;;AAIA;AACA;AACA;AACe,SAASA,MAAM,CAM5BC,CAAoE,EAAE;EACtE;EACA,OAAO,IAAI;AACb"}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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; }
/**
* Component which prevents updates for children if no props changed
*/
function StaticContainer(props) {
return props.children;
}
var _default = /*#__PURE__*/React.memo(StaticContainer, (prevProps, nextProps) => {
const prevPropKeys = Object.keys(prevProps);
const nextPropKeys = Object.keys(nextProps);
if (prevPropKeys.length !== nextPropKeys.length) {
return false;
}
for (const key of prevPropKeys) {
if (key === 'children') {
continue;
}
if (prevProps[key] !== nextProps[key]) {
return false;
}
}
return true;
});
exports.default = _default;
//# sourceMappingURL=StaticContainer.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["StaticContainer","props","children","React","memo","prevProps","nextProps","prevPropKeys","Object","keys","nextPropKeys","length","key"],"sourceRoot":"../../src","sources":["StaticContainer.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAE/B;AACA;AACA;AACA,SAASA,eAAe,CAACC,KAAU,EAAE;EACnC,OAAOA,KAAK,CAACC,QAAQ;AACvB;AAAC,4BAEcC,KAAK,CAACC,IAAI,CAACJ,eAAe,EAAE,CAACK,SAAc,EAAEC,SAAc,KAAK;EAC7E,MAAMC,YAAY,GAAGC,MAAM,CAACC,IAAI,CAACJ,SAAS,CAAC;EAC3C,MAAMK,YAAY,GAAGF,MAAM,CAACC,IAAI,CAACH,SAAS,CAAC;EAE3C,IAAIC,YAAY,CAACI,MAAM,KAAKD,YAAY,CAACC,MAAM,EAAE;IAC/C,OAAO,KAAK;EACd;EAEA,KAAK,MAAMC,GAAG,IAAIL,YAAY,EAAE;IAC9B,IAAIK,GAAG,KAAK,UAAU,EAAE;MACtB;IACF;IAEA,IAAIP,SAAS,CAACO,GAAG,CAAC,KAAKN,SAAS,CAACM,GAAG,CAAC,EAAE;MACrC,OAAO,KAAK;IACd;EACF;EAEA,OAAO,IAAI;AACb,CAAC,CAAC;AAAA"}

View File

@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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 UnhandledActionContext = /*#__PURE__*/React.createContext(undefined);
var _default = UnhandledActionContext;
exports.default = _default;
//# sourceMappingURL=UnhandledActionContext.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["UnhandledActionContext","React","createContext","undefined"],"sourceRoot":"../../src","sources":["UnhandledActionContext.tsx"],"mappings":";;;;;;AACA;AAA+B;AAAA;AAE/B,MAAMA,sBAAsB,gBAAGC,KAAK,CAACC,aAAa,CAEhDC,SAAS,CAAC;AAAC,eAEEH,sBAAsB;AAAA"}

View File

@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = checkDuplicateRouteNames;
function checkDuplicateRouteNames(state) {
const duplicates = [];
const getRouteNames = (location, state) => {
state.routes.forEach(route => {
var _route$state, _route$state$routeNam;
const currentLocation = location ? `${location} > ${route.name}` : route.name;
(_route$state = route.state) === null || _route$state === void 0 ? void 0 : (_route$state$routeNam = _route$state.routeNames) === null || _route$state$routeNam === void 0 ? void 0 : _route$state$routeNam.forEach(routeName => {
if (routeName === route.name) {
duplicates.push([currentLocation, `${currentLocation} > ${route.name}`]);
}
});
if (route.state) {
getRouteNames(currentLocation, route.state);
}
});
};
getRouteNames('', state);
return duplicates;
}
//# sourceMappingURL=checkDuplicateRouteNames.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["checkDuplicateRouteNames","state","duplicates","getRouteNames","location","routes","forEach","route","currentLocation","name","routeNames","routeName","push"],"sourceRoot":"../../src","sources":["checkDuplicateRouteNames.tsx"],"mappings":";;;;;;AAEe,SAASA,wBAAwB,CAACC,KAAsB,EAAE;EACvE,MAAMC,UAAsB,GAAG,EAAE;EAEjC,MAAMC,aAAa,GAAG,CACpBC,QAAgB,EAChBH,KAAsD,KACnD;IACHA,KAAK,CAACI,MAAM,CAACC,OAAO,CAAEC,KAA+B,IAAK;MAAA;MACxD,MAAMC,eAAe,GAAGJ,QAAQ,GAC3B,GAAEA,QAAS,MAAKG,KAAK,CAACE,IAAK,EAAC,GAC7BF,KAAK,CAACE,IAAI;MAEd,gBAAAF,KAAK,CAACN,KAAK,0EAAX,aAAaS,UAAU,0DAAvB,sBAAyBJ,OAAO,CAAEK,SAAS,IAAK;QAC9C,IAAIA,SAAS,KAAKJ,KAAK,CAACE,IAAI,EAAE;UAC5BP,UAAU,CAACU,IAAI,CAAC,CACdJ,eAAe,EACd,GAAEA,eAAgB,MAAKD,KAAK,CAACE,IAAK,EAAC,CACrC,CAAC;QACJ;MACF,CAAC,CAAC;MAEF,IAAIF,KAAK,CAACN,KAAK,EAAE;QACfE,aAAa,CAACK,eAAe,EAAED,KAAK,CAACN,KAAK,CAAC;MAC7C;IACF,CAAC,CAAC;EACJ,CAAC;EAEDE,aAAa,CAAC,EAAE,EAAEF,KAAK,CAAC;EAExB,OAAOC,UAAU;AACnB"}

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = checkSerializable;
const checkSerializableWithoutCircularReference = (o, seen, location) => {
if (o === undefined || o === null || typeof o === 'boolean' || typeof o === 'number' || typeof o === 'string') {
return {
serializable: true
};
}
if (Object.prototype.toString.call(o) !== '[object Object]' && !Array.isArray(o)) {
return {
serializable: false,
location,
reason: typeof o === 'function' ? 'Function' : String(o)
};
}
if (seen.has(o)) {
return {
serializable: false,
reason: 'Circular reference',
location
};
}
seen.add(o);
if (Array.isArray(o)) {
for (let i = 0; i < o.length; i++) {
const childResult = checkSerializableWithoutCircularReference(o[i], new Set(seen), [...location, i]);
if (!childResult.serializable) {
return childResult;
}
}
} else {
for (const key in o) {
const childResult = checkSerializableWithoutCircularReference(o[key], new Set(seen), [...location, key]);
if (!childResult.serializable) {
return childResult;
}
}
}
return {
serializable: true
};
};
function checkSerializable(o) {
return checkSerializableWithoutCircularReference(o, new Set(), []);
}
//# sourceMappingURL=checkSerializable.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["checkSerializableWithoutCircularReference","o","seen","location","undefined","serializable","Object","prototype","toString","call","Array","isArray","reason","String","has","add","i","length","childResult","Set","key","checkSerializable"],"sourceRoot":"../../src","sources":["checkSerializable.tsx"],"mappings":";;;;;;AAAA,MAAMA,yCAAyC,GAAG,CAChDC,CAAyB,EACzBC,IAAc,EACdC,QAA6B,KAOtB;EACP,IACEF,CAAC,KAAKG,SAAS,IACfH,CAAC,KAAK,IAAI,IACV,OAAOA,CAAC,KAAK,SAAS,IACtB,OAAOA,CAAC,KAAK,QAAQ,IACrB,OAAOA,CAAC,KAAK,QAAQ,EACrB;IACA,OAAO;MAAEI,YAAY,EAAE;IAAK,CAAC;EAC/B;EAEA,IACEC,MAAM,CAACC,SAAS,CAACC,QAAQ,CAACC,IAAI,CAACR,CAAC,CAAC,KAAK,iBAAiB,IACvD,CAACS,KAAK,CAACC,OAAO,CAACV,CAAC,CAAC,EACjB;IACA,OAAO;MACLI,YAAY,EAAE,KAAK;MACnBF,QAAQ;MACRS,MAAM,EAAE,OAAOX,CAAC,KAAK,UAAU,GAAG,UAAU,GAAGY,MAAM,CAACZ,CAAC;IACzD,CAAC;EACH;EAEA,IAAIC,IAAI,CAACY,GAAG,CAACb,CAAC,CAAC,EAAE;IACf,OAAO;MACLI,YAAY,EAAE,KAAK;MACnBO,MAAM,EAAE,oBAAoB;MAC5BT;IACF,CAAC;EACH;EAEAD,IAAI,CAACa,GAAG,CAACd,CAAC,CAAC;EAEX,IAAIS,KAAK,CAACC,OAAO,CAACV,CAAC,CAAC,EAAE;IACpB,KAAK,IAAIe,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGf,CAAC,CAACgB,MAAM,EAAED,CAAC,EAAE,EAAE;MACjC,MAAME,WAAW,GAAGlB,yCAAyC,CAC3DC,CAAC,CAACe,CAAC,CAAC,EACJ,IAAIG,GAAG,CAAMjB,IAAI,CAAC,EAClB,CAAC,GAAGC,QAAQ,EAAEa,CAAC,CAAC,CACjB;MAED,IAAI,CAACE,WAAW,CAACb,YAAY,EAAE;QAC7B,OAAOa,WAAW;MACpB;IACF;EACF,CAAC,MAAM;IACL,KAAK,MAAME,GAAG,IAAInB,CAAC,EAAE;MACnB,MAAMiB,WAAW,GAAGlB,yCAAyC,CAC3DC,CAAC,CAACmB,GAAG,CAAC,EACN,IAAID,GAAG,CAAMjB,IAAI,CAAC,EAClB,CAAC,GAAGC,QAAQ,EAAEiB,GAAG,CAAC,CACnB;MAED,IAAI,CAACF,WAAW,CAACb,YAAY,EAAE;QAC7B,OAAOa,WAAW;MACpB;IACF;EACF;EAEA,OAAO;IAAEb,YAAY,EAAE;EAAK,CAAC;AAC/B,CAAC;AAEc,SAASgB,iBAAiB,CAACpB,CAAyB,EAAE;EACnE,OAAOD,yCAAyC,CAACC,CAAC,EAAE,IAAIkB,GAAG,EAAO,EAAE,EAAE,CAAC;AACzE"}

View File

@@ -0,0 +1,74 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.NOT_INITIALIZED_ERROR = void 0;
exports.default = createNavigationContainerRef;
var _routers = require("@react-navigation/routers");
const NOT_INITIALIZED_ERROR = "The 'navigation' object hasn't been initialized yet. This might happen if you don't have a navigator mounted, or if the navigator hasn't finished mounting. See https://reactnavigation.org/docs/navigating-without-navigation-prop#handling-initialization for more details.";
exports.NOT_INITIALIZED_ERROR = NOT_INITIALIZED_ERROR;
function createNavigationContainerRef() {
const methods = [...Object.keys(_routers.CommonActions), 'addListener', 'removeListener', 'resetRoot', 'dispatch', 'isFocused', 'canGoBack', 'getRootState', 'getState', 'getParent', 'getCurrentRoute', 'getCurrentOptions'];
const listeners = {};
const removeListener = (event, callback) => {
if (listeners[event]) {
listeners[event] = listeners[event].filter(cb => cb !== callback);
}
};
let current = null;
const ref = {
get current() {
return current;
},
set current(value) {
current = value;
if (value != null) {
Object.entries(listeners).forEach(_ref => {
let [event, callbacks] = _ref;
callbacks.forEach(callback => {
value.addListener(event, callback);
});
});
}
},
isReady: () => {
if (current == null) {
return false;
}
return current.isReady();
},
...methods.reduce((acc, name) => {
acc[name] = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
if (current == null) {
switch (name) {
case 'addListener':
{
const [event, callback] = args;
listeners[event] = listeners[event] || [];
listeners[event].push(callback);
return () => removeListener(event, callback);
}
case 'removeListener':
{
const [event, callback] = args;
removeListener(event, callback);
break;
}
default:
console.error(NOT_INITIALIZED_ERROR);
}
} else {
// @ts-expect-error: this is ok
return current[name](...args);
}
};
return acc;
}, {})
};
return ref;
}
//# sourceMappingURL=createNavigationContainerRef.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NOT_INITIALIZED_ERROR","createNavigationContainerRef","methods","Object","keys","CommonActions","listeners","removeListener","event","callback","filter","cb","current","ref","value","entries","forEach","callbacks","addListener","isReady","reduce","acc","name","args","push","console","error"],"sourceRoot":"../../src","sources":["createNavigationContainerRef.tsx"],"mappings":";;;;;;;AAAA;AAQO,MAAMA,qBAAqB,GAChC,+QAA+Q;AAAC;AAEnQ,SAASC,4BAA4B,GAEF;EAChD,MAAMC,OAAO,GAAG,CACd,GAAGC,MAAM,CAACC,IAAI,CAACC,sBAAa,CAAC,EAC7B,aAAa,EACb,gBAAgB,EAChB,WAAW,EACX,UAAU,EACV,WAAW,EACX,WAAW,EACX,cAAc,EACd,UAAU,EACV,WAAW,EACX,iBAAiB,EACjB,mBAAmB,CACX;EAEV,MAAMC,SAAuD,GAAG,CAAC,CAAC;EAElE,MAAMC,cAAc,GAAG,CACrBC,KAAa,EACbC,QAAkC,KAC/B;IACH,IAAIH,SAAS,CAACE,KAAK,CAAC,EAAE;MACpBF,SAAS,CAACE,KAAK,CAAC,GAAGF,SAAS,CAACE,KAAK,CAAC,CAAC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AACD,KAAK,EAAEC,QAAQ,CAAC,GAAGc,IAAI;gBAE9BhB,cAAc,CAACC,KAAK,EAAEC,QAAQ,CAAC;gBAC/B;cACF;YACA;cACEgB,OAAO,CAACC,KAAK,CAAC1B,qBAAqB,CAAC;UAAC;QAE3C,CAAC,MAAM;UACL;UACA,OAAOY,OAAO,CAACU,IAAI,CAAC,CAAC,GAAGC,IAAI,CAAC;QAC/B;MACF,CAAC;MACD,OAAOF,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC;EACP,CAAC;EAED,OAAOR,GAAG;AACZ"}

View File

@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = createNavigatorFactory;
var _Group = _interopRequireDefault(require("./Group"));
var _Screen = _interopRequireDefault(require("./Screen"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Higher order component to create a `Navigator` and `Screen` pair.
* Custom navigators should wrap the navigator component in `createNavigator` before exporting.
*
* @param Navigator The navigtor component to wrap.
* @returns Factory method to create a `Navigator` and `Screen` pair.
*/
function createNavigatorFactory(Navigator) {
return function () {
if (arguments[0] !== undefined) {
throw new Error("Creating a navigator doesn't take an argument. Maybe you are trying to use React Navigation 4 API? See https://reactnavigation.org/docs/hello-react-navigation for the latest API and guides.");
}
return {
Navigator,
Group: _Group.default,
Screen: _Screen.default
};
};
}
//# sourceMappingURL=createNavigatorFactory.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["createNavigatorFactory","Navigator","arguments","undefined","Error","Group","Screen"],"sourceRoot":"../../src","sources":["createNavigatorFactory.tsx"],"mappings":";;;;;;AAGA;AACA;AAA8B;AAG9B;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,sBAAsB,CAK5CC,SAA6B,EAAE;EAC/B,OAAO,YAML;IACA,IAAIC,SAAS,CAAC,CAAC,CAAC,KAAKC,SAAS,EAAE;MAC9B,MAAM,IAAIC,KAAK,CACb,+LAA+L,CAChM;IACH;IAEA,OAAO;MACLH,SAAS;MACTI,KAAK,EAALA,cAAK;MACLC,MAAM,EAANA;IACF,CAAC;EACH,CAAC;AACH"}

View File

@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findFocusedRoute;
function findFocusedRoute(state) {
var _current2, _current3;
let current = state;
while (((_current = current) === null || _current === void 0 ? void 0 : _current.routes[current.index ?? 0].state) != null) {
var _current;
current = current.routes[current.index ?? 0].state;
}
const route = (_current2 = current) === null || _current2 === void 0 ? void 0 : _current2.routes[((_current3 = current) === null || _current3 === void 0 ? void 0 : _current3.index) ?? 0];
return route;
}
//# sourceMappingURL=findFocusedRoute.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["findFocusedRoute","state","current","routes","index","route"],"sourceRoot":"../../src","sources":["findFocusedRoute.tsx"],"mappings":";;;;;;AAEe,SAASA,gBAAgB,CAACC,KAAmB,EAAE;EAAA;EAC5D,IAAIC,OAAiC,GAAGD,KAAK;EAE7C,OAAO,aAAAC,OAAO,6CAAP,SAASC,MAAM,CAACD,OAAO,CAACE,KAAK,IAAI,CAAC,CAAC,CAACH,KAAK,KAAI,IAAI,EAAE;IAAA;IACxDC,OAAO,GAAGA,OAAO,CAACC,MAAM,CAACD,OAAO,CAACE,KAAK,IAAI,CAAC,CAAC,CAACH,KAAK;EACpD;EAEA,MAAMI,KAAK,gBAAGH,OAAO,8CAAP,UAASC,MAAM,CAAC,cAAAD,OAAO,8CAAP,UAASE,KAAK,KAAI,CAAC,CAAC;EAElD,OAAOC,KAAK;AACd"}

View File

@@ -0,0 +1,18 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = fromEntries;
// Object.fromEntries is not available in older iOS versions
function fromEntries(entries) {
return entries.reduce((acc, _ref) => {
let [k, v] = _ref;
if (acc.hasOwnProperty(k)) {
throw new Error(`A value for key '${k}' already exists in the object.`);
}
acc[k] = v;
return acc;
}, {});
}
//# sourceMappingURL=fromEntries.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["fromEntries","entries","reduce","acc","k","v","hasOwnProperty","Error"],"sourceRoot":"../../src","sources":["fromEntries.tsx"],"mappings":";;;;;;AAAA;AACe,SAASA,WAAW,CACjCC,OAA4B,EAC5B;EACA,OAAOA,OAAO,CAACC,MAAM,CAAC,CAACC,GAAG,WAAa;IAAA,IAAX,CAACC,CAAC,EAAEC,CAAC,CAAC;IAChC,IAAIF,GAAG,CAACG,cAAc,CAACF,CAAC,CAAC,EAAE;MACzB,MAAM,IAAIG,KAAK,CAAE,oBAAmBH,CAAE,iCAAgC,CAAC;IACzE;IAEAD,GAAG,CAACC,CAAC,CAAC,GAAGC,CAAC;IACV,OAAOF,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAiB;AACxB"}

View File

@@ -0,0 +1,89 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getActionFromState;
function getActionFromState(state, options) {
var _normalizedConfig$scr;
// Create a normalized configs object which will be easier to use
const normalizedConfig = options ? createNormalizedConfigItem(options) : {};
const routes = state.index != null ? state.routes.slice(0, state.index + 1) : state.routes;
if (routes.length === 0) {
return undefined;
}
if (!(routes.length === 1 && routes[0].key === undefined || routes.length === 2 && routes[0].key === undefined && routes[0].name === (normalizedConfig === null || normalizedConfig === void 0 ? void 0 : normalizedConfig.initialRouteName) && routes[1].key === undefined)) {
return {
type: 'RESET',
payload: state
};
}
const route = state.routes[state.index ?? state.routes.length - 1];
let current = route === null || route === void 0 ? void 0 : route.state;
let config = normalizedConfig === null || normalizedConfig === void 0 ? void 0 : (_normalizedConfig$scr = normalizedConfig.screens) === null || _normalizedConfig$scr === void 0 ? void 0 : _normalizedConfig$scr[route === null || route === void 0 ? void 0 : route.name];
let params = {
...route.params
};
let payload = route ? {
name: route.name,
path: route.path,
params
} : undefined;
while (current) {
var _config, _config2, _config2$screens;
if (current.routes.length === 0) {
return undefined;
}
const routes = current.index != null ? current.routes.slice(0, current.index + 1) : current.routes;
const route = routes[routes.length - 1];
// Explicitly set to override existing value when merging params
Object.assign(params, {
initial: undefined,
screen: undefined,
params: undefined,
state: undefined
});
if (routes.length === 1 && routes[0].key === undefined) {
params.initial = true;
params.screen = route.name;
} else if (routes.length === 2 && routes[0].key === undefined && routes[0].name === ((_config = config) === null || _config === void 0 ? void 0 : _config.initialRouteName) && routes[1].key === undefined) {
params.initial = false;
params.screen = route.name;
} else {
params.state = current;
break;
}
if (route.state) {
params.params = {
...route.params
};
params = params.params;
} else {
params.path = route.path;
params.params = route.params;
}
current = route.state;
config = (_config2 = config) === null || _config2 === void 0 ? void 0 : (_config2$screens = _config2.screens) === null || _config2$screens === void 0 ? void 0 : _config2$screens[route.name];
}
if (!payload) {
return;
}
// Try to construct payload for a `NAVIGATE` action from the state
// This lets us preserve the navigation state and not lose it
return {
type: 'NAVIGATE',
payload
};
}
const createNormalizedConfigItem = config => typeof config === 'object' && config != null ? {
initialRouteName: config.initialRouteName,
screens: config.screens != null ? createNormalizedConfigs(config.screens) : undefined
} : {};
const createNormalizedConfigs = options => Object.entries(options).reduce((acc, _ref) => {
let [k, v] = _ref;
acc[k] = createNormalizedConfigItem(v);
return acc;
}, {});
//# sourceMappingURL=getActionFromState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getActionFromState","state","options","normalizedConfig","createNormalizedConfigItem","routes","index","slice","length","undefined","key","name","initialRouteName","type","payload","route","current","config","screens","params","path","Object","assign","initial","screen","createNormalizedConfigs","entries","reduce","acc","k","v"],"sourceRoot":"../../src","sources":["getActionFromState.tsx"],"mappings":";;;;;;AA8Be,SAASA,kBAAkB,CACxCC,KAAoC,EACpCC,OAAiB,EACmD;EAAA;EACpE;EACA,MAAMC,gBAAgB,GAAGD,OAAO,GAC5BE,0BAA0B,CAACF,OAAO,CAAgC,GAClE,CAAC,CAAC;EAEN,MAAMG,MAAM,GACVJ,KAAK,CAACK,KAAK,IAAI,IAAI,GAAGL,KAAK,CAACI,MAAM,CAACE,KAAK,CAAC,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;IACH,CAAC,MAAM;MACLA,MAAM,CAACC,IAAI,GAAGL,KAAK,CAACK,IAAI;MACxBD,MAAM,CAACA,MAAM,GAAGJ,KAAK,CAACI,MAAM;IAC9B;IAEAH,OAAO,GAAGD,KAAK,CAACd,KAAK;IACrBgB,MAAM,eAAGA,MAAM,iEAAN,SAAQC,OAAO,qDAAf,iBAAkBH,KAAK,CAACJ,IAAI,CAAC;EACxC;EAEA,IAAI,CAACG,OAAO,EAAE;IACZ;EACF;;EAEA;EACA;EACA,OAAO;IACLD,IAAI,EAAE,UAAU;IAChBC;EACF,CAAC;AACH;AAEA,MAAMV,0BAA0B,GAAIa,MAAmC,IACrE,OAAOA,MAAM,KAAK,QAAQ,IAAIA,MAAM,IAAI,IAAI,GACxC;EACEL,gBAAgB,EAAEK,MAAM,CAACL,gBAAgB;EACzCM,OAAO,EACLD,MAAM,CAACC,OAAO,IAAI,IAAI,GAClBO,uBAAuB,CAACR,MAAM,CAACC,OAAO,CAAC,GACvCT;AACR,CAAC,GACD,CAAC,CAAC;AAER,MAAMgB,uBAAuB,GAAIvB,OAA8B,IAC7DmB,MAAM,CAACK,OAAO,CAACxB,OAAO,CAAC,CAACyB,MAAM,CAA6B,CAACC,GAAG,WAAa;EAAA,IAAX,CAACC,CAAC,EAAEC,CAAC,CAAC;EACrEF,GAAG,CAACC,CAAC,CAAC,GAAGzB,0BAA0B,CAAC0B,CAAC,CAAC;EACtC,OAAOF,GAAG;AACZ,CAAC,EAAE,CAAC,CAAC,CAAC"}

View File

@@ -0,0 +1,22 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getFocusedRouteNameFromRoute;
var _useRouteCache = require("./useRouteCache");
function getFocusedRouteNameFromRoute(route) {
// @ts-expect-error: this isn't in type definitions coz we want this private
const state = route[_useRouteCache.CHILD_STATE] ?? route.state;
const params = route.params;
const routeName = state ?
// Get the currently active route name in the nested navigator
state.routes[
// If we have a partial state without index, for tab/drawer, first screen will be focused one, and last for stack
// The type property will only exist for rehydrated state and not for state from deep link
state.index ?? (typeof state.type === 'string' && state.type !== 'stack' ? 0 : state.routes.length - 1)].name :
// If state doesn't exist, we need to default to `screen` param if available
typeof (params === null || params === void 0 ? void 0 : params.screen) === 'string' ? params.screen : undefined;
return routeName;
}
//# sourceMappingURL=getFocusedRouteNameFromRoute.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["getFocusedRouteNameFromRoute","route","state","CHILD_STATE","params","routeName","routes","index","type","length","name","screen","undefined"],"sourceRoot":"../../src","sources":["getFocusedRouteNameFromRoute.tsx"],"mappings":";;;;;;AAEA;AAEe,SAASA,4BAA4B,CAClDC,KAA6B,EACT;EACpB;EACA,MAAMC,KAAK,GAAGD,KAAK,CAACE,0BAAW,CAAC,IAAIF,KAAK,CAACC,KAAK;EAC/C,MAAME,MAAM,GAAGH,KAAK,CAACG,MAA0C;EAE/D,MAAMC,SAAS,GAAGH,KAAK;EACnB;EACAA,KAAK,CAACI,MAAM;EACV;EACA;EACAJ,KAAK,CAACK,KAAK,KACR,OAAOL,KAAK,CAACM,IAAI,KAAK,QAAQ,IAAIN,KAAK,CAACM,IAAI,KAAK,OAAO,GACrD,CAAC,GACDN,KAAK,CAACI,MAAM,CAACG,MAAM,GAAG,CAAC,CAAC,CAC/B,CAACC,IAAI;EACN;EACF,QAAON,MAAM,aAANA,MAAM,uBAANA,MAAM,CAAEO,MAAM,MAAK,QAAQ,GAChCP,MAAM,CAACO,MAAM,GACbC,SAAS;EAEb,OAAOP,SAAS;AAClB"}

View File

@@ -0,0 +1,218 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getPathFromState;
var queryString = _interopRequireWildcard(require("query-string"));
var _fromEntries = _interopRequireDefault(require("./fromEntries"));
var _validatePathConfig = _interopRequireDefault(require("./validatePathConfig"));
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 getActiveRoute = state => {
const route = typeof state.index === 'number' ? state.routes[state.index] : state.routes[state.routes.length - 1];
if (route.state) {
return getActiveRoute(route.state);
}
return route;
};
/**
* Utility to serialize a navigation state object to a path string.
*
* @example
* ```js
* getPathFromState(
* {
* routes: [
* {
* name: 'Chat',
* params: { author: 'Jane', id: 42 },
* },
* ],
* },
* {
* screens: {
* Chat: {
* path: 'chat/:author/:id',
* stringify: { author: author => author.toLowerCase() }
* }
* }
* }
* )
* ```
*
* @param state Navigation state to serialize.
* @param options Extra options to fine-tune how to serialize the path.
* @returns Path representing the state, e.g. /foo/bar?count=42.
*/
function getPathFromState(state, options) {
if (state == null) {
throw Error("Got 'undefined' for the navigation state. You must pass a valid state object.");
}
if (options) {
(0, _validatePathConfig.default)(options);
}
// Create a normalized configs object which will be easier to use
const configs = options !== null && options !== void 0 && options.screens ? createNormalizedConfigs(options === null || options === void 0 ? void 0 : options.screens) : {};
let path = '/';
let current = state;
const allParams = {};
while (current) {
let index = typeof current.index === 'number' ? current.index : 0;
let route = current.routes[index];
let pattern;
let focusedParams;
let focusedRoute = getActiveRoute(state);
let currentOptions = configs;
// Keep all the route names that appeared during going deeper in config in case the pattern is resolved to undefined
let nestedRouteNames = [];
let hasNext = true;
while (route.name in currentOptions && hasNext) {
pattern = currentOptions[route.name].pattern;
nestedRouteNames.push(route.name);
if (route.params) {
var _currentOptions$route;
const stringify = (_currentOptions$route = currentOptions[route.name]) === null || _currentOptions$route === void 0 ? void 0 : _currentOptions$route.stringify;
const currentParams = (0, _fromEntries.default)(Object.entries(route.params).map(_ref => {
let [key, value] = _ref;
return [key, stringify !== null && stringify !== void 0 && stringify[key] ? stringify[key](value) : String(value)];
}));
if (pattern) {
Object.assign(allParams, currentParams);
}
if (focusedRoute === route) {
var _pattern;
// If this is the focused route, keep the params for later use
// We save it here since it's been stringified already
focusedParams = {
...currentParams
};
(_pattern = pattern) === null || _pattern === void 0 ? void 0 : _pattern.split('/').filter(p => p.startsWith(':'))
// eslint-disable-next-line no-loop-func
.forEach(p => {
const name = getParamName(p);
// Remove the params present in the pattern since we'll only use the rest for query string
if (focusedParams) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete focusedParams[name];
}
});
}
}
// If there is no `screens` property or no nested state, we return pattern
if (!currentOptions[route.name].screens || route.state === undefined) {
hasNext = false;
} else {
index = typeof route.state.index === 'number' ? route.state.index : route.state.routes.length - 1;
const nextRoute = route.state.routes[index];
const nestedConfig = currentOptions[route.name].screens;
// if there is config for next route name, we go deeper
if (nestedConfig && nextRoute.name in nestedConfig) {
route = nextRoute;
currentOptions = nestedConfig;
} else {
// If not, there is no sense in going deeper in config
hasNext = false;
}
}
}
if (pattern === undefined) {
pattern = nestedRouteNames.join('/');
}
if (currentOptions[route.name] !== undefined) {
path += pattern.split('/').map(p => {
const name = getParamName(p);
// We don't know what to show for wildcard patterns
// Showing the route name seems ok, though whatever we show here will be incorrect
// Since the page doesn't actually exist
if (p === '*') {
return route.name;
}
// If the path has a pattern for a param, put the param in the path
if (p.startsWith(':')) {
const value = allParams[name];
if (value === undefined && p.endsWith('?')) {
// Optional params without value assigned in route.params should be ignored
return '';
}
return encodeURIComponent(value);
}
return encodeURIComponent(p);
}).join('/');
} else {
path += encodeURIComponent(route.name);
}
if (!focusedParams) {
focusedParams = focusedRoute.params;
}
if (route.state) {
path += '/';
} else if (focusedParams) {
for (let param in focusedParams) {
if (focusedParams[param] === 'undefined') {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete focusedParams[param];
}
}
const query = queryString.stringify(focusedParams, {
sort: false
});
if (query) {
path += `?${query}`;
}
}
current = route.state;
}
// Remove multiple as well as trailing slashes
path = path.replace(/\/+/g, '/');
path = path.length > 1 ? path.replace(/\/$/, '') : path;
return path;
}
const getParamName = pattern => pattern.replace(/^:/, '').replace(/\?$/, '');
const joinPaths = function () {
for (var _len = arguments.length, paths = new Array(_len), _key = 0; _key < _len; _key++) {
paths[_key] = arguments[_key];
}
return [].concat(...paths.map(p => p.split('/'))).filter(Boolean).join('/');
};
const createConfigItem = (config, parentPattern) => {
var _pattern2;
if (typeof config === 'string') {
// If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern
const pattern = parentPattern ? joinPaths(parentPattern, config) : config;
return {
pattern
};
}
// If an object is specified as the value (e.g. Foo: { ... }),
// It can have `path` property and `screens` prop which has nested configs
let pattern;
if (config.exact && config.path === undefined) {
throw new Error("A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.");
}
pattern = config.exact !== true ? joinPaths(parentPattern || '', config.path || '') : config.path || '';
const screens = config.screens ? createNormalizedConfigs(config.screens, pattern) : undefined;
return {
// Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.
pattern: (_pattern2 = pattern) === null || _pattern2 === void 0 ? void 0 : _pattern2.split('/').filter(Boolean).join('/'),
stringify: config.stringify,
screens
};
};
const createNormalizedConfigs = (options, pattern) => (0, _fromEntries.default)(Object.entries(options).map(_ref2 => {
let [name, c] = _ref2;
const result = createConfigItem(c, pattern);
return [name, result];
}));
//# sourceMappingURL=getPathFromState.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,441 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = getStateFromPath;
var _escapeStringRegexp = _interopRequireDefault(require("escape-string-regexp"));
var queryString = _interopRequireWildcard(require("query-string"));
var _findFocusedRoute = _interopRequireDefault(require("./findFocusedRoute"));
var _validatePathConfig = _interopRequireDefault(require("./validatePathConfig"));
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 }; }
/**
* Utility to parse a path string to initial state object accepted by the container.
* This is useful for deep linking when we need to handle the incoming URL.
*
* @example
* ```js
* getStateFromPath(
* '/chat/jane/42',
* {
* screens: {
* Chat: {
* path: 'chat/:author/:id',
* parse: { id: Number }
* }
* }
* }
* )
* ```
* @param path Path string to parse and convert, e.g. /foo/bar?count=42.
* @param options Extra options to fine-tune how to parse the path.
*/
function getStateFromPath(path, options) {
if (options) {
(0, _validatePathConfig.default)(options);
}
let initialRoutes = [];
if (options !== null && options !== void 0 && options.initialRouteName) {
initialRoutes.push({
initialRouteName: options.initialRouteName,
parentScreens: []
});
}
const screens = options === null || options === void 0 ? void 0 : options.screens;
let remaining = path.replace(/\/+/g, '/') // Replace multiple slash (//) with single ones
.replace(/^\//, '') // Remove extra leading slash
.replace(/\?.*$/, ''); // Remove query params which we will handle later
// Make sure there is a trailing slash
remaining = remaining.endsWith('/') ? remaining : `${remaining}/`;
if (screens === undefined) {
// When no config is specified, use the path segments as route names
const routes = remaining.split('/').filter(Boolean).map(segment => {
const name = decodeURIComponent(segment);
return {
name
};
});
if (routes.length) {
return createNestedStateObject(path, routes, initialRoutes);
}
return undefined;
}
// Create a normalized configs array which will be easier to use
const configs = [].concat(...Object.keys(screens).map(key => createNormalizedConfigs(key, screens, [], initialRoutes, []))).sort((a, b) => {
// Sort config so that:
// - the most exhaustive ones are always at the beginning
// - patterns with wildcard are always at the end
// If 2 patterns are same, move the one with less route names up
// This is an error state, so it's only useful for consistent error messages
if (a.pattern === b.pattern) {
return b.routeNames.join('>').localeCompare(a.routeNames.join('>'));
}
// If one of the patterns starts with the other, it's more exhaustive
// So move it up
if (a.pattern.startsWith(b.pattern)) {
return -1;
}
if (b.pattern.startsWith(a.pattern)) {
return 1;
}
const aParts = a.pattern.split('/');
const bParts = b.pattern.split('/');
for (let i = 0; i < Math.max(aParts.length, bParts.length); i++) {
// if b is longer, b get higher priority
if (aParts[i] == null) {
return 1;
}
// if a is longer, a get higher priority
if (bParts[i] == null) {
return -1;
}
const aWildCard = aParts[i] === '*' || aParts[i].startsWith(':');
const bWildCard = bParts[i] === '*' || bParts[i].startsWith(':');
// if both are wildcard we compare next component
if (aWildCard && bWildCard) {
continue;
}
// if only a is wild card, b get higher priority
if (aWildCard) {
return 1;
}
// if only b is wild card, a get higher priority
if (bWildCard) {
return -1;
}
}
return bParts.length - aParts.length;
});
// Check for duplicate patterns in the config
configs.reduce((acc, config) => {
if (acc[config.pattern]) {
const a = acc[config.pattern].routeNames;
const b = config.routeNames;
// It's not a problem if the path string omitted from a inner most screen
// For example, it's ok if a path resolves to `A > B > C` or `A > B`
const intersects = a.length > b.length ? b.every((it, i) => a[i] === it) : a.every((it, i) => b[i] === it);
if (!intersects) {
throw new Error(`Found conflicting screens with the same pattern. The pattern '${config.pattern}' resolves to both '${a.join(' > ')}' and '${b.join(' > ')}'. Patterns must be unique and cannot resolve to more than one screen.`);
}
}
return Object.assign(acc, {
[config.pattern]: config
});
}, {});
if (remaining === '/') {
// We need to add special handling of empty path so navigation to empty path also works
// When handling empty path, we should only look at the root level config
const match = configs.find(config => config.path === '' && config.routeNames.every(
// Make sure that none of the parent configs have a non-empty path defined
name => {
var _configs$find;
return !((_configs$find = configs.find(c => c.screen === name)) !== null && _configs$find !== void 0 && _configs$find.path);
}));
if (match) {
return createNestedStateObject(path, match.routeNames.map(name => ({
name
})), initialRoutes, configs);
}
return undefined;
}
let result;
let current;
// We match the whole path against the regex instead of segments
// This makes sure matches such as wildcard will catch any unmatched routes, even if nested
const {
routes,
remainingPath
} = matchAgainstConfigs(remaining, configs.map(c => ({
...c,
// Add `$` to the regex to make sure it matches till end of the path and not just beginning
regex: c.regex ? new RegExp(c.regex.source + '$') : undefined
})));
if (routes !== undefined) {
// This will always be empty if full path matched
current = createNestedStateObject(path, routes, initialRoutes, configs);
remaining = remainingPath;
result = current;
}
if (current == null || result == null) {
return undefined;
}
return result;
}
const joinPaths = function () {
for (var _len = arguments.length, paths = new Array(_len), _key = 0; _key < _len; _key++) {
paths[_key] = arguments[_key];
}
return [].concat(...paths.map(p => p.split('/'))).filter(Boolean).join('/');
};
const matchAgainstConfigs = (remaining, configs) => {
let routes;
let remainingPath = remaining;
// Go through all configs, and see if the next path segment matches our regex
for (const config of configs) {
if (!config.regex) {
continue;
}
const match = remainingPath.match(config.regex);
// If our regex matches, we need to extract params from the path
if (match) {
var _config$pattern;
const matchResult = (_config$pattern = config.pattern) === null || _config$pattern === void 0 ? void 0 : _config$pattern.split('/').reduce((acc, p, index) => {
if (!p.startsWith(':')) {
return acc;
}
// Path parameter so increment position for the segment
acc.pos += 1;
const decodedParamSegment = decodeURIComponent(
// The param segments appear every second item starting from 2 in the regex match result
match[(acc.pos + 1) * 2]
// Remove trailing slash
.replace(/\/$/, ''));
Object.assign(acc.matchedParams, {
[p]: Object.assign(acc.matchedParams[p] || {}, {
[index]: decodedParamSegment
})
});
return acc;
}, {
pos: -1,
matchedParams: {}
});
const matchedParams = matchResult.matchedParams || {};
routes = config.routeNames.map(name => {
var _routeConfig$pattern$;
const routeConfig = configs.find(c => {
// Check matching name AND pattern in case same screen is used at different levels in config
return c.screen === name && config.pattern.startsWith(c.pattern);
});
// Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.
const normalizedPath = routeConfig === null || routeConfig === void 0 ? void 0 : routeConfig.path.split('/').filter(Boolean).join('/');
// Get the number of segments in the initial pattern
const numInitialSegments = routeConfig === null || routeConfig === void 0 ? void 0 : (_routeConfig$pattern$ = routeConfig.pattern
// Extract the prefix from the pattern by removing the ending path pattern (e.g pattern=`a/b/c/d` and normalizedPath=`c/d` becomes `a/b`)
.replace(new RegExp(`${(0, _escapeStringRegexp.default)(normalizedPath)}$`), '')) === null || _routeConfig$pattern$ === void 0 ? void 0 : _routeConfig$pattern$.split('/').length;
const params = normalizedPath === null || normalizedPath === void 0 ? void 0 : normalizedPath.split('/').reduce((acc, p, index) => {
var _matchedParams$p;
if (!p.startsWith(':')) {
return acc;
}
// Get the real index of the path parameter in the matched path
// by offsetting by the number of segments in the initial pattern
const offset = numInitialSegments ? numInitialSegments - 1 : 0;
const value = (_matchedParams$p = matchedParams[p]) === null || _matchedParams$p === void 0 ? void 0 : _matchedParams$p[index + offset];
if (value) {
var _routeConfig$parse;
const key = p.replace(/^:/, '').replace(/\?$/, '');
acc[key] = routeConfig !== null && routeConfig !== void 0 && (_routeConfig$parse = routeConfig.parse) !== null && _routeConfig$parse !== void 0 && _routeConfig$parse[key] ? routeConfig.parse[key](value) : value;
}
return acc;
}, {});
if (params && Object.keys(params).length) {
return {
name,
params
};
}
return {
name
};
});
remainingPath = remainingPath.replace(match[1], '');
break;
}
}
return {
routes,
remainingPath
};
};
const createNormalizedConfigs = function (screen, routeConfig) {
let routeNames = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
let initials = arguments.length > 3 ? arguments[3] : undefined;
let parentScreens = arguments.length > 4 ? arguments[4] : undefined;
let parentPattern = arguments.length > 5 ? arguments[5] : undefined;
const configs = [];
routeNames.push(screen);
parentScreens.push(screen);
// @ts-expect-error: we can't strongly typecheck this for now
const config = routeConfig[screen];
if (typeof config === 'string') {
// If a string is specified as the value of the key(e.g. Foo: '/path'), use it as the pattern
const pattern = parentPattern ? joinPaths(parentPattern, config) : config;
configs.push(createConfigItem(screen, routeNames, pattern, config));
} else if (typeof config === 'object') {
let pattern;
// if an object is specified as the value (e.g. Foo: { ... }),
// it can have `path` property and
// it could have `screens` prop which has nested configs
if (typeof config.path === 'string') {
if (config.exact && config.path === undefined) {
throw new Error("A 'path' needs to be specified when specifying 'exact: true'. If you don't want this screen in the URL, specify it as empty string, e.g. `path: ''`.");
}
pattern = config.exact !== true ? joinPaths(parentPattern || '', config.path || '') : config.path || '';
configs.push(createConfigItem(screen, routeNames, pattern, config.path, config.parse));
}
if (config.screens) {
// property `initialRouteName` without `screens` has no purpose
if (config.initialRouteName) {
initials.push({
initialRouteName: config.initialRouteName,
parentScreens
});
}
Object.keys(config.screens).forEach(nestedConfig => {
const result = createNormalizedConfigs(nestedConfig, config.screens, routeNames, initials, [...parentScreens], pattern ?? parentPattern);
configs.push(...result);
});
}
}
routeNames.pop();
return configs;
};
const createConfigItem = (screen, routeNames, pattern, path, parse) => {
// Normalize pattern to remove any leading, trailing slashes, duplicate slashes etc.
pattern = pattern.split('/').filter(Boolean).join('/');
const regex = pattern ? new RegExp(`^(${pattern.split('/').map(it => {
if (it.startsWith(':')) {
return `(([^/]+\\/)${it.endsWith('?') ? '?' : ''})`;
}
return `${it === '*' ? '.*' : (0, _escapeStringRegexp.default)(it)}\\/`;
}).join('')})`) : undefined;
return {
screen,
regex,
pattern,
path,
// The routeNames array is mutated, so copy it to keep the current state
routeNames: [...routeNames],
parse
};
};
const findParseConfigForRoute = (routeName, flatConfig) => {
for (const config of flatConfig) {
if (routeName === config.routeNames[config.routeNames.length - 1]) {
return config.parse;
}
}
return undefined;
};
// Try to find an initial route connected with the one passed
const findInitialRoute = (routeName, parentScreens, initialRoutes) => {
for (const config of initialRoutes) {
if (parentScreens.length === config.parentScreens.length) {
let sameParents = true;
for (let i = 0; i < parentScreens.length; i++) {
if (parentScreens[i].localeCompare(config.parentScreens[i]) !== 0) {
sameParents = false;
break;
}
}
if (sameParents) {
return routeName !== config.initialRouteName ? config.initialRouteName : undefined;
}
}
}
return undefined;
};
// returns state object with values depending on whether
// it is the end of state and if there is initialRoute for this level
const createStateObject = (initialRoute, route, isEmpty) => {
if (isEmpty) {
if (initialRoute) {
return {
index: 1,
routes: [{
name: initialRoute
}, route]
};
} else {
return {
routes: [route]
};
}
} else {
if (initialRoute) {
return {
index: 1,
routes: [{
name: initialRoute
}, {
...route,
state: {
routes: []
}
}]
};
} else {
return {
routes: [{
...route,
state: {
routes: []
}
}]
};
}
}
};
const createNestedStateObject = (path, routes, initialRoutes, flatConfig) => {
let state;
let route = routes.shift();
const parentScreens = [];
let initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
parentScreens.push(route.name);
state = createStateObject(initialRoute, route, routes.length === 0);
if (routes.length > 0) {
let nestedState = state;
while (route = routes.shift()) {
initialRoute = findInitialRoute(route.name, parentScreens, initialRoutes);
const nestedStateIndex = nestedState.index || nestedState.routes.length - 1;
nestedState.routes[nestedStateIndex].state = createStateObject(initialRoute, route, routes.length === 0);
if (routes.length > 0) {
nestedState = nestedState.routes[nestedStateIndex].state;
}
parentScreens.push(route.name);
}
}
route = (0, _findFocusedRoute.default)(state);
route.path = path;
const params = parseQueryParams(path, flatConfig ? findParseConfigForRoute(route.name, flatConfig) : undefined);
if (params) {
route.params = {
...route.params,
...params
};
}
return state;
};
const parseQueryParams = (path, parseConfig) => {
const query = path.split('?')[1];
const params = queryString.parse(query);
if (parseConfig) {
Object.keys(params).forEach(name => {
if (Object.hasOwnProperty.call(parseConfig, name) && typeof params[name] === 'string') {
params[name] = parseConfig[name](params[name]);
}
});
}
return Object.keys(params).length ? params : undefined;
};
//# sourceMappingURL=getStateFromPath.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,233 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _exportNames = {
BaseNavigationContainer: true,
createNavigationContainerRef: true,
createNavigatorFactory: true,
CurrentRenderContext: true,
findFocusedRoute: true,
getActionFromState: true,
getFocusedRouteNameFromRoute: true,
getPathFromState: true,
getStateFromPath: true,
NavigationContainerRefContext: true,
NavigationContext: true,
NavigationHelpersContext: true,
NavigationRouteContext: true,
PreventRemoveContext: true,
PreventRemoveProvider: true,
useFocusEffect: true,
useIsFocused: true,
useNavigation: true,
useNavigationBuilder: true,
useNavigationContainerRef: true,
useNavigationState: true,
UNSTABLE_usePreventRemove: true,
usePreventRemoveContext: true,
useRoute: true,
validatePathConfig: true
};
Object.defineProperty(exports, "BaseNavigationContainer", {
enumerable: true,
get: function () {
return _BaseNavigationContainer.default;
}
});
Object.defineProperty(exports, "CurrentRenderContext", {
enumerable: true,
get: function () {
return _CurrentRenderContext.default;
}
});
Object.defineProperty(exports, "NavigationContainerRefContext", {
enumerable: true,
get: function () {
return _NavigationContainerRefContext.default;
}
});
Object.defineProperty(exports, "NavigationContext", {
enumerable: true,
get: function () {
return _NavigationContext.default;
}
});
Object.defineProperty(exports, "NavigationHelpersContext", {
enumerable: true,
get: function () {
return _NavigationHelpersContext.default;
}
});
Object.defineProperty(exports, "NavigationRouteContext", {
enumerable: true,
get: function () {
return _NavigationRouteContext.default;
}
});
Object.defineProperty(exports, "PreventRemoveContext", {
enumerable: true,
get: function () {
return _PreventRemoveContext.default;
}
});
Object.defineProperty(exports, "PreventRemoveProvider", {
enumerable: true,
get: function () {
return _PreventRemoveProvider.default;
}
});
Object.defineProperty(exports, "UNSTABLE_usePreventRemove", {
enumerable: true,
get: function () {
return _usePreventRemove.default;
}
});
Object.defineProperty(exports, "createNavigationContainerRef", {
enumerable: true,
get: function () {
return _createNavigationContainerRef.default;
}
});
Object.defineProperty(exports, "createNavigatorFactory", {
enumerable: true,
get: function () {
return _createNavigatorFactory.default;
}
});
Object.defineProperty(exports, "findFocusedRoute", {
enumerable: true,
get: function () {
return _findFocusedRoute.default;
}
});
Object.defineProperty(exports, "getActionFromState", {
enumerable: true,
get: function () {
return _getActionFromState.default;
}
});
Object.defineProperty(exports, "getFocusedRouteNameFromRoute", {
enumerable: true,
get: function () {
return _getFocusedRouteNameFromRoute.default;
}
});
Object.defineProperty(exports, "getPathFromState", {
enumerable: true,
get: function () {
return _getPathFromState.default;
}
});
Object.defineProperty(exports, "getStateFromPath", {
enumerable: true,
get: function () {
return _getStateFromPath.default;
}
});
Object.defineProperty(exports, "useFocusEffect", {
enumerable: true,
get: function () {
return _useFocusEffect.default;
}
});
Object.defineProperty(exports, "useIsFocused", {
enumerable: true,
get: function () {
return _useIsFocused.default;
}
});
Object.defineProperty(exports, "useNavigation", {
enumerable: true,
get: function () {
return _useNavigation.default;
}
});
Object.defineProperty(exports, "useNavigationBuilder", {
enumerable: true,
get: function () {
return _useNavigationBuilder.default;
}
});
Object.defineProperty(exports, "useNavigationContainerRef", {
enumerable: true,
get: function () {
return _useNavigationContainerRef.default;
}
});
Object.defineProperty(exports, "useNavigationState", {
enumerable: true,
get: function () {
return _useNavigationState.default;
}
});
Object.defineProperty(exports, "usePreventRemoveContext", {
enumerable: true,
get: function () {
return _usePreventRemoveContext.default;
}
});
Object.defineProperty(exports, "useRoute", {
enumerable: true,
get: function () {
return _useRoute.default;
}
});
Object.defineProperty(exports, "validatePathConfig", {
enumerable: true,
get: function () {
return _validatePathConfig.default;
}
});
var _BaseNavigationContainer = _interopRequireDefault(require("./BaseNavigationContainer"));
var _createNavigationContainerRef = _interopRequireDefault(require("./createNavigationContainerRef"));
var _createNavigatorFactory = _interopRequireDefault(require("./createNavigatorFactory"));
var _CurrentRenderContext = _interopRequireDefault(require("./CurrentRenderContext"));
var _findFocusedRoute = _interopRequireDefault(require("./findFocusedRoute"));
var _getActionFromState = _interopRequireDefault(require("./getActionFromState"));
var _getFocusedRouteNameFromRoute = _interopRequireDefault(require("./getFocusedRouteNameFromRoute"));
var _getPathFromState = _interopRequireDefault(require("./getPathFromState"));
var _getStateFromPath = _interopRequireDefault(require("./getStateFromPath"));
var _NavigationContainerRefContext = _interopRequireDefault(require("./NavigationContainerRefContext"));
var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
var _NavigationHelpersContext = _interopRequireDefault(require("./NavigationHelpersContext"));
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
var _PreventRemoveContext = _interopRequireDefault(require("./PreventRemoveContext"));
var _PreventRemoveProvider = _interopRequireDefault(require("./PreventRemoveProvider"));
var _types = require("./types");
Object.keys(_types).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _types[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _types[key];
}
});
});
var _useFocusEffect = _interopRequireDefault(require("./useFocusEffect"));
var _useIsFocused = _interopRequireDefault(require("./useIsFocused"));
var _useNavigation = _interopRequireDefault(require("./useNavigation"));
var _useNavigationBuilder = _interopRequireDefault(require("./useNavigationBuilder"));
var _useNavigationContainerRef = _interopRequireDefault(require("./useNavigationContainerRef"));
var _useNavigationState = _interopRequireDefault(require("./useNavigationState"));
var _usePreventRemove = _interopRequireDefault(require("./usePreventRemove"));
var _usePreventRemoveContext = _interopRequireDefault(require("./usePreventRemoveContext"));
var _useRoute = _interopRequireDefault(require("./useRoute"));
var _validatePathConfig = _interopRequireDefault(require("./validatePathConfig"));
var _routers = require("@react-navigation/routers");
Object.keys(_routers).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
if (key in exports && exports[key] === _routers[key]) return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function () {
return _routers[key];
}
});
});
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":[],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAAA;EAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;AAA0C"}

View File

@@ -0,0 +1,20 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isArrayEqual;
/**
* Compare two arrays with primitive values as the content.
* We need to make sure that both values and order match.
*/
function isArrayEqual(a, b) {
if (a === b) {
return true;
}
if (a.length !== b.length) {
return false;
}
return a.every((it, index) => it === b[index]);
}
//# sourceMappingURL=isArrayEqual.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["isArrayEqual","a","b","length","every","it","index"],"sourceRoot":"../../src","sources":["isArrayEqual.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACe,SAASA,YAAY,CAACC,CAAQ,EAAEC,CAAQ,EAAE;EACvD,IAAID,CAAC,KAAKC,CAAC,EAAE;IACX,OAAO,IAAI;EACb;EAEA,IAAID,CAAC,CAACE,MAAM,KAAKD,CAAC,CAACC,MAAM,EAAE;IACzB,OAAO,KAAK;EACd;EAEA,OAAOF,CAAC,CAACG,KAAK,CAAC,CAACC,EAAE,EAAEC,KAAK,KAAKD,EAAE,KAAKH,CAAC,CAACI,KAAK,CAAC,CAAC;AAChD"}

View File

@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = isRecordEqual;
/**
* Compare two records with primitive values as the content.
*/
function isRecordEqual(a, b) {
if (a === b) {
return true;
}
const aKeys = Object.keys(a);
const bKeys = Object.keys(b);
if (aKeys.length !== bKeys.length) {
return false;
}
return aKeys.every(key => a[key] === b[key]);
}
//# sourceMappingURL=isRecordEqual.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["isRecordEqual","a","b","aKeys","Object","keys","bKeys","length","every","key"],"sourceRoot":"../../src","sources":["isRecordEqual.tsx"],"mappings":";;;;;;AAAA;AACA;AACA;AACe,SAASA,aAAa,CACnCC,CAAsB,EACtBC,CAAsB,EACtB;EACA,IAAID,CAAC,KAAKC,CAAC,EAAE;IACX,OAAO,IAAI;EACb;EAEA,MAAMC,KAAK,GAAGC,MAAM,CAACC,IAAI,CAACJ,CAAC,CAAC;EAC5B,MAAMK,KAAK,GAAGF,MAAM,CAACC,IAAI,CAACH,CAAC,CAAC;EAE5B,IAAIC,KAAK,CAACI,MAAM,KAAKD,KAAK,CAACC,MAAM,EAAE;IACjC,OAAO,KAAK;EACd;EAEA,OAAOJ,KAAK,CAACK,KAAK,CAAEC,GAAG,IAAKR,CAAC,CAACQ,GAAG,CAAC,KAAKP,CAAC,CAACO,GAAG,CAAC,CAAC;AAChD"}

View File

@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PrivateValueStore = void 0;
class PrivateValueStore {}
exports.PrivateValueStore = PrivateValueStore;
//# sourceMappingURL=types.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["PrivateValueStore"],"sourceRoot":"../../src","sources":["types.tsx"],"mappings":";;;;;;AAoJO,MAAMA,iBAAiB,CAA4B;AAYzD"}

View File

@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useChildListeners;
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; }
/**
* Hook which lets child navigators add action listeners.
*/
function useChildListeners() {
const {
current: listeners
} = React.useRef({
action: [],
focus: []
});
const addListener = React.useCallback((type, listener) => {
listeners[type].push(listener);
let removed = false;
return () => {
const index = listeners[type].indexOf(listener);
if (!removed && index > -1) {
removed = true;
listeners[type].splice(index, 1);
}
};
}, [listeners]);
return {
listeners,
addListener
};
}
//# sourceMappingURL=useChildListeners.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useChildListeners","current","listeners","React","useRef","action","focus","addListener","useCallback","type","listener","push","removed","index","indexOf","splice"],"sourceRoot":"../../src","sources":["useChildListeners.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAI/B;AACA;AACA;AACe,SAASA,iBAAiB,GAAG;EAC1C,MAAM;IAAEC,OAAO,EAAEC;EAAU,CAAC,GAAGC,KAAK,CAACC,MAAM,CAExC;IACDC,MAAM,EAAE,EAAE;IACVC,KAAK,EAAE;EACT,CAAC,CAAC;EAEF,MAAMC,WAAW,GAAGJ,KAAK,CAACK,WAAW,CACnC,CAA8BC,IAAO,EAAEC,QAAwB,KAAK;IAClER,SAAS,CAACO,IAAI,CAAC,CAACE,IAAI,CAACD,QAAQ,CAAC;IAE9B,IAAIE,OAAO,GAAG,KAAK;IACnB,OAAO,MAAM;MACX,MAAMC,KAAK,GAAGX,SAAS,CAACO,IAAI,CAAC,CAACK,OAAO,CAACJ,QAAQ,CAAC;MAE/C,IAAI,CAACE,OAAO,IAAIC,KAAK,GAAG,CAAC,CAAC,EAAE;QAC1BD,OAAO,GAAG,IAAI;QACdV,SAAS,CAACO,IAAI,CAAC,CAACM,MAAM,CAACF,KAAK,EAAE,CAAC,CAAC;MAClC;IACF,CAAC;EACH,CAAC,EACD,CAACX,SAAS,CAAC,CACZ;EAED,OAAO;IACLA,SAAS;IACTK;EACF,CAAC;AACH"}

View File

@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useComponent;
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 NavigationContent = _ref => {
let {
render,
children
} = _ref;
return render(children);
};
function useComponent(render) {
const renderRef = React.useRef(render);
// Normally refs shouldn't be mutated in render
// But we return a component which will be rendered
// So it's just for immediate consumption
renderRef.current = render;
React.useEffect(() => {
renderRef.current = null;
});
return React.useRef(_ref2 => {
let {
children
} = _ref2;
const render = renderRef.current;
if (render === null) {
throw new Error('The returned component must be rendered in the same render phase as the hook.');
}
return /*#__PURE__*/React.createElement(NavigationContent, {
render: render
}, children);
}).current;
}
//# sourceMappingURL=useComponent.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["NavigationContent","render","children","useComponent","renderRef","React","useRef","current","useEffect","Error"],"sourceRoot":"../../src","sources":["useComponent.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAS/B,MAAMA,iBAAiB,GAAG,QAAiC;EAAA,IAAhC;IAAEC,MAAM;IAAEC;EAAgB,CAAC;EACpD,OAAOD,MAAM,CAACC,QAAQ,CAAC;AACzB,CAAC;AAEc,SAASC,YAAY,CAACF,MAAc,EAAE;EACnD,MAAMG,SAAS,GAAGC,KAAK,CAACC,MAAM,CAAgBL,MAAM,CAAC;;EAErD;EACA;EACA;EACAG,SAAS,CAACG,OAAO,GAAGN,MAAM;EAE1BI,KAAK,CAACG,SAAS,CAAC,MAAM;IACpBJ,SAAS,CAACG,OAAO,GAAG,IAAI;EAC1B,CAAC,CAAC;EAEF,OAAOF,KAAK,CAACC,MAAM,CAAC,SAAiD;IAAA,IAAhD;MAAEJ;IAAwC,CAAC;IAC9D,MAAMD,MAAM,GAAGG,SAAS,CAACG,OAAO;IAEhC,IAAIN,MAAM,KAAK,IAAI,EAAE;MACnB,MAAM,IAAIQ,KAAK,CACb,+EAA+E,CAChF;IACH;IAEA,oBAAO,oBAAC,iBAAiB;MAAC,MAAM,EAAER;IAAO,GAAEC,QAAQ,CAAqB;EAC1E,CAAC,CAAC,CAACK,OAAO;AACZ"}

View File

@@ -0,0 +1,27 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useCurrentRender;
var React = _interopRequireWildcard(require("react"));
var _CurrentRenderContext = _interopRequireDefault(require("./CurrentRenderContext"));
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; }
/**
* Write the current options, so that server renderer can get current values
* Mutating values like this is not safe in async mode, but it doesn't apply to SSR
*/
function useCurrentRender(_ref) {
let {
state,
navigation,
descriptors
} = _ref;
const current = React.useContext(_CurrentRenderContext.default);
if (current && navigation.isFocused()) {
current.options = descriptors[state.routes[state.index].key].options;
}
}
//# sourceMappingURL=useCurrentRender.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useCurrentRender","state","navigation","descriptors","current","React","useContext","CurrentRenderContext","isFocused","options","routes","index","key"],"sourceRoot":"../../src","sources":["useCurrentRender.tsx"],"mappings":";;;;;;AACA;AAEA;AAA0D;AAAA;AAAA;AAiB1D;AACA;AACA;AACA;AACe,SAASA,gBAAgB,OAI5B;EAAA,IAJ6B;IACvCC,KAAK;IACLC,UAAU;IACVC;EACO,CAAC;EACR,MAAMC,OAAO,GAAGC,KAAK,CAACC,UAAU,CAACC,6BAAoB,CAAC;EAEtD,IAAIH,OAAO,IAAIF,UAAU,CAACM,SAAS,EAAE,EAAE;IACrCJ,OAAO,CAACK,OAAO,GAAGN,WAAW,CAACF,KAAK,CAACS,MAAM,CAACT,KAAK,CAACU,KAAK,CAAC,CAACC,GAAG,CAAC,CAACH,OAAO;EACtE;AACF"}

View File

@@ -0,0 +1,134 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useDescriptors;
var React = _interopRequireWildcard(require("react"));
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
var _SceneView = _interopRequireDefault(require("./SceneView"));
var _useNavigationCache = _interopRequireDefault(require("./useNavigationCache"));
var _useRouteCache = _interopRequireDefault(require("./useRouteCache"));
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; }
/**
* Hook to create descriptor objects for the child routes.
*
* A descriptor object provides 3 things:
* - Helper method to render a screen
* - Options specified by the screen for the navigator
* - Navigation object intended for the route
*/
function useDescriptors(_ref) {
let {
state,
screens,
navigation,
screenOptions,
defaultScreenOptions,
onAction,
getState,
setState,
addListener,
addKeyedListener,
onRouteFocus,
router,
emitter
} = _ref;
const [options, setOptions] = React.useState({});
const {
onDispatchAction,
onOptionsChange,
stackRef
} = React.useContext(_NavigationBuilderContext.default);
const context = React.useMemo(() => ({
navigation,
onAction,
addListener,
addKeyedListener,
onRouteFocus,
onDispatchAction,
onOptionsChange,
stackRef
}), [navigation, onAction, addListener, addKeyedListener, onRouteFocus, onDispatchAction, onOptionsChange, stackRef]);
const navigations = (0, _useNavigationCache.default)({
state,
getState,
navigation,
setOptions,
router,
emitter
});
const routes = (0, _useRouteCache.default)(state.routes);
return routes.reduce((acc, route, i) => {
const config = screens[route.name];
const screen = config.props;
const navigation = navigations[route.key];
const optionsList = [
// The default `screenOptions` passed to the navigator
screenOptions,
// The `screenOptions` props passed to `Group` elements
...(config.options ? config.options.filter(Boolean) : []),
// The `options` prop passed to `Screen` elements,
screen.options,
// The options set via `navigation.setOptions`
options[route.key]];
const customOptions = optionsList.reduce((acc, curr) => Object.assign(acc,
// @ts-expect-error: we check for function but TS still complains
typeof curr !== 'function' ? curr : curr({
route,
navigation
})), {});
const mergedOptions = {
...(typeof defaultScreenOptions === 'function' ?
// @ts-expect-error: ts gives incorrect error here
defaultScreenOptions({
route,
navigation,
options: customOptions
}) : defaultScreenOptions),
...customOptions
};
const clearOptions = () => setOptions(o => {
if (route.key in o) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {
[route.key]: _,
...rest
} = o;
return rest;
}
return o;
});
acc[route.key] = {
route,
// @ts-expect-error: it's missing action helpers, fix later
navigation,
render() {
return /*#__PURE__*/React.createElement(_NavigationBuilderContext.default.Provider, {
key: route.key,
value: context
}, /*#__PURE__*/React.createElement(_NavigationContext.default.Provider, {
value: navigation
}, /*#__PURE__*/React.createElement(_NavigationRouteContext.default.Provider, {
value: route
}, /*#__PURE__*/React.createElement(_SceneView.default, {
navigation: navigation,
route: route,
screen: screen,
routeState: state.routes[i].state,
getState: getState,
setState: setState,
options: mergedOptions,
clearOptions: clearOptions
}))));
},
options: mergedOptions
};
return acc;
}, {});
}
//# sourceMappingURL=useDescriptors.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useDescriptors","state","screens","navigation","screenOptions","defaultScreenOptions","onAction","getState","setState","addListener","addKeyedListener","onRouteFocus","router","emitter","options","setOptions","React","useState","onDispatchAction","onOptionsChange","stackRef","useContext","NavigationBuilderContext","context","useMemo","navigations","useNavigationCache","routes","useRouteCache","reduce","acc","route","i","config","name","screen","props","key","optionsList","filter","Boolean","customOptions","curr","Object","assign","mergedOptions","clearOptions","o","_","rest","render"],"sourceRoot":"../../src","sources":["useDescriptors.tsx"],"mappings":";;;;;;AAMA;AAEA;AAIA;AACA;AACA;AAUA;AACA;AAA4C;AAAA;AAAA;AAgD5C;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAc,OAmBM;EAAA,IAd1C;IACAC,KAAK;IACLC,OAAO;IACPC,UAAU;IACVC,aAAa;IACbC,oBAAoB;IACpBC,QAAQ;IACRC,QAAQ;IACRC,QAAQ;IACRC,WAAW;IACXC,gBAAgB;IAChBC,YAAY;IACZC,MAAM;IACNC;EACuC,CAAC;EACxC,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGC,KAAK,CAACC,QAAQ,CAAyB,CAAC,CAAC,CAAC;EACxE,MAAM;IAA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CAAC;MACDhC,OAAO,EAAE+B;IACX,CAAC;IAED,OAAOf,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;AACR"}

View File

@@ -0,0 +1,107 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useEventEmitter;
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; }
/**
* Hook to manage the event system used by the navigator to notify screens of various events.
*/
function useEventEmitter(listen) {
const listenRef = React.useRef(listen);
React.useEffect(() => {
listenRef.current = listen;
});
const listeners = React.useRef(Object.create(null));
const create = React.useCallback(target => {
const removeListener = (type, callback) => {
const callbacks = listeners.current[type] ? listeners.current[type][target] : undefined;
if (!callbacks) {
return;
}
const index = callbacks.indexOf(callback);
if (index > -1) {
callbacks.splice(index, 1);
}
};
const addListener = (type, callback) => {
listeners.current[type] = listeners.current[type] || {};
listeners.current[type][target] = listeners.current[type][target] || [];
listeners.current[type][target].push(callback);
let removed = false;
return () => {
// Prevent removing other listeners when unsubscribing same listener multiple times
if (!removed) {
removed = true;
removeListener(type, callback);
}
};
};
return {
addListener,
removeListener
};
}, []);
const emit = React.useCallback(_ref => {
var _items$target, _listenRef$current;
let {
type,
data,
target,
canPreventDefault
} = _ref;
const items = listeners.current[type] || {};
// Copy the current list of callbacks in case they are mutated during execution
const callbacks = target !== undefined ? (_items$target = items[target]) === null || _items$target === void 0 ? void 0 : _items$target.slice() : [].concat(...Object.keys(items).map(t => items[t])).filter((cb, i, self) => self.lastIndexOf(cb) === i);
const event = {
get type() {
return type;
}
};
if (target !== undefined) {
Object.defineProperty(event, 'target', {
enumerable: true,
get() {
return target;
}
});
}
if (data !== undefined) {
Object.defineProperty(event, 'data', {
enumerable: true,
get() {
return data;
}
});
}
if (canPreventDefault) {
let defaultPrevented = false;
Object.defineProperties(event, {
defaultPrevented: {
enumerable: true,
get() {
return defaultPrevented;
}
},
preventDefault: {
enumerable: true,
value() {
defaultPrevented = true;
}
}
});
}
(_listenRef$current = listenRef.current) === null || _listenRef$current === void 0 ? void 0 : _listenRef$current.call(listenRef, event);
callbacks === null || callbacks === void 0 ? void 0 : callbacks.forEach(cb => cb(event));
return event;
}, []);
return React.useMemo(() => ({
create,
emit
}), [create, emit]);
}
//# sourceMappingURL=useEventEmitter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useEventEmitter","listen","listenRef","React","useRef","useEffect","current","listeners","Object","create","useCallback","target","removeListener","type","callback","callbacks","undefined","index","indexOf","splice","addListener","push","removed","emit","data","canPreventDefault","items","slice","concat","keys","map","t","filter","cb","i","self","lastIndexOf","event","defineProperty","enumerable","get","defaultPrevented","defineProperties","preventDefault","value","forEach","useMemo"],"sourceRoot":"../../src","sources":["useEventEmitter.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAW/B;AACA;AACA;AACe,SAASA,eAAe,CACrCC,MAAyB,EACE;EAC3B,MAAMC,SAAS,GAAGC,KAAK,CAACC,MAAM,CAACH,MAAM,CAAC;EAEtCE,KAAK,CAACE,SAAS,CAAC,MAAM;IACpBH,SAAS,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AE,IAAI;UAChBC,GAAG,GAAG;YACJ,OAAOC,gBAAgB;UACzB;QACF,CAAC;QACDE,cAAc,EAAE;UACdJ,UAAU,EAAE,IAAI;UAChBK,KAAK,GAAG;YACNH,gBAAgB,GAAG,IAAI;UACzB;QACF;MACF,CAAC,CAAC;IACJ;IAEA,sBAAAvC,SAAS,CAACI,OAAO,uDAAjB,wBAAAJ,SAAS,EAAWmC,KAAK,CAAC;IAE1BtB,SAAS,aAATA,SAAS,uBAATA,SAAS,CAAE8B,OAAO,CAAEZ,EAAE,IAAKA,EAAE,CAACI,KAAK,CAAC,CAAC;IAErC,OAAOA,KAAK;EACd,CAAC,EACD,EAAE,CACH;EAED,OAAOlC,KAAK,CAAC2C,OAAO,CAAC,OAAO;IAAErC,MAAM;IAAEc;EAAK,CAAC,CAAC,EAAE,CAACd,MAAM,EAAEc,IAAI,CAAC,CAAC;AAChE"}

View File

@@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useFocusEffect;
var React = _interopRequireWildcard(require("react"));
var _useNavigation = _interopRequireDefault(require("./useNavigation"));
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; }
/**
* Hook to run an effect in a focused screen, similar to `React.useEffect`.
* This can be used to perform side-effects such as fetching data or subscribing to events.
* The passed callback should be wrapped in `React.useCallback` to avoid running the effect too often.
*
* @param callback Memoized callback containing the effect, should optionally return a cleanup function.
*/
function useFocusEffect(effect) {
const navigation = (0, _useNavigation.default)();
if (arguments[1] !== undefined) {
const message = "You passed a second argument to 'useFocusEffect', but it only accepts one argument. " + "If you want to pass a dependency array, you can use 'React.useCallback':\n\n" + 'useFocusEffect(\n' + ' React.useCallback(() => {\n' + ' // Your code here\n' + ' }, [depA, depB])\n' + ');\n\n' + 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';
console.error(message);
}
React.useEffect(() => {
let isFocused = false;
let cleanup;
const callback = () => {
const destroy = effect();
if (destroy === undefined || typeof destroy === 'function') {
return destroy;
}
if (process.env.NODE_ENV !== 'production') {
let message = 'An effect function must not return anything besides a function, which is used for clean-up.';
if (destroy === null) {
message += " You returned 'null'. If your effect does not require clean-up, return 'undefined' (or nothing).";
} else if (typeof destroy.then === 'function') {
message += "\n\nIt looks like you wrote 'useFocusEffect(async () => ...)' or returned a Promise. " + 'Instead, write the async function inside your effect ' + 'and call it immediately:\n\n' + 'useFocusEffect(\n' + ' React.useCallback(() => {\n' + ' async function fetchData() {\n' + ' // You can await here\n' + ' const response = await MyAPI.getData(someId);\n' + ' // ...\n' + ' }\n\n' + ' fetchData();\n' + ' }, [someId])\n' + ');\n\n' + 'See usage guide: https://reactnavigation.org/docs/use-focus-effect';
} else {
message += ` You returned '${JSON.stringify(destroy)}'.`;
}
console.error(message);
}
};
// We need to run the effect on intial render/dep changes if the screen is focused
if (navigation.isFocused()) {
cleanup = callback();
isFocused = true;
}
const unsubscribeFocus = navigation.addListener('focus', () => {
// If callback was already called for focus, avoid calling it again
// The focus event may also fire on intial render, so we guard against runing the effect twice
if (isFocused) {
return;
}
if (cleanup !== undefined) {
cleanup();
}
cleanup = callback();
isFocused = true;
});
const unsubscribeBlur = navigation.addListener('blur', () => {
if (cleanup !== undefined) {
cleanup();
}
cleanup = undefined;
isFocused = false;
});
return () => {
if (cleanup !== undefined) {
cleanup();
}
unsubscribeFocus();
unsubscribeBlur();
};
}, [effect, navigation]);
}
//# sourceMappingURL=useFocusEffect.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useFocusEffect","effect","navigation","useNavigation","arguments","undefined","message","console","error","React","useEffect","isFocused","cleanup","callback","destroy","process","env","NODE_ENV","then","JSON","stringify","unsubscribeFocus","addListener","unsubscribeBlur"],"sourceRoot":"../../src","sources":["useFocusEffect.tsx"],"mappings":";;;;;;AAAA;AAEA;AAA4C;AAAA;AAAA;AAI5C;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,cAAc,CAACC,MAAsB,EAAE;EAC7D,MAAMC,UAAU,GAAG,IAAAC,sBAAa,GAAE;EAElC,IAAIC,SAAS,CAAC,CAAC,CAAC,KAAKC,SAAS,EAAE;IAC9B,MAAMC,OAAO,GACX,sFAAsF,GACtF,8EAA8E,GAC9E,mBAAmB,GACnB,+BAA+B,GAC/B,yBAAyB,GACzB,sBAAsB,GACtB,QAAQ,GACR,oEAAoE;IAEtEC,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC;EACxB;EAEAG,KAAK,CAACC,SAAS,CAAC,MAAM;IACpB,IAAIC,SAAS,GAAG,KAAK;IACrB,IAAIC,OAAwC;IAE5C,MAAMC,QAAQ,GAAG,MAAM;MACrB,MAAMC,OAAO,GAAGb,MAAM,EAAE;MAExB,IAAIa,OAAO,KAAKT,SAAS,IAAI,OAAOS,OAAO,KAAK,UAAU,EAAE;QAC1D,OAAOA,OAAO;MAChB;MAEA,IAAIC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,EAAE;QACzC,IAAIX,OAAO,GACT,6FAA6F;QAE/F,I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AM,EAAEC,UAAU,CAAC,CAAC;AAC1B"}

View File

@@ -0,0 +1,72 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useFocusEvents;
var React = _interopRequireWildcard(require("react"));
var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
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; }
/**
* Hook to take care of emitting `focus` and `blur` events.
*/
function useFocusEvents(_ref) {
let {
state,
emitter
} = _ref;
const navigation = React.useContext(_NavigationContext.default);
const lastFocusedKeyRef = React.useRef();
const currentFocusedKey = state.routes[state.index].key;
// When the parent screen changes its focus state, we also need to change child's focus
// Coz the child screen can't be focused if the parent screen is out of focus
React.useEffect(() => navigation === null || navigation === void 0 ? void 0 : navigation.addListener('focus', () => {
lastFocusedKeyRef.current = currentFocusedKey;
emitter.emit({
type: 'focus',
target: currentFocusedKey
});
}), [currentFocusedKey, emitter, navigation]);
React.useEffect(() => navigation === null || navigation === void 0 ? void 0 : navigation.addListener('blur', () => {
lastFocusedKeyRef.current = undefined;
emitter.emit({
type: 'blur',
target: currentFocusedKey
});
}), [currentFocusedKey, emitter, navigation]);
React.useEffect(() => {
const lastFocusedKey = lastFocusedKeyRef.current;
lastFocusedKeyRef.current = currentFocusedKey;
// We wouldn't have `lastFocusedKey` on initial mount
// Fire focus event for the current route on mount if there's no parent navigator
if (lastFocusedKey === undefined && !navigation) {
emitter.emit({
type: 'focus',
target: currentFocusedKey
});
}
// We should only emit events when the focused key changed and navigator is focused
// When navigator is not focused, screens inside shouldn't receive focused status either
if (lastFocusedKey === currentFocusedKey || !(navigation ? navigation.isFocused() : true)) {
return;
}
if (lastFocusedKey === undefined) {
// Only fire events after initial mount
return;
}
emitter.emit({
type: 'blur',
target: lastFocusedKey
});
emitter.emit({
type: 'focus',
target: currentFocusedKey
});
}, [currentFocusedKey, emitter, navigation]);
}
//# sourceMappingURL=useFocusEvents.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useFocusEvents","state","emitter","navigation","React","useContext","NavigationContext","lastFocusedKeyRef","useRef","currentFocusedKey","routes","index","key","useEffect","addListener","current","emit","type","target","undefined","lastFocusedKey","isFocused"],"sourceRoot":"../../src","sources":["useFocusEvents.tsx"],"mappings":";;;;;;AACA;AAEA;AAAoD;AAAA;AAAA;AASpD;AACA;AACA;AACe,SAASA,cAAc,OAGnB;EAAA,IAHmD;IACpEC,KAAK;IACLC;EACc,CAAC;EACf,MAAMC,UAAU,GAAGC,KAAK,CAACC,UAAU,CAACC,0BAAiB,CAAC;EACtD,MAAMC,iBAAiB,GAAGH,KAAK,CAACI,MAAM,EAAsB;EAE5D,MAAMC,iBAAiB,GAAGR,KAAK,CAACS,MAAM,CAACT,KAAK,CAACU,KAAK,CAAC,CAACC,GAAG;;EAEvD;EACA;EACAR,KAAK,CAACS,SAAS,CACb,MACEV,UAAU,aAAVA,UAAU,uBAAVA,UAAU,CAAEW,WAAW,CAAC,OAAO,EAAE,MAAM;IACrCP,iBAAiB,CAACQ,OAAO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AEP,OAAO,EAAEC,UAAU,CAAC,CAAC;AAC9C"}

View File

@@ -0,0 +1,50 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useFocusedListenersChildrenAdapter;
var React = _interopRequireWildcard(require("react"));
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
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; }
/**
* Hook for passing focus callback to children
*/
function useFocusedListenersChildrenAdapter(_ref) {
let {
navigation,
focusedListeners
} = _ref;
const {
addListener
} = React.useContext(_NavigationBuilderContext.default);
const listener = React.useCallback(callback => {
if (navigation.isFocused()) {
for (const listener of focusedListeners) {
const {
handled,
result
} = listener(callback);
if (handled) {
return {
handled,
result
};
}
}
return {
handled: true,
result: callback(navigation)
};
} else {
return {
handled: false,
result: null
};
}
}, [focusedListeners, navigation]);
React.useEffect(() => addListener === null || addListener === void 0 ? void 0 : addListener('focus', listener), [addListener, listener]);
}
//# sourceMappingURL=useFocusedListenersChildrenAdapter.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useFocusedListenersChildrenAdapter","navigation","focusedListeners","addListener","React","useContext","NavigationBuilderContext","listener","useCallback","callback","isFocused","handled","result","useEffect"],"sourceRoot":"../../src","sources":["useFocusedListenersChildrenAdapter.tsx"],"mappings":";;;;;;AACA;AAEA;AAGoC;AAAA;AAAA;AAQpC;AACA;AACA;AACe,SAASA,kCAAkC,OAG9C;EAAA,IAH+C;IACzDC,UAAU;IACVC;EACO,CAAC;EACR,MAAM;IAAEC;EAAY,CAAC,GAAGC,KAAK,CAACC,UAAU,CAACC,iCAAwB,CAAC;EAElE,MAAMC,QAAQ,GAAGH,KAAK,CAACI,WAAW,CAC/BC,QAAwC,IAAK;IAC5C,IAAIR,UAAU,CAACS,SAAS,EAAE,EAAE;MAC1B,KAAK,MAAMH,QAAQ,IAAIL,gBAAgB,EAAE;QACvC,MAAM;UAAES,OAAO;UAAEC;QAAO,CAAC,GAAGL,QAAQ,CAACE,QAAQ,CAAC;QAE9C,IAAIE,OAAO,EAAE;UACX,OAAO;YAAEA,OAAO;YAAEC;UAAO,CAAC;QAC5B;MACF;MAEA,OAAO;QAAED,OAAO,EAAE,IAAI;QAAEC,MAAM,EAAEH,QAAQ,CAACR,UAAU;MAAE,CAAC;IACxD,CAAC,MAAM;MACL,OAAO;QAAEU,OAAO,EAAE,KAAK;QAAEC,MAAM,EAAE;MAAK,CAAC;IACzC;EACF,CAAC,EACD,CAACV,gBAAgB,EAAED,UAAU,CAAC,CAC/B;EAEDG,KAAK,CAACS,SAAS,CACb,MAAMV,WAAW,aAAXA,WAAW,uBAAXA,WAAW,CAAG,OAAO,EAAEI,QAAQ,CAAC,EACtC,CAACJ,WAAW,EAAEI,QAAQ,CAAC,CACxB;AACH"}

View File

@@ -0,0 +1,39 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useIsFocused;
var React = _interopRequireWildcard(require("react"));
var _useNavigation = _interopRequireDefault(require("./useNavigation"));
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; }
/**
* Hook to get the current focus state of the screen. Returns a `true` if screen is focused, otherwise `false`.
* This can be used if a component needs to render something based on the focus state.
*/
function useIsFocused() {
const navigation = (0, _useNavigation.default)();
const [isFocused, setIsFocused] = (0, React.useState)(navigation.isFocused);
const valueToReturn = navigation.isFocused();
if (isFocused !== valueToReturn) {
// If the value has changed since the last render, we need to update it.
// This could happen if we missed an update from the event listeners during re-render.
// React will process this update immediately, so the old subscription value won't be committed.
// It is still nice to avoid returning a mismatched value though, so let's override the return value.
// This is the same logic as in https://github.com/facebook/react/tree/master/packages/use-subscription
setIsFocused(valueToReturn);
}
React.useEffect(() => {
const unsubscribeFocus = navigation.addListener('focus', () => setIsFocused(true));
const unsubscribeBlur = navigation.addListener('blur', () => setIsFocused(false));
return () => {
unsubscribeFocus();
unsubscribeBlur();
};
}, [navigation]);
React.useDebugValue(valueToReturn);
return valueToReturn;
}
//# sourceMappingURL=useIsFocused.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useIsFocused","navigation","useNavigation","isFocused","setIsFocused","useState","valueToReturn","React","useEffect","unsubscribeFocus","addListener","unsubscribeBlur","useDebugValue"],"sourceRoot":"../../src","sources":["useIsFocused.tsx"],"mappings":";;;;;;AAAA;AAGA;AAA4C;AAAA;AAAA;AAE5C;AACA;AACA;AACA;AACe,SAASA,YAAY,GAAY;EAC9C,MAAMC,UAAU,GAAG,IAAAC,sBAAa,GAAE;EAClC,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAG,IAAAC,cAAQ,EAACJ,UAAU,CAACE,SAAS,CAAC;EAEhE,MAAMG,aAAa,GAAGL,UAAU,CAACE,SAAS,EAAE;EAE5C,IAAIA,SAAS,KAAKG,aAAa,EAAE;IAC/B;IACA;IACA;IACA;IACA;IACAF,YAAY,CAACE,aAAa,CAAC;EAC7B;EAEAC,KAAK,CAACC,SAAS,CAAC,MAAM;IACpB,MAAMC,gBAAgB,GAAGR,UAAU,CAACS,WAAW,CAAC,OAAO,EAAE,MACvDN,YAAY,CAAC,IAAI,CAAC,CACnB;IAED,MAAMO,eAAe,GAAGV,UAAU,CAACS,WAAW,CAAC,MAAM,EAAE,MACrDN,YAAY,CAAC,KAAK,CAAC,CACpB;IAED,OAAO,MAAM;MACXK,gBAAgB,EAAE;MAClBE,eAAe,EAAE;IACnB,CAAC;EACH,CAAC,EAAE,CAACV,UAAU,CAAC,CAAC;EAEhBM,KAAK,CAACK,aAAa,CAACN,aAAa,CAAC;EAElC,OAAOA,aAAa;AACtB"}

View File

@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useKeyedChildListeners;
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; }
/**
* Hook which lets child navigators add getters to be called for obtaining rehydrated state.
*/
function useKeyedChildListeners() {
const {
current: keyedListeners
} = React.useRef(Object.assign(Object.create(null), {
getState: {},
beforeRemove: {}
}));
const addKeyedListener = React.useCallback((type, key, listener) => {
// @ts-expect-error: according to ref stated above you can use `key` to index type
keyedListeners[type][key] = listener;
return () => {
// @ts-expect-error: according to ref stated above you can use `key` to index type
keyedListeners[type][key] = undefined;
};
}, [keyedListeners]);
return {
keyedListeners,
addKeyedListener
};
}
//# sourceMappingURL=useKeyedChildListeners.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useKeyedChildListeners","current","keyedListeners","React","useRef","Object","assign","create","getState","beforeRemove","addKeyedListener","useCallback","type","key","listener","undefined"],"sourceRoot":"../../src","sources":["useKeyedChildListeners.tsx"],"mappings":";;;;;;AAAA;AAA+B;AAAA;AAI/B;AACA;AACA;AACe,SAASA,sBAAsB,GAAG;EAC/C,MAAM;IAAEC,OAAO,EAAEC;EAAe,CAAC,GAAGC,KAAK,CAACC,MAAM,CAM9CC,MAAM,CAACC,MAAM,CAACD,MAAM,CAACE,MAAM,CAAC,IAAI,CAAC,EAAE;IACjCC,QAAQ,EAAE,CAAC,CAAC;IACZC,YAAY,EAAE,CAAC;EACjB,CAAC,CAAC,CACH;EAED,MAAMC,gBAAgB,GAAGP,KAAK,CAACQ,WAAW,CACxC,CACEC,IAAO,EACPC,GAAW,EACXC,QAA6B,KAC1B;IACH;IACAZ,cAAc,CAACU,IAAI,CAAC,CAACC,GAAG,CAAC,GAAGC,QAAQ;IAEpC,OAAO,MAAM;MACX;MACAZ,cAAc,CAACU,IAAI,CAAC,CAACC,GAAG,CAAC,GAAGE,SAAS;IACvC,CAAC;EACH,CAAC,EACD,CAACb,cAAc,CAAC,CACjB;EAED,OAAO;IACLA,cAAc;IACdQ;EACF,CAAC;AACH"}

View File

@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useNavigation;
var React = _interopRequireWildcard(require("react"));
var _NavigationContainerRefContext = _interopRequireDefault(require("./NavigationContainerRefContext"));
var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
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; }
/**
* Hook to access the navigation prop of the parent screen anywhere.
*
* @returns Navigation prop of the parent screen.
*/
function useNavigation() {
const root = React.useContext(_NavigationContainerRefContext.default);
const navigation = React.useContext(_NavigationContext.default);
if (navigation === undefined && root === undefined) {
throw new Error("Couldn't find a navigation object. Is your component inside NavigationContainer?");
}
// FIXME: Figure out a better way to do this
return navigation ?? root;
}
//# sourceMappingURL=useNavigation.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useNavigation","root","React","useContext","NavigationContainerRefContext","navigation","NavigationContext","undefined","Error"],"sourceRoot":"../../src","sources":["useNavigation.tsx"],"mappings":";;;;;;AACA;AAEA;AACA;AAAoD;AAAA;AAAA;AAGpD;AACA;AACA;AACA;AACA;AACe,SAASA,aAAa,GAI9B;EACL,MAAMC,IAAI,GAAGC,KAAK,CAACC,UAAU,CAACC,sCAA6B,CAAC;EAC5D,MAAMC,UAAU,GAAGH,KAAK,CAACC,UAAU,CAACG,0BAAiB,CAAC;EAEtD,IAAID,UAAU,KAAKE,SAAS,IAAIN,IAAI,KAAKM,SAAS,EAAE;IAClD,MAAM,IAAIC,KAAK,CACb,kFAAkF,CACnF;EACH;;EAEA;EACA,OAAQH,UAAU,IAAIJ,IAAI;AAC5B"}

View File

@@ -0,0 +1,457 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useNavigationBuilder;
var _routers = require("@react-navigation/routers");
var React = _interopRequireWildcard(require("react"));
var _reactIs = require("react-is");
var _Group = _interopRequireDefault(require("./Group"));
var _isArrayEqual = _interopRequireDefault(require("./isArrayEqual"));
var _isRecordEqual = _interopRequireDefault(require("./isRecordEqual"));
var _NavigationHelpersContext = _interopRequireDefault(require("./NavigationHelpersContext"));
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
var _NavigationStateContext = _interopRequireDefault(require("./NavigationStateContext"));
var _PreventRemoveProvider = _interopRequireDefault(require("./PreventRemoveProvider"));
var _Screen = _interopRequireDefault(require("./Screen"));
var _types = require("./types");
var _useChildListeners = _interopRequireDefault(require("./useChildListeners"));
var _useComponent = _interopRequireDefault(require("./useComponent"));
var _useCurrentRender = _interopRequireDefault(require("./useCurrentRender"));
var _useDescriptors = _interopRequireDefault(require("./useDescriptors"));
var _useEventEmitter = _interopRequireDefault(require("./useEventEmitter"));
var _useFocusedListenersChildrenAdapter = _interopRequireDefault(require("./useFocusedListenersChildrenAdapter"));
var _useFocusEvents = _interopRequireDefault(require("./useFocusEvents"));
var _useKeyedChildListeners = _interopRequireDefault(require("./useKeyedChildListeners"));
var _useNavigationHelpers = _interopRequireDefault(require("./useNavigationHelpers"));
var _useOnAction = _interopRequireDefault(require("./useOnAction"));
var _useOnGetState = _interopRequireDefault(require("./useOnGetState"));
var _useOnRouteFocus = _interopRequireDefault(require("./useOnRouteFocus"));
var _useRegisterNavigator = _interopRequireDefault(require("./useRegisterNavigator"));
var _useScheduleUpdate = _interopRequireDefault(require("./useScheduleUpdate"));
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; }
// This is to make TypeScript compiler happy
// eslint-disable-next-line babel/no-unused-expressions
_types.PrivateValueStore;
const isValidKey = key => key === undefined || typeof key === 'string' && key !== '';
/**
* Extract route config object from React children elements.
*
* @param children React Elements to extract the config from.
*/
const getRouteConfigsFromChildren = (children, groupKey, groupOptions) => {
const configs = React.Children.toArray(children).reduce((acc, child) => {
var _child$type, _child$props;
if ( /*#__PURE__*/React.isValidElement(child)) {
if (child.type === _Screen.default) {
// We can only extract the config from `Screen` elements
// If something else was rendered, it's probably a bug
if (!isValidKey(child.props.navigationKey)) {
throw new Error(`Got an invalid 'navigationKey' prop (${JSON.stringify(child.props.navigationKey)}) for the screen '${child.props.name}'. It must be a non-empty string or 'undefined'.`);
}
acc.push({
keys: [groupKey, child.props.navigationKey],
options: groupOptions,
props: child.props
});
return acc;
}
if (child.type === React.Fragment || child.type === _Group.default) {
if (!isValidKey(child.props.navigationKey)) {
throw new Error(`Got an invalid 'navigationKey' prop (${JSON.stringify(child.props.navigationKey)}) for the group. It must be a non-empty string or 'undefined'.`);
}
// When we encounter a fragment or group, we need to dive into its children to extract the configs
// This is handy to conditionally define a group of screens
acc.push(...getRouteConfigsFromChildren(child.props.children, child.props.navigationKey, child.type !== _Group.default ? groupOptions : groupOptions != null ? [...groupOptions, child.props.screenOptions] : [child.props.screenOptions]));
return acc;
}
}
throw new Error(`A navigator can only contain 'Screen', 'Group' or 'React.Fragment' as its direct children (found ${/*#__PURE__*/React.isValidElement(child) ? `'${typeof child.type === 'string' ? child.type : (_child$type = child.type) === null || _child$type === void 0 ? void 0 : _child$type.name}'${child.props != null && typeof child.props === 'object' && 'name' in child.props && (_child$props = child.props) !== null && _child$props !== void 0 && _child$props.name ? ` for the screen '${child.props.name}'` : ''}` : typeof child === 'object' ? JSON.stringify(child) : `'${String(child)}'`}). To render this component in the navigator, pass it in the 'component' prop to 'Screen'.`);
}, []);
if (process.env.NODE_ENV !== 'production') {
configs.forEach(config => {
const {
name,
children,
component,
getComponent
} = config.props;
if (typeof name !== 'string' || !name) {
throw new Error(`Got an invalid name (${JSON.stringify(name)}) for the screen. It must be a non-empty string.`);
}
if (children != null || component !== undefined || getComponent !== undefined) {
if (children != null && component !== undefined) {
throw new Error(`Got both 'component' and 'children' props for the screen '${name}'. You must pass only one of them.`);
}
if (children != null && getComponent !== undefined) {
throw new Error(`Got both 'getComponent' and 'children' props for the screen '${name}'. You must pass only one of them.`);
}
if (component !== undefined && getComponent !== undefined) {
throw new Error(`Got both 'component' and 'getComponent' props for the screen '${name}'. You must pass only one of them.`);
}
if (children != null && typeof children !== 'function') {
throw new Error(`Got an invalid value for 'children' prop for the screen '${name}'. It must be a function returning a React Element.`);
}
if (component !== undefined && !(0, _reactIs.isValidElementType)(component)) {
throw new Error(`Got an invalid value for 'component' prop for the screen '${name}'. It must be a valid React Component.`);
}
if (getComponent !== undefined && typeof getComponent !== 'function') {
throw new Error(`Got an invalid value for 'getComponent' prop for the screen '${name}'. It must be a function returning a React Component.`);
}
if (typeof component === 'function') {
if (component.name === 'component') {
// Inline anonymous functions passed in the `component` prop will have the name of the prop
// It's relatively safe to assume that it's not a component since it should also have PascalCase name
// We won't catch all scenarios here, but this should catch a good chunk of incorrect use.
console.warn(`Looks like you're passing an inline function for 'component' prop for the screen '${name}' (e.g. component={() => <SomeComponent />}). Passing an inline function will cause the component state to be lost on re-render and cause perf issues since it's re-created every render. You can pass the function as children to 'Screen' instead to achieve the desired behaviour.`);
} else if (/^[a-z]/.test(component.name)) {
console.warn(`Got a component with the name '${component.name}' for the screen '${name}'. React Components must start with an uppercase letter. If you're passing a regular function and not a component, pass it as children to 'Screen' instead. Otherwise capitalize your component's name.`);
}
}
} else {
throw new Error(`Couldn't find a 'component', 'getComponent' or 'children' prop for the screen '${name}'. This can happen if you passed 'undefined'. You likely forgot to export your component from the file it's defined in, or mixed up default import and named import when importing.`);
}
});
}
return configs;
};
/**
* Hook for building navigators.
*
* @param createRouter Factory method which returns router object.
* @param options Options object containing `children` and additional options for the router.
* @returns An object containing `state`, `navigation`, `descriptors` objects.
*/
function useNavigationBuilder(createRouter, options) {
const navigatorKey = (0, _useRegisterNavigator.default)();
const route = React.useContext(_NavigationRouteContext.default);
const {
children,
screenListeners,
...rest
} = options;
const {
current: router
} = React.useRef(createRouter({
...rest,
...(route !== null && route !== void 0 && route.params && route.params.state == null && route.params.initial !== false && typeof route.params.screen === 'string' ? {
initialRouteName: route.params.screen
} : null)
}));
const routeConfigs = getRouteConfigsFromChildren(children);
const screens = routeConfigs.reduce((acc, config) => {
if (config.props.name in acc) {
throw new Error(`A navigator cannot contain multiple 'Screen' components with the same name (found duplicate screen named '${config.props.name}')`);
}
acc[config.props.name] = config;
return acc;
}, {});
const routeNames = routeConfigs.map(config => config.props.name);
const routeKeyList = routeNames.reduce((acc, curr) => {
acc[curr] = screens[curr].keys.map(key => key ?? '').join(':');
return acc;
}, {});
const routeParamList = routeNames.reduce((acc, curr) => {
const {
initialParams
} = screens[curr].props;
acc[curr] = initialParams;
return acc;
}, {});
const routeGetIdList = routeNames.reduce((acc, curr) => Object.assign(acc, {
[curr]: screens[curr].props.getId
}), {});
if (!routeNames.length) {
throw new Error("Couldn't find any screens for the navigator. Have you defined any screens as its children?");
}
const isStateValid = React.useCallback(state => state.type === undefined || state.type === router.type, [router.type]);
const isStateInitialized = React.useCallback(state => state !== undefined && state.stale === false && isStateValid(state), [isStateValid]);
const {
state: currentState,
getState: getCurrentState,
setState: setCurrentState,
setKey,
getKey,
getIsInitial
} = React.useContext(_NavigationStateContext.default);
const stateCleanedUp = React.useRef(false);
const cleanUpState = React.useCallback(() => {
setCurrentState(undefined);
stateCleanedUp.current = true;
}, [setCurrentState]);
const setState = React.useCallback(state => {
if (stateCleanedUp.current) {
// State might have been already cleaned up due to unmount
// We do not want to expose API allowing to override this
// This would lead to old data preservation on main navigator unmount
return;
}
setCurrentState(state);
}, [setCurrentState]);
const [initializedState, isFirstStateInitialization] = React.useMemo(() => {
var _route$params4;
const initialRouteParamList = routeNames.reduce((acc, curr) => {
var _route$params, _route$params2, _route$params3;
const {
initialParams
} = screens[curr].props;
const initialParamsFromParams = (route === null || route === void 0 ? void 0 : (_route$params = route.params) === null || _route$params === void 0 ? void 0 : _route$params.state) == null && (route === null || route === void 0 ? void 0 : (_route$params2 = route.params) === null || _route$params2 === void 0 ? void 0 : _route$params2.initial) !== false && (route === null || route === void 0 ? void 0 : (_route$params3 = route.params) === null || _route$params3 === void 0 ? void 0 : _route$params3.screen) === curr ? route.params.params : undefined;
acc[curr] = initialParams !== undefined || initialParamsFromParams !== undefined ? {
...initialParams,
...initialParamsFromParams
} : undefined;
return acc;
}, {});
// If the current state isn't initialized on first render, we initialize it
// We also need to re-initialize it if the state passed from parent was changed (maybe due to reset)
// Otherwise assume that the state was provided as initial state
// So we need to rehydrate it to make it usable
if ((currentState === undefined || !isStateValid(currentState)) && (route === null || route === void 0 ? void 0 : (_route$params4 = route.params) === null || _route$params4 === void 0 ? void 0 : _route$params4.state) == null) {
return [router.getInitialState({
routeNames,
routeParamList: initialRouteParamList,
routeGetIdList
}), true];
} else {
var _route$params5;
return [router.getRehydratedState((route === null || route === void 0 ? void 0 : (_route$params5 = route.params) === null || _route$params5 === void 0 ? void 0 : _route$params5.state) ?? currentState, {
routeNames,
routeParamList: initialRouteParamList,
routeGetIdList
}), false];
}
// We explicitly don't include routeNames, route.params etc. in the dep list
// below. We want to avoid forcing a new state to be calculated in those cases
// Instead, we handle changes to these in the nextState code below. Note
// that some changes to routeConfigs are explicitly ignored, such as changes
// to initialParams
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentState, router, isStateValid]);
const previousRouteKeyListRef = React.useRef(routeKeyList);
React.useEffect(() => {
previousRouteKeyListRef.current = routeKeyList;
});
const previousRouteKeyList = previousRouteKeyListRef.current;
let state =
// If the state isn't initialized, or stale, use the state we initialized instead
// The state won't update until there's a change needed in the state we have initalized locally
// So it'll be `undefined` or stale until the first navigation event happens
isStateInitialized(currentState) ? currentState : initializedState;
let nextState = state;
if (!(0, _isArrayEqual.default)(state.routeNames, routeNames) || !(0, _isRecordEqual.default)(routeKeyList, previousRouteKeyList)) {
// When the list of route names change, the router should handle it to remove invalid routes
nextState = router.getStateForRouteNamesChange(state, {
routeNames,
routeParamList,
routeGetIdList,
routeKeyChanges: Object.keys(routeKeyList).filter(name => previousRouteKeyList.hasOwnProperty(name) && routeKeyList[name] !== previousRouteKeyList[name])
});
}
const previousNestedParamsRef = React.useRef(route === null || route === void 0 ? void 0 : route.params);
React.useEffect(() => {
previousNestedParamsRef.current = route === null || route === void 0 ? void 0 : route.params;
}, [route === null || route === void 0 ? void 0 : route.params]);
if (route !== null && route !== void 0 && route.params) {
const previousParams = previousNestedParamsRef.current;
let action;
if (typeof route.params.state === 'object' && route.params.state != null && route.params !== previousParams) {
// If the route was updated with new state, we should reset to it
action = _routers.CommonActions.reset(route.params.state);
} else if (typeof route.params.screen === 'string' && (route.params.initial === false && isFirstStateInitialization || route.params !== previousParams)) {
// If the route was updated with new screen name and/or params, we should navigate there
action = _routers.CommonActions.navigate({
name: route.params.screen,
params: route.params.params,
path: route.params.path
});
}
// The update should be limited to current navigator only, so we call the router manually
const updatedState = action ? router.getStateForAction(nextState, action, {
routeNames,
routeParamList,
routeGetIdList
}) : null;
nextState = updatedState !== null ? router.getRehydratedState(updatedState, {
routeNames,
routeParamList,
routeGetIdList
}) : nextState;
}
const shouldUpdate = state !== nextState;
(0, _useScheduleUpdate.default)(() => {
if (shouldUpdate) {
// If the state needs to be updated, we'll schedule an update
setState(nextState);
}
});
// The up-to-date state will come in next render, but we don't need to wait for it
// We can't use the outdated state since the screens have changed, which will cause error due to mismatched config
// So we override the state object we return to use the latest state as soon as possible
state = nextState;
React.useEffect(() => {
setKey(navigatorKey);
if (!getIsInitial()) {
// If it's not initial render, we need to update the state
// This will make sure that our container gets notifier of state changes due to new mounts
// This is necessary for proper screen tracking, URL updates etc.
setState(nextState);
}
return () => {
// We need to clean up state for this navigator on unmount
// We do it in a timeout because we need to detect if another navigator mounted in the meantime
// For example, if another navigator has started rendering, we should skip cleanup
// Otherwise, our cleanup step will cleanup state for the other navigator and re-initialize it
setTimeout(() => {
if (getCurrentState() !== undefined && getKey() === navigatorKey) {
cleanUpState();
}
}, 0);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
// We initialize this ref here to avoid a new getState getting initialized
// whenever initializedState changes. We want getState to have access to the
// latest initializedState, but don't need it to change when that happens
const initializedStateRef = React.useRef();
initializedStateRef.current = initializedState;
const getState = React.useCallback(() => {
const currentState = getCurrentState();
return isStateInitialized(currentState) ? currentState : initializedStateRef.current;
}, [getCurrentState, isStateInitialized]);
const emitter = (0, _useEventEmitter.default)(e => {
let routeNames = [];
let route;
if (e.target) {
var _route;
route = state.routes.find(route => route.key === e.target);
if ((_route = route) !== null && _route !== void 0 && _route.name) {
routeNames.push(route.name);
}
} else {
route = state.routes[state.index];
routeNames.push(...Object.keys(screens).filter(name => {
var _route2;
return ((_route2 = route) === null || _route2 === void 0 ? void 0 : _route2.name) === name;
}));
}
if (route == null) {
return;
}
const navigation = descriptors[route.key].navigation;
const listeners = [].concat(
// Get an array of listeners for all screens + common listeners on navigator
...[screenListeners, ...routeNames.map(name => {
const {
listeners
} = screens[name].props;
return listeners;
})].map(listeners => {
const map = typeof listeners === 'function' ? listeners({
route: route,
navigation
}) : listeners;
return map ? Object.keys(map).filter(type => type === e.type).map(type => map === null || map === void 0 ? void 0 : map[type]) : undefined;
}))
// We don't want same listener to be called multiple times for same event
// So we remove any duplicate functions from the array
.filter((cb, i, self) => cb && self.lastIndexOf(cb) === i);
listeners.forEach(listener => listener === null || listener === void 0 ? void 0 : listener(e));
});
(0, _useFocusEvents.default)({
state,
emitter
});
React.useEffect(() => {
emitter.emit({
type: 'state',
data: {
state
}
});
}, [emitter, state]);
const {
listeners: childListeners,
addListener
} = (0, _useChildListeners.default)();
const {
keyedListeners,
addKeyedListener
} = (0, _useKeyedChildListeners.default)();
const onAction = (0, _useOnAction.default)({
router,
getState,
setState,
key: route === null || route === void 0 ? void 0 : route.key,
actionListeners: childListeners.action,
beforeRemoveListeners: keyedListeners.beforeRemove,
routerConfigOptions: {
routeNames,
routeParamList,
routeGetIdList
},
emitter
});
const onRouteFocus = (0, _useOnRouteFocus.default)({
router,
key: route === null || route === void 0 ? void 0 : route.key,
getState,
setState
});
const navigation = (0, _useNavigationHelpers.default)({
id: options.id,
onAction,
getState,
emitter,
router
});
(0, _useFocusedListenersChildrenAdapter.default)({
navigation,
focusedListeners: childListeners.focus
});
(0, _useOnGetState.default)({
getState,
getStateListeners: keyedListeners.getState
});
const descriptors = (0, _useDescriptors.default)({
state,
screens,
navigation,
screenOptions: options.screenOptions,
defaultScreenOptions: options.defaultScreenOptions,
onAction,
getState,
setState,
onRouteFocus,
addListener,
addKeyedListener,
router,
// @ts-expect-error: this should have both core and custom events, but too much work right now
emitter
});
(0, _useCurrentRender.default)({
state,
navigation,
descriptors
});
const NavigationContent = (0, _useComponent.default)(children => /*#__PURE__*/React.createElement(_NavigationHelpersContext.default.Provider, {
value: navigation
}, /*#__PURE__*/React.createElement(_PreventRemoveProvider.default, null, children)));
return {
state,
navigation,
descriptors,
NavigationContent
};
}
//# sourceMappingURL=useNavigationBuilder.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,126 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useNavigationCache;
var _routers = require("@react-navigation/routers");
var React = _interopRequireWildcard(require("react"));
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
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; }
/**
* Hook to cache navigation objects for each screen in the navigator.
* It's important to cache them to make sure navigation objects don't change between renders.
* This lets us apply optimizations like `React.memo` to minimize re-rendering screens.
*/
function useNavigationCache(_ref) {
let {
state,
getState,
navigation,
setOptions,
router,
emitter
} = _ref;
const {
stackRef
} = React.useContext(_NavigationBuilderContext.default);
// Cache object which holds navigation objects for each screen
// We use `React.useMemo` instead of `React.useRef` coz we want to invalidate it when deps change
// In reality, these deps will rarely change, if ever
const cache = React.useMemo(() => ({
current: {}
}),
// eslint-disable-next-line react-hooks/exhaustive-deps
[getState, navigation, setOptions, router, emitter]);
const actions = {
...router.actionCreators,
..._routers.CommonActions
};
cache.current = state.routes.reduce((acc, route) => {
const previous = cache.current[route.key];
if (previous) {
// If a cached navigation object already exists, reuse it
acc[route.key] = previous;
} else {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const {
emit,
...rest
} = navigation;
const dispatch = thunk => {
const action = typeof thunk === 'function' ? thunk(getState()) : thunk;
if (action != null) {
navigation.dispatch({
source: route.key,
...action
});
}
};
const withStack = callback => {
let isStackSet = false;
try {
if (process.env.NODE_ENV !== 'production' && stackRef && !stackRef.current) {
// Capture the stack trace for devtools
stackRef.current = new Error().stack;
isStackSet = true;
}
callback();
} finally {
if (isStackSet && stackRef) {
stackRef.current = undefined;
}
}
};
const helpers = Object.keys(actions).reduce((acc, name) => {
acc[name] = function () {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return withStack(() =>
// @ts-expect-error: name is a valid key, but TypeScript is dumb
dispatch(actions[name](...args)));
};
return acc;
}, {});
acc[route.key] = {
...rest,
...helpers,
// FIXME: too much work to fix the types for now
...emitter.create(route.key),
dispatch: thunk => withStack(() => dispatch(thunk)),
getParent: id => {
if (id !== undefined && id === rest.getId()) {
// If the passed id is the same as the current navigation id,
// we return the cached navigation object for the relevant route
return acc[route.key];
}
return rest.getParent(id);
},
setOptions: options => setOptions(o => ({
...o,
[route.key]: {
...o[route.key],
...options
}
})),
isFocused: () => {
const state = getState();
if (state.routes[state.index].key !== route.key) {
return false;
}
// If the current screen is focused, we also need to check if parent navigator is focused
// This makes sure that we return the focus state in the whole tree, not just this navigator
return navigation ? navigation.isFocused() : true;
}
};
}
return acc;
}, {});
return cache.current;
}
//# sourceMappingURL=useNavigationCache.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useNavigationCache","state","getState","navigation","setOptions","router","emitter","stackRef","React","useContext","NavigationBuilderContext","cache","useMemo","current","actions","actionCreators","CommonActions","routes","reduce","acc","route","previous","key","emit","rest","dispatch","thunk","action","source","withStack","callback","isStackSet","process","env","NODE_ENV","Error","stack","undefined","helpers","Object","keys","name","args","create","getParent","id","getId","options","o","isFocused","index"],"sourceRoot":"../../src","sources":["useNavigationCache.tsx"],"mappings":";;;;;;AAAA;AAOA;AAEA;AAAkE;AAAA;AAAA;AAmClE;AACA;AACA;AACA;AACA;AACe,SAASA,kBAAkB,OAWb;EAAA,IAP3B;IACAC,KAAK;IACLC,QAAQ;IACRC,UAAU;IACVC,UAAU;IACVC,MAAM;IACNC;EACwB,CAAC;EACzB,MAAM;IAAEC;EAAS,CAAC,GAAGC,KAAK,CAACC,UAAU,CAACC,iCAAwB,CAAC;;EAE/D;EACA;EACA;EACA,MAAMC,KAAK,GAAGH,KAAK,CAACI,OAAO,CACzB,OAAO;IAAEC,OAAO,EAAE,CAAC;EAAqD,CAAC,CAAC;EAC1E;EAC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CAAC5B,GAAG,KAAKF,KAAK,CAACE,GAAG,EAAE;YAC/C,OAAO,KAAK;UACd;;UAEA;UACA;UACA,OAAOnB,UAAU,GAAGA,UAAU,CAAC8C,SAAS,EAAE,GAAG,IAAI;QACnD;MACF,CAAC;IACH;IAEA,OAAO9B,GAAG;EACZ,CAAC,EAAE,CAAC,CAAC,CAAC;EAEN,OAAOR,KAAK,CAACE,OAAO;AACtB"}

View File

@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useNavigationContainerRef;
var React = _interopRequireWildcard(require("react"));
var _createNavigationContainerRef = _interopRequireDefault(require("./createNavigationContainerRef"));
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 useNavigationContainerRef() {
const navigation = React.useRef(null);
if (navigation.current == null) {
navigation.current = (0, _createNavigationContainerRef.default)();
}
return navigation.current;
}
//# sourceMappingURL=useNavigationContainerRef.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useNavigationContainerRef","navigation","React","useRef","current","createNavigationContainerRef"],"sourceRoot":"../../src","sources":["useNavigationContainerRef.tsx"],"mappings":";;;;;;AAAA;AAEA;AAA0E;AAAA;AAAA;AAG3D,SAASA,yBAAyB,GAEC;EAChD,MAAMC,UAAU,GACdC,KAAK,CAACC,MAAM,CAAsD,IAAI,CAAC;EAEzE,IAAIF,UAAU,CAACG,OAAO,IAAI,IAAI,EAAE;IAC9BH,UAAU,CAACG,OAAO,GAAG,IAAAC,qCAA4B,GAAa;EAChE;EAEA,OAAOJ,UAAU,CAACG,OAAO;AAC3B"}

View File

@@ -0,0 +1,81 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useNavigationHelpers;
var _routers = require("@react-navigation/routers");
var React = _interopRequireWildcard(require("react"));
var _NavigationContext = _interopRequireDefault(require("./NavigationContext"));
var _types = require("./types");
var _UnhandledActionContext = _interopRequireDefault(require("./UnhandledActionContext"));
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; }
// This is to make TypeScript compiler happy
// eslint-disable-next-line babel/no-unused-expressions
_types.PrivateValueStore;
/**
* Navigation object with helper methods to be used by a navigator.
* This object includes methods for common actions as well as methods the parent screen's navigation object.
*/
function useNavigationHelpers(_ref) {
let {
id: navigatorId,
onAction,
getState,
emitter,
router
} = _ref;
const onUnhandledAction = React.useContext(_UnhandledActionContext.default);
const parentNavigationHelpers = React.useContext(_NavigationContext.default);
return React.useMemo(() => {
const dispatch = op => {
const action = typeof op === 'function' ? op(getState()) : op;
const handled = onAction(action);
if (!handled) {
onUnhandledAction === null || onUnhandledAction === void 0 ? void 0 : onUnhandledAction(action);
}
};
const actions = {
...router.actionCreators,
..._routers.CommonActions
};
const helpers = Object.keys(actions).reduce((acc, name) => {
// @ts-expect-error: name is a valid key, but TypeScript is dumb
acc[name] = function () {
return dispatch(actions[name](...arguments));
};
return acc;
}, {});
const navigationHelpers = {
...parentNavigationHelpers,
...helpers,
dispatch,
emit: emitter.emit,
isFocused: parentNavigationHelpers ? parentNavigationHelpers.isFocused : () => true,
canGoBack: () => {
const state = getState();
return router.getStateForAction(state, _routers.CommonActions.goBack(), {
routeNames: state.routeNames,
routeParamList: {},
routeGetIdList: {}
}) !== null || (parentNavigationHelpers === null || parentNavigationHelpers === void 0 ? void 0 : parentNavigationHelpers.canGoBack()) || false;
},
getId: () => navigatorId,
getParent: id => {
if (id !== undefined) {
let current = navigationHelpers;
while (current && id !== current.getId()) {
current = current.getParent();
}
return current;
}
return parentNavigationHelpers;
},
getState
};
return navigationHelpers;
}, [navigatorId, emitter.emit, getState, onAction, onUnhandledAction, parentNavigationHelpers, router]);
}
//# sourceMappingURL=useNavigationHelpers.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["PrivateValueStore","useNavigationHelpers","id","navigatorId","onAction","getState","emitter","router","onUnhandledAction","React","useContext","UnhandledActionContext","parentNavigationHelpers","NavigationContext","useMemo","dispatch","op","action","handled","actions","actionCreators","CommonActions","helpers","Object","keys","reduce","acc","name","navigationHelpers","emit","isFocused","canGoBack","state","getStateForAction","goBack","routeNames","routeParamList","routeGetIdList","getId","getParent","undefined","current"],"sourceRoot":"../../src","sources":["useNavigationHelpers.tsx"],"mappings":";;;;;;AAAA;AAOA;AAEA;AACA;AACA;AAA8D;AAAA;AAAA;AAG9D;AACA;AACAA,wBAAiB;AAUjB;AACA;AACA;AACA;AACe,SAASC,oBAAoB,OAWjB;EAAA,IANzB;IACAC,EAAE,EAAEC,WAAW;IACfC,QAAQ;IACRC,QAAQ;IACRC,OAAO;IACPC;EACsB,CAAC;EACvB,MAAMC,iBAAiB,GAAGC,KAAK,CAACC,UAAU,CAACC,+BAAsB,CAAC;EAClE,MAAMC,uBAAuB,GAAGH,KAAK,CAACC,UAAU,CAACG,0BAAiB,CAAC;EAEnE,OAAOJ,KAAK,CAACK,OAAO,CAAC,MAAM;IACzB,MAAMC,QAAQ,GAAIC,EAAuC,IAAK;MAC5D,MAAMC,MAAM,GAAG,OAAOD,EAAE,KAAK,UAAU,GAAGA,EAAE,CAACX,QAAQ,EAAE,CAAC,GAAGW,EAAE;MAE7D,MAAME,OAAO,GAAGd,QAAQ,CAACa,MAAM,CAAC;MAEhC,IAAI,CAACC,OAAO,EAAE;QACZV,iBAAiB,aAAjBA,iBAAiB,uBAAjBA,iBAAiB,CAAGS,MAAM,CAAC;MAC7B;IACF,CAAC;IAED,MAAME,OAAO,GAAG;MACd,GAAGZ,MAAM,CAACa,cAAc;MACxB,GAAGC;IACL,CAAC;IAED,MAAMC,OAAO,GAAGC,MAAM,CAACC,IAAI,CAACL,OAAO,CAAC,CAACM,MAAM,CAAC,CAACC,GAAG,EAAEC,IAAI,KAAK;MACzD;MACAD,GAAG,CAACC,IAAI,CAAC,GAAG;QAAA,OAAkBZ,QAAQ,CAACI,OAAO,CAACQ,IAAI,CAAC,CAAC,YAAO,CAAC,CAAC;MAAA;MAC9D,OAAOD,GAAG;IACZ,CAAC,EAAE,CAAC,CAAC,CAAkB;IAEvB,MAAME,iBAAiB,GAAG;MACxB,GAAGhB,uBAAuB;MAC1B,GAAGU,OAAO;MACVP,QAAQ;MACRc,IAAI,EAAEvB,OAAO,CAACuB,IAAI;MAClBC,SAAS,EAAElB,uBAAuB,GAC9BA,uBAAuB,CAACkB,SAAS,GACjC,MAAM,IAAI;MACdC,SAAS,EAAE,MAAM;QACf,MAAMC,KAAK,GAAG3B,QAAQ,EAAE;QAExB,OACEE,MAAM,CAAC0B,iBAAiB,CAACD,KAAK,EAAEX,sBAAa,CAACa,MAAM,EAAE,EAAY;UAChEC,UAAU,EAAEH,KAAK,CAACG,UAAU;UAC5BC,cAAc,EAAE,CAAC,CAAC;UAClBC,cAAc,EAAE,CAAC;QACnB,CAAC,CAAC,KAAK,IAAI,KACXzB,uBAAuB,aAAvBA,uBAAuB,uBAAvBA,uBAAuB,CAAEmB,SAAS,EAAE,KACpC,KAAK;MAET,CAAC;MACDO,KAAK,EAAE,MAAMnC,WAAW;MACxBoC,SAAS,EAAGrC,EAAW,IAAK;QAC1B,IAAIA,EAAE,KAAKsC,SAAS,EAAE;UACpB,IAAIC,OAAO,GAAGb,iBAAiB;UAE/B,OAAOa,OAAO,IAAIvC,EAAE,KAAKuC,OAAO,CAACH,KAAK,EAAE,EAAE;YACxCG,OAAO,GAAGA,OAAO,CAACF,SAAS,EAAE;UAC/B;UAEA,OAAOE,OAAO;QAChB;QAEA,OAAO7B,uBAAuB;MAChC,CAAC;MACDP;IACF,CAA+D;IAE/D,OAAOuB,iBAAiB;EAC1B,CAAC,EAAE,CACDzB,WAAW,EACXG,OAAO,CAACuB,IAAI,EACZxB,QAAQ,EACRD,QAAQ,EACRI,iBAAiB,EACjBI,uBAAuB,EACvBL,MAAM,CACP,CAAC;AACJ"}

View File

@@ -0,0 +1,37 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useNavigationState;
var React = _interopRequireWildcard(require("react"));
var _useNavigation = _interopRequireDefault(require("./useNavigation"));
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; }
/**
* Hook to get a value from the current navigation state using a selector.
*
* @param selector Selector function to get a value from the state.
*/
function useNavigationState(selector) {
const navigation = (0, _useNavigation.default)();
// We don't care about the state value, we run the selector again at the end
// The state is only to make sure that there's a re-render when we have a new value
const [, setResult] = React.useState(() => selector(navigation.getState()));
// We store the selector in a ref to avoid re-subscribing listeners every render
const selectorRef = React.useRef(selector);
React.useEffect(() => {
selectorRef.current = selector;
});
React.useEffect(() => {
const unsubscribe = navigation.addListener('state', e => {
setResult(selectorRef.current(e.data.state));
});
return unsubscribe;
}, [navigation]);
return selector(navigation.getState());
}
//# sourceMappingURL=useNavigationState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useNavigationState","selector","navigation","useNavigation","setResult","React","useState","getState","selectorRef","useRef","useEffect","current","unsubscribe","addListener","e","data","state"],"sourceRoot":"../../src","sources":["useNavigationState.tsx"],"mappings":";;;;;;AACA;AAGA;AAA4C;AAAA;AAAA;AAM5C;AACA;AACA;AACA;AACA;AACe,SAASA,kBAAkB,CACxCC,QAAgC,EAC7B;EACH,MAAMC,UAAU,GAAG,IAAAC,sBAAa,GAA6B;;EAE7D;EACA;EACA,MAAM,GAAGC,SAAS,CAAC,GAAGC,KAAK,CAACC,QAAQ,CAAC,MAAML,QAAQ,CAACC,UAAU,CAACK,QAAQ,EAAE,CAAC,CAAC;;EAE3E;EACA,MAAMC,WAAW,GAAGH,KAAK,CAACI,MAAM,CAACR,QAAQ,CAAC;EAE1CI,KAAK,CAACK,SAAS,CAAC,MAAM;IACpBF,WAAW,CAACG,OAAO,GAAGV,QAAQ;EAChC,CAAC,CAAC;EAEFI,KAAK,CAACK,SAAS,CAAC,MAAM;IACpB,MAAME,WAAW,GAAGV,UAAU,CAACW,WAAW,CAAC,OAAO,EAAGC,CAAC,IAAK;MACzDV,SAAS,CAACI,WAAW,CAACG,OAAO,CAACG,CAAC,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC;IAC9C,CAAC,CAAC;IAEF,OAAOJ,WAAW;EACpB,CAAC,EAAE,CAACV,UAAU,CAAC,CAAC;EAEhB,OAAOD,QAAQ,CAACC,UAAU,CAACK,QAAQ,EAAE,CAAC;AACxC"}

View File

@@ -0,0 +1,103 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useOnAction;
var React = _interopRequireWildcard(require("react"));
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
var _useOnPreventRemove = _interopRequireWildcard(require("./useOnPreventRemove"));
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; }
/**
* Hook to handle actions for a navigator, including state updates and bubbling.
*
* Bubbling an action is achieved in 2 ways:
* 1. To bubble action to parent, we expose the action handler in context and then access the parent context
* 2. To bubble action to child, child adds event listeners subscribing to actions from parent
*
* When the action handler handles as action, it returns `true`, otherwise `false`.
*/
function useOnAction(_ref) {
let {
router,
getState,
setState,
key,
actionListeners,
beforeRemoveListeners,
routerConfigOptions,
emitter
} = _ref;
const {
onAction: onActionParent,
onRouteFocus: onRouteFocusParent,
addListener: addListenerParent,
onDispatchAction
} = React.useContext(_NavigationBuilderContext.default);
const routerConfigOptionsRef = React.useRef(routerConfigOptions);
React.useEffect(() => {
routerConfigOptionsRef.current = routerConfigOptions;
});
const onAction = React.useCallback(function (action) {
let visitedNavigators = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : new Set();
const state = getState();
// Since actions can bubble both up and down, they could come to the same navigator again
// We keep track of navigators which have already tried to handle the action and return if it's already visited
if (visitedNavigators.has(state.key)) {
return false;
}
visitedNavigators.add(state.key);
if (typeof action.target !== 'string' || action.target === state.key) {
let result = router.getStateForAction(state, action, routerConfigOptionsRef.current);
// If a target is specified and set to current navigator, the action shouldn't bubble
// So instead of `null`, we use the state object for such cases to signal that action was handled
result = result === null && action.target === state.key ? state : result;
if (result !== null) {
onDispatchAction(action, state === result);
if (state !== result) {
const isPrevented = (0, _useOnPreventRemove.shouldPreventRemove)(emitter, beforeRemoveListeners, state.routes, result.routes, action);
if (isPrevented) {
return true;
}
setState(result);
}
if (onRouteFocusParent !== undefined) {
// Some actions such as `NAVIGATE` also want to bring the navigated route to focus in the whole tree
// This means we need to focus all of the parent navigators of this navigator as well
const shouldFocus = router.shouldActionChangeFocus(action);
if (shouldFocus && key !== undefined) {
onRouteFocusParent(key);
}
}
return true;
}
}
if (onActionParent !== undefined) {
// Bubble action to the parent if the current navigator didn't handle it
if (onActionParent(action, visitedNavigators)) {
return true;
}
}
// If the action wasn't handled by current navigator or a parent navigator, let children handle it
for (let i = actionListeners.length - 1; i >= 0; i--) {
const listener = actionListeners[i];
if (listener(action, visitedNavigators)) {
return true;
}
}
return false;
}, [actionListeners, beforeRemoveListeners, emitter, getState, key, onActionParent, onDispatchAction, onRouteFocusParent, router, setState]);
(0, _useOnPreventRemove.default)({
getState,
emitter,
beforeRemoveListeners
});
React.useEffect(() => addListenerParent === null || addListenerParent === void 0 ? void 0 : addListenerParent('action', onAction), [addListenerParent, onAction]);
return onAction;
}
//# sourceMappingURL=useOnAction.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useOnAction","router","getState","setState","key","actionListeners","beforeRemoveListeners","routerConfigOptions","emitter","onAction","onActionParent","onRouteFocus","onRouteFocusParent","addListener","addListenerParent","onDispatchAction","React","useContext","NavigationBuilderContext","routerConfigOptionsRef","useRef","useEffect","current","useCallback","action","visitedNavigators","Set","state","has","add","target","result","getStateForAction","isPrevented","shouldPreventRemove","routes","undefined","shouldFocus","shouldActionChangeFocus","i","length","listener","useOnPreventRemove"],"sourceRoot":"../../src","sources":["useOnAction.tsx"],"mappings":";;;;;;AAOA;AAEA;AAMA;AAA+E;AAAA;AAAA;AAa/E;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACe,SAASA,WAAW,OASvB;EAAA,IATwB;IAClCC,MAAM;IACNC,QAAQ;IACRC,QAAQ;IACRC,GAAG;IACHC,eAAe;IACfC,qBAAqB;IACrBC,mBAAmB;IACnBC;EACO,CAAC;EACR,MAAM;IACJC,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@@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useOnGetState;
var React = _interopRequireWildcard(require("react"));
var _isArrayEqual = _interopRequireDefault(require("./isArrayEqual"));
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
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 useOnGetState(_ref) {
let {
getState,
getStateListeners
} = _ref;
const {
addKeyedListener
} = React.useContext(_NavigationBuilderContext.default);
const route = React.useContext(_NavigationRouteContext.default);
const key = route ? route.key : 'root';
const getRehydratedState = React.useCallback(() => {
const state = getState();
// Avoid returning new route objects if we don't need to
const routes = state.routes.map(route => {
var _getStateListeners$ro;
const childState = (_getStateListeners$ro = getStateListeners[route.key]) === null || _getStateListeners$ro === void 0 ? void 0 : _getStateListeners$ro.call(getStateListeners);
if (route.state === childState) {
return route;
}
return {
...route,
state: childState
};
});
if ((0, _isArrayEqual.default)(state.routes, routes)) {
return state;
}
return {
...state,
routes
};
}, [getState, getStateListeners]);
React.useEffect(() => {
return addKeyedListener === null || addKeyedListener === void 0 ? void 0 : addKeyedListener('getState', key, getRehydratedState);
}, [addKeyedListener, getRehydratedState, key]);
}
//# sourceMappingURL=useOnGetState.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["useOnGetState","getState","getStateListeners","addKeyedListener","React","useContext","NavigationBuilderContext","route","NavigationRouteContext","key","getRehydratedState","useCallback","state","routes","map","childState","isArrayEqual","useEffect"],"sourceRoot":"../../src","sources":["useOnGetState.tsx"],"mappings":";;;;;;AACA;AAEA;AACA;AAGA;AAA8D;AAAA;AAAA;AAO/C,SAASA,aAAa,OAGzB;EAAA,IAH0B;IACpCC,QAAQ;IACRC;EACO,CAAC;EACR,MAAM;IAAEC;EAAiB,CAAC,GAAGC,KAAK,CAACC,UAAU,CAACC,iCAAwB,CAAC;EACvE,MAAMC,KAAK,GAAGH,KAAK,CAACC,UAAU,CAACG,+BAAsB,CAAC;EACtD,MAAMC,GAAG,GAAGF,KAAK,GAAGA,KAAK,CAACE,GAAG,GAAG,MAAM;EAEtC,MAAMC,kBAAkB,GAAGN,KAAK,CAACO,WAAW,CAAC,MAAM;IACjD,MAAMC,KAAK,GAAGX,QAAQ,EAAE;;IAExB;IACA,MAAMY,MAAM,GAAGD,KAAK,CAACC,MAAM,CAACC,GAAG,CAAEP,KAAK,IAAK;MAAA;MACzC,MAAMQ,UAAU,4BAAGb,iBAAiB,CAACK,KAAK,CAACE,GAAG,CAAC,0DAA5B,2BAAAP,iBAAiB,CAAe;MAEnD,IAAIK,KAAK,CAACK,KAAK,KAAKG,UAAU,EAAE;QAC9B,OAAOR,KAAK;MACd;MAEA,OAAO;QAAE,GAAGA,KAAK;QAAEK,KAAK,EAAEG;MAAW,CAAC;IACxC,CAAC,CAAC;IAEF,IAAI,IAAAC,qBAAY,EAACJ,KAAK,CAACC,MAAM,EAAEA,MAAM,CAAC,EAAE;MACtC,OAAOD,KAAK;IACd;IAEA,OAAO;MAAE,GAAGA,KAAK;MAAEC;IAAO,CAAC;EAC7B,CAAC,EAAE,CAACZ,QAAQ,EAAEC,iBAAiB,CAAC,CAAC;EAEjCE,KAAK,CAACa,SAAS,CAAC,MAAM;IACpB,OAAOd,gBAAgB,aAAhBA,gBAAgB,uBAAhBA,gBAAgB,CAAG,UAAU,EAAEM,GAAG,EAAEC,kBAAkB,CAAC;EAChE,CAAC,EAAE,CAACP,gBAAgB,EAAEO,kBAAkB,EAAED,GAAG,CAAC,CAAC;AACjD"}

View File

@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = useOnPreventRemove;
exports.shouldPreventRemove = void 0;
var React = _interopRequireWildcard(require("react"));
var _NavigationBuilderContext = _interopRequireDefault(require("./NavigationBuilderContext"));
var _NavigationRouteContext = _interopRequireDefault(require("./NavigationRouteContext"));
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 VISITED_ROUTE_KEYS = Symbol('VISITED_ROUTE_KEYS');
const shouldPreventRemove = (emitter, beforeRemoveListeners, currentRoutes, nextRoutes, action) => {
const nextRouteKeys = nextRoutes.map(route => route.key);
// Call these in reverse order so last screens handle the event first
const removedRoutes = currentRoutes.filter(route => !nextRouteKeys.includes(route.key)).reverse();
const visitedRouteKeys =
// @ts-expect-error: add this property to mark that we've already emitted this action
action[VISITED_ROUTE_KEYS] ?? new Set();
const beforeRemoveAction = {
...action,
[VISITED_ROUTE_KEYS]: visitedRouteKeys
};
for (const route of removedRoutes) {
var _beforeRemoveListener;
if (visitedRouteKeys.has(route.key)) {
// Skip if we've already emitted this action for this screen
continue;
}
// First, we need to check if any child screens want to prevent it
const isPrevented = (_beforeRemoveListener = beforeRemoveListeners[route.key]) === null || _beforeRemoveListener === void 0 ? void 0 : _beforeRemoveListener.call(beforeRemoveListeners, beforeRemoveAction);
if (isPrevented) {
return true;
}
visitedRouteKeys.add(route.key);
const event = emitter.emit({
type: 'beforeRemove',
target: route.key,
data: {
action: beforeRemoveAction
},
canPreventDefault: true
});
if (event.defaultPrevented) {
return true;
}
}
return false;
};
exports.shouldPreventRemove = shouldPreventRemove;
function useOnPreventRemove(_ref) {
let {
getState,
emitter,
beforeRemoveListeners
} = _ref;
const {
addKeyedListener
} = React.useContext(_NavigationBuilderContext.default);
const route = React.useContext(_NavigationRouteContext.default);
const routeKey = route === null || route === void 0 ? void 0 : route.key;
React.useEffect(() => {
if (routeKey) {
return addKeyedListener === null || addKeyedListener === void 0 ? void 0 : addKeyedListener('beforeRemove', routeKey, action => {
const state = getState();
return shouldPreventRemove(emitter, beforeRemoveListeners, state.routes, [], action);
});
}
}, [addKeyedListener, beforeRemoveListeners, emitter, getState, routeKey]);
}
//# sourceMappingURL=useOnPreventRemove.js.map

View File

@@ -0,0 +1 @@
{"version":3,"names":["VISITED_ROUTE_KEYS","Symbol","shouldPreventRemove","emitter","beforeRemoveListeners","currentRoutes","nextRoutes","action","nextRouteKeys","map","route","key","removedRoutes","filter","includes","reverse","visitedRouteKeys","Set","beforeRemoveAction","has","isPrevented","add","event","emit","type","target","data","canPreventDefault","defaultPrevented","useOnPreventRemove","getState","addKeyedListener","React","useContext","NavigationBuilderContext","NavigationRouteContext","routeKey","useEffect","state","routes"],"sourceRoot":"../../src","sources":["useOnPreventRemove.tsx"],"mappings":";;;;;;;AAIA;AAEA;AAGA;AAA8D;AAAA;AAAA;AAU9D,MAAMA,kBAAkB,GAAGC,MAAM,CAAC,oBAAoB,CAAC;AAEhD,MAAMC,mBAAmB,GAAG,CACjCC,OAAkD,EAClDC,qBAA4E,EAC5EC,aAAgC,EAChCC,UAA0C,EAC1CC,MAAwB,KACrB;EACH,MAAMC,aAAa,GAAGF,UAAU,CAACG,GAAG,CAAEC,KAAK,IAAKA,KAAK,CAACC,GAAG,CAAC;;EAE1D;EACA,MAAMC,aAAa,GAAGP,aAAa,CAChCQ,MAAM,CAAEH,KAAK,IAAK,CAACF,aAAa,CAACM,QAAQ,CAACJ,KAAK,CAACC,GAAG,CAAC,CAAC,CACrDI,OAAO,EAAE;EAEZ,MAAMC,gBAA6B;EACjC;EACAT,MAAM,CAACP,kBAAkB,CAAC,IAAI,IAAIiB,GAAG,EAAU;EAEjD,MAAMC,kBAAkB,GAAG;IACzB,GAAGX,MAAM;IACT,CAACP,kBAAkB,GAAGgB;EACxB,CAAC;EAED,KAAK,MAAMN,KAAK,IAAIE,aAAa,EAAE;IAAA;IACjC,IAAII,gBAAgB,CAACG,GAAG,CAACT,KAAK,CAACC,GAAG,CAAC,EAAE;MACnC;MACA;IACF;;IAEA;IACA,MAAMS,WAAW,4BAAGhB,qBAAqB,CAACM,KAAK,CAACC,GAAG,CAAC,0DAAhC,2BAAAP,qBAAqB,EAAcc,kBAAkB,CAAC;IAE1E,IAAIE,WAAW,EAAE;MACf,OAAO,IAAI;IACb;IAEAJ,gBAAgB,CAACK,GAAG,CAACX,KAAK,CAACC,GAAG,CAAC;IAE/B,MAAMW,KAAK,GAAGnB,OAA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