UNPKG

repoweaver

Version:

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

1 lines 19.3 kB
{"ast":null,"code":"\"use strict\";\n\nimport _objectWithoutPropertiesLoose from \"@babel/runtime/helpers/objectWithoutPropertiesLoose\";\nfunction _toPropertyKey(t) { var i = _toPrimitive(t, \"string\"); return \"symbol\" == typeof i ? i : i + \"\"; }\nfunction _toPrimitive(t, r) { if (\"object\" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || \"default\"); if (\"object\" != typeof i) return i; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (\"string\" === r ? String : Number)(t); }\nimport * as React from 'react';\nimport { NavigationBuilderContext } from \"./NavigationBuilderContext.js\";\nimport { NavigationContext } from \"./NavigationContext.js\";\nimport { NavigationRouteContext } from \"./NavigationRouteContext.js\";\nimport { SceneView } from \"./SceneView.js\";\nimport { ThemeContext } from \"./theming/ThemeContext.js\";\nimport { useNavigationCache } from \"./useNavigationCache.js\";\nimport { useRouteCache } from \"./useRouteCache.js\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport function useDescriptors({\n state,\n screens,\n navigation,\n screenOptions,\n screenLayout,\n onAction,\n getState,\n setState,\n addListener,\n addKeyedListener,\n onRouteFocus,\n router,\n emitter\n}) {\n const theme = React.useContext(ThemeContext);\n const [options, setOptions] = React.useState({});\n const {\n onDispatchAction,\n onOptionsChange,\n scheduleUpdate,\n flushUpdates,\n stackRef\n } = React.useContext(NavigationBuilderContext);\n const context = React.useMemo(() => ({\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n scheduleUpdate,\n flushUpdates,\n stackRef\n }), [navigation, onAction, addListener, addKeyedListener, onRouteFocus, onDispatchAction, onOptionsChange, scheduleUpdate, flushUpdates, stackRef]);\n const {\n base,\n navigations\n } = useNavigationCache({\n state,\n getState,\n navigation,\n setOptions,\n router,\n emitter\n });\n const routes = useRouteCache(state.routes);\n const getOptions = (route, navigation, overrides) => {\n const config = screens[route.name];\n const screen = config.props;\n const optionsList = [screenOptions, ...(config.options ? config.options.filter(Boolean) : []), screen.options, overrides];\n return optionsList.reduce((acc, curr) => Object.assign(acc, typeof curr !== 'function' ? curr : curr({\n route,\n navigation,\n theme\n })), {});\n };\n const render = (route, navigation, customOptions, routeState) => {\n const config = screens[route.name];\n const screen = config.props;\n const clearOptions = () => setOptions(o => {\n if (route.key in o) {\n const _route$key = route.key,\n rest = _objectWithoutPropertiesLoose(o, [_route$key].map(_toPropertyKey));\n return rest;\n }\n return o;\n });\n const layout = screen.layout ?? config.layout ?? screenLayout;\n let element = _jsx(SceneView, {\n navigation: navigation,\n route: route,\n screen: screen,\n routeState: routeState,\n getState: getState,\n setState: setState,\n options: customOptions,\n clearOptions: clearOptions\n });\n if (layout != null) {\n element = layout({\n route,\n navigation,\n options: customOptions,\n theme,\n children: element\n });\n }\n return _jsx(NavigationBuilderContext.Provider, {\n value: context,\n children: _jsx(NavigationContext.Provider, {\n value: navigation,\n children: _jsx(NavigationRouteContext.Provider, {\n value: route,\n children: element\n })\n })\n }, route.key);\n };\n const descriptors = routes.reduce((acc, route, i) => {\n const navigation = navigations[route.key];\n const customOptions = getOptions(route, navigation, options[route.key]);\n const element = render(route, navigation, customOptions, state.routes[i].state);\n acc[route.key] = {\n route,\n navigation,\n render() {\n return element;\n },\n options: customOptions\n };\n return acc;\n }, {});\n const describe = (route, placeholder) => {\n if (!placeholder) {\n if (!(route.key in descriptors)) {\n throw new Error(`Couldn't find a route with the key ${route.key}.`);\n }\n return descriptors[route.key];\n }\n const navigation = base;\n const customOptions = getOptions(route, navigation, {});\n const element = render(route, navigation, customOptions, undefined);\n return {\n route,\n navigation,\n render() {\n return element;\n },\n options: customOptions\n };\n };\n return {\n describe,\n descriptors\n };\n}","map":{"version":3,"names":["React","NavigationBuilderContext","NavigationContext","NavigationRouteContext","SceneView","ThemeContext","useNavigationCache","useRouteCache","jsx","_jsx","useDescriptors","state","screens","navigation","screenOptions","screenLayout","onAction","getState","setState","addListener","addKeyedListener","onRouteFocus","router","emitter","theme","useContext","options","setOptions","useState","onDispatchAction","onOptionsChange","scheduleUpdate","flushUpdates","stackRef","context","useMemo","base","navigations","routes","getOptions","route","overrides","config","name","screen","props","optionsList","filter","Boolean","reduce","acc","curr","Object","assign","render","customOptions","routeState","clearOptions","o","key","_route$key","rest","_objectWithoutPropertiesLoose","map","_toPropertyKey","layout","element","children","Provider","value","descriptors","i","describe","placeholder","Error","undefined"],"sources":["/Users/pmouli/Documents/GitHub.nosync/boots-strapper/mobile/node_modules/@react-navigation/core/src/useDescriptors.tsx"],"sourcesContent":["import type {\n NavigationAction,\n NavigationState,\n ParamListBase,\n PartialState,\n Router,\n} from '@react-navigation/routers';\nimport * as React from 'react';\n\nimport {\n type AddKeyedListener,\n type AddListener,\n NavigationBuilderContext,\n} from './NavigationBuilderContext';\nimport { NavigationContext } from './NavigationContext';\nimport { NavigationRouteContext } from './NavigationRouteContext';\nimport { SceneView } from './SceneView';\nimport { ThemeContext } from './theming/ThemeContext';\nimport type {\n Descriptor,\n EventMapBase,\n NavigationHelpers,\n NavigationProp,\n RouteConfig,\n RouteProp,\n} from './types';\nimport type { NavigationEventEmitter } from './useEventEmitter';\nimport { useNavigationCache } from './useNavigationCache';\nimport { useRouteCache } from './useRouteCache';\n\nexport type ScreenConfigWithParent<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase,\n> = {\n keys: (string | undefined)[];\n options: (ScreenOptionsOrCallback<ScreenOptions> | undefined)[] | undefined;\n layout: ScreenLayout<ScreenOptions> | undefined;\n props: RouteConfig<\n ParamListBase,\n string,\n State,\n ScreenOptions,\n EventMap,\n unknown\n >;\n};\n\ntype ScreenLayout<ScreenOptions extends {}> = (props: {\n route: RouteProp<ParamListBase, string>;\n options: ScreenOptions;\n navigation: any;\n theme: ReactNavigation.Theme;\n children: React.ReactElement;\n}) => React.ReactElement;\n\ntype ScreenOptionsOrCallback<ScreenOptions extends {}> =\n | ScreenOptions\n | ((props: {\n route: RouteProp<ParamListBase, string>;\n navigation: any;\n theme: ReactNavigation.Theme;\n }) => ScreenOptions);\n\ntype Options<\n State extends NavigationState,\n ScreenOptions extends {},\n EventMap extends EventMapBase,\n> = {\n state: State;\n screens: Record<\n string,\n ScreenConfigWithParent<State, ScreenOptions, EventMap>\n >;\n navigation: NavigationHelpers<ParamListBase>;\n screenOptions: ScreenOptionsOrCallback<ScreenOptions> | undefined;\n screenLayout: ScreenLayout<ScreenOptions> | undefined;\n onAction: (action: NavigationAction) => boolean;\n getState: () => State;\n setState: (state: State) => void;\n addListener: AddListener;\n addKeyedListener: AddKeyedListener;\n onRouteFocus: (key: string) => void;\n router: Router<State, NavigationAction>;\n emitter: NavigationEventEmitter<EventMap>;\n};\n\n/**\n * Hook to create descriptor objects for the child routes.\n *\n * A descriptor object provides 3 things:\n * - Helper method to render a screen\n * - Options specified by the screen for the navigator\n * - Navigation object intended for the route\n */\nexport function useDescriptors<\n State extends NavigationState,\n ActionHelpers extends Record<string, () => void>,\n ScreenOptions extends {},\n EventMap extends EventMapBase,\n>({\n state,\n screens,\n navigation,\n screenOptions,\n screenLayout,\n onAction,\n getState,\n setState,\n addListener,\n addKeyedListener,\n onRouteFocus,\n router,\n emitter,\n}: Options<State, ScreenOptions, EventMap>) {\n const theme = React.useContext(ThemeContext);\n const [options, setOptions] = React.useState<Record<string, ScreenOptions>>(\n {}\n );\n const {\n onDispatchAction,\n onOptionsChange,\n scheduleUpdate,\n flushUpdates,\n stackRef,\n } = React.useContext(NavigationBuilderContext);\n\n const context = React.useMemo(\n () => ({\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n scheduleUpdate,\n flushUpdates,\n stackRef,\n }),\n [\n navigation,\n onAction,\n addListener,\n addKeyedListener,\n onRouteFocus,\n onDispatchAction,\n onOptionsChange,\n scheduleUpdate,\n flushUpdates,\n stackRef,\n ]\n );\n\n const { base, navigations } = useNavigationCache<\n State,\n ScreenOptions,\n EventMap,\n ActionHelpers\n >({\n state,\n getState,\n navigation,\n setOptions,\n router,\n emitter,\n });\n\n const routes = useRouteCache(state.routes);\n\n const getOptions = (\n route: RouteProp<ParamListBase, string>,\n navigation: NavigationProp<\n ParamListBase,\n string,\n string | undefined,\n State,\n ScreenOptions,\n EventMap\n >,\n overrides: Record<string, ScreenOptions>\n ) => {\n const config = screens[route.name];\n const screen = config.props;\n\n const optionsList = [\n // The default `screenOptions` passed to the navigator\n screenOptions,\n // The `screenOptions` props passed to `Group` elements\n ...((config.options\n ? config.options.filter(Boolean)\n : []) as ScreenOptionsOrCallback<ScreenOptions>[]),\n // The `options` prop passed to `Screen` elements,\n screen.options,\n // The options set via `navigation.setOptions`\n overrides,\n ];\n\n return optionsList.reduce<ScreenOptions>(\n (acc, curr) =>\n Object.assign(\n acc,\n // @ts-expect-error: we check for function but TS still complains\n typeof curr !== 'function' ? curr : curr({ route, navigation, theme })\n ),\n {} as ScreenOptions\n );\n };\n\n const render = (\n route: RouteProp<ParamListBase, string>,\n navigation: NavigationProp<\n ParamListBase,\n string,\n string | undefined,\n State,\n ScreenOptions,\n EventMap\n >,\n customOptions: ScreenOptions,\n routeState: NavigationState | PartialState<NavigationState> | undefined\n ) => {\n const config = screens[route.name];\n const screen = config.props;\n\n const clearOptions = () =>\n setOptions((o) => {\n if (route.key in o) {\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n const { [route.key]: _, ...rest } = o;\n return rest;\n }\n\n return o;\n });\n\n const layout =\n // The `layout` prop passed to `Screen` elements,\n screen.layout ??\n // The `screenLayout` props passed to `Group` elements\n config.layout ??\n // The default `screenLayout` passed to the navigator\n screenLayout;\n\n let element = (\n <SceneView\n navigation={navigation}\n route={route}\n screen={screen}\n routeState={routeState}\n getState={getState}\n setState={setState}\n options={customOptions}\n clearOptions={clearOptions}\n />\n );\n\n if (layout != null) {\n element = layout({\n route,\n navigation,\n options: customOptions,\n // @ts-expect-error: in practice `theme` will be defined\n theme,\n children: element,\n });\n }\n\n return (\n <NavigationBuilderContext.Provider key={route.key} value={context}>\n <NavigationContext.Provider value={navigation}>\n <NavigationRouteContext.Provider value={route}>\n {element}\n </NavigationRouteContext.Provider>\n </NavigationContext.Provider>\n </NavigationBuilderContext.Provider>\n );\n };\n\n const descriptors = routes.reduce<\n Record<\n string,\n Descriptor<\n ScreenOptions,\n NavigationProp<\n ParamListBase,\n string,\n string | undefined,\n State,\n ScreenOptions,\n EventMap\n > &\n ActionHelpers,\n RouteProp<ParamListBase>\n >\n >\n >((acc, route, i) => {\n const navigation = navigations[route.key];\n const customOptions = getOptions(route, navigation, options[route.key]);\n const element = render(\n route,\n navigation,\n customOptions,\n state.routes[i].state\n );\n\n acc[route.key] = {\n route,\n // @ts-expect-error: it's missing action helpers, fix later\n navigation,\n render() {\n return element;\n },\n options: customOptions as ScreenOptions,\n };\n\n return acc;\n }, {});\n\n /**\n * Create a descriptor object for a route.\n *\n * @param route Route object for which the descriptor should be created\n * @param placeholder Whether the descriptor should be a placeholder, e.g. for a route not yet in the state\n * @returns Descriptor object\n */\n const describe = (route: RouteProp<ParamListBase>, placeholder: boolean) => {\n if (!placeholder) {\n if (!(route.key in descriptors)) {\n throw new Error(`Couldn't find a route with the key ${route.key}.`);\n }\n\n return descriptors[route.key];\n }\n\n const navigation = base;\n const customOptions = getOptions(route, navigation, {});\n const element = render(route, navigation, customOptions, undefined);\n\n return {\n route,\n navigation,\n render() {\n return element;\n },\n options: customOptions as ScreenOptions,\n };\n };\n\n return {\n describe,\n descriptors,\n };\n}\n"],"mappings":";;;;;AAOA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAE9B,SAGEC,wBAAwB;AAE1B,SAASC,iBAAiB;AAC1B,SAASC,sBAAsB;AAC/B,SAASC,SAAS;AAClB,SAASC,YAAY;AAUrB,SAASC,kBAAkB;AAC3B,SAASC,aAAa;AAA0B,SAAAC,GAAA,IA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