273 lines
8.8 KiB
React
273 lines
8.8 KiB
React
// Metro module 1493 (f1494).
|
|
import _objectWithoutProperties from "./_objectWithoutProperties";
|
|
import { forwardRef, useContext, useRef, useCallback, useMemo, useImperativeHandle, useEffect } from "react";
|
|
import Module1494 from "./Module1494";
|
|
import useSyncState from "./useSyncState";
|
|
import useChildListeners from "./useChildListeners";
|
|
import useKeyedChildListeners from "./useKeyedChildListeners";
|
|
import { NOT_INITIALIZED_ERROR } from "./createNavigationContainerRef";
|
|
import { CommonActions } from "./Module1485";
|
|
import findFocusedRoute from "./findFocusedRoute";
|
|
import useEventEmitter from "./useEventEmitter";
|
|
import useOptionsGetters from "./useOptionsGetters";
|
|
import Module1503 from "./Module1503";
|
|
import { ScheduleUpdateContext } from "./useScheduleUpdate";
|
|
import Module1502 from "./Module1502";
|
|
import Module1505 from "./Module1505";
|
|
import EnsureSingleNavigator from "./EnsureSingleNavigator";
|
|
import Module1507 from "./Module1507";
|
|
import Module1508 from "./Module1508";
|
|
import { HermesBuiltin } from "../_hermes/prelude";
|
|
function $mk69297($env) {
|
|
return (a0) => {
|
|
const state = a0.state;
|
|
let r1 = a0;
|
|
if (state !== void 0) {
|
|
const r5 = $env;
|
|
const r12 = r5[8];
|
|
const state2 = a0.state;
|
|
if (typeof r12 !== "function") {
|
|
HermesBuiltin.throwTypeError("Trying to call a non-function");
|
|
}
|
|
let state3 = void 0;
|
|
if (state2 !== void 0) {
|
|
state2.key;
|
|
state2.routeNames;
|
|
state3 = {
|
|
...(0, r5[5])(state2, r5[3]),
|
|
stale: true,
|
|
routes: state2.routes.map($mk69297(r5))
|
|
};
|
|
}
|
|
r1 = {
|
|
...a0,
|
|
state: state3
|
|
};
|
|
}
|
|
return r1;
|
|
};
|
|
}
|
|
let env1202 = {};
|
|
const _excluded = ["key", "routeNames"];
|
|
const getPartialState = (a0) => {};
|
|
export default forwardRef(function BaseNavigationContainer(props, a1) {
|
|
let state, getState2, setState, scheduleUpdate, flushUpdates, ref, ref2, callback, callback2, listeners, addListener, keyedListeners, addKeyedListener, callback3, callback4, callback5, callback6, callback7, c13067_20, addOptionsGetter, getCurrentOptions, memo, callback8, ref3, callback9, ref4, ref5, callback10, ref6, ref7;
|
|
const { initialState, onStateChange } = props;
|
|
let onUnhandledAction = props.onUnhandledAction;
|
|
const { independent, children } = props;
|
|
state = void 0;
|
|
getState2 = void 0;
|
|
setState = void 0;
|
|
scheduleUpdate = void 0;
|
|
flushUpdates = void 0;
|
|
ref = void 0;
|
|
ref2 = void 0;
|
|
callback = void 0;
|
|
callback2 = void 0;
|
|
listeners = void 0;
|
|
addListener = void 0;
|
|
keyedListeners = void 0;
|
|
addKeyedListener = void 0;
|
|
callback3 = void 0;
|
|
callback4 = void 0;
|
|
callback5 = void 0;
|
|
callback6 = void 0;
|
|
callback7 = void 0;
|
|
c13067_20 = void 0;
|
|
addOptionsGetter = void 0;
|
|
getCurrentOptions = void 0;
|
|
memo = void 0;
|
|
callback8 = void 0;
|
|
ref3 = void 0;
|
|
callback9 = void 0;
|
|
ref4 = void 0;
|
|
ref5 = void 0;
|
|
callback10 = void 0;
|
|
ref6 = void 0;
|
|
ref7 = void 0;
|
|
if (!useContext(Module1494).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.");
|
|
}
|
|
[state, getState2, setState, scheduleUpdate, flushUpdates] = useSyncState(() => {
|
|
const r4 = env1202;
|
|
const r5 = initialState == null ? void 0 : initialState;
|
|
let r13 = void 0;
|
|
if (r5 !== void 0) {
|
|
r5.key;
|
|
r5.routeNames;
|
|
r13 = {
|
|
..._objectWithoutProperties(r5, _excluded),
|
|
stale: true,
|
|
routes: r5.routes.map($mk69297(r4))
|
|
};
|
|
}
|
|
return r13;
|
|
});
|
|
ref = useRef(true);
|
|
ref2 = useRef();
|
|
callback = useCallback(() => ref2.current, []);
|
|
callback2 = useCallback((a0) => {
|
|
ref2.current = a0;
|
|
}, []);
|
|
const childListeners = useChildListeners();
|
|
listeners = childListeners.listeners;
|
|
addListener = childListeners.addListener;
|
|
const keyedChildListeners = useKeyedChildListeners();
|
|
keyedListeners = keyedChildListeners.keyedListeners;
|
|
addKeyedListener = keyedChildListeners.addKeyedListener;
|
|
callback3 = useCallback((c24439_0) => {
|
|
if (listeners.focus[0] == null) {
|
|
console.error(NOT_INITIALIZED_ERROR);
|
|
} else {
|
|
listeners.focus[0]((a0) => a0.dispatch(c24439_0));
|
|
}
|
|
}, [listeners.focus]);
|
|
callback4 = useCallback(() => {
|
|
if (listeners.focus[0] == null) {
|
|
return false;
|
|
}
|
|
const r9 = listeners.focus[0]((a0) => a0.canGoBack());
|
|
const result = r9.result;
|
|
return !!r9.handled && result;
|
|
}, [listeners.focus]);
|
|
callback5 = useCallback((a0) => {
|
|
let c24440_0 = a0;
|
|
let r6 = a0?.key;
|
|
if (r6 == null) {
|
|
const getState3 = keyedListeners.getState;
|
|
const root = getState3.root;
|
|
r6 = root == null ? void 0 : root.call(getState3).key;
|
|
}
|
|
const key = r6;
|
|
if (key == null) {
|
|
console.error(NOT_INITIALIZED_ERROR);
|
|
} else {
|
|
listeners.focus[0]((a0) => a0.dispatch.call(a0, {
|
|
...CommonActions.reset(c24440_0),
|
|
target: key
|
|
}));
|
|
}
|
|
}, [keyedListeners.getState, listeners.focus]);
|
|
callback6 = useCallback(() => {
|
|
const getState3 = keyedListeners.getState;
|
|
const root = getState3.root;
|
|
return root == null ? void 0 : root.call(getState3);
|
|
}, [keyedListeners.getState]);
|
|
callback7 = useCallback(() => {
|
|
const r3 = callback6();
|
|
if (r3 != null) {
|
|
return findFocusedRoute(r3);
|
|
}
|
|
}, [callback6]);
|
|
const eventEmitter = useEventEmitter();
|
|
c13067_20 = eventEmitter;
|
|
const optionsGetters = useOptionsGetters({});
|
|
addOptionsGetter = optionsGetters.addOptionsGetter;
|
|
getCurrentOptions = optionsGetters.getCurrentOptions;
|
|
memo = useMemo(() => ({
|
|
...Object.keys(CommonActions).reduce((acc, item) => {
|
|
acc[item] = function() {
|
|
return callback3(CommonActions[item].apply(CommonActions, [...Array.prototype.slice.call(arguments, 0)]));
|
|
};
|
|
return acc;
|
|
}, {}),
|
|
...c13067_20.create("root"),
|
|
dispatch: callback3,
|
|
resetRoot: callback5,
|
|
isFocused: () => true,
|
|
canGoBack: callback4,
|
|
getParent: () => {},
|
|
getState: () => ref7.current,
|
|
getRootState: callback6,
|
|
getCurrentRoute: callback7,
|
|
getCurrentOptions,
|
|
isReady: () => listeners.focus[0] != null
|
|
}), [callback4, callback3, eventEmitter, getCurrentOptions, callback7, callback6, listeners.focus, callback5]);
|
|
useImperativeHandle(a1, () => memo, [memo]);
|
|
callback8 = useCallback((a0, a1) => {
|
|
c13067_20.emit({
|
|
type: "__unsafe_action__",
|
|
data: {
|
|
action: a0,
|
|
noop: a1,
|
|
stack: ref4.current
|
|
}
|
|
});
|
|
}, [eventEmitter]);
|
|
ref3 = useRef();
|
|
callback9 = useCallback((a0) => {
|
|
if (ref3.current !== a0) {
|
|
ref3.current = a0;
|
|
c13067_20.emit({
|
|
type: "options",
|
|
data: {
|
|
options: a0
|
|
}
|
|
});
|
|
}
|
|
}, [eventEmitter]);
|
|
ref4 = useRef();
|
|
const memo2 = useMemo(() => ({
|
|
addListener,
|
|
addKeyedListener,
|
|
onDispatchAction: callback8,
|
|
onOptionsChange: callback9,
|
|
stackRef: ref4
|
|
}), [addListener, addKeyedListener, callback8, callback9]);
|
|
const memo3 = useMemo(() => ({
|
|
scheduleUpdate,
|
|
flushUpdates
|
|
}), [scheduleUpdate, flushUpdates]);
|
|
ref5 = useRef(true);
|
|
callback10 = useCallback(() => ref5.current, []);
|
|
const memo4 = useMemo(() => ({
|
|
state,
|
|
getState: getState2,
|
|
setState,
|
|
getKey: callback,
|
|
setKey: callback2,
|
|
getIsInitial: callback10,
|
|
addOptionsGetter
|
|
}), [state, getState2, setState, callback, callback2, callback10, addOptionsGetter]);
|
|
ref6 = useRef(onStateChange);
|
|
ref7 = useRef(state);
|
|
useEffect(() => {
|
|
ref5.current = false;
|
|
ref6.current = onStateChange;
|
|
ref7.current = state;
|
|
});
|
|
useEffect(() => {
|
|
const r5 = callback6();
|
|
c13067_20.emit({
|
|
type: "state",
|
|
data: {
|
|
state
|
|
}
|
|
});
|
|
const current = ref.current;
|
|
if (current ? !current : ref6.current) {
|
|
ref6.current(r5);
|
|
}
|
|
ref.current = false;
|
|
}, [callback6, eventEmitter, state]);
|
|
const callback11 = useCallback((a0) => {}, []);
|
|
const Provider = ScheduleUpdateContext.Provider;
|
|
if (onUnhandledAction == null) {
|
|
onUnhandledAction = callback11;
|
|
}
|
|
const r182 = <Module1503.Provider value={memo}>
|
|
<Provider value={memo3}>
|
|
<Module1502.Provider value={memo2}>
|
|
<Module1494.Provider value={memo4}>
|
|
<Module1505.Provider value={onUnhandledAction}>
|
|
<EnsureSingleNavigator>{children}</EnsureSingleNavigator>
|
|
</Module1505.Provider>
|
|
</Module1494.Provider>
|
|
</Module1502.Provider>
|
|
</Provider>
|
|
</Module1503.Provider>;
|
|
return independent ? <Module1507.Provider value={void 0}>
|
|
<Module1508.Provider value={void 0}>{r182}</Module1508.Provider>
|
|
</Module1507.Provider> : r182;
|
|
});
|