UNPKG

repoweaver

Version:

A GitHub App that skillfully weaves multiple templates together to create and update repositories with intelligent merge strategies

1 lines 17.6 kB
{"ast":null,"code":"\"use strict\";\n\nimport _defineProperty from \"@babel/runtime/helpers/defineProperty\";\nimport _objectWithoutProperties from \"@babel/runtime/helpers/objectWithoutProperties\";\nvar _excluded = [\"emit\"];\nfunction ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }\nfunction _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }\nimport { CommonActions } from '@react-navigation/routers';\nimport * as React from 'react';\nimport { NavigationBuilderContext } from \"./NavigationBuilderContext.js\";\nexport function useNavigationCache(_ref) {\n var state = _ref.state,\n getState = _ref.getState,\n navigation = _ref.navigation,\n _setOptions = _ref.setOptions,\n router = _ref.router,\n emitter = _ref.emitter;\n var _React$useContext = React.useContext(NavigationBuilderContext),\n stackRef = _React$useContext.stackRef;\n var base = React.useMemo(function () {\n var emit = navigation.emit,\n rest = _objectWithoutProperties(navigation, _excluded);\n var actions = _objectSpread(_objectSpread({}, router.actionCreators), CommonActions);\n var dispatch = function dispatch() {\n throw new Error('Actions cannot be dispatched from a placeholder screen.');\n };\n var helpers = Object.keys(actions).reduce(function (acc, name) {\n acc[name] = dispatch;\n return acc;\n }, {});\n return _objectSpread(_objectSpread(_objectSpread({}, rest), helpers), {}, {\n addListener: function addListener() {\n return function () {};\n },\n removeListener: function removeListener() {},\n dispatch: dispatch,\n getParent: function getParent(id) {\n if (id !== undefined && id === rest.getId()) {\n return base;\n }\n return rest.getParent(id);\n },\n setOptions: function setOptions() {\n throw new Error('Options cannot be set from a placeholder screen.');\n },\n isFocused: function isFocused() {\n return false;\n }\n });\n }, [navigation, router.actionCreators]);\n var cache = React.useMemo(function () {\n return {\n current: {}\n };\n }, [base, getState, navigation, _setOptions, emitter]);\n cache.current = state.routes.reduce(function (acc, route) {\n var previous = cache.current[route.key];\n if (previous) {\n acc[route.key] = previous;\n } else {\n var _dispatch = function dispatch(thunk) {\n var action = typeof thunk === 'function' ? thunk(getState()) : thunk;\n if (action != null) {\n navigation.dispatch(_objectSpread({\n source: route.key\n }, action));\n }\n };\n var withStack = function withStack(callback) {\n var isStackSet = false;\n try {\n if (process.env.NODE_ENV !== 'production' && stackRef && !stackRef.current) {\n stackRef.current = new Error().stack;\n isStackSet = true;\n }\n callback();\n } finally {\n if (isStackSet && stackRef) {\n stackRef.current = undefined;\n }\n }\n };\n var actions = _objectSpread(_objectSpread({}, router.actionCreators), CommonActions);\n var helpers = Object.keys(actions).reduce(function (acc, name) {\n acc[name] = function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n return withStack(function () {\n return (_dispatch(actions[name].apply(actions, args))\n );\n });\n };\n return acc;\n }, {});\n acc[route.key] = _objectSpread(_objectSpread(_objectSpread(_objectSpread({}, base), helpers), emitter.create(route.key)), {}, {\n dispatch: function dispatch(thunk) {\n return withStack(function () {\n return _dispatch(thunk);\n });\n },\n getParent: function getParent(id) {\n if (id !== undefined && id === base.getId()) {\n return acc[route.key];\n }\n return base.getParent(id);\n },\n setOptions: function setOptions(options) {\n _setOptions(function (o) {\n return _objectSpread(_objectSpread({}, o), {}, _defineProperty({}, route.key, _objectSpread(_objectSpread({}, o[route.key]), options)));\n });\n },\n isFocused: function isFocused() {\n var state = base.getState();\n if (state.routes[state.index].key !== route.key) {\n return false;\n }\n return navigation ? navigation.isFocused() : true;\n }\n });\n }\n return acc;\n }, {});\n return {\n base: base,\n navigations: cache.current\n };\n}","map":{"version":3,"names":["CommonActions","React","NavigationBuilderContext","useNavigationCache","_ref","state","getState","navigation","setOptions","router","emitter","_React$useContext","useContext","stackRef","base","useMemo","emit","rest","_objectWithoutProperties","_excluded","actions","_objectSpread","actionCreators","dispatch","Error","helpers","Object","keys","reduce","acc","name","addListener","removeListener","getParent","id","undefined","getId","isFocused","cache","current","routes","route","previous","key","thunk","action","source","withStack","callback","isStackSet","process","env","NODE_ENV","stack","_len","arguments","length","args","Array","_key","apply","create","options","o","_defineProperty","index","navigations"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@react-navigation/core/src/useNavigationCache.tsx"],"sourcesContent":["import {\n CommonActions,\n type NavigationAction,\n type NavigationState,\n type ParamListBase,\n type Router,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport { NavigationBuilderContext } from './NavigationBuilderContext';\nimport type { NavigationHelpers, NavigationProp } from './types';\nimport type { NavigationEventEmitter } from './useEventEmitter';\n\ntype Options<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends Record<string, any>,\n> = {\n state: State;\n getState: () => State;\n navigation: NavigationHelpers<ParamListBase> &\n Partial<NavigationProp<ParamListBase, string, any, any, any>>;\n setOptions: (\n cb: (\n options: Record<string, ScreenOptions>\n ) => Record<string, ScreenOptions>\n ) => void;\n router: Router<State, NavigationAction>;\n emitter: NavigationEventEmitter<EventMap>;\n};\n\ntype NavigationItem<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends Record<string, any>,\n> = NavigationProp<\n ParamListBase,\n string,\n string | undefined,\n State,\n ScreenOptions,\n EventMap\n>;\n\ntype NavigationCache<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends Record<string, any>,\n> = Record<string, NavigationItem<State, ScreenOptions, EventMap>>;\n\n/**\n * Hook to cache navigation objects for each screen in the navigator.\n * It's important to cache them to make sure navigation objects don't change between renders.\n * This lets us apply optimizations like `React.memo` to minimize re-rendering screens.\n */\nexport function useNavigationCache<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends Record<string, any>,\n ActionHelpers extends Record<string, () => void>,\n>({\n state,\n getState,\n navigation,\n setOptions,\n router,\n emitter,\n}: Options<State, ScreenOptions, EventMap>) {\n const { stackRef } = React.useContext(NavigationBuilderContext);\n\n const base = React.useMemo((): NavigationItem<\n State,\n ScreenOptions,\n EventMap\n > &\n ActionHelpers => {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { emit, ...rest } = navigation;\n\n const actions = {\n ...router.actionCreators,\n ...CommonActions,\n };\n\n const dispatch = () => {\n throw new Error(\n 'Actions cannot be dispatched from a placeholder screen.'\n );\n };\n\n const helpers = Object.keys(actions).reduce<Record<string, () => void>>(\n (acc, name) => {\n acc[name] = dispatch;\n\n return acc;\n },\n {}\n ) as ActionHelpers;\n\n return {\n ...rest,\n ...helpers,\n addListener: () => {\n // Event listeners are not supported for placeholder screens\n\n return () => {\n // Empty function\n };\n },\n removeListener: () => {\n // Event listeners are not supported for placeholder screens\n },\n dispatch,\n getParent: (id?: string) => {\n if (id !== undefined && id === rest.getId()) {\n return base;\n }\n\n return rest.getParent(id);\n },\n setOptions: () => {\n throw new Error('Options cannot be set from a placeholder screen.');\n },\n isFocused: () => false,\n };\n }, [navigation, router.actionCreators]);\n\n // Cache object which holds navigation objects for each screen\n // We use `React.useMemo` instead of `React.useRef` coz we want to invalidate it when deps change\n // In reality, these deps will rarely change, if ever\n const cache = React.useMemo(\n () => ({ current: {} as NavigationCache<State, ScreenOptions, EventMap> }),\n // eslint-disable-next-line react-hooks/exhaustive-deps\n [base, getState, navigation, setOptions, emitter]\n );\n\n cache.current = state.routes.reduce<\n NavigationCache<State, ScreenOptions, EventMap>\n >((acc, route) => {\n const previous = cache.current[route.key];\n\n type Thunk =\n | NavigationAction\n | ((state: State) => NavigationAction | null | undefined);\n\n if (previous) {\n // If a cached navigation object already exists, reuse it\n acc[route.key] = previous;\n } else {\n const dispatch = (thunk: Thunk) => {\n const action = typeof thunk === 'function' ? thunk(getState()) : thunk;\n\n if (action != null) {\n navigation.dispatch({ source: route.key, ...action });\n }\n };\n\n const withStack = (callback: () => void) => {\n let isStackSet = false;\n\n try {\n if (\n process.env.NODE_ENV !== 'production' &&\n stackRef &&\n !stackRef.current\n ) {\n // Capture the stack trace for devtools\n stackRef.current = new Error().stack;\n isStackSet = true;\n }\n\n callback();\n } finally {\n if (isStackSet && stackRef) {\n stackRef.current = undefined;\n }\n }\n };\n\n const actions = {\n ...router.actionCreators,\n ...CommonActions,\n };\n\n const helpers = Object.keys(actions).reduce<Record<string, () => void>>(\n (acc, name) => {\n acc[name] = (...args: any) =>\n withStack(() =>\n // @ts-expect-error: name is a valid key, but TypeScript is dumb\n dispatch(actions[name](...args))\n );\n\n return acc;\n },\n {}\n );\n\n acc[route.key] = {\n ...base,\n ...helpers,\n // FIXME: too much work to fix the types for now\n ...(emitter.create(route.key) as any),\n dispatch: (thunk: Thunk) => withStack(() => dispatch(thunk)),\n getParent: (id?: string) => {\n if (id !== undefined && id === base.getId()) {\n // If the passed id is the same as the current navigation id,\n // we return the cached navigation object for the relevant route\n return acc[route.key];\n }\n\n return base.getParent(id);\n },\n setOptions: (options: object) => {\n setOptions((o) => ({\n ...o,\n [route.key]: { ...o[route.key], ...options },\n }));\n },\n isFocused: () => {\n const state = base.getState();\n\n if (state.routes[state.index].key !== route.key) {\n return false;\n }\n\n // If the current screen is focused, we also need to check if parent navigator is focused\n // This makes sure that we return the focus state in the whole tree, not just this navigator\n return navigation ? navigation.isFocused() : true;\n },\n };\n }\n\n return acc;\n }, {});\n\n return {\n base,\n navigations: cache.current,\n };\n}\n"],"mappings":";;;;;;;AAAA,SACEA,aAAa,QAKR,2BAA2B;AAClC,OAAO,KAAKC,KAAK,MAAM,OAAO;AAE9B,SAASC,wBAAwB;AA8CjC,OAAO,SAASC,kBAAkBA,CAAAC,IAAA,EAYU;EAAA,IAN1CC,KAAK,G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